JeVois  1.22
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
Loading...
Searching...
No Matches
ICM_20948_DMP.h
Go to the documentation of this file.
1/*
2
3This file contains a useful c translation of the DMP register map
4
5*/
6
7#ifndef _ICM_20948_DMP_H_
8#define _ICM_20948_DMP_H_
9
10#include <stdint.h>
11
12#ifdef __cplusplus
13extern "C"
14{
15#endif /* __cplusplus */
16
17#define DMP_START_ADDRESS ((unsigned short)0x1000)
18#define DMP_MEM_BANK_SIZE 256
19#define DMP_LOAD_START 0x90
20
21#define CFG_FIFO_SIZE (4222)
22
23// AGB0_REG_DMP_INT_STATUS bit definitions
24#define BIT_WAKE_ON_MOTION_INT 0x08
25#define BIT_MSG_DMP_INT 0x0002
26#define BIT_MSG_DMP_INT_0 0x0100 // CI Command
27
28#define BIT_MSG_DMP_INT_2 0x0200 // CIM Command - SMD
29#define BIT_MSG_DMP_INT_3 0x0400 // CIM Command - Pedometer
30
31#define BIT_MSG_DMP_INT_4 0x1000 // CIM Command - Pedometer binning
32#define BIT_MSG_DMP_INT_5 0x2000 // CIM Command - Bring To See Gesture
33#define BIT_MSG_DMP_INT_6 0x4000 // CIM Command - Look To See Gesture
34
35// Appendix I: DMP register addresses
36
37// data output control
38#define DATA_OUT_CTL1 (4 * 16) // 16-bit: Data output control 1 register : configure DMP to output required data
39#define DATA_OUT_CTL2 (4 * 16 + 2) // 16-bit: Data output control 2 register : configure the BM, accel/gyro/compass accuracy and gesture such as Pick-up
40#define DATA_INTR_CTL (4 * 16 + 12) // 16-bit: Determines which sensors can generate interrupt according to bit map defined for DATA_OUT_CTL1
41#define FIFO_WATERMARK (31 * 16 + 14) // 16-bit: DMP will send FIFO interrupt if FIFO count > FIFO watermark. FIFO watermark is set to 80% of actual FIFO size by default
42
43// motion event control
44#define MOTION_EVENT_CTL (4 * 16 + 14) // 16-bit: configure DMP for Android L and Invensense specific features
45
46// indicates to DMP which sensors are available
47/* 1: gyro samples available
48 2: accel samples available
49 8: secondary compass samples available */
50#define DATA_RDY_STATUS (8 * 16 + 10) // 16-bit: indicates to DMP which sensors are available
51
52// batch mode
53#define BM_BATCH_CNTR (27 * 16) // 32-bit: Batch counter
54#define BM_BATCH_THLD (19 * 16 + 12) // 32-bit: Batch mode threshold
55#define BM_BATCH_MASK (21 * 16 + 14) // 16-bit
56
57// sensor output data rate: all 16-bit
58#define ODR_ACCEL (11 * 16 + 14) // ODR_ACCEL Register for accel ODR
59#define ODR_GYRO (11 * 16 + 10) // ODR_GYRO Register for gyro ODR
60#define ODR_CPASS (11 * 16 + 6) // ODR_CPASS Register for compass ODR
61#define ODR_ALS (11 * 16 + 2) // ODR_ALS Register for ALS ODR
62#define ODR_QUAT6 (10 * 16 + 12) // ODR_QUAT6 Register for 6-axis quaternion ODR
63#define ODR_QUAT9 (10 * 16 + 8) // ODR_QUAT9 Register for 9-axis quaternion ODR
64#define ODR_PQUAT6 (10 * 16 + 4) // ODR_PQUAT6 Register for 6-axis pedometer quaternion ODR
65#define ODR_GEOMAG (10 * 16 + 0) // ODR_GEOMAG Register for Geomag rv ODR
66#define ODR_PRESSURE (11 * 16 + 12) // ODR_PRESSURE Register for pressure ODR
67#define ODR_GYRO_CALIBR (11 * 16 + 8) // ODR_GYRO_CALIBR Register for calibrated gyro ODR
68#define ODR_CPASS_CALIBR (11 * 16 + 4) // ODR_CPASS_CALIBR Register for calibrated compass ODR
69
70// sensor output data rate counter: all 16-bit
71#define ODR_CNTR_ACCEL (9 * 16 + 14) // ODR_CNTR_ACCEL Register for accel ODR counter
72#define ODR_CNTR_GYRO (9 * 16 + 10) // ODR_CNTR_GYRO Register for gyro ODR counter
73#define ODR_CNTR_CPASS (9 * 16 + 6) // ODR_CNTR_CPASS Register for compass ODR counter
74#define ODR_CNTR_ALS (9 * 16 + 2) // ODR_CNTR_ALS Register for ALS ODR counter
75#define ODR_CNTR_QUAT6 (8 * 16 + 12) // ODR_CNTR_QUAT6 Register for 6-axis quaternion ODR counter
76#define ODR_CNTR_QUAT9 (8 * 16 + 8) // ODR_CNTR_QUAT9 Register for 9-axis quaternion ODR counter
77#define ODR_CNTR_PQUAT6 (8 * 16 + 4) // ODR_CNTR_PQUAT6 Register for 6-axis pedometer quaternion ODR counter
78#define ODR_CNTR_GEOMAG (8 * 16 + 0) // ODR_CNTR_GEOMAG Register for Geomag rv ODR counter
79#define ODR_CNTR_PRESSURE (9 * 16 + 12) // ODR_CNTR_PRESSURE Register for pressure ODR counter
80#define ODR_CNTR_GYRO_CALIBR (9 * 16 + 8) // ODR_CNTR_GYRO_CALIBR Register for calibrated gyro ODR counter
81#define ODR_CNTR_CPASS_CALIBR (9 * 16 + 4) // ODR_CNTR_CPASS_CALIBR Register for calibrated compass ODR counter
82
83// mounting matrix: all 32-bit
84#define CPASS_MTX_00 (23 * 16) // Compass mount matrix and scale
85#define CPASS_MTX_01 (23 * 16 + 4) // Compass mount matrix and scale
86#define CPASS_MTX_02 (23 * 16 + 8) // Compass mount matrix and scale
87#define CPASS_MTX_10 (23 * 16 + 12) // Compass mount matrix and scale
88#define CPASS_MTX_11 (24 * 16) // Compass mount matrix and scale
89#define CPASS_MTX_12 (24 * 16 + 4) // Compass mount matrix and scale
90#define CPASS_MTX_20 (24 * 16 + 8) // Compass mount matrix and scale
91#define CPASS_MTX_21 (24 * 16 + 12) // Compass mount matrix and scale
92#define CPASS_MTX_22 (25 * 16) // Compass mount matrix and scale
93
94// bias calibration: all 32-bit
95// The biases are 32-bits in chip frame in hardware unit scaled by:
96// 2^12 (FSR 4g) for accel, 2^15 for gyro, in uT scaled by 2^16 for compass.
97#define GYRO_BIAS_X (139 * 16 + 4)
98#define GYRO_BIAS_Y (139 * 16 + 8)
99#define GYRO_BIAS_Z (139 * 16 + 12)
100#define ACCEL_BIAS_X (110 * 16 + 4)
101#define ACCEL_BIAS_Y (110 * 16 + 8)
102#define ACCEL_BIAS_Z (110 * 16 + 12)
103#define CPASS_BIAS_X (126 * 16 + 4)
104#define CPASS_BIAS_Y (126 * 16 + 8)
105#define CPASS_BIAS_Z (126 * 16 + 12)
106
107#define GYRO_ACCURACY (138 * 16 + 2)
108#define GYRO_BIAS_SET (138 * 16 + 6)
109#define GYRO_LAST_TEMPR (134 * 16)
110#define GYRO_SLOPE_X (78 * 16 + 4)
111#define GYRO_SLOPE_Y (78 * 16 + 8)
112#define GYRO_SLOPE_Z (78 * 16 + 12)
113
114// parameters for accel calibration
115#define ACCEL_ACCURACY (97 * 16)
116#define ACCEL_CAL_RESET (77 * 16)
117#define ACCEL_VARIANCE_THRESH (93 * 16)
118#define ACCEL_CAL_RATE (94 * 16 + 4) // 16-bit: 0 (225Hz, 112Hz, 56Hz)
119#define ACCEL_PRE_SENSOR_DATA (97 * 16 + 4)
120#define ACCEL_COVARIANCE (101 * 16 + 8)
121#define ACCEL_ALPHA_VAR (91 * 16) // 32-bit: 1026019965 (225Hz) 977872018 (112Hz) 882002213 (56Hz)
122#define ACCEL_A_VAR (92 * 16) // 32-bit: 47721859 (225Hz) 95869806 (112Hz) 191739611 (56Hz)
123#define ACCEL_CAL_INIT (94 * 16 + 2)
124#define ACCEL_CAL_SCALE_COVQ_IN_RANGE (194 * 16)
125#define ACCEL_CAL_SCALE_COVQ_OUT_RANGE (195 * 16)
126#define ACCEL_CAL_TEMPERATURE_SENSITIVITY (194 * 16 + 4)
127#define ACCEL_CAL_TEMPERATURE_OFFSET_TRIM (194 * 16 + 12)
128
129#define CPASS_ACCURACY (37 * 16)
130#define CPASS_BIAS_SET (34 * 16 + 14)
131#define MAR_MODE (37 * 16 + 2)
132#define CPASS_COVARIANCE (115 * 16)
133#define CPASS_COVARIANCE_CUR (118 * 16 + 8)
134#define CPASS_REF_MAG_3D (122 * 16)
135#define CPASS_CAL_INIT (114 * 16)
136#define CPASS_EST_FIRST_BIAS (113 * 16)
137#define MAG_DISTURB_STATE (113 * 16 + 2)
138#define CPASS_VAR_COUNT (112 * 16 + 6)
139#define CPASS_COUNT_7 (87 * 16 + 2)
140#define CPASS_MAX_INNO (124 * 16)
141#define CPASS_BIAS_OFFSET (113 * 16 + 4)
142#define CPASS_CUR_BIAS_OFFSET (114 * 16 + 4)
143#define CPASS_PRE_SENSOR_DATA (87 * 16 + 4)
144
145// Compass Cal params to be adjusted according to sampling rate
146#define CPASS_TIME_BUFFER (112 * 16 + 14)
147#define CPASS_RADIUS_3D_THRESH_ANOMALY (112 * 16 + 8)
148
149#define CPASS_STATUS_CHK (25 * 16 + 12)
150
151// gains
152#define ACCEL_FB_GAIN (34 * 16)
153#define ACCEL_ONLY_GAIN (16 * 16 + 12) // 32-bit: 15252014 (225Hz) 30504029 (112Hz) 61117001 (56Hz)
154#define GYRO_SF (19 * 16) // 32-bit: gyro scaling factor
155
156// 9-axis
157#define MAGN_THR_9X (80 * 16)
158#define MAGN_LPF_THR_9X (80 * 16 + 8)
159#define QFB_THR_9X (80 * 16 + 12)
160
161// DMP running counter
162#define DMPRATE_CNTR (18 * 16 + 4)
163
164// pedometer
165#define PEDSTD_BP_B (49 * 16 + 12)
166#define PEDSTD_BP_A4 (52 * 16)
167#define PEDSTD_BP_A3 (52 * 16 + 4)
168#define PEDSTD_BP_A2 (52 * 16 + 8)
169#define PEDSTD_BP_A1 (52 * 16 + 12)
170#define PEDSTD_SB (50 * 16 + 8)
171#define PEDSTD_SB_TIME (50 * 16 + 12)
172#define PEDSTD_PEAKTHRSH (57 * 16 + 8)
173#define PEDSTD_TIML (50 * 16 + 10)
174#define PEDSTD_TIMH (50 * 16 + 14)
175#define PEDSTD_PEAK (57 * 16 + 4)
176#define PEDSTD_STEPCTR (54 * 16)
177#define PEDSTD_STEPCTR2 (58 * 16 + 8)
178#define PEDSTD_TIMECTR (60 * 16 + 4)
179#define PEDSTD_DECI (58 * 16)
180#define PEDSTD_SB2 (60 * 16 + 14)
181#define STPDET_TIMESTAMP (18 * 16 + 8)
182#define PEDSTEP_IND (19 * 16 + 4)
183#define PED_Y_RATIO (17 * 16 + 0)
184
185// SMD
186#define SMD_VAR_TH (141 * 16 + 12)
187#define SMD_VAR_TH_DRIVE (143 * 16 + 12)
188#define SMD_DRIVE_TIMER_TH (143 * 16 + 8)
189#define SMD_TILT_ANGLE_TH (179 * 16 + 12)
190#define BAC_SMD_ST_TH (179 * 16 + 8)
191#define BAC_ST_ALPHA4 (180 * 16 + 12)
192#define BAC_ST_ALPHA4A (176 * 16 + 12)
193
194// Wake on Motion
195#define WOM_ENABLE (64 * 16 + 14)
196#define WOM_STATUS (64 * 16 + 6)
197#define WOM_THRESHOLD_DMP (64 * 16) // Renamed by PaulZC to avoid duplication with the Bank 2 Reg 0x13
198#define WOM_CNTR_TH (64 * 16 + 12)
199
200// Activity Recognition
201#define BAC_RATE (48 * 16 + 10)
202#define BAC_STATE (179 * 16 + 0)
203#define BAC_STATE_PREV (179 * 16 + 4)
204#define BAC_ACT_ON (182 * 16 + 0)
205#define BAC_ACT_OFF (183 * 16 + 0)
206#define BAC_STILL_S_F (177 * 16 + 0)
207#define BAC_RUN_S_F (177 * 16 + 4)
208#define BAC_DRIVE_S_F (178 * 16 + 0)
209#define BAC_WALK_S_F (178 * 16 + 4)
210#define BAC_SMD_S_F (178 * 16 + 8)
211#define BAC_BIKE_S_F (178 * 16 + 12)
212#define BAC_E1_SHORT (146 * 16 + 0)
213#define BAC_E2_SHORT (146 * 16 + 4)
214#define BAC_E3_SHORT (146 * 16 + 8)
215#define BAC_VAR_RUN (148 * 16 + 12)
216#define BAC_TILT_INIT (181 * 16 + 0)
217#define BAC_MAG_ON (225 * 16 + 0)
218#define BAC_PS_ON (74 * 16 + 0)
219#define BAC_BIKE_PREFERENCE (173 * 16 + 8)
220#define BAC_MAG_I2C_ADDR (229 * 16 + 8)
221#define BAC_PS_I2C_ADDR (75 * 16 + 4)
222#define BAC_DRIVE_CONFIDENCE (144 * 16 + 0)
223#define BAC_WALK_CONFIDENCE (144 * 16 + 4)
224#define BAC_SMD_CONFIDENCE (144 * 16 + 8)
225#define BAC_BIKE_CONFIDENCE (144 * 16 + 12)
226#define BAC_STILL_CONFIDENCE (145 * 16 + 0)
227#define BAC_RUN_CONFIDENCE (145 * 16 + 4)
228#define BAC_MODE_CNTR (150 * 16)
229#define BAC_STATE_T_PREV (185 * 16 + 4)
230#define BAC_ACT_T_ON (184 * 16 + 0)
231#define BAC_ACT_T_OFF (184 * 16 + 4)
232#define BAC_STATE_WRDBS_PREV (185 * 16 + 8)
233#define BAC_ACT_WRDBS_ON (184 * 16 + 8)
234#define BAC_ACT_WRDBS_OFF (184 * 16 + 12)
235#define BAC_ACT_ON_OFF (190 * 16 + 2)
236#define PREV_BAC_ACT_ON_OFF (188 * 16 + 2)
237#define BAC_CNTR (48 * 16 + 2)
238
239// Flip/Pick-up
240#define FP_VAR_ALPHA (245 * 16 + 8)
241#define FP_STILL_TH (246 * 16 + 4)
242#define FP_MID_STILL_TH (244 * 16 + 8)
243#define FP_NOT_STILL_TH (246 * 16 + 8)
244#define FP_VIB_REJ_TH (241 * 16 + 8)
245#define FP_MAX_PICKUP_T_TH (244 * 16 + 12)
246#define FP_PICKUP_TIMEOUT_TH (248 * 16 + 8)
247#define FP_STILL_CONST_TH (246 * 16 + 12)
248#define FP_MOTION_CONST_TH (240 * 16 + 8)
249#define FP_VIB_COUNT_TH (242 * 16 + 8)
250#define FP_STEADY_TILT_TH (247 * 16 + 8)
251#define FP_STEADY_TILT_UP_TH (242 * 16 + 12)
252#define FP_Z_FLAT_TH_MINUS (243 * 16 + 8)
253#define FP_Z_FLAT_TH_PLUS (243 * 16 + 12)
254#define FP_DEV_IN_POCKET_TH (76 * 16 + 12)
255#define FP_PICKUP_CNTR (247 * 16 + 4)
256#define FP_RATE (240 * 16 + 12)
257
258// Gyro FSR
259#define GYRO_FULLSCALE (72 * 16 + 12)
260
261// Accel FSR
262// The DMP scales accel raw data internally to align 1g as 2^25.
263// To do this and output hardware unit again as configured FSR, write 0x4000000 to ACC_SCALE DMP register, and write 0x40000 to ACC_SCALE2 DMP register.
264#define ACC_SCALE (30 * 16 + 0) // 32-bit: Write accel scaling value for internal use
265#define ACC_SCALE2 (79 * 16 + 4) // 32-bit: Write accel scaling down value
266
267// EIS authentication
268#define EIS_AUTH_INPUT (160 * 16 + 4)
269#define EIS_AUTH_OUTPUT (160 * 16 + 0)
270
271// B2S
272#define B2S_RATE (48 * 16 + 8)
273
274// B2S mounting matrix
275#define B2S_MTX_00 (208 * 16)
276#define B2S_MTX_01 (208 * 16 + 4)
277#define B2S_MTX_02 (208 * 16 + 8)
278#define B2S_MTX_10 (208 * 16 + 12)
279#define B2S_MTX_11 (209 * 16)
280#define B2S_MTX_12 (209 * 16 + 4)
281#define B2S_MTX_20 (209 * 16 + 8)
282#define B2S_MTX_21 (209 * 16 + 12)
283#define B2S_MTX_22 (210 * 16)
284
285// Dmp3 orientation parameters (Q30) initialization
286#define Q0_QUAT6 (33 * 16 + 0)
287#define Q1_QUAT6 (33 * 16 + 4)
288#define Q2_QUAT6 (33 * 16 + 8)
289#define Q3_QUAT6 (33 * 16 + 12)
290
292 {
293 DMP_ODR_Reg_Accel = ODR_ACCEL, // ODR_ACCEL Register for accel ODR
294 DMP_ODR_Reg_Gyro = ODR_GYRO, // ODR_GYRO Register for gyro ODR
295 DMP_ODR_Reg_Cpass = ODR_CPASS, // ODR_CPASS Register for compass ODR
296 DMP_ODR_Reg_ALS = ODR_ALS, // ODR_ALS Register for ALS ODR
297 DMP_ODR_Reg_Quat6 = ODR_QUAT6, // ODR_QUAT6 Register for 6-axis quaternion ODR
298 DMP_ODR_Reg_Quat9 = ODR_QUAT9, // ODR_QUAT9 Register for 9-axis quaternion ODR
299 DMP_ODR_Reg_PQuat6 = ODR_PQUAT6, // ODR_PQUAT6 Register for 6-axis pedometer quaternion ODR
300 DMP_ODR_Reg_Geomag = ODR_GEOMAG, // ODR_GEOMAG Register for Geomag RV ODR
301 DMP_ODR_Reg_Pressure = ODR_PRESSURE, // ODR_PRESSURE Register for pressure ODR
302 DMP_ODR_Reg_Gyro_Calibr = ODR_GYRO_CALIBR, // ODR_GYRO_CALIBR Register for calibrated gyro ODR
303 DMP_ODR_Reg_Cpass_Calibr = ODR_CPASS_CALIBR // ODR_CPASS_CALIBR Register for calibrated compass ODR
304 };
305
306 /** @brief Sensor identifier for control function
307 */
333
334 /* enum for android sensor*/
336 {
360
383
389 SETUP, // 50
391 };
392
393// Determines which base sensor needs to be on based upon ANDROID_SENSORS 0-31
394#define INV_NEEDS_ACCEL_MASK ((1L << 1) | (1L << 3) | (1L << 9) | (1L << 10) | (1L << 11) | (1L << 15) | (1L << 17) | (1L << 18) | (1L << 19) | (1L << 20) | (1L << 23) | (1L << 25) | (1L << 29) | (1L << 30) | (1L << 31))
395#define INV_NEEDS_GYRO_MASK ((1L << 3) | (1L << 4) | (1L << 9) | (1L << 10) | (1L << 11) | (1L << 15) | (1L << 16) | (1L << 25) | (1L << 26) | (1L << 29) | (1L << 30) | (1L << 31))
396#define INV_NEEDS_COMPASS_MASK ((1L << 2) | (1L << 3) | (1L << 11) | (1L << 14) | (1L << 20) | (1L << 24) | (1L << 25) | (1L << 31))
397#define INV_NEEDS_PRESSURE ((1L << 6) | (1L << 28))
398
399// Determines which base sensor needs to be on based upon ANDROID_SENSORS 32-
400#define INV_NEEDS_ACCEL_MASK1 ((1L << 3) | (1L << 5) | (1L << 6) | (1L << 7) | (1L << 9) | (1L << 10)) // I.e. 35, 37, 38, 39, 41, 42
401#define INV_NEEDS_GYRO_MASK1 ((1L << 3) | (1L << 4) | (1L << 11)) // I.e. 35, 36, 43
402#define INV_NEEDS_COMPASS_MASK1 ((1L << 2) | (1L << 7)) // I.e. 34 and 39
403
405 {
406 DMP_Data_ready_Gyro = 0x0001, // Gyro samples available
407 DMP_Data_ready_Accel = 0x0002, // Accel samples available
408 DMP_Data_ready_Secondary_Compass = 0x0008 // Secondary compass samples available
409 };
410
412 {
413 DMP_Data_Output_Control_1_Step_Ind_0 = 0x0001, // Pedometer Step Indicator Bit 0
414 DMP_Data_Output_Control_1_Step_Ind_1 = 0x0002, // Pedometer Step Indicator Bit 1
415 DMP_Data_Output_Control_1_Step_Ind_2 = 0x0004, // Pedometer Step Indicator Bit 2
417 DMP_Data_Output_Control_1_Step_Detector = 0x0010, // Pedometer Step Detector
418 DMP_Data_Output_Control_1_Compass_Calibr = 0x0020, // 32-bit calibrated compass
419 DMP_Data_Output_Control_1_Gyro_Calibr = 0x0040, // 32-bit calibrated gyro
420 DMP_Data_Output_Control_1_Pressure = 0x0080, // 16-bit Pressure
421 DMP_Data_Output_Control_1_Geomag = 0x0100, // 32-bit Geomag rv + heading accuracy
422 DMP_Data_Output_Control_1_PQuat6 = 0x0200, // 16-bit pedometer quaternion
423 DMP_Data_Output_Control_1_Quat9 = 0x0400, // 32-bit 9-axis quaternion + heading accuracy
424 DMP_Data_Output_Control_1_Quat6 = 0x0800, // 32-bit 6-axis quaternion
425 DMP_Data_Output_Control_1_ALS = 0x1000, // 16-bit ALS
426 DMP_Data_Output_Control_1_Compass = 0x2000, // 16-bit compass
427 DMP_Data_Output_Control_1_Gyro = 0x4000, // 16-bit gyro
428 DMP_Data_Output_Control_1_Accel = 0x8000 // 16-bit accel
429 };
430
442
460
477
488
489 typedef struct // DMP Activity Recognition data
490 {
491 uint8_t Drive : 1;
492 uint8_t Walk : 1;
493 uint8_t Run : 1;
494 uint8_t Bike : 1;
495 uint8_t Tilt : 1;
496 uint8_t Still : 1;
497 uint8_t reserved : 2;
499
500 typedef struct // DMP Secondary On/Off data
501 {
502 uint16_t Gyro_Off : 1;
503 uint16_t Gyro_On : 1;
504 uint16_t Compass_Off : 1;
505 uint16_t Compass_On : 1;
506 uint16_t Proximity_Off : 1;
507 uint16_t Proximity_On : 1;
508 uint16_t reserved : 10;
510
511#define icm_20948_DMP_Header_Bytes 2
512#define icm_20948_DMP_Header2_Bytes 2
513#define icm_20948_DMP_Raw_Accel_Bytes 6
514#define icm_20948_DMP_Raw_Gyro_Bytes 6
515#define icm_20948_DMP_Gyro_Bias_Bytes 6
516#define icm_20948_DMP_Compass_Bytes 6
517#define icm_20948_DMP_ALS_Bytes 8
518#define icm_20948_DMP_Quat6_Bytes 12
519#define icm_20948_DMP_Quat9_Bytes 14
520// <-- lcm20948MPUFifoControl.c suggests icm_20948_DMP_Step_Detector_Bytes comes here <--
521#define icm_20948_DMP_PQuat6_Bytes 6
522#define icm_20948_DMP_Geomag_Bytes 14
523#define icm_20948_DMP_Pressure_Bytes 6
524#define icm_20948_DMP_Gyro_Calibr_Bytes 12 // lcm20948MPUFifoControl.c suggests icm_20948_DMP_Gyro_Calibr_Bytes is not supported?
525#define icm_20948_DMP_Compass_Calibr_Bytes 12
526#define icm_20948_DMP_Step_Detector_Bytes 4 // See note above
527#define icm_20948_DMP_Accel_Accuracy_Bytes 2
528#define icm_20948_DMP_Gyro_Accuracy_Bytes 2
529#define icm_20948_DMP_Compass_Accuracy_Bytes 2
530#define icm_20948_DMP_Fsync_Detection_Bytes 2 // lcm20948MPUFifoControl.c suggests icm_20948_DMP_Fsync_Detection_Bytes is not supported?
531#define icm_20948_DMP_Pickup_Bytes 2
532#define icm_20948_DMP_Activity_Recognition_Bytes 6
533#define icm_20948_DMP_Secondary_On_Off_Bytes 2
534#define icm_20948_DMP_Footer_Bytes 2
535#define icm_20948_DMP_Maximum_Bytes 14 // The most bytes we will attempt to read from the FIFO in one go
536
537 typedef struct
538 {
539 uint16_t header;
540 uint16_t header2;
541 union
542 {
544 struct
545 {
546 int16_t X;
547 int16_t Y;
548 int16_t Z;
549 } Data;
550 } Raw_Accel;
551 union
552 {
554 struct
555 {
556 int16_t X;
557 int16_t Y;
558 int16_t Z;
559 int16_t BiasX;
560 int16_t BiasY;
561 int16_t BiasZ;
562 } Data;
563 } Raw_Gyro;
564 union
565 {
566 uint8_t Bytes[icm_20948_DMP_Compass_Bytes];
567 struct
568 {
569 int16_t X;
570 int16_t Y;
571 int16_t Z;
572 } Data;
573 } Compass;
574 uint8_t ALS[icm_20948_DMP_ALS_Bytes]; // Byte[0]: Dummy, Byte[2:1]: Ch0DATA, Byte[4:3]: Ch1DATA, Byte[6:5]: PDATA, Byte[7]: Dummy
575 // The 6-Axis and 9-axis Quaternion outputs each consist of 12 bytes of data.
576 // These 12 bytes in turn consists of three 4-byte elements.
577 // 9-axis quaternion data and Geomag rv is always followed by 2-bytes of heading accuracy, hence the size of Quat9 and Geomag data size in the FIFO is 14 bytes.
578 // Quaternion data for both cases is cumulative/integrated values.
579 // For a given quaternion Q, the ordering of its elements is {Q1, Q2, Q3}.
580 // Each element is represented using Big Endian byte order.
581 // Q0 value is computed from this equation: Q20 + Q21 + Q22 + Q23 = 1.
582 // In case of drift, the sum will not add to 1, therefore, quaternion data need to be corrected with right bias values.
583 // The quaternion data is scaled by 2^30.
584 union
585 {
586 uint8_t Bytes[icm_20948_DMP_Quat6_Bytes];
587 struct
588 {
589 int32_t Q1;
590 int32_t Q2;
591 int32_t Q3;
592 } Data;
593 } Quat6;
594 union
595 {
596 uint8_t Bytes[icm_20948_DMP_Quat9_Bytes];
597 struct
598 {
599 int32_t Q1;
600 int32_t Q2;
601 int32_t Q3;
602 int16_t Accuracy;
603 } Data;
604 } Quat9;
605 union
606 {
607 uint8_t Bytes[icm_20948_DMP_PQuat6_Bytes];
608 struct
609 {
610 int16_t Q1;
611 int16_t Q2;
612 int16_t Q3;
613 } Data;
614 } PQuat6;
615 union
616 {
617 uint8_t Bytes[icm_20948_DMP_Geomag_Bytes];
618 struct
619 {
620 int32_t Q1;
621 int32_t Q2;
622 int32_t Q3;
623 int16_t Accuracy;
624 } Data;
625 } Geomag;
626 uint8_t Pressure[6]; // Byte [2:0]: Pressure data, Byte [5:3]: Temperature data
627 union
628 {
629 uint8_t Bytes[icm_20948_DMP_Gyro_Calibr_Bytes];
630 struct
631 {
632 int32_t X;
633 int32_t Y;
634 int32_t Z;
635 } Data;
636 } Gyro_Calibr; // Hardware unit scaled by 2^15
637 union
638 {
640 struct
641 {
642 int32_t X;
643 int32_t Y;
644 int32_t Z;
645 } Data;
646 } Compass_Calibr; // The unit is uT scaled by 2^16
647 uint32_t Pedometer_Timestamp; // Timestamp as DMP cycle
648 uint16_t Accel_Accuracy; // The accuracy is expressed as 0~3. The lowest is 0 and 3 is the highest.
649 uint16_t Gyro_Accuracy; // The accuracy is expressed as 0~3. The lowest is 0 and 3 is the highest.
650 uint16_t Compass_Accuracy; // The accuracy is expressed as 0~3. The lowest is 0 and 3 is the highest.
651 uint16_t Fsync_Delay_Time; // The data is delay time between Fsync event and the 1st ODR event after Fsync event.
652 uint16_t Pickup; // The value “2” indicates pick up is detected.
653 // Activity Recognition data
654 // The data include Start and End states, and timestamp as DMP cycle.
655 // Byte [0]: State-Start, Byte [1]: State-End, Byte [5:2]: timestamp.
656 // The states are expressed as below.
657 // Drive: 0x01
658 // Walk: 0x02
659 // Run: 0x04
660 // Bike: 0x08
661 // Tilt: 0x10
662 // Still: 0x20
663 union
664 {
666 struct
667 {
670 uint32_t Timestamp;
671 } Data;
672 } Activity_Recognition;
673 // Secondary On/Off data
674 // BAC algorithm requires sensors on/off through FIFO data to detect activities effectively and save power.
675 // The driver is expected to control sensors accordingly.
676 // The data indicates which sensor and on or off as below.
677 // Gyro Off: 0x01
678 // Gyro On: 0x02
679 // Compass Off: 0x04
680 // Compass On: 0x08
681 // Proximity Off: 0x10
682 // Proximity On: 0x20
683 union
684 {
687 } Secondary_On_Off;
688 uint16_t Footer; // Gyro count?
690
691#ifdef __cplusplus
692}
693#endif /* __cplusplus */
694
695#endif /* _ICM_20948_REGISTERS_H_ */
#define icm_20948_DMP_Gyro_Bias_Bytes
#define ODR_PRESSURE
#define icm_20948_DMP_Secondary_On_Off_Bytes
#define ODR_CPASS_CALIBR
DMP_Motion_Event_Control_Register_Bits
@ DMP_Motion_Event_Control_Pedometer_Interrupt
@ DMP_Motion_Event_Control_Significant_Motion_Det
@ DMP_Motion_Event_Control_Bring_Look_To_See
@ DMP_Motion_Event_Control_Compass_Calibr
@ DMP_Motion_Event_Control_BTS
@ DMP_Motion_Event_Control_Accel_Calibr
@ DMP_Motion_Event_Control_Gyro_Calibr
@ DMP_Motion_Event_Control_Pickup
@ DMP_Motion_Event_Control_Activity_Recog_Pedom_Accel
@ DMP_Motion_Event_Control_Tilt_Interrupt
@ DMP_Motion_Event_Control_BAC_Wearable
@ DMP_Motion_Event_Control_9axis
@ DMP_Motion_Event_Control_Geomag
@ DMP_Motion_Event_Control_Activity_Recog_Pedom
#define ODR_QUAT9
#define icm_20948_DMP_Compass_Bytes
#define ODR_ALS
DMP_Data_Output_Control_1_Register_Bits
@ DMP_Data_Output_Control_1_Step_Detector
@ DMP_Data_Output_Control_1_Header2
@ DMP_Data_Output_Control_1_Quat6
@ DMP_Data_Output_Control_1_PQuat6
@ DMP_Data_Output_Control_1_ALS
@ DMP_Data_Output_Control_1_Quat9
@ DMP_Data_Output_Control_1_Accel
@ DMP_Data_Output_Control_1_Pressure
@ DMP_Data_Output_Control_1_Compass_Calibr
@ DMP_Data_Output_Control_1_Gyro
@ DMP_Data_Output_Control_1_Compass
@ DMP_Data_Output_Control_1_Step_Ind_0
@ DMP_Data_Output_Control_1_Step_Ind_1
@ DMP_Data_Output_Control_1_Geomag
@ DMP_Data_Output_Control_1_Gyro_Calibr
@ DMP_Data_Output_Control_1_Step_Ind_2
DMP_Header2_Bitmap
@ DMP_header2_bitmap_Accel_Accuracy
@ DMP_header2_bitmap_Secondary_On_Off
@ DMP_header2_bitmap_Fsync
@ DMP_header2_bitmap_Pickup
@ DMP_header2_bitmap_Gyro_Accuracy
@ DMP_header2_bitmap_Compass_Accuracy
@ DMP_header2_bitmap_Activity_Recog
#define icm_20948_DMP_Quat6_Bytes
#define icm_20948_DMP_Compass_Calibr_Bytes
#define ODR_GYRO
#define ODR_GYRO_CALIBR
#define icm_20948_DMP_Raw_Accel_Bytes
DMP_Header_Bitmap
@ DMP_header_bitmap_Header2
@ DMP_header_bitmap_Quat9
@ DMP_header_bitmap_Pressure
@ DMP_header_bitmap_ALS
@ DMP_header_bitmap_Geomag
@ DMP_header_bitmap_Gyro_Calibr
@ DMP_header_bitmap_Step_Detector
@ DMP_header_bitmap_Quat6
@ DMP_header_bitmap_Accel
@ DMP_header_bitmap_Gyro
@ DMP_header_bitmap_Compass
@ DMP_header_bitmap_PQuat6
@ DMP_header_bitmap_Compass_Calibr
#define ODR_CPASS
#define icm_20948_DMP_Quat9_Bytes
#define ODR_ACCEL
DMP_Data_Ready_Status_Register_Bits
@ DMP_Data_ready_Gyro
@ DMP_Data_ready_Accel
@ DMP_Data_ready_Secondary_Compass
#define icm_20948_DMP_PQuat6_Bytes
ANDROID_SENSORS
@ ANDROID_SENSOR_GYROSCOPE
@ ANDROID_SENSOR_WAKEUP_MAGNETIC_FIELD
@ ANDROID_SENSOR_LINEAR_ACCELERATION
@ ANDROID_SENSOR_PRESSURE
@ ANDROID_SENSOR_WAKEUP_STEP_COUNTER
@ ANDROID_SENSOR_NUM_MAX
@ ANDROID_SENSOR_GRAVITY
@ ANDROID_SENSOR_ACTIVITY_CLASSIFICATON
@ ANDROID_SENSOR_WAKEUP_LINEAR_ACCELERATION
@ ANDROID_SENSOR_GAME_ROTATION_VECTOR
@ ANDROID_SENSOR_WAKEUP_GRAVITY
@ ANDROID_SENSOR_WAKEUP_STEP_DETECTOR
@ ANDROID_SENSOR_WAKEUP_AMBIENT_TEMPERATURE
@ ANDROID_SENSOR_ROTATION_VECTOR
@ ANDROID_SENSOR_RAW_GYROSCOPE
@ ANDROID_SENSOR_META_DATA
@ ANDROID_SENSOR_MAGNETIC_FIELD_UNCALIBRATED
@ ANDROID_SENSOR_RAW_ACCELEROMETER
@ ANDROID_SENSOR_STEP_DETECTOR
@ ANDROID_SENSOR_B2S
@ ANDROID_SENSOR_GYROSCOPE_UNCALIBRATED
@ ANDROID_SENSOR_WAKEUP_PRESSURE
@ ANDROID_SENSOR_ORIENTATION
@ ANDROID_SENSOR_AMBIENT_TEMPERATURE
@ ANDROID_SENSOR_WAKEUP_GYROSCOPE
@ ANDROID_SENSOR_PROXIMITY
@ ANDROID_SENSOR_GEOMAGNETIC_FIELD
@ ANDROID_SENSOR_WAKEUP_ACCELEROMETER
@ ANDROID_SENSOR_WAKEUP_RELATIVE_HUMIDITY
@ ANDROID_SENSOR_HEART_RATE
@ ANDROID_SENSOR_WAKEUP_GEOMAGNETIC_ROTATION_VECTOR
@ ANDROID_SENSOR_GEOMAGNETIC_ROTATION_VECTOR
@ ANDROID_SENSOR_WAKEUP_GAME_ROTATION_VECTOR
@ ANDROID_SENSOR_WAKEUP_SIGNIFICANT_MOTION
@ ANDROID_SENSOR_HUMIDITY
@ ANDROID_SENSOR_WAKEUP_HEART_RATE
@ ANDROID_SENSOR_WAKEUP_ROTATION_VECTOR
@ SELF_TEST
@ ANDROID_SENSOR_WAKEUP_LIGHT
@ ANDROID_SENSOR_WAKEUP_PROXIMITY
@ ANDROID_SENSOR_ACCELEROMETER
@ ANDROID_SENSOR_STEP_COUNTER
@ ANDROID_SENSOR_FLIP_PICKUP
@ ANDROID_SENSOR_WAKEUP_MAGNETIC_FIELD_UNCALIBRATED
@ ANDROID_SENSOR_WAKEUP_TILT_DETECTOR
@ ANDROID_SENSOR_TEMPERATURE
@ SETUP
@ ANDROID_SENSOR_LIGHT
@ ANDROID_SENSOR_WAKEUP_GYROSCOPE_UNCALIBRATED
@ GENERAL_SENSORS_MAX
@ ANDROID_SENSOR_WAKEUP_ORIENTATION
@ ANDROID_SENSOR_SCREEN_ROTATION
DMP_ODR_Registers
@ DMP_ODR_Reg_ALS
@ DMP_ODR_Reg_Pressure
@ DMP_ODR_Reg_Cpass_Calibr
@ DMP_ODR_Reg_Gyro_Calibr
@ DMP_ODR_Reg_Geomag
@ DMP_ODR_Reg_Quat6
@ DMP_ODR_Reg_PQuat6
@ DMP_ODR_Reg_Gyro
@ DMP_ODR_Reg_Accel
@ DMP_ODR_Reg_Cpass
@ DMP_ODR_Reg_Quat9
#define icm_20948_DMP_Gyro_Calibr_Bytes
#define icm_20948_DMP_ALS_Bytes
#define ODR_QUAT6
#define ODR_GEOMAG
#define icm_20948_DMP_Geomag_Bytes
inv_icm20948_sensor
Sensor identifier for control function.
@ INV_ICM20948_SENSOR_FLIP_PICKUP
@ INV_ICM20948_SENSOR_ORIENTATION
@ INV_ICM20948_SENSOR_ACTIVITY_CLASSIFICATON
@ INV_ICM20948_SENSOR_RAW_MAGNETOMETER
@ INV_ICM20948_SENSOR_ACCELEROMETER
@ INV_ICM20948_SENSOR_STEP_COUNTER
@ INV_ICM20948_SENSOR_GEOMAGNETIC_ROTATION_VECTOR
@ INV_ICM20948_SENSOR_GRAVITY
@ INV_ICM20948_SENSOR_GYROSCOPE
@ INV_ICM20948_SENSOR_GYROSCOPE_UNCALIBRATED
@ INV_ICM20948_SENSOR_WAKEUP_TILT_DETECTOR
@ INV_ICM20948_SENSOR_WAKEUP_SIGNIFICANT_MOTION
@ INV_ICM20948_SENSOR_STEP_DETECTOR
@ INV_ICM20948_SENSOR_ROTATION_VECTOR
@ INV_ICM20948_SENSOR_RAW_ACCELEROMETER
@ INV_ICM20948_SENSOR_GEOMAGNETIC_FIELD
@ INV_ICM20948_SENSOR_RAW_GYROSCOPE
@ INV_ICM20948_SENSOR_GAME_ROTATION_VECTOR
@ INV_ICM20948_SENSOR_MAX
@ INV_ICM20948_SENSOR_B2S
@ INV_ICM20948_SENSOR_MAGNETIC_FIELD_UNCALIBRATED
@ INV_ICM20948_SENSOR_LINEAR_ACCELERATION
#define icm_20948_DMP_Raw_Gyro_Bytes
#define icm_20948_DMP_Activity_Recognition_Bytes
#define ODR_PQUAT6
DMP_Data_Output_Control_2_Register_Bits
@ DMP_Data_Output_Control_2_Compass_Accuracy
@ DMP_Data_Output_Control_2_Accel_Accuracy
@ DMP_Data_Output_Control_2_Fsync_Detection
@ DMP_Data_Output_Control_2_Activity_Recognition_BAC
@ DMP_Data_Output_Control_2_Pickup
@ DMP_Data_Output_Control_2_Gyro_Accuracy
@ DMP_Data_Output_Control_2_Batch_Mode_Enable
@ DMP_Data_Output_Control_2_Secondary_On_Off
icm_20948_DMP_Activity_t State_Start
icm_20948_DMP_Secondary_On_Off_t Sensors
icm_20948_DMP_Activity_t State_End