Sensor Hub 初探

核心定义结构:hardware/libhardware/include/hardware/sensors.h

  sensor_type 类型定义:

    1、#define SENSOR_TYPE_ACCELEROMETER

    2、#define SENSOR_TYPE_GEOMAGNETIC_FIELD

    3、#define SENSOR_TYPE_ORIENTATION

  结构体:

    1、struct sensors_vec_t // sensor event data

    2、struct uncalibrated_event_t //无标定事件,uncalibrated gyroscope and magnetometer event data

    3、struct meta_data_event // meta data event data

    4、struct heart_rate_event_t   //心跳频率

    5、struct sensors_event_t  // union of the various types of sensor data that can be returned

    6、struct sensors_module_t //every hardware module must have a data structure named HAL_MODULE_INFO_SYM

    7、struct sensor_t  // the detail info of a sensor

    8、struct sensors_poll_device_t // it is used with SENSORS_DEVICE_API_VERSION_0_1

    9、struct sensors_poll_device_1  // it is compatible with sensors_poll_device_t. it is used in HAL versions >= SENSORS_DEVICE_API_VERSION_1_0

 

  函数:  (convenience API for opening and closing a device)

    1、sensors_open()  

    2、sensors_close()

    3、sensors_open_1()

    4、sensors_close_1()

 

 

Android does not define how the different physical sensors are connected to the system on chip (SoC).

Often, sensor chips are connected to the SoC through a sensor hub, allowing some low-power monitoring and processing of the data.

Often, Inter-Integrated Circuit (I2C) or Serial Peripheral Interface (SPI) is used as the transport mechanism.

 

Android sensors provide data as a series of sensor events.

Each event contains:

  • a handle to the sensor that generated it
  • the timestamp at which the event was detected or measured
  • and some data

 

Control flows from the applications down to the sensors, and data flows from the sensors up to the applications.

 

 Sensor Stack

  SDK:

    Applications access sensors through the Sensors SDK (Software Development Kit) API. The SDK contains functions to list available sensors and to register to a sensor.

    the application specifies its preferred sampling frequency and its latency requirements. //指定采样频率和延迟请求

  Framework:

    The framework is in charge of linking the several applications to the HAL.  //管理应用程序链接到HAL层

    When a first application registers to a sensor, the framework sends a request to the HAL to activate the sensor. //第一个注册或绑定该sensor

    When the last application registered to one sensor unregisters from it, the frameworks sends a request to the HAL to deactivate the sensor so power is not consumed unnecessarily.  //应用解绑时,deactivity,使之省电

  Impact of multiplexing: //复用的影响

    当多个application 对于同一个sensor,设置不同的sampling frequency时,sensor实际采样是以最快的为准。同时,设置比较慢的application也会收到 快速的rate。

    相对应的,latency也以最短的算。 //即 采样频率以最快的算,延迟时间以最短的算。

    There is no mechanism to send data down from the applications to the sensors or their drivers. This ensures one application cannot modify the behavior of the sensors, breaking other applications. //

  

  Sensor fusion

    

  JNI

    The framework uses a Java Native Interface (JNI) associated with android.hardware and located in the frameworks/base/core/jni/ directory. This code calls the lower level native code to obtain access to the sensor hardware.

  Native Framework:

    The native framework calls the Binder IPC proxies to obtain access to sensor-specific services.

 

 

 

   

 

posted @ 2015-03-19 10:58  zyliang  阅读(3155)  评论(0编辑  收藏  举报