| LibDriver MPU9250 1.0.0 MPU9250 full function driver

driver_mpu9250_read_test.c
Go to the documentation of this file.
1
37 #include "driver_mpu9250_read_test.h"
38
39 static mpu9250_handle_t gs_handle;
51 uint8_t mpu9250_read_test(mpu9250_interface_t interface, mpu9250_address_t addr, uint32_t times)
52 {
53 uint8_t res;
54 uint32_t i;
55 mpu9250_info_t info;
56
57 /* link interface function */
58 DRIVER_MPU9250_LINK_INIT(&gs_handle, mpu9250_handle_t);
59 DRIVER_MPU9250_LINK_IIC_INIT(&gs_handle, mpu9250_interface_iic_init);
60 DRIVER_MPU9250_LINK_IIC_DEINIT(&gs_handle, mpu9250_interface_iic_deinit);
61 DRIVER_MPU9250_LINK_IIC_READ(&gs_handle, mpu9250_interface_iic_read);
62 DRIVER_MPU9250_LINK_IIC_WRITE(&gs_handle, mpu9250_interface_iic_write);
63 DRIVER_MPU9250_LINK_SPI_INIT(&gs_handle, mpu9250_interface_spi_init);
64 DRIVER_MPU9250_LINK_SPI_DEINIT(&gs_handle, mpu9250_interface_spi_deinit);
65 DRIVER_MPU9250_LINK_SPI_READ(&gs_handle, mpu9250_interface_spi_read);
66 DRIVER_MPU9250_LINK_SPI_WRITE(&gs_handle, mpu9250_interface_spi_write);
67 DRIVER_MPU9250_LINK_DELAY_MS(&gs_handle, mpu9250_interface_delay_ms);
68 DRIVER_MPU9250_LINK_DEBUG_PRINT(&gs_handle, mpu9250_interface_debug_print);
69 DRIVER_MPU9250_LINK_RECEIVE_CALLBACK(&gs_handle, mpu9250_interface_receive_callback);
70
71 /* get information */
72 res = mpu9250_info(&info);
73 if (res != 0)
74 {
75 mpu9250_interface_debug_print("mpu9250: get info failed.\n");
76
77 return 1;
78 }
79 else
80 {
81 /* print chip info */
82 mpu9250_interface_debug_print("mpu9250: chip is %s.\n", info.chip_name);
83 mpu9250_interface_debug_print("mpu9250: manufacturer is %s.\n", info.manufacturer_name);
84 mpu9250_interface_debug_print("mpu9250: interface is %s.\n", info.interface);
85 mpu9250_interface_debug_print("mpu9250: driver version is %d.%d.\n", info.driver_version / 1000, (info.driver_version % 1000) / 100);
86 mpu9250_interface_debug_print("mpu9250: min supply voltage is %0.1fV.\n", info.supply_voltage_min_v);
87 mpu9250_interface_debug_print("mpu9250: max supply voltage is %0.1fV.\n", info.supply_voltage_max_v);
88 mpu9250_interface_debug_print("mpu9250: max current is %0.2fmA.\n", info.max_current_ma);
89 mpu9250_interface_debug_print("mpu9250: max temperature is %0.1fC.\n", info.temperature_max);
90 mpu9250_interface_debug_print("mpu9250: min temperature is %0.1fC.\n", info.temperature_min);
91 }
92
93 /* start read test */
94 mpu9250_interface_debug_print("mpu9250: start read test.\n");
95
96 /* set the interface */
97 res = mpu9250_set_interface(&gs_handle, interface);
98 if (res != 0)
99 {
100 mpu9250_interface_debug_print("mpu9250: set interface failed.\n");
101
102 return 1;
103 }
104
105 /* set the addr pin */
106 res = mpu9250_set_addr_pin(&gs_handle, addr);
107 if (res != 0)
108 {
109 mpu9250_interface_debug_print("mpu9250: set addr pin failed.\n");
110
111 return 1;
112 }
113
114 /* init */
115 res = mpu9250_init(&gs_handle);
116 if (res != 0)
117 {
118 mpu9250_interface_debug_print("mpu9250: init failed.\n");
119
120 return 1;
121 }
122
123 /* delay 100 ms */
124 mpu9250_interface_delay_ms(100);
125
126 /* disable sleep */
127 res = mpu9250_set_sleep(&gs_handle, MPU9250_BOOL_FALSE);
128 if (res != 0)
129 {
130 mpu9250_interface_debug_print("mpu9250: set sleep failed.\n");
131 (void)mpu9250_deinit(&gs_handle);
132
133 return 1;
134 }
135
136 /* if spi interface, disable iic interface */
137 if (interface == MPU9250_INTERFACE_SPI)
138 {
139 /* disable iic */
140 res = mpu9250_set_disable_iic_slave(&gs_handle, MPU9250_BOOL_TRUE);
141 if (res != 0)
142 {
143 mpu9250_interface_debug_print("mpu9250: set disable iic slave failed.\n");
144 (void)mpu9250_deinit(&gs_handle);
145
146 return 1;
147 }
148 }
149
150 /* set fifo 1024kb */
151 res = mpu9250_set_fifo_1024kb(&gs_handle);
152 if (res != 0)
153 {
154 mpu9250_interface_debug_print("mpu9250: set fifo 1024kb failed.\n");
155 (void)mpu9250_deinit(&gs_handle);
156
157 return 1;
158 }
159
160 /* set pll */
161 res = mpu9250_set_clock_source(&gs_handle, MPU9250_CLOCK_SOURCE_PLL);
162 if (res != 0)
163 {
164 mpu9250_interface_debug_print("mpu9250: set clock source failed.\n");
165 (void)mpu9250_deinit(&gs_handle);
166
167 return 1;
168 }
169
170 /* set 50Hz */
171 res = mpu9250_set_sample_rate_divider(&gs_handle, (1000 / 50) - 1);
172 if (res != 0)
173 {
174 mpu9250_interface_debug_print("mpu9250: set sample rate divider failed.\n");
175 (void)mpu9250_deinit(&gs_handle);
176
177 return 1;
178 }
179
180 /* enable temperature sensor */
181 res = mpu9250_set_ptat(&gs_handle, MPU9250_BOOL_TRUE);
182 if (res != 0)
183 {
184 mpu9250_interface_debug_print("mpu9250: set ptat failed.\n");
185 (void)mpu9250_deinit(&gs_handle);
186
187 return 1;
188 }
189
190 /* disable cycle wake up */
191 res = mpu9250_set_cycle_wake_up(&gs_handle, MPU9250_BOOL_FALSE);
192 if (res != 0)
193 {
194 mpu9250_interface_debug_print("mpu9250: set cycle wake up failed.\n");
195 (void)mpu9250_deinit(&gs_handle);
196
197 return 1;
198 }
199
200 /* enable acc x */
201 res = mpu9250_set_standby_mode(&gs_handle, MPU9250_SOURCE_ACC_X, MPU9250_BOOL_FALSE);
202 if (res != 0)
203 {
204 mpu9250_interface_debug_print("mpu9250: set standby mode failed.\n");
205 (void)mpu9250_deinit(&gs_handle);
206
207 return 1;
208 }
209
210 /* enable acc y */
211 res = mpu9250_set_standby_mode(&gs_handle, MPU9250_SOURCE_ACC_Y, MPU9250_BOOL_FALSE);
212 if (res != 0)
213 {
214 mpu9250_interface_debug_print("mpu9250: set standby mode failed.\n");
215 (void)mpu9250_deinit(&gs_handle);
216
217 return 1;
218 }
219
220 /* enable acc z */
221 res = mpu9250_set_standby_mode(&gs_handle, MPU9250_SOURCE_ACC_Z, MPU9250_BOOL_FALSE);
222 if (res != 0)
223 {
224 mpu9250_interface_debug_print("mpu9250: set standby mode failed.\n");
225 (void)mpu9250_deinit(&gs_handle);
226
227 return 1;
228 }
229
230 /* enable gyro x */
231 res = mpu9250_set_standby_mode(&gs_handle, MPU9250_SOURCE_GYRO_X, MPU9250_BOOL_FALSE);
232 if (res != 0)
233 {
234 mpu9250_interface_debug_print("mpu9250: set standby mode failed.\n");
235 (void)mpu9250_deinit(&gs_handle);
236
237 return 1;
238 }
239
240 /* enable gyro y */
241 res = mpu9250_set_standby_mode(&gs_handle, MPU9250_SOURCE_GYRO_Y, MPU9250_BOOL_FALSE);
242 if (res != 0)
243 {
244 mpu9250_interface_debug_print("mpu9250: set standby mode failed.\n");
245 (void)mpu9250_deinit(&gs_handle);
246
247 return 1;
248 }
249
250 /* enable gyro z */
251 res = mpu9250_set_standby_mode(&gs_handle, MPU9250_SOURCE_GYRO_Z, MPU9250_BOOL_FALSE);
252 if (res != 0)
253 {
254 mpu9250_interface_debug_print("mpu9250: set standby mode failed.\n");
255 (void)mpu9250_deinit(&gs_handle);
256
257 return 1;
258 }
259
260 /* disable gyroscope x test */
261 res = mpu9250_set_gyroscope_test(&gs_handle, MPU9250_AXIS_X, MPU9250_BOOL_FALSE);
262 if (res != 0)
263 {
264 mpu9250_interface_debug_print("mpu9250: set gyroscope test failed.\n");
265 (void)mpu9250_deinit(&gs_handle);
266
267 return 1;
268 }
269
270 /* disable gyroscope y test */
271 res = mpu9250_set_gyroscope_test(&gs_handle, MPU9250_AXIS_Y, MPU9250_BOOL_FALSE);
272 if (res != 0)
273 {
274 mpu9250_interface_debug_print("mpu9250: set gyroscope test failed.\n");
275 (void)mpu9250_deinit(&gs_handle);
276
277 return 1;
278 }
279
280 /* disable gyroscope z test */
281 res = mpu9250_set_gyroscope_test(&gs_handle, MPU9250_AXIS_Z, MPU9250_BOOL_FALSE);
282 if (res != 0)
283 {
284 mpu9250_interface_debug_print("mpu9250: set gyroscope test failed.\n");
285 (void)mpu9250_deinit(&gs_handle);
286
287 return 1;
288 }
289
290 /* disable accelerometer x test */
291 res = mpu9250_set_accelerometer_test(&gs_handle, MPU9250_AXIS_X, MPU9250_BOOL_FALSE);
292 if (res != 0)
293 {
294 mpu9250_interface_debug_print("mpu9250: set accelerometer test failed.\n");
295 (void)mpu9250_deinit(&gs_handle);
296
297 return 1;
298 }
299
300 /* disable accelerometer y test */
301 res = mpu9250_set_accelerometer_test(&gs_handle, MPU9250_AXIS_Y, MPU9250_BOOL_FALSE);
302 if (res != 0)
303 {
304 mpu9250_interface_debug_print("mpu9250: set accelerometer test failed.\n");
305 (void)mpu9250_deinit(&gs_handle);
306
307 return 1;
308 }
309
310 /* disable accelerometer z test */
311 res = mpu9250_set_accelerometer_test(&gs_handle, MPU9250_AXIS_Z, MPU9250_BOOL_FALSE);
312 if (res != 0)
313 {
314 mpu9250_interface_debug_print("mpu9250: set accelerometer test failed.\n");
315 (void)mpu9250_deinit(&gs_handle);
316
317 return 1;
318 }
319
320 /* disable fifo */
321 res = mpu9250_set_fifo(&gs_handle, MPU9250_BOOL_FALSE);
322 if (res != 0)
323 {
324 mpu9250_interface_debug_print("mpu9250: set fifo failed.\n");
325 (void)mpu9250_deinit(&gs_handle);
326
327 return 1;
328 }
329
330 /* disable temp fifo */
331 res = mpu9250_set_fifo_enable(&gs_handle, MPU9250_FIFO_TEMP, MPU9250_BOOL_FALSE);
332 if (res != 0)
333 {
334 mpu9250_interface_debug_print("mpu9250: set fifo enable failed.\n");
335 (void)mpu9250_deinit(&gs_handle);
336
337 return 1;
338 }
339
340 /* disable xg fifo */
341 res = mpu9250_set_fifo_enable(&gs_handle, MPU9250_FIFO_XG, MPU9250_BOOL_FALSE);
342 if (res != 0)
343 {
344 mpu9250_interface_debug_print("mpu9250: set fifo enable failed.\n");
345 (void)mpu9250_deinit(&gs_handle);
346
347 return 1;
348 }
349
350 /* disable yg fifo */
351 res = mpu9250_set_fifo_enable(&gs_handle, MPU9250_FIFO_YG, MPU9250_BOOL_FALSE);
352 if (res != 0)
353 {
354 mpu9250_interface_debug_print("mpu9250: set fifo enable failed.\n");
355 (void)mpu9250_deinit(&gs_handle);
356
357 return 1;
358 }
359
360 /* disable zg fifo */
361 res = mpu9250_set_fifo_enable(&gs_handle, MPU9250_FIFO_ZG, MPU9250_BOOL_FALSE);
362 if (res != 0)
363 {
364 mpu9250_interface_debug_print("mpu9250: set fifo enable failed.\n");
365 (void)mpu9250_deinit(&gs_handle);
366
367 return 1;
368 }
369
370 /* disable accel fifo */
371 res = mpu9250_set_fifo_enable(&gs_handle, MPU9250_FIFO_ACCEL, MPU9250_BOOL_FALSE);
372 if (res != 0)
373 {
374 mpu9250_interface_debug_print("mpu9250: set fifo enable failed.\n");
375 (void)mpu9250_deinit(&gs_handle);
376
377 return 1;
378 }
379
380 /* set interrupt level low */
381 res = mpu9250_set_interrupt_level(&gs_handle, MPU9250_PIN_LEVEL_LOW);
382 if (res != 0)
383 {
384 mpu9250_interface_debug_print("mpu9250: set interrupt level failed.\n");
385 (void)mpu9250_deinit(&gs_handle);
386
387 return 1;
388 }
389
390 /* push-pull */
391 res = mpu9250_set_interrupt_pin_type(&gs_handle, MPU9250_PIN_TYPE_PUSH_PULL);
392 if (res != 0)
393 {
394 mpu9250_interface_debug_print("mpu9250: set interrupt pin type failed.\n");
395 (void)mpu9250_deinit(&gs_handle);
396
397 return 1;
398 }
399
400 /* disable motion */
401 res = mpu9250_set_interrupt(&gs_handle, MPU9250_INTERRUPT_MOTION, MPU9250_BOOL_FALSE);
402 if (res != 0)
403 {
404 mpu9250_interface_debug_print("mpu9250: set interrupt failed.\n");
405 (void)mpu9250_deinit(&gs_handle);
406
407 return 1;
408 }
409
410 /* disable fifo overflow */
411 res = mpu9250_set_interrupt(&gs_handle, MPU9250_INTERRUPT_FIFO_OVERFLOW, MPU9250_BOOL_FALSE);
412 if (res != 0)
413 {
414 mpu9250_interface_debug_print("mpu9250: set interrupt failed.\n");
415 (void)mpu9250_deinit(&gs_handle);
416
417 return 1;
418 }
419
420 /* disable dmp interrupt */
421 res = mpu9250_set_interrupt(&gs_handle, MPU9250_INTERRUPT_DMP, MPU9250_BOOL_FALSE);
422 if (res != 0)
423 {
424 mpu9250_interface_debug_print("mpu9250: set interrupt failed.\n");
425 (void)mpu9250_deinit(&gs_handle);
426
427 return 1;
428 }
429
430 /* disable fsync int */
431 res = mpu9250_set_interrupt(&gs_handle, MPU9250_INTERRUPT_FSYNC_INT, MPU9250_BOOL_FALSE);
432 if (res != 0)
433 {
434 mpu9250_interface_debug_print("mpu9250: set interrupt failed.\n");
435 (void)mpu9250_deinit(&gs_handle);
436
437 return 1;
438 }
439
440 /* disable data ready */
441 res = mpu9250_set_interrupt(&gs_handle, MPU9250_INTERRUPT_DATA_READY, MPU9250_BOOL_FALSE);
442 if (res != 0)
443 {
444 mpu9250_interface_debug_print("mpu9250: set interrupt failed.\n");
445 (void)mpu9250_deinit(&gs_handle);
446
447 return 1;
448 }
449
450 /* enable latch */
451 res = mpu9250_set_interrupt_latch(&gs_handle, MPU9250_BOOL_TRUE);
452 if (res != 0)
453 {
454 mpu9250_interface_debug_print("mpu9250: set interrupt latch failed.\n");
455 (void)mpu9250_deinit(&gs_handle);
456
457 return 1;
458 }
459
460 /* enable interrupt read clear */
461 res = mpu9250_set_interrupt_read_clear(&gs_handle, MPU9250_BOOL_TRUE);
462 if (res != 0)
463 {
464 mpu9250_interface_debug_print("mpu9250: set interrupt read clear failed.\n");
465 (void)mpu9250_deinit(&gs_handle);
466
467 return 1;
468 }
469
470 /* disable sync input */
471 res = mpu9250_set_extern_sync(&gs_handle, MPU9250_EXTERN_SYNC_INPUT_DISABLED);
472 if (res != 0)
473 {
474 mpu9250_interface_debug_print("mpu9250: set extern sync failed.\n");
475 (void)mpu9250_deinit(&gs_handle);
476
477 return 1;
478 }
479
480 /* disable fsync interrupt */
481 res = mpu9250_set_fsync_interrupt(&gs_handle, MPU9250_BOOL_FALSE);
482 if (res != 0)
483 {
484 mpu9250_interface_debug_print("mpu9250: set fsync interrupt failed.\n");
485 (void)mpu9250_deinit(&gs_handle);
486
487 return 1;
488 }
489
490 /* fsync interrupt level low */
491 res = mpu9250_set_fsync_interrupt_level(&gs_handle, MPU9250_PIN_LEVEL_LOW);
492 if (res != 0)
493 {
494 mpu9250_interface_debug_print("mpu9250: set fsync interrupt level failed.\n");
495 (void)mpu9250_deinit(&gs_handle);
496
497 return 1;
498 }
499
500 /* disable iic master */
501 res = mpu9250_set_iic_master(&gs_handle, MPU9250_BOOL_FALSE);
502 if (res != 0)
503 {
504 mpu9250_interface_debug_print("mpu9250: set iic master failed.\n");
505 (void)mpu9250_deinit(&gs_handle);
506
507 return 1;
508 }
509
510 /* disable iic bypass */
511 res = mpu9250_set_iic_bypass(&gs_handle, MPU9250_BOOL_FALSE);
512 if (res != 0)
513 {
514 mpu9250_interface_debug_print("mpu9250: set iic bypass failed.\n");
515 (void)mpu9250_deinit(&gs_handle);
516
517 return 1;
518 }
519
520 /* disable gyro standby */
521 res = mpu9250_set_gyro_standby(&gs_handle, MPU9250_BOOL_FALSE);
522 if (res != 0)
523 {
524 mpu9250_interface_debug_print("mpu9250: set gyro standby failed.\n");
525 (void)mpu9250_deinit(&gs_handle);
526
527 return 1;
528 }
529
530 /* set the fifo normal mode */
531 res = mpu9250_set_fifo_mode(&gs_handle, MPU9250_FIFO_MODE_NORMAL);
532 if (res != 0)
533 {
534 mpu9250_interface_debug_print("mpu9250: set fifo mode failed.\n");
535 (void)mpu9250_deinit(&gs_handle);
536
537 return 1;
538 }
539
540 /* set gyroscope choice 0 */
541 res = mpu9250_set_gyroscope_choice(&gs_handle, 0);
542 if (res != 0)
543 {
544 mpu9250_interface_debug_print("mpu9250: set gyroscope choice failed.\n");
545 (void)mpu9250_deinit(&gs_handle);
546
547 return 1;
548 }
549
550 /* set low pass filter 3 */
551 res = mpu9250_set_low_pass_filter(&gs_handle, MPU9250_LOW_PASS_FILTER_3);
552 if (res != 0)
553 {
554 mpu9250_interface_debug_print("mpu9250: set low pass filter failed.\n");
555 (void)mpu9250_deinit(&gs_handle);
556
557 return 1;
558 }
559
560 /* set accelerometer choice 0 */
561 res = mpu9250_set_accelerometer_choice(&gs_handle, 0);
562 if (res != 0)
563 {
564 mpu9250_interface_debug_print("mpu9250: set accelerometer choice failed.\n");
565 (void)mpu9250_deinit(&gs_handle);
566
567 return 1;
568 }
569
570 /* set accelerometer low pass filter 3 */
571 res = mpu9250_set_accelerometer_low_pass_filter(&gs_handle, MPU9250_ACCELEROMETER_LOW_PASS_FILTER_3);
572 if (res != 0)
573 {
574 mpu9250_interface_debug_print("mpu9250: set accelerometer low pass filter failed.\n");
575 (void)mpu9250_deinit(&gs_handle);
576
577 return 1;
578 }
579
580 /* set low power accel output rate 62.5Hz */
581 res = mpu9250_set_low_power_accel_output_rate(&gs_handle, MPU9250_LOW_POWER_ACCEL_OUTPUT_RATE_62P50);
582 if (res != 0)
583 {
584 mpu9250_interface_debug_print("mpu9250: set low power accel output rate failed.\n");
585 (void)mpu9250_deinit(&gs_handle);
586
587 return 1;
588 }
589
590 /* disable wake on motion */
591 res = mpu9250_set_wake_on_motion(&gs_handle, MPU9250_BOOL_FALSE);
592 if (res != 0)
593 {
594 mpu9250_interface_debug_print("mpu9250: set wake on motion failed.\n");
595 (void)mpu9250_deinit(&gs_handle);
596
597 return 1;
598 }
599
600 /* enable accel compare with previous sample */
601 res = mpu9250_set_accel_compare_with_previous_sample(&gs_handle, MPU9250_BOOL_TRUE);
602 if (res != 0)
603 {
604 mpu9250_interface_debug_print("mpu9250: set accel compare with previous sample failed.\n");
605 (void)mpu9250_deinit(&gs_handle);
606
607 return 1;
608 }
609
610 /* ±2g */
611 res = mpu9250_set_accelerometer_range(&gs_handle, MPU9250_ACCELEROMETER_RANGE_2G);
612 if (res != 0)
613 {
614 mpu9250_interface_debug_print("mpu9250: set accelerometer range failed.\n");
615 (void)mpu9250_deinit(&gs_handle);
616
617 return 1;
618 }
619
620 /* delay 100 ms */
621 mpu9250_interface_delay_ms(100);
622
623 mpu9250_interface_debug_print("mpu9250: set accelerometer range 2g.\n");
624 for (i = 0; i < times; i++)
625 {
626 int16_t accel_raw[1][3];
627 float accel_g[1][3];
628 int16_t gyro_raw[1][3];
629 float gyro_dps[1][3];
630 int16_t mag_raw[1][3];
631 float mag_ut[1][3];
632 uint16_t len;
633
634 len = 1;
635 res = mpu9250_read(&gs_handle, accel_raw, accel_g, gyro_raw, gyro_dps, mag_raw, mag_ut, &len);
636 if (res != 0)
637 {
638 mpu9250_interface_debug_print("mpu9250: read failed.\n");
639 (void)mpu9250_deinit(&gs_handle);
640
641 return 1;
642 }
643 mpu9250_interface_debug_print("mpu9250: acc x is %0.2fg.\n", accel_g[0][0]);
644 mpu9250_interface_debug_print("mpu9250: acc y is %0.2fg.\n", accel_g[0][1]);
645 mpu9250_interface_debug_print("mpu9250: acc z is %0.2fg.\n", accel_g[0][2]);
646
647 /* delay 1000 ms */
648 mpu9250_interface_delay_ms(1000);
649 }
650
651 /* ±4g */
652 res = mpu9250_set_accelerometer_range(&gs_handle, MPU9250_ACCELEROMETER_RANGE_4G);
653 if (res != 0)
654 {
655 mpu9250_interface_debug_print("mpu9250: set accelerometer range failed.\n");
656 (void)mpu9250_deinit(&gs_handle);
657
658 return 1;
659 }
660
661 /* delay 100 ms */
662 mpu9250_interface_delay_ms(100);
663
664 mpu9250_interface_debug_print("mpu9250: set accelerometer range 4g.\n");
665 for (i = 0; i < times; i++)
666 {
667 int16_t accel_raw[1][3];
668 float accel_g[1][3];
669 int16_t gyro_raw[1][3];
670 float gyro_dps[1][3];
671 int16_t mag_raw[1][3];
672 float mag_ut[1][3];
673 uint16_t len;
674
675 len = 1;
676 res = mpu9250_read(&gs_handle, accel_raw, accel_g, gyro_raw, gyro_dps, mag_raw, mag_ut, &len);
677 if (res != 0)
678 {
679 mpu9250_interface_debug_print("mpu9250: read failed.\n");
680 (void)mpu9250_deinit(&gs_handle);
681
682 return 1;
683 }
684 mpu9250_interface_debug_print("mpu9250: acc x is %0.2fg.\n", accel_g[0][0]);
685 mpu9250_interface_debug_print("mpu9250: acc y is %0.2fg.\n", accel_g[0][1]);
686 mpu9250_interface_debug_print("mpu9250: acc z is %0.2fg.\n", accel_g[0][2]);
687
688 /* delay 1000 ms */
689 mpu9250_interface_delay_ms(1000);
690 }
691
692 /* ±8g */
693 res = mpu9250_set_accelerometer_range(&gs_handle, MPU9250_ACCELEROMETER_RANGE_8G);
694 if (res != 0)
695 {
696 mpu9250_interface_debug_print("mpu9250: set accelerometer range failed.\n");
697 (void)mpu9250_deinit(&gs_handle);
698
699 return 1;
700 }
701
702 /* delay 100 ms */
703 mpu9250_interface_delay_ms(100);
704
705 mpu9250_interface_debug_print("mpu9250: set accelerometer range 8g.\n");
706 for (i = 0; i < times; i++)
707 {
708 int16_t accel_raw[1][3];
709 float accel_g[1][3];
710 int16_t gyro_raw[1][3];
711 float gyro_dps[1][3];
712 int16_t mag_raw[1][3];
713 float mag_ut[1][3];
714 uint16_t len;
715
716 len = 1;
717 res = mpu9250_read(&gs_handle, accel_raw, accel_g, gyro_raw, gyro_dps, mag_raw, mag_ut, &len);
718 if (res != 0)
719 {
720 mpu9250_interface_debug_print("mpu9250: read failed.\n");
721 (void)mpu9250_deinit(&gs_handle);
722
723 return 1;
724 }
725 mpu9250_interface_debug_print("mpu9250: acc x is %0.2fg.\n", accel_g[0][0]);
726 mpu9250_interface_debug_print("mpu9250: acc y is %0.2fg.\n", accel_g[0][1]);
727 mpu9250_interface_debug_print("mpu9250: acc z is %0.2fg.\n", accel_g[0][2]);
728
729 /* delay 1000 ms */
730 mpu9250_interface_delay_ms(1000);
731 }
732
733 /* ±16g */
734 res = mpu9250_set_accelerometer_range(&gs_handle, MPU9250_ACCELEROMETER_RANGE_16G);
735 if (res != 0)
736 {
737 mpu9250_interface_debug_print("mpu9250: set accelerometer range failed.\n");
738 (void)mpu9250_deinit(&gs_handle);
739
740 return 1;
741 }
742
743 /* delay 100 ms */
744 mpu9250_interface_delay_ms(100);
745
746 mpu9250_interface_debug_print("mpu9250: set accelerometer range 16g.\n");
747 for (i = 0; i < times; i++)
748 {
749 int16_t accel_raw[1][3];
750 float accel_g[1][3];
751 int16_t gyro_raw[1][3];
752 float gyro_dps[1][3];
753 int16_t mag_raw[1][3];
754 float mag_ut[1][3];
755 uint16_t len;
756
757 len = 1;
758 res = mpu9250_read(&gs_handle, accel_raw, accel_g, gyro_raw, gyro_dps, mag_raw, mag_ut, &len);
759 if (res != 0)
760 {
761 mpu9250_interface_debug_print("mpu9250: read failed.\n");
762 (void)mpu9250_deinit(&gs_handle);
763
764 return 1;
765 }
766 mpu9250_interface_debug_print("mpu9250: acc x is %0.2fg.\n", accel_g[0][0]);
767 mpu9250_interface_debug_print("mpu9250: acc y is %0.2fg.\n", accel_g[0][1]);
768 mpu9250_interface_debug_print("mpu9250: acc z is %0.2fg.\n", accel_g[0][2]);
769
770 /* delay 1000 ms */
771 mpu9250_interface_delay_ms(1000);
772 }
773
774 /* ±250dps */
775 res = mpu9250_set_gyroscope_range(&gs_handle, MPU9250_GYROSCOPE_RANGE_250DPS);
776 if (res != 0)
777 {
778 mpu9250_interface_debug_print("mpu9250: set gyroscope range failed.\n");
779 (void)mpu9250_deinit(&gs_handle);
780
781 return 1;
782 }
783
784 /* delay 100 ms */
785 mpu9250_interface_delay_ms(100);
786
787 mpu9250_interface_debug_print("mpu9250: set gyroscope range 250dps.\n");
788 for (i = 0; i < times; i++)
789 {
790 int16_t accel_raw[1][3];
791 float accel_g[1][3];
792 int16_t gyro_raw[1][3];
793 float gyro_dps[1][3];
794 int16_t mag_raw[1][3];
795 float mag_ut[1][3];
796 uint16_t len;
797
798 len = 1;
799 res = mpu9250_read(&gs_handle, accel_raw, accel_g, gyro_raw, gyro_dps, mag_raw, mag_ut, &len);
800 if (res != 0)
801 {
802 mpu9250_interface_debug_print("mpu9250: read failed.\n");
803 (void)mpu9250_deinit(&gs_handle);
804
805 return 1;
806 }
807 mpu9250_interface_debug_print("mpu9250: gyro x is %0.2fdps.\n", gyro_dps[0][0]);
808 mpu9250_interface_debug_print("mpu9250: gyro y is %0.2fdps.\n", gyro_dps[0][1]);
809 mpu9250_interface_debug_print("mpu9250: gyro z is %0.2fdps.\n", gyro_dps[0][2]);
810
811 /* delay 1000 ms */
812 mpu9250_interface_delay_ms(1000);
813 }
814
815 /* ±500dps */
816 res = mpu9250_set_gyroscope_range(&gs_handle, MPU9250_GYROSCOPE_RANGE_500DPS);
817 if (res != 0)
818 {
819 mpu9250_interface_debug_print("mpu9250: set gyroscope range failed.\n");
820 (void)mpu9250_deinit(&gs_handle);
821
822 return 1;
823 }
824
825 /* delay 100 ms */
826 mpu9250_interface_delay_ms(100);
827
828 mpu9250_interface_debug_print("mpu9250: set gyroscope range 500dps.\n");
829 for (i = 0; i < times; i++)
830 {
831 int16_t accel_raw[1][3];
832 float accel_g[1][3];
833 int16_t gyro_raw[1][3];
834 float gyro_dps[1][3];
835 int16_t mag_raw[1][3];
836 float mag_ut[1][3];
837 uint16_t len;
838
839 len = 1;
840 res = mpu9250_read(&gs_handle, accel_raw, accel_g, gyro_raw, gyro_dps, mag_raw, mag_ut, &len);
841 if (res != 0)
842 {
843 mpu9250_interface_debug_print("mpu9250: read failed.\n");
844 (void)mpu9250_deinit(&gs_handle);
845
846 return 1;
847 }
848 mpu9250_interface_debug_print("mpu9250: gyro x is %0.2fdps.\n", gyro_dps[0][0]);
849 mpu9250_interface_debug_print("mpu9250: gyro y is %0.2fdps.\n", gyro_dps[0][1]);
850 mpu9250_interface_debug_print("mpu9250: gyro z is %0.2fdps.\n", gyro_dps[0][2]);
851
852 /* delay 1000 ms */
853 mpu9250_interface_delay_ms(1000);
854 }
855
856 /* ±1000dps */
857 res = mpu9250_set_gyroscope_range(&gs_handle, MPU9250_GYROSCOPE_RANGE_1000DPS);
858 if (res != 0)
859 {
860 mpu9250_interface_debug_print("mpu9250: set gyroscope range failed.\n");
861 (void)mpu9250_deinit(&gs_handle);
862
863 return 1;
864 }
865
866 /* delay 100 ms */
867 mpu9250_interface_delay_ms(100);
868
869 mpu9250_interface_debug_print("mpu9250: set gyroscope range 1000dps.\n");
870 for (i = 0; i < times; i++)
871 {
872 int16_t accel_raw[1][3];
873 float accel_g[1][3];
874 int16_t gyro_raw[1][3];
875 float gyro_dps[1][3];
876 int16_t mag_raw[1][3];
877 float mag_ut[1][3];
878 uint16_t len;
879
880 len = 1;
881 res = mpu9250_read(&gs_handle, accel_raw, accel_g, gyro_raw, gyro_dps, mag_raw, mag_ut, &len);
882 if (res != 0)
883 {
884 mpu9250_interface_debug_print("mpu9250: read failed.\n");
885 (void)mpu9250_deinit(&gs_handle);
886
887 return 1;
888 }
889 mpu9250_interface_debug_print("mpu9250: gyro x is %0.2fdps.\n", gyro_dps[0][0]);
890 mpu9250_interface_debug_print("mpu9250: gyro y is %0.2fdps.\n", gyro_dps[0][1]);
891 mpu9250_interface_debug_print("mpu9250: gyro z is %0.2fdps.\n", gyro_dps[0][2]);
892
893 /* delay 1000 ms */
894 mpu9250_interface_delay_ms(1000);
895 }
896
897 /* ±2000dps */
898 res = mpu9250_set_gyroscope_range(&gs_handle, MPU9250_GYROSCOPE_RANGE_2000DPS);
899 if (res != 0)
900 {
901 mpu9250_interface_debug_print("mpu9250: set gyroscope range failed.\n");
902 (void)mpu9250_deinit(&gs_handle);
903
904 return 1;
905 }
906
907 /* delay 100 ms */
908 mpu9250_interface_delay_ms(100);
909
910 mpu9250_interface_debug_print("mpu9250: set gyroscope range 2000dps.\n");
911 for (i = 0; i < times; i++)
912 {
913 int16_t accel_raw[1][3];
914 float accel_g[1][3];
915 int16_t gyro_raw[1][3];
916 float gyro_dps[1][3];
917 int16_t mag_raw[1][3];
918 float mag_ut[1][3];
919 uint16_t len;
920
921 len = 1;
922 res = mpu9250_read(&gs_handle, accel_raw, accel_g, gyro_raw, gyro_dps, mag_raw, mag_ut, &len);
923 if (res != 0)
924 {
925 mpu9250_interface_debug_print("mpu9250: read failed.\n");
926 (void)mpu9250_deinit(&gs_handle);
927
928 return 1;
929 }
930 mpu9250_interface_debug_print("mpu9250: gyro x is %0.2fdps.\n", gyro_dps[0][0]);
931 mpu9250_interface_debug_print("mpu9250: gyro y is %0.2fdps.\n", gyro_dps[0][1]);
932 mpu9250_interface_debug_print("mpu9250: gyro z is %0.2fdps.\n", gyro_dps[0][2]);
933
934 /* delay 1000 ms */
935 mpu9250_interface_delay_ms(1000);
936 }
937
938 mpu9250_interface_debug_print("mpu9250: read temperature.\n");
939 for (i = 0; i < times; i++)
940 {
941 int16_t raw;
942 float degrees;
943
944 /* read temperature */
945 res = mpu9250_read_temperature(&gs_handle, &raw, &degrees);
946 if (res != 0)
947 {
948 mpu9250_interface_debug_print("mpu9250: read temperature failed.\n");
949 (void)mpu9250_deinit(&gs_handle);
950
951 return 1;
952 }
953 mpu9250_interface_debug_print("mpu9250: temperature %0.2fC.\n", degrees);
954
955 /* delay 1000 ms */
956 mpu9250_interface_delay_ms(1000);
957 }
958
959 /* if iic interface */
960 if (interface == MPU9250_INTERFACE_IIC)
961 {
962 /* mag init */
963 res = mpu9250_mag_init(&gs_handle);
964 if (res != 0)
965 {
966 mpu9250_interface_debug_print("mpu9250: mag init failed.\n");
967 (void)mpu9250_deinit(&gs_handle);
968
969 return 1;
970 }
971
972 /* 100Hz */
973 res = mpu9250_mag_set_mode(&gs_handle, MPU9250_MAGNETOMETER_MODE_CONTINUOUS2);
974 if (res != 0)
975 {
976 mpu9250_interface_debug_print("mpu9250: mag set mode failed.\n");
977 (void)mpu9250_mag_deinit(&gs_handle);
978 (void)mpu9250_deinit(&gs_handle);
979
980 return 1;
981 }
982
983 /* read magnetometer */
984 mpu9250_interface_debug_print("mpu9250: read magnetometer.\n");
985
986 /* set magnetometer 14 bits */
987 mpu9250_interface_debug_print("mpu9250: set magnetometer 14 bits.\n");
988
989 /* set 14 bits */
990 res = mpu9250_mag_set_bits(&gs_handle, MPU9250_MAGNETOMETER_BITS_14);
991 if (res != 0)
992 {
993 mpu9250_interface_debug_print("mpu9250: mag set bits failed.\n");
994 (void)mpu9250_mag_deinit(&gs_handle);
995 (void)mpu9250_deinit(&gs_handle);
996
997 return 1;
998 }
999
1000 for (i = 0; i < times; i++)
1001 {
1002 int16_t accel_raw[1][3];
1003 float accel_g[1][3];
1004 int16_t gyro_raw[1][3];
1005 float gyro_dps[1][3];
1006 int16_t mag_raw[1][3];
1007 float mag_ut[1][3];
1008 uint16_t len;
1009
1010 len = 1;
1011 res = mpu9250_read(&gs_handle, accel_raw, accel_g, gyro_raw, gyro_dps, mag_raw, mag_ut, &len);
1012 if (res != 0)
1013 {
1014 mpu9250_interface_debug_print("mpu9250: read failed.\n");
1015 (void)mpu9250_mag_deinit(&gs_handle);
1016 (void)mpu9250_deinit(&gs_handle);
1017
1018 return 1;
1019 }
1020 mpu9250_interface_debug_print("mpu9250: mag x is %0.2fuT.\n", mag_ut[0][0]);
1021 mpu9250_interface_debug_print("mpu9250: mag y is %0.2fuT.\n", mag_ut[0][1]);
1022 mpu9250_interface_debug_print("mpu9250: mag z is %0.2fuT.\n", mag_ut[0][2]);
1023
1024 /* delay 1000 ms */
1025 mpu9250_interface_delay_ms(1000);
1026 }
1027
1028 /* set magnetometer 16 bits */
1029 mpu9250_interface_debug_print("mpu9250: set magnetometer 16 bits.\n");
1030
1031 /* set 16 bits */
1032 res = mpu9250_mag_set_bits(&gs_handle, MPU9250_MAGNETOMETER_BITS_16);
1033 if (res != 0)
1034 {
1035 mpu9250_interface_debug_print("mpu9250: mag set bits failed.\n");
1036 (void)mpu9250_mag_deinit(&gs_handle);
1037 (void)mpu9250_deinit(&gs_handle);
1038
1039 return 1;
1040 }
1041
1042 for (i = 0; i < times; i++)
1043 {
1044 int16_t accel_raw[1][3];
1045 float accel_g[1][3];
1046 int16_t gyro_raw[1][3];
1047 float gyro_dps[1][3];
1048 int16_t mag_raw[1][3];
1049 float mag_ut[1][3];
1050 uint16_t len;
1051
1052 len = 1;
1053 res = mpu9250_read(&gs_handle, accel_raw, accel_g, gyro_raw, gyro_dps, mag_raw, mag_ut, &len);
1054 if (res != 0)
1055 {
1056 mpu9250_interface_debug_print("mpu9250: read failed.\n");
1057 (void)mpu9250_mag_deinit(&gs_handle);
1058 (void)mpu9250_deinit(&gs_handle);
1059
1060 return 1;
1061 }
1062 mpu9250_interface_debug_print("mpu9250: mag x is %0.2fuT.\n", mag_ut[0][0]);
1063 mpu9250_interface_debug_print("mpu9250: mag y is %0.2fuT.\n", mag_ut[0][1]);
1064 mpu9250_interface_debug_print("mpu9250: mag z is %0.2fuT.\n", mag_ut[0][2]);
1065
1066 /* delay 1000 ms */
1067 mpu9250_interface_delay_ms(1000);
1068 }
1069
1070 /* mpu9250 mag read test */
1071 mpu9250_interface_debug_print("mpu9250: mpu9250 mag read test.\n");
1072
1073 for (i = 0; i < times; i++)
1074 {
1075 int16_t mag_raw[3];
1076 float mag_ut[3];
1077
1078 res = mpu9250_mag_read(&gs_handle, mag_raw, mag_ut);
1079 if (res != 0)
1080 {
1081 mpu9250_interface_debug_print("mpu9250: mag read failed.\n");
1082 (void)mpu9250_mag_deinit(&gs_handle);
1083 (void)mpu9250_deinit(&gs_handle);
1084
1085 return 1;
1086 }
1087 mpu9250_interface_debug_print("mpu9250: mag x is %0.2fuT.\n", mag_ut[0]);
1088 mpu9250_interface_debug_print("mpu9250: mag y is %0.2fuT.\n", mag_ut[1]);
1089 mpu9250_interface_debug_print("mpu9250: mag z is %0.2fuT.\n", mag_ut[2]);
1090
1091 /* delay 1000 ms */
1092 mpu9250_interface_delay_ms(1000);
1093 }
1094
1095 /* mag deinit */
1096 (void)mpu9250_mag_deinit(&gs_handle);
1097 }
1098
1099 /* finish read test */
1100 mpu9250_interface_debug_print("mpu9250: finish read test.\n");
1101 (void)mpu9250_deinit(&gs_handle);
1102
1103 return 0;
1104 }
driver_mpu9250_read_test.h
driver mpu9250 read test header file
mpu9250_set_accelerometer_low_pass_filter
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
Definition: driver_mpu9250.c:7886
mpu9250_set_wake_on_motion
uint8_t mpu9250_set_wake_on_motion(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable wake on motion
Definition: driver_mpu9250.c:8050
mpu9250_set_accel_compare_with_previous_sample
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
Definition: driver_mpu9250.c:8132
mpu9250_set_fifo_mode
uint8_t mpu9250_set_fifo_mode(mpu9250_handle_t *handle, mpu9250_fifo_mode mode)
set the fifo mode
Definition: driver_mpu9250.c:7249
mpu9250_set_addr_pin
uint8_t mpu9250_set_addr_pin(mpu9250_handle_t *handle, mpu9250_address_t addr_pin)
set the chip address pin
Definition: driver_mpu9250.c:3964
mpu9250_set_ptat
uint8_t mpu9250_set_ptat(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the temperature sensor
Definition: driver_mpu9250.c:6449
mpu9250_set_fifo_enable
uint8_t mpu9250_set_fifo_enable(mpu9250_handle_t *handle, mpu9250_fifo_t fifo, mpu9250_bool_t enable)
enable or disable the fifo function
Definition: driver_mpu9250.c:8215
mpu9250_set_standby_mode
uint8_t mpu9250_set_standby_mode(mpu9250_handle_t *handle, mpu9250_source_t source, mpu9250_bool_t enable)
set source into standby mode
Definition: driver_mpu9250.c:6778
mpu9250_set_cycle_wake_up
uint8_t mpu9250_set_cycle_wake_up(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the cycle wake up mode
Definition: driver_mpu9250.c:6531
mpu9250_set_interrupt_latch
uint8_t mpu9250_set_interrupt_latch(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the interrupt latch
Definition: driver_mpu9250.c:8462
mpu9250_set_extern_sync
uint8_t mpu9250_set_extern_sync(mpu9250_handle_t *handle, mpu9250_extern_sync_t sync)
set the extern sync type
Definition: driver_mpu9250.c:7085
mpu9250_set_gyro_standby
uint8_t mpu9250_set_gyro_standby(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the gyro standby
Definition: driver_mpu9250.c:6695
mpu9250_address_t
mpu9250_address_t
mpu9250 address enumeration definition
Definition: driver_mpu9250.h:72
mpu9250_set_fsync_interrupt
uint8_t mpu9250_set_fsync_interrupt(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the fsync interrupt
Definition: driver_mpu9250.c:8708
mpu9250_set_iic_bypass
uint8_t mpu9250_set_iic_bypass(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the iic bypass
Definition: driver_mpu9250.c:8790
mpu9250_info
uint8_t mpu9250_info(mpu9250_info_t *info)
get the chip's information
Definition: driver_mpu9250.c:13083
mpu9250_set_accelerometer_test
uint8_t mpu9250_set_accelerometer_test(mpu9250_handle_t *handle, mpu9250_axis_t axis, mpu9250_bool_t enable)
set the accelerometer test
Definition: driver_mpu9250.c:7587
mpu9250_set_interrupt_level
uint8_t mpu9250_set_interrupt_level(mpu9250_handle_t *handle, mpu9250_pin_level_t level)
set the interrupt level
Definition: driver_mpu9250.c:8298
mpu9250_set_interrupt_read_clear
uint8_t mpu9250_set_interrupt_read_clear(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the interrupt reading clear
Definition: driver_mpu9250.c:8544
mpu9250_set_interface
uint8_t mpu9250_set_interface(mpu9250_handle_t *handle, mpu9250_interface_t interface)
set the chip interface
Definition: driver_mpu9250.c:3922
mpu9250_interface_t
mpu9250_interface_t
mpu9250 interface enumeration definition
Definition: driver_mpu9250.h:63
mpu9250_set_interrupt
uint8_t mpu9250_set_interrupt(mpu9250_handle_t *handle, mpu9250_interrupt_t type, mpu9250_bool_t enable)
enable or disable the interrupt
Definition: driver_mpu9250.c:8873
mpu9250_set_fsync_interrupt_level
uint8_t mpu9250_set_fsync_interrupt_level(mpu9250_handle_t *handle, mpu9250_pin_level_t level)
set the fsync interrupt level
Definition: driver_mpu9250.c:8626
mpu9250_set_gyroscope_choice
uint8_t mpu9250_set_gyroscope_choice(mpu9250_handle_t *handle, uint8_t choice)
set the gyroscope choice
Definition: driver_mpu9250.c:7498
mpu9250_deinit
uint8_t mpu9250_deinit(mpu9250_handle_t *handle)
close the chip
Definition: driver_mpu9250.c:4168
mpu9250_read
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
Definition: driver_mpu9250.c:4223
mpu9250_read_temperature
uint8_t mpu9250_read_temperature(mpu9250_handle_t *handle, int16_t(*raw), float *degrees)
read the temperature
Definition: driver_mpu9250.c:4631
mpu9250_set_fifo_1024kb
uint8_t mpu9250_set_fifo_1024kb(mpu9250_handle_t *handle)
set fifo 1024kb
Definition: driver_mpu9250.c:7751
mpu9250_set_low_pass_filter
uint8_t mpu9250_set_low_pass_filter(mpu9250_handle_t *handle, mpu9250_low_pass_filter_t filter)
set the low pass filter
Definition: driver_mpu9250.c:7167
mpu9250_set_gyroscope_test
uint8_t mpu9250_set_gyroscope_test(mpu9250_handle_t *handle, mpu9250_axis_t axis, mpu9250_bool_t enable)
set the gyroscope test
Definition: driver_mpu9250.c:7332
mpu9250_set_clock_source
uint8_t mpu9250_set_clock_source(mpu9250_handle_t *handle, mpu9250_clock_source_t clock_source)
set the chip clock source
Definition: driver_mpu9250.c:6367
mpu9250_set_low_power_accel_output_rate
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
Definition: driver_mpu9250.c:7968
mpu9250_set_disable_iic_slave
uint8_t mpu9250_set_disable_iic_slave(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the iic slave mode
Definition: driver_mpu9250.c:5961
mpu9250_set_sample_rate_divider
uint8_t mpu9250_set_sample_rate_divider(mpu9250_handle_t *handle, uint8_t d)
set the sample rate divider
Definition: driver_mpu9250.c:7015
mpu9250_set_fifo
uint8_t mpu9250_set_fifo(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable fifo
Definition: driver_mpu9250.c:5763
mpu9250_init
uint8_t mpu9250_init(mpu9250_handle_t *handle)
initialize the chip
Definition: driver_mpu9250.c:4009
mpu9250_set_accelerometer_choice
uint8_t mpu9250_set_accelerometer_choice(mpu9250_handle_t *handle, uint8_t choice)
set the accelerometer choice
Definition: driver_mpu9250.c:7797
mpu9250_set_gyroscope_range
uint8_t mpu9250_set_gyroscope_range(mpu9250_handle_t *handle, mpu9250_gyroscope_range_t range)
set the gyroscope range
Definition: driver_mpu9250.c:7415
mpu9250_set_interrupt_pin_type
uint8_t mpu9250_set_interrupt_pin_type(mpu9250_handle_t *handle, mpu9250_pin_type_t type)
set the interrupt pin type
Definition: driver_mpu9250.c:8380
mpu9250_set_iic_master
uint8_t mpu9250_set_iic_master(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the iic master mode
Definition: driver_mpu9250.c:5879
mpu9250_set_accelerometer_range
uint8_t mpu9250_set_accelerometer_range(mpu9250_handle_t *handle, mpu9250_accelerometer_range_t range)
set the accelerometer range
Definition: driver_mpu9250.c:7670
mpu9250_set_sleep
uint8_t mpu9250_set_sleep(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the sleep mode
Definition: driver_mpu9250.c:6613
MPU9250_ACCELEROMETER_RANGE_4G
@ MPU9250_ACCELEROMETER_RANGE_4G
Definition: driver_mpu9250.h:213
MPU9250_ACCELEROMETER_RANGE_2G
@ MPU9250_ACCELEROMETER_RANGE_2G
Definition: driver_mpu9250.h:212
MPU9250_ACCELEROMETER_RANGE_16G
@ MPU9250_ACCELEROMETER_RANGE_16G
Definition: driver_mpu9250.h:215
MPU9250_ACCELEROMETER_RANGE_8G
@ MPU9250_ACCELEROMETER_RANGE_8G
Definition: driver_mpu9250.h:214
MPU9250_PIN_TYPE_PUSH_PULL
@ MPU9250_PIN_TYPE_PUSH_PULL
Definition: driver_mpu9250.h:254
MPU9250_GYROSCOPE_RANGE_2000DPS
@ MPU9250_GYROSCOPE_RANGE_2000DPS
Definition: driver_mpu9250.h:204
MPU9250_GYROSCOPE_RANGE_250DPS
@ MPU9250_GYROSCOPE_RANGE_250DPS
Definition: driver_mpu9250.h:201
MPU9250_GYROSCOPE_RANGE_500DPS
@ MPU9250_GYROSCOPE_RANGE_500DPS
Definition: driver_mpu9250.h:202
MPU9250_GYROSCOPE_RANGE_1000DPS
@ MPU9250_GYROSCOPE_RANGE_1000DPS
Definition: driver_mpu9250.h:203
MPU9250_INTERRUPT_MOTION
@ MPU9250_INTERRUPT_MOTION
Definition: driver_mpu9250.h:263
MPU9250_INTERRUPT_DATA_READY
@ MPU9250_INTERRUPT_DATA_READY
Definition: driver_mpu9250.h:267
MPU9250_INTERRUPT_FSYNC_INT
@ MPU9250_INTERRUPT_FSYNC_INT
Definition: driver_mpu9250.h:265
MPU9250_INTERRUPT_DMP
@ MPU9250_INTERRUPT_DMP
Definition: driver_mpu9250.h:266
MPU9250_INTERRUPT_FIFO_OVERFLOW
@ MPU9250_INTERRUPT_FIFO_OVERFLOW
Definition: driver_mpu9250.h:264
MPU9250_EXTERN_SYNC_INPUT_DISABLED
@ MPU9250_EXTERN_SYNC_INPUT_DISABLED
Definition: driver_mpu9250.h:124
MPU9250_SOURCE_GYRO_X
@ MPU9250_SOURCE_GYRO_X
Definition: driver_mpu9250.h:94
MPU9250_SOURCE_ACC_Z
@ MPU9250_SOURCE_ACC_Z
Definition: driver_mpu9250.h:93
MPU9250_SOURCE_GYRO_Y
@ MPU9250_SOURCE_GYRO_Y
Definition: driver_mpu9250.h:95
MPU9250_SOURCE_GYRO_Z
@ MPU9250_SOURCE_GYRO_Z
Definition: driver_mpu9250.h:96
MPU9250_SOURCE_ACC_X
@ MPU9250_SOURCE_ACC_X
Definition: driver_mpu9250.h:91
MPU9250_SOURCE_ACC_Y
@ MPU9250_SOURCE_ACC_Y
Definition: driver_mpu9250.h:92
MPU9250_INTERFACE_SPI
@ MPU9250_INTERFACE_SPI
Definition: driver_mpu9250.h:65
MPU9250_INTERFACE_IIC
@ MPU9250_INTERFACE_IIC
Definition: driver_mpu9250.h:64
MPU9250_BOOL_TRUE
@ MPU9250_BOOL_TRUE
Definition: driver_mpu9250.h:83
MPU9250_BOOL_FALSE
@ MPU9250_BOOL_FALSE
Definition: driver_mpu9250.h:82
MPU9250_LOW_PASS_FILTER_3
@ MPU9250_LOW_PASS_FILTER_3
Definition: driver_mpu9250.h:144
MPU9250_FIFO_MODE_NORMAL
@ MPU9250_FIFO_MODE_NORMAL
Definition: driver_mpu9250.h:237
MPU9250_LOW_POWER_ACCEL_OUTPUT_RATE_62P50
@ MPU9250_LOW_POWER_ACCEL_OUTPUT_RATE_62P50
Definition: driver_mpu9250.h:180
MPU9250_AXIS_X
@ MPU9250_AXIS_X
Definition: driver_mpu9250.h:193
MPU9250_AXIS_Z
@ MPU9250_AXIS_Z
Definition: driver_mpu9250.h:191
MPU9250_AXIS_Y
@ MPU9250_AXIS_Y
Definition: driver_mpu9250.h:192
MPU9250_ACCELEROMETER_LOW_PASS_FILTER_3
@ MPU9250_ACCELEROMETER_LOW_PASS_FILTER_3
Definition: driver_mpu9250.h:160
MPU9250_PIN_LEVEL_LOW
@ MPU9250_PIN_LEVEL_LOW
Definition: driver_mpu9250.h:246
MPU9250_FIFO_XG
@ MPU9250_FIFO_XG
Definition: driver_mpu9250.h:224
MPU9250_FIFO_YG
@ MPU9250_FIFO_YG
Definition: driver_mpu9250.h:225
MPU9250_FIFO_ZG
@ MPU9250_FIFO_ZG
Definition: driver_mpu9250.h:226
MPU9250_FIFO_ACCEL
@ MPU9250_FIFO_ACCEL
Definition: driver_mpu9250.h:227
MPU9250_FIFO_TEMP
@ MPU9250_FIFO_TEMP
Definition: driver_mpu9250.h:223
MPU9250_CLOCK_SOURCE_PLL
@ MPU9250_CLOCK_SOURCE_PLL
Definition: driver_mpu9250.h:105
mpu9250_interface_debug_print
void mpu9250_interface_debug_print(const char *const fmt,...)
interface print format data
Definition: driver_mpu9250_interface_template.c:164
mpu9250_interface_spi_write
uint8_t mpu9250_interface_spi_write(uint8_t reg, uint8_t *buf, uint16_t len)
interface spi bus write
Definition: driver_mpu9250_interface_template.c:144
mpu9250_interface_iic_deinit
uint8_t mpu9250_interface_iic_deinit(void)
interface iic bus deinit
Definition: driver_mpu9250_interface_template.c:58
mpu9250_interface_iic_write
uint8_t mpu9250_interface_iic_write(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
interface iic bus write
Definition: driver_mpu9250_interface_template.c:90
mpu9250_interface_iic_read
uint8_t mpu9250_interface_iic_read(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
interface iic bus read
Definition: driver_mpu9250_interface_template.c:74
mpu9250_interface_iic_init
uint8_t mpu9250_interface_iic_init(void)
interface iic bus init
Definition: driver_mpu9250_interface_template.c:46
mpu9250_interface_spi_read
uint8_t mpu9250_interface_spi_read(uint8_t reg, uint8_t *buf, uint16_t len)
interface spi bus read
Definition: driver_mpu9250_interface_template.c:129
mpu9250_interface_spi_init
uint8_t mpu9250_interface_spi_init(void)
interface spi bus init
Definition: driver_mpu9250_interface_template.c:102
mpu9250_interface_receive_callback
void mpu9250_interface_receive_callback(uint8_t type)
interface receive callback
Definition: driver_mpu9250_interface_template.c:174
mpu9250_interface_delay_ms
void mpu9250_interface_delay_ms(uint32_t ms)
interface delay ms
Definition: driver_mpu9250_interface_template.c:154
mpu9250_interface_spi_deinit
uint8_t mpu9250_interface_spi_deinit(void)
interface spi bus deinit
Definition: driver_mpu9250_interface_template.c:114
DRIVER_MPU9250_LINK_INIT
#define DRIVER_MPU9250_LINK_INIT(HANDLE, STRUCTURE)
initialize mpu9250_handle_t structure
Definition: driver_mpu9250.h:560
DRIVER_MPU9250_LINK_RECEIVE_CALLBACK
#define DRIVER_MPU9250_LINK_RECEIVE_CALLBACK(HANDLE, FUC)
link receive_callback function
Definition: driver_mpu9250.h:648
DRIVER_MPU9250_LINK_IIC_DEINIT
#define DRIVER_MPU9250_LINK_IIC_DEINIT(HANDLE, FUC)
link iic_deinit function
Definition: driver_mpu9250.h:576
DRIVER_MPU9250_LINK_SPI_INIT
#define DRIVER_MPU9250_LINK_SPI_INIT(HANDLE, FUC)
link spi_init function
Definition: driver_mpu9250.h:600
DRIVER_MPU9250_LINK_SPI_READ
#define DRIVER_MPU9250_LINK_SPI_READ(HANDLE, FUC)
link spi_read function
Definition: driver_mpu9250.h:616
DRIVER_MPU9250_LINK_IIC_READ
#define DRIVER_MPU9250_LINK_IIC_READ(HANDLE, FUC)
link iic_read function
Definition: driver_mpu9250.h:584
DRIVER_MPU9250_LINK_IIC_WRITE
#define DRIVER_MPU9250_LINK_IIC_WRITE(HANDLE, FUC)
link iic_write function
Definition: driver_mpu9250.h:592
DRIVER_MPU9250_LINK_SPI_DEINIT
#define DRIVER_MPU9250_LINK_SPI_DEINIT(HANDLE, FUC)
link spi_deinit function
Definition: driver_mpu9250.h:608
DRIVER_MPU9250_LINK_IIC_INIT
#define DRIVER_MPU9250_LINK_IIC_INIT(HANDLE, FUC)
link iic_init function
Definition: driver_mpu9250.h:568
DRIVER_MPU9250_LINK_DEBUG_PRINT
#define DRIVER_MPU9250_LINK_DEBUG_PRINT(HANDLE, FUC)
link debug_print function
Definition: driver_mpu9250.h:640
DRIVER_MPU9250_LINK_DELAY_MS
#define DRIVER_MPU9250_LINK_DELAY_MS(HANDLE, FUC)
link delay_ms function
Definition: driver_mpu9250.h:632
DRIVER_MPU9250_LINK_SPI_WRITE
#define DRIVER_MPU9250_LINK_SPI_WRITE(HANDLE, FUC)
link spi_write function
Definition: driver_mpu9250.h:624
mpu9250_mag_set_mode
uint8_t mpu9250_mag_set_mode(mpu9250_handle_t *handle, mpu9250_magnetometer_mode_t mode)
magnetometer set the mode
Definition: driver_mpu9250.c:5186
mpu9250_mag_set_bits
uint8_t mpu9250_mag_set_bits(mpu9250_handle_t *handle, mpu9250_magnetometer_bits_t bits)
magnetometer set the bits
Definition: driver_mpu9250.c:5282
mpu9250_mag_init
uint8_t mpu9250_mag_init(mpu9250_handle_t *handle)
initialize the magnetometer of mpu9250
Definition: driver_mpu9250.c:4742
mpu9250_mag_deinit
uint8_t mpu9250_mag_deinit(mpu9250_handle_t *handle)
magnetometer deinit
Definition: driver_mpu9250.c:4894
mpu9250_mag_read
uint8_t mpu9250_mag_read(mpu9250_handle_t *handle, int16_t mag_raw[3], float mag_ut[3])
mag read the data
Definition: driver_mpu9250.c:4995
MPU9250_MAGNETOMETER_BITS_16
@ MPU9250_MAGNETOMETER_BITS_16
Definition: driver_mpu9250.h:428
MPU9250_MAGNETOMETER_BITS_14
@ MPU9250_MAGNETOMETER_BITS_14
Definition: driver_mpu9250.h:427
MPU9250_MAGNETOMETER_MODE_CONTINUOUS2
@ MPU9250_MAGNETOMETER_MODE_CONTINUOUS2
Definition: driver_mpu9250.h:416
mpu9250_read_test
uint8_t mpu9250_read_test(mpu9250_interface_t interface, mpu9250_address_t addr, uint32_t times)
read test
Definition: driver_mpu9250_read_test.c:51
mpu9250_handle_s
mpu9250 handle structure definition
Definition: driver_mpu9250.h:502
mpu9250_info_s
mpu9250 information structure definition
Definition: driver_mpu9250.h:531
mpu9250_info_s::temperature_max
float temperature_max
Definition: driver_mpu9250.h:539
mpu9250_info_s::supply_voltage_max_v
float supply_voltage_max_v
Definition: driver_mpu9250.h:536
mpu9250_info_s::driver_version
uint32_t driver_version
Definition: driver_mpu9250.h:540
mpu9250_info_s::temperature_min
float temperature_min
Definition: driver_mpu9250.h:538
mpu9250_info_s::max_current_ma
float max_current_ma
Definition: driver_mpu9250.h:537
mpu9250_info_s::manufacturer_name
char manufacturer_name[32]
Definition: driver_mpu9250.h:533
mpu9250_info_s::supply_voltage_min_v
float supply_voltage_min_v
Definition: driver_mpu9250.h:535
mpu9250_info_s::interface
char interface[8]
Definition: driver_mpu9250.h:534
mpu9250_info_s::chip_name
char chip_name[32]
Definition: driver_mpu9250.h:532