Modified Arduino library for ICM_20948 IMU for Nucleo boards

Committer:
saloutos
Date:
Mon Jan 31 03:25:31 2022 +0000
Revision:
0:894b603d32ee
modified ICM_20948 Arduino library for Nucleo boards

Who changed what in which revision?

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