44 #define CHIP_NAME "TDK MPU9250"
45 #define MANUFACTURER_NAME "TDK"
46 #define SUPPLY_VOLTAGE_MIN 2.4f
47 #define SUPPLY_VOLTAGE_MAX 3.6f
48 #define MAX_CURRENT 3.7f
49 #define TEMPERATURE_MIN -40.0f
50 #define TEMPERATURE_MAX 85.0f
51 #define DRIVER_VERSION 1000
56 #define AK8963_IIC_ADDRESS 0x0C
61 #define MPU9250_REG_SELF_TEST_X_GYRO 0x00
62 #define MPU9250_REG_SELF_TEST_Y_GYRO 0x01
63 #define MPU9250_REG_SELF_TEST_Z_GYRO 0x02
64 #define MPU9250_REG_SELF_TEST_X_ACCEL 0x0D
65 #define MPU9250_REG_SELF_TEST_Y_ACCEL 0x0E
66 #define MPU9250_REG_SELF_TEST_Z_ACCEL 0x0F
67 #define MPU9250_REG_XG_OFFSET_H 0x13
68 #define MPU9250_REG_XG_OFFSET_L 0x14
69 #define MPU9250_REG_YG_OFFSET_H 0x15
70 #define MPU9250_REG_YG_OFFSET_L 0x16
71 #define MPU9250_REG_ZG_OFFSET_H 0x17
72 #define MPU9250_REG_ZG_OFFSET_L 0x18
73 #define MPU9250_REG_SMPRT_DIV 0x19
74 #define MPU9250_REG_CONFIG 0x1A
75 #define MPU9250_REG_GYRO_CONFIG 0x1B
76 #define MPU9250_REG_ACCEL_CONFIG 0x1C
77 #define MPU9250_REG_ACCEL_CONFIG2 0x1D
78 #define MPU9250_REG_LP_ACCEL_ODR 0x1E
79 #define MPU9250_REG_WOM_THR 0x1F
80 #define MPU9250_REG_MOTION_DURATION 0x20
81 #define MPU9250_REG_FIFO_EN 0x23
82 #define MPU9250_REG_I2C_MST_CTRL 0x24
83 #define MPU9250_REG_I2C_MST_STATUS 0x36
84 #define MPU9250_REG_I2C_MST_DELAY_CTRL 0x67
85 #define MPU9250_REG_I2C_SLV0_ADDR 0x25
86 #define MPU9250_REG_I2C_SLV0_REG 0x26
87 #define MPU9250_REG_I2C_SLV0_CTRL 0x27
88 #define MPU9250_REG_I2C_SLV0_DO 0x63
89 #define MPU9250_REG_I2C_SLV1_ADDR 0x28
90 #define MPU9250_REG_I2C_SLV1_REG 0x29
91 #define MPU9250_REG_I2C_SLV1_CTRL 0x2A
92 #define MPU9250_REG_I2C_SLV1_DO 0x64
93 #define MPU9250_REG_I2C_SLV2_ADDR 0x2B
94 #define MPU9250_REG_I2C_SLV2_REG 0x2C
95 #define MPU9250_REG_I2C_SLV2_CTRL 0x2D
96 #define MPU9250_REG_I2C_SLV2_DO 0x65
97 #define MPU9250_REG_I2C_SLV3_ADDR 0x2E
98 #define MPU9250_REG_I2C_SLV3_REG 0x2F
99 #define MPU9250_REG_I2C_SLV3_CTRL 0x30
100 #define MPU9250_REG_I2C_SLV3_DO 0x66
101 #define MPU9250_REG_I2C_SLV4_ADDR 0x31
102 #define MPU9250_REG_I2C_SLV4_REG 0x32
103 #define MPU9250_REG_I2C_SLV4_CTRL 0x34
104 #define MPU9250_REG_I2C_SLV4_DO 0x33
105 #define MPU9250_REG_I2C_SLV4_DI 0x35
106 #define MPU9250_REG_EXT_SENS_DATA_00 0x49
107 #define MPU9250_REG_INT_PIN_CFG 0x37
108 #define MPU9250_REG_INT_ENABLE 0x38
109 #define MPU9250_REG_INT_STATUS 0x3A
110 #define MPU9250_REG_ACCEL_XOUT_H 0x3B
111 #define MPU9250_REG_ACCEL_XOUT_L 0x3C
112 #define MPU9250_REG_ACCEL_YOUT_H 0x3D
113 #define MPU9250_REG_ACCEL_YOUT_L 0x3E
114 #define MPU9250_REG_ACCEL_ZOUT_H 0x3F
115 #define MPU9250_REG_ACCEL_ZOUT_L 0x40
116 #define MPU9250_REG_TEMP_OUT_H 0x41
117 #define MPU9250_REG_TEMP_OUT_L 0x42
118 #define MPU9250_REG_GYRO_XOUT_H 0x43
119 #define MPU9250_REG_GYRO_XOUT_L 0x44
120 #define MPU9250_REG_GYRO_YOUT_H 0x45
121 #define MPU9250_REG_GYRO_YOUT_L 0x46
122 #define MPU9250_REG_GYRO_ZOUT_H 0x47
123 #define MPU9250_REG_GYRO_ZOUT_L 0x48
124 #define MPU9250_REG_SIGNAL_PATH_RESET 0x68
125 #define MPU9250_REG_MOT_DETECT_CTRL 0x69
126 #define MPU9250_REG_USER_CTRL 0x6A
127 #define MPU9250_REG_PWR_MGMT_1 0x6B
128 #define MPU9250_REG_PWR_MGMT_2 0x6C
129 #define MPU9250_REG_BANK_SEL 0x6D
130 #define MPU9250_REG_MEM 0x6F
131 #define MPU9250_REG_PROGRAM_START 0x70
132 #define MPU9250_REG_FIFO_COUNTH 0x72
133 #define MPU9250_REG_FIFO_COUNTL 0x73
134 #define MPU9250_REG_R_W 0x74
135 #define MPU9250_REG_WHO_AM_I 0x75
136 #define MPU9250_REG_XA_OFFSET_H 0x77
137 #define MPU9250_REG_XA_OFFSET_L 0x78
138 #define MPU9250_REG_YA_OFFSET_H 0x7A
139 #define MPU9250_REG_YA_OFFSET_L 0x7B
140 #define MPU9250_REG_ZA_OFFSET_H 0x7D
141 #define MPU9250_REG_ZA_OFFSET_L 0x7E
142 #define AK8963_REG_WIA 0x00
143 #define AK8963_REG_INFO 0x01
144 #define AK8963_REG_ST1 0x02
145 #define AK8963_REG_HXL 0x03
146 #define AK8963_REG_HXH 0x04
147 #define AK8963_REG_HYL 0x05
148 #define AK8963_REG_HYH 0x06
149 #define AK8963_REG_HZL 0x07
150 #define AK8963_REG_HZH 0x08
151 #define AK8963_REG_ST2 0x09
152 #define AK8963_REG_CNTL1 0x0A
153 #define AK8963_REG_CNTL2 0x0B
154 #define AK8963_REG_ASTC 0x0C
155 #define AK8963_REG_TS1 0x0D
156 #define AK8963_REG_TS2 0x0E
157 #define AK8963_REG_I2CDIS 0x0F
158 #define AK8963_REG_ASAX 0x10
159 #define AK8963_REG_ASAY 0x11
160 #define AK8963_REG_ASAZ 0x12
165 #define MPU9250_DMP_SAMPLE_RATE 200
166 #define MPU9250_DMP_GYRO_SF (46850825LL * 200 / MPU9250_DMP_SAMPLE_RATE)
167 #define MPU9250_DMP_D_PEDSTD_TIMECTR 964
168 #define MPU9250_DMP_D_PEDSTD_STEPCTR (768 + 0x60)
169 #define MPU9250_DMP_D_1_36 (256 + 36)
170 #define MPU9250_DMP_D_1_40 (256 + 40)
171 #define MPU9250_DMP_D_1_44 (256 + 44)
172 #define MPU9250_DMP_D_1_72 (256 + 72)
173 #define MPU9250_DMP_D_1_79 (256 + 79)
174 #define MPU9250_DMP_D_1_88 (256 + 88)
175 #define MPU9250_DMP_D_1_90 (256 + 90)
176 #define MPU9250_DMP_D_1_92 (256 + 92)
177 #define MPU9250_DMP_D_1_218 (256 + 218)
178 #define MPU9250_DMP_D_0_22 (512 + 22)
179 #define MPU9250_DMP_D_0_104 104
180 #define MPU9250_DMP_TAPW_MIN 478
181 #define MPU9250_DMP_TAP_THX 468
182 #define MPU9250_DMP_TAP_THY 472
183 #define MPU9250_DMP_TAP_THZ 476
184 #define MPU9250_DMP_CFG_6 2753
185 #define MPU9250_DMP_CFG_8 2718
186 #define MPU9250_DMP_CFG_MOTION_BIAS 1208
187 #define MPU9250_DMP_CFG_LP_QUAT 2712
188 #define MPU9250_DMP_CFG_FIFO_ON_EVENT 2690
189 #define MPU9250_DMP_FCFG_1 1062
190 #define MPU9250_DMP_FCFG_2 1066
191 #define MPU9250_DMP_FCFG_3 1088
192 #define MPU9250_DMP_FCFG_7 1073
193 #define MPU9250_DMP_D_EXT_GYRO_BIAS_X (61 * 16)
194 #define MPU9250_DMP_D_EXT_GYRO_BIAS_Y (61 * 16 + 4)
195 #define MPU9250_DMP_D_EXT_GYRO_BIAS_Z (61 * 16 + 8)
196 #define MPU9250_DMP_D_ACCEL_BIAS 660
197 #define MPU9250_DMP_FEATURE_SEND_ANY_GYRO (MPU9250_DMP_FEATURE_SEND_RAW_GYRO | \
198 MPU9250_DMP_FEATURE_SEND_CAL_GYRO)
199 #define MPU9250_DMP_CFG_15 2727
200 #define MPU9250_DMP_CFG_27 2742
201 #define MPU9250_DMP_CFG_GYRO_RAW_DATA 2722
202 #define MPU9250_DMP_CFG_20 2224
203 #define MPU9250_DMP_CFG_ORIENT_INT 1853
204 #define MPU9250_DMP_QUAT_ERROR_THRESH (1L << 24)
205 #define MPU9250_DMP_QUAT_MAG_SQ_NORMALIZED (1L << 28)
206 #define MPU9250_DMP_QUAT_MAG_SQ_MIN (MPU9250_DMP_QUAT_MAG_SQ_NORMALIZED - \
207 MPU9250_DMP_QUAT_ERROR_THRESH)
208 #define MPU9250_DMP_QUAT_MAG_SQ_MAX (MPU9250_DMP_QUAT_MAG_SQ_NORMALIZED + \
209 MPU9250_DMP_QUAT_ERROR_THRESH)
210 #define MPU9250_DMP_INT_SRC_TAP 0x01
211 #define MPU9250_DMP_INT_SRC_ORIENT 0x08
212 #define MPU9250_DMP_TAP_THRESH 250
213 #define MPU9250_DMP_TAP_MIN_TAP_COUNT 1
214 #define MPU9250_DMP_TAP_TIME 100
215 #define MPU9250_DMP_TAP_TIME_MULTI 200
216 #define MPU9250_DMP_SHAKE_REJECT_THRESH 200
217 #define MPU9250_DMP_SHAKE_REJECT_TIME 40
218 #define MPU9250_DMP_SHAKE_REJECT_TIMEOUT 10
223 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
228 static uint16_t gs_st_tb[256] =
230 2620, 2646, 2672, 2699, 2726, 2753, 2781, 2808,
231 2837, 2865, 2894, 2923, 2952, 2981, 3011, 3041,
232 3072, 3102, 3133, 3165, 3196, 3228, 3261, 3293,
233 3326, 3359, 3393, 3427, 3461, 3496, 3531, 3566,
234 3602, 3638, 3674, 3711, 3748, 3786, 3823, 3862,
235 3900, 3939, 3979, 4019, 4059, 4099, 4140, 4182,
236 4224, 4266, 4308, 4352, 4395, 4439, 4483, 4528,
237 4574, 4619, 4665, 4712, 4759, 4807, 4855, 4903,
238 4953, 5002, 5052, 5103, 5154, 5205, 5257, 5310,
239 5363, 5417, 5471, 5525, 5581, 5636, 5693, 5750,
240 5807, 5865, 5924, 5983, 6043, 6104, 6165, 6226,
241 6289, 6351, 6415, 6479, 6544, 6609, 6675, 6742,
242 6810, 6878, 6946, 7016, 7086, 7157, 7229, 7301,
243 7374, 7448, 7522, 7597, 7673, 7750, 7828, 7906,
244 7985, 8065, 8145, 8227, 8309, 8392, 8476, 8561,
245 8647, 8733, 8820, 8909, 8998, 9088, 9178, 9270,
246 9363, 9457, 9551, 9647, 9743, 9841, 9939, 10038,
247 10139, 10240, 10343, 10446, 10550, 10656, 10763, 10870,
248 10979, 11089, 11200, 11312, 11425, 11539, 11654, 11771,
249 11889, 12008, 12128, 12249, 12371, 12495, 12620, 12746,
250 12874, 13002, 13132, 13264, 13396, 13530, 13666, 13802,
251 13940, 14080, 14221, 14363, 14506, 14652, 14798, 14946,
252 15096, 15247, 15399, 15553, 15709, 15866, 16024, 16184,
253 16346, 16510, 16675, 16842, 17010, 17180, 17352, 17526,
254 17701, 17878, 18057, 18237, 18420, 18604, 18790, 18978,
255 19167, 19359, 19553, 19748, 19946, 20145, 20347, 20550,
256 20756, 20963, 21173, 21385, 21598, 21814, 22033, 22253,
257 22475, 22700, 22927, 23156, 23388, 23622, 23858, 24097,
258 24338, 24581, 24827, 25075, 25326, 25579, 25835, 26093,
259 26354, 26618, 26884, 27153, 27424, 27699, 27976, 28255,
260 28538, 28823, 29112, 29403, 29697, 29994, 30294, 30597,
261 30903, 31212, 31524, 31839, 32157, 32479, 32804, 33132,
275 static uint8_t a_mpu9250_read(
mpu9250_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
290 if (handle->
spi_read(reg | 0x80, (uint8_t *)buf, len) != 0)
312 static uint8_t a_mpu9250_write(
mpu9250_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
327 if (handle->
spi_write(reg & (~0x80), (uint8_t *)buf, len) != 0)
348 static uint8_t a_mpu9250_mag_write(
mpu9250_handle_t *handle, uint8_t reg, uint8_t *data)
378 static uint8_t a_mpu9250_mag_read(
mpu9250_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
409 static uint8_t a_mpu9250_write_mem(
mpu9250_handle_t *handle, uint16_t addr, uint8_t *buf, uint16_t len)
413 tmp[0] = (addr >> 8) & 0xFF;
414 tmp[1] = (addr >> 0) & 0xFF;
416 if (tmp[1] + len > 256)
459 static uint8_t a_mpu9250_read_mem(
mpu9250_handle_t *handle, uint16_t addr, uint8_t *buf, uint16_t len)
463 tmp[0] = (addr >> 8) & 0xFF;
464 tmp[1] = (addr >> 0) & 0xFF;
466 if (tmp[1] + len > 256)
515 handle->
debug_print(
"mpu9250: read int enable register failed.\n");
522 handle->
debug_print(
"mpu9250: read fifo enable register failed.\n");
529 handle->
debug_print(
"mpu9250: read user ctrl register failed.\n");
538 handle->
debug_print(
"mpu9250: write int enable register failed.\n");
546 handle->
debug_print(
"mpu9250: write fifo enable register failed.\n");
550 user_ctrl &= ~(1 << 6);
551 user_ctrl &= ~(1 << 7);
554 user_ctrl |= (1 << 2) | (1 << 3);
563 handle->
debug_print(
"mpu9250: write user ctrl register failed.\n");
570 user_ctrl |= (1 << 6) | (1 << 7);
579 handle->
debug_print(
"mpu9250: write user ctrl register failed.\n");
587 handle->
debug_print(
"mpu9250: write int enable register failed.\n");
594 handle->
debug_print(
"mpu9250: write fifo enable register failed.\n");
608 static uint16_t a_mpu9250_inv_row_2_scale(int8_t *row)
650 static uint16_t a_mpu9250_inv_orientation_matrix_to_scalar(int8_t *mtx)
654 scalar = a_mpu9250_inv_row_2_scale(mtx);
655 scalar |= a_mpu9250_inv_row_2_scale(mtx + 3) << 3;
656 scalar |= a_mpu9250_inv_row_2_scale(mtx + 6) << 6;
666 static void a_mpu9250_dmp_decode_gesture(
mpu9250_handle_t *handle, uint8_t gesture[4])
671 orient = gesture[3] & 0xC0;
672 tap = 0x3F & gesture[3];
675 uint8_t direction, count;
677 direction = tap >> 3;
678 count = (tap % 8) + 1;
703 static uint8_t a_mpu9250_accel_self_test(
mpu9250_handle_t *handle, int32_t *bias_regular, int32_t *bias_st)
707 uint8_t otp_value_zero;
709 float accel_st_al_min;
710 float accel_st_al_max;
711 float accel_offset_max;
712 float st_shift_cust[3];
713 float st_shift_ratio[3];
714 float ct_shift_prod[3];
723 for (i = 0; i < 3; i++)
727 ct_shift_prod[i] = (float)gs_st_tb[regs[i] - 1];
728 ct_shift_prod[i] *= 65536.f;
729 ct_shift_prod[i] /= 16384.0f;
733 ct_shift_prod[i] = 0.0f;
737 if (otp_value_zero == 0)
739 for (i = 0; i < 3; i++)
741 st_shift_cust[i] = (float)(bias_st[i] - bias_regular[i]);
742 st_shift_ratio[i] = st_shift_cust[i] / ct_shift_prod[i] - 1.f;
743 if (fabsf(st_shift_ratio[i]) > 0.5f)
751 accel_st_al_min = 0.225f * 65536.f;
752 accel_st_al_max = 0.675f * 65536.f;
753 for (i = 0; i < 3; i++)
755 st_shift_cust[i] = (float)(bias_st[i] - bias_regular[i]);
756 if (st_shift_cust[i] < accel_st_al_min
757 || st_shift_cust[i] > accel_st_al_max)
764 accel_offset_max = 0.5f * 65536.f;
765 for (i = 0; i < 3; i++)
767 if (fabsf((
float)bias_regular[i]) > accel_offset_max)
786 static uint8_t a_mpu9250_gyro_self_test(
mpu9250_handle_t *handle, int32_t *bias_regular, int32_t *bias_st)
790 uint8_t otp_value_zero;
791 float gyro_st_al_max;
792 float gyro_offset_max;
793 float st_shift_cust[3];
794 float st_shift_ratio[3];
795 float ct_shift_prod[3];
805 for (i = 0; i < 3; i++)
809 ct_shift_prod[i] = (float)gs_st_tb[regs[i] - 1];
810 ct_shift_prod[i] *= 65536.f;
811 ct_shift_prod[i] /= 131.0f;
815 ct_shift_prod[i] = 0;
820 if (otp_value_zero == 0)
822 for (i = 0; i < 3; i++)
824 st_shift_cust[i] = (float)(bias_st[i] - bias_regular[i]);
825 st_shift_ratio[i] = st_shift_cust[i] / ct_shift_prod[i];
826 if (fabsf(st_shift_ratio[i]) < 0.5f)
834 gyro_st_al_max = 60.f * 65536.f;
835 for (i = 0; i < 3; i++)
837 st_shift_cust[i] = (float)(bias_st[i] - bias_regular[i]);
838 if (st_shift_cust[i] < gyro_st_al_max)
845 gyro_offset_max = 20.f * 65536.f;
846 for (i = 0; i < 3; i++)
848 if( fabsf((
float)bias_regular[i]) > gyro_offset_max)
869 int32_t gyro_offset[3], int32_t accel_offset[3],
870 uint8_t hw_test_enable)
913 data[0] = 1 << 3 | 1 << 2;
932 if (hw_test_enable != 0)
934 data[0] = 0x00 | 0xE0;
945 if (hw_test_enable != 0)
947 data[0] = 0x18 | 0xE0;
958 if (hw_test_enable != 0)
988 cnt = ((uint16_t)data[0] << 8) | data[1];
997 for (i = 0; i < pack_cnt; i++)
999 int16_t accel_cur[3];
1000 int16_t gyro_cur[3];
1008 accel_cur[0] = ((int16_t)data[0] << 8) | data[1];
1009 accel_cur[1] = ((int16_t)data[2] << 8) | data[3];
1010 accel_cur[2] = ((int16_t)data[4] << 8) | data[5];
1011 accel_offset[0] += (int32_t)accel_cur[0];
1012 accel_offset[1] += (int32_t)accel_cur[1];
1013 accel_offset[2] += (int32_t)accel_cur[2];
1014 gyro_cur[0] = (((int16_t)data[6] << 8) | data[7]);
1015 gyro_cur[1] = (((int16_t)data[8] << 8) | data[9]);
1016 gyro_cur[2] = (((int16_t)data[10] << 8) | data[11]);
1017 gyro_offset[0] += (int32_t)gyro_cur[0];
1018 gyro_offset[1] += (int32_t)gyro_cur[1];
1019 gyro_offset[2] += (int32_t)gyro_cur[2];
1022 gyro_offset[0] = (int32_t)(((int64_t)gyro_offset[0] << 16) / (32768 / 250) / pack_cnt);
1023 gyro_offset[1] = (int32_t)(((int64_t)gyro_offset[1] << 16) / (32768 / 250) / pack_cnt);
1024 gyro_offset[2] = (int32_t)(((int64_t)gyro_offset[2] << 16) / (32768 / 250) / pack_cnt);
1025 accel_offset[0] = (int32_t)(((int64_t)accel_offset[0] << 16) / (32768 / 16) / pack_cnt);
1026 accel_offset[1] = (int32_t)(((int64_t)accel_offset[1] << 16) / (32768 / 16) / pack_cnt);
1027 accel_offset[2] = (int32_t)(((int64_t)accel_offset[2] << 16) / (32768 / 16) / pack_cnt);
1028 if (accel_offset[2] > 0L)
1030 accel_offset[2] -= 65536L;
1034 accel_offset[2] += 65536L;
1092 uint16_t this_write;
1106 handle->
debug_print(
"mpu9250: dmp is running.\n");
1112 for (i = 0; i < size; i += this_write)
1114 this_write =
MIN(16, size - i);
1116 res = a_mpu9250_write_mem(handle, i, (uint8_t *)(gs_mpu9250_dmp_code + i),
1120 handle->
debug_print(
"mpu9250: write mem failed.\n");
1124 res = a_mpu9250_read_mem(handle, i, cur, this_write);
1127 handle->
debug_print(
"mpu9250: read mem failed.\n");
1131 if (memcmp(gs_mpu9250_dmp_code + i, cur, this_write) != 0)
1133 handle->
debug_print(
"mpu9250: code compare error.\n");
1138 tmp[0] = (0x0400 >> 8) & 0xFF;
1139 tmp[1] = (0x0400 >> 0) & 0xFF;
1142 (uint8_t *)tmp, 2) != 0)
1144 handle->
debug_print(
"mpu9250: set program start failed.\n");
1180 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
1186 tmp[0] = (uint8_t)((ms >> 24) & 0xFF);
1187 tmp[1] = (uint8_t)((ms >> 16) & 0xFF);
1188 tmp[2] = (uint8_t)((ms >> 8) & 0xFF);
1189 tmp[3] = (uint8_t)(ms & 0xFF);
1194 handle->
debug_print(
"mpu9250: write mem failed.\n");
1229 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
1237 handle->
debug_print(
"mpu9250: read mem failed.\n");
1241 *ms = (((uint32_t)tmp[0] << 24) | ((uint32_t)tmp[1] << 16) |
1242 ((uint32_t)tmp[2] << 8) | tmp[3]) * 20;
1274 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
1279 tmp[0] = (uint8_t)((count >> 24) & 0xFF);
1280 tmp[1] = (uint8_t)((count >> 16) & 0xFF);
1281 tmp[2] = (uint8_t)((count >> 8) & 0xFF);
1282 tmp[3] = (uint8_t)(count & 0xFF);
1287 handle->
debug_print(
"mpu9250: write mem failed.\n");
1322 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
1330 handle->
debug_print(
"mpu9250: read mem failed.\n");
1334 *count = (((uint32_t)tmp[0] << 24) | ((uint32_t)tmp[1] << 16) |
1335 ((uint32_t)tmp[2] << 8) | tmp[3]);
1367 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
1373 tmp[0] = (ms >> 8) & 0xFF;
1374 tmp[1] = (ms >> 0) & 0xFF;
1379 handle->
debug_print(
"mpu9250: write mem failed.\n");
1414 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
1422 handle->
debug_print(
"mpu9250: read mem failed.\n");
1426 *ms = (uint16_t)((uint16_t)tmp[0] << 8) | tmp[1];
1459 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
1465 tmp[0] = (ms >> 8) & 0xFF;
1466 tmp[1] = (ms >> 0) & 0xFF;
1471 handle->
debug_print(
"mpu9250: write mem failed.\n");
1506 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
1514 handle->
debug_print(
"mpu9250: read mem failed.\n");
1518 *ms = (uint16_t)((uint16_t)tmp[0] << 8) | tmp[1];
1540 uint32_t thresh_scaled;
1552 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
1558 tmp[0] = (uint8_t)(((uint32_t)thresh_scaled >> 24) & 0xFF);
1559 tmp[1] = (uint8_t)(((uint32_t)thresh_scaled >> 16) & 0xFF);
1560 tmp[2] = (uint8_t)(((uint32_t)thresh_scaled >> 8) & 0xFF);
1561 tmp[3] = (uint8_t)((uint32_t)thresh_scaled & 0xFF);
1566 handle->
debug_print(
"mpu9250: write mem failed.\n");
1590 uint32_t thresh_scaled;
1602 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
1610 handle->
debug_print(
"mpu9250: read mem failed.\n");
1614 thresh_scaled = (((uint32_t)tmp[0] << 24) | ((uint32_t)tmp[1] << 16) |
1615 ((uint32_t)tmp[2] << 8) | tmp[3]);
1616 *dps = (uint16_t)((
float)(thresh_scaled) /
1649 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
1655 tmp[0] = (ms >> 8) & 0xFF;
1656 tmp[1] = (ms >> 0) & 0xFF;
1661 handle->
debug_print(
"mpu9250: write mem failed.\n");
1696 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
1704 handle->
debug_print(
"mpu9250: read mem failed.\n");
1708 *ms = (uint16_t)((uint16_t)tmp[0] << 8) | tmp[1];
1741 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
1747 tmp[0] = (ms >> 8) & 0xFF;
1748 tmp[1] = (ms >> 0) & 0xFF;
1753 handle->
debug_print(
"mpu9250: write mem failed.\n");
1788 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
1796 handle->
debug_print(
"mpu9250: read mem failed.\n");
1800 *ms = (uint16_t)((uint16_t)tmp[0] << 8) | tmp[1];
1834 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
1838 if ((cnt < 1) || (cnt > 4))
1840 handle->
debug_print(
"mpu9250: cnt must be between 1 and 4.\n");
1849 handle->
debug_print(
"mpu9250: write mem failed.\n");
1884 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
1892 handle->
debug_print(
"mpu9250: read mem failed.\n");
1927 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
1934 uint8_t regs[9] = {0xb8, 0xaa, 0xb3, 0x8d, 0xb4, 0x98, 0x0d, 0x35, 0x5d};
1939 handle->
debug_print(
"mpu9250: write mem failed.\n");
1949 uint8_t regs[9] = {0xb8, 0xaa, 0xaa, 0xaa, 0xb0, 0x88, 0xc3, 0xc5, 0xc7};
1954 handle->
debug_print(
"mpu9250: write mem failed.\n");
1990 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
1997 uint8_t regs[4] = {0xC0, 0xC2, 0xC4, 0xC6};
2002 handle->
debug_print(
"mpu9250: write mem failed.\n");
2006 res = a_mpu9250_reset_fifo(handle);
2009 handle->
debug_print(
"mpu9250: reset fifo failed.\n");
2019 uint8_t regs[4] = {0x8B, 0x8B, 0x8B, 0x8B};
2024 handle->
debug_print(
"mpu9250: write mem failed.\n");
2028 res = a_mpu9250_reset_fifo(handle);
2031 handle->
debug_print(
"mpu9250: reset fifo failed.\n");
2067 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
2074 uint8_t regs[4] = {0x20, 0x28, 0x30, 0x38};
2079 handle->
debug_print(
"mpu9250: write mem failed.\n");
2083 res = a_mpu9250_reset_fifo(handle);
2086 handle->
debug_print(
"mpu9250: reset fifo failed.\n");
2096 uint8_t regs[4] = {0xA3, 0xA3, 0xA3, 0xA3};
2101 handle->
debug_print(
"mpu9250: write mem failed.\n");
2105 res = a_mpu9250_reset_fifo(handle);
2108 handle->
debug_print(
"mpu9250: reset fifo failed.\n");
2144 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
2151 uint8_t regs_continuous[11] = {0xd8, 0xb1, 0xb9,
2157 (uint8_t *)regs_continuous, 11);
2160 handle->
debug_print(
"mpu9250: write mem failed.\n");
2169 uint8_t regs_gesture[11] = {0xda, 0xb1, 0xb9,
2175 (uint8_t *)regs_gesture, 11);
2178 handle->
debug_print(
"mpu9250: write mem failed.\n");
2203 int32_t gyro_bias_body[3];
2215 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
2220 gyro_bias_body[0] = bias[handle->
orient & 3];
2221 if ((handle->
orient & 4) != 0)
2223 gyro_bias_body[0] *= -1;
2225 gyro_bias_body[1] = bias[(handle->
orient >> 3) & 3];
2226 if ((handle->
orient & 0x20) != 0)
2228 gyro_bias_body[1] *= -1;
2230 gyro_bias_body[2] = bias[(handle->
orient >> 6) & 3];
2231 if ((handle->
orient & 0x100) != 0)
2233 gyro_bias_body[2] *= -1;
2240 regs[0] = (uint8_t)((gyro_bias_body[0] >> 24) & 0xFF);
2241 regs[1] = (uint8_t)((gyro_bias_body[0] >> 16) & 0xFF);
2242 regs[2] = (uint8_t)((gyro_bias_body[0] >> 8) & 0xFF);
2243 regs[3] = (uint8_t)(gyro_bias_body[0] & 0xFF);
2247 handle->
debug_print(
"mpu9250: write mem failed.\n");
2251 regs[0] = (uint8_t)((gyro_bias_body[1] >> 24) & 0xFF);
2252 regs[1] = (uint8_t)((gyro_bias_body[1] >> 16) & 0xFF);
2253 regs[2] = (uint8_t)((gyro_bias_body[1] >> 8) & 0xFF);
2254 regs[3] = (uint8_t)(gyro_bias_body[1] & 0xFF);
2258 handle->
debug_print(
"mpu9250: write mem failed.\n");
2262 regs[0] = (uint8_t)((gyro_bias_body[2] >> 24) & 0xFF);
2263 regs[1] = (uint8_t)((gyro_bias_body[2] >> 16) & 0xFF);
2264 regs[2] = (uint8_t)((gyro_bias_body[2] >> 8) & 0xFF);
2265 regs[3] = (uint8_t)(gyro_bias_body[2] & 0xFF);
2269 handle->
debug_print(
"mpu9250: write mem failed.\n");
2294 int32_t accel_bias_body[3];
2308 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
2316 handle->
debug_print(
"mpu9250: read accelerometer config failed.\n");
2320 range = ((prev >> 3) & 0x3);
2323 accel_sf = (int64_t)16384 << 15;
2325 else if (range == 1)
2327 accel_sf = (int64_t)8192 << 15;
2329 else if (range == 2)
2331 accel_sf = (int64_t)4096 << 15;
2335 accel_sf = (int64_t)2048 << 15;
2338 accel_bias_body[0] = bias[handle->
orient & 3];
2339 if ((handle->
orient & 4) != 0)
2341 accel_bias_body[0] *= -1;
2343 accel_bias_body[1] = bias[(handle->
orient >> 3) & 3];
2344 if ((handle->
orient & 0x20) != 0)
2346 accel_bias_body[1] *= -1;
2348 accel_bias_body[2] = bias[(handle->
orient >> 6) & 3];
2349 if ((handle->
orient & 0x100) != 0)
2351 accel_bias_body[2] *= -1;
2354 accel_bias_body[0] = (int32_t)(((int64_t)accel_bias_body[0] * accel_sf) >> 30);
2355 accel_bias_body[1] = (int32_t)(((int64_t)accel_bias_body[1] * accel_sf) >> 30);
2356 accel_bias_body[2] = (int32_t)(((int64_t)accel_bias_body[2] * accel_sf) >> 30);
2357 regs[0] = (uint8_t)((accel_bias_body[0] >> 24) & 0xFF);
2358 regs[1] = (uint8_t)((accel_bias_body[0] >> 16) & 0xFF);
2359 regs[2] = (uint8_t)((accel_bias_body[0] >> 8) & 0xFF);
2360 regs[3] = (uint8_t)(accel_bias_body[0] & 0xFF);
2361 regs[4] = (uint8_t)((accel_bias_body[1] >> 24) & 0xFF);
2362 regs[5] = (uint8_t)((accel_bias_body[1] >> 16) & 0xFF);
2363 regs[6] = (uint8_t)((accel_bias_body[1] >> 8) & 0xFF);
2364 regs[7] = (uint8_t)(accel_bias_body[1] & 0xFF);
2365 regs[8] = (uint8_t)((accel_bias_body[2] >> 24) & 0xFF);
2366 regs[9] = (uint8_t)((accel_bias_body[2] >> 16) & 0xFF);
2367 regs[10] = (uint8_t)((accel_bias_body[2] >> 8) & 0xFF);
2368 regs[11] = (uint8_t)(accel_bias_body[2] & 0xFF);
2372 handle->
debug_print(
"mpu9250: write mem failed.\n");
2394 uint8_t gyro_axes[4] = {0x4C, 0xCD, 0x6C, 0x00};
2395 uint8_t accel_axes[4] = {0x0C, 0xC9, 0x2C, 0x00 };
2396 uint8_t gyro_sign[4] = {0x36, 0x56, 0x76, 0x00 };
2397 uint8_t accel_sign[4] = {0x26, 0x46, 0x66, 0x00 };
2399 uint8_t gyro_regs[3];
2400 uint8_t accel_regs[3];
2413 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
2418 orient = a_mpu9250_inv_orientation_matrix_to_scalar(mat);
2419 gyro_regs[0] = gyro_axes[orient & 3];
2420 gyro_regs[1] = gyro_axes[(orient >> 3) & 3];
2421 gyro_regs[2] = gyro_axes[(orient >> 6) & 3];
2422 accel_regs[0] = accel_axes[orient & 3];
2423 accel_regs[1] = accel_axes[(orient >> 3) & 3];
2424 accel_regs[2] = accel_axes[(orient >> 6) & 3];
2426 (uint8_t *)gyro_regs, 3);
2429 handle->
debug_print(
"mpu9250: write mem failed.\n");
2434 (uint8_t *)accel_regs, 3);
2437 handle->
debug_print(
"mpu9250: write mem failed.\n");
2442 memcpy(gyro_regs, gyro_sign, 3);
2443 memcpy(accel_regs, accel_sign, 3);
2444 if ((orient & 4) != 0)
2449 if ((orient & 0x20) != 0)
2454 if ((orient & 0x100) != 0)
2460 (uint8_t *)gyro_regs, 3);
2463 handle->
debug_print(
"mpu9250: write mem failed.\n");
2468 (uint8_t *)accel_regs, 3);
2471 handle->
debug_print(
"mpu9250: write mem failed.\n");
2511 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
2523 handle->
debug_print(
"mpu9250: write mem failed.\n");
2559 handle->
debug_print(
"mpu9250: write mem failed.\n");
2575 handle->
debug_print(
"mpu9250: write mem failed.\n");
2582 uint8_t regs[9] = {0xb8, 0xaa, 0xb3, 0x8d, 0xb4, 0x98, 0x0d, 0x35, 0x5d};
2587 handle->
debug_print(
"mpu9250: write mem failed.\n");
2594 uint8_t regs[9] = {0xb8, 0xaa, 0xaa, 0xaa, 0xb0, 0x88, 0xc3, 0xc5, 0xc7};
2599 handle->
debug_print(
"mpu9250: write mem failed.\n");
2624 handle->
debug_print(
"mpu9250: write mem failed.\n");
2635 uint32_t thresh_scaled;
2637 uint16_t dmp_thresh;
2638 uint16_t dmp_thresh_2;
2639 float scaled_thresh;
2645 handle->
debug_print(
"mpu9250: write mem failed.\n");
2654 handle->
debug_print(
"mpu9250: read accelerometer config failed.\n");
2658 range = ((prev >> 3) & 0x3);
2661 dmp_thresh = (uint16_t)(scaled_thresh * 16384);
2662 dmp_thresh_2 = (uint16_t)(scaled_thresh * 12288);
2664 else if (range == 1)
2666 dmp_thresh = (uint16_t)(scaled_thresh * 8192);
2667 dmp_thresh_2 = (uint16_t)(scaled_thresh * 6144);
2669 else if (range == 2)
2671 dmp_thresh = (uint16_t)(scaled_thresh * 4096);
2672 dmp_thresh_2 = (uint16_t)(scaled_thresh * 3072);
2676 dmp_thresh = (uint16_t)(scaled_thresh * 2048);
2677 dmp_thresh_2 = (uint16_t)(scaled_thresh * 1536);
2679 tmp[0] = (uint8_t)(dmp_thresh >> 8);
2680 tmp[1] = (uint8_t)(dmp_thresh & 0xFF);
2681 tmp[2] = (uint8_t)(dmp_thresh_2 >> 8);
2682 tmp[3] = (uint8_t)(dmp_thresh_2 & 0xFF);
2687 handle->
debug_print(
"mpu9250: write mem failed.\n");
2694 handle->
debug_print(
"mpu9250: write mem failed.\n");
2702 handle->
debug_print(
"mpu9250: write mem failed.\n");
2709 handle->
debug_print(
"mpu9250: write mem failed.\n");
2717 handle->
debug_print(
"mpu9250: write mem failed.\n");
2724 handle->
debug_print(
"mpu9250: write mem failed.\n");
2733 handle->
debug_print(
"mpu9250: write mem failed.\n");
2742 handle->
debug_print(
"mpu9250: write mem failed.\n");
2749 tmp[0] = (ms >> 8) & 0xFF;
2750 tmp[1] = (ms >> 0) & 0xFF;
2755 handle->
debug_print(
"mpu9250: write mem failed.\n");
2762 tmp[0] = (ms >> 8) & 0xFF;
2763 tmp[1] = (ms >> 0) & 0xFF;
2768 handle->
debug_print(
"mpu9250: write mem failed.\n");
2775 tmp[0] = (uint8_t)(((uint32_t)thresh_scaled >> 24) & 0xFF);
2776 tmp[1] = (uint8_t)(((uint32_t)thresh_scaled >> 16) & 0xFF);
2777 tmp[2] = (uint8_t)(((uint32_t)thresh_scaled >> 8) & 0xFF);
2778 tmp[3] = (uint8_t)((uint32_t)thresh_scaled & 0xFF);
2783 handle->
debug_print(
"mpu9250: write mem failed.\n");
2790 tmp[0] = (ms >> 8) & 0xFF;
2791 tmp[1] = (ms >> 0) & 0xFF;
2796 handle->
debug_print(
"mpu9250: write mem failed.\n");
2803 tmp[0] = (ms >> 8) & 0xFF;
2804 tmp[1] = (ms >> 0) & 0xFF;
2809 handle->
debug_print(
"mpu9250: write mem failed.\n");
2820 handle->
debug_print(
"mpu9250: write mem failed.\n");
2837 handle->
debug_print(
"mpu9250: write mem failed.\n");
2844 uint8_t regs[4] = {0xC0, 0xC2, 0xC4, 0xC6};
2849 handle->
debug_print(
"mpu9250: write mem failed.\n");
2853 res = a_mpu9250_reset_fifo(handle);
2856 handle->
debug_print(
"mpu9250: reset fifo failed.\n");
2863 uint8_t regs[4] = {0x8B, 0x8B, 0x8B, 0x8B};
2868 handle->
debug_print(
"mpu9250: write mem failed.\n");
2872 res = a_mpu9250_reset_fifo(handle);
2875 handle->
debug_print(
"mpu9250: reset fifo failed.\n");
2883 uint8_t regs[4] = {0x20, 0x28, 0x30, 0x38};
2888 handle->
debug_print(
"mpu9250: write mem failed.\n");
2892 res = a_mpu9250_reset_fifo(handle);
2895 handle->
debug_print(
"mpu9250: reset fifo failed.\n");
2902 uint8_t regs[4] = {0xA3, 0xA3, 0xA3, 0xA3};
2907 handle->
debug_print(
"mpu9250: write mem failed.\n");
2911 res = a_mpu9250_reset_fifo(handle);
2914 handle->
debug_print(
"mpu9250: reset fifo failed.\n");
2922 return a_mpu9250_reset_fifo(handle);
2940 uint8_t regs_end[12] = {0xFE, 0xF2, 0xAB,
2958 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
2970 tmp[0] = (uint8_t)((d >> 8) & 0xFF);
2971 tmp[1] = (uint8_t)(d & 0xFF);
2976 handle->
debug_print(
"mpu9250: write mem failed.\n");
2981 (uint8_t *)regs_end, 12);
2984 handle->
debug_print(
"mpu9250: write mem failed.\n");
3020 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
3028 handle->
debug_print(
"mpu9250: read mem failed.\n");
3032 d = (uint16_t)tmp[0] << 8 | tmp[1];
3067 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
3075 handle->
debug_print(
"mpu9250: read mem failed.\n");
3079 pos = (uint8_t)((axis - 5) * 2);
3091 handle->
debug_print(
"mpu9250: write mem failed.\n");
3128 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
3136 handle->
debug_print(
"mpu9250: read mem failed.\n");
3140 pos = (uint8_t)((axis - 5) * 2);
3141 if (((tmp >> pos) & 0x3) == 0x3)
3174 uint16_t dmp_thresh;
3175 uint16_t dmp_thresh_2;
3176 float scaled_thresh;
3188 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
3201 (uint8_t *)&prev, 1);
3204 handle->
debug_print(
"mpu9250: read accelerometer config failed.\n");
3208 range = ((prev >> 3) & 0x3);
3211 dmp_thresh = (uint16_t)(scaled_thresh * 16384);
3212 dmp_thresh_2 = (uint16_t)(scaled_thresh * 12288);
3214 else if (range == 1)
3216 dmp_thresh = (uint16_t)(scaled_thresh * 8192);
3217 dmp_thresh_2 = (uint16_t)(scaled_thresh * 6144);
3219 else if (range == 2)
3221 dmp_thresh = (uint16_t)(scaled_thresh * 4096);
3222 dmp_thresh_2 = (uint16_t)(scaled_thresh * 3072);
3226 dmp_thresh = (uint16_t)(scaled_thresh * 2048);
3227 dmp_thresh_2 = (uint16_t)(scaled_thresh * 1536);
3229 tmp[0] = (uint8_t)(dmp_thresh >> 8);
3230 tmp[1] = (uint8_t)(dmp_thresh & 0xFF);
3231 tmp[2] = (uint8_t)(dmp_thresh_2 >> 8);
3232 tmp[3] = (uint8_t)(dmp_thresh_2 & 0xFF);
3239 handle->
debug_print(
"mpu9250: write mem failed.\n");
3246 handle->
debug_print(
"mpu9250: write mem failed.\n");
3258 handle->
debug_print(
"mpu9250: write mem failed.\n");
3265 handle->
debug_print(
"mpu9250: write mem failed.\n");
3277 handle->
debug_print(
"mpu9250: write mem failed.\n");
3284 handle->
debug_print(
"mpu9250: write mem failed.\n");
3319 uint16_t dmp_thresh;
3320 float scaled_thresh;
3332 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
3342 handle->
debug_print(
"mpu9250: read mem failed.\n");
3352 handle->
debug_print(
"mpu9250: read mem failed.\n");
3362 handle->
debug_print(
"mpu9250: read mem failed.\n");
3373 dmp_thresh = (uint16_t)tmp[0] << 8 | tmp[1];
3376 (uint8_t *)&prev, 1);
3379 handle->
debug_print(
"mpu9250: read accelerometer config failed.\n");
3383 range = ((prev >> 3) & 0x3);
3386 scaled_thresh = dmp_thresh / 16384.0f;
3388 else if (range == 1)
3390 scaled_thresh = dmp_thresh / 8192.0f;
3392 else if (range == 2)
3394 scaled_thresh = dmp_thresh / 4096.0f;
3398 scaled_thresh = dmp_thresh / 2048.0f;
3430 int16_t (*accel_raw)[3],
float (*accel_g)[3],
3431 int16_t (*gyro_raw)[3],
float (*gyro_dps)[3],
3433 float *pitch,
float *roll,
float *yaw,
3455 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
3463 handle->
debug_print(
"mpu9250: read int status failed.\n");
3470 (void)a_mpu9250_reset_fifo(handle);
3502 handle->
debug_print(
"mpu9250: read fifo count failed.\n");
3506 count = (uint16_t)(((uint16_t)buf[0] << 8) | buf[1]);
3507 count = (count < 1024) ? count : 1024;
3508 count = (count < (*l) * len) ? count : ((*l) *len);
3509 count = (count / len) * len;
3520 handle->
debug_print(
"mpu9250: fifo data is too little.\n");
3525 for (j = 0; j < (*l); j++)
3529 int32_t quat_q14[4];
3530 int32_t quat_mag_sq;
3531 float q0 = 1.0f, q1 = 0.0f, q2 = 0.0f, q3 = 0.0f;
3534 quat[j][0] = ((int32_t)handle->
buf[0 + len * j] << 24) | ((int32_t)handle->
buf[1 + len * j] << 16) |
3535 ((int32_t)handle->
buf[2 + len * j] << 8) | handle->
buf[3 + len * j];
3536 quat[j][1] = ((int32_t)handle->
buf[4 + len * j] << 24) | ((int32_t)handle->
buf[5 + len * j] << 16) |
3537 ((int32_t)handle->
buf[6 + len * j] << 8) | handle->
buf[7 + len * j];
3538 quat[j][2] = ((int32_t)handle->
buf[8 + len * j] << 24) | ((int32_t)handle->
buf[9 + len * j] << 16) |
3539 ((int32_t)handle->
buf[10 + len * j] << 8) | handle->
buf[11 + len * j];
3540 quat[j][3] = ((int32_t)handle->
buf[12 + len * j] << 24) | ((int32_t)handle->
buf[13 + len * j] << 16) |
3541 ((int32_t)handle->
buf[14 + len * j] << 8) | handle->
buf[15 + len * j];
3544 quat_q14[0] = quat[j][0] >> 16;
3545 quat_q14[1] = quat[j][1] >> 16;
3546 quat_q14[2] = quat[j][2] >> 16;
3547 quat_q14[3] = quat[j][3] >> 16;
3548 quat_mag_sq = quat_q14[0] * quat_q14[0] + quat_q14[1] * quat_q14[1] +
3549 quat_q14[2] * quat_q14[2] + quat_q14[3] * quat_q14[3];
3553 handle->
debug_print(
"mpu9250: quat check error.\n");
3554 (void)a_mpu9250_reset_fifo(handle);
3558 q0 = quat[j][0] / 1073741824.0f;
3559 q1 = quat[j][1] / 1073741824.0f;
3560 q2 = quat[j][2] / 1073741824.0f;
3561 q3 = quat[j][3] / 1073741824.0f;
3562 pitch[j] = asinf(-2 * q1 * q3 + 2 * q0* q2)* 57.3f;
3563 roll[j] = atan2f(2 * q2 * q3 + 2 * q0 * q1, -2 * q1 * q1 - 2 * q2 * q2 + 1)* 57.3f;
3564 yaw[j] = atan2f(2 * (q1 * q2 + q0 * q3), q0 * q0 + q1 * q1 - q2 * q2 - q3 * q3) * 57.3f;
3580 accel_raw[j][0] = ((int16_t)handle->
buf[i + 0 + len * j] << 8) | handle->
buf[i + 1 + len * j];
3581 accel_raw[j][1] = ((int16_t)handle->
buf[i + 2 + len * j] << 8) | handle->
buf[i + 3 + len * j];
3582 accel_raw[j][2] = ((int16_t)handle->
buf[i + 4 + len * j] << 8) | handle->
buf[i + 5 + len * j];
3588 handle->
debug_print(
"mpu9250: read accel config failed.\n");
3592 accel_conf = (accel_conf >> 3) & 0x3;
3593 if (accel_conf == 0)
3595 accel_g[j][0] = (float)(accel_raw[j][0]) / 16384.0f;
3596 accel_g[j][1] = (float)(accel_raw[j][1]) / 16384.0f;
3597 accel_g[j][2] = (float)(accel_raw[j][2]) / 16384.0f;
3599 else if (accel_conf == 1)
3601 accel_g[j][0] = (float)(accel_raw[j][0]) / 8192.0f;
3602 accel_g[j][1] = (float)(accel_raw[j][1]) / 8192.0f;
3603 accel_g[j][2] = (float)(accel_raw[j][2]) / 8192.0f;
3605 else if (accel_conf == 2)
3607 accel_g[j][0] = (float)(accel_raw[j][0]) / 4096.0f;
3608 accel_g[j][1] = (float)(accel_raw[j][1]) / 4096.0f;
3609 accel_g[j][2] = (float)(accel_raw[j][2]) / 4096.0f;
3613 accel_g[j][0] = (float)(accel_raw[j][0]) / 2048.0f;
3614 accel_g[j][1] = (float)(accel_raw[j][1]) / 2048.0f;
3615 accel_g[j][2] = (float)(accel_raw[j][2]) / 2048.0f;
3620 accel_raw[j][0] = 0;
3621 accel_raw[j][1] = 0;
3622 accel_raw[j][2] = 0;
3623 accel_g[j][0] = 0.0f;
3624 accel_g[j][1] = 0.0f;
3625 accel_g[j][2] = 0.0f;
3631 gyro_raw[j][0] = ((int16_t)handle->
buf[i + 0 + len * j] << 8) | handle->
buf[i + 1 + len * j];
3632 gyro_raw[j][1] = ((int16_t)handle->
buf[i + 2 + len * j] << 8) | handle->
buf[i + 3 + len * j];
3633 gyro_raw[j][2] = ((int16_t)handle->
buf[i + 4 + len * j] << 8) | handle->
buf[i + 5 + len * j];
3639 handle->
debug_print(
"mpu9250: read gyro config failed.\n");
3643 gyro_conf = (gyro_conf >> 3) & 0x3;
3646 gyro_dps[j][0] = (float)(gyro_raw[j][0]) / 131.0f;
3647 gyro_dps[j][1] = (float)(gyro_raw[j][1]) / 131.0f;
3648 gyro_dps[j][2] = (float)(gyro_raw[j][2]) / 131.0f;
3650 else if (gyro_conf == 1)
3652 gyro_dps[j][0] = (float)(gyro_raw[j][0]) / 65.5f;
3653 gyro_dps[j][1] = (float)(gyro_raw[j][1]) / 65.5f;
3654 gyro_dps[j][2] = (float)(gyro_raw[j][2]) / 65.5f;
3656 else if (gyro_conf == 2)
3658 gyro_dps[j][0] = (float)(gyro_raw[j][0]) / 32.8f;
3659 gyro_dps[j][1] = (float)(gyro_raw[j][1]) / 32.8f;
3660 gyro_dps[j][2] = (float)(gyro_raw[j][2]) / 32.8f;
3664 gyro_dps[j][0] = (float)(gyro_raw[j][0]) / 16.4f;
3665 gyro_dps[j][1] = (float)(gyro_raw[j][1]) / 16.4f;
3666 gyro_dps[j][2] = (float)(gyro_raw[j][2]) / 16.4f;
3674 gyro_dps[j][0] = 0.0f;
3675 gyro_dps[j][1] = 0.0f;
3676 gyro_dps[j][2] = 0.0f;
3680 a_mpu9250_dmp_decode_gesture(handle, handle->
buf + i + len * j);
3711 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
3745 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
3782 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
3790 handle->
debug_print(
"mpu9250: read user ctrl failed.\n");
3795 prev |= enable << 7;
3799 handle->
debug_print(
"mpu9250: write user ctrl failed.\n");
3823 int32_t gyro_offset_raw[3], int32_t accel_offset_raw[3],
3824 int32_t gyro_offset[3], int32_t accel_offset[3])
3840 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
3848 handle->
debug_print(
"mpu9250: read accel config failed.\n");
3855 handle->
debug_print(
"mpu9250: read gyro config failed.\n");
3859 accel_conf = (accel_conf >> 3) & 0x3;
3860 gyro_conf = (gyro_conf >> 3) & 0x3;
3861 if (accel_conf == 0)
3863 accel_offset[0] = (int32_t)(accel_offset_raw[0] * 16384.0f);
3864 accel_offset[1] = (int32_t)(accel_offset_raw[1] * 16384.0f);
3865 accel_offset[2] = (int32_t)(accel_offset_raw[2] * 16384.0f);
3867 else if (accel_conf == 1)
3869 accel_offset[0] = (int32_t)(accel_offset_raw[0] * 8192.0f);
3870 accel_offset[1] = (int32_t)(accel_offset_raw[1] * 8192.0f);
3871 accel_offset[2] = (int32_t)(accel_offset_raw[2] * 8192.0f);
3873 else if (accel_conf == 2)
3875 accel_offset[0] = (int32_t)(accel_offset_raw[0] * 4096.0f);
3876 accel_offset[1] = (int32_t)(accel_offset_raw[1] * 4096.0f);
3877 accel_offset[2] = (int32_t)(accel_offset_raw[2] * 4096.0f);
3881 accel_offset[0] = (int32_t)(accel_offset_raw[0] * 2048.0f);
3882 accel_offset[1] = (int32_t)(accel_offset_raw[1] * 2048.0f);
3883 accel_offset[2] = (int32_t)(accel_offset_raw[2] * 2048.0f);
3887 gyro_offset[0] = (int32_t)(gyro_offset_raw[0] * 131.f);
3888 gyro_offset[1] = (int32_t)(gyro_offset_raw[1] * 131.f);
3889 gyro_offset[2] = (int32_t)(gyro_offset_raw[2] * 131.f);
3891 else if (gyro_conf == 1)
3893 gyro_offset[0] = (int32_t)(gyro_offset_raw[0] * 65.5f);
3894 gyro_offset[1] = (int32_t)(gyro_offset_raw[1] * 65.5f);
3895 gyro_offset[2] = (int32_t)(gyro_offset_raw[2] * 65.5f);
3897 else if (gyro_conf == 2)
3899 gyro_offset[0] = (int32_t)(gyro_offset_raw[0] * 32.8f);
3900 gyro_offset[1] = (int32_t)(gyro_offset_raw[1] * 32.8f);
3901 gyro_offset[2] = (int32_t)(gyro_offset_raw[2] * 32.8f);
3905 gyro_offset[0] = (int32_t)(gyro_offset_raw[0] * 16.4f);
3906 gyro_offset[1] = (int32_t)(gyro_offset_raw[1] * 16.4f);
3907 gyro_offset[2] = (int32_t)(gyro_offset_raw[2] * 16.4f);
3929 handle->
iic_spi = (uint8_t)interface;
3971 handle->
iic_addr = (uint8_t)addr_pin;
4024 handle->
debug_print(
"mpu9250: iic_init is null.\n");
4030 handle->
debug_print(
"mpu9250: iic_deinit is null.\n");
4036 handle->
debug_print(
"mpu9250: iic_read is null.\n");
4042 handle->
debug_print(
"mpu9250: iic_write is null.\n");
4048 handle->
debug_print(
"mpu9250: spi_init is null.\n");
4054 handle->
debug_print(
"mpu9250: spi_deinit is null.\n");
4060 handle->
debug_print(
"mpu9250: spi_read is null.\n");
4066 handle->
debug_print(
"mpu9250: spi_write is null.\n");
4072 handle->
debug_print(
"mpu9250: delay_ms is null.\n");
4078 handle->
debug_print(
"mpu9250: receive_callback is null.\n");
4088 handle->
debug_print(
"mpu9250: iic init failed.\n");
4098 handle->
debug_print(
"mpu9250: spi init failed.\n");
4107 handle->
debug_print(
"mpu9250: read who am i failed.\n");
4108 (void)a_mpu9250_deinit(handle);
4115 (void)a_mpu9250_deinit(handle);
4124 handle->
debug_print(
"mpu9250: write pwr mgmt 1 failed.\n");
4125 (void)a_mpu9250_deinit(handle);
4131 while (timeout != 0)
4136 handle->
debug_print(
"mpu9250: read pwr mgmt 1 failed.\n");
4137 (void)a_mpu9250_deinit(handle);
4141 if ((prev & (1 << 7)) == 0)
4182 prev = (1 << 6) | (1 << 3) | (7 << 0);
4186 handle->
debug_print(
"mpu9250: write pwr mgmt 1 failed.\n");
4190 res = a_mpu9250_deinit(handle);
4224 int16_t (*accel_raw)[3],
float (*accel_g)[3],
4225 int16_t (*gyro_raw)[3],
float (*gyro_dps)[3],
4226 int16_t (*mag_raw)[3],
float (*mag_ut)[3],
4245 handle->
debug_print(
"mpu9250: length is zero.\n");
4251 handle->
debug_print(
"mpu9250: dmp is running.\n");
4259 handle->
debug_print(
"mpu9250: read user ctrl failed.\n");
4266 handle->
debug_print(
"mpu9250: read accel config failed.\n");
4273 handle->
debug_print(
"mpu9250: read gyro config failed.\n");
4277 accel_conf = (accel_conf >> 3) & 0x3;
4278 gyro_conf = (gyro_conf >> 3) & 0x3;
4279 if ((prev & (1 << 6)) != 0)
4289 handle->
debug_print(
"mpu9250: read fifo enable failed.\n");
4293 if ((conf != 0x78) && (conf != 0x79))
4295 handle->
debug_print(
"mpu9250: fifo conf is error.\n");
4303 handle->
debug_print(
"mpu9250: read fifo count failed.\n");
4310 count = (uint16_t)(((uint16_t)buf[0] << 8) | buf[1]);
4311 count = (count < 1024) ? count : 1024;
4312 count = (count < ((*len) * 12)) ? count : ((*len) * 12);
4313 count = (count / 12) * 12;
4322 for (i = 0; i < (*len); i++)
4324 accel_raw[i][0] = (int16_t)((uint16_t)handle->
buf[i * 12 + 0] << 8) |
4325 handle->
buf[i * 12 + 1];
4326 accel_raw[i][1] = (int16_t)((uint16_t)handle->
buf[i * 12 + 2] << 8) |
4327 handle->
buf[i * 12 + 3];
4328 accel_raw[i][2] = (int16_t)((uint16_t)handle->
buf[i * 12 + 4] << 8) |
4329 handle->
buf[i * 12 + 5];
4330 gyro_raw[i][0] = (int16_t)((uint16_t)handle->
buf[i * 12 + 6] << 8) |
4331 handle->
buf[i * 12 + 7];
4332 gyro_raw[i][1] = (int16_t)((uint16_t)handle->
buf[i * 12 + 8] << 8) |
4333 handle->
buf[i * 12 + 9];
4334 gyro_raw[i][2] = (int16_t)((uint16_t)handle->
buf[i * 12 + 10] << 8) |
4335 handle->
buf[i * 12 + 11];
4340 if (accel_conf == 0)
4342 accel_g[i][0] = (float)(accel_raw[i][0]) / 16384.0f;
4343 accel_g[i][1] = (float)(accel_raw[i][1]) / 16384.0f;
4344 accel_g[i][2] = (float)(accel_raw[i][2]) / 16384.0f;
4346 else if (accel_conf == 1)
4348 accel_g[i][0] = (float)(accel_raw[i][0]) / 8192.0f;
4349 accel_g[i][1] = (float)(accel_raw[i][1]) / 8192.0f;
4350 accel_g[i][2] = (float)(accel_raw[i][2]) / 8192.0f;
4352 else if (accel_conf == 2)
4354 accel_g[i][0] = (float)(accel_raw[i][0]) / 4096.0f;
4355 accel_g[i][1] = (float)(accel_raw[i][1]) / 4096.0f;
4356 accel_g[i][2] = (float)(accel_raw[i][2]) / 4096.0f;
4360 accel_g[i][0] = (float)(accel_raw[i][0]) / 2048.0f;
4361 accel_g[i][1] = (float)(accel_raw[i][1]) / 2048.0f;
4362 accel_g[i][2] = (float)(accel_raw[i][2]) / 2048.0f;
4367 gyro_dps[i][0] = (float)(gyro_raw[i][0]) / 131.0f;
4368 gyro_dps[i][1] = (float)(gyro_raw[i][1]) / 131.0f;
4369 gyro_dps[i][2] = (float)(gyro_raw[i][2]) / 131.0f;
4371 else if (gyro_conf == 1)
4373 gyro_dps[i][0] = (float)(gyro_raw[i][0]) / 65.5f;
4374 gyro_dps[i][1] = (float)(gyro_raw[i][1]) / 65.5f;
4375 gyro_dps[i][2] = (float)(gyro_raw[i][2]) / 65.5f;
4377 else if (gyro_conf == 2)
4379 gyro_dps[i][0] = (float)(gyro_raw[i][0]) / 32.8f;
4380 gyro_dps[i][1] = (float)(gyro_raw[i][1]) / 32.8f;
4381 gyro_dps[i][2] = (float)(gyro_raw[i][2]) / 32.8f;
4385 gyro_dps[i][0] = (float)(gyro_raw[i][0]) / 16.4f;
4386 gyro_dps[i][1] = (float)(gyro_raw[i][1]) / 16.4f;
4387 gyro_dps[i][2] = (float)(gyro_raw[i][2]) / 16.4f;
4389 mag_ut[i][0] = 0.0f;
4390 mag_ut[i][1] = 0.0f;
4391 mag_ut[i][2] = 0.0f;
4402 count = (uint16_t)(((uint16_t)buf[0] << 8) | buf[1]);
4403 count = (count < 1024) ? count : 1024;
4404 count = (count < ((*len) * 20)) ? count : ((*len) * 20);
4405 count = (count / 20) * 20;
4415 mag_k_x = ((float)handle->
mag_asa[0] - 128.0f) * 0.5f / 128.0f + 1.0f;
4416 mag_k_y = ((float)handle->
mag_asa[1] - 128.0f) * 0.5f / 128.0f + 1.0f;
4417 mag_k_z = ((float)handle->
mag_asa[2] - 128.0f) * 0.5f / 128.0f + 1.0f;
4419 for (i = 0; i < (*len); i++)
4421 accel_raw[i][0] = (int16_t)((uint16_t)handle->
buf[i * 20 + 0] << 8) |
4422 handle->
buf[i * 20 + 1];
4423 accel_raw[i][1] = (int16_t)((uint16_t)handle->
buf[i * 20 + 2] << 8) |
4424 handle->
buf[i * 20 + 3];
4425 accel_raw[i][2] = (int16_t)((uint16_t)handle->
buf[i * 20 + 4] << 8) |
4426 handle->
buf[i * 20 + 5];
4427 gyro_raw[i][0] = (int16_t)((uint16_t)handle->
buf[i * 20 + 6] << 8) |
4428 handle->
buf[i * 20 + 7];
4429 gyro_raw[i][1] = (int16_t)((uint16_t)handle->
buf[i * 20 + 8] << 8) |
4430 handle->
buf[i * 20 + 9];
4431 gyro_raw[i][2] = (int16_t)((uint16_t)handle->
buf[i * 20 + 10] << 8) |
4432 handle->
buf[i * 20 + 11];
4433 mag_raw[i][0] = (int16_t)((uint16_t)handle->
buf[i * 20 + 14] << 8) |
4434 handle->
buf[i * 20 + 13];
4435 mag_raw[i][1] = (int16_t)((uint16_t)handle->
buf[i * 20 + 16] << 8) |
4436 handle->
buf[i * 20 + 15];
4437 mag_raw[i][2] = (int16_t)((uint16_t)handle->
buf[i * 20 + 18] << 8) |
4438 handle->
buf[i * 20 + 17];
4440 if (accel_conf == 0)
4442 accel_g[i][0] = (float)(accel_raw[i][0]) / 16384.0f;
4443 accel_g[i][1] = (float)(accel_raw[i][1]) / 16384.0f;
4444 accel_g[i][2] = (float)(accel_raw[i][2]) / 16384.0f;
4446 else if (accel_conf == 1)
4448 accel_g[i][0] = (float)(accel_raw[i][0]) / 8192.0f;
4449 accel_g[i][1] = (float)(accel_raw[i][1]) / 8192.0f;
4450 accel_g[i][2] = (float)(accel_raw[i][2]) / 8192.0f;
4452 else if (accel_conf == 2)
4454 accel_g[i][0] = (float)(accel_raw[i][0]) / 4096.0f;
4455 accel_g[i][1] = (float)(accel_raw[i][1]) / 4096.0f;
4456 accel_g[i][2] = (float)(accel_raw[i][2]) / 4096.0f;
4460 accel_g[i][0] = (float)(accel_raw[i][0]) / 2048.0f;
4461 accel_g[i][1] = (float)(accel_raw[i][1]) / 2048.0f;
4462 accel_g[i][2] = (float)(accel_raw[i][2]) / 2048.0f;
4467 gyro_dps[i][0] = (float)(gyro_raw[i][0]) / 131.0f;
4468 gyro_dps[i][1] = (float)(gyro_raw[i][1]) / 131.0f;
4469 gyro_dps[i][2] = (float)(gyro_raw[i][2]) / 131.0f;
4471 else if (gyro_conf == 1)
4473 gyro_dps[i][0] = (float)(gyro_raw[i][0]) / 65.5f;
4474 gyro_dps[i][1] = (float)(gyro_raw[i][1]) / 65.5f;
4475 gyro_dps[i][2] = (float)(gyro_raw[i][2]) / 65.5f;
4477 else if (gyro_conf == 2)
4479 gyro_dps[i][0] = (float)(gyro_raw[i][0]) / 32.8f;
4480 gyro_dps[i][1] = (float)(gyro_raw[i][1]) / 32.8f;
4481 gyro_dps[i][2] = (float)(gyro_raw[i][2]) / 32.8f;
4485 gyro_dps[i][0] = (float)(gyro_raw[i][0]) / 16.4f;
4486 gyro_dps[i][1] = (float)(gyro_raw[i][1]) / 16.4f;
4487 gyro_dps[i][2] = (float)(gyro_raw[i][2]) / 16.4f;
4489 if ((handle->
buf[i * 20 + 19] & (1 << 4)) != 0)
4491 mag_ut[i][0] = (float)mag_raw[i][0] * mag_k_x * 0.15f;
4492 mag_ut[i][1] = (float)mag_raw[i][1] * mag_k_y * 0.15f;
4493 mag_ut[i][2] = (float)mag_raw[i][2] * mag_k_z * 0.15f;
4497 mag_ut[i][0] = (float)mag_raw[i][0] * mag_k_x * 0.6f;
4498 mag_ut[i][1] = (float)mag_raw[i][1] * mag_k_y * 0.6f;
4499 mag_ut[i][2] = (float)mag_raw[i][2] * mag_k_z * 0.6f;
4516 accel_raw[0][0] = (int16_t)((uint16_t)handle->
buf[0] << 8) | handle->
buf[1];
4517 accel_raw[0][1] = (int16_t)((uint16_t)handle->
buf[2] << 8) | handle->
buf[3];
4518 accel_raw[0][2] = (int16_t)((uint16_t)handle->
buf[4] << 8) | handle->
buf[5];
4519 gyro_raw[0][0] = (int16_t)((uint16_t)handle->
buf[8] << 8) | handle->
buf[9];
4520 gyro_raw[0][1] = (int16_t)((uint16_t)handle->
buf[10] << 8) | handle->
buf[11];
4521 gyro_raw[0][2] = (int16_t)((uint16_t)handle->
buf[12] << 8) | handle->
buf[13];
4523 if (accel_conf == 0)
4525 accel_g[0][0] = (float)(accel_raw[0][0]) / 16384.0f;
4526 accel_g[0][1] = (float)(accel_raw[0][1]) / 16384.0f;
4527 accel_g[0][2] = (float)(accel_raw[0][2]) / 16384.0f;
4529 else if (accel_conf == 1)
4531 accel_g[0][0] = (float)(accel_raw[0][0]) / 8192.0f;
4532 accel_g[0][1] = (float)(accel_raw[0][1]) / 8192.0f;
4533 accel_g[0][2] = (float)(accel_raw[0][2]) / 8192.0f;
4535 else if (accel_conf == 2)
4537 accel_g[0][0] = (float)(accel_raw[0][0]) / 4096.0f;
4538 accel_g[0][1] = (float)(accel_raw[0][1]) / 4096.0f;
4539 accel_g[0][2] = (float)(accel_raw[0][2]) / 4096.0f;
4543 accel_g[0][0] = (float)(accel_raw[0][0]) / 2048.0f;
4544 accel_g[0][1] = (float)(accel_raw[0][1]) / 2048.0f;
4545 accel_g[0][2] = (float)(accel_raw[0][2]) / 2048.0f;
4550 gyro_dps[0][0] = (float)(gyro_raw[0][0]) / 131.0f;
4551 gyro_dps[0][1] = (float)(gyro_raw[0][1]) / 131.0f;
4552 gyro_dps[0][2] = (float)(gyro_raw[0][2]) / 131.0f;
4554 else if (gyro_conf == 1)
4556 gyro_dps[0][0] = (float)(gyro_raw[0][0]) / 65.5f;
4557 gyro_dps[0][1] = (float)(gyro_raw[0][1]) / 65.5f;
4558 gyro_dps[0][2] = (float)(gyro_raw[0][2]) / 65.5f;
4560 else if (gyro_conf == 2)
4562 gyro_dps[0][0] = (float)(gyro_raw[0][0]) / 32.8f;
4563 gyro_dps[0][1] = (float)(gyro_raw[0][1]) / 32.8f;
4564 gyro_dps[0][2] = (float)(gyro_raw[0][2]) / 32.8f;
4568 gyro_dps[0][0] = (float)(gyro_raw[0][0]) / 16.4f;
4569 gyro_dps[0][1] = (float)(gyro_raw[0][1]) / 16.4f;
4570 gyro_dps[0][2] = (float)(gyro_raw[0][2]) / 16.4f;
4581 handle->
debug_print(
"mpu9250: mag read failed.\n");
4585 mag_raw[0][0] = (int16_t)((uint16_t)handle->
buf[2] << 8) | handle->
buf[1];
4586 mag_raw[0][1] = (int16_t)((uint16_t)handle->
buf[4] << 8) | handle->
buf[3];
4587 mag_raw[0][2] = (int16_t)((uint16_t)handle->
buf[6] << 8) | handle->
buf[5];
4589 mag_k_x = ((
float)handle->
mag_asa[0] - 128.0f) * 0.5f / 128.0f + 1.0f;
4590 mag_k_y = ((float)handle->
mag_asa[1] - 128.0f) * 0.5f / 128.0f + 1.0f;
4591 mag_k_z = ((float)handle->
mag_asa[2] - 128.0f) * 0.5f / 128.0f + 1.0f;
4592 if ((handle->
buf[7] & (1 << 4)) != 0)
4594 mag_ut[0][0] = (float)mag_raw[0][0] * mag_k_x * 0.15f;
4595 mag_ut[0][1] = (float)mag_raw[0][1] * mag_k_y * 0.15f;
4596 mag_ut[0][2] = (float)mag_raw[0][2] * mag_k_z * 0.15f;
4600 mag_ut[0][0] = (float)mag_raw[0][0] * mag_k_x * 0.6f;
4601 mag_ut[0][1] = (float)mag_raw[0][1] * mag_k_y * 0.6f;
4602 mag_ut[0][2] = (float)mag_raw[0][2] * mag_k_z * 0.6f;
4610 mag_ut[0][0] = 0.0f;
4611 mag_ut[0][1] = 0.0f;
4612 mag_ut[0][2] = 0.0f;
4652 *raw = (int16_t)((uint16_t)buf[0] << 8) | buf[1];
4653 *degrees = (float)(*raw) / 321.0f + 21.0f;
4685 handle->
debug_print(
"mpu9250: read int status failed.\n");
4702 (void)a_mpu9250_reset_fifo(handle);
4762 handle->
debug_print(
"mpu9250: read user ctrl failed.\n");
4770 handle->
debug_print(
"mpu9250: write user ctrl failed.\n");
4777 handle->
debug_print(
"mpu9250: read int pin cfg failed.\n");
4786 handle->
debug_print(
"mpu9250: write int pin cfg failed.\n");
4791 res = a_mpu9250_mag_read(handle,
AK8963_REG_WIA, (uint8_t *)&prev, 1);
4794 handle->
debug_print(
"mpu9250: mag read who am i failed.\n");
4800 handle->
debug_print(
"mpu9250: mag id is invalid.\n");
4809 handle->
debug_print(
"mpu9250: mag write cntl2 failed.\n");
4814 while (timeout != 0)
4819 handle->
debug_print(
"mpu9250: mag read cntl2 failed.\n");
4823 if ((prev & 0x01) == 0x00)
4841 handle->
debug_print(
"mpu9250: mag write cntl1 failed.\n");
4850 handle->
debug_print(
"mpu9250: mag write cntl1 failed.\n");
4857 handle->
debug_print(
"mpu9250: mag read asa failed.\n");
4865 handle->
debug_print(
"mpu9250: mag write cntl1 failed.\n");
4877 handle->
debug_print(
"mpu9250: spi don't support.\n");
4909 handle->
debug_print(
"mpu9250: mag is not inited.\n");
4917 handle->
debug_print(
"mpu9250: read user ctrl failed.\n");
4925 handle->
debug_print(
"mpu9250: write user ctrl failed.\n");
4932 handle->
debug_print(
"mpu9250: read int pin cfg failed.\n");
4941 handle->
debug_print(
"mpu9250: write int pin cfg failed.\n");
4946 res = a_mpu9250_mag_read(handle,
AK8963_REG_WIA, (uint8_t *)&prev, 1);
4949 handle->
debug_print(
"mpu9250: mag read who am i failed.\n");
4955 handle->
debug_print(
"mpu9250: mag id is invalid.\n");
4963 handle->
debug_print(
"mpu9250: mag read cntl1 failed.\n");
4967 prev &= ~(0xF << 0);
4972 handle->
debug_print(
"mpu9250: mag write cntl1 failed.\n");
5013 handle->
debug_print(
"mpu9250: mag is not inited.\n");
5021 handle->
debug_print(
"mpu9250: mag read failed.\n");
5025 mag_raw[0] = (int16_t)((uint16_t)buf[2] << 8) | buf[1];
5026 mag_raw[1] = (int16_t)((uint16_t)buf[4] << 8) | buf[3];
5027 mag_raw[2] = (int16_t)((uint16_t)buf[6] << 8) | buf[5];
5029 mag_k_x = ((float)handle->
mag_asa[0] - 128.0f) * 0.5f / 128.0f + 1.0f;
5030 mag_k_y = ((float)handle->
mag_asa[1] - 128.0f) * 0.5f / 128.0f + 1.0f;
5031 mag_k_z = ((float)handle->
mag_asa[2] - 128.0f) * 0.5f / 128.0f + 1.0f;
5032 if ((buf[7] & (1 << 4)) != 0)
5034 mag_ut[0] = (float)mag_raw[0] * mag_k_x * 0.15f;
5035 mag_ut[1] = (float)mag_raw[1] * mag_k_y * 0.15f;
5036 mag_ut[2] = (float)mag_raw[2] * mag_k_z * 0.15f;
5040 mag_ut[0] = (float)mag_raw[0] * mag_k_x * 0.6f;
5041 mag_ut[1] = (float)mag_raw[1] * mag_k_y * 0.6f;
5042 mag_ut[2] = (float)mag_raw[2] * mag_k_z * 0.6f;
5074 handle->
debug_print(
"mpu9250: mag is not inited.\n");
5079 res = a_mpu9250_mag_read(handle,
AK8963_REG_INFO, (uint8_t *)info, 1);
5082 handle->
debug_print(
"mpu9250: mag read info failed.\n");
5116 handle->
debug_print(
"mpu9250: mag is not inited.\n");
5121 res = a_mpu9250_mag_read(handle,
AK8963_REG_ST1, (uint8_t *)status, 1);
5124 handle->
debug_print(
"mpu9250: mag read status1 failed.\n");
5158 handle->
debug_print(
"mpu9250: mag is not inited.\n");
5163 res = a_mpu9250_mag_read(handle,
AK8963_REG_ST2, (uint8_t *)status, 1);
5166 handle->
debug_print(
"mpu9250: mag read status2 failed.\n");
5201 handle->
debug_print(
"mpu9250: mag is not inited.\n");
5209 handle->
debug_print(
"mpu9250: mag read cntl1 failed.\n");
5213 prev &= ~(0xF << 0);
5218 handle->
debug_print(
"mpu9250: mag write cntl1 failed.\n");
5253 handle->
debug_print(
"mpu9250: mag is not inited.\n");
5261 handle->
debug_print(
"mpu9250: mag read cntl1 failed.\n");
5297 handle->
debug_print(
"mpu9250: mag is not inited.\n");
5305 handle->
debug_print(
"mpu9250: mag read cntl1 failed.\n");
5314 handle->
debug_print(
"mpu9250: mag write cntl1 failed.\n");
5349 handle->
debug_print(
"mpu9250: mag is not inited.\n");
5357 handle->
debug_print(
"mpu9250: mag read cntl1 failed.\n");
5393 handle->
debug_print(
"mpu9250: mag is not inited.\n");
5401 handle->
debug_print(
"mpu9250: mag read cntl2 failed.\n");
5406 prev |= enable << 0;
5410 handle->
debug_print(
"mpu9250: mag write cntl2 failed.\n");
5445 handle->
debug_print(
"mpu9250: mag is not inited.\n");
5453 handle->
debug_print(
"mpu9250: mag read cntl2 failed.\n");
5489 handle->
debug_print(
"mpu9250: mag is not inited.\n");
5494 res = a_mpu9250_mag_read(handle,
AK8963_REG_ASTC, (uint8_t *)&prev, 1);
5497 handle->
debug_print(
"mpu9250: mag read astc failed.\n");
5502 prev |= enable << 6;
5506 handle->
debug_print(
"mpu9250: mag write astc failed.\n");
5541 handle->
debug_print(
"mpu9250: mag is not inited.\n");
5546 res = a_mpu9250_mag_read(handle,
AK8963_REG_ASTC, (uint8_t *)&prev, 1);
5549 handle->
debug_print(
"mpu9250: mag read astc failed.\n");
5584 handle->
debug_print(
"mpu9250: mag is not inited.\n");
5593 handle->
debug_print(
"mpu9250: mag write i2cdis failed.\n");
5627 handle->
debug_print(
"mpu9250: mag is not inited.\n");
5635 handle->
debug_print(
"mpu9250: mag read asa failed.\n");
5669 handle->
debug_print(
"mpu9250: mag is not inited.\n");
5677 handle->
debug_print(
"mpu9250: read user ctrl failed.\n");
5686 handle->
debug_print(
"mpu9250: write user ctrl failed.\n");
5693 handle->
debug_print(
"mpu9250: read int pin cfg failed.\n");
5701 handle->
debug_print(
"mpu9250: write int pin cfg failed.\n");
5710 handle->
debug_print(
"mpu9250: write iic slv0 addr failed.\n");
5718 handle->
debug_print(
"mpu9250: write iic slv0 reg failed.\n");
5726 handle->
debug_print(
"mpu9250: read fifo enable failed.\n");
5735 handle->
debug_print(
"mpu9250: write fifo enable failed.\n");
5744 handle->
debug_print(
"mpu9250: write iic slv0 ctrl failed.\n");
5780 handle->
debug_print(
"mpu9250: read user ctrl failed.\n");
5785 prev |= enable << 6;
5789 handle->
debug_print(
"mpu9250: write user ctrl failed.\n");
5825 handle->
debug_print(
"mpu9250: read user ctrl failed.\n");
5857 res = a_mpu9250_reset_fifo(handle);
5860 handle->
debug_print(
"mpu9250: force reset fifo failed.\n");
5896 handle->
debug_print(
"mpu9250: read user ctrl failed.\n");
5901 prev |= enable << 5;
5905 handle->
debug_print(
"mpu9250: write user ctrl failed.\n");
5941 handle->
debug_print(
"mpu9250: read user ctrl failed.\n");
5978 handle->
debug_print(
"mpu9250: read user ctrl failed.\n");
5983 prev |= enable << 4;
5987 handle->
debug_print(
"mpu9250: write user ctrl failed.\n");
6023 handle->
debug_print(
"mpu9250: read user ctrl failed.\n");
6059 handle->
debug_print(
"mpu9250: read user ctrl failed.\n");
6068 handle->
debug_print(
"mpu9250: write user ctrl failed.\n");
6104 handle->
debug_print(
"mpu9250: read user ctrl failed.\n");
6140 handle->
debug_print(
"mpu9250: read user ctrl failed.\n");
6149 handle->
debug_print(
"mpu9250: write user ctrl failed.\n");
6185 handle->
debug_print(
"mpu9250: read user ctrl failed.\n");
6221 handle->
debug_print(
"mpu9250: read user ctrl failed.\n");
6230 handle->
debug_print(
"mpu9250: write user ctrl failed.\n");
6266 handle->
debug_print(
"mpu9250: read user ctrl failed.\n");
6302 handle->
debug_print(
"mpu9250: read power management 1 failed.\n");
6311 handle->
debug_print(
"mpu9250: write power management 1 failed.\n");
6347 handle->
debug_print(
"mpu9250: read power management 1 failed.\n");
6384 handle->
debug_print(
"mpu9250: read power management 1 failed.\n");
6388 prev &= ~(0x7 << 0);
6389 prev |= clock_source << 0;
6393 handle->
debug_print(
"mpu9250: write power management 1 failed.\n");
6429 handle->
debug_print(
"mpu9250: read power management 1 failed.\n");
6466 handle->
debug_print(
"mpu9250: read power management 1 failed.\n");
6471 prev |= (!enable) << 3;
6475 handle->
debug_print(
"mpu9250: write power management 1 failed.\n");
6511 handle->
debug_print(
"mpu9250: read power management 1 failed.\n");
6548 handle->
debug_print(
"mpu9250: read power management 1 failed.\n");
6553 prev |= enable << 5;
6557 handle->
debug_print(
"mpu9250: write power management 1 failed.\n");
6593 handle->
debug_print(
"mpu9250: read power management 1 failed.\n");
6630 handle->
debug_print(
"mpu9250: read power management 1 failed.\n");
6635 prev |= enable << 6;
6639 handle->
debug_print(
"mpu9250: write power management 1 failed.\n");
6675 handle->
debug_print(
"mpu9250: read power management 1 failed.\n");
6712 handle->
debug_print(
"mpu9250: read power management 1 failed.\n");
6717 prev |= enable << 4;
6721 handle->
debug_print(
"mpu9250: write power management 1 failed.\n");
6757 handle->
debug_print(
"mpu9250: read power management 1 failed.\n");
6795 handle->
debug_print(
"mpu9250: read power management 2 failed.\n");
6799 prev &= ~(1 << source);
6800 prev |= enable << source;
6804 handle->
debug_print(
"mpu9250: write power management 2 failed.\n");
6841 handle->
debug_print(
"mpu9250: read power management 2 failed.\n");
6878 handle->
debug_print(
"mpu9250: read fifo count failed.\n");
6882 *count = (uint16_t)(((uint16_t)buf[0] << 8) | buf[1]);
6915 handle->
debug_print(
"mpu9250: fifo read failed.\n");
6951 handle->
debug_print(
"mpu9250: fifo write failed.\n");
6987 handle->
debug_print(
"mpu9250: read signal path reset failed.\n");
6991 prev &= ~(1 << path);
6996 handle->
debug_print(
"mpu9250: write signal path reset failed.\n");
7031 handle->
debug_print(
"mpu9250: write smprt div failed.\n");
7066 handle->
debug_print(
"mpu9250: read smprt div failed.\n");
7102 handle->
debug_print(
"mpu9250: read config failed.\n");
7106 prev &= ~(0x7 << 3);
7111 handle->
debug_print(
"mpu9250: write config failed.\n");
7147 handle->
debug_print(
"mpu9250: read config failed.\n");
7184 handle->
debug_print(
"mpu9250: read config failed.\n");
7188 prev &= ~(0x7 << 0);
7189 prev |= filter << 0;
7193 handle->
debug_print(
"mpu9250: write config failed.\n");
7229 handle->
debug_print(
"mpu9250: read config failed.\n");
7266 handle->
debug_print(
"mpu9250: read config failed.\n");
7275 handle->
debug_print(
"mpu9250: write config failed.\n");
7311 handle->
debug_print(
"mpu9250: read config failed.\n");
7349 handle->
debug_print(
"mpu9250: read gyroscope config failed.\n");
7353 prev &= ~(1 << axis);
7354 prev |= enable << axis;
7358 handle->
debug_print(
"mpu9250: write gyroscope config failed.\n");
7395 handle->
debug_print(
"mpu9250: read gyroscope config failed.\n");
7432 handle->
debug_print(
"mpu9250: read gyroscope config failed.\n");
7441 handle->
debug_print(
"mpu9250: write gyroscope config failed.\n");
7477 handle->
debug_print(
"mpu9250: read gyroscope config failed.\n");
7521 handle->
debug_print(
"mpu9250: read gyroscope config failed.\n");
7526 prev |= choice << 0;
7530 handle->
debug_print(
"mpu9250: write gyroscope config failed.\n");
7566 handle->
debug_print(
"mpu9250: read gyroscope config failed.\n");
7570 *choice = prev & 0x03;
7604 handle->
debug_print(
"mpu9250: read accelerometer config failed.\n");
7608 prev &= ~(1 << axis);
7609 prev |= enable << axis;
7613 handle->
debug_print(
"mpu9250: write accelerometer config failed.\n");
7650 handle->
debug_print(
"mpu9250: read accelerometer config failed.\n");
7687 handle->
debug_print(
"mpu9250: read accelerometer config failed.\n");
7696 handle->
debug_print(
"mpu9250: write accelerometer config failed.\n");
7732 handle->
debug_print(
"mpu9250: read accelerometer config failed.\n");
7768 handle->
debug_print(
"mpu9250: read accelerometer 2 config failed.\n");
7777 handle->
debug_print(
"mpu9250: write accelerometer 2 config failed.\n");
7820 handle->
debug_print(
"mpu9250: read accelerometer 2 config failed.\n");
7825 prev |= choice << 3;
7829 handle->
debug_print(
"mpu9250: write accelerometer 2 config failed.\n");
7866 handle->
debug_print(
"mpu9250: read accelerometer 2 config failed.\n");
7870 *choice = (prev >> 3) & 0x1;
7903 handle->
debug_print(
"mpu9250: read accelerometer 2 config failed.\n");
7907 prev &= ~(0x7 << 0);
7908 prev |= filter << 0;
7912 handle->
debug_print(
"mpu9250: write accelerometer 2 config failed.\n");
7948 handle->
debug_print(
"mpu9250: read accelerometer 2 config failed.\n");
7985 handle->
debug_print(
"mpu9250: read lp accelerometer odr failed.\n");
7989 prev &= ~(0xF << 0);
7994 handle->
debug_print(
"mpu9250: write lp accelerometer odr failed.\n");
8030 handle->
debug_print(
"mpu9250: read lp accelerometer odr failed.\n");
8067 handle->
debug_print(
"mpu9250: read motion detect ctrl failed.\n");
8072 prev |= enable << 7;
8076 handle->
debug_print(
"mpu9250: write motion detect ctrl failed.\n");
8112 handle->
debug_print(
"mpu9250: read motion detect ctrl failed.\n");
8149 handle->
debug_print(
"mpu9250: read motion detect ctrl failed.\n");
8154 prev |= enable << 6;
8158 handle->
debug_print(
"mpu9250: write motion detect ctrl failed.\n");
8194 handle->
debug_print(
"mpu9250: read motion detect ctrl failed.\n");
8232 handle->
debug_print(
"mpu9250: read fifo enable config failed.\n");
8236 prev &= ~(1 << fifo);
8237 prev |= enable << fifo;
8241 handle->
debug_print(
"mpu9250: write fifo enable config failed.\n");
8278 handle->
debug_print(
"mpu9250: read fifo enable config failed.\n");
8315 handle->
debug_print(
"mpu9250: read interrupt pin failed.\n");
8324 handle->
debug_print(
"mpu9250: write interrupt pin failed.\n");
8360 handle->
debug_print(
"mpu9250: read interrupt pin failed.\n");
8397 handle->
debug_print(
"mpu9250: read interrupt pin failed.\n");
8406 handle->
debug_print(
"mpu9250: write interrupt pin failed.\n");
8442 handle->
debug_print(
"mpu9250: read interrupt pin failed.\n");
8479 handle->
debug_print(
"mpu9250: read interrupt pin failed.\n");
8484 prev |= (!enable) << 5;
8488 handle->
debug_print(
"mpu9250: write interrupt pin failed.\n");
8524 handle->
debug_print(
"mpu9250: read interrupt pin failed.\n");
8561 handle->
debug_print(
"mpu9250: read interrupt pin failed.\n");
8566 prev |= enable << 4;
8570 handle->
debug_print(
"mpu9250: write interrupt pin failed.\n");
8606 handle->
debug_print(
"mpu9250: read interrupt pin failed.\n");
8643 handle->
debug_print(
"mpu9250: read interrupt pin failed.\n");
8652 handle->
debug_print(
"mpu9250: write interrupt pin failed.\n");
8688 handle->
debug_print(
"mpu9250: read interrupt pin failed.\n");
8725 handle->
debug_print(
"mpu9250: read interrupt pin failed.\n");
8730 prev |= enable << 2;
8734 handle->
debug_print(
"mpu9250: write interrupt pin failed.\n");
8770 handle->
debug_print(
"mpu9250: read interrupt pin failed.\n");
8807 handle->
debug_print(
"mpu9250: read interrupt pin failed.\n");
8812 prev |= enable << 1;
8816 handle->
debug_print(
"mpu9250: write interrupt pin failed.\n");
8852 handle->
debug_print(
"mpu9250: read interrupt pin failed.\n");
8890 handle->
debug_print(
"mpu9250: read interrupt enable failed.\n");
8894 prev &= ~(1 << type);
8895 prev |= enable << type;
8899 handle->
debug_print(
"mpu9250: write interrupt enable failed.\n");
8936 handle->
debug_print(
"mpu9250: read interrupt enable failed.\n");
8972 handle->
debug_print(
"mpu9250: read interrupt status failed.\n");
9007 handle->
debug_print(
"mpu9250: write self test x failed.\n");
9042 handle->
debug_print(
"mpu9250: read self test x failed.\n");
9077 handle->
debug_print(
"mpu9250: write self test y failed.\n");
9112 handle->
debug_print(
"mpu9250: read self test y failed.\n");
9147 handle->
debug_print(
"mpu9250: write self test z failed.\n");
9182 handle->
debug_print(
"mpu9250: read self test z failed.\n");
9217 handle->
debug_print(
"mpu9250: write self test x failed.\n");
9252 handle->
debug_print(
"mpu9250: read self test x failed.\n");
9287 handle->
debug_print(
"mpu9250: write self test y failed.\n");
9322 handle->
debug_print(
"mpu9250: read self test y failed.\n");
9357 handle->
debug_print(
"mpu9250: write self test z failed.\n");
9392 handle->
debug_print(
"mpu9250: read self test z failed.\n");
9425 buf[0] = (offset >> 8) & 0xFF;
9426 buf[1] = (offset >> 0) & 0xFF;
9430 handle->
debug_print(
"mpu9250: write xa offset failed.\n");
9466 handle->
debug_print(
"mpu9250: read xa offset failed.\n");
9470 *offset = (int16_t)(((uint16_t)buf[0] << 8) | buf[1]);
9500 buf[0] = (offset >> 8) & 0xFF;
9501 buf[1] = (offset >> 0) & 0xFF;
9505 handle->
debug_print(
"mpu9250: write ya offset failed.\n");
9541 handle->
debug_print(
"mpu9250: read ya offset failed.\n");
9545 *offset = (int16_t)(((uint16_t)buf[0] << 8) | buf[1]);
9575 buf[0] = (offset >> 8) & 0xFF;
9576 buf[1] = (offset >> 0) & 0xFF;
9580 handle->
debug_print(
"mpu9250: write za offset failed.\n");
9616 handle->
debug_print(
"mpu9250: read za offset failed.\n");
9620 *offset = (int16_t)(((uint16_t)buf[0] << 8) | buf[1]);
9647 *reg = (int16_t)(mg / 0.98f);
9674 *mg = (float)(reg) * 0.98f;
9704 buf[0] = (offset >> 8) & 0xFF;
9705 buf[1] = (offset >> 0) & 0xFF;
9709 handle->
debug_print(
"mpu9250: write xg offset failed.\n");
9745 handle->
debug_print(
"mpu9250: read xg offset failed.\n");
9749 *offset = (int16_t)(((uint16_t)buf[0] << 8) | buf[1]);
9779 buf[0] = (offset >> 8) & 0xFF;
9780 buf[1] = (offset >> 0) & 0xFF;
9784 handle->
debug_print(
"mpu9250: write yg offset failed.\n");
9820 handle->
debug_print(
"mpu9250: read yg offset failed.\n");
9824 *offset = (int16_t)(((uint16_t)buf[0] << 8) | buf[1]);
9854 buf[0] = (offset >> 8) & 0xFF;
9855 buf[1] = (offset >> 0) & 0xFF;
9859 handle->
debug_print(
"mpu9250: write zg offset failed.\n");
9895 handle->
debug_print(
"mpu9250: read zg offset failed.\n");
9899 *offset = (int16_t)(((uint16_t)buf[0] << 8) | buf[1]);
9926 *reg = (int16_t)(dps / 0.0305f);
9953 *dps = (float)(reg) * 0.0305f;
9985 handle->
debug_print(
"mpu9250: write motion threshold failed.\n");
10008 if (handle == NULL)
10012 if (handle->
inited != 1)
10020 handle->
debug_print(
"mpu9250: read motion threshold failed.\n");
10041 if (handle == NULL)
10045 if (handle->
inited != 1)
10050 *reg = (uint8_t)(mg / 4.0f);
10068 if (handle == NULL)
10072 if (handle->
inited != 1)
10077 *mg = (float)(reg) * 4.0f;
10098 int32_t gyro_offset_raw_st[3];
10099 int32_t accel_offset_raw_st[3];
10101 if (handle == NULL)
10105 if (handle->
inited != 1)
10110 res = a_mpu9250_get_st_biases(handle, gyro_offset_raw, accel_offset_raw, 0);
10113 handle->
debug_print(
"mpu9250: get st biases failed.\n");
10117 res = a_mpu9250_get_st_biases(handle, gyro_offset_raw_st, accel_offset_raw_st, 1);
10120 handle->
debug_print(
"mpu9250: get st biases failed.\n");
10124 res = a_mpu9250_accel_self_test(handle, accel_offset_raw, accel_offset_raw_st);
10127 handle->
debug_print(
"mpu9250: accel self test failed.\n");
10131 res = a_mpu9250_gyro_self_test(handle, gyro_offset_raw, gyro_offset_raw_st);
10134 handle->
debug_print(
"mpu9250: gyro self test failed.\n");
10143 handle->
debug_print(
"mpu9250: write pwr mgmt 1 failed.\n");
10151 handle->
debug_print(
"mpu9250: read power management 1 failed.\n");
10159 handle->
debug_print(
"mpu9250: write power management 1 failed.\n");
10183 if (handle == NULL)
10187 if (handle->
inited != 1)
10195 handle->
debug_print(
"mpu9250: read i2c mst ctrl failed.\n");
10204 handle->
debug_print(
"mpu9250: write i2c mst ctrl failed.\n");
10228 if (handle == NULL)
10232 if (handle->
inited != 1)
10240 handle->
debug_print(
"mpu9250: read i2c mst ctrl failed.\n");
10265 if (handle == NULL)
10269 if (handle->
inited != 1)
10277 handle->
debug_print(
"mpu9250: read i2c mst ctrl failed.\n");
10282 prev |= enable << 7;
10286 handle->
debug_print(
"mpu9250: write i2c mst ctrl failed.\n");
10310 if (handle == NULL)
10314 if (handle->
inited != 1)
10322 handle->
debug_print(
"mpu9250: read i2c mst ctrl failed.\n");
10347 if (handle == NULL)
10351 if (handle->
inited != 1)
10359 handle->
debug_print(
"mpu9250: read i2c mst ctrl failed.\n");
10364 prev |= enable << 6;
10368 handle->
debug_print(
"mpu9250: write i2c mst ctrl failed.\n");
10392 if (handle == NULL)
10396 if (handle->
inited != 1)
10404 handle->
debug_print(
"mpu9250: read i2c mst ctrl failed.\n");
10429 if (handle == NULL)
10433 if (handle->
inited != 1)
10441 handle->
debug_print(
"mpu9250: read i2c mst ctrl failed.\n");
10450 handle->
debug_print(
"mpu9250: write i2c mst ctrl failed.\n");
10474 if (handle == NULL)
10478 if (handle->
inited != 1)
10486 handle->
debug_print(
"mpu9250: read i2c mst ctrl failed.\n");
10513 if (handle == NULL)
10517 if (handle->
inited != 1)
10530 handle->
debug_print(
"mpu9250: read fifo enable failed.\n");
10534 prev &= ~(1 << slave);
10535 prev |= enable << slave;
10539 handle->
debug_print(
"mpu9250: write fifo enable failed.\n");
10549 handle->
debug_print(
"mpu9250: read i2c mst ctrl failed.\n");
10554 prev |= enable << 5;
10558 handle->
debug_print(
"mpu9250: write i2c mst ctrl failed.\n");
10565 handle->
debug_print(
"mpu9250: invalid slave.\n");
10591 if (handle == NULL)
10595 if (handle->
inited != 1)
10608 handle->
debug_print(
"mpu9250: read fifo enable failed.\n");
10619 handle->
debug_print(
"mpu9250: read i2c mst ctrl failed.\n");
10627 handle->
debug_print(
"mpu9250: invalid slave.\n");
10653 if (handle == NULL)
10657 if (handle->
inited != 1)
10667 handle->
debug_print(
"mpu9250: read i2c slv0 addr failed.\n");
10676 handle->
debug_print(
"mpu9250: write i2c slv0 addr failed.\n");
10686 handle->
debug_print(
"mpu9250: read i2c slv1 addr failed.\n");
10695 handle->
debug_print(
"mpu9250: write i2c slv1 addr failed.\n");
10705 handle->
debug_print(
"mpu9250: read i2c slv2 addr failed.\n");
10714 handle->
debug_print(
"mpu9250: write i2c slv2 addr failed.\n");
10724 handle->
debug_print(
"mpu9250: read i2c slv3 addr failed.\n");
10733 handle->
debug_print(
"mpu9250: write i2c slv3 addr failed.\n");
10743 handle->
debug_print(
"mpu9250: read i2c slv4 addr failed.\n");
10752 handle->
debug_print(
"mpu9250: write i2c slv4 addr failed.\n");
10759 handle->
debug_print(
"mpu9250: invalid slave.\n");
10785 if (handle == NULL)
10789 if (handle->
inited != 1)
10799 handle->
debug_print(
"mpu9250: read i2c slv0 addr failed.\n");
10810 handle->
debug_print(
"mpu9250: read i2c slv1 addr failed.\n");
10821 handle->
debug_print(
"mpu9250: read i2c slv2 addr failed.\n");
10832 handle->
debug_print(
"mpu9250: read i2c slv3 addr failed.\n");
10843 handle->
debug_print(
"mpu9250: read i2c slv4 addr failed.\n");
10851 handle->
debug_print(
"mpu9250: invalid slave.\n");
10877 if (handle == NULL)
10881 if (handle->
inited != 1)
10891 handle->
debug_print(
"mpu9250: read i2c slv0 addr failed.\n");
10896 prev |= addr_7bit & 0x7F;
10900 handle->
debug_print(
"mpu9250: write i2c slv0 addr failed.\n");
10910 handle->
debug_print(
"mpu9250: read i2c slv1 addr failed.\n");
10915 prev |= addr_7bit & 0x7F;
10919 handle->
debug_print(
"mpu9250: write i2c slv1 addr failed.\n");
10929 handle->
debug_print(
"mpu9250: read i2c slv2 addr failed.\n");
10934 prev |= addr_7bit & 0x7F;
10938 handle->
debug_print(
"mpu9250: write i2c slv2 addr failed.\n");
10948 handle->
debug_print(
"mpu9250: read i2c slv3 addr failed.\n");
10953 prev |= addr_7bit & 0x7F;
10957 handle->
debug_print(
"mpu9250: write i2c slv3 addr failed.\n");
10967 handle->
debug_print(
"mpu9250: read i2c slv4 addr failed.\n");
10972 prev |= addr_7bit & 0x7F;
10976 handle->
debug_print(
"mpu9250: write i2c slv4 addr failed.\n");
10983 handle->
debug_print(
"mpu9250: invalid slave.\n");
11009 if (handle == NULL)
11013 if (handle->
inited != 1)
11023 handle->
debug_print(
"mpu9250: read i2c slv0 addr failed.\n");
11027 *addr_7bit = prev & 0x7F;
11034 handle->
debug_print(
"mpu9250: read i2c slv1 addr failed.\n");
11038 *addr_7bit = prev & 0x7F;
11045 handle->
debug_print(
"mpu9250: read i2c slv2 addr failed.\n");
11049 *addr_7bit = prev & 0x7F;
11056 handle->
debug_print(
"mpu9250: read i2c slv3 addr failed.\n");
11060 *addr_7bit = prev & 0x7F;
11067 handle->
debug_print(
"mpu9250: read i2c slv4 addr failed.\n");
11071 *addr_7bit = prev & 0x7F;
11075 handle->
debug_print(
"mpu9250: invalid slave.\n");
11100 if (handle == NULL)
11104 if (handle->
inited != 1)
11114 handle->
debug_print(
"mpu9250: write i2c slv0 reg failed.\n");
11124 handle->
debug_print(
"mpu9250: write i2c slv1 reg failed.\n");
11134 handle->
debug_print(
"mpu9250: write i2c slv2 reg failed.\n");
11144 handle->
debug_print(
"mpu9250: write i2c slv3 reg failed.\n");
11154 handle->
debug_print(
"mpu9250: write i2c slv4 reg failed.\n");
11161 handle->
debug_print(
"mpu9250: invalid slave.\n");
11186 if (handle == NULL)
11190 if (handle->
inited != 1)
11200 handle->
debug_print(
"mpu9250: read i2c slv0 reg failed.\n");
11210 handle->
debug_print(
"mpu9250: read i2c slv1 reg failed.\n");
11220 handle->
debug_print(
"mpu9250: read i2c slv2 reg failed.\n");
11230 handle->
debug_print(
"mpu9250: read i2c slv3 reg failed.\n");
11240 handle->
debug_print(
"mpu9250: read i2c slv4 reg failed.\n");
11247 handle->
debug_print(
"mpu9250: invalid slave.\n");
11272 if (handle == NULL)
11276 if (handle->
inited != 1)
11286 handle->
debug_print(
"mpu9250: write i2c slv0 do failed.\n");
11296 handle->
debug_print(
"mpu9250: write i2c slv1 do failed.\n");
11306 handle->
debug_print(
"mpu9250: write i2c slv2 do failed.\n");
11316 handle->
debug_print(
"mpu9250: write i2c slv3 do failed.\n");
11323 handle->
debug_print(
"mpu9250: invalid slave.\n");
11348 if (handle == NULL)
11352 if (handle->
inited != 1)
11362 handle->
debug_print(
"mpu9250: read i2c slv0 do failed.\n");
11372 handle->
debug_print(
"mpu9250: read i2c slv1 do failed.\n");
11382 handle->
debug_print(
"mpu9250: read i2c slv2 do failed.\n");
11392 handle->
debug_print(
"mpu9250: read i2c slv3 do failed.\n");
11399 handle->
debug_print(
"mpu9250: invalid slave.\n");
11425 if (handle == NULL)
11429 if (handle->
inited != 1)
11439 handle->
debug_print(
"mpu9250: read i2c slv0 ctrl failed.\n");
11444 prev |= enable << 7;
11448 handle->
debug_print(
"mpu9250: write i2c slv0 ctrl failed.\n");
11458 handle->
debug_print(
"mpu9250: read i2c slv1 ctrl failed.\n");
11463 prev |= enable << 7;
11467 handle->
debug_print(
"mpu9250: write i2c slv1 ctrl failed.\n");
11477 handle->
debug_print(
"mpu9250: read i2c slv2 ctrl failed.\n");
11482 prev |= enable << 7;
11486 handle->
debug_print(
"mpu9250: write i2c slv2 ctrl failed.\n");
11496 handle->
debug_print(
"mpu9250: read i2c slv3 ctrl failed.\n");
11501 prev |= enable << 7;
11505 handle->
debug_print(
"mpu9250: write i2c slv3 ctrl failed.\n");
11512 handle->
debug_print(
"mpu9250: invalid slave.\n");
11538 if (handle == NULL)
11542 if (handle->
inited != 1)
11552 handle->
debug_print(
"mpu9250: read i2c slv0 ctrl failed.\n");
11563 handle->
debug_print(
"mpu9250: read i2c slv1 ctrl failed.\n");
11574 handle->
debug_print(
"mpu9250: read i2c slv2 ctrl failed.\n");
11585 handle->
debug_print(
"mpu9250: read i2c slv3 ctrl failed.\n");
11593 handle->
debug_print(
"mpu9250: invalid slave.\n");
11619 if (handle == NULL)
11623 if (handle->
inited != 1)
11633 handle->
debug_print(
"mpu9250: read i2c slv0 ctrl failed.\n");
11638 prev |= enable << 6;
11642 handle->
debug_print(
"mpu9250: write i2c slv0 ctrl failed.\n");
11652 handle->
debug_print(
"mpu9250: read i2c slv1 ctrl failed.\n");
11657 prev |= enable << 6;
11661 handle->
debug_print(
"mpu9250: write i2c slv1 ctrl failed.\n");
11671 handle->
debug_print(
"mpu9250: read i2c slv2 ctrl failed.\n");
11676 prev |= enable << 6;
11680 handle->
debug_print(
"mpu9250: write i2c slv2 ctrl failed.\n");
11690 handle->
debug_print(
"mpu9250: read i2c slv3 ctrl failed.\n");
11695 prev |= enable << 6;
11699 handle->
debug_print(
"mpu9250: write i2c slv3 ctrl failed.\n");
11706 handle->
debug_print(
"mpu9250: invalid slave.\n");
11732 if (handle == NULL)
11736 if (handle->
inited != 1)
11746 handle->
debug_print(
"mpu9250: read i2c slv0 ctrl failed.\n");
11757 handle->
debug_print(
"mpu9250: read i2c slv1 ctrl failed.\n");
11768 handle->
debug_print(
"mpu9250: read i2c slv2 ctrl failed.\n");
11779 handle->
debug_print(
"mpu9250: read i2c slv3 ctrl failed.\n");
11787 handle->
debug_print(
"mpu9250: invalid slave.\n");
11813 if (handle == NULL)
11817 if (handle->
inited != 1)
11827 handle->
debug_print(
"mpu9250: read i2c slv0 ctrl failed.\n");
11836 handle->
debug_print(
"mpu9250: write i2c slv0 ctrl failed.\n");
11846 handle->
debug_print(
"mpu9250: read i2c slv1 ctrl failed.\n");
11855 handle->
debug_print(
"mpu9250: write i2c slv1 ctrl failed.\n");
11865 handle->
debug_print(
"mpu9250: read i2c slv2 ctrl failed.\n");
11874 handle->
debug_print(
"mpu9250: write i2c slv2 ctrl failed.\n");
11884 handle->
debug_print(
"mpu9250: read i2c slv3 ctrl failed.\n");
11893 handle->
debug_print(
"mpu9250: write i2c slv3 ctrl failed.\n");
11900 handle->
debug_print(
"mpu9250: invalid slave.\n");
11926 if (handle == NULL)
11930 if (handle->
inited != 1)
11940 handle->
debug_print(
"mpu9250: read i2c slv0 ctrl failed.\n");
11951 handle->
debug_print(
"mpu9250: read i2c slv1 ctrl failed.\n");
11962 handle->
debug_print(
"mpu9250: read i2c slv2 ctrl failed.\n");
11973 handle->
debug_print(
"mpu9250: read i2c slv3 ctrl failed.\n");
11981 handle->
debug_print(
"mpu9250: invalid slave.\n");
12007 if (handle == NULL)
12011 if (handle->
inited != 1)
12021 handle->
debug_print(
"mpu9250: read i2c slv0 ctrl failed.\n");
12026 prev |= order << 4;
12030 handle->
debug_print(
"mpu9250: write i2c slv0 ctrl failed.\n");
12040 handle->
debug_print(
"mpu9250: read i2c slv1 ctrl failed.\n");
12045 prev |= order << 4;
12049 handle->
debug_print(
"mpu9250: write i2c slv1 ctrl failed.\n");
12059 handle->
debug_print(
"mpu9250: read i2c slv2 ctrl failed.\n");
12064 prev |= order << 4;
12068 handle->
debug_print(
"mpu9250: write i2c slv2 ctrl failed.\n");
12078 handle->
debug_print(
"mpu9250: read i2c slv3 ctrl failed.\n");
12083 prev |= order << 4;
12087 handle->
debug_print(
"mpu9250: write i2c slv3 ctrl failed.\n");
12094 handle->
debug_print(
"mpu9250: invalid slave.\n");
12120 if (handle == NULL)
12124 if (handle->
inited != 1)
12134 handle->
debug_print(
"mpu9250: read i2c slv0 ctrl failed.\n");
12145 handle->
debug_print(
"mpu9250: read i2c slv1 ctrl failed.\n");
12156 handle->
debug_print(
"mpu9250: read i2c slv2 ctrl failed.\n");
12167 handle->
debug_print(
"mpu9250: read i2c slv3 ctrl failed.\n");
12175 handle->
debug_print(
"mpu9250: invalid slave.\n");
12202 if (handle == NULL)
12206 if (handle->
inited != 1)
12222 handle->
debug_print(
"mpu9250: read i2c slv0 ctrl failed.\n");
12231 handle->
debug_print(
"mpu9250: write i2c slv0 ctrl failed.\n");
12241 handle->
debug_print(
"mpu9250: read i2c slv1 ctrl failed.\n");
12250 handle->
debug_print(
"mpu9250: write i2c slv1 ctrl failed.\n");
12260 handle->
debug_print(
"mpu9250: read i2c slv2 ctrl failed.\n");
12269 handle->
debug_print(
"mpu9250: write i2c slv2 ctrl failed.\n");
12279 handle->
debug_print(
"mpu9250: read i2c slv3 ctrl failed.\n");
12288 handle->
debug_print(
"mpu9250: write i2c slv3 ctrl failed.\n");
12295 handle->
debug_print(
"mpu9250: invalid slave.\n");
12321 if (handle == NULL)
12325 if (handle->
inited != 1)
12335 handle->
debug_print(
"mpu9250: read i2c slv0 ctrl failed.\n");
12339 *len = prev & 0x0F;
12346 handle->
debug_print(
"mpu9250: read i2c slv1 ctrl failed.\n");
12350 *len = prev & 0x0F;
12357 handle->
debug_print(
"mpu9250: read i2c slv2 ctrl failed.\n");
12361 *len = prev & 0x0F;
12368 handle->
debug_print(
"mpu9250: read i2c slv3 ctrl failed.\n");
12372 *len = prev & 0x0F;
12376 handle->
debug_print(
"mpu9250: invalid slave.\n");
12399 if (handle == NULL)
12403 if (handle->
inited != 1)
12411 handle->
debug_print(
"mpu9250: read i2c mst status failed.\n");
12436 if (handle == NULL)
12440 if (handle->
inited != 1)
12448 handle->
debug_print(
"mpu9250: read i2c mst delay ctrl failed.\n");
12452 prev &= ~(1 << delay);
12453 prev |= enable << delay;
12457 handle->
debug_print(
"mpu9250: write i2c mst delay ctrl failed.\n");
12482 if (handle == NULL)
12486 if (handle->
inited != 1)
12494 handle->
debug_print(
"mpu9250: read i2c mst delay ctrl failed.\n");
12519 if (handle == NULL)
12523 if (handle->
inited != 1)
12531 handle->
debug_print(
"mpu9250: read i2c slv4 ctrl failed.\n");
12536 prev |= enable << 7;
12540 handle->
debug_print(
"mpu9250: write i2c slv4 ctrl failed.\n");
12564 if (handle == NULL)
12568 if (handle->
inited != 1)
12576 handle->
debug_print(
"mpu9250: read i2c slv4 ctrl failed.\n");
12601 if (handle == NULL)
12605 if (handle->
inited != 1)
12613 handle->
debug_print(
"mpu9250: read i2c slv4 ctrl failed.\n");
12618 prev |= enable << 6;
12622 handle->
debug_print(
"mpu9250: write i2c slv4 ctrl failed.\n");
12646 if (handle == NULL)
12650 if (handle->
inited != 1)
12658 handle->
debug_print(
"mpu9250: read i2c slv4 ctrl failed.\n");
12683 if (handle == NULL)
12687 if (handle->
inited != 1)
12695 handle->
debug_print(
"mpu9250: read i2c slv4 ctrl failed.\n");
12704 handle->
debug_print(
"mpu9250: write i2c slv4 ctrl failed.\n");
12728 if (handle == NULL)
12732 if (handle->
inited != 1)
12740 handle->
debug_print(
"mpu9250: read i2c slv4 ctrl failed.\n");
12766 if (handle == NULL)
12770 if (handle->
inited != 1)
12784 handle->
debug_print(
"mpu9250: read i2c slv4 ctrl failed.\n");
12793 handle->
debug_print(
"mpu9250: write i2c slv4 ctrl failed.\n");
12817 if (handle == NULL)
12821 if (handle->
inited != 1)
12829 handle->
debug_print(
"mpu9250: read i2c slv4 ctrl failed.\n");
12833 *delay = prev & 0x1F;
12853 if (handle == NULL)
12857 if (handle->
inited != 1)
12865 handle->
debug_print(
"mpu9250: write i2c slv4 do failed.\n");
12888 if (handle == NULL)
12892 if (handle->
inited != 1)
12900 handle->
debug_print(
"mpu9250: read i2c slv4 do failed.\n");
12923 if (handle == NULL)
12927 if (handle->
inited != 1)
12935 handle->
debug_print(
"mpu9250: write i2c slv4 di failed.\n");
12958 if (handle == NULL)
12962 if (handle->
inited != 1)
12970 handle->
debug_print(
"mpu9250: read i2c slv4 di failed.\n");
12995 if (handle == NULL)
12999 if (handle->
inited != 1)
13013 handle->
debug_print(
"mpu9250: read ext sens data 00 failed.\n");
13036 if (handle == NULL)
13040 if (handle->
inited != 1)
13045 return a_mpu9250_write(handle, reg, buf, len);
13063 if (handle == NULL)
13067 if (handle->
inited != 1)
13072 return a_mpu9250_read(handle, reg, buf, len);
13093 strncpy(info->
interface,
"IIC SPI", 8);
#define MPU9250_REG_MOT_DETECT_CTRL
#define MPU9250_DMP_D_1_79
#define MPU9250_DMP_TAP_THX
#define MPU9250_REG_YA_OFFSET_H
#define MPU9250_DMP_CFG_FIFO_ON_EVENT
#define MPU9250_DMP_FEATURE_SEND_ANY_GYRO
#define MPU9250_REG_SELF_TEST_Y_ACCEL
#define MPU9250_REG_SELF_TEST_Y_GYRO
#define MPU9250_DMP_SHAKE_REJECT_TIMEOUT
#define MPU9250_DMP_CFG_GYRO_RAW_DATA
#define MPU9250_REG_WHO_AM_I
#define MPU9250_DMP_CFG_8
#define MPU9250_REG_SELF_TEST_Z_ACCEL
#define MPU9250_REG_SELF_TEST_X_ACCEL
#define MPU9250_DMP_CFG_15
#define MPU9250_REG_I2C_SLV1_ADDR
#define MPU9250_DMP_CFG_27
#define MPU9250_REG_I2C_SLV3_REG
#define MPU9250_REG_I2C_MST_CTRL
#define MPU9250_DMP_D_0_22
#define MPU9250_DMP_TAP_THZ
#define MPU9250_DMP_D_1_218
#define MPU9250_REG_I2C_SLV4_ADDR
#define MPU9250_REG_I2C_SLV1_REG
#define MPU9250_REG_I2C_MST_STATUS
#define MPU9250_DMP_TAP_TIME_MULTI
#define MIN(a, b)
inner function definition
#define MPU9250_REG_EXT_SENS_DATA_00
#define MPU9250_REG_I2C_MST_DELAY_CTRL
#define MPU9250_REG_I2C_SLV0_ADDR
#define MPU9250_DMP_GYRO_SF
#define MPU9250_DMP_SAMPLE_RATE
mpu9250 dmp code definition
#define MPU9250_REG_FIFO_COUNTH
#define MPU9250_DMP_D_1_92
#define MPU9250_DMP_D_EXT_GYRO_BIAS_Y
#define MPU9250_REG_INT_ENABLE
#define MPU9250_DMP_CFG_6
#define MPU9250_REG_XG_OFFSET_H
#define MPU9250_DMP_D_1_88
#define MPU9250_DMP_D_1_36
#define MPU9250_DMP_D_1_44
#define SUPPLY_VOLTAGE_MAX
#define MPU9250_REG_FIFO_EN
#define MPU9250_REG_I2C_SLV1_CTRL
#define MPU9250_DMP_TAP_MIN_TAP_COUNT
#define MPU9250_DMP_INT_SRC_TAP
#define MPU9250_REG_INT_PIN_CFG
#define MPU9250_DMP_TAPW_MIN
#define MPU9250_DMP_CFG_ORIENT_INT
#define MPU9250_REG_USER_CTRL
#define AK8963_REG_I2CDIS
#define MPU9250_DMP_D_1_90
#define MPU9250_REG_SMPRT_DIV
#define MPU9250_REG_ZA_OFFSET_H
#define MPU9250_DMP_QUAT_MAG_SQ_MAX
#define MPU9250_DMP_SHAKE_REJECT_THRESH
#define MPU9250_DMP_D_ACCEL_BIAS
#define MPU9250_REG_PROGRAM_START
#define MPU9250_REG_I2C_SLV1_DO
#define MPU9250_REG_SELF_TEST_X_GYRO
chip register definition
#define MPU9250_REG_I2C_SLV0_DO
#define MPU9250_DMP_FCFG_7
#define MPU9250_DMP_D_0_104
#define MPU9250_DMP_FCFG_2
#define MPU9250_REG_YG_OFFSET_H
#define MPU9250_REG_SELF_TEST_Z_GYRO
#define MPU9250_REG_XA_OFFSET_H
#define MPU9250_REG_ACCEL_CONFIG
#define MPU9250_DMP_D_1_72
#define MPU9250_DMP_SHAKE_REJECT_TIME
#define MPU9250_DMP_TAP_THRESH
#define MPU9250_DMP_TAP_TIME
#define MANUFACTURER_NAME
#define MPU9250_REG_WOM_THR
#define SUPPLY_VOLTAGE_MIN
#define MPU9250_REG_GYRO_CONFIG
#define MPU9250_REG_SIGNAL_PATH_RESET
#define MPU9250_REG_I2C_SLV2_REG
#define MPU9250_REG_I2C_SLV2_DO
#define MPU9250_DMP_D_PEDSTD_STEPCTR
#define MPU9250_REG_ZG_OFFSET_H
#define MPU9250_DMP_TAP_THY
#define MPU9250_DMP_D_PEDSTD_TIMECTR
#define MPU9250_DMP_D_EXT_GYRO_BIAS_X
#define MPU9250_DMP_D_1_40
#define MPU9250_REG_I2C_SLV3_CTRL
#define MPU9250_REG_CONFIG
#define MPU9250_REG_I2C_SLV2_ADDR
#define MPU9250_DMP_CFG_LP_QUAT
#define MPU9250_REG_I2C_SLV4_DI
#define MPU9250_DMP_QUAT_MAG_SQ_MIN
#define MPU9250_REG_ACCEL_CONFIG2
#define MPU9250_REG_I2C_SLV2_CTRL
#define MPU9250_REG_I2C_SLV3_ADDR
#define MPU9250_REG_I2C_SLV4_REG
#define MPU9250_REG_PWR_MGMT_2
#define CHIP_NAME
chip information definition
#define MPU9250_REG_ACCEL_XOUT_H
#define MPU9250_REG_I2C_SLV4_DO
#define MPU9250_REG_LP_ACCEL_ODR
#define MPU9250_REG_I2C_SLV3_DO
#define AK8963_IIC_ADDRESS
chip ak8963 iic address definition
#define MPU9250_REG_TEMP_OUT_H
#define MPU9250_DMP_CFG_20
#define MPU9250_DMP_CFG_MOTION_BIAS
#define MPU9250_REG_I2C_SLV4_CTRL
#define MPU9250_REG_I2C_SLV0_CTRL
#define MPU9250_REG_PWR_MGMT_1
#define MPU9250_DMP_FCFG_1
#define MPU9250_DMP_FCFG_3
#define MPU9250_DMP_INT_SRC_ORIENT
#define MPU9250_DMP_D_EXT_GYRO_BIAS_Z
#define MPU9250_REG_INT_STATUS
#define MPU9250_REG_I2C_SLV0_REG
#define MPU9250_REG_BANK_SEL
driver mpu9250 header file
driver mpu9250 code header file
uint8_t mpu9250_get_addr_pin(mpu9250_handle_t *handle, mpu9250_address_t *addr_pin)
get the chip address pin
uint8_t mpu9250_set_accelerometer_z_test(mpu9250_handle_t *handle, uint8_t data)
set the accelerometer z test
uint8_t mpu9250_get_accel_compare_with_previous_sample(mpu9250_handle_t *handle, mpu9250_bool_t *enable)
get the accel compare with previous sample status
uint8_t mpu9250_get_interrupt_pin_type(mpu9250_handle_t *handle, mpu9250_pin_type_t *type)
get the interrupt pin type
uint8_t mpu9250_set_accelerometer_low_pass_filter(mpu9250_handle_t *handle, mpu9250_accelerometer_low_pass_filter_t filter)
set the accelerometer low pass filter
uint8_t mpu9250_set_wake_on_motion(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable wake on motion
uint8_t mpu9250_set_accel_compare_with_previous_sample(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable accel compare with previous sample
uint8_t mpu9250_set_fifo_mode(mpu9250_handle_t *handle, mpu9250_fifo_mode mode)
set the fifo mode
uint8_t mpu9250_get_iic_read_mode(mpu9250_handle_t *handle, mpu9250_iic_read_mode_t *mode)
get the iic read mode
uint8_t mpu9250_self_test(mpu9250_handle_t *handle, int32_t gyro_offset_raw[3], int32_t accel_offset_raw[3])
run the self test
uint8_t mpu9250_set_addr_pin(mpu9250_handle_t *handle, mpu9250_address_t addr_pin)
set the chip address pin
uint8_t mpu9250_set_accelerometer_z_offset(mpu9250_handle_t *handle, int16_t offset)
set the accelerometer z offset
uint8_t mpu9250_get_interrupt_read_clear(mpu9250_handle_t *handle, mpu9250_bool_t *enable)
get the interrupt reading clear status
uint8_t mpu9250_set_ptat(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the temperature sensor
uint8_t mpu9250_get_iic_master(mpu9250_handle_t *handle, mpu9250_bool_t *enable)
get the iic master status
uint8_t mpu9250_get_iic_enable(mpu9250_handle_t *handle, mpu9250_iic_slave_t slave, mpu9250_bool_t *enable)
get the iic status
uint8_t mpu9250_get_iic4_enable(mpu9250_handle_t *handle, mpu9250_bool_t *enable)
get the iic4 status
uint8_t mpu9250_get_fsync_interrupt_level(mpu9250_handle_t *handle, mpu9250_pin_level_t *level)
get the fsync interrupt level
uint8_t mpu9250_set_fifo_enable(mpu9250_handle_t *handle, mpu9250_fifo_t fifo, mpu9250_bool_t enable)
enable or disable the fifo function
uint8_t mpu9250_get_fifo_mode(mpu9250_handle_t *handle, mpu9250_fifo_mode *mode)
get the fifo mode
uint8_t mpu9250_get_accelerometer_low_pass_filter(mpu9250_handle_t *handle, mpu9250_accelerometer_low_pass_filter_t *filter)
get the accelerometer low pass filter
uint8_t mpu9250_set_standby_mode(mpu9250_handle_t *handle, mpu9250_source_t source, mpu9250_bool_t enable)
set source into standby mode
uint8_t mpu9250_set_iic_wait_for_external_sensor(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable iic wait for external sensor
uint8_t mpu9250_get_gyro_z_offset(mpu9250_handle_t *handle, int16_t *offset)
get the gyro z offset
uint8_t mpu9250_get_iic_mode(mpu9250_handle_t *handle, mpu9250_iic_slave_t slave, mpu9250_iic_mode_t *mode)
get the iic mode
uint8_t mpu9250_get_iic_bypass(mpu9250_handle_t *handle, mpu9250_bool_t *enable)
get the iic bypass status
uint8_t mpu9250_get_gyroscope_y_test(mpu9250_handle_t *handle, uint8_t *data)
get the gyroscope y test
uint8_t mpu9250_get_sample_rate_divider(mpu9250_handle_t *handle, uint8_t *d)
get the sample rate divider
uint8_t mpu9250_set_cycle_wake_up(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the cycle wake up mode
uint8_t mpu9250_set_accelerometer_y_test(mpu9250_handle_t *handle, uint8_t data)
set the accelerometer y test
uint8_t mpu9250_get_wake_on_motion(mpu9250_handle_t *handle, mpu9250_bool_t *enable)
get the wake on motion status
uint8_t mpu9250_set_interrupt_latch(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the interrupt latch
uint8_t mpu9250_set_iic4_data_in(mpu9250_handle_t *handle, uint8_t data)
set the iic4 data in
uint8_t mpu9250_get_gyro_y_offset(mpu9250_handle_t *handle, int16_t *offset)
get the gyro y offset
mpu9250_accelerometer_range_t
mpu9250 accelerometer range enumeration definition
uint8_t mpu9250_get_accelerometer_z_offset(mpu9250_handle_t *handle, int16_t *offset)
get the accelerometer z offset
uint8_t mpu9250_get_iic_byte_swap(mpu9250_handle_t *handle, mpu9250_iic_slave_t slave, mpu9250_bool_t *enable)
get the iic byte swap status
uint8_t mpu9250_get_fifo_count(mpu9250_handle_t *handle, uint16_t *count)
get the fifo counter value
uint8_t mpu9250_get_iic_master_reset(mpu9250_handle_t *handle, mpu9250_bool_t *enable)
get the iic master reset status
uint8_t mpu9250_set_extern_sync(mpu9250_handle_t *handle, mpu9250_extern_sync_t sync)
set the extern sync type
uint8_t mpu9250_accelerometer_offset_convert_to_data(mpu9250_handle_t *handle, int16_t reg, float *mg)
convert the register raw data to the accelerometer offset
uint8_t mpu9250_get_iic4_interrupt(mpu9250_handle_t *handle, mpu9250_bool_t *enable)
get the iic4 interrupt status
uint8_t mpu9250_fifo_get(mpu9250_handle_t *handle, uint8_t *buf, uint16_t len)
fifo read bytes
uint8_t mpu9250_get_accelerometer_test(mpu9250_handle_t *handle, mpu9250_axis_t axis, mpu9250_bool_t *enable)
get the accelerometer test
mpu9250_pin_type_t
mpu9250 pin type enumeration definition
uint8_t mpu9250_set_gyro_standby(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the gyro standby
mpu9250_signal_path_reset_t
mpu9250 signal path reset enumeration definition
uint8_t mpu9250_set_iic_multi_master(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable iic multi master
uint8_t mpu9250_get_sleep(mpu9250_handle_t *handle, mpu9250_bool_t *enable)
get the sleep status
uint8_t mpu9250_get_accelerometer_z_test(mpu9250_handle_t *handle, uint8_t *data)
get the accelerometer z test
uint8_t mpu9250_set_signal_path_reset(mpu9250_handle_t *handle, mpu9250_signal_path_reset_t path)
set the signal path reset
uint8_t mpu9250_get_accelerometer_range(mpu9250_handle_t *handle, mpu9250_accelerometer_range_t *range)
get the accelerometer range
uint8_t mpu9250_get_ptat(mpu9250_handle_t *handle, mpu9250_bool_t *enable)
get the temperature sensor status
uint8_t mpu9250_get_iic_multi_master(mpu9250_handle_t *handle, mpu9250_bool_t *enable)
get the iic multi master status
mpu9250_iic_delay_t
mpu9250 iic delay enumeration definition
uint8_t mpu9250_get_iic_data_out(mpu9250_handle_t *handle, mpu9250_iic_slave_t slave, uint8_t *data)
get the iic data out
uint8_t mpu9250_set_iic_transferred_len(mpu9250_handle_t *handle, mpu9250_iic_slave_t slave, uint8_t len)
set the iic transferred length
uint8_t mpu9250_fifo_reset(mpu9250_handle_t *handle)
reset the fifo
uint8_t mpu9250_set_iic_read_mode(mpu9250_handle_t *handle, mpu9250_iic_read_mode_t mode)
set the iic read mode
uint8_t mpu9250_accelerometer_offset_convert_to_register(mpu9250_handle_t *handle, float mg, int16_t *reg)
convert the accelerometer offset to the register raw data
uint8_t mpu9250_get_sensor_reset(mpu9250_handle_t *handle, mpu9250_bool_t *enable)
get the sensor reset status
mpu9250_address_t
mpu9250 address enumeration definition
mpu9250_gyroscope_range_t
mpu9250 gyroscope range enumeration definition
uint8_t mpu9250_set_iic4_data_out(mpu9250_handle_t *handle, uint8_t data)
set the iic4 data out
uint8_t mpu9250_set_iic_register(mpu9250_handle_t *handle, mpu9250_iic_slave_t slave, uint8_t reg)
set the iic register
uint8_t mpu9250_get_accelerometer_choice(mpu9250_handle_t *handle, uint8_t *choice)
get the accelerometer choice
uint8_t mpu9250_set_iic_data_out(mpu9250_handle_t *handle, mpu9250_iic_slave_t slave, uint8_t data)
set the iic data out
uint8_t mpu9250_set_fsync_interrupt(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the fsync interrupt
uint8_t mpu9250_get_iic4_transaction_mode(mpu9250_handle_t *handle, mpu9250_iic4_transaction_mode_t *mode)
get the iic4 transaction mode
uint8_t mpu9250_get_interrupt(mpu9250_handle_t *handle, mpu9250_interrupt_t type, mpu9250_bool_t *enable)
get the interrupt status
uint8_t mpu9250_set_accelerometer_y_offset(mpu9250_handle_t *handle, int16_t offset)
set the accelerometer y offset
uint8_t mpu9250_motion_threshold_convert_to_data(mpu9250_handle_t *handle, uint8_t reg, float *mg)
convert the register raw data to the motion threshold
uint8_t mpu9250_set_iic_bypass(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the iic bypass
uint8_t mpu9250_get_standby_mode(mpu9250_handle_t *handle, mpu9250_source_t source, mpu9250_bool_t *enable)
get the source mode
uint8_t mpu9250_get_clock_source(mpu9250_handle_t *handle, mpu9250_clock_source_t *clock_source)
get the chip clock source
uint8_t mpu9250_info(mpu9250_info_t *info)
get the chip's information
uint8_t mpu9250_set_accelerometer_test(mpu9250_handle_t *handle, mpu9250_axis_t axis, mpu9250_bool_t enable)
set the accelerometer test
uint8_t mpu9250_set_interrupt_level(mpu9250_handle_t *handle, mpu9250_pin_level_t level)
set the interrupt level
uint8_t mpu9250_set_gyroscope_x_test(mpu9250_handle_t *handle, uint8_t data)
set the gyroscope x test
uint8_t mpu9250_get_iic4_data_out(mpu9250_handle_t *handle, uint8_t *data)
get the iic4 data out
uint8_t mpu9250_set_interrupt_read_clear(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the interrupt reading clear
uint8_t mpu9250_get_extern_sync(mpu9250_handle_t *handle, mpu9250_extern_sync_t *sync)
get the extern sync type
uint8_t mpu9250_set_interface(mpu9250_handle_t *handle, mpu9250_interface_t interface)
set the chip interface
uint8_t mpu9250_get_interface(mpu9250_handle_t *handle, mpu9250_interface_t *interface)
get the chip interface
mpu9250_iic_transaction_mode_t
mpu9250 iic transaction mode enumeration definition
mpu9250_iic_slave_t
mpu9250 iic slave enumeration definition
uint8_t mpu9250_irq_handler(mpu9250_handle_t *handle)
irq handler
uint8_t mpu9250_set_gyroscope_y_test(mpu9250_handle_t *handle, uint8_t data)
set the gyroscope y test
uint8_t mpu9250_get_gyro_standby(mpu9250_handle_t *handle, mpu9250_bool_t *enable)
get the gyro standby status
uint8_t mpu9250_set_iic_mode(mpu9250_handle_t *handle, mpu9250_iic_slave_t slave, mpu9250_iic_mode_t mode)
set the iic mode
mpu9250_interrupt_t
mpu9250 interrupt enumeration definition
uint8_t mpu9250_get_gyroscope_x_test(mpu9250_handle_t *handle, uint8_t *data)
get the gyroscope x test
uint8_t mpu9250_get_fsync_interrupt(mpu9250_handle_t *handle, mpu9250_bool_t *enable)
get the fsync interrupt status
mpu9250_extern_sync_t
mpu9250 extern sync enumeration definition
uint8_t mpu9250_gyro_offset_convert_to_data(mpu9250_handle_t *handle, int16_t reg, float *dps)
convert the register raw data to the gyro offset
uint8_t mpu9250_sensor_reset(mpu9250_handle_t *handle)
reset all sensors
mpu9250_source_t
mpu9250 source enumeration definition
uint8_t mpu9250_set_iic_delay_enable(mpu9250_handle_t *handle, mpu9250_iic_delay_t delay, mpu9250_bool_t enable)
enable or disable the iic delay
uint8_t mpu9250_get_iic_transaction_mode(mpu9250_handle_t *handle, mpu9250_iic_slave_t slave, mpu9250_iic_transaction_mode_t *mode)
get the iic transaction mode
mpu9250_interface_t
mpu9250 interface enumeration definition
mpu9250_bool_t
mpu9250 bool enumeration definition
uint8_t mpu9250_set_iic_transaction_mode(mpu9250_handle_t *handle, mpu9250_iic_slave_t slave, mpu9250_iic_transaction_mode_t mode)
set the iic transaction mode
uint8_t mpu9250_get_accelerometer_y_test(mpu9250_handle_t *handle, uint8_t *data)
get the accelerometer y test
uint8_t mpu9250_set_gyro_y_offset(mpu9250_handle_t *handle, int16_t offset)
set the gyro y offset
uint8_t mpu9250_get_gyroscope_z_test(mpu9250_handle_t *handle, uint8_t *data)
get the gyroscope z test
uint8_t mpu9250_set_interrupt(mpu9250_handle_t *handle, mpu9250_interrupt_t type, mpu9250_bool_t enable)
enable or disable the interrupt
uint8_t mpu9250_get_accelerometer_x_test(mpu9250_handle_t *handle, uint8_t *data)
get the accelerometer x test
uint8_t mpu9250_set_motion_threshold(mpu9250_handle_t *handle, uint8_t threshold)
set the motion_threshold
uint8_t mpu9250_set_fsync_interrupt_level(mpu9250_handle_t *handle, mpu9250_pin_level_t level)
set the fsync interrupt level
uint8_t mpu9250_get_low_pass_filter(mpu9250_handle_t *handle, mpu9250_low_pass_filter_t *filter)
get the low pass filter
uint8_t mpu9250_get_interrupt_status(mpu9250_handle_t *handle, uint8_t *status)
get the interrupt status
uint8_t mpu9250_set_gyroscope_choice(mpu9250_handle_t *handle, uint8_t choice)
set the gyroscope choice
uint8_t mpu9250_set_iic_fifo_enable(mpu9250_handle_t *handle, mpu9250_iic_slave_t slave, mpu9250_bool_t enable)
enable or disable the iic fifo
uint8_t mpu9250_deinit(mpu9250_handle_t *handle)
close the chip
uint8_t mpu9250_read(mpu9250_handle_t *handle, int16_t(*accel_raw)[3], float(*accel_g)[3], int16_t(*gyro_raw)[3], float(*gyro_dps)[3], int16_t(*mag_raw)[3], float(*mag_ut)[3], uint16_t *len)
read the data
uint8_t mpu9250_read_temperature(mpu9250_handle_t *handle, int16_t(*raw), float *degrees)
read the temperature
uint8_t mpu9250_get_accelerometer_y_offset(mpu9250_handle_t *handle, int16_t *offset)
get the accelerometer y offset
uint8_t mpu9250_get_fifo_enable(mpu9250_handle_t *handle, mpu9250_fifo_t fifo, mpu9250_bool_t *enable)
get the fifo function status
uint8_t mpu9250_set_fifo_1024kb(mpu9250_handle_t *handle)
set fifo 1024kb
uint8_t mpu9250_get_gyroscope_range(mpu9250_handle_t *handle, mpu9250_gyroscope_range_t *range)
get the gyroscope range
uint8_t mpu9250_get_interrupt_level(mpu9250_handle_t *handle, mpu9250_pin_level_t *level)
get the interrupt level
uint8_t mpu9250_motion_threshold_convert_to_register(mpu9250_handle_t *handle, float mg, uint8_t *reg)
convert the motion threshold to the register raw data
uint8_t mpu9250_set_low_pass_filter(mpu9250_handle_t *handle, mpu9250_low_pass_filter_t filter)
set the low pass filter
uint8_t mpu9250_set_gyroscope_test(mpu9250_handle_t *handle, mpu9250_axis_t axis, mpu9250_bool_t enable)
set the gyroscope test
uint8_t mpu9250_set_clock_source(mpu9250_handle_t *handle, mpu9250_clock_source_t clock_source)
set the chip clock source
uint8_t mpu9250_get_gyroscope_test(mpu9250_handle_t *handle, mpu9250_axis_t axis, mpu9250_bool_t *enable)
get the gyroscope test
uint8_t mpu9250_device_reset(mpu9250_handle_t *handle)
reset the chip
uint8_t mpu9250_set_low_power_accel_output_rate(mpu9250_handle_t *handle, mpu9250_low_power_accel_output_rate_t rate)
set the low power accel output rate
uint8_t mpu9250_get_cycle_wake_up(mpu9250_handle_t *handle, mpu9250_bool_t *enable)
get the cycle wake up mode status
mpu9250_low_pass_filter_t
mpu9250 low pass filter enumeration definition
uint8_t mpu9250_get_iic_group_order(mpu9250_handle_t *handle, mpu9250_iic_slave_t slave, mpu9250_iic_group_order_t *order)
get the iic group order
uint8_t mpu9250_get_iic4_data_in(mpu9250_handle_t *handle, uint8_t *data)
get the iic4 data in
uint8_t mpu9250_set_iic_clock(mpu9250_handle_t *handle, mpu9250_iic_clock_t clk)
set the iic clock
uint8_t mpu9250_get_disable_iic_slave(mpu9250_handle_t *handle, mpu9250_bool_t *enable)
get the iic slave status
uint8_t mpu9250_get_iic_delay_enable(mpu9250_handle_t *handle, mpu9250_iic_delay_t delay, mpu9250_bool_t *enable)
get the iic delay status
uint8_t mpu9250_set_disable_iic_slave(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the iic slave mode
uint8_t mpu9250_get_iic_transferred_len(mpu9250_handle_t *handle, mpu9250_iic_slave_t slave, uint8_t *len)
get the iic transferred length
uint8_t mpu9250_get_gyro_x_offset(mpu9250_handle_t *handle, int16_t *offset)
get the gyro x offset
uint8_t mpu9250_set_iic_address(mpu9250_handle_t *handle, mpu9250_iic_slave_t slave, uint8_t addr_7bit)
set the iic address
mpu9250_fifo_mode
mpu9250 fifo mode enumeration definition
mpu9250_low_power_accel_output_rate_t
mpu9250 low power accel output rate enumeration definition
uint8_t mpu9250_get_iic_status(mpu9250_handle_t *handle, uint8_t *status)
get the iic status
uint8_t mpu9250_read_extern_sensor_data(mpu9250_handle_t *handle, uint8_t *data, uint8_t len)
read the extern sensor data
uint8_t mpu9250_set_sample_rate_divider(mpu9250_handle_t *handle, uint8_t d)
set the sample rate divider
uint8_t mpu9250_fifo_set(mpu9250_handle_t *handle, uint8_t *buf, uint16_t len)
fifo write bytes
uint8_t mpu9250_get_iic_fifo_enable(mpu9250_handle_t *handle, mpu9250_iic_slave_t slave, mpu9250_bool_t *enable)
get the iic fifo status
uint8_t mpu9250_set_gyro_x_offset(mpu9250_handle_t *handle, int16_t offset)
set the gyro x offset
uint8_t mpu9250_set_accelerometer_x_offset(mpu9250_handle_t *handle, int16_t offset)
set the accelerometer x offset
mpu9250_iic_read_mode_t
mpu9250 iic read mode enumeration definition
uint8_t mpu9250_set_accelerometer_x_test(mpu9250_handle_t *handle, uint8_t data)
set the accelerometer x test
uint8_t mpu9250_set_fifo(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable fifo
uint8_t mpu9250_get_fifo_reset(mpu9250_handle_t *handle, mpu9250_bool_t *enable)
get the fifo reset status
uint8_t mpu9250_init(mpu9250_handle_t *handle)
initialize the chip
uint8_t mpu9250_set_iic_enable(mpu9250_handle_t *handle, mpu9250_iic_slave_t slave, mpu9250_bool_t enable)
enable or disable the iic
uint8_t mpu9250_get_iic_delay(mpu9250_handle_t *handle, uint8_t *delay)
get the iic delay
mpu9250_iic4_transaction_mode_t
mpu9250 iic4 transaction mode enumeration definition
uint8_t mpu9250_set_iic_delay(mpu9250_handle_t *handle, uint8_t delay)
set the iic delay
uint8_t mpu9250_set_accelerometer_choice(mpu9250_handle_t *handle, uint8_t choice)
set the accelerometer choice
mpu9250_iic_clock_t
mpu9250 iic clock enumeration definition
uint8_t mpu9250_set_iic4_interrupt(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the iic4 interrupt
uint8_t mpu9250_set_gyroscope_range(mpu9250_handle_t *handle, mpu9250_gyroscope_range_t range)
set the gyroscope range
mpu9250_iic_group_order_t
mpu9250 iic group order enumeration definition
uint8_t mpu9250_iic_master_reset(mpu9250_handle_t *handle)
reset the iic master controller
uint8_t mpu9250_get_device_reset(mpu9250_handle_t *handle, mpu9250_bool_t *enable)
get the device reset status
uint8_t mpu9250_get_accelerometer_x_offset(mpu9250_handle_t *handle, int16_t *offset)
get the accelerometer x offset
uint8_t mpu9250_set_iic_byte_swap(mpu9250_handle_t *handle, mpu9250_iic_slave_t slave, mpu9250_bool_t enable)
enable or disable the iic byte swap
uint8_t mpu9250_set_gyro_z_offset(mpu9250_handle_t *handle, int16_t offset)
set the gyro z offset
uint8_t mpu9250_set_interrupt_pin_type(mpu9250_handle_t *handle, mpu9250_pin_type_t type)
set the interrupt pin type
uint8_t mpu9250_get_fifo(mpu9250_handle_t *handle, mpu9250_bool_t *enable)
get the fifo status
uint8_t mpu9250_set_iic4_transaction_mode(mpu9250_handle_t *handle, mpu9250_iic4_transaction_mode_t mode)
set the iic4 transaction mode
uint8_t mpu9250_get_interrupt_latch(mpu9250_handle_t *handle, mpu9250_bool_t *enable)
get the interrupt latch status
uint8_t mpu9250_get_gyroscope_choice(mpu9250_handle_t *handle, uint8_t *choice)
get the gyroscope choice
uint8_t mpu9250_set_gyroscope_z_test(mpu9250_handle_t *handle, uint8_t data)
set the gyroscope z test
uint8_t mpu9250_set_iic_master(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the iic master mode
uint8_t mpu9250_get_iic_register(mpu9250_handle_t *handle, mpu9250_iic_slave_t slave, uint8_t *reg)
get the iic register
uint8_t mpu9250_set_accelerometer_range(mpu9250_handle_t *handle, mpu9250_accelerometer_range_t range)
set the accelerometer range
uint8_t mpu9250_gyro_offset_convert_to_register(mpu9250_handle_t *handle, float dps, int16_t *reg)
convert the gyro offset to the register raw data
uint8_t mpu9250_get_iic_wait_for_external_sensor(mpu9250_handle_t *handle, mpu9250_bool_t *enable)
get the iic wait for external sensor status
mpu9250_iic_mode_t
mpu9250 iic mode enumeration definition
mpu9250_axis_t
mpu9250 axis enumeration definition
uint8_t mpu9250_get_iic_clock(mpu9250_handle_t *handle, mpu9250_iic_clock_t *clk)
get the iic clock
mpu9250_accelerometer_low_pass_filter_t
mpu9250 accelerometer low pass filter enumeration definition
uint8_t mpu9250_set_iic_group_order(mpu9250_handle_t *handle, mpu9250_iic_slave_t slave, mpu9250_iic_group_order_t order)
set the iic group order
uint8_t mpu9250_get_motion_threshold(mpu9250_handle_t *handle, uint8_t *threshold)
get the motion_threshold
uint8_t mpu9250_set_sleep(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the sleep mode
uint8_t mpu9250_get_iic_address(mpu9250_handle_t *handle, mpu9250_iic_slave_t slave, uint8_t *addr_7bit)
get the iic address
uint8_t mpu9250_get_low_power_accel_output_rate(mpu9250_handle_t *handle, mpu9250_low_power_accel_output_rate_t *rate)
get the low power accel output rate
uint8_t mpu9250_set_iic4_enable(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the iic4
mpu9250_pin_level_t
mpu9250 pin level enumeration definition
mpu9250_fifo_t
mpu9250 fifo enumeration definition
mpu9250_clock_source_t
mpu9250 clock source enumeration definition
uint8_t mpu9250_force_fifo_reset(mpu9250_handle_t *handle)
force reset the fifo
@ MPU9250_INTERRUPT_MOTION
@ MPU9250_INTERRUPT_DATA_READY
@ MPU9250_INTERRUPT_FSYNC_INT
@ MPU9250_INTERRUPT_FIFO_OVERFLOW
uint8_t mpu9250_dmp_set_accel_bias(mpu9250_handle_t *handle, int32_t bias[3])
dmp set the accel bias
uint8_t mpu9250_dmp_set_tap_callback(mpu9250_handle_t *handle, void(*callback)(uint8_t count, uint8_t direction))
dmp set the tap callback
uint8_t mpu9250_dmp_get_fifo_rate(mpu9250_handle_t *handle, uint16_t *rate)
dmp get the fifo rate
uint8_t mpu9250_dmp_set_gyro_bias(mpu9250_handle_t *handle, int32_t bias[3])
dmp set the gyro bias
uint8_t mpu9250_dmp_set_shake_reject_timeout(mpu9250_handle_t *handle, uint16_t ms)
dmp set the shake reject timeout
uint8_t mpu9250_dmp_get_pedometer_walk_time(mpu9250_handle_t *handle, uint32_t *ms)
dmp get the pedometer walk time
uint8_t mpu9250_dmp_get_tap_time_multi(mpu9250_handle_t *handle, uint16_t *ms)
dmp get max time between taps to register as a multi tap
uint8_t mpu9250_dmp_set_6x_quaternion(mpu9250_handle_t *handle, mpu9250_bool_t enable)
dmp enable or disable generate 6 axis quaternions from dmp
uint8_t mpu9250_dmp_set_orientation(mpu9250_handle_t *handle, int8_t mat[9])
dmp set the orientation
uint8_t mpu9250_dmp_set_fifo_rate(mpu9250_handle_t *handle, uint16_t rate)
dmp set the fifo rate
uint8_t mpu9250_dmp_load_firmware(mpu9250_handle_t *handle)
load the dmp firmware
uint8_t mpu9250_dmp_set_3x_quaternion(mpu9250_handle_t *handle, mpu9250_bool_t enable)
dmp enable or disable generate 3 axis quaternions from dmp
uint8_t mpu9250_dmp_set_tap_axes(mpu9250_handle_t *handle, mpu9250_axis_t axis, mpu9250_bool_t enable)
dmp enable or disable the tap axes
uint8_t mpu9250_dmp_get_tap_axes(mpu9250_handle_t *handle, mpu9250_axis_t axis, mpu9250_bool_t *enable)
dmp get the tap axes status
uint8_t mpu9250_dmp_set_enable(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the dmp
uint8_t mpu9250_dmp_set_feature(mpu9250_handle_t *handle, uint16_t mask)
dmp enable or disable the dmp feature
uint8_t mpu9250_dmp_set_shake_reject_thresh(mpu9250_handle_t *handle, uint16_t dps)
dmp set the shake reject thresh
uint8_t mpu9250_dmp_set_orient_callback(mpu9250_handle_t *handle, void(*callback)(uint8_t orientation))
dmp set the orient callback
uint8_t mpu9250_dmp_set_interrupt_mode(mpu9250_handle_t *handle, mpu9250_dmp_interrupt_mode_t mode)
dmp set the interrupt mode
uint8_t mpu9250_dmp_get_shake_reject_time(mpu9250_handle_t *handle, uint16_t *ms)
dmp get the shake reject time
uint8_t mpu9250_dmp_get_pedometer_step_count(mpu9250_handle_t *handle, uint32_t *count)
dmp get the pedometer step count
uint8_t mpu9250_dmp_set_pedometer_step_count(mpu9250_handle_t *handle, uint32_t count)
dmp set the pedometer step count
uint8_t mpu9250_dmp_get_tap_thresh(mpu9250_handle_t *handle, mpu9250_axis_t axis, uint16_t *mg_ms)
dmp get the tap thresh
uint8_t mpu9250_dmp_set_shake_reject_time(mpu9250_handle_t *handle, uint16_t ms)
dmp set the shake reject time
uint8_t mpu9250_dmp_get_min_tap_count(mpu9250_handle_t *handle, uint8_t *cnt)
dmp get the min tap count
uint8_t mpu9250_dmp_get_tap_time(mpu9250_handle_t *handle, uint16_t *ms)
dmp get the tap time
mpu9250_dmp_interrupt_mode_t
mpu9250 dmp interrupt mode enumeration definition
uint8_t mpu9250_dmp_set_gyro_calibrate(mpu9250_handle_t *handle, mpu9250_bool_t enable)
dmp enable or disable gyro calibrate
uint8_t mpu9250_dmp_get_shake_reject_timeout(mpu9250_handle_t *handle, uint16_t *ms)
dmp get the shake reject timeout
uint8_t mpu9250_dmp_gyro_accel_raw_offset_convert(mpu9250_handle_t *handle, int32_t gyro_offset_raw[3], int32_t accel_offset_raw[3], int32_t gyro_offset[3], int32_t accel_offset[3])
dmp gyro accel raw offset convert
uint8_t mpu9250_dmp_set_tap_time(mpu9250_handle_t *handle, uint16_t ms)
dmp set the tap time
uint8_t mpu9250_dmp_set_tap_thresh(mpu9250_handle_t *handle, mpu9250_axis_t axis, uint16_t mg_ms)
dmp set the tap thresh
uint8_t mpu9250_dmp_set_min_tap_count(mpu9250_handle_t *handle, uint8_t cnt)
dmp set the min tap count
uint8_t mpu9250_dmp_set_pedometer_walk_time(mpu9250_handle_t *handle, uint32_t ms)
dmp set the pedometer walk time
uint8_t mpu9250_dmp_read(mpu9250_handle_t *handle, int16_t(*accel_raw)[3], float(*accel_g)[3], int16_t(*gyro_raw)[3], float(*gyro_dps)[3], int32_t(*quat)[4], float *pitch, float *roll, float *yaw, uint16_t *l)
dmp read the data
uint8_t mpu9250_dmp_set_tap_time_multi(mpu9250_handle_t *handle, uint16_t ms)
dmp set max time between taps to register as a multi tap
#define MPU9250_DMP_CODE_SIZE
mpu9250 dmp code definition
uint8_t mpu9250_dmp_get_shake_reject_thresh(mpu9250_handle_t *handle, uint16_t *dps)
dmp get the shake reject thresh
@ MPU9250_DMP_FEATURE_6X_QUAT
@ MPU9250_DMP_FEATURE_3X_QUAT
@ MPU9250_DMP_FEATURE_GYRO_CAL
@ MPU9250_DMP_FEATURE_PEDOMETER
@ MPU9250_DMP_FEATURE_SEND_CAL_GYRO
@ MPU9250_DMP_FEATURE_SEND_RAW_ACCEL
@ MPU9250_DMP_FEATURE_TAP
@ MPU9250_DMP_FEATURE_ORIENT
@ MPU9250_DMP_INTERRUPT_MODE_CONTINUOUS
uint8_t mpu9250_set_reg(mpu9250_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
set the chip register
uint8_t mpu9250_get_reg(mpu9250_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
get the chip register
uint8_t mpu9250_mag_get_status1(mpu9250_handle_t *handle, uint8_t *status)
magnetometer get the status1
mpu9250_magnetometer_bits_t
mpu9250 magnetometer bits enumeration definition
uint8_t mpu9250_mag_get_status2(mpu9250_handle_t *handle, uint8_t *status)
magnetometer get the status2
uint8_t mpu9250_mag_set_mode(mpu9250_handle_t *handle, mpu9250_magnetometer_mode_t mode)
magnetometer set the mode
uint8_t mpu9250_mag_iic_disable(mpu9250_handle_t *handle)
magnetometer disable the iic
uint8_t mpu9250_mag_get_mode(mpu9250_handle_t *handle, mpu9250_magnetometer_mode_t *mode)
magnetometer get the mode
uint8_t mpu9250_mag_get_self_test(mpu9250_handle_t *handle, mpu9250_bool_t *enable)
magnetometer get the self test status
uint8_t mpu9250_mag_get_bits(mpu9250_handle_t *handle, mpu9250_magnetometer_bits_t *bits)
magnetometer get the bits
uint8_t mpu9250_mag_set_bits(mpu9250_handle_t *handle, mpu9250_magnetometer_bits_t bits)
magnetometer set the bits
mpu9250_magnetometer_mode_t
mpu9250 magnetometer mode enumeration definition
uint8_t mpu9250_mag_set_reset(mpu9250_handle_t *handle, mpu9250_bool_t enable)
magnetometer enable or disable reset
uint8_t mpu9250_mag_get_info(mpu9250_handle_t *handle, uint8_t *info)
magnetometer get the information
uint8_t mpu9250_mag_get_asa(mpu9250_handle_t *handle, uint8_t asa[3])
magnetometer get the asa data
uint8_t mpu9250_mag_get_reset(mpu9250_handle_t *handle, mpu9250_bool_t *enable)
magnetometer get the reset status
uint8_t mpu9250_mag_init(mpu9250_handle_t *handle)
initialize the magnetometer of mpu9250
uint8_t mpu9250_mag_deinit(mpu9250_handle_t *handle)
magnetometer deinit
uint8_t mpu9250_mag_set_fifo_mode(mpu9250_handle_t *handle)
magnetometer set into fifo mode
uint8_t mpu9250_mag_set_self_test(mpu9250_handle_t *handle, mpu9250_bool_t enable)
magnetometer enable or disable self test
uint8_t mpu9250_mag_read(mpu9250_handle_t *handle, int16_t mag_raw[3], float mag_ut[3])
mag read the data
mpu9250 handle structure definition
void(* dmp_tap_callback)(uint8_t count, uint8_t direction)
uint8_t(* spi_init)(void)
void(* delay_ms)(uint32_t ms)
uint8_t(* spi_read)(uint8_t reg, uint8_t *buf, uint16_t len)
void(* receive_callback)(uint8_t type)
uint8_t(* spi_write)(uint8_t reg, uint8_t *buf, uint16_t len)
void(* debug_print)(const char *const fmt,...)
uint8_t(* iic_init)(void)
uint8_t(* spi_deinit)(void)
void(* dmp_orient_callback)(uint8_t orientation)
uint8_t(* iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_read)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_deinit)(void)
mpu9250 information structure definition
float supply_voltage_max_v
char manufacturer_name[32]
float supply_voltage_min_v