Deep linux driver series: Examples of the high-pass analysis of the three sensor architecture (ADSP Detailed report data, the calibration procedure Detailed) [turn]

This article reprinted from: https://blog.csdn.net/radianceblau/article/details/76180915

This series of navigation:

Deep linux driver series: One example of a high-pass analysis sensor architecture (+ AP whole overview side code analysis)

linux driver series Deep: Qualcomm sensor architecture analysis example bis (ADSP driver code structure)
linux driver Deep series: Examples of the high-pass analysis of the three sensor architecture (ADSP Detailed report data, the calibration procedure Detailed)


The method of obtaining data from adsp divided into synchronous, or asynchronous mode, an asynchronous mode is generally used in practical use, because the synchronization data can be retrieved by blocking smgr low speed peripheral bus problems, reduce efficiency, increase in power consumption.

 

Sensor reported data is divided into the following categories

sync synchronization reporting data (each data reports a)

asynchronous reporting async data, each following a request is not blocked, the timing view status, (i.e., receives a report)

self-scheduling asynchronous data reported, after each request does not block, interrupt or wait state timing of view, (i.e., it receives a report)

Asynchronous FIFO data reports, each request a set of data, the sensor data is accumulated when the set level, a set of data reporting is triggered by the interrupt level.

S4S (Synchronization for Sensors) used to synchronize the clock, to avoid missing data or the same data is extracted twice

 

To sum up into three ways in actual use:

1, (Polling) 0x00 synchronous manner [sync]: smgr request to the sensor data, block waiting for arrival of data back; asynchronous [async]: After calling a get_data start timer, and the like timer interrupt call sns_ddf_driver_if_s arrived specified handle_timer ( ) a set of sensor data reporting function. handle_timer () generally used sns_ddf_smgr_notify_data ddf provided () function to report the data.

2, (DRI) 0x80 also known as [self-scheduling] call enable_sched_data () Enable DRI (DataReadyInterrupt, the data complete interrupt) until the data is completed or interrupted to start a timer designated according set_cycle_time ODR (Output Data Rate, the data output rate) for data acquisition, the acquisition is complete after the call sns_ddf_driver_if_s specified handle_irq () function to report sensor data.

3, (FIFO) 0xD0 call trigger_fifo_data () function to start FIFO mode, when the data reaches the specified threshold, triggering sns_ddf_smgr_data_notify () function reports the number of data.

(Handle_irq-> report_data-> sns_ddf_smgr_notify_data report data)

 Usually the amount of data accelerometer, a gyroscope and other large FIFO mode is used, light, distance data changes only need to be reported using the DRI sensor mode.

 

Below an example g-sensor bmi160 specific analysis:

sns_ddf_driver_if_s SNS_DD_IF_BMI160 =
{

.init = & sns_dd_bmi160_init,

.get_data = & sns_dd_bmi160_get_data,

.set_attrib = & sns_dd_bmi160_set_attr,

.get_attrib = & sns_dd_bmi160_get_attr,

.handle_timer = & sns_dd_bmi160_handle_timer,

.handle_irq = & sns_dd_bmi160_interrupt_handler,

.reset = & sns_dd_bmi160_reset,

.run_test = & sns_dd_bmi160_self_test,

.enable_sched_data = & sns_dd_bmi160_enable_sched_data,

. Probe = & sns_dd_bmi160_probe,

.trigger_fifo_data = & sns_dd_bmi160_trigger_fifo_data
};
this structure is the key to high-pass adsp the sensor driven implementation, the driver need only implement the corresponding function, then a structure pointer filled into a smgr_sensor_fn_ptr_map table will be registered in the system.

Careful observation of the function of the above-described structure is found in some functions, such as file sns_dd_xxxx.c sns_dd_bmi160_init, while others, such as the file in sns_dd_xxxx_uimg.c & sns_dd_bmi160_get_data, this is actually a high-pass side adsp codes unique architecture, i.e., having uimg identification code running in the cache, wherein the code data is generally reported related work done, during operation of the sensor can be operated in an external closed ddr lowest power; umig during code runs with no need to identify the open ddr where do some initialization code is generally related work.

 

The following list of sensor types number Qualcomm platform with an overall understanding.
enum typedef
{
SNS_DDF_SENSOR__NONE, // 0
SNS_DDF_SENSOR_ACCEL, //. 1
SNS_DDF_SENSOR_MAG, // 2
SNS_DDF_SENSOR_GYRO, //. 3
SNS_DDF_SENSOR_TEMP, //. 4
SNS_DDF_SENSOR_PROXIMITY, //. 5
SNS_DDF_SENSOR_AMBIENT, //. 6
SNS_DDF_SENSOR_PRESSURE, //. 7
SNS_DDF_SENSOR_MAG_6D, //. 8
SNS_DDF_SENSOR_GYRO_6D, . 9 //
SNS_DDF_SENSOR_DOUBLETAP, // 10
SNS_DDF_SENSOR_SINGLETAP, //. 11
SNS_DDF_SENSOR_IR_GESTURE, // 12 is
SNS_DDF_SENSOR_OEM_SENSOR_01, // 13 is
SNS_DDF_SENSOR_OEM_SENSOR_02, // 14
SNS_DDF_SENSOR_OEM_SENSOR_03, // 15
SNS_DDF_SENSOR_OEM_SENSOR_04, // 16
SNS_DDF_SENSOR_OEM_SENSOR_05, // 17
SNS_DDF_SENSOR_OEM_SENSOR_06, // 18
SNS_DDF_SENSOR_OEM_SENSOR_07, // 19
SNS_DDF_SENSOR_OEM_SENSOR_08, // 20
SNS_DDF_SENSOR_OEM_SENSOR_09, // 21
SNS_DDF_SENSOR_OEM_SENSOR_10, // 22
SNS_DDF_SENSOR_STEP_EVENT, // 23
SNS_DDF_SENSOR_STEP_COUNT, // 24
SNS_DDF_SENSOR_SMD, // 25
SNS_DDF_SENSOR_GAME_RV, // 26
SNS_DDF_SENSOR_HUMIDITY, // 27
SNS_DDF_SENSOR_RGB, // 28
SNS_DDF_SENSOR_CT_C, // 29
SNS_DDF_SENSOR_SAR, // 30
SNS_DDF_SENSOR_HALL_EFFECT, // 31
SNS_DDF_SENSOR_AMBIENT_TEMP, // 32
SNS_DDF_SENSOR_ULTRA_VIOLET, // 33
SNS_DDF_SENSOR_HEART_RATE, //34
SNS_DDF_SENSOR_HEART_RATE_RAW, // 35
SNS_DDF_SENSOR_OBJECT_TEMP, // 36
SNS_DDF_SENSOR_TILT_EVENT, // 37 [
SNS_DDF_SENSOR_ORIENTATION_EVENT, // 38 is

SNS_DDF_SENSOR__ALL, / ** <* Addresses All Sensors /
SNS_DDF_SENSOR_LAST
} sns_ddf_sensor_e;
before watching particular data flow, first look at the various definitions Qualcomm sensor configuration attributes for

typedef enum
{
SNS_DDF_ATTRIB_POWER_INFO,//0
SNS_DDF_ATTRIB_POWER_STATE,//1
SNS_DDF_ATTRIB_DELAYS,//2
SNS_DDF_ATTRIB_RANGE,//3
SNS_DDF_ATTRIB_RESOLUTION_ADC,//4
SNS_DDF_ATTRIB_RESOLUTION,//5
SNS_DDF_ATTRIB_LOWPASS,//6
SNS_DDF_ATTRIB_MOTION_DETECT,//7
SNS_DDF_ATTRIB_DRIVER_INFO,//8
SNS_DDF_ATTRIB_DEVICE_INFO,//9
SNS_DDF_ATTRIB_THRESHOLD,//10
SNS_DDF_ATTRIB_ACCURACY,//11
SNS_DDF_ATTRIB_BIAS,//12
SNS_DDF_ATTRIB_ODR,//13
SNS_DDF_ATTRIB_SUPPORTED_ODR_LIST,//14
SNS_DDF_ATTRIB_REGISTRY_GROUP,//15
SNS_DDF_ATTRIB_IO_REGISTER,//16
SNS_DDF_ATTRIB_FIFO,//17
SNS_DDF_ATTRIB_ODR_TOLERANCE,//18
SNS_DDF_ATTRIB_FILTER_DELAY//19

} sns_ddf_attribute_e;


Initialization process

1,probe

2,init

3,get_attr

SNS_DDF_ATTRIB_RESOLUTION_ADC

SNS_DDF_ATTRIB_LOWPASS,

SNS_DDF_ATTRIB_ODR,

SNS_DDF_ATTRIB_SUPPORTED_ODR_LIST,

SNS_DDF_ATTRIB_FIFO,

SNS_DDF_ATTRIB_DEVICE_INFO,

SNS_DDF_ATTRIB_POWER_INFO,

SNS_DDF_ATTRIB_RESOLUTION,

SNS_DDF_ATTRIB_RANGE,

4,reset

 

FIFO mode when the power button press process

1,reset

2, set_attr properties provided SNS_DDF_ATTRIB_POWER_INFO

SNS_DDF_ATTRIB_RANGE,

SNS_DDF_ATTRIB_ODR,

SNS_DDF_ATTRIB_FILTER_DELAY

SNS_DDF_ATTRIB_FIFO

  

FIFO mode data reporting process

enable_sched_data

reset

handle_timer

interrupt_handler

handle_irq_attach_temp

 

interrupt_handler

handle_irq_attach_temp

...

 DRI pattern data reporting process

reset

set_attr

enable_sched_data

reset

handle_timer

interrupt_handler

handle_irq_drdy

handle_irq_attach_temp

 

interrupt_handler

handle_irq_drdy

handle_irq_attach_temp

...

 

 POLLING pattern data reporting process

1,reset

2,get_data

3, handle_timer

4,get_data

5,get_data

...

 

 

Calibration Process

Finally, look at the sensor calibration process, because of differences in the consistency of the device, each machine in the factory need to be calibrated. Achieve calibration process is as follows:

 

1, the calibration app like SSC (high-pass sensor controller abbreviation) calibration request issued

2, ssc call sns_ddf_driver_if_s sensor drive structure specified function run_test

3, run_test SNS_DDF_TEST_OEM function mode wherein data is calculated from a plurality of bias current machine calibration mode, and stored.

/ **
* Factory's Tests.
* /
Typedef enum
{
SNS_DDF_TEST_SELF, / ** <Self Test. * /
SNS_DDF_TEST_IRQ, / ** <Interrupt Test. * /
SNS_DDF_TEST_CONNECTIVITY, / ** <Basic Connectivity Test. * /
SNS_DDF_TEST_SELF_HW, / * . * <Hardware Self Test * /
. SNS_DDF_TEST_SELF_SW, / ** <Software Self Test * /
. SNS_DDF_TEST_OEM / ** <Test the OEM * /

} sns_ddf_test_e;
. 4, ssc and then calls Get SNS_DDF_ATTRIB_BIAS get_attr properties, get the calibration value of the last calibration data stored in the /persist/sensor/sns.reg
5, after the initialization SSC sns.reg are each read from the file to the current value of the sensor bias

6, we each calibrated sensor reading get_Data data, the raw data are acquired and calculates the bias value, so as to return to the upper layer data after calibration.

Guess you like

Origin www.cnblogs.com/zzb-Dream-90Time/p/10963720.html