| eMD IIM4265x Driver API 1.0.0

Ixm42xxxSelfTest.c
Go to the documentation of this file.
1 /*
2 * ________________________________________________________________________________________________________
3 * Copyright (c) 2015-2015 InvenSense Inc. All rights reserved.
4 *
5 * This software, related documentation and any modifications thereto (collectively “Software”) is subject
6 * to InvenSense and its licensors' intellectual property rights under U.S. and international copyright
7 * and other intellectual property rights laws.
8 *
9 * InvenSense and its licensors retain all intellectual property and proprietary rights in and to the Software
10 * and any use, reproduction, disclosure or distribution of the Software without an express license agreement
11 * from InvenSense is strictly prohibited.
12 *
13 * EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, THE SOFTWARE IS
14 * PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
15 * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
16 * EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, IN NO EVENT SHALL
17 * INVENSENSE BE LIABLE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
18 * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
19 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20 * OF THE SOFTWARE.
21 * ________________________________________________________________________________________________________
22 */
23
24 #include "Invn/Drivers/Ixm42xxx/Ixm42xxxSelfTest.h"
25 #include "Invn/Drivers/Ixm42xxx/Ixm42xxxDefs.h"
26 #include "Invn/Drivers/Ixm42xxx/Ixm42xxxExtFunc.h"
27 #include "Invn/Drivers/Ixm42xxx/Ixm42xxxTransport.h"
28 #include "Invn/Drivers/Ixm42xxx/Ixm42xxxDriver_HL.h"
29
30 #include <stdio.h>
31 #include <math.h>
32
33
34 #ifndef INV_ABS
35 #define INV_ABS(x) (((x) < 0) ? -(x) : (x))
36 #endif
37
38
40 #define ST_GYRO_FSR IXM42XXX_GYRO_CONFIG0_FS_SEL_250dps
41 #define ST_GYRO_ODR IXM42XXX_GYRO_CONFIG0_ODR_1_KHZ
42 #define ST_GYRO_UI_FILT_ORD_IND IXM42XXX_GYRO_CONFIG_GYRO_UI_FILT_ORD_3RD_ORDER
43 #define ST_GYRO_UI_FILT_BW_IND IXM42XXX_GYRO_ACCEL_CONFIG0_GYRO_FILT_BW_10
44
45 #define ST_ACCEL_FSR IXM42XXX_ACCEL_CONFIG0_FS_SEL_4g
46 #define ST_ACCEL_ODR IXM42XXX_ACCEL_CONFIG0_ODR_1_KHZ
47 #define ST_ACCEL_UI_FILT_ORD_IND IXM42XXX_ACCEL_CONFIG_ACCEL_UI_FILT_ORD_3RD_ORDER
48 #define ST_ACCEL_UI_FILT_BW_IND IXM42XXX_GYRO_ACCEL_CONFIG0_ACCEL_FILT_BW_10
49
50 /* Formula to get ST_OTP based on FS and ST_code */
51 #if defined(ICM42686)
52 #define INV_ST_OTP_EQUATION(FS, ST_code) (uint32_t)((1310/pow(2,3-FS))*pow(1.01, ST_code-1)+0.5)
53 #else
54 #define INV_ST_OTP_EQUATION(FS, ST_code) (uint32_t)((2620/pow(2,3-FS))*pow(1.01, ST_code-1)+0.5)
55 #endif
56
57 /* Pass/Fail criteria */
58 #define MIN_RATIO_GYRO 0.5f /* expected ratio greater than 0.5 */
59 #define MIN_ST_GYRO_DPS 60 /* expected values greater than 60dps */
60 #define MAX_ST_GYRO_OFFSET_DPS 20 /* expected offset less than 20 dps */
61
62 #define MIN_RATIO_GYRO 0.5f /* expected ratio greater than 0.5 */
63 #define MAX_RATIO_GYRO 1.5f /* expected ratio lower than 1.5 */
64 #define MIN_ST_ACCEL_MG 225 /* expected values in [225mgee;675mgee] */
65 #define MAX_ST_ACCEL_MG 675
66
67
70 enum inv_ixm42xxx_sensor_on_mask {
71 INV_IXM42XXX_SENSOR_ON_MASK_ACCEL = (1L<<INV_IXM42XXX_SENSOR_ACCEL),
72 INV_IXM42XXX_SENSOR_ON_MASK_GYRO = (1L<<INV_IXM42XXX_SENSOR_GYRO),
73 };
74
77 struct recover_regs {
78 /* bank 0 */
79 uint8_t intf_config1; /* REG_INTF_CONFIG1 */
80 uint8_t pwr_mgmt_0; /* REG_PWR_MGMT_0 */
81 uint8_t accel_config0; /* REG_ACCEL_CONFIG0 */
82 uint8_t accel_config1; /* REG_ACCEL_CONFIG1 */
83 uint8_t gyro_config0; /* REG_GYRO_CONFIG0 */
84 uint8_t gyro_config1; /* REG_GYRO_CONFIG1 */
85 uint8_t accel_gyro_config0; /* REG_ACCEL_GYRO_CONFIG0 */
86 uint8_t fifo_config1; /* REG_FIFO_CONFIG1 */
87 uint8_t self_test_config; /* REG_SELF_TEST_CONFIG */
88 };
89
90 /* Static fonctions definition */
91 static int run_gyro_self_test(struct inv_ixm42xxx * s, int * result);
92 static int run_accel_self_test(struct inv_ixm42xxx * s, int * result);
93 static int average_sensor_output(struct inv_ixm42xxx * s, int sensor, int self_test_config, int32_t sensor_result[3]);
94 static int save_settings(struct inv_ixm42xxx * s, struct recover_regs * saved_regs);
95 static int recover_settings(struct inv_ixm42xxx * s, const struct recover_regs * saved_regs);
96 static int set_user_offset_regs(struct inv_ixm42xxx * s, uint8_t sensor);
97 static int reg_to_accel_fsr(IXM42XXX_ACCEL_CONFIG0_FS_SEL_t reg);
98 static int reg_to_gyro_fsr(IXM42XXX_GYRO_CONFIG0_FS_SEL_t reg);
99
100
101 int inv_ixm42xxx_run_selftest(struct inv_ixm42xxx * s, int * result)
102 {
103 int status = 0;
104 int gyro_result = 0, accel_result = 0;
105 struct recover_regs saved_regs;
106
107 *result = 0;
108
109 /* Run self-test only once */
110 if (s->st_result == 0) {
111
112 /* Save current settings to restore them at the end of the routine */
113 status |= save_settings(s, &saved_regs);
114
115 status |= run_gyro_self_test(s, &gyro_result);
116 if ((status == 0) && (gyro_result == 1))
117 status |= set_user_offset_regs(s, INV_IXM42XXX_SENSOR_ON_MASK_GYRO);
118
119 status |= run_accel_self_test(s, &accel_result);
120 if ((status == 0) && (accel_result == 1))
121 status |= set_user_offset_regs(s, INV_IXM42XXX_SENSOR_ON_MASK_ACCEL);
122
123 /* Restore settings previously saved */
124 status |= recover_settings(s, &saved_regs);
125
126 /* Store acc and gyr results */
127 s->st_result = (accel_result << 1) | gyro_result;
128 }
129
130 *result = s->st_result;
131 return status;
132 }
133
134 int inv_ixm42xxx_get_st_bias(struct inv_ixm42xxx * s, int st_bias[6])
135 {
136 int status = 0;
137 int i;
138
139 /* if ST didn't run, return null biases */
140 if (s->st_result == 0) {
141 for (i = 0; i < 6; i++)
142 st_bias[i] = 0;
143 return status;
144 }
145
146 /* Gyro bias LN: first 3 elements */
147 for (i = 0; i < 3; i++) /* convert bias to 1 dps Q16 */
148 st_bias[i] = s->gyro_st_bias[i] * 2 * reg_to_gyro_fsr(ST_GYRO_FSR);
149
150 /* Accel bias LN: last 3 elements */
151 for (i = 0; i < 3; i++) /* convert bias to 1 gee Q16 */
152 st_bias[i+3] = s->accel_st_bias[i] * 2 * reg_to_accel_fsr(ST_ACCEL_FSR);
153
154 return status;
155 }
156
157 int inv_ixm42xxx_set_st_bias(struct inv_ixm42xxx * s, const int st_bias[6])
158 {
159 int status = 0;
160 int i;
161
162 /* Gyro */
163 for (i = 0; i < 3; i++)
164 s->gyro_st_bias[i] = st_bias[i] / (2 * reg_to_gyro_fsr(ST_GYRO_FSR));
165
166 status |= set_user_offset_regs(s, INV_IXM42XXX_SENSOR_ON_MASK_GYRO);
167
168 /* Accel */
169 for (i = 0; i < 3; i++)
170 s->accel_st_bias[i] = st_bias[i+3] / (2 * reg_to_accel_fsr(ST_ACCEL_FSR));
171
172 status |= set_user_offset_regs(s, INV_IXM42XXX_SENSOR_ON_MASK_ACCEL);
173
174 return status;
175 }
176
177 /*
178 * Params:
179 * - result: 1 if success, 0 if failure
180 * Returns 0 if success, error code if failure
181 */
182 static int run_gyro_self_test(struct inv_ixm42xxx * s, int * result)
183 {
184 int status = 0;
185 uint8_t data;
186 uint8_t bank;
187
188 int32_t STG_OFF[3], STG_ON[3];
189 uint32_t STG_response[3];
190
191 uint8_t ST_code_regs[3];
192 uint32_t STG_OTP[3];
193
194 int i = 0;
195
196 uint32_t gyro_sensitivity_1dps;
197
198 *result = 1;
199
200 /* Set gyro configuration */
201 status |= inv_ixm42xxx_read_reg(s, MPUREG_GYRO_CONFIG0, 1, &data);
202 data &= ~BIT_GYRO_CONFIG0_FS_SEL_MASK;
203 data &= ~BIT_GYRO_CONFIG0_ODR_MASK;
204 data |= ST_GYRO_FSR;
205 data |= ST_GYRO_ODR;
206 status |= inv_ixm42xxx_write_reg(s, MPUREG_GYRO_CONFIG0, 1, &data);
207
208 status |= inv_ixm42xxx_read_reg(s, MPUREG_GYRO_CONFIG1, 1, &data);
209 data &= ~BIT_GYRO_CONFIG1_GYRO_UI_FILT_ORD_MASK;
210 data |= ST_GYRO_UI_FILT_ORD_IND;
211 status |= inv_ixm42xxx_write_reg(s, MPUREG_GYRO_CONFIG1, 1, &data);
212
213 status |= inv_ixm42xxx_read_reg(s, MPUREG_ACCEL_GYRO_CONFIG0, 1, &data);
214 data &= ~BIT_GYRO_ACCEL_CONFIG0_GYRO_FILT_MASK;
215 data |= ST_GYRO_UI_FILT_BW_IND;
216 status |= inv_ixm42xxx_write_reg(s, MPUREG_ACCEL_GYRO_CONFIG0, 1, &data);
217
218 /* Read average gyro digital output for each axis and store them as STG_OFF_{x,y,z} in lsb */
219 status |= average_sensor_output(s, INV_IXM42XXX_SENSOR_ON_MASK_GYRO, 0, STG_OFF);
220
221 /* Enable self-test for each axis and read average gyro digital output
222 * for each axis and store them as STG_ON_{x,y,z} in lsb */
223 status |= average_sensor_output(s, INV_IXM42XXX_SENSOR_ON_MASK_GYRO,
224 (BIT_GYRO_X_ST_EN + BIT_GYRO_Y_ST_EN + BIT_GYRO_Z_ST_EN), STG_ON);
225
226 /* calculate the self-test response as ABS(ST_ON_{x,y,z} - ST_OFF_{x,y,z}) for each axis */
227 for(i = 0; i < 3; i++)
228 STG_response[i] = INV_ABS(STG_ON[i] - STG_OFF[i]);
229
230 /* calculate ST results OTP based on the equation */
231 bank = 1;
232 status |= inv_ixm42xxx_write_reg(s, MPUREG_REG_BANK_SEL, 1, &bank);
233 status |= inv_ixm42xxx_read_reg(s, MPUREG_XG_ST_DATA_B1, 3, ST_code_regs);
234 bank = 0;
235 status |= inv_ixm42xxx_write_reg(s, MPUREG_REG_BANK_SEL, 1, &bank);
236
237 for (i = 0; i < 3; i++) {
238 int fs_sel = ST_GYRO_FSR >> BIT_GYRO_CONFIG0_FS_SEL_POS;
239 STG_OTP[i] = INV_ST_OTP_EQUATION(fs_sel, ST_code_regs[i]);
240 }
241
243 gyro_sensitivity_1dps = 32768 / reg_to_gyro_fsr(ST_GYRO_FSR);
244
245 for (i = 0; i < 3; i++) {
246 if (STG_OTP[i]) {
247 float ratio = ((float)STG_response[i]) / ((float)STG_OTP[i]);
248 if (ratio <= MIN_RATIO_GYRO)
249 *result = 0; /* fail */
250 } else if(STG_response[i] < (MIN_ST_GYRO_DPS * gyro_sensitivity_1dps)) {
251 *result = 0; /* fail */
252 }
253 }
254
255 /* stored the computed bias (checking GST and GOFFSET values) */
256 for (i = 0; i < 3; i++) {
257 if((INV_ABS(STG_OFF[i]) > (int32_t)(MAX_ST_GYRO_OFFSET_DPS * gyro_sensitivity_1dps)))
258 *result = 0; /* fail */
259 s->gyro_st_bias[i] = STG_OFF[i];
260 }
261
262 return status;
263 }
264
265 /*
266 * Params:
267 * - result: 1 if success, 0 if failure
268 * Returns 0 if success, error code if failure
269 */
270 static int run_accel_self_test(struct inv_ixm42xxx * s, int * result)
271 {
272 int status = 0;
273 uint8_t data;
274 uint8_t bank;
275
276 int32_t STA_OFF[3], STA_ON[3];
277 uint32_t STA_response[3];
278
279 uint8_t ST_code_regs[3];
280 uint32_t STA_OTP[3];
281
282 int i = 0;
283 int axis, axis_sign;
284
285 uint32_t accel_sensitivity_1g, gravity;
286
287 *result = 1;
288
289 /* Set accel configuration */
290 status |= inv_ixm42xxx_read_reg(s, MPUREG_ACCEL_CONFIG0, 1, &data);
291 data &= ~BIT_ACCEL_CONFIG0_FS_SEL_MASK;
292 data &= ~BIT_ACCEL_CONFIG0_ODR_MASK;
293 data |= ST_ACCEL_FSR;
294 data |= ST_ACCEL_ODR;
295 status |= inv_ixm42xxx_write_reg(s, MPUREG_ACCEL_CONFIG0, 1, &data);
296
297 status |= inv_ixm42xxx_read_reg(s, MPUREG_ACCEL_CONFIG1, 1, &data);
298 data &= ~BIT_ACCEL_CONFIG1_ACCEL_UI_FILT_ORD_MASK;
299 data |= ST_ACCEL_UI_FILT_ORD_IND;
300 status |= inv_ixm42xxx_write_reg(s, MPUREG_ACCEL_CONFIG1, 1, &data);
301
302 status |= inv_ixm42xxx_read_reg(s, MPUREG_ACCEL_GYRO_CONFIG0, 1, &data);
303 data &= ~BIT_GYRO_ACCEL_CONFIG0_ACCEL_FILT_MASK;
304 data |= ST_ACCEL_UI_FILT_BW_IND;
305 status |= inv_ixm42xxx_write_reg(s, MPUREG_ACCEL_GYRO_CONFIG0, 1, &data);
306
307 /* read average accel digital output for each axis and store them as ST_OFF_{x,y,z} in lsb x 1000 */
308 status |= average_sensor_output(s, INV_IXM42XXX_SENSOR_ON_MASK_ACCEL, 0, STA_OFF);
309
310 /* Enable self-test for each axis and read average gyro digital output
311 * for each axis and store them as ST_ON_{x,y,z} in lsb x 1000 */
312 status |= average_sensor_output(s, INV_IXM42XXX_SENSOR_ON_MASK_ACCEL,
313 (BIT_ACCEL_X_ST_EN + BIT_ACCEL_Y_ST_EN + BIT_ACCEL_Z_ST_EN + BIT_ST_REGULATOR_EN), STA_ON);
314
315 /* calculate the self-test response as ABS(ST_ON_{x,y,z} - ST_OFF_{x,y,z}) for each axis */
316 /* outputs from this routine are in units of lsb and hence are dependent on the full-scale used on the DUT */
317 for(i = 0; i < 3; i++)
318 STA_response[i] = INV_ABS(STA_ON[i] - STA_OFF[i]);
319
320 /* calculate ST results OTP based on the equation */
321 bank = 2;
322 status |= inv_ixm42xxx_write_reg(s, MPUREG_REG_BANK_SEL, 1, &bank);
323 status |= inv_ixm42xxx_read_reg(s, MPUREG_XA_ST_DATA_B2, 3, ST_code_regs);
324 bank = 0;
325 status |= inv_ixm42xxx_write_reg(s, MPUREG_REG_BANK_SEL, 1, &bank);
326
327 for (i = 0; i < 3; i++) {
328 int fs_sel = ST_ACCEL_FSR >> BIT_ACCEL_CONFIG0_FS_SEL_POS;
329 STA_OTP[i] = INV_ST_OTP_EQUATION(fs_sel, ST_code_regs[i]);
330 }
331
332
334 accel_sensitivity_1g = 32768 / reg_to_accel_fsr(ST_ACCEL_FSR);
335
336 for (i = 0; i < 3; i++) {
337 if (STA_OTP[i]) {
338 float ratio = ((float)STA_response[i]) / ((float)STA_OTP[i]);
339 if ((ratio >= MAX_RATIO_GYRO) || (ratio <= MIN_RATIO_GYRO))
340 *result = 0; /* fail */
341 } else if ((STA_response[i] < ((MIN_ST_ACCEL_MG * accel_sensitivity_1g) / 1000))
342 || (STA_response[i] > ((MAX_ST_ACCEL_MG * accel_sensitivity_1g) / 1000))) {
343 *result = 0; /* fail */
344 }
345 }
346
347 /* stored the computed offset */
348 for(i = 0; i < 3; i++) {
349 s->accel_st_bias[i] = STA_OFF[i];
350 }
351
352 /* assume the largest data axis shows +1 or -1 gee for gravity */
353 axis = 0;
354 axis_sign = 1;
355 if (INV_ABS(s->accel_st_bias[1]) > INV_ABS(s->accel_st_bias[0]))
356 axis = 1;
357 if (INV_ABS(s->accel_st_bias[2]) > INV_ABS(s->accel_st_bias[axis]))
358 axis = 2;
359 if (s->accel_st_bias[axis] < 0)
360 axis_sign = -1;
361
362 gravity = accel_sensitivity_1g * axis_sign;
363 s->accel_st_bias[axis] -= gravity;
364
365 return status;
366 }
367
368 static int average_sensor_output(struct inv_ixm42xxx * s, int sensor, int self_test_config, int32_t average[3])
369 {
370 int status = 0;
371 int it = 0; /* Number of sample read */
372 int sample_discarded = 0; /* Number of sample discarded */
373 int timeout = 300; /* us */
374 uint8_t data_reg; /* address of the register where to read the data */
375 uint8_t self_test_config_reg; /* SELF_TEST_CONFIG register content */
376 uint8_t pwr_mgmt_reg; /* PWR_MGMT register content */
377 int32_t sum[3] = {0}; /* sum of all data read */
378
379 if(sensor == INV_IXM42XXX_SENSOR_ON_MASK_GYRO) {
380 data_reg = MPUREG_GYRO_DATA_X0_UI;
381
382 /* Enable Gyro */
383 status |= inv_ixm42xxx_read_reg(s, MPUREG_PWR_MGMT_0, 1, &pwr_mgmt_reg);
384 pwr_mgmt_reg &= (uint8_t)~BIT_PWR_MGMT_0_GYRO_MODE_MASK;
385 pwr_mgmt_reg |= (uint8_t)IXM42XXX_PWR_MGMT_0_GYRO_MODE_LN;
386 status |= inv_ixm42xxx_write_reg(s, MPUREG_PWR_MGMT_0, 1, &pwr_mgmt_reg);
387
388 /* wait for 60ms to allow output to settle */
389 inv_ixm42xxx_sleep_us(60*1000);
390
391 } else if(sensor == INV_IXM42XXX_SENSOR_ON_MASK_ACCEL) {
392 data_reg = MPUREG_ACCEL_DATA_X0_UI;
393
394 /* Enable Accel */
395 status |= inv_ixm42xxx_read_reg(s, MPUREG_PWR_MGMT_0, 1, &pwr_mgmt_reg);
396 pwr_mgmt_reg &= (uint8_t)~BIT_PWR_MGMT_0_ACCEL_MODE_MASK;
397 pwr_mgmt_reg |= (uint8_t)IXM42XXX_PWR_MGMT_0_ACCEL_MODE_LN;
398 status |= inv_ixm42xxx_write_reg(s, MPUREG_PWR_MGMT_0, 1, &pwr_mgmt_reg);
399
400 /* wait for 25ms to allow output to settle */
401 inv_ixm42xxx_sleep_us(25*1000);
402 }
403 else
404 return INV_ERROR_BAD_ARG; /* Invalid sensor provided */
405
406 /* Apply ST config if required */
407 if(self_test_config) {
408 status |= inv_ixm42xxx_read_reg(s, MPUREG_SELF_TEST_CONFIG, 1, &self_test_config_reg);
409 self_test_config_reg |= self_test_config;
410 status |= inv_ixm42xxx_write_reg(s, MPUREG_SELF_TEST_CONFIG, 1, &self_test_config_reg);
411
412 if(sensor == INV_IXM42XXX_SENSOR_ON_MASK_GYRO)
413 /* wait 200ms for the oscillation to stabilize */
414 inv_ixm42xxx_sleep_us(200*1000);
415 else
416 /* wait for 25ms to allow output to settle */
417 inv_ixm42xxx_sleep_us(25*1000);
418 }
419
420 do {
421 uint8_t int_status;
422 status |= inv_ixm42xxx_read_reg(s, MPUREG_INT_STATUS, 1, &int_status);
423
424 if (int_status & BIT_INT_STATUS_DRDY) {
425 int16_t sensor_data[3] = {0};
426 uint8_t sensor_data_reg[6]; /* sensor data registers content */
427
428 /* Read data */
429 status |= inv_ixm42xxx_read_reg(s, data_reg, 6, sensor_data_reg);
430
431 if (s->endianess_data == IXM42XXX_INTF_CONFIG0_DATA_BIG_ENDIAN) {
432 sensor_data[0] = (sensor_data_reg[0] << 8) | sensor_data_reg[1];
433 sensor_data[1] = (sensor_data_reg[2] << 8) | sensor_data_reg[3];
434 sensor_data[2] = (sensor_data_reg[4] << 8) | sensor_data_reg[5];
435 } else { // LITTLE ENDIAN
436 sensor_data[0] = (sensor_data_reg[1] << 8) | sensor_data_reg[0];
437 sensor_data[1] = (sensor_data_reg[3] << 8) | sensor_data_reg[2];
438 sensor_data[2] = (sensor_data_reg[5] << 8) | sensor_data_reg[4];
439 }
440 if ((sensor_data[0] != -32768) && (sensor_data[1] != -32768) && (sensor_data[2] != -32768)) {
441 sum[0] += sensor_data[0];
442 sum[1] += sensor_data[1];
443 sum[2] += sensor_data[2];
444 } else {
445 sample_discarded++;
446 }
447 it++;
448 }
449 inv_ixm42xxx_sleep_us(1000);
450 timeout--;
451 } while((it < 200) && (timeout > 0));
452
453 /* Disable Accel and Gyro */
454 status |= inv_ixm42xxx_read_reg(s, MPUREG_PWR_MGMT_0, 1, &pwr_mgmt_reg);
455 pwr_mgmt_reg &= (uint8_t)~BIT_PWR_MGMT_0_GYRO_MODE_MASK;
456 pwr_mgmt_reg &= (uint8_t)~BIT_PWR_MGMT_0_ACCEL_MODE_MASK;
457 pwr_mgmt_reg |= (uint8_t)IXM42XXX_PWR_MGMT_0_GYRO_MODE_OFF;
458 pwr_mgmt_reg |= (uint8_t)IXM42XXX_PWR_MGMT_0_ACCEL_MODE_OFF;
459 status |= inv_ixm42xxx_write_reg(s, MPUREG_PWR_MGMT_0, 1, &pwr_mgmt_reg);
460
461 /* Disable self-test config if necessary */
462 if(self_test_config) {
463 self_test_config_reg &= ~self_test_config;
464 status |= inv_ixm42xxx_write_reg(s, MPUREG_SELF_TEST_CONFIG, 1, &self_test_config_reg);
465 }
466
467 /* Compute average value */
468 it -= sample_discarded;
469 average[0] = (sum[0] / it);
470 average[1] = (sum[1] / it);
471 average[2] = (sum[2] / it);
472
473 return status;
474 }
475
476 static int save_settings(struct inv_ixm42xxx * s, struct recover_regs * saved_regs)
477 {
478 int status = 0;
479
480 status |= inv_ixm42xxx_read_reg(s, MPUREG_INTF_CONFIG1, 1, &saved_regs->intf_config1);
481 status |= inv_ixm42xxx_read_reg(s, MPUREG_PWR_MGMT_0, 1, &saved_regs->pwr_mgmt_0);
482 status |= inv_ixm42xxx_read_reg(s, MPUREG_ACCEL_CONFIG0, 1, &saved_regs->accel_config0);
483 status |= inv_ixm42xxx_read_reg(s, MPUREG_ACCEL_CONFIG1, 1, &saved_regs->accel_config1);
484 status |= inv_ixm42xxx_read_reg(s, MPUREG_GYRO_CONFIG0, 1, &saved_regs->gyro_config0);
485 status |= inv_ixm42xxx_read_reg(s, MPUREG_GYRO_CONFIG1, 1, &saved_regs->gyro_config1);
486 status |= inv_ixm42xxx_read_reg(s, MPUREG_ACCEL_GYRO_CONFIG0, 1, &saved_regs->accel_gyro_config0);
487 status |= inv_ixm42xxx_read_reg(s, MPUREG_FIFO_CONFIG1, 1, &saved_regs->fifo_config1);
488 status |= inv_ixm42xxx_read_reg(s, MPUREG_SELF_TEST_CONFIG, 1, &saved_regs->self_test_config);
489
490 return status;
491 }
492
493 static int recover_settings(struct inv_ixm42xxx * s, const struct recover_regs * saved_regs)
494 {
495 int status = 0;
496
497 /* Set en_g{x/y/z}_st_d2a to 0 disable self-test for each axis */
498 status |= inv_ixm42xxx_write_reg(s, MPUREG_SELF_TEST_CONFIG, 1, &saved_regs->self_test_config);
499 /*Restore gyro_dec2_m2_ord, gyro_ui_filt_ord_ind and gyro_ui_filt_bw_ind to previous values.*/
500 status |= inv_ixm42xxx_write_reg(s, MPUREG_INTF_CONFIG1, 1, &saved_regs->intf_config1);
501 status |= inv_ixm42xxx_write_reg(s, MPUREG_PWR_MGMT_0, 1, &saved_regs->pwr_mgmt_0);
502 status |= inv_ixm42xxx_write_reg(s, MPUREG_ACCEL_CONFIG0, 1, &saved_regs->accel_config0);
503 status |= inv_ixm42xxx_write_reg(s, MPUREG_ACCEL_CONFIG1, 1, &saved_regs->accel_config1);
504 status |= inv_ixm42xxx_write_reg(s, MPUREG_GYRO_CONFIG0, 1, &saved_regs->gyro_config0);
505 status |= inv_ixm42xxx_write_reg(s, MPUREG_GYRO_CONFIG1, 1, &saved_regs->gyro_config1);
506 status |= inv_ixm42xxx_write_reg(s, MPUREG_FIFO_CONFIG1, 1, &saved_regs->fifo_config1);
507 status |= inv_ixm42xxx_write_reg(s, MPUREG_ACCEL_GYRO_CONFIG0, 1, &saved_regs->accel_gyro_config0);
508 /* wait 200ms for gyro output to settle */
509 inv_ixm42xxx_sleep_us(200*1000);
510
511 status |= inv_ixm42xxx_reset_fifo(s);
512
513 return status;
514 }
515
516 static int set_user_offset_regs(struct inv_ixm42xxx * s, uint8_t sensor)
517 {
518 uint8_t data[5];
519 int16_t cur_bias;
520 int status = 0;
521
522 // Set memory bank 4
523 status |= inv_ixm42xxx_set_reg_bank(s, 4);
524
525 /* Set offset registers sensor */
526 if (sensor == INV_IXM42XXX_SENSOR_ON_MASK_ACCEL) {
527 /*
528 * Invert sign for OFFSET and
529 * accel_st_bias is 2g coded 16
530 * OFFUSER is 1g coded 12 (or 2g coded 12 for High FSR parts)
531 */
532 status |= inv_ixm42xxx_read_reg(s, MPUREG_OFFSET_USER_4_B4, 1, &data[0]); // Fetch gyro_z_offuser[8-11]
533 data[0] &= BIT_GYRO_Z_OFFUSER_MASK_HI;
534
535 cur_bias = (int16_t)(-s->accel_st_bias[0] >> 3);
536 cur_bias /= ACCEL_OFFUSER_MAX_MG/1000;
537 data[0] |= (((cur_bias & 0x0F00) >> 8) << BIT_ACCEL_X_OFFUSER_POS_HI);
538 data[1] = ((cur_bias & 0x00FF) << BIT_ACCEL_X_OFFUSER_POS_LO);
539 cur_bias = (int16_t)(-s->accel_st_bias[1] >> 3);
540 cur_bias /= ACCEL_OFFUSER_MAX_MG/1000;
541 data[2] = ((cur_bias & 0x00FF) << BIT_ACCEL_Y_OFFUSER_POS_LO);
542 data[3] = (((cur_bias & 0x0F00) >> 8) << BIT_ACCEL_Y_OFFUSER_POS_HI);
543 cur_bias = (int16_t)(-s->accel_st_bias[2] >> 3);
544 cur_bias /= ACCEL_OFFUSER_MAX_MG/1000;
545 data[3] |= (((cur_bias & 0x0F00) >> 8) << BIT_ACCEL_Z_OFFUSER_POS_HI);
546 data[4] = ((cur_bias & 0x00FF) << BIT_ACCEL_Z_OFFUSER_POS_LO);
547
548 status |= inv_ixm42xxx_write_reg(s, MPUREG_OFFSET_USER_4_B4, 5, &data[0]);
549
550 } else if (sensor == INV_IXM42XXX_SENSOR_ON_MASK_GYRO) {
551 /*
552 * Invert sign for OFFSET and
553 * gyro_st_bias is 250dps coded 16
554 * OFFUSER is 64dps coded 12 (or 128dps coded 12 for High FSR parts)
555 */
556 status |= inv_ixm42xxx_read_reg(s, MPUREG_OFFSET_USER_4_B4, 1, &data[4]); // Fetch accel_x_offuser[8-11]
557 data[4] &= BIT_ACCEL_X_OFFUSER_MASK_HI;
558
559 cur_bias = (int16_t)(-(s->gyro_st_bias[0]*250/GYRO_OFFUSER_MAX_DPS) >> 4);
560 data[0] = ((cur_bias & 0x00FF) << BIT_GYRO_X_OFFUSER_POS_LO);
561 data[1] = (((cur_bias & 0x0F00) >> 8) << BIT_GYRO_X_OFFUSER_POS_HI);
562 cur_bias = (int16_t)(-(s->gyro_st_bias[1]*250/GYRO_OFFUSER_MAX_DPS) >> 4);
563 data[1] |= (((cur_bias & 0x0F00) >> 8) << BIT_GYRO_Y_OFFUSER_POS_HI);
564 data[2] = ((cur_bias & 0x00FF) << BIT_GYRO_Y_OFFUSER_POS_LO);
565 cur_bias = (int16_t)(-(s->gyro_st_bias[2]*250/GYRO_OFFUSER_MAX_DPS) >> 4);
566 data[3] = ((cur_bias & 0x00FF) << BIT_GYRO_Z_OFFUSER_POS_LO);
567 data[4] |= (((cur_bias & 0x0F00) >> 8) << BIT_GYRO_Z_OFFUSER_POS_HI);
568
569 status |= inv_ixm42xxx_write_reg(s, MPUREG_OFFSET_USER_0_B4, 5, &data[0]);
570
571 }
572
573 // Set memory bank 0
574 status |= inv_ixm42xxx_set_reg_bank(s, 0);
575
576 return status;
577 }
578
579 static int reg_to_accel_fsr(IXM42XXX_ACCEL_CONFIG0_FS_SEL_t reg)
580 {
581 switch(reg) {
582 case IXM42XXX_ACCEL_CONFIG0_FS_SEL_2g: return 2;
583 case IXM42XXX_ACCEL_CONFIG0_FS_SEL_4g: return 4;
584 case IXM42XXX_ACCEL_CONFIG0_FS_SEL_8g: return 8;
585 case IXM42XXX_ACCEL_CONFIG0_FS_SEL_16g: return 16;
586 #if defined(ICM42686)
587 case IXM42XXX_ACCEL_CONFIG0_FS_SEL_32g: return 32;
588 #endif
589 default: return -1;
590 }
591 }
592 static int reg_to_gyro_fsr(IXM42XXX_GYRO_CONFIG0_FS_SEL_t reg)
593 {
594 switch(reg) {
595 #if !defined(ICM42686)
596 case IXM42XXX_GYRO_CONFIG0_FS_SEL_16dps: return 16;
597 #endif
598 case IXM42XXX_GYRO_CONFIG0_FS_SEL_31dps: return 31;
599 case IXM42XXX_GYRO_CONFIG0_FS_SEL_62dps: return 62;
600 case IXM42XXX_GYRO_CONFIG0_FS_SEL_125dps: return 125;
601 case IXM42XXX_GYRO_CONFIG0_FS_SEL_250dps: return 250;
602 case IXM42XXX_GYRO_CONFIG0_FS_SEL_500dps: return 500;
603 case IXM42XXX_GYRO_CONFIG0_FS_SEL_1000dps: return 1000;
604 case IXM42XXX_GYRO_CONFIG0_FS_SEL_2000dps: return 2000;
605 #if defined(ICM42686)
606 case IXM42XXX_GYRO_CONFIG0_FS_SEL_4000dps: return 4000;
607 #endif
608 default: return -1;
609 }
610 }
BIT_GYRO_X_ST_EN
#define BIT_GYRO_X_ST_EN
Definition: Ixm42xxxDefs.h:1219
MPUREG_XA_ST_DATA_B2
#define MPUREG_XA_ST_DATA_B2
Definition: Ixm42xxxDefs.h:155
recover_regs
Contains the current register values. Used to reapply values after the ST procedure.
Definition: Ixm42xxxSelfTest.c:77
IXM42XXX_PWR_MGMT_0_ACCEL_MODE_LN
@ IXM42XXX_PWR_MGMT_0_ACCEL_MODE_LN
Definition: Ixm42xxxDefs.h:677
IXM42XXX_GYRO_CONFIG0_FS_SEL_16dps
@ IXM42XXX_GYRO_CONFIG0_FS_SEL_16dps
Definition: Ixm42xxxDefs.h:705
BIT_ACCEL_Z_ST_EN
#define BIT_ACCEL_Z_ST_EN
Definition: Ixm42xxxDefs.h:1214
IXM42XXX_GYRO_CONFIG0_FS_SEL_62dps
@ IXM42XXX_GYRO_CONFIG0_FS_SEL_62dps
Definition: Ixm42xxxDefs.h:707
MPUREG_GYRO_DATA_X0_UI
#define MPUREG_GYRO_DATA_X0_UI
Definition: Ixm42xxxDefs.h:92
BIT_ST_REGULATOR_EN
#define BIT_ST_REGULATOR_EN
Definition: Ixm42xxxDefs.h:1213
BIT_GYRO_CONFIG0_ODR_MASK
#define BIT_GYRO_CONFIG0_ODR_MASK
Definition: Ixm42xxxDefs.h:718
INV_ABS
#define INV_ABS(x)
Definition: Ixm42xxxSelfTest.c:35
Ixm42xxxDefs.h
inv_ixm42xxx_run_selftest
int inv_ixm42xxx_run_selftest(struct inv_ixm42xxx *s, int *result)
Perform hardware self-test for Accel and Gyro.
Definition: Ixm42xxxSelfTest.c:101
recover_regs::accel_gyro_config0
uint8_t accel_gyro_config0
Definition: Ixm42xxxSelfTest.c:85
inv_ixm42xxx
Ixm42xxx driver states definition.
Definition: Ixm42xxxDriver_HL.h:164
inv_ixm42xxx_sleep_us
void inv_ixm42xxx_sleep_us(uint32_t us)
Hook for low-level high res system sleep() function to be implemented by upper layer ~100us resolutio...
MPUREG_ACCEL_GYRO_CONFIG0
#define MPUREG_ACCEL_GYRO_CONFIG0
Definition: Ixm42xxxDefs.h:116
MIN_ST_GYRO_DPS
#define MIN_ST_GYRO_DPS
Definition: Ixm42xxxSelfTest.c:59
BIT_ACCEL_X_ST_EN
#define BIT_ACCEL_X_ST_EN
Definition: Ixm42xxxDefs.h:1216
IXM42XXX_ACCEL_CONFIG0_FS_SEL_16g
@ IXM42XXX_ACCEL_CONFIG0_FS_SEL_16g
Definition: Ixm42xxxDefs.h:762
IXM42XXX_GYRO_CONFIG0_FS_SEL_500dps
@ IXM42XXX_GYRO_CONFIG0_FS_SEL_500dps
Definition: Ixm42xxxDefs.h:710
BIT_GYRO_Y_OFFUSER_POS_HI
#define BIT_GYRO_Y_OFFUSER_POS_HI
Definition: Ixm42xxxDefs.h:1984
MIN_ST_ACCEL_MG
#define MIN_ST_ACCEL_MG
Definition: Ixm42xxxSelfTest.c:64
inv_ixm42xxx_reset_fifo
int inv_ixm42xxx_reset_fifo(struct inv_ixm42xxx *s)
reset IXM42XXX fifo
Definition: Ixm42xxxDriver_HL.c:1270
BIT_ACCEL_Y_OFFUSER_POS_HI
#define BIT_ACCEL_Y_OFFUSER_POS_HI
Definition: Ixm42xxxDefs.h:2039
INV_IXM42XXX_SENSOR_ACCEL
@ INV_IXM42XXX_SENSOR_ACCEL
Definition: Ixm42xxxDriver_HL.h:129
IXM42XXX_GYRO_CONFIG0_FS_SEL_1000dps
@ IXM42XXX_GYRO_CONFIG0_FS_SEL_1000dps
Definition: Ixm42xxxDefs.h:711
recover_regs::self_test_config
uint8_t self_test_config
Definition: Ixm42xxxSelfTest.c:87
BIT_GYRO_Y_OFFUSER_POS_LO
#define BIT_GYRO_Y_OFFUSER_POS_LO
Definition: Ixm42xxxDefs.h:1992
MPUREG_GYRO_CONFIG1
#define MPUREG_GYRO_CONFIG1
Definition: Ixm42xxxDefs.h:115
BIT_INT_STATUS_DRDY
#define BIT_INT_STATUS_DRDY
Definition: Ixm42xxxDefs.h:395
BIT_GYRO_Z_ST_EN
#define BIT_GYRO_Z_ST_EN
Definition: Ixm42xxxDefs.h:1217
recover_regs::accel_config0
uint8_t accel_config0
Definition: Ixm42xxxSelfTest.c:81
BIT_ACCEL_X_OFFUSER_POS_LO
#define BIT_ACCEL_X_OFFUSER_POS_LO
Definition: Ixm42xxxDefs.h:2021
BIT_ACCEL_CONFIG0_FS_SEL_POS
#define BIT_ACCEL_CONFIG0_FS_SEL_POS
Definition: Ixm42xxxDefs.h:744
inv_ixm42xxx::st_result
int st_result
Definition: Ixm42xxxDriver_HL.h:175
MPUREG_INT_STATUS
#define MPUREG_INT_STATUS
Definition: Ixm42xxxDefs.h:95
INV_IXM42XXX_SENSOR_ON_MASK_ACCEL
@ INV_IXM42XXX_SENSOR_ON_MASK_ACCEL
Definition: Ixm42xxxSelfTest.c:71
IXM42XXX_GYRO_CONFIG0_FS_SEL_t
IXM42XXX_GYRO_CONFIG0_FS_SEL_t
Gyroscope FSR selection.
Definition: Ixm42xxxDefs.h:694
BIT_GYRO_CONFIG0_FS_SEL_MASK
#define BIT_GYRO_CONFIG0_FS_SEL_MASK
Definition: Ixm42xxxDefs.h:689
inv_ixm42xxx::accel_st_bias
int accel_st_bias[3]
Definition: Ixm42xxxDriver_HL.h:174
BIT_GYRO_ACCEL_CONFIG0_ACCEL_FILT_MASK
#define BIT_GYRO_ACCEL_CONFIG0_ACCEL_FILT_MASK
Definition: Ixm42xxxDefs.h:823
BIT_ACCEL_CONFIG1_ACCEL_UI_FILT_ORD_MASK
#define BIT_ACCEL_CONFIG1_ACCEL_UI_FILT_ORD_MASK
Definition: Ixm42xxxDefs.h:866
Ixm42xxxExtFunc.h
MPUREG_REG_BANK_SEL
#define MPUREG_REG_BANK_SEL
Definition: Ixm42xxxDefs.h:135
recover_regs::accel_config1
uint8_t accel_config1
Definition: Ixm42xxxSelfTest.c:82
MPUREG_ACCEL_CONFIG0
#define MPUREG_ACCEL_CONFIG0
Definition: Ixm42xxxDefs.h:114
MPUREG_OFFSET_USER_0_B4
#define MPUREG_OFFSET_USER_0_B4
Definition: Ixm42xxxDefs.h:194
inv_ixm42xxx_get_st_bias
int inv_ixm42xxx_get_st_bias(struct inv_ixm42xxx *s, int st_bias[6])
Retrieve bias collected by self-test.
Definition: Ixm42xxxSelfTest.c:134
ACCEL_OFFUSER_MAX_MG
#define ACCEL_OFFUSER_MAX_MG
Definition: Ixm42xxxDriver_HL.h:93
Ixm42xxxTransport.h
recover_regs::gyro_config1
uint8_t gyro_config1
Definition: Ixm42xxxSelfTest.c:84
BIT_GYRO_X_OFFUSER_POS_HI
#define BIT_GYRO_X_OFFUSER_POS_HI
Definition: Ixm42xxxDefs.h:1980
BIT_PWR_MGMT_0_GYRO_MODE_MASK
#define BIT_PWR_MGMT_0_GYRO_MODE_MASK
Definition: Ixm42xxxDefs.h:662
ST_GYRO_FSR
#define ST_GYRO_FSR
Definition: Ixm42xxxSelfTest.c:40
IXM42XXX_PWR_MGMT_0_GYRO_MODE_LN
@ IXM42XXX_PWR_MGMT_0_GYRO_MODE_LN
Definition: Ixm42xxxDefs.h:666
MPUREG_XG_ST_DATA_B1
#define MPUREG_XG_ST_DATA_B1
Definition: Ixm42xxxDefs.h:142
INV_IXM42XXX_SENSOR_ON_MASK_GYRO
@ INV_IXM42XXX_SENSOR_ON_MASK_GYRO
Definition: Ixm42xxxSelfTest.c:72
IXM42XXX_GYRO_CONFIG0_FS_SEL_125dps
@ IXM42XXX_GYRO_CONFIG0_FS_SEL_125dps
Definition: Ixm42xxxDefs.h:708
Ixm42xxxDriver_HL.h
BIT_PWR_MGMT_0_ACCEL_MODE_MASK
#define BIT_PWR_MGMT_0_ACCEL_MODE_MASK
Definition: Ixm42xxxDefs.h:673
ST_GYRO_ODR
#define ST_GYRO_ODR
Definition: Ixm42xxxSelfTest.c:41
BIT_ACCEL_X_OFFUSER_POS_HI
#define BIT_ACCEL_X_OFFUSER_POS_HI
Definition: Ixm42xxxDefs.h:2013
ST_ACCEL_UI_FILT_ORD_IND
#define ST_ACCEL_UI_FILT_ORD_IND
Definition: Ixm42xxxSelfTest.c:47
IXM42XXX_GYRO_CONFIG0_FS_SEL_250dps
@ IXM42XXX_GYRO_CONFIG0_FS_SEL_250dps
Definition: Ixm42xxxDefs.h:709
BIT_ACCEL_CONFIG0_ODR_MASK
#define BIT_ACCEL_CONFIG0_ODR_MASK
Definition: Ixm42xxxDefs.h:768
BIT_ACCEL_Z_OFFUSER_POS_LO
#define BIT_ACCEL_Z_OFFUSER_POS_LO
Definition: Ixm42xxxDefs.h:2052
ST_ACCEL_FSR
#define ST_ACCEL_FSR
Definition: Ixm42xxxSelfTest.c:45
ST_GYRO_UI_FILT_BW_IND
#define ST_GYRO_UI_FILT_BW_IND
Definition: Ixm42xxxSelfTest.c:43
BIT_GYRO_Z_OFFUSER_POS_LO
#define BIT_GYRO_Z_OFFUSER_POS_LO
Definition: Ixm42xxxDefs.h:2001
BIT_GYRO_X_OFFUSER_POS_LO
#define BIT_GYRO_X_OFFUSER_POS_LO
Definition: Ixm42xxxDefs.h:1972
MPUREG_OFFSET_USER_4_B4
#define MPUREG_OFFSET_USER_4_B4
Definition: Ixm42xxxDefs.h:198
MPUREG_PWR_MGMT_0
#define MPUREG_PWR_MGMT_0
Definition: Ixm42xxxDefs.h:112
IXM42XXX_ACCEL_CONFIG0_FS_SEL_2g
@ IXM42XXX_ACCEL_CONFIG0_FS_SEL_2g
Definition: Ixm42xxxDefs.h:759
MIN_RATIO_GYRO
#define MIN_RATIO_GYRO
Definition: Ixm42xxxSelfTest.c:62
BIT_ACCEL_Y_OFFUSER_POS_LO
#define BIT_ACCEL_Y_OFFUSER_POS_LO
Definition: Ixm42xxxDefs.h:2030
BIT_ACCEL_Y_ST_EN
#define BIT_ACCEL_Y_ST_EN
Definition: Ixm42xxxDefs.h:1215
MAX_ST_ACCEL_MG
#define MAX_ST_ACCEL_MG
Definition: Ixm42xxxSelfTest.c:65
INV_ST_OTP_EQUATION
#define INV_ST_OTP_EQUATION(FS, ST_code)
Definition: Ixm42xxxSelfTest.c:54
BIT_ACCEL_Z_OFFUSER_POS_HI
#define BIT_ACCEL_Z_OFFUSER_POS_HI
Definition: Ixm42xxxDefs.h:2043
BIT_ACCEL_X_OFFUSER_MASK_HI
#define BIT_ACCEL_X_OFFUSER_MASK_HI
Definition: Ixm42xxxDefs.h:2014
Ixm42xxxSelfTest.h
BIT_GYRO_ACCEL_CONFIG0_GYRO_FILT_MASK
#define BIT_GYRO_ACCEL_CONFIG0_GYRO_FILT_MASK
Definition: Ixm42xxxDefs.h:845
IXM42XXX_GYRO_CONFIG0_FS_SEL_2000dps
@ IXM42XXX_GYRO_CONFIG0_FS_SEL_2000dps
Definition: Ixm42xxxDefs.h:712
BIT_ACCEL_CONFIG0_FS_SEL_MASK
#define BIT_ACCEL_CONFIG0_FS_SEL_MASK
Definition: Ixm42xxxDefs.h:745
MPUREG_SELF_TEST_CONFIG
#define MPUREG_SELF_TEST_CONFIG
Definition: Ixm42xxxDefs.h:133
recover_regs::pwr_mgmt_0
uint8_t pwr_mgmt_0
Definition: Ixm42xxxSelfTest.c:80
MPUREG_ACCEL_CONFIG1
#define MPUREG_ACCEL_CONFIG1
Definition: Ixm42xxxDefs.h:117
MPUREG_INTF_CONFIG1
#define MPUREG_INTF_CONFIG1
Definition: Ixm42xxxDefs.h:111
inv_ixm42xxx_sensor_on_mask
inv_ixm42xxx_sensor_on_mask
Ixm42xxx HW Base sensor status based upon s->sensor_on_mask.
Definition: Ixm42xxxSelfTest.c:70
MPUREG_FIFO_CONFIG1
#define MPUREG_FIFO_CONFIG1
Definition: Ixm42xxxDefs.h:121
inv_ixm42xxx_set_st_bias
int inv_ixm42xxx_set_st_bias(struct inv_ixm42xxx *s, const int st_bias[6])
Apply bias.
Definition: Ixm42xxxSelfTest.c:157
BIT_GYRO_CONFIG1_GYRO_UI_FILT_ORD_MASK
#define BIT_GYRO_CONFIG1_GYRO_UI_FILT_ORD_MASK
Definition: Ixm42xxxDefs.h:802
recover_regs::fifo_config1
uint8_t fifo_config1
Definition: Ixm42xxxSelfTest.c:86
ST_ACCEL_ODR
#define ST_ACCEL_ODR
Definition: Ixm42xxxSelfTest.c:46
IXM42XXX_GYRO_CONFIG0_FS_SEL_31dps
@ IXM42XXX_GYRO_CONFIG0_FS_SEL_31dps
Definition: Ixm42xxxDefs.h:706
IXM42XXX_ACCEL_CONFIG0_FS_SEL_t
IXM42XXX_ACCEL_CONFIG0_FS_SEL_t
Accelerometer FSR selection.
Definition: Ixm42xxxDefs.h:750
inv_ixm42xxx::gyro_st_bias
int gyro_st_bias[3]
Definition: Ixm42xxxDriver_HL.h:173
recover_regs::gyro_config0
uint8_t gyro_config0
Definition: Ixm42xxxSelfTest.c:83
inv_ixm42xxx_write_reg
int inv_ixm42xxx_write_reg(struct inv_ixm42xxx *s, uint8_t reg, uint32_t len, const uint8_t *buf)
Writes data to a register on Ixm42xxx.
Definition: Ixm42xxxTransport.c:86
IXM42XXX_PWR_MGMT_0_GYRO_MODE_OFF
@ IXM42XXX_PWR_MGMT_0_GYRO_MODE_OFF
Definition: Ixm42xxxDefs.h:668
MPUREG_GYRO_CONFIG0
#define MPUREG_GYRO_CONFIG0
Definition: Ixm42xxxDefs.h:113
BIT_GYRO_CONFIG0_FS_SEL_POS
#define BIT_GYRO_CONFIG0_FS_SEL_POS
Definition: Ixm42xxxDefs.h:688
inv_ixm42xxx_set_reg_bank
int inv_ixm42xxx_set_reg_bank(struct inv_ixm42xxx *s, uint8_t bank)
Set register bank index.
Definition: Ixm42xxxDriver_HL.c:35
BIT_GYRO_Z_OFFUSER_POS_HI
#define BIT_GYRO_Z_OFFUSER_POS_HI
Definition: Ixm42xxxDefs.h:2009
inv_ixm42xxx_read_reg
int inv_ixm42xxx_read_reg(struct inv_ixm42xxx *s, uint8_t reg, uint32_t len, uint8_t *buf)
Reads data from a register on Ixm42xxx.
Definition: Ixm42xxxTransport.c:54
MPUREG_ACCEL_DATA_X0_UI
#define MPUREG_ACCEL_DATA_X0_UI
Definition: Ixm42xxxDefs.h:91
BIT_GYRO_Y_ST_EN
#define BIT_GYRO_Y_ST_EN
Definition: Ixm42xxxDefs.h:1218
ST_ACCEL_UI_FILT_BW_IND
#define ST_ACCEL_UI_FILT_BW_IND
Definition: Ixm42xxxSelfTest.c:48
recover_regs::intf_config1
uint8_t intf_config1
Definition: Ixm42xxxSelfTest.c:79
IXM42XXX_ACCEL_CONFIG0_FS_SEL_4g
@ IXM42XXX_ACCEL_CONFIG0_FS_SEL_4g
Definition: Ixm42xxxDefs.h:760
MAX_RATIO_GYRO
#define MAX_RATIO_GYRO
Definition: Ixm42xxxSelfTest.c:63
IXM42XXX_INTF_CONFIG0_DATA_BIG_ENDIAN
@ IXM42XXX_INTF_CONFIG0_DATA_BIG_ENDIAN
Definition: Ixm42xxxDefs.h:586
ST_GYRO_UI_FILT_ORD_IND
#define ST_GYRO_UI_FILT_ORD_IND
Definition: Ixm42xxxSelfTest.c:42
BIT_GYRO_Z_OFFUSER_MASK_HI
#define BIT_GYRO_Z_OFFUSER_MASK_HI
Definition: Ixm42xxxDefs.h:2010
IXM42XXX_ACCEL_CONFIG0_FS_SEL_8g
@ IXM42XXX_ACCEL_CONFIG0_FS_SEL_8g
Definition: Ixm42xxxDefs.h:761
inv_ixm42xxx::endianess_data
uint8_t endianess_data
Definition: Ixm42xxxDriver_HL.h:185
INV_IXM42XXX_SENSOR_GYRO
@ INV_IXM42XXX_SENSOR_GYRO
Definition: Ixm42xxxDriver_HL.h:130
GYRO_OFFUSER_MAX_DPS
#define GYRO_OFFUSER_MAX_DPS
Definition: Ixm42xxxDriver_HL.h:94
IXM42XXX_PWR_MGMT_0_ACCEL_MODE_OFF
@ IXM42XXX_PWR_MGMT_0_ACCEL_MODE_OFF
Definition: Ixm42xxxDefs.h:679
MAX_ST_GYRO_OFFSET_DPS
#define MAX_ST_GYRO_OFFSET_DPS
Definition: Ixm42xxxSelfTest.c:60