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))
228static 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,
275static 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)
312static 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)
348static uint8_t a_mpu9250_mag_write(
mpu9250_handle_t *handle, uint8_t reg, uint8_t *data)
378static uint8_t a_mpu9250_mag_read(
mpu9250_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
409static 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)
459static 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");
608static uint16_t a_mpu9250_inv_row_2_scale(int8_t *row)
650static 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;
666static 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;
703static 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)
786static 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;
1143 handle->
debug_print(
"mpu9250: set program start failed.\n");
1179 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
1185 tmp[0] = (uint8_t)((ms >> 24) & 0xFF);
1186 tmp[1] = (uint8_t)((ms >> 16) & 0xFF);
1187 tmp[2] = (uint8_t)((ms >> 8) & 0xFF);
1188 tmp[3] = (uint8_t)(ms & 0xFF);
1193 handle->
debug_print(
"mpu9250: write mem failed.\n");
1228 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
1236 handle->
debug_print(
"mpu9250: read mem failed.\n");
1240 *ms = (((uint32_t)tmp[0] << 24) | ((uint32_t)tmp[1] << 16) |
1241 ((uint32_t)tmp[2] << 8) | tmp[3]) * 20;
1273 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
1278 tmp[0] = (uint8_t)((count >> 24) & 0xFF);
1279 tmp[1] = (uint8_t)((count >> 16) & 0xFF);
1280 tmp[2] = (uint8_t)((count >> 8) & 0xFF);
1281 tmp[3] = (uint8_t)(count & 0xFF);
1286 handle->
debug_print(
"mpu9250: write mem failed.\n");
1321 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
1329 handle->
debug_print(
"mpu9250: read mem failed.\n");
1333 *count = (((uint32_t)tmp[0] << 24) | ((uint32_t)tmp[1] << 16) |
1334 ((uint32_t)tmp[2] << 8) | tmp[3]);
1366 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
1372 tmp[0] = (ms >> 8) & 0xFF;
1373 tmp[1] = (ms >> 0) & 0xFF;
1378 handle->
debug_print(
"mpu9250: write mem failed.\n");
1413 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
1421 handle->
debug_print(
"mpu9250: read mem failed.\n");
1425 *ms = (uint16_t)((uint16_t)tmp[0] << 8) | tmp[1];
1458 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
1464 tmp[0] = (ms >> 8) & 0xFF;
1465 tmp[1] = (ms >> 0) & 0xFF;
1470 handle->
debug_print(
"mpu9250: write mem failed.\n");
1505 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
1513 handle->
debug_print(
"mpu9250: read mem failed.\n");
1517 *ms = (uint16_t)((uint16_t)tmp[0] << 8) | tmp[1];
1539 uint32_t thresh_scaled;
1551 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
1557 tmp[0] = (uint8_t)(((uint32_t)thresh_scaled >> 24) & 0xFF);
1558 tmp[1] = (uint8_t)(((uint32_t)thresh_scaled >> 16) & 0xFF);
1559 tmp[2] = (uint8_t)(((uint32_t)thresh_scaled >> 8) & 0xFF);
1560 tmp[3] = (uint8_t)((uint32_t)thresh_scaled & 0xFF);
1565 handle->
debug_print(
"mpu9250: write mem failed.\n");
1589 uint32_t thresh_scaled;
1601 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
1609 handle->
debug_print(
"mpu9250: read mem failed.\n");
1613 thresh_scaled = (((uint32_t)tmp[0] << 24) | ((uint32_t)tmp[1] << 16) |
1614 ((uint32_t)tmp[2] << 8) | tmp[3]);
1615 *dps = (uint16_t)((
float)(thresh_scaled) /
1648 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
1654 tmp[0] = (ms >> 8) & 0xFF;
1655 tmp[1] = (ms >> 0) & 0xFF;
1660 handle->
debug_print(
"mpu9250: write mem failed.\n");
1695 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
1703 handle->
debug_print(
"mpu9250: read mem failed.\n");
1707 *ms = (uint16_t)((uint16_t)tmp[0] << 8) | tmp[1];
1740 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
1746 tmp[0] = (ms >> 8) & 0xFF;
1747 tmp[1] = (ms >> 0) & 0xFF;
1752 handle->
debug_print(
"mpu9250: write mem failed.\n");
1787 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
1795 handle->
debug_print(
"mpu9250: read mem failed.\n");
1799 *ms = (uint16_t)((uint16_t)tmp[0] << 8) | tmp[1];
1833 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
1837 if ((cnt < 1) || (cnt > 4))
1839 handle->
debug_print(
"mpu9250: cnt must be between 1 and 4.\n");
1848 handle->
debug_print(
"mpu9250: write mem failed.\n");
1883 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
1891 handle->
debug_print(
"mpu9250: read mem failed.\n");
1926 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
1933 uint8_t regs[9] = {0xb8, 0xaa, 0xb3, 0x8d, 0xb4, 0x98, 0x0d, 0x35, 0x5d};
1938 handle->
debug_print(
"mpu9250: write mem failed.\n");
1948 uint8_t regs[9] = {0xb8, 0xaa, 0xaa, 0xaa, 0xb0, 0x88, 0xc3, 0xc5, 0xc7};
1953 handle->
debug_print(
"mpu9250: write mem failed.\n");
1989 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
1996 uint8_t regs[4] = {0xC0, 0xC2, 0xC4, 0xC6};
2001 handle->
debug_print(
"mpu9250: write mem failed.\n");
2005 res = a_mpu9250_reset_fifo(handle);
2008 handle->
debug_print(
"mpu9250: reset fifo failed.\n");
2018 uint8_t regs[4] = {0x8B, 0x8B, 0x8B, 0x8B};
2023 handle->
debug_print(
"mpu9250: write mem failed.\n");
2027 res = a_mpu9250_reset_fifo(handle);
2030 handle->
debug_print(
"mpu9250: reset fifo failed.\n");
2066 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
2073 uint8_t regs[4] = {0x20, 0x28, 0x30, 0x38};
2078 handle->
debug_print(
"mpu9250: write mem failed.\n");
2082 res = a_mpu9250_reset_fifo(handle);
2085 handle->
debug_print(
"mpu9250: reset fifo failed.\n");
2095 uint8_t regs[4] = {0xA3, 0xA3, 0xA3, 0xA3};
2100 handle->
debug_print(
"mpu9250: write mem failed.\n");
2104 res = a_mpu9250_reset_fifo(handle);
2107 handle->
debug_print(
"mpu9250: reset fifo failed.\n");
2143 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
2150 uint8_t regs_continuous[11] = {0xd8, 0xb1, 0xb9,
2156 (uint8_t *)regs_continuous, 11);
2159 handle->
debug_print(
"mpu9250: write mem failed.\n");
2168 uint8_t regs_gesture[11] = {0xda, 0xb1, 0xb9,
2174 (uint8_t *)regs_gesture, 11);
2177 handle->
debug_print(
"mpu9250: write mem failed.\n");
2202 int32_t gyro_bias_body[3];
2214 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
2219 gyro_bias_body[0] = bias[handle->
orient & 3];
2220 if ((handle->
orient & 4) != 0)
2222 gyro_bias_body[0] *= -1;
2224 gyro_bias_body[1] = bias[(handle->
orient >> 3) & 3];
2225 if ((handle->
orient & 0x20) != 0)
2227 gyro_bias_body[1] *= -1;
2229 gyro_bias_body[2] = bias[(handle->
orient >> 6) & 3];
2230 if ((handle->
orient & 0x100) != 0)
2232 gyro_bias_body[2] *= -1;
2239 regs[0] = (uint8_t)((gyro_bias_body[0] >> 24) & 0xFF);
2240 regs[1] = (uint8_t)((gyro_bias_body[0] >> 16) & 0xFF);
2241 regs[2] = (uint8_t)((gyro_bias_body[0] >> 8) & 0xFF);
2242 regs[3] = (uint8_t)(gyro_bias_body[0] & 0xFF);
2246 handle->
debug_print(
"mpu9250: write mem failed.\n");
2250 regs[0] = (uint8_t)((gyro_bias_body[1] >> 24) & 0xFF);
2251 regs[1] = (uint8_t)((gyro_bias_body[1] >> 16) & 0xFF);
2252 regs[2] = (uint8_t)((gyro_bias_body[1] >> 8) & 0xFF);
2253 regs[3] = (uint8_t)(gyro_bias_body[1] & 0xFF);
2257 handle->
debug_print(
"mpu9250: write mem failed.\n");
2261 regs[0] = (uint8_t)((gyro_bias_body[2] >> 24) & 0xFF);
2262 regs[1] = (uint8_t)((gyro_bias_body[2] >> 16) & 0xFF);
2263 regs[2] = (uint8_t)((gyro_bias_body[2] >> 8) & 0xFF);
2264 regs[3] = (uint8_t)(gyro_bias_body[2] & 0xFF);
2268 handle->
debug_print(
"mpu9250: write mem failed.\n");
2293 int32_t accel_bias_body[3];
2307 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
2315 handle->
debug_print(
"mpu9250: read accelerometer config failed.\n");
2319 range = ((prev >> 3) & 0x3);
2322 accel_sf = (int64_t)16384 << 15;
2324 else if (range == 1)
2326 accel_sf = (int64_t)8192 << 15;
2328 else if (range == 2)
2330 accel_sf = (int64_t)4096 << 15;
2334 accel_sf = (int64_t)2048 << 15;
2337 accel_bias_body[0] = bias[handle->
orient & 3];
2338 if ((handle->
orient & 4) != 0)
2340 accel_bias_body[0] *= -1;
2342 accel_bias_body[1] = bias[(handle->
orient >> 3) & 3];
2343 if ((handle->
orient & 0x20) != 0)
2345 accel_bias_body[1] *= -1;
2347 accel_bias_body[2] = bias[(handle->
orient >> 6) & 3];
2348 if ((handle->
orient & 0x100) != 0)
2350 accel_bias_body[2] *= -1;
2353 accel_bias_body[0] = (int32_t)(((int64_t)accel_bias_body[0] * accel_sf) >> 30);
2354 accel_bias_body[1] = (int32_t)(((int64_t)accel_bias_body[1] * accel_sf) >> 30);
2355 accel_bias_body[2] = (int32_t)(((int64_t)accel_bias_body[2] * accel_sf) >> 30);
2356 regs[0] = (uint8_t)((accel_bias_body[0] >> 24) & 0xFF);
2357 regs[1] = (uint8_t)((accel_bias_body[0] >> 16) & 0xFF);
2358 regs[2] = (uint8_t)((accel_bias_body[0] >> 8) & 0xFF);
2359 regs[3] = (uint8_t)(accel_bias_body[0] & 0xFF);
2360 regs[4] = (uint8_t)((accel_bias_body[1] >> 24) & 0xFF);
2361 regs[5] = (uint8_t)((accel_bias_body[1] >> 16) & 0xFF);
2362 regs[6] = (uint8_t)((accel_bias_body[1] >> 8) & 0xFF);
2363 regs[7] = (uint8_t)(accel_bias_body[1] & 0xFF);
2364 regs[8] = (uint8_t)((accel_bias_body[2] >> 24) & 0xFF);
2365 regs[9] = (uint8_t)((accel_bias_body[2] >> 16) & 0xFF);
2366 regs[10] = (uint8_t)((accel_bias_body[2] >> 8) & 0xFF);
2367 regs[11] = (uint8_t)(accel_bias_body[2] & 0xFF);
2371 handle->
debug_print(
"mpu9250: write mem failed.\n");
2393 uint8_t gyro_axes[4] = {0x4C, 0xCD, 0x6C, 0x00};
2394 uint8_t accel_axes[4] = {0x0C, 0xC9, 0x2C, 0x00 };
2395 uint8_t gyro_sign[4] = {0x36, 0x56, 0x76, 0x00 };
2396 uint8_t accel_sign[4] = {0x26, 0x46, 0x66, 0x00 };
2398 uint8_t gyro_regs[3];
2399 uint8_t accel_regs[3];
2412 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
2417 orient = a_mpu9250_inv_orientation_matrix_to_scalar(mat);
2418 gyro_regs[0] = gyro_axes[orient & 3];
2419 gyro_regs[1] = gyro_axes[(orient >> 3) & 3];
2420 gyro_regs[2] = gyro_axes[(orient >> 6) & 3];
2421 accel_regs[0] = accel_axes[orient & 3];
2422 accel_regs[1] = accel_axes[(orient >> 3) & 3];
2423 accel_regs[2] = accel_axes[(orient >> 6) & 3];
2425 (uint8_t *)gyro_regs, 3);
2428 handle->
debug_print(
"mpu9250: write mem failed.\n");
2433 (uint8_t *)accel_regs, 3);
2436 handle->
debug_print(
"mpu9250: write mem failed.\n");
2441 memcpy(gyro_regs, gyro_sign, 3);
2442 memcpy(accel_regs, accel_sign, 3);
2443 if ((orient & 4) != 0)
2448 if ((orient & 0x20) != 0)
2453 if ((orient & 0x100) != 0)
2459 (uint8_t *)gyro_regs, 3);
2462 handle->
debug_print(
"mpu9250: write mem failed.\n");
2467 (uint8_t *)accel_regs, 3);
2470 handle->
debug_print(
"mpu9250: write mem failed.\n");
2510 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
2522 handle->
debug_print(
"mpu9250: write mem failed.\n");
2558 handle->
debug_print(
"mpu9250: write mem failed.\n");
2574 handle->
debug_print(
"mpu9250: write mem failed.\n");
2581 uint8_t regs[9] = {0xb8, 0xaa, 0xb3, 0x8d, 0xb4, 0x98, 0x0d, 0x35, 0x5d};
2586 handle->
debug_print(
"mpu9250: write mem failed.\n");
2593 uint8_t regs[9] = {0xb8, 0xaa, 0xaa, 0xaa, 0xb0, 0x88, 0xc3, 0xc5, 0xc7};
2598 handle->
debug_print(
"mpu9250: write mem failed.\n");
2623 handle->
debug_print(
"mpu9250: write mem failed.\n");
2634 uint32_t thresh_scaled;
2636 uint16_t dmp_thresh;
2637 uint16_t dmp_thresh_2;
2638 float scaled_thresh;
2644 handle->
debug_print(
"mpu9250: write mem failed.\n");
2653 handle->
debug_print(
"mpu9250: read accelerometer config failed.\n");
2657 range = ((prev >> 3) & 0x3);
2660 dmp_thresh = (uint16_t)(scaled_thresh * 16384);
2661 dmp_thresh_2 = (uint16_t)(scaled_thresh * 12288);
2663 else if (range == 1)
2665 dmp_thresh = (uint16_t)(scaled_thresh * 8192);
2666 dmp_thresh_2 = (uint16_t)(scaled_thresh * 6144);
2668 else if (range == 2)
2670 dmp_thresh = (uint16_t)(scaled_thresh * 4096);
2671 dmp_thresh_2 = (uint16_t)(scaled_thresh * 3072);
2675 dmp_thresh = (uint16_t)(scaled_thresh * 2048);
2676 dmp_thresh_2 = (uint16_t)(scaled_thresh * 1536);
2678 tmp[0] = (uint8_t)(dmp_thresh >> 8);
2679 tmp[1] = (uint8_t)(dmp_thresh & 0xFF);
2680 tmp[2] = (uint8_t)(dmp_thresh_2 >> 8);
2681 tmp[3] = (uint8_t)(dmp_thresh_2 & 0xFF);
2686 handle->
debug_print(
"mpu9250: write mem failed.\n");
2693 handle->
debug_print(
"mpu9250: write mem failed.\n");
2701 handle->
debug_print(
"mpu9250: write mem failed.\n");
2708 handle->
debug_print(
"mpu9250: write mem failed.\n");
2716 handle->
debug_print(
"mpu9250: write mem failed.\n");
2723 handle->
debug_print(
"mpu9250: write mem failed.\n");
2732 handle->
debug_print(
"mpu9250: write mem failed.\n");
2741 handle->
debug_print(
"mpu9250: write mem failed.\n");
2748 tmp[0] = (ms >> 8) & 0xFF;
2749 tmp[1] = (ms >> 0) & 0xFF;
2754 handle->
debug_print(
"mpu9250: write mem failed.\n");
2761 tmp[0] = (ms >> 8) & 0xFF;
2762 tmp[1] = (ms >> 0) & 0xFF;
2767 handle->
debug_print(
"mpu9250: write mem failed.\n");
2774 tmp[0] = (uint8_t)(((uint32_t)thresh_scaled >> 24) & 0xFF);
2775 tmp[1] = (uint8_t)(((uint32_t)thresh_scaled >> 16) & 0xFF);
2776 tmp[2] = (uint8_t)(((uint32_t)thresh_scaled >> 8) & 0xFF);
2777 tmp[3] = (uint8_t)((uint32_t)thresh_scaled & 0xFF);
2782 handle->
debug_print(
"mpu9250: write mem failed.\n");
2789 tmp[0] = (ms >> 8) & 0xFF;
2790 tmp[1] = (ms >> 0) & 0xFF;
2795 handle->
debug_print(
"mpu9250: write mem failed.\n");
2802 tmp[0] = (ms >> 8) & 0xFF;
2803 tmp[1] = (ms >> 0) & 0xFF;
2808 handle->
debug_print(
"mpu9250: write mem failed.\n");
2819 handle->
debug_print(
"mpu9250: write mem failed.\n");
2836 handle->
debug_print(
"mpu9250: write mem failed.\n");
2843 uint8_t regs[4] = {0xC0, 0xC2, 0xC4, 0xC6};
2848 handle->
debug_print(
"mpu9250: write mem failed.\n");
2852 res = a_mpu9250_reset_fifo(handle);
2855 handle->
debug_print(
"mpu9250: reset fifo failed.\n");
2862 uint8_t regs[4] = {0x8B, 0x8B, 0x8B, 0x8B};
2867 handle->
debug_print(
"mpu9250: write mem failed.\n");
2871 res = a_mpu9250_reset_fifo(handle);
2874 handle->
debug_print(
"mpu9250: reset fifo failed.\n");
2882 uint8_t regs[4] = {0x20, 0x28, 0x30, 0x38};
2887 handle->
debug_print(
"mpu9250: write mem failed.\n");
2891 res = a_mpu9250_reset_fifo(handle);
2894 handle->
debug_print(
"mpu9250: reset fifo failed.\n");
2901 uint8_t regs[4] = {0xA3, 0xA3, 0xA3, 0xA3};
2906 handle->
debug_print(
"mpu9250: write mem failed.\n");
2910 res = a_mpu9250_reset_fifo(handle);
2913 handle->
debug_print(
"mpu9250: reset fifo failed.\n");
2921 return a_mpu9250_reset_fifo(handle);
2939 uint8_t regs_end[12] = {0xFE, 0xF2, 0xAB,
2957 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
2969 tmp[0] = (uint8_t)((d >> 8) & 0xFF);
2970 tmp[1] = (uint8_t)(d & 0xFF);
2975 handle->
debug_print(
"mpu9250: write mem failed.\n");
2980 (uint8_t *)regs_end, 12);
2983 handle->
debug_print(
"mpu9250: write mem failed.\n");
3019 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
3027 handle->
debug_print(
"mpu9250: read mem failed.\n");
3031 d = (uint16_t)tmp[0] << 8 | tmp[1];
3066 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
3074 handle->
debug_print(
"mpu9250: read mem failed.\n");
3078 pos = (uint8_t)((axis - 5) * 2);
3090 handle->
debug_print(
"mpu9250: write mem failed.\n");
3127 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
3135 handle->
debug_print(
"mpu9250: read mem failed.\n");
3139 pos = (uint8_t)((axis - 5) * 2);
3140 if (((tmp >> pos) & 0x3) == 0x3)
3173 uint16_t dmp_thresh;
3174 uint16_t dmp_thresh_2;
3175 float scaled_thresh;
3187 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
3200 (uint8_t *)&prev, 1);
3203 handle->
debug_print(
"mpu9250: read accelerometer config failed.\n");
3207 range = ((prev >> 3) & 0x3);
3210 dmp_thresh = (uint16_t)(scaled_thresh * 16384);
3211 dmp_thresh_2 = (uint16_t)(scaled_thresh * 12288);
3213 else if (range == 1)
3215 dmp_thresh = (uint16_t)(scaled_thresh * 8192);
3216 dmp_thresh_2 = (uint16_t)(scaled_thresh * 6144);
3218 else if (range == 2)
3220 dmp_thresh = (uint16_t)(scaled_thresh * 4096);
3221 dmp_thresh_2 = (uint16_t)(scaled_thresh * 3072);
3225 dmp_thresh = (uint16_t)(scaled_thresh * 2048);
3226 dmp_thresh_2 = (uint16_t)(scaled_thresh * 1536);
3228 tmp[0] = (uint8_t)(dmp_thresh >> 8);
3229 tmp[1] = (uint8_t)(dmp_thresh & 0xFF);
3230 tmp[2] = (uint8_t)(dmp_thresh_2 >> 8);
3231 tmp[3] = (uint8_t)(dmp_thresh_2 & 0xFF);
3238 handle->
debug_print(
"mpu9250: write mem failed.\n");
3245 handle->
debug_print(
"mpu9250: write mem failed.\n");
3257 handle->
debug_print(
"mpu9250: write mem failed.\n");
3264 handle->
debug_print(
"mpu9250: write mem failed.\n");
3276 handle->
debug_print(
"mpu9250: write mem failed.\n");
3283 handle->
debug_print(
"mpu9250: write mem failed.\n");
3318 uint16_t dmp_thresh;
3319 float scaled_thresh;
3331 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
3341 handle->
debug_print(
"mpu9250: read mem failed.\n");
3351 handle->
debug_print(
"mpu9250: read mem failed.\n");
3361 handle->
debug_print(
"mpu9250: read mem failed.\n");
3372 dmp_thresh = (uint16_t)tmp[0] << 8 | tmp[1];
3375 (uint8_t *)&prev, 1);
3378 handle->
debug_print(
"mpu9250: read accelerometer config failed.\n");
3382 range = ((prev >> 3) & 0x3);
3385 scaled_thresh = dmp_thresh / 16384.0f;
3387 else if (range == 1)
3389 scaled_thresh = dmp_thresh / 8192.0f;
3391 else if (range == 2)
3393 scaled_thresh = dmp_thresh / 4096.0f;
3397 scaled_thresh = dmp_thresh / 2048.0f;
3429 int16_t (*accel_raw)[3],
float (*accel_g)[3],
3430 int16_t (*gyro_raw)[3],
float (*gyro_dps)[3],
3432 float *pitch,
float *roll,
float *yaw,
3454 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
3462 handle->
debug_print(
"mpu9250: read int status failed.\n");
3469 (void)a_mpu9250_reset_fifo(handle);
3501 handle->
debug_print(
"mpu9250: read fifo count failed.\n");
3505 count = (uint16_t)(((uint16_t)buf[0] << 8) | buf[1]);
3506 count = (count < 1024) ? count : 1024;
3507 count = (count < (*l) * len) ? count : ((*l) *len);
3508 count = (count / len) * len;
3519 handle->
debug_print(
"mpu9250: fifo data is too little.\n");
3524 for (j = 0; j < (*l); j++)
3528 int32_t quat_q14[4];
3529 int32_t quat_mag_sq;
3530 float q0 = 1.0f, q1 = 0.0f, q2 = 0.0f, q3 = 0.0f;
3533 quat[j][0] = ((int32_t)handle->
buf[0 + len * j] << 24) | ((int32_t)handle->
buf[1 + len * j] << 16) |
3534 ((int32_t)handle->
buf[2 + len * j] << 8) | handle->
buf[3 + len * j];
3535 quat[j][1] = ((int32_t)handle->
buf[4 + len * j] << 24) | ((int32_t)handle->
buf[5 + len * j] << 16) |
3536 ((int32_t)handle->
buf[6 + len * j] << 8) | handle->
buf[7 + len * j];
3537 quat[j][2] = ((int32_t)handle->
buf[8 + len * j] << 24) | ((int32_t)handle->
buf[9 + len * j] << 16) |
3538 ((int32_t)handle->
buf[10 + len * j] << 8) | handle->
buf[11 + len * j];
3539 quat[j][3] = ((int32_t)handle->
buf[12 + len * j] << 24) | ((int32_t)handle->
buf[13 + len * j] << 16) |
3540 ((int32_t)handle->
buf[14 + len * j] << 8) | handle->
buf[15 + len * j];
3543 quat_q14[0] = quat[j][0] >> 16;
3544 quat_q14[1] = quat[j][1] >> 16;
3545 quat_q14[2] = quat[j][2] >> 16;
3546 quat_q14[3] = quat[j][3] >> 16;
3547 quat_mag_sq = quat_q14[0] * quat_q14[0] + quat_q14[1] * quat_q14[1] +
3548 quat_q14[2] * quat_q14[2] + quat_q14[3] * quat_q14[3];
3552 handle->
debug_print(
"mpu9250: quat check error.\n");
3553 (void)a_mpu9250_reset_fifo(handle);
3557 q0 = quat[j][0] / 1073741824.0f;
3558 q1 = quat[j][1] / 1073741824.0f;
3559 q2 = quat[j][2] / 1073741824.0f;
3560 q3 = quat[j][3] / 1073741824.0f;
3561 pitch[j] = asinf(-2 * q1 * q3 + 2 * q0* q2)* 57.3f;
3562 roll[j] = atan2f(2 * q2 * q3 + 2 * q0 * q1, -2 * q1 * q1 - 2 * q2 * q2 + 1)* 57.3f;
3563 yaw[j] = atan2f(2 * (q1 * q2 + q0 * q3), q0 * q0 + q1 * q1 - q2 * q2 - q3 * q3) * 57.3f;
3579 accel_raw[j][0] = ((int16_t)handle->
buf[i + 0 + len * j] << 8) | handle->
buf[i + 1 + len * j];
3580 accel_raw[j][1] = ((int16_t)handle->
buf[i + 2 + len * j] << 8) | handle->
buf[i + 3 + len * j];
3581 accel_raw[j][2] = ((int16_t)handle->
buf[i + 4 + len * j] << 8) | handle->
buf[i + 5 + len * j];
3587 handle->
debug_print(
"mpu9250: read accel config failed.\n");
3591 accel_conf = (accel_conf >> 3) & 0x3;
3592 if (accel_conf == 0)
3594 accel_g[j][0] = (float)(accel_raw[j][0]) / 16384.0f;
3595 accel_g[j][1] = (float)(accel_raw[j][1]) / 16384.0f;
3596 accel_g[j][2] = (float)(accel_raw[j][2]) / 16384.0f;
3598 else if (accel_conf == 1)
3600 accel_g[j][0] = (float)(accel_raw[j][0]) / 8192.0f;
3601 accel_g[j][1] = (float)(accel_raw[j][1]) / 8192.0f;
3602 accel_g[j][2] = (float)(accel_raw[j][2]) / 8192.0f;
3604 else if (accel_conf == 2)
3606 accel_g[j][0] = (float)(accel_raw[j][0]) / 4096.0f;
3607 accel_g[j][1] = (float)(accel_raw[j][1]) / 4096.0f;
3608 accel_g[j][2] = (float)(accel_raw[j][2]) / 4096.0f;
3612 accel_g[j][0] = (float)(accel_raw[j][0]) / 2048.0f;
3613 accel_g[j][1] = (float)(accel_raw[j][1]) / 2048.0f;
3614 accel_g[j][2] = (float)(accel_raw[j][2]) / 2048.0f;
3619 accel_raw[j][0] = 0;
3620 accel_raw[j][1] = 0;
3621 accel_raw[j][2] = 0;
3622 accel_g[j][0] = 0.0f;
3623 accel_g[j][1] = 0.0f;
3624 accel_g[j][2] = 0.0f;
3630 gyro_raw[j][0] = ((int16_t)handle->
buf[i + 0 + len * j] << 8) | handle->
buf[i + 1 + len * j];
3631 gyro_raw[j][1] = ((int16_t)handle->
buf[i + 2 + len * j] << 8) | handle->
buf[i + 3 + len * j];
3632 gyro_raw[j][2] = ((int16_t)handle->
buf[i + 4 + len * j] << 8) | handle->
buf[i + 5 + len * j];
3638 handle->
debug_print(
"mpu9250: read gyro config failed.\n");
3642 gyro_conf = (gyro_conf >> 3) & 0x3;
3645 gyro_dps[j][0] = (float)(gyro_raw[j][0]) / 131.0f;
3646 gyro_dps[j][1] = (float)(gyro_raw[j][1]) / 131.0f;
3647 gyro_dps[j][2] = (float)(gyro_raw[j][2]) / 131.0f;
3649 else if (gyro_conf == 1)
3651 gyro_dps[j][0] = (float)(gyro_raw[j][0]) / 65.5f;
3652 gyro_dps[j][1] = (float)(gyro_raw[j][1]) / 65.5f;
3653 gyro_dps[j][2] = (float)(gyro_raw[j][2]) / 65.5f;
3655 else if (gyro_conf == 2)
3657 gyro_dps[j][0] = (float)(gyro_raw[j][0]) / 32.8f;
3658 gyro_dps[j][1] = (float)(gyro_raw[j][1]) / 32.8f;
3659 gyro_dps[j][2] = (float)(gyro_raw[j][2]) / 32.8f;
3663 gyro_dps[j][0] = (float)(gyro_raw[j][0]) / 16.4f;
3664 gyro_dps[j][1] = (float)(gyro_raw[j][1]) / 16.4f;
3665 gyro_dps[j][2] = (float)(gyro_raw[j][2]) / 16.4f;
3673 gyro_dps[j][0] = 0.0f;
3674 gyro_dps[j][1] = 0.0f;
3675 gyro_dps[j][2] = 0.0f;
3679 a_mpu9250_dmp_decode_gesture(handle, handle->
buf + i + len * j);
3710 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
3744 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
3781 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
3789 handle->
debug_print(
"mpu9250: read user ctrl failed.\n");
3794 prev |= enable << 7;
3798 handle->
debug_print(
"mpu9250: write user ctrl failed.\n");
3822 int32_t gyro_offset_raw[3], int32_t accel_offset_raw[3],
3823 int32_t gyro_offset[3], int32_t accel_offset[3])
3839 handle->
debug_print(
"mpu9250: dmp is not inited.\n");
3847 handle->
debug_print(
"mpu9250: read accel config failed.\n");
3854 handle->
debug_print(
"mpu9250: read gyro config failed.\n");
3858 accel_conf = (accel_conf >> 3) & 0x3;
3859 gyro_conf = (gyro_conf >> 3) & 0x3;
3860 if (accel_conf == 0)
3862 accel_offset[0] = (int32_t)(accel_offset_raw[0] * 16384.0f);
3863 accel_offset[1] = (int32_t)(accel_offset_raw[1] * 16384.0f);
3864 accel_offset[2] = (int32_t)(accel_offset_raw[2] * 16384.0f);
3866 else if (accel_conf == 1)
3868 accel_offset[0] = (int32_t)(accel_offset_raw[0] * 8192.0f);
3869 accel_offset[1] = (int32_t)(accel_offset_raw[1] * 8192.0f);
3870 accel_offset[2] = (int32_t)(accel_offset_raw[2] * 8192.0f);
3872 else if (accel_conf == 2)
3874 accel_offset[0] = (int32_t)(accel_offset_raw[0] * 4096.0f);
3875 accel_offset[1] = (int32_t)(accel_offset_raw[1] * 4096.0f);
3876 accel_offset[2] = (int32_t)(accel_offset_raw[2] * 4096.0f);
3880 accel_offset[0] = (int32_t)(accel_offset_raw[0] * 2048.0f);
3881 accel_offset[1] = (int32_t)(accel_offset_raw[1] * 2048.0f);
3882 accel_offset[2] = (int32_t)(accel_offset_raw[2] * 2048.0f);
3886 gyro_offset[0] = (int32_t)(gyro_offset_raw[0] * 131.f);
3887 gyro_offset[1] = (int32_t)(gyro_offset_raw[1] * 131.f);
3888 gyro_offset[2] = (int32_t)(gyro_offset_raw[2] * 131.f);
3890 else if (gyro_conf == 1)
3892 gyro_offset[0] = (int32_t)(gyro_offset_raw[0] * 65.5f);
3893 gyro_offset[1] = (int32_t)(gyro_offset_raw[1] * 65.5f);
3894 gyro_offset[2] = (int32_t)(gyro_offset_raw[2] * 65.5f);
3896 else if (gyro_conf == 2)
3898 gyro_offset[0] = (int32_t)(gyro_offset_raw[0] * 32.8f);
3899 gyro_offset[1] = (int32_t)(gyro_offset_raw[1] * 32.8f);
3900 gyro_offset[2] = (int32_t)(gyro_offset_raw[2] * 32.8f);
3904 gyro_offset[0] = (int32_t)(gyro_offset_raw[0] * 16.4f);
3905 gyro_offset[1] = (int32_t)(gyro_offset_raw[1] * 16.4f);
3906 gyro_offset[2] = (int32_t)(gyro_offset_raw[2] * 16.4f);
3928 handle->
iic_spi = (uint8_t)interface;
3970 handle->
iic_addr = (uint8_t)addr_pin;
4023 handle->
debug_print(
"mpu9250: iic_init is null.\n");
4029 handle->
debug_print(
"mpu9250: iic_deinit is null.\n");
4035 handle->
debug_print(
"mpu9250: iic_read is null.\n");
4041 handle->
debug_print(
"mpu9250: iic_write is null.\n");
4047 handle->
debug_print(
"mpu9250: spi_init is null.\n");
4053 handle->
debug_print(
"mpu9250: spi_deinit is null.\n");
4059 handle->
debug_print(
"mpu9250: spi_read is null.\n");
4065 handle->
debug_print(
"mpu9250: spi_write is null.\n");
4071 handle->
debug_print(
"mpu9250: delay_ms is null.\n");
4077 handle->
debug_print(
"mpu9250: receive_callback is null.\n");
4087 handle->
debug_print(
"mpu9250: iic init failed.\n");
4097 handle->
debug_print(
"mpu9250: spi init failed.\n");
4106 handle->
debug_print(
"mpu9250: read who am i failed.\n");
4107 (void)a_mpu9250_deinit(handle);
4114 (void)a_mpu9250_deinit(handle);
4123 handle->
debug_print(
"mpu9250: write pwr mgmt 1 failed.\n");
4124 (void)a_mpu9250_deinit(handle);
4130 while (timeout != 0)
4135 handle->
debug_print(
"mpu9250: read pwr mgmt 1 failed.\n");
4136 (void)a_mpu9250_deinit(handle);
4140 if ((prev & (1 << 7)) == 0)
4181 prev = (1 << 6) | (1 << 3) | (7 << 0);
4185 handle->
debug_print(
"mpu9250: write pwr mgmt 1 failed.\n");
4189 res = a_mpu9250_deinit(handle);
4223 int16_t (*accel_raw)[3],
float (*accel_g)[3],
4224 int16_t (*gyro_raw)[3],
float (*gyro_dps)[3],
4225 int16_t (*mag_raw)[3],
float (*mag_ut)[3],
4244 handle->
debug_print(
"mpu9250: length is zero.\n");
4250 handle->
debug_print(
"mpu9250: dmp is running.\n");
4258 handle->
debug_print(
"mpu9250: read user ctrl failed.\n");
4265 handle->
debug_print(
"mpu9250: read accel config failed.\n");
4272 handle->
debug_print(
"mpu9250: read gyro config failed.\n");
4276 accel_conf = (accel_conf >> 3) & 0x3;
4277 gyro_conf = (gyro_conf >> 3) & 0x3;
4278 if ((prev & (1 << 6)) != 0)
4288 handle->
debug_print(
"mpu9250: read fifo enable failed.\n");
4292 if ((conf != 0x78) && (conf != 0x79))
4294 handle->
debug_print(
"mpu9250: fifo conf is error.\n");
4302 handle->
debug_print(
"mpu9250: read fifo count failed.\n");
4309 count = (uint16_t)(((uint16_t)buf[0] << 8) | buf[1]);
4310 count = (count < 1024) ? count : 1024;
4311 count = (count < ((*len) * 12)) ? count : ((*len) * 12);
4312 count = (count / 12) * 12;
4321 for (i = 0; i < (*len); i++)
4323 accel_raw[i][0] = (int16_t)((uint16_t)handle->
buf[i * 12 + 0] << 8) |
4324 handle->
buf[i * 12 + 1];
4325 accel_raw[i][1] = (int16_t)((uint16_t)handle->
buf[i * 12 + 2] << 8) |
4326 handle->
buf[i * 12 + 3];
4327 accel_raw[i][2] = (int16_t)((uint16_t)handle->
buf[i * 12 + 4] << 8) |
4328 handle->
buf[i * 12 + 5];
4329 gyro_raw[i][0] = (int16_t)((uint16_t)handle->
buf[i * 12 + 6] << 8) |
4330 handle->
buf[i * 12 + 7];
4331 gyro_raw[i][1] = (int16_t)((uint16_t)handle->
buf[i * 12 + 8] << 8) |
4332 handle->
buf[i * 12 + 9];
4333 gyro_raw[i][2] = (int16_t)((uint16_t)handle->
buf[i * 12 + 10] << 8) |
4334 handle->
buf[i * 12 + 11];
4339 if (accel_conf == 0)
4341 accel_g[i][0] = (float)(accel_raw[i][0]) / 16384.0f;
4342 accel_g[i][1] = (float)(accel_raw[i][1]) / 16384.0f;
4343 accel_g[i][2] = (float)(accel_raw[i][2]) / 16384.0f;
4345 else if (accel_conf == 1)
4347 accel_g[i][0] = (float)(accel_raw[i][0]) / 8192.0f;
4348 accel_g[i][1] = (float)(accel_raw[i][1]) / 8192.0f;
4349 accel_g[i][2] = (float)(accel_raw[i][2]) / 8192.0f;
4351 else if (accel_conf == 2)
4353 accel_g[i][0] = (float)(accel_raw[i][0]) / 4096.0f;
4354 accel_g[i][1] = (float)(accel_raw[i][1]) / 4096.0f;
4355 accel_g[i][2] = (float)(accel_raw[i][2]) / 4096.0f;
4359 accel_g[i][0] = (float)(accel_raw[i][0]) / 2048.0f;
4360 accel_g[i][1] = (float)(accel_raw[i][1]) / 2048.0f;
4361 accel_g[i][2] = (float)(accel_raw[i][2]) / 2048.0f;
4366 gyro_dps[i][0] = (float)(gyro_raw[i][0]) / 131.0f;
4367 gyro_dps[i][1] = (float)(gyro_raw[i][1]) / 131.0f;
4368 gyro_dps[i][2] = (float)(gyro_raw[i][2]) / 131.0f;
4370 else if (gyro_conf == 1)
4372 gyro_dps[i][0] = (float)(gyro_raw[i][0]) / 65.5f;
4373 gyro_dps[i][1] = (float)(gyro_raw[i][1]) / 65.5f;
4374 gyro_dps[i][2] = (float)(gyro_raw[i][2]) / 65.5f;
4376 else if (gyro_conf == 2)
4378 gyro_dps[i][0] = (float)(gyro_raw[i][0]) / 32.8f;
4379 gyro_dps[i][1] = (float)(gyro_raw[i][1]) / 32.8f;
4380 gyro_dps[i][2] = (float)(gyro_raw[i][2]) / 32.8f;
4384 gyro_dps[i][0] = (float)(gyro_raw[i][0]) / 16.4f;
4385 gyro_dps[i][1] = (float)(gyro_raw[i][1]) / 16.4f;
4386 gyro_dps[i][2] = (float)(gyro_raw[i][2]) / 16.4f;
4388 mag_ut[i][0] = 0.0f;
4389 mag_ut[i][1] = 0.0f;
4390 mag_ut[i][2] = 0.0f;
4401 count = (uint16_t)(((uint16_t)buf[0] << 8) | buf[1]);
4402 count = (count < 1024) ? count : 1024;
4403 count = (count < ((*len) * 20)) ? count : ((*len) * 20);
4404 count = (count / 20) * 20;
4414 mag_k_x = ((float)handle->
mag_asa[0] - 128.0f) * 0.5f / 128.0f + 1.0f;
4415 mag_k_y = ((float)handle->
mag_asa[1] - 128.0f) * 0.5f / 128.0f + 1.0f;
4416 mag_k_z = ((float)handle->
mag_asa[2] - 128.0f) * 0.5f / 128.0f + 1.0f;
4418 for (i = 0; i < (*len); i++)
4420 accel_raw[i][0] = (int16_t)((uint16_t)handle->
buf[i * 20 + 0] << 8) |
4421 handle->
buf[i * 20 + 1];
4422 accel_raw[i][1] = (int16_t)((uint16_t)handle->
buf[i * 20 + 2] << 8) |
4423 handle->
buf[i * 20 + 3];
4424 accel_raw[i][2] = (int16_t)((uint16_t)handle->
buf[i * 20 + 4] << 8) |
4425 handle->
buf[i * 20 + 5];
4426 gyro_raw[i][0] = (int16_t)((uint16_t)handle->
buf[i * 20 + 6] << 8) |
4427 handle->
buf[i * 20 + 7];
4428 gyro_raw[i][1] = (int16_t)((uint16_t)handle->
buf[i * 20 + 8] << 8) |
4429 handle->
buf[i * 20 + 9];
4430 gyro_raw[i][2] = (int16_t)((uint16_t)handle->
buf[i * 20 + 10] << 8) |
4431 handle->
buf[i * 20 + 11];
4432 mag_raw[i][0] = (int16_t)((uint16_t)handle->
buf[i * 20 + 14] << 8) |
4433 handle->
buf[i * 20 + 13];
4434 mag_raw[i][1] = (int16_t)((uint16_t)handle->
buf[i * 20 + 16] << 8) |
4435 handle->
buf[i * 20 + 15];
4436 mag_raw[i][2] = (int16_t)((uint16_t)handle->
buf[i * 20 + 18] << 8) |
4437 handle->
buf[i * 20 + 17];
4439 if (accel_conf == 0)
4441 accel_g[i][0] = (float)(accel_raw[i][0]) / 16384.0f;
4442 accel_g[i][1] = (float)(accel_raw[i][1]) / 16384.0f;
4443 accel_g[i][2] = (float)(accel_raw[i][2]) / 16384.0f;
4445 else if (accel_conf == 1)
4447 accel_g[i][0] = (float)(accel_raw[i][0]) / 8192.0f;
4448 accel_g[i][1] = (float)(accel_raw[i][1]) / 8192.0f;
4449 accel_g[i][2] = (float)(accel_raw[i][2]) / 8192.0f;
4451 else if (accel_conf == 2)
4453 accel_g[i][0] = (float)(accel_raw[i][0]) / 4096.0f;
4454 accel_g[i][1] = (float)(accel_raw[i][1]) / 4096.0f;
4455 accel_g[i][2] = (float)(accel_raw[i][2]) / 4096.0f;
4459 accel_g[i][0] = (float)(accel_raw[i][0]) / 2048.0f;
4460 accel_g[i][1] = (float)(accel_raw[i][1]) / 2048.0f;
4461 accel_g[i][2] = (float)(accel_raw[i][2]) / 2048.0f;
4466 gyro_dps[i][0] = (float)(gyro_raw[i][0]) / 131.0f;
4467 gyro_dps[i][1] = (float)(gyro_raw[i][1]) / 131.0f;
4468 gyro_dps[i][2] = (float)(gyro_raw[i][2]) / 131.0f;
4470 else if (gyro_conf == 1)
4472 gyro_dps[i][0] = (float)(gyro_raw[i][0]) / 65.5f;
4473 gyro_dps[i][1] = (float)(gyro_raw[i][1]) / 65.5f;
4474 gyro_dps[i][2] = (float)(gyro_raw[i][2]) / 65.5f;
4476 else if (gyro_conf == 2)
4478 gyro_dps[i][0] = (float)(gyro_raw[i][0]) / 32.8f;
4479 gyro_dps[i][1] = (float)(gyro_raw[i][1]) / 32.8f;
4480 gyro_dps[i][2] = (float)(gyro_raw[i][2]) / 32.8f;
4484 gyro_dps[i][0] = (float)(gyro_raw[i][0]) / 16.4f;
4485 gyro_dps[i][1] = (float)(gyro_raw[i][1]) / 16.4f;
4486 gyro_dps[i][2] = (float)(gyro_raw[i][2]) / 16.4f;
4488 if ((handle->
buf[i * 20 + 19] & (1 << 4)) != 0)
4490 mag_ut[i][0] = (float)mag_raw[i][0] * mag_k_x * 0.15f;
4491 mag_ut[i][1] = (float)mag_raw[i][1] * mag_k_y * 0.15f;
4492 mag_ut[i][2] = (float)mag_raw[i][2] * mag_k_z * 0.15f;
4496 mag_ut[i][0] = (float)mag_raw[i][0] * mag_k_x * 0.6f;
4497 mag_ut[i][1] = (float)mag_raw[i][1] * mag_k_y * 0.6f;
4498 mag_ut[i][2] = (float)mag_raw[i][2] * mag_k_z * 0.6f;
4515 accel_raw[0][0] = (int16_t)((uint16_t)handle->
buf[0] << 8) | handle->
buf[1];
4516 accel_raw[0][1] = (int16_t)((uint16_t)handle->
buf[2] << 8) | handle->
buf[3];
4517 accel_raw[0][2] = (int16_t)((uint16_t)handle->
buf[4] << 8) | handle->
buf[5];
4518 gyro_raw[0][0] = (int16_t)((uint16_t)handle->
buf[8] << 8) | handle->
buf[9];
4519 gyro_raw[0][1] = (int16_t)((uint16_t)handle->
buf[10] << 8) | handle->
buf[11];
4520 gyro_raw[0][2] = (int16_t)((uint16_t)handle->
buf[12] << 8) | handle->
buf[13];
4522 if (accel_conf == 0)
4524 accel_g[0][0] = (float)(accel_raw[0][0]) / 16384.0f;
4525 accel_g[0][1] = (float)(accel_raw[0][1]) / 16384.0f;
4526 accel_g[0][2] = (float)(accel_raw[0][2]) / 16384.0f;
4528 else if (accel_conf == 1)
4530 accel_g[0][0] = (float)(accel_raw[0][0]) / 8192.0f;
4531 accel_g[0][1] = (float)(accel_raw[0][1]) / 8192.0f;
4532 accel_g[0][2] = (float)(accel_raw[0][2]) / 8192.0f;
4534 else if (accel_conf == 2)
4536 accel_g[0][0] = (float)(accel_raw[0][0]) / 4096.0f;
4537 accel_g[0][1] = (float)(accel_raw[0][1]) / 4096.0f;
4538 accel_g[0][2] = (float)(accel_raw[0][2]) / 4096.0f;
4542 accel_g[0][0] = (float)(accel_raw[0][0]) / 2048.0f;
4543 accel_g[0][1] = (float)(accel_raw[0][1]) / 2048.0f;
4544 accel_g[0][2] = (float)(accel_raw[0][2]) / 2048.0f;
4549 gyro_dps[0][0] = (float)(gyro_raw[0][0]) / 131.0f;
4550 gyro_dps[0][1] = (float)(gyro_raw[0][1]) / 131.0f;
4551 gyro_dps[0][2] = (float)(gyro_raw[0][2]) / 131.0f;
4553 else if (gyro_conf == 1)
4555 gyro_dps[0][0] = (float)(gyro_raw[0][0]) / 65.5f;
4556 gyro_dps[0][1] = (float)(gyro_raw[0][1]) / 65.5f;
4557 gyro_dps[0][2] = (float)(gyro_raw[0][2]) / 65.5f;
4559 else if (gyro_conf == 2)
4561 gyro_dps[0][0] = (float)(gyro_raw[0][0]) / 32.8f;
4562 gyro_dps[0][1] = (float)(gyro_raw[0][1]) / 32.8f;
4563 gyro_dps[0][2] = (float)(gyro_raw[0][2]) / 32.8f;
4567 gyro_dps[0][0] = (float)(gyro_raw[0][0]) / 16.4f;
4568 gyro_dps[0][1] = (float)(gyro_raw[0][1]) / 16.4f;
4569 gyro_dps[0][2] = (float)(gyro_raw[0][2]) / 16.4f;
4580 handle->
debug_print(
"mpu9250: mag read failed.\n");
4584 mag_raw[0][0] = (int16_t)((uint16_t)handle->
buf[2] << 8) | handle->
buf[1];
4585 mag_raw[0][1] = (int16_t)((uint16_t)handle->
buf[4] << 8) | handle->
buf[3];
4586 mag_raw[0][2] = (int16_t)((uint16_t)handle->
buf[6] << 8) | handle->
buf[5];
4588 mag_k_x = ((float)handle->
mag_asa[0] - 128.0f) * 0.5f / 128.0f + 1.0f;
4589 mag_k_y = ((float)handle->
mag_asa[1] - 128.0f) * 0.5f / 128.0f + 1.0f;
4590 mag_k_z = ((float)handle->
mag_asa[2] - 128.0f) * 0.5f / 128.0f + 1.0f;
4591 if ((handle->
buf[7] & (1 << 4)) != 0)
4593 mag_ut[0][0] = (float)mag_raw[0][0] * mag_k_x * 0.15f;
4594 mag_ut[0][1] = (float)mag_raw[0][1] * mag_k_y * 0.15f;
4595 mag_ut[0][2] = (float)mag_raw[0][2] * mag_k_z * 0.15f;
4599 mag_ut[0][0] = (float)mag_raw[0][0] * mag_k_x * 0.6f;
4600 mag_ut[0][1] = (float)mag_raw[0][1] * mag_k_y * 0.6f;
4601 mag_ut[0][2] = (float)mag_raw[0][2] * mag_k_z * 0.6f;
4609 mag_ut[0][0] = 0.0f;
4610 mag_ut[0][1] = 0.0f;
4611 mag_ut[0][2] = 0.0f;
4651 *raw = (int16_t)((uint16_t)buf[0] << 8) | buf[1];
4652 *degrees = (float)(*raw) / 321.0f + 21.0f;
4684 handle->
debug_print(
"mpu9250: read int status failed.\n");
4701 (void)a_mpu9250_reset_fifo(handle);
4761 handle->
debug_print(
"mpu9250: read user ctrl failed.\n");
4769 handle->
debug_print(
"mpu9250: write user ctrl failed.\n");
4776 handle->
debug_print(
"mpu9250: read int pin cfg failed.\n");
4785 handle->
debug_print(
"mpu9250: write int pin cfg failed.\n");
4790 res = a_mpu9250_mag_read(handle,
AK8963_REG_WIA, (uint8_t *)&prev, 1);
4793 handle->
debug_print(
"mpu9250: mag read who am i failed.\n");
4799 handle->
debug_print(
"mpu9250: mag id is invalid.\n");
4808 handle->
debug_print(
"mpu9250: mag write cntl2 failed.\n");
4813 while (timeout != 0)
4818 handle->
debug_print(
"mpu9250: mag read cntl2 failed.\n");
4822 if ((prev & 0x01) == 0x00)
4840 handle->
debug_print(
"mpu9250: mag write cntl1 failed.\n");
4849 handle->
debug_print(
"mpu9250: mag write cntl1 failed.\n");
4856 handle->
debug_print(
"mpu9250: mag read asa failed.\n");
4864 handle->
debug_print(
"mpu9250: mag write cntl1 failed.\n");
4876 handle->
debug_print(
"mpu9250: spi don't support.\n");
4908 handle->
debug_print(
"mpu9250: mag is not inited.\n");
4916 handle->
debug_print(
"mpu9250: read user ctrl failed.\n");
4924 handle->
debug_print(
"mpu9250: write user ctrl failed.\n");
4931 handle->
debug_print(
"mpu9250: read int pin cfg failed.\n");
4940 handle->
debug_print(
"mpu9250: write int pin cfg failed.\n");
4945 res = a_mpu9250_mag_read(handle,
AK8963_REG_WIA, (uint8_t *)&prev, 1);
4948 handle->
debug_print(
"mpu9250: mag read who am i failed.\n");
4954 handle->
debug_print(
"mpu9250: mag id is invalid.\n");
4962 handle->
debug_print(
"mpu9250: mag read cntl1 failed.\n");
4966 prev &= ~(0xF << 0);
4971 handle->
debug_print(
"mpu9250: mag write cntl1 failed.\n");
5012 handle->
debug_print(
"mpu9250: mag is not inited.\n");
5020 handle->
debug_print(
"mpu9250: mag read failed.\n");
5024 mag_raw[0] = (int16_t)((uint16_t)buf[2] << 8) | buf[1];
5025 mag_raw[1] = (int16_t)((uint16_t)buf[4] << 8) | buf[3];
5026 mag_raw[2] = (int16_t)((uint16_t)buf[6] << 8) | buf[5];
5028 mag_k_x = ((float)handle->
mag_asa[0] - 128.0f) * 0.5f / 128.0f + 1.0f;
5029 mag_k_y = ((float)handle->
mag_asa[1] - 128.0f) * 0.5f / 128.0f + 1.0f;
5030 mag_k_z = ((float)handle->
mag_asa[2] - 128.0f) * 0.5f / 128.0f + 1.0f;
5031 if ((buf[7] & (1 << 4)) != 0)
5033 mag_ut[0] = (float)mag_raw[0] * mag_k_x * 0.15f;
5034 mag_ut[1] = (float)mag_raw[1] * mag_k_y * 0.15f;
5035 mag_ut[2] = (float)mag_raw[2] * mag_k_z * 0.15f;
5039 mag_ut[0] = (float)mag_raw[0] * mag_k_x * 0.6f;
5040 mag_ut[1] = (float)mag_raw[1] * mag_k_y * 0.6f;
5041 mag_ut[2] = (float)mag_raw[2] * mag_k_z * 0.6f;
5073 handle->
debug_print(
"mpu9250: mag is not inited.\n");
5078 res = a_mpu9250_mag_read(handle,
AK8963_REG_INFO, (uint8_t *)info, 1);
5081 handle->
debug_print(
"mpu9250: mag read info failed.\n");
5115 handle->
debug_print(
"mpu9250: mag is not inited.\n");
5120 res = a_mpu9250_mag_read(handle,
AK8963_REG_ST1, (uint8_t *)status, 1);
5123 handle->
debug_print(
"mpu9250: mag read status1 failed.\n");
5157 handle->
debug_print(
"mpu9250: mag is not inited.\n");
5162 res = a_mpu9250_mag_read(handle,
AK8963_REG_ST2, (uint8_t *)status, 1);
5165 handle->
debug_print(
"mpu9250: mag read status2 failed.\n");
5200 handle->
debug_print(
"mpu9250: mag is not inited.\n");
5208 handle->
debug_print(
"mpu9250: mag read cntl1 failed.\n");
5212 prev &= ~(0xF << 0);
5217 handle->
debug_print(
"mpu9250: mag write cntl1 failed.\n");
5252 handle->
debug_print(
"mpu9250: mag is not inited.\n");
5260 handle->
debug_print(
"mpu9250: mag read cntl1 failed.\n");
5296 handle->
debug_print(
"mpu9250: mag is not inited.\n");
5304 handle->
debug_print(
"mpu9250: mag read cntl1 failed.\n");
5313 handle->
debug_print(
"mpu9250: mag write cntl1 failed.\n");
5348 handle->
debug_print(
"mpu9250: mag is not inited.\n");
5356 handle->
debug_print(
"mpu9250: mag read cntl1 failed.\n");
5392 handle->
debug_print(
"mpu9250: mag is not inited.\n");
5400 handle->
debug_print(
"mpu9250: mag read cntl2 failed.\n");
5405 prev |= enable << 0;
5409 handle->
debug_print(
"mpu9250: mag write cntl2 failed.\n");
5444 handle->
debug_print(
"mpu9250: mag is not inited.\n");
5452 handle->
debug_print(
"mpu9250: mag read cntl2 failed.\n");
5488 handle->
debug_print(
"mpu9250: mag is not inited.\n");
5493 res = a_mpu9250_mag_read(handle,
AK8963_REG_ASTC, (uint8_t *)&prev, 1);
5496 handle->
debug_print(
"mpu9250: mag read astc failed.\n");
5501 prev |= enable << 6;
5505 handle->
debug_print(
"mpu9250: mag write astc failed.\n");
5540 handle->
debug_print(
"mpu9250: mag is not inited.\n");
5545 res = a_mpu9250_mag_read(handle,
AK8963_REG_ASTC, (uint8_t *)&prev, 1);
5548 handle->
debug_print(
"mpu9250: mag read astc failed.\n");
5583 handle->
debug_print(
"mpu9250: mag is not inited.\n");
5592 handle->
debug_print(
"mpu9250: mag write i2cdis failed.\n");
5626 handle->
debug_print(
"mpu9250: mag is not inited.\n");
5634 handle->
debug_print(
"mpu9250: mag read asa failed.\n");
5668 handle->
debug_print(
"mpu9250: mag is not inited.\n");
5676 handle->
debug_print(
"mpu9250: read user ctrl failed.\n");
5685 handle->
debug_print(
"mpu9250: write user ctrl failed.\n");
5692 handle->
debug_print(
"mpu9250: read int pin cfg failed.\n");
5700 handle->
debug_print(
"mpu9250: write int pin cfg failed.\n");
5709 handle->
debug_print(
"mpu9250: write iic slv0 addr failed.\n");
5717 handle->
debug_print(
"mpu9250: write iic slv0 reg failed.\n");
5725 handle->
debug_print(
"mpu9250: read fifo enable failed.\n");
5734 handle->
debug_print(
"mpu9250: write fifo enable failed.\n");
5743 handle->
debug_print(
"mpu9250: write iic slv0 ctrl failed.\n");
5779 handle->
debug_print(
"mpu9250: read user ctrl failed.\n");
5784 prev |= enable << 6;
5788 handle->
debug_print(
"mpu9250: write user ctrl failed.\n");
5824 handle->
debug_print(
"mpu9250: read user ctrl failed.\n");
5856 res = a_mpu9250_reset_fifo(handle);
5859 handle->
debug_print(
"mpu9250: force reset fifo failed.\n");
5895 handle->
debug_print(
"mpu9250: read user ctrl failed.\n");
5900 prev |= enable << 5;
5904 handle->
debug_print(
"mpu9250: write user ctrl failed.\n");
5940 handle->
debug_print(
"mpu9250: read user ctrl failed.\n");
5977 handle->
debug_print(
"mpu9250: read user ctrl failed.\n");
5982 prev |= enable << 4;
5986 handle->
debug_print(
"mpu9250: write user ctrl failed.\n");
6022 handle->
debug_print(
"mpu9250: read user ctrl failed.\n");
6058 handle->
debug_print(
"mpu9250: read user ctrl failed.\n");
6067 handle->
debug_print(
"mpu9250: write user ctrl failed.\n");
6103 handle->
debug_print(
"mpu9250: read user ctrl failed.\n");
6139 handle->
debug_print(
"mpu9250: read user ctrl failed.\n");
6148 handle->
debug_print(
"mpu9250: write user ctrl failed.\n");
6184 handle->
debug_print(
"mpu9250: read user ctrl failed.\n");
6220 handle->
debug_print(
"mpu9250: read user ctrl failed.\n");
6229 handle->
debug_print(
"mpu9250: write user ctrl failed.\n");
6265 handle->
debug_print(
"mpu9250: read user ctrl failed.\n");
6301 handle->
debug_print(
"mpu9250: read power management 1 failed.\n");
6310 handle->
debug_print(
"mpu9250: write power management 1 failed.\n");
6346 handle->
debug_print(
"mpu9250: read power management 1 failed.\n");
6383 handle->
debug_print(
"mpu9250: read power management 1 failed.\n");
6387 prev &= ~(0x7 << 0);
6388 prev |= clock_source << 0;
6392 handle->
debug_print(
"mpu9250: write power management 1 failed.\n");
6428 handle->
debug_print(
"mpu9250: read power management 1 failed.\n");
6465 handle->
debug_print(
"mpu9250: read power management 1 failed.\n");
6470 prev |= (!enable) << 3;
6474 handle->
debug_print(
"mpu9250: write power management 1 failed.\n");
6510 handle->
debug_print(
"mpu9250: read power management 1 failed.\n");
6547 handle->
debug_print(
"mpu9250: read power management 1 failed.\n");
6552 prev |= enable << 5;
6556 handle->
debug_print(
"mpu9250: write power management 1 failed.\n");
6592 handle->
debug_print(
"mpu9250: read power management 1 failed.\n");
6629 handle->
debug_print(
"mpu9250: read power management 1 failed.\n");
6634 prev |= enable << 6;
6638 handle->
debug_print(
"mpu9250: write power management 1 failed.\n");
6674 handle->
debug_print(
"mpu9250: read power management 1 failed.\n");
6711 handle->
debug_print(
"mpu9250: read power management 1 failed.\n");
6716 prev |= enable << 4;
6720 handle->
debug_print(
"mpu9250: write power management 1 failed.\n");
6756 handle->
debug_print(
"mpu9250: read power management 1 failed.\n");
6794 handle->
debug_print(
"mpu9250: read power management 2 failed.\n");
6798 prev &= ~(1 << source);
6799 prev |= enable << source;
6803 handle->
debug_print(
"mpu9250: write power management 2 failed.\n");
6840 handle->
debug_print(
"mpu9250: read power management 2 failed.\n");
6877 handle->
debug_print(
"mpu9250: read fifo count failed.\n");
6881 *count = (uint16_t)(((uint16_t)buf[0] << 8) | buf[1]);
6914 handle->
debug_print(
"mpu9250: fifo read failed.\n");
6950 handle->
debug_print(
"mpu9250: fifo write failed.\n");
6986 handle->
debug_print(
"mpu9250: read signal path reset failed.\n");
6990 prev &= ~(1 << path);
6995 handle->
debug_print(
"mpu9250: write signal path reset failed.\n");
7030 handle->
debug_print(
"mpu9250: write smprt div failed.\n");
7065 handle->
debug_print(
"mpu9250: read smprt div failed.\n");
7101 handle->
debug_print(
"mpu9250: read config failed.\n");
7105 prev &= ~(0x7 << 3);
7110 handle->
debug_print(
"mpu9250: write config failed.\n");
7146 handle->
debug_print(
"mpu9250: read config failed.\n");
7183 handle->
debug_print(
"mpu9250: read config failed.\n");
7187 prev &= ~(0x7 << 0);
7188 prev |= filter << 0;
7192 handle->
debug_print(
"mpu9250: write config failed.\n");
7228 handle->
debug_print(
"mpu9250: read config failed.\n");
7265 handle->
debug_print(
"mpu9250: read config failed.\n");
7274 handle->
debug_print(
"mpu9250: write config failed.\n");
7310 handle->
debug_print(
"mpu9250: read config failed.\n");
7348 handle->
debug_print(
"mpu9250: read gyroscope config failed.\n");
7352 prev &= ~(1 << axis);
7353 prev |= enable << axis;
7357 handle->
debug_print(
"mpu9250: write gyroscope config failed.\n");
7394 handle->
debug_print(
"mpu9250: read gyroscope config failed.\n");
7431 handle->
debug_print(
"mpu9250: read gyroscope config failed.\n");
7440 handle->
debug_print(
"mpu9250: write gyroscope config failed.\n");
7476 handle->
debug_print(
"mpu9250: read gyroscope config failed.\n");
7520 handle->
debug_print(
"mpu9250: read gyroscope config failed.\n");
7525 prev |= choice << 0;
7529 handle->
debug_print(
"mpu9250: write gyroscope config failed.\n");
7565 handle->
debug_print(
"mpu9250: read gyroscope config failed.\n");
7569 *choice = prev & 0x03;
7603 handle->
debug_print(
"mpu9250: read accelerometer config failed.\n");
7607 prev &= ~(1 << axis);
7608 prev |= enable << axis;
7612 handle->
debug_print(
"mpu9250: write accelerometer config failed.\n");
7649 handle->
debug_print(
"mpu9250: read accelerometer config failed.\n");
7686 handle->
debug_print(
"mpu9250: read accelerometer config failed.\n");
7695 handle->
debug_print(
"mpu9250: write accelerometer config failed.\n");
7731 handle->
debug_print(
"mpu9250: read accelerometer config failed.\n");
7767 handle->
debug_print(
"mpu9250: read accelerometer 2 config failed.\n");
7776 handle->
debug_print(
"mpu9250: write accelerometer 2 config failed.\n");
7819 handle->
debug_print(
"mpu9250: read accelerometer 2 config failed.\n");
7824 prev |= choice << 3;
7828 handle->
debug_print(
"mpu9250: write accelerometer 2 config failed.\n");
7865 handle->
debug_print(
"mpu9250: read accelerometer 2 config failed.\n");
7869 *choice = (prev >> 3) & 0x1;
7902 handle->
debug_print(
"mpu9250: read accelerometer 2 config failed.\n");
7906 prev &= ~(0x7 << 0);
7907 prev |= filter << 0;
7911 handle->
debug_print(
"mpu9250: write accelerometer 2 config failed.\n");
7947 handle->
debug_print(
"mpu9250: read accelerometer 2 config failed.\n");
7984 handle->
debug_print(
"mpu9250: read lp accelerometer odr failed.\n");
7988 prev &= ~(0xF << 0);
7993 handle->
debug_print(
"mpu9250: write lp accelerometer odr failed.\n");
8029 handle->
debug_print(
"mpu9250: read lp accelerometer odr failed.\n");
8066 handle->
debug_print(
"mpu9250: read motion detect ctrl failed.\n");
8071 prev |= enable << 7;
8075 handle->
debug_print(
"mpu9250: write motion detect ctrl failed.\n");
8111 handle->
debug_print(
"mpu9250: read motion detect ctrl failed.\n");
8148 handle->
debug_print(
"mpu9250: read motion detect ctrl failed.\n");
8153 prev |= enable << 6;
8157 handle->
debug_print(
"mpu9250: write motion detect ctrl failed.\n");
8193 handle->
debug_print(
"mpu9250: read motion detect ctrl failed.\n");
8231 handle->
debug_print(
"mpu9250: read fifo enable config failed.\n");
8235 prev &= ~(1 << fifo);
8236 prev |= enable << fifo;
8240 handle->
debug_print(
"mpu9250: write fifo enable config failed.\n");
8277 handle->
debug_print(
"mpu9250: read fifo enable config failed.\n");
8314 handle->
debug_print(
"mpu9250: read interrupt pin failed.\n");
8323 handle->
debug_print(
"mpu9250: write interrupt pin failed.\n");
8359 handle->
debug_print(
"mpu9250: read interrupt pin failed.\n");
8396 handle->
debug_print(
"mpu9250: read interrupt pin failed.\n");
8405 handle->
debug_print(
"mpu9250: write interrupt pin failed.\n");
8441 handle->
debug_print(
"mpu9250: read interrupt pin failed.\n");
8478 handle->
debug_print(
"mpu9250: read interrupt pin failed.\n");
8483 prev |= (!enable) << 5;
8487 handle->
debug_print(
"mpu9250: write interrupt pin failed.\n");
8523 handle->
debug_print(
"mpu9250: read interrupt pin failed.\n");
8560 handle->
debug_print(
"mpu9250: read interrupt pin failed.\n");
8565 prev |= enable << 4;
8569 handle->
debug_print(
"mpu9250: write interrupt pin failed.\n");
8605 handle->
debug_print(
"mpu9250: read interrupt pin failed.\n");
8642 handle->
debug_print(
"mpu9250: read interrupt pin failed.\n");
8651 handle->
debug_print(
"mpu9250: write interrupt pin failed.\n");
8687 handle->
debug_print(
"mpu9250: read interrupt pin failed.\n");
8724 handle->
debug_print(
"mpu9250: read interrupt pin failed.\n");
8729 prev |= enable << 2;
8733 handle->
debug_print(
"mpu9250: write interrupt pin failed.\n");
8769 handle->
debug_print(
"mpu9250: read interrupt pin failed.\n");
8806 handle->
debug_print(
"mpu9250: read interrupt pin failed.\n");
8811 prev |= enable << 1;
8815 handle->
debug_print(
"mpu9250: write interrupt pin failed.\n");
8851 handle->
debug_print(
"mpu9250: read interrupt pin failed.\n");
8889 handle->
debug_print(
"mpu9250: read interrupt enable failed.\n");
8893 prev &= ~(1 << type);
8894 prev |= enable << type;
8898 handle->
debug_print(
"mpu9250: write interrupt enable failed.\n");
8935 handle->
debug_print(
"mpu9250: read interrupt enable failed.\n");
8971 handle->
debug_print(
"mpu9250: read interrupt status failed.\n");
9006 handle->
debug_print(
"mpu9250: write self test x failed.\n");
9041 handle->
debug_print(
"mpu9250: read self test x failed.\n");
9076 handle->
debug_print(
"mpu9250: write self test y failed.\n");
9111 handle->
debug_print(
"mpu9250: read self test y failed.\n");
9146 handle->
debug_print(
"mpu9250: write self test z failed.\n");
9181 handle->
debug_print(
"mpu9250: read self test z failed.\n");
9216 handle->
debug_print(
"mpu9250: write self test x failed.\n");
9251 handle->
debug_print(
"mpu9250: read self test x failed.\n");
9286 handle->
debug_print(
"mpu9250: write self test y failed.\n");
9321 handle->
debug_print(
"mpu9250: read self test y failed.\n");
9356 handle->
debug_print(
"mpu9250: write self test z failed.\n");
9391 handle->
debug_print(
"mpu9250: read self test z failed.\n");
9424 buf[0] = (offset >> 8) & 0xFF;
9425 buf[1] = (offset >> 0) & 0xFF;
9429 handle->
debug_print(
"mpu9250: write xa offset failed.\n");
9465 handle->
debug_print(
"mpu9250: read xa offset failed.\n");
9469 *offset = (int16_t)(((uint16_t)buf[0] << 8) | buf[1]);
9499 buf[0] = (offset >> 8) & 0xFF;
9500 buf[1] = (offset >> 0) & 0xFF;
9504 handle->
debug_print(
"mpu9250: write ya offset failed.\n");
9540 handle->
debug_print(
"mpu9250: read ya offset failed.\n");
9544 *offset = (int16_t)(((uint16_t)buf[0] << 8) | buf[1]);
9574 buf[0] = (offset >> 8) & 0xFF;
9575 buf[1] = (offset >> 0) & 0xFF;
9579 handle->
debug_print(
"mpu9250: write za offset failed.\n");
9615 handle->
debug_print(
"mpu9250: read za offset failed.\n");
9619 *offset = (int16_t)(((uint16_t)buf[0] << 8) | buf[1]);
9646 *reg = (int16_t)(mg / 0.98f);
9673 *mg = (float)(reg) * 0.98f;
9703 buf[0] = (offset >> 8) & 0xFF;
9704 buf[1] = (offset >> 0) & 0xFF;
9708 handle->
debug_print(
"mpu9250: write xg offset failed.\n");
9744 handle->
debug_print(
"mpu9250: read xg offset failed.\n");
9748 *offset = (int16_t)(((uint16_t)buf[0] << 8) | buf[1]);
9778 buf[0] = (offset >> 8) & 0xFF;
9779 buf[1] = (offset >> 0) & 0xFF;
9783 handle->
debug_print(
"mpu9250: write yg offset failed.\n");
9819 handle->
debug_print(
"mpu9250: read yg offset failed.\n");
9823 *offset = (int16_t)(((uint16_t)buf[0] << 8) | buf[1]);
9853 buf[0] = (offset >> 8) & 0xFF;
9854 buf[1] = (offset >> 0) & 0xFF;
9858 handle->
debug_print(
"mpu9250: write zg offset failed.\n");
9894 handle->
debug_print(
"mpu9250: read zg offset failed.\n");
9898 *offset = (int16_t)(((uint16_t)buf[0] << 8) | buf[1]);
9925 *reg = (int16_t)(dps / 0.0305f);
9952 *dps = (float)(reg) * 0.0305f;
9984 handle->
debug_print(
"mpu9250: write motion threshold failed.\n");
10007 if (handle == NULL)
10011 if (handle->
inited != 1)
10019 handle->
debug_print(
"mpu9250: read motion threshold failed.\n");
10040 if (handle == NULL)
10044 if (handle->
inited != 1)
10049 *reg = (uint8_t)(mg / 4.0f);
10067 if (handle == NULL)
10071 if (handle->
inited != 1)
10076 *mg = (float)(reg) * 4.0f;
10097 int32_t gyro_offset_raw_st[3];
10098 int32_t accel_offset_raw_st[3];
10100 if (handle == NULL)
10104 if (handle->
inited != 1)
10109 res = a_mpu9250_get_st_biases(handle, gyro_offset_raw, accel_offset_raw, 0);
10112 handle->
debug_print(
"mpu9250: get st biases failed.\n");
10116 res = a_mpu9250_get_st_biases(handle, gyro_offset_raw_st, accel_offset_raw_st, 1);
10119 handle->
debug_print(
"mpu9250: get st biases failed.\n");
10123 res = a_mpu9250_accel_self_test(handle, accel_offset_raw, accel_offset_raw_st);
10126 handle->
debug_print(
"mpu9250: accel self test failed.\n");
10130 res = a_mpu9250_gyro_self_test(handle, gyro_offset_raw, gyro_offset_raw_st);
10133 handle->
debug_print(
"mpu9250: gyro self test failed.\n");
10142 handle->
debug_print(
"mpu9250: write pwr mgmt 1 failed.\n");
10150 handle->
debug_print(
"mpu9250: read power management 1 failed.\n");
10158 handle->
debug_print(
"mpu9250: write power management 1 failed.\n");
10182 if (handle == NULL)
10186 if (handle->
inited != 1)
10194 handle->
debug_print(
"mpu9250: read i2c mst ctrl failed.\n");
10203 handle->
debug_print(
"mpu9250: write i2c mst ctrl failed.\n");
10227 if (handle == NULL)
10231 if (handle->
inited != 1)
10239 handle->
debug_print(
"mpu9250: read i2c mst ctrl failed.\n");
10264 if (handle == NULL)
10268 if (handle->
inited != 1)
10276 handle->
debug_print(
"mpu9250: read i2c mst ctrl failed.\n");
10281 prev |= enable << 7;
10285 handle->
debug_print(
"mpu9250: write i2c mst ctrl failed.\n");
10309 if (handle == NULL)
10313 if (handle->
inited != 1)
10321 handle->
debug_print(
"mpu9250: read i2c mst ctrl failed.\n");
10346 if (handle == NULL)
10350 if (handle->
inited != 1)
10358 handle->
debug_print(
"mpu9250: read i2c mst ctrl failed.\n");
10363 prev |= enable << 6;
10367 handle->
debug_print(
"mpu9250: write i2c mst ctrl failed.\n");
10391 if (handle == NULL)
10395 if (handle->
inited != 1)
10403 handle->
debug_print(
"mpu9250: read i2c mst ctrl failed.\n");
10428 if (handle == NULL)
10432 if (handle->
inited != 1)
10440 handle->
debug_print(
"mpu9250: read i2c mst ctrl failed.\n");
10449 handle->
debug_print(
"mpu9250: write i2c mst ctrl failed.\n");
10473 if (handle == NULL)
10477 if (handle->
inited != 1)
10485 handle->
debug_print(
"mpu9250: read i2c mst ctrl failed.\n");
10512 if (handle == NULL)
10516 if (handle->
inited != 1)
10529 handle->
debug_print(
"mpu9250: read fifo enable failed.\n");
10533 prev &= ~(1 << slave);
10534 prev |= enable << slave;
10538 handle->
debug_print(
"mpu9250: write fifo enable failed.\n");
10548 handle->
debug_print(
"mpu9250: read i2c mst ctrl failed.\n");
10553 prev |= enable << 5;
10557 handle->
debug_print(
"mpu9250: write i2c mst ctrl failed.\n");
10564 handle->
debug_print(
"mpu9250: invalid slave.\n");
10590 if (handle == NULL)
10594 if (handle->
inited != 1)
10607 handle->
debug_print(
"mpu9250: read fifo enable failed.\n");
10618 handle->
debug_print(
"mpu9250: read i2c mst ctrl failed.\n");
10626 handle->
debug_print(
"mpu9250: invalid slave.\n");
10652 if (handle == NULL)
10656 if (handle->
inited != 1)
10666 handle->
debug_print(
"mpu9250: read i2c slv0 addr failed.\n");
10675 handle->
debug_print(
"mpu9250: write i2c slv0 addr failed.\n");
10685 handle->
debug_print(
"mpu9250: read i2c slv1 addr failed.\n");
10694 handle->
debug_print(
"mpu9250: write i2c slv1 addr failed.\n");
10704 handle->
debug_print(
"mpu9250: read i2c slv2 addr failed.\n");
10713 handle->
debug_print(
"mpu9250: write i2c slv2 addr failed.\n");
10723 handle->
debug_print(
"mpu9250: read i2c slv3 addr failed.\n");
10732 handle->
debug_print(
"mpu9250: write i2c slv3 addr failed.\n");
10742 handle->
debug_print(
"mpu9250: read i2c slv4 addr failed.\n");
10751 handle->
debug_print(
"mpu9250: write i2c slv4 addr failed.\n");
10758 handle->
debug_print(
"mpu9250: invalid slave.\n");
10784 if (handle == NULL)
10788 if (handle->
inited != 1)
10798 handle->
debug_print(
"mpu9250: read i2c slv0 addr failed.\n");
10809 handle->
debug_print(
"mpu9250: read i2c slv1 addr failed.\n");
10820 handle->
debug_print(
"mpu9250: read i2c slv2 addr failed.\n");
10831 handle->
debug_print(
"mpu9250: read i2c slv3 addr failed.\n");
10842 handle->
debug_print(
"mpu9250: read i2c slv4 addr failed.\n");
10850 handle->
debug_print(
"mpu9250: invalid slave.\n");
10876 if (handle == NULL)
10880 if (handle->
inited != 1)
10890 handle->
debug_print(
"mpu9250: read i2c slv0 addr failed.\n");
10895 prev |= addr_7bit & 0x7F;
10899 handle->
debug_print(
"mpu9250: write i2c slv0 addr failed.\n");
10909 handle->
debug_print(
"mpu9250: read i2c slv1 addr failed.\n");
10914 prev |= addr_7bit & 0x7F;
10918 handle->
debug_print(
"mpu9250: write i2c slv1 addr failed.\n");
10928 handle->
debug_print(
"mpu9250: read i2c slv2 addr failed.\n");
10933 prev |= addr_7bit & 0x7F;
10937 handle->
debug_print(
"mpu9250: write i2c slv2 addr failed.\n");
10947 handle->
debug_print(
"mpu9250: read i2c slv3 addr failed.\n");
10952 prev |= addr_7bit & 0x7F;
10956 handle->
debug_print(
"mpu9250: write i2c slv3 addr failed.\n");
10966 handle->
debug_print(
"mpu9250: read i2c slv4 addr failed.\n");
10971 prev |= addr_7bit & 0x7F;
10975 handle->
debug_print(
"mpu9250: write i2c slv4 addr failed.\n");
10982 handle->
debug_print(
"mpu9250: invalid slave.\n");
11008 if (handle == NULL)
11012 if (handle->
inited != 1)
11022 handle->
debug_print(
"mpu9250: read i2c slv0 addr failed.\n");
11026 *addr_7bit = prev & 0x7F;
11033 handle->
debug_print(
"mpu9250: read i2c slv1 addr failed.\n");
11037 *addr_7bit = prev & 0x7F;
11044 handle->
debug_print(
"mpu9250: read i2c slv2 addr failed.\n");
11048 *addr_7bit = prev & 0x7F;
11055 handle->
debug_print(
"mpu9250: read i2c slv3 addr failed.\n");
11059 *addr_7bit = prev & 0x7F;
11066 handle->
debug_print(
"mpu9250: read i2c slv4 addr failed.\n");
11070 *addr_7bit = prev & 0x7F;
11074 handle->
debug_print(
"mpu9250: invalid slave.\n");
11099 if (handle == NULL)
11103 if (handle->
inited != 1)
11113 handle->
debug_print(
"mpu9250: write i2c slv0 reg failed.\n");
11123 handle->
debug_print(
"mpu9250: write i2c slv1 reg failed.\n");
11133 handle->
debug_print(
"mpu9250: write i2c slv2 reg failed.\n");
11143 handle->
debug_print(
"mpu9250: write i2c slv3 reg failed.\n");
11153 handle->
debug_print(
"mpu9250: write i2c slv4 reg failed.\n");
11160 handle->
debug_print(
"mpu9250: invalid slave.\n");
11185 if (handle == NULL)
11189 if (handle->
inited != 1)
11199 handle->
debug_print(
"mpu9250: read i2c slv0 reg failed.\n");
11209 handle->
debug_print(
"mpu9250: read i2c slv1 reg failed.\n");
11219 handle->
debug_print(
"mpu9250: read i2c slv2 reg failed.\n");
11229 handle->
debug_print(
"mpu9250: read i2c slv3 reg failed.\n");
11239 handle->
debug_print(
"mpu9250: read i2c slv4 reg failed.\n");
11246 handle->
debug_print(
"mpu9250: invalid slave.\n");
11271 if (handle == NULL)
11275 if (handle->
inited != 1)
11285 handle->
debug_print(
"mpu9250: write i2c slv0 do failed.\n");
11295 handle->
debug_print(
"mpu9250: write i2c slv1 do failed.\n");
11305 handle->
debug_print(
"mpu9250: write i2c slv2 do failed.\n");
11315 handle->
debug_print(
"mpu9250: write i2c slv3 do failed.\n");
11322 handle->
debug_print(
"mpu9250: invalid slave.\n");
11347 if (handle == NULL)
11351 if (handle->
inited != 1)
11361 handle->
debug_print(
"mpu9250: read i2c slv0 do failed.\n");
11371 handle->
debug_print(
"mpu9250: read i2c slv1 do failed.\n");
11381 handle->
debug_print(
"mpu9250: read i2c slv2 do failed.\n");
11391 handle->
debug_print(
"mpu9250: read i2c slv3 do failed.\n");
11398 handle->
debug_print(
"mpu9250: invalid slave.\n");
11424 if (handle == NULL)
11428 if (handle->
inited != 1)
11438 handle->
debug_print(
"mpu9250: read i2c slv0 ctrl failed.\n");
11443 prev |= enable << 7;
11447 handle->
debug_print(
"mpu9250: write i2c slv0 ctrl failed.\n");
11457 handle->
debug_print(
"mpu9250: read i2c slv1 ctrl failed.\n");
11462 prev |= enable << 7;
11466 handle->
debug_print(
"mpu9250: write i2c slv1 ctrl failed.\n");
11476 handle->
debug_print(
"mpu9250: read i2c slv2 ctrl failed.\n");
11481 prev |= enable << 7;
11485 handle->
debug_print(
"mpu9250: write i2c slv2 ctrl failed.\n");
11495 handle->
debug_print(
"mpu9250: read i2c slv3 ctrl failed.\n");
11500 prev |= enable << 7;
11504 handle->
debug_print(
"mpu9250: write i2c slv3 ctrl failed.\n");
11511 handle->
debug_print(
"mpu9250: invalid slave.\n");
11537 if (handle == NULL)
11541 if (handle->
inited != 1)
11551 handle->
debug_print(
"mpu9250: read i2c slv0 ctrl failed.\n");
11562 handle->
debug_print(
"mpu9250: read i2c slv1 ctrl failed.\n");
11573 handle->
debug_print(
"mpu9250: read i2c slv2 ctrl failed.\n");
11584 handle->
debug_print(
"mpu9250: read i2c slv3 ctrl failed.\n");
11592 handle->
debug_print(
"mpu9250: invalid slave.\n");
11618 if (handle == NULL)
11622 if (handle->
inited != 1)
11632 handle->
debug_print(
"mpu9250: read i2c slv0 ctrl failed.\n");
11637 prev |= enable << 6;
11641 handle->
debug_print(
"mpu9250: write i2c slv0 ctrl failed.\n");
11651 handle->
debug_print(
"mpu9250: read i2c slv1 ctrl failed.\n");
11656 prev |= enable << 6;
11660 handle->
debug_print(
"mpu9250: write i2c slv1 ctrl failed.\n");
11670 handle->
debug_print(
"mpu9250: read i2c slv2 ctrl failed.\n");
11675 prev |= enable << 6;
11679 handle->
debug_print(
"mpu9250: write i2c slv2 ctrl failed.\n");
11689 handle->
debug_print(
"mpu9250: read i2c slv3 ctrl failed.\n");
11694 prev |= enable << 6;
11698 handle->
debug_print(
"mpu9250: write i2c slv3 ctrl failed.\n");
11705 handle->
debug_print(
"mpu9250: invalid slave.\n");
11731 if (handle == NULL)
11735 if (handle->
inited != 1)
11745 handle->
debug_print(
"mpu9250: read i2c slv0 ctrl failed.\n");
11756 handle->
debug_print(
"mpu9250: read i2c slv1 ctrl failed.\n");
11767 handle->
debug_print(
"mpu9250: read i2c slv2 ctrl failed.\n");
11778 handle->
debug_print(
"mpu9250: read i2c slv3 ctrl failed.\n");
11786 handle->
debug_print(
"mpu9250: invalid slave.\n");
11812 if (handle == NULL)
11816 if (handle->
inited != 1)
11826 handle->
debug_print(
"mpu9250: read i2c slv0 ctrl failed.\n");
11835 handle->
debug_print(
"mpu9250: write i2c slv0 ctrl failed.\n");
11845 handle->
debug_print(
"mpu9250: read i2c slv1 ctrl failed.\n");
11854 handle->
debug_print(
"mpu9250: write i2c slv1 ctrl failed.\n");
11864 handle->
debug_print(
"mpu9250: read i2c slv2 ctrl failed.\n");
11873 handle->
debug_print(
"mpu9250: write i2c slv2 ctrl failed.\n");
11883 handle->
debug_print(
"mpu9250: read i2c slv3 ctrl failed.\n");
11892 handle->
debug_print(
"mpu9250: write i2c slv3 ctrl failed.\n");
11899 handle->
debug_print(
"mpu9250: invalid slave.\n");
11925 if (handle == NULL)
11929 if (handle->
inited != 1)
11939 handle->
debug_print(
"mpu9250: read i2c slv0 ctrl failed.\n");
11950 handle->
debug_print(
"mpu9250: read i2c slv1 ctrl failed.\n");
11961 handle->
debug_print(
"mpu9250: read i2c slv2 ctrl failed.\n");
11972 handle->
debug_print(
"mpu9250: read i2c slv3 ctrl failed.\n");
11980 handle->
debug_print(
"mpu9250: invalid slave.\n");
12006 if (handle == NULL)
12010 if (handle->
inited != 1)
12020 handle->
debug_print(
"mpu9250: read i2c slv0 ctrl failed.\n");
12025 prev |= order << 4;
12029 handle->
debug_print(
"mpu9250: write i2c slv0 ctrl failed.\n");
12039 handle->
debug_print(
"mpu9250: read i2c slv1 ctrl failed.\n");
12044 prev |= order << 4;
12048 handle->
debug_print(
"mpu9250: write i2c slv1 ctrl failed.\n");
12058 handle->
debug_print(
"mpu9250: read i2c slv2 ctrl failed.\n");
12063 prev |= order << 4;
12067 handle->
debug_print(
"mpu9250: write i2c slv2 ctrl failed.\n");
12077 handle->
debug_print(
"mpu9250: read i2c slv3 ctrl failed.\n");
12082 prev |= order << 4;
12086 handle->
debug_print(
"mpu9250: write i2c slv3 ctrl failed.\n");
12093 handle->
debug_print(
"mpu9250: invalid slave.\n");
12119 if (handle == NULL)
12123 if (handle->
inited != 1)
12133 handle->
debug_print(
"mpu9250: read i2c slv0 ctrl failed.\n");
12144 handle->
debug_print(
"mpu9250: read i2c slv1 ctrl failed.\n");
12155 handle->
debug_print(
"mpu9250: read i2c slv2 ctrl failed.\n");
12166 handle->
debug_print(
"mpu9250: read i2c slv3 ctrl failed.\n");
12174 handle->
debug_print(
"mpu9250: invalid slave.\n");
12201 if (handle == NULL)
12205 if (handle->
inited != 1)
12221 handle->
debug_print(
"mpu9250: read i2c slv0 ctrl failed.\n");
12230 handle->
debug_print(
"mpu9250: write i2c slv0 ctrl failed.\n");
12240 handle->
debug_print(
"mpu9250: read i2c slv1 ctrl failed.\n");
12249 handle->
debug_print(
"mpu9250: write i2c slv1 ctrl failed.\n");
12259 handle->
debug_print(
"mpu9250: read i2c slv2 ctrl failed.\n");
12268 handle->
debug_print(
"mpu9250: write i2c slv2 ctrl failed.\n");
12278 handle->
debug_print(
"mpu9250: read i2c slv3 ctrl failed.\n");
12287 handle->
debug_print(
"mpu9250: write i2c slv3 ctrl failed.\n");
12294 handle->
debug_print(
"mpu9250: invalid slave.\n");
12320 if (handle == NULL)
12324 if (handle->
inited != 1)
12334 handle->
debug_print(
"mpu9250: read i2c slv0 ctrl failed.\n");
12338 *len = prev & 0x0F;
12345 handle->
debug_print(
"mpu9250: read i2c slv1 ctrl failed.\n");
12349 *len = prev & 0x0F;
12356 handle->
debug_print(
"mpu9250: read i2c slv2 ctrl failed.\n");
12360 *len = prev & 0x0F;
12367 handle->
debug_print(
"mpu9250: read i2c slv3 ctrl failed.\n");
12371 *len = prev & 0x0F;
12375 handle->
debug_print(
"mpu9250: invalid slave.\n");
12398 if (handle == NULL)
12402 if (handle->
inited != 1)
12410 handle->
debug_print(
"mpu9250: read i2c mst status failed.\n");
12435 if (handle == NULL)
12439 if (handle->
inited != 1)
12447 handle->
debug_print(
"mpu9250: read i2c mst delay ctrl failed.\n");
12451 prev &= ~(1 << delay);
12452 prev |= enable << delay;
12456 handle->
debug_print(
"mpu9250: write i2c mst delay ctrl failed.\n");
12481 if (handle == NULL)
12485 if (handle->
inited != 1)
12493 handle->
debug_print(
"mpu9250: read i2c mst delay ctrl failed.\n");
12518 if (handle == NULL)
12522 if (handle->
inited != 1)
12530 handle->
debug_print(
"mpu9250: read i2c slv4 ctrl failed.\n");
12535 prev |= enable << 7;
12539 handle->
debug_print(
"mpu9250: write i2c slv4 ctrl failed.\n");
12563 if (handle == NULL)
12567 if (handle->
inited != 1)
12575 handle->
debug_print(
"mpu9250: read i2c slv4 ctrl failed.\n");
12600 if (handle == NULL)
12604 if (handle->
inited != 1)
12612 handle->
debug_print(
"mpu9250: read i2c slv4 ctrl failed.\n");
12617 prev |= enable << 6;
12621 handle->
debug_print(
"mpu9250: write i2c slv4 ctrl failed.\n");
12645 if (handle == NULL)
12649 if (handle->
inited != 1)
12657 handle->
debug_print(
"mpu9250: read i2c slv4 ctrl failed.\n");
12682 if (handle == NULL)
12686 if (handle->
inited != 1)
12694 handle->
debug_print(
"mpu9250: read i2c slv4 ctrl failed.\n");
12703 handle->
debug_print(
"mpu9250: write i2c slv4 ctrl failed.\n");
12727 if (handle == NULL)
12731 if (handle->
inited != 1)
12739 handle->
debug_print(
"mpu9250: read i2c slv4 ctrl failed.\n");
12765 if (handle == NULL)
12769 if (handle->
inited != 1)
12783 handle->
debug_print(
"mpu9250: read i2c slv4 ctrl failed.\n");
12792 handle->
debug_print(
"mpu9250: write i2c slv4 ctrl failed.\n");
12816 if (handle == NULL)
12820 if (handle->
inited != 1)
12828 handle->
debug_print(
"mpu9250: read i2c slv4 ctrl failed.\n");
12832 *delay = prev & 0x1F;
12852 if (handle == NULL)
12856 if (handle->
inited != 1)
12864 handle->
debug_print(
"mpu9250: write i2c slv4 do failed.\n");
12887 if (handle == NULL)
12891 if (handle->
inited != 1)
12899 handle->
debug_print(
"mpu9250: read i2c slv4 do failed.\n");
12922 if (handle == NULL)
12926 if (handle->
inited != 1)
12934 handle->
debug_print(
"mpu9250: write i2c slv4 di failed.\n");
12957 if (handle == NULL)
12961 if (handle->
inited != 1)
12969 handle->
debug_print(
"mpu9250: read i2c slv4 di failed.\n");
12994 if (handle == NULL)
12998 if (handle->
inited != 1)
13012 handle->
debug_print(
"mpu9250: read ext sens data 00 failed.\n");
13035 if (handle == NULL)
13039 if (handle->
inited != 1)
13044 return a_mpu9250_write(handle, reg, buf, len);
13062 if (handle == NULL)
13066 if (handle->
inited != 1)
13071 return a_mpu9250_read(handle, reg, buf, len);
13092 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
struct mpu9250_info_s mpu9250_info_t
mpu9250 information structure definition
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
struct mpu9250_handle_s mpu9250_handle_t
mpu9250 handle structure definition
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
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)
float supply_voltage_max_v
char manufacturer_name[32]
float supply_voltage_min_v