| LibDriver MPU9250 1.0.0 MPU9250 full function driver

driver_mpu9250_dmp_tap_orient_motion_test.c
Go to the documentation of this file.
1
37 #include "driver_mpu9250_dmp_tap_orient_motion_test.h"
38 #include <stdlib.h>
39
40 static mpu9250_handle_t gs_handle;
41 static int16_t gs_accel_raw[128][3];
42 static float gs_accel_g[128][3];
43 static int16_t gs_gyro_raw[128][3];
44 static float gs_gyro_dps[128][3];
45 static int32_t gs_quat[128][4];
46 static float gs_pitch[128];
47 static float gs_roll[128];
48 static float gs_yaw[128];
49 static volatile uint8_t gs_flag;
58 uint8_t mpu9250_dmp_tap_orient_motion_test_irq_handler(void)
59 {
60 if (mpu9250_irq_handler(&gs_handle) != 0)
61 {
62 return 1;
63 }
64 else
65 {
66 return 0;
67 }
68 }
69
75 static void a_receive_callback(uint8_t type)
76 {
77 switch (type)
78 {
79 case MPU9250_INTERRUPT_MOTION :
80 {
81 gs_flag |= 1 << 0;
82 mpu9250_interface_debug_print("mpu9250: irq motion.\n");
83
84 break;
85 }
86 case MPU9250_INTERRUPT_FIFO_OVERFLOW :
87 {
88 mpu9250_interface_debug_print("mpu9250: irq fifo overflow.\n");
89
90 break;
91 }
92 case MPU9250_INTERRUPT_FSYNC_INT :
93 {
94 mpu9250_interface_debug_print("mpu9250: irq fsync int.\n");
95
96 break;
97 }
98 case MPU9250_INTERRUPT_DMP :
99 {
100 break;
101 }
102 case MPU9250_INTERRUPT_DATA_READY :
103 {
104 break;
105 }
106 default :
107 {
108 mpu9250_interface_debug_print("mpu9250: irq unknown code.\n");
109
110 break;
111 }
112 }
113 }
114
121 static void a_dmp_tap_callback(uint8_t count, uint8_t direction)
122 {
123 switch (direction)
124 {
125 case MPU9250_DMP_TAP_X_UP :
126 {
127 gs_flag |= 1 << 1;
128 mpu9250_interface_debug_print("mpu9250: tap irq x up with %d.\n", count);
129
130 break;
131 }
132 case MPU9250_DMP_TAP_X_DOWN :
133 {
134 gs_flag |= 1 << 1;
135 mpu9250_interface_debug_print("mpu9250: tap irq x down with %d.\n", count);
136
137 break;
138 }
139 case MPU9250_DMP_TAP_Y_UP :
140 {
141 gs_flag |= 1 << 1;
142 mpu9250_interface_debug_print("mpu9250: tap irq y up with %d.\n", count);
143
144 break;
145 }
146 case MPU9250_DMP_TAP_Y_DOWN :
147 {
148 gs_flag |= 1 << 1;
149 mpu9250_interface_debug_print("mpu9250: tap irq y down with %d.\n", count);
150
151 break;
152 }
153 case MPU9250_DMP_TAP_Z_UP :
154 {
155 gs_flag |= 1 << 1;
156 mpu9250_interface_debug_print("mpu9250: tap irq z up with %d.\n", count);
157
158 break;
159 }
160 case MPU9250_DMP_TAP_Z_DOWN :
161 {
162 gs_flag |= 1 << 1;
163 mpu9250_interface_debug_print("mpu9250: tap irq z down with %d.\n", count);
164
165 break;
166 }
167 default :
168 {
169 mpu9250_interface_debug_print("mpu9250: tap irq unknown code.\n");
170
171 break;
172 }
173 }
174 }
175
181 static void a_dmp_orient_callback(uint8_t orientation)
182 {
183 switch (orientation)
184 {
185 case MPU9250_DMP_ORIENT_PORTRAIT :
186 {
187 gs_flag |= 1 << 2;
188 mpu9250_interface_debug_print("mpu9250: orient irq portrait.\n");
189
190 break;
191 }
192 case MPU9250_DMP_ORIENT_LANDSCAPE :
193 {
194 gs_flag |= 1 << 2;
195 mpu9250_interface_debug_print("mpu9250: orient irq landscape.\n");
196
197 break;
198 }
199 case MPU9250_DMP_ORIENT_REVERSE_PORTRAIT :
200 {
201 gs_flag |= 1 << 2;
202 mpu9250_interface_debug_print("mpu9250: orient irq reverse portrait.\n");
203
204 break;
205 }
206 case MPU9250_DMP_ORIENT_REVERSE_LANDSCAPE :
207 {
208 gs_flag |= 1 << 2;
209 mpu9250_interface_debug_print("mpu9250: orient irq reverse landscape.\n");
210
211 break;
212 }
213 default :
214 {
215 mpu9250_interface_debug_print("mpu9250: orient irq unknown code.\n");
216
217 break;
218 }
219 }
220 }
221
231 uint8_t mpu9250_dmp_tap_orient_motion_test(mpu9250_interface_t interface, mpu9250_address_t addr)
232 {
233 uint8_t res;
234 uint8_t reg;
235 uint32_t ms;
236 uint32_t ms_check;
237 uint32_t cnt;
238 uint32_t cnt_check;
239 uint32_t i;
240 uint16_t m;
241 uint16_t m_check;
242 uint8_t c;
243 uint8_t c_check;
244 int32_t gyro_offset_raw[3];
245 int32_t accel_offset_raw[3];
246 int32_t gyro_offset[3];
247 int32_t accel_offset[3];
248 mpu9250_bool_t enable;
249 mpu9250_info_t info;
250 int8_t gyro_orientation[9] = {1, 0, 0,
251 0, 1, 0,
252 0, 0, 1};
253
254 /* link interface function */
255 DRIVER_MPU9250_LINK_INIT(&gs_handle, mpu9250_handle_t);
256 DRIVER_MPU9250_LINK_IIC_INIT(&gs_handle, mpu9250_interface_iic_init);
257 DRIVER_MPU9250_LINK_IIC_DEINIT(&gs_handle, mpu9250_interface_iic_deinit);
258 DRIVER_MPU9250_LINK_IIC_READ(&gs_handle, mpu9250_interface_iic_read);
259 DRIVER_MPU9250_LINK_IIC_WRITE(&gs_handle, mpu9250_interface_iic_write);
260 DRIVER_MPU9250_LINK_SPI_INIT(&gs_handle, mpu9250_interface_spi_init);
261 DRIVER_MPU9250_LINK_SPI_DEINIT(&gs_handle, mpu9250_interface_spi_deinit);
262 DRIVER_MPU9250_LINK_SPI_READ(&gs_handle, mpu9250_interface_spi_read);
263 DRIVER_MPU9250_LINK_SPI_WRITE(&gs_handle, mpu9250_interface_spi_write);
264 DRIVER_MPU9250_LINK_DELAY_MS(&gs_handle, mpu9250_interface_delay_ms);
265 DRIVER_MPU9250_LINK_DEBUG_PRINT(&gs_handle, mpu9250_interface_debug_print);
266 DRIVER_MPU9250_LINK_RECEIVE_CALLBACK(&gs_handle, a_receive_callback);
267
268 /* get information */
269 res = mpu9250_info(&info);
270 if (res != 0)
271 {
272 mpu9250_interface_debug_print("mpu9250: get info failed.\n");
273
274 return 1;
275 }
276 else
277 {
278 /* print chip info */
279 mpu9250_interface_debug_print("mpu9250: chip is %s.\n", info.chip_name);
280 mpu9250_interface_debug_print("mpu9250: manufacturer is %s.\n", info.manufacturer_name);
281 mpu9250_interface_debug_print("mpu9250: interface is %s.\n", info.interface);
282 mpu9250_interface_debug_print("mpu9250: driver version is %d.%d.\n", info.driver_version / 1000, (info.driver_version % 1000) / 100);
283 mpu9250_interface_debug_print("mpu9250: min supply voltage is %0.1fV.\n", info.supply_voltage_min_v);
284 mpu9250_interface_debug_print("mpu9250: max supply voltage is %0.1fV.\n", info.supply_voltage_max_v);
285 mpu9250_interface_debug_print("mpu9250: max current is %0.2fmA.\n", info.max_current_ma);
286 mpu9250_interface_debug_print("mpu9250: max temperature is %0.1fC.\n", info.temperature_max);
287 mpu9250_interface_debug_print("mpu9250: min temperature is %0.1fC.\n", info.temperature_min);
288 }
289
290 /* start dmp tap orient motion test */
291 mpu9250_interface_debug_print("mpu9250: start dmp tap orient motion test.\n");
292
293 /* set the interface */
294 res = mpu9250_set_interface(&gs_handle, interface);
295 if (res != 0)
296 {
297 mpu9250_interface_debug_print("mpu9250: set interface failed.\n");
298
299 return 1;
300 }
301
302 /* set the addr pin */
303 res = mpu9250_set_addr_pin(&gs_handle, addr);
304 if (res != 0)
305 {
306 mpu9250_interface_debug_print("mpu9250: set addr pin failed.\n");
307
308 return 1;
309 }
310
311 /* init */
312 res = mpu9250_init(&gs_handle);
313 if (res != 0)
314 {
315 mpu9250_interface_debug_print("mpu9250: init failed.\n");
316
317 return 1;
318 }
319
320 /* delay 100 ms */
321 mpu9250_interface_delay_ms(100);
322
323 /* disable sleep */
324 res = mpu9250_set_sleep(&gs_handle, MPU9250_BOOL_FALSE);
325 if (res != 0)
326 {
327 mpu9250_interface_debug_print("mpu9250: set sleep failed.\n");
328 (void)mpu9250_deinit(&gs_handle);
329
330 return 1;
331 }
332
333 /* if spi interface, disable iic interface */
334 if (interface == MPU9250_INTERFACE_SPI)
335 {
336 /* disable iic */
337 res = mpu9250_set_disable_iic_slave(&gs_handle, MPU9250_BOOL_TRUE);
338 if (res != 0)
339 {
340 mpu9250_interface_debug_print("mpu9250: set disable iic slave failed.\n");
341 (void)mpu9250_deinit(&gs_handle);
342
343 return 1;
344 }
345 }
346
347 /* set fifo 1024kb */
348 res = mpu9250_set_fifo_1024kb(&gs_handle);
349 if (res != 0)
350 {
351 mpu9250_interface_debug_print("mpu9250: set fifo 1024kb failed.\n");
352 (void)mpu9250_deinit(&gs_handle);
353
354 return 1;
355 }
356
357 /* run the self test */
358 res = mpu9250_self_test(&gs_handle, gyro_offset_raw, accel_offset_raw);
359 if (res != 0)
360 {
361 mpu9250_interface_debug_print("mpu9250: self test failed.\n");
362 (void)mpu9250_deinit(&gs_handle);
363
364 return 1;
365 }
366
367 /* set pll */
368 res = mpu9250_set_clock_source(&gs_handle, MPU9250_CLOCK_SOURCE_PLL);
369 if (res != 0)
370 {
371 mpu9250_interface_debug_print("mpu9250: set clock source failed.\n");
372 (void)mpu9250_deinit(&gs_handle);
373
374 return 1;
375 }
376
377 /* set 50Hz */
378 res = mpu9250_set_sample_rate_divider(&gs_handle, (1000 / 50) - 1);
379 if (res != 0)
380 {
381 mpu9250_interface_debug_print("mpu9250: set sample rate divider failed.\n");
382 (void)mpu9250_deinit(&gs_handle);
383
384 return 1;
385 }
386
387 /* ±2g */
388 res = mpu9250_set_accelerometer_range(&gs_handle, MPU9250_ACCELEROMETER_RANGE_2G);
389 if (res != 0)
390 {
391 mpu9250_interface_debug_print("mpu9250: set accelerometer range failed.\n");
392 (void)mpu9250_deinit(&gs_handle);
393
394 return 1;
395 }
396
397 /* ±2000dps */
398 res = mpu9250_set_gyroscope_range(&gs_handle, MPU9250_GYROSCOPE_RANGE_2000DPS);
399 if (res != 0)
400 {
401 mpu9250_interface_debug_print("mpu9250: set gyroscope range failed.\n");
402 (void)mpu9250_deinit(&gs_handle);
403
404 return 1;
405 }
406
407 /* set low pass filter 3 */
408 res = mpu9250_set_low_pass_filter(&gs_handle, MPU9250_LOW_PASS_FILTER_3);
409 if (res != 0)
410 {
411 mpu9250_interface_debug_print("mpu9250: set low pass filter failed.\n");
412 (void)mpu9250_deinit(&gs_handle);
413
414 return 1;
415 }
416
417 /* enable temperature sensor */
418 res = mpu9250_set_ptat(&gs_handle, MPU9250_BOOL_TRUE);
419 if (res != 0)
420 {
421 mpu9250_interface_debug_print("mpu9250: set ptat failed.\n");
422 (void)mpu9250_deinit(&gs_handle);
423
424 return 1;
425 }
426
427 /* disable cycle wake up */
428 res = mpu9250_set_cycle_wake_up(&gs_handle, MPU9250_BOOL_FALSE);
429 if (res != 0)
430 {
431 mpu9250_interface_debug_print("mpu9250: set cycle wake up failed.\n");
432 (void)mpu9250_deinit(&gs_handle);
433
434 return 1;
435 }
436
437 /* enable acc x */
438 res = mpu9250_set_standby_mode(&gs_handle, MPU9250_SOURCE_ACC_X, MPU9250_BOOL_FALSE);
439 if (res != 0)
440 {
441 mpu9250_interface_debug_print("mpu9250: set standby mode failed.\n");
442 (void)mpu9250_deinit(&gs_handle);
443
444 return 1;
445 }
446
447 /* enable acc y */
448 res = mpu9250_set_standby_mode(&gs_handle, MPU9250_SOURCE_ACC_Y, MPU9250_BOOL_FALSE);
449 if (res != 0)
450 {
451 mpu9250_interface_debug_print("mpu9250: set standby mode failed.\n");
452 (void)mpu9250_deinit(&gs_handle);
453
454 return 1;
455 }
456
457 /* enable acc z */
458 res = mpu9250_set_standby_mode(&gs_handle, MPU9250_SOURCE_ACC_Z, MPU9250_BOOL_FALSE);
459 if (res != 0)
460 {
461 mpu9250_interface_debug_print("mpu9250: set standby mode failed.\n");
462 (void)mpu9250_deinit(&gs_handle);
463
464 return 1;
465 }
466
467 /* enable gyro x */
468 res = mpu9250_set_standby_mode(&gs_handle, MPU9250_SOURCE_GYRO_X, MPU9250_BOOL_FALSE);
469 if (res != 0)
470 {
471 mpu9250_interface_debug_print("mpu9250: set standby mode failed.\n");
472 (void)mpu9250_deinit(&gs_handle);
473
474 return 1;
475 }
476
477 /* enable gyro y */
478 res = mpu9250_set_standby_mode(&gs_handle, MPU9250_SOURCE_GYRO_Y, MPU9250_BOOL_FALSE);
479 if (res != 0)
480 {
481 mpu9250_interface_debug_print("mpu9250: set standby mode failed.\n");
482 (void)mpu9250_deinit(&gs_handle);
483
484 return 1;
485 }
486
487 /* enable gyro z */
488 res = mpu9250_set_standby_mode(&gs_handle, MPU9250_SOURCE_GYRO_Z, MPU9250_BOOL_FALSE);
489 if (res != 0)
490 {
491 mpu9250_interface_debug_print("mpu9250: set standby mode failed.\n");
492 (void)mpu9250_deinit(&gs_handle);
493
494 return 1;
495 }
496
497 /* disable gyroscope x test */
498 res = mpu9250_set_gyroscope_test(&gs_handle, MPU9250_AXIS_X, MPU9250_BOOL_FALSE);
499 if (res != 0)
500 {
501 mpu9250_interface_debug_print("mpu9250: set gyroscope test failed.\n");
502 (void)mpu9250_deinit(&gs_handle);
503
504 return 1;
505 }
506
507 /* disable gyroscope y test */
508 res = mpu9250_set_gyroscope_test(&gs_handle, MPU9250_AXIS_Y, MPU9250_BOOL_FALSE);
509 if (res != 0)
510 {
511 mpu9250_interface_debug_print("mpu9250: set gyroscope test failed.\n");
512 (void)mpu9250_deinit(&gs_handle);
513
514 return 1;
515 }
516
517 /* disable gyroscope z test */
518 res = mpu9250_set_gyroscope_test(&gs_handle, MPU9250_AXIS_Z, MPU9250_BOOL_FALSE);
519 if (res != 0)
520 {
521 mpu9250_interface_debug_print("mpu9250: set gyroscope test failed.\n");
522 (void)mpu9250_deinit(&gs_handle);
523
524 return 1;
525 }
526
527 /* disable accelerometer x test */
528 res = mpu9250_set_accelerometer_test(&gs_handle, MPU9250_AXIS_X, MPU9250_BOOL_FALSE);
529 if (res != 0)
530 {
531 mpu9250_interface_debug_print("mpu9250: set accelerometer test failed.\n");
532 (void)mpu9250_deinit(&gs_handle);
533
534 return 1;
535 }
536
537 /* disable accelerometer y test */
538 res = mpu9250_set_accelerometer_test(&gs_handle, MPU9250_AXIS_Y, MPU9250_BOOL_FALSE);
539 if (res != 0)
540 {
541 mpu9250_interface_debug_print("mpu9250: set accelerometer test failed.\n");
542 (void)mpu9250_deinit(&gs_handle);
543
544 return 1;
545 }
546
547 /* disable accelerometer z test */
548 res = mpu9250_set_accelerometer_test(&gs_handle, MPU9250_AXIS_Z, MPU9250_BOOL_FALSE);
549 if (res != 0)
550 {
551 mpu9250_interface_debug_print("mpu9250: set accelerometer test failed.\n");
552 (void)mpu9250_deinit(&gs_handle);
553
554 return 1;
555 }
556
557 /* disable temp fifo */
558 res = mpu9250_set_fifo_enable(&gs_handle, MPU9250_FIFO_TEMP, MPU9250_BOOL_FALSE);
559 if (res != 0)
560 {
561 mpu9250_interface_debug_print("mpu9250: set fifo enable failed.\n");
562 (void)mpu9250_deinit(&gs_handle);
563
564 return 1;
565 }
566
567 /* disable xg fifo */
568 res = mpu9250_set_fifo_enable(&gs_handle, MPU9250_FIFO_XG, MPU9250_BOOL_FALSE);
569 if (res != 0)
570 {
571 mpu9250_interface_debug_print("mpu9250: set fifo enable failed.\n");
572 (void)mpu9250_deinit(&gs_handle);
573
574 return 1;
575 }
576
577 /* disable yg fifo */
578 res = mpu9250_set_fifo_enable(&gs_handle, MPU9250_FIFO_YG, MPU9250_BOOL_FALSE);
579 if (res != 0)
580 {
581 mpu9250_interface_debug_print("mpu9250: set fifo enable failed.\n");
582 (void)mpu9250_deinit(&gs_handle);
583
584 return 1;
585 }
586
587 /* disable zg fifo */
588 res = mpu9250_set_fifo_enable(&gs_handle, MPU9250_FIFO_ZG, MPU9250_BOOL_FALSE);
589 if (res != 0)
590 {
591 mpu9250_interface_debug_print("mpu9250: set fifo enable failed.\n");
592 (void)mpu9250_deinit(&gs_handle);
593
594 return 1;
595 }
596
597 /* disable accel fifo */
598 res = mpu9250_set_fifo_enable(&gs_handle, MPU9250_FIFO_ACCEL, MPU9250_BOOL_FALSE);
599 if (res != 0)
600 {
601 mpu9250_interface_debug_print("mpu9250: set fifo enable failed.\n");
602 (void)mpu9250_deinit(&gs_handle);
603
604 return 1;
605 }
606
607 /* enable fifo */
608 res = mpu9250_set_fifo(&gs_handle, MPU9250_BOOL_TRUE);
609 if (res != 0)
610 {
611 mpu9250_interface_debug_print("mpu9250: set fifo failed.\n");
612 (void)mpu9250_deinit(&gs_handle);
613
614 return 1;
615 }
616
617 /* set interrupt level low */
618 res = mpu9250_set_interrupt_level(&gs_handle, MPU9250_PIN_LEVEL_LOW);
619 if (res != 0)
620 {
621 mpu9250_interface_debug_print("mpu9250: set interrupt level failed.\n");
622 (void)mpu9250_deinit(&gs_handle);
623
624 return 1;
625 }
626
627 /* push-pull */
628 res = mpu9250_set_interrupt_pin_type(&gs_handle, MPU9250_PIN_TYPE_PUSH_PULL);
629 if (res != 0)
630 {
631 mpu9250_interface_debug_print("mpu9250: set interrupt pin type failed.\n");
632 (void)mpu9250_deinit(&gs_handle);
633
634 return 1;
635 }
636
637 /* set 200mg */
638 res = mpu9250_motion_threshold_convert_to_register(&gs_handle, 200.0f, &reg);
639 if (res != 0)
640 {
641 mpu9250_interface_debug_print("mpu9250: motion threshold convert to register failed.\n");
642 (void)mpu9250_deinit(&gs_handle);
643
644 return 1;
645 }
646
647 /* set the motion threshold */
648 res = mpu9250_set_motion_threshold(&gs_handle, reg);
649 if (res != 0)
650 {
651 mpu9250_interface_debug_print("mpu9250: set motion threshold failed.\n");
652 (void)mpu9250_deinit(&gs_handle);
653
654 return 1;
655 }
656
657 /* enable motion */
658 res = mpu9250_set_interrupt(&gs_handle, MPU9250_INTERRUPT_MOTION, MPU9250_BOOL_TRUE);
659 if (res != 0)
660 {
661 mpu9250_interface_debug_print("mpu9250: set interrupt failed.\n");
662 (void)mpu9250_deinit(&gs_handle);
663
664 return 1;
665 }
666
667 /* enable fifo overflow */
668 res = mpu9250_set_interrupt(&gs_handle, MPU9250_INTERRUPT_FIFO_OVERFLOW, MPU9250_BOOL_TRUE);
669 if (res != 0)
670 {
671 mpu9250_interface_debug_print("mpu9250: set interrupt failed.\n");
672 (void)mpu9250_deinit(&gs_handle);
673
674 return 1;
675 }
676
677 /* disable dmp interrupt */
678 res = mpu9250_set_interrupt(&gs_handle, MPU9250_INTERRUPT_DMP, MPU9250_BOOL_FALSE);
679 if (res != 0)
680 {
681 mpu9250_interface_debug_print("mpu9250: set interrupt failed.\n");
682 (void)mpu9250_deinit(&gs_handle);
683
684 return 1;
685 }
686
687 /* disable fsync int */
688 res = mpu9250_set_interrupt(&gs_handle, MPU9250_INTERRUPT_FSYNC_INT, MPU9250_BOOL_FALSE);
689 if (res != 0)
690 {
691 mpu9250_interface_debug_print("mpu9250: set interrupt failed.\n");
692 (void)mpu9250_deinit(&gs_handle);
693
694 return 1;
695 }
696
697 /* disable data ready */
698 res = mpu9250_set_interrupt(&gs_handle, MPU9250_INTERRUPT_DATA_READY, MPU9250_BOOL_FALSE);
699 if (res != 0)
700 {
701 mpu9250_interface_debug_print("mpu9250: set interrupt failed.\n");
702 (void)mpu9250_deinit(&gs_handle);
703
704 return 1;
705 }
706
707 /* enable latch */
708 res = mpu9250_set_interrupt_latch(&gs_handle, MPU9250_BOOL_TRUE);
709 if (res != 0)
710 {
711 mpu9250_interface_debug_print("mpu9250: set interrupt latch failed.\n");
712 (void)mpu9250_deinit(&gs_handle);
713
714 return 1;
715 }
716
717 /* enable interrupt read clear */
718 res = mpu9250_set_interrupt_read_clear(&gs_handle, MPU9250_BOOL_TRUE);
719 if (res != 0)
720 {
721 mpu9250_interface_debug_print("mpu9250: set interrupt read clear failed.\n");
722 (void)mpu9250_deinit(&gs_handle);
723
724 return 1;
725 }
726
727 /* disable sync input */
728 res = mpu9250_set_extern_sync(&gs_handle, MPU9250_EXTERN_SYNC_INPUT_DISABLED);
729 if (res != 0)
730 {
731 mpu9250_interface_debug_print("mpu9250: set extern sync failed.\n");
732 (void)mpu9250_deinit(&gs_handle);
733
734 return 1;
735 }
736
737 /* disable fsync interrupt */
738 res = mpu9250_set_fsync_interrupt(&gs_handle, MPU9250_BOOL_FALSE);
739 if (res != 0)
740 {
741 mpu9250_interface_debug_print("mpu9250: set fsync interrupt failed.\n");
742 (void)mpu9250_deinit(&gs_handle);
743
744 return 1;
745 }
746
747 /* fsync interrupt level low */
748 res = mpu9250_set_fsync_interrupt_level(&gs_handle, MPU9250_PIN_LEVEL_LOW);
749 if (res != 0)
750 {
751 mpu9250_interface_debug_print("mpu9250: set fsync interrupt level failed.\n");
752 (void)mpu9250_deinit(&gs_handle);
753
754 return 1;
755 }
756
757 /* disable iic master */
758 res = mpu9250_set_iic_master(&gs_handle, MPU9250_BOOL_FALSE);
759 if (res != 0)
760 {
761 mpu9250_interface_debug_print("mpu9250: set iic master failed.\n");
762 (void)mpu9250_deinit(&gs_handle);
763
764 return 1;
765 }
766
767 /* disable iic bypass */
768 res = mpu9250_set_iic_bypass(&gs_handle, MPU9250_BOOL_FALSE);
769 if (res != 0)
770 {
771 mpu9250_interface_debug_print("mpu9250: set iic bypass failed.\n");
772 (void)mpu9250_deinit(&gs_handle);
773
774 return 1;
775 }
776
777 /* disable gyro standby */
778 res = mpu9250_set_gyro_standby(&gs_handle, MPU9250_BOOL_FALSE);
779 if (res != 0)
780 {
781 mpu9250_interface_debug_print("mpu9250: set gyro standby failed.\n");
782 (void)mpu9250_deinit(&gs_handle);
783
784 return 1;
785 }
786
787 /* set the fifo normal mode */
788 res = mpu9250_set_fifo_mode(&gs_handle, MPU9250_FIFO_MODE_NORMAL);
789 if (res != 0)
790 {
791 mpu9250_interface_debug_print("mpu9250: set fifo mode failed.\n");
792 (void)mpu9250_deinit(&gs_handle);
793
794 return 1;
795 }
796
797 /* set gyroscope choice 0 */
798 res = mpu9250_set_gyroscope_choice(&gs_handle, 0);
799 if (res != 0)
800 {
801 mpu9250_interface_debug_print("mpu9250: set gyroscope choice failed.\n");
802 (void)mpu9250_deinit(&gs_handle);
803
804 return 1;
805 }
806
807 /* set low pass filter 3 */
808 res = mpu9250_set_low_pass_filter(&gs_handle, MPU9250_LOW_PASS_FILTER_3);
809 if (res != 0)
810 {
811 mpu9250_interface_debug_print("mpu9250: set low pass filter failed.\n");
812 (void)mpu9250_deinit(&gs_handle);
813
814 return 1;
815 }
816
817 /* set accelerometer choice 0 */
818 res = mpu9250_set_accelerometer_choice(&gs_handle, 0);
819 if (res != 0)
820 {
821 mpu9250_interface_debug_print("mpu9250: set accelerometer choice failed.\n");
822 (void)mpu9250_deinit(&gs_handle);
823
824 return 1;
825 }
826
827 /* set accelerometer low pass filter 3 */
828 res = mpu9250_set_accelerometer_low_pass_filter(&gs_handle, MPU9250_ACCELEROMETER_LOW_PASS_FILTER_3);
829 if (res != 0)
830 {
831 mpu9250_interface_debug_print("mpu9250: set accelerometer low pass filter failed.\n");
832 (void)mpu9250_deinit(&gs_handle);
833
834 return 1;
835 }
836
837 /* set low power accel output rate 62.5Hz */
838 res = mpu9250_set_low_power_accel_output_rate(&gs_handle, MPU9250_LOW_POWER_ACCEL_OUTPUT_RATE_62P50);
839 if (res != 0)
840 {
841 mpu9250_interface_debug_print("mpu9250: set low power accel output rate failed.\n");
842 (void)mpu9250_deinit(&gs_handle);
843
844 return 1;
845 }
846
847 /* enable wake on motion */
848 res = mpu9250_set_wake_on_motion(&gs_handle, MPU9250_BOOL_TRUE);
849 if (res != 0)
850 {
851 mpu9250_interface_debug_print("mpu9250: set wake on motion failed.\n");
852 (void)mpu9250_deinit(&gs_handle);
853
854 return 1;
855 }
856
857 /* enable accel compare with previous sample */
858 res = mpu9250_set_accel_compare_with_previous_sample(&gs_handle, MPU9250_BOOL_TRUE);
859 if (res != 0)
860 {
861 mpu9250_interface_debug_print("mpu9250: set accel compare with previous sample failed.\n");
862 (void)mpu9250_deinit(&gs_handle);
863
864 return 1;
865 }
866
867 /* load dmp firmware */
868 mpu9250_interface_debug_print("mpu9250: load dmp firmware.\n");
869
870 /* dmp load firmware */
871 res = mpu9250_dmp_load_firmware(&gs_handle);
872 if (res != 0)
873 {
874 mpu9250_interface_debug_print("mpu9250: dmp load firmware failed.\n");
875 (void)mpu9250_deinit(&gs_handle);
876
877 return 1;
878 }
879
880 /* load dmp firmware successful */
881 mpu9250_interface_debug_print("mpu9250: load dmp firmware successful .\n");
882
883 /* mpu9250_dmp_set_pedometer_walk_time/mpu9250_dmp_get_pedometer_walk_time test */
884 mpu9250_interface_debug_print("mpu9250: mpu9250_dmp_set_pedometer_walk_time/mpu9250_dmp_get_pedometer_walk_time test.\n");
885
886 ms = 200;
887 res = mpu9250_dmp_set_pedometer_walk_time(&gs_handle, ms);
888 if (res != 0)
889 {
890 mpu9250_interface_debug_print("mpu9250: dmp set pedometer walk time failed.\n");
891 (void)mpu9250_deinit(&gs_handle);
892
893 return 1;
894 }
895 mpu9250_interface_debug_print("mpu9250: dmp set pedometer walk time %d ms.\n", ms);
896 res = mpu9250_dmp_get_pedometer_walk_time(&gs_handle, &ms_check);
897 if (res != 0)
898 {
899 mpu9250_interface_debug_print("mpu9250: dmp get pedometer walk time failed.\n");
900 (void)mpu9250_deinit(&gs_handle);
901
902 return 1;
903 }
904 mpu9250_interface_debug_print("mpu9250: check pedometer walk time %s.\n", ms_check == ms ? "ok" : "error");
905
906 /* mpu9250_dmp_set_pedometer_step_count/mpu9250_dmp_get_pedometer_step_count test */
907 mpu9250_interface_debug_print("mpu9250: mpu9250_dmp_set_pedometer_step_count/mpu9250_dmp_get_pedometer_step_count test.\n");
908
909 cnt = rand() % 1000;
910 res = mpu9250_dmp_set_pedometer_step_count(&gs_handle, cnt);
911 if (res != 0)
912 {
913 mpu9250_interface_debug_print("mpu9250: dmp set pedometer step count failed.\n");
914 (void)mpu9250_deinit(&gs_handle);
915
916 return 1;
917 }
918 mpu9250_interface_debug_print("mpu9250: dmp set pedometer step count %d.\n", cnt);
919 res = mpu9250_dmp_get_pedometer_step_count(&gs_handle, &cnt_check);
920 if (res != 0)
921 {
922 mpu9250_interface_debug_print("mpu9250: dmp get pedometer step count failed.\n");
923 (void)mpu9250_deinit(&gs_handle);
924
925 return 1;
926 }
927 mpu9250_interface_debug_print("mpu9250: check pedometer step count %s.\n", cnt_check == cnt ? "ok" : "error");
928
929 /* mpu9250_dmp_set_shake_reject_timeout/mpu9250_dmp_get_shake_reject_timeout test */
930 mpu9250_interface_debug_print("mpu9250: mpu9250_dmp_set_shake_reject_timeout/mpu9250_dmp_get_shake_reject_timeout test.\n");
931
932 m = 10;
933 res = mpu9250_dmp_set_shake_reject_timeout(&gs_handle, m);
934 if (res != 0)
935 {
936 mpu9250_interface_debug_print("mpu9250: dmp set shake reject timeout failed.\n");
937 (void)mpu9250_deinit(&gs_handle);
938
939 return 1;
940 }
941 mpu9250_interface_debug_print("mpu9250: dmp set shake reject timeout %d ms.\n", m);
942 res = mpu9250_dmp_get_shake_reject_timeout(&gs_handle, &m_check);
943 if (res != 0)
944 {
945 mpu9250_interface_debug_print("mpu9250: dmp get shake reject timeout failed.\n");
946 (void)mpu9250_deinit(&gs_handle);
947
948 return 1;
949 }
950 mpu9250_interface_debug_print("mpu9250: check shake reject timeout %s.\n", m_check == m ? "ok" : "error");
951
952 /* mpu9250_dmp_set_shake_reject_time/mpu9250_dmp_get_shake_reject_time test */
953 mpu9250_interface_debug_print("mpu9250: mpu9250_dmp_set_shake_reject_time/mpu9250_dmp_get_shake_reject_time test.\n");
954
955 m = 40;
956 res = mpu9250_dmp_set_shake_reject_time(&gs_handle, m);
957 if (res != 0)
958 {
959 mpu9250_interface_debug_print("mpu9250: dmp set shake reject time failed.\n");
960 (void)mpu9250_deinit(&gs_handle);
961
962 return 1;
963 }
964 mpu9250_interface_debug_print("mpu9250: dmp set shake reject time %d ms.\n", m);
965 res = mpu9250_dmp_get_shake_reject_time(&gs_handle, &m_check);
966 if (res != 0)
967 {
968 mpu9250_interface_debug_print("mpu9250: dmp get shake reject time failed.\n");
969 (void)mpu9250_deinit(&gs_handle);
970
971 return 1;
972 }
973 mpu9250_interface_debug_print("mpu9250: check shake reject time %s.\n", m_check == m ? "ok" : "error");
974
975 /* mpu9250_dmp_set_shake_reject_thresh/mpu9250_dmp_get_shake_reject_thresh test */
976 mpu9250_interface_debug_print("mpu9250: mpu9250_dmp_set_shake_reject_thresh/mpu9250_dmp_get_shake_reject_thresh test.\n");
977
978 m = 200;
979 res = mpu9250_dmp_set_shake_reject_thresh(&gs_handle, m);
980 if (res != 0)
981 {
982 mpu9250_interface_debug_print("mpu9250: dmp set shake reject thresh failed.\n");
983 (void)mpu9250_deinit(&gs_handle);
984
985 return 1;
986 }
987 mpu9250_interface_debug_print("mpu9250: set shake reject thresh %d dps.\n", m);
988 res = mpu9250_dmp_get_shake_reject_thresh(&gs_handle, &m_check);
989 if (res != 0)
990 {
991 mpu9250_interface_debug_print("mpu9250: dmp get shake reject thresh failed.\n");
992 (void)mpu9250_deinit(&gs_handle);
993
994 return 1;
995 }
996 mpu9250_interface_debug_print("mpu9250: check shake reject thresh %s.\n", m_check == m ? "ok" : "error");
997
998 /* mpu9250_dmp_set_tap_time_multi/mpu9250_dmp_get_tap_time_multi test */
999 mpu9250_interface_debug_print("mpu9250: mpu9250_dmp_set_tap_time_multi/mpu9250_dmp_get_tap_time_multi test.\n");
1000
1001 m = 200;
1002 res = mpu9250_dmp_set_tap_time_multi(&gs_handle, m);
1003 if (res != 0)
1004 {
1005 mpu9250_interface_debug_print("mpu9250: dmp set tap time multi failed.\n");
1006 (void)mpu9250_deinit(&gs_handle);
1007
1008 return 1;
1009 }
1010 mpu9250_interface_debug_print("mpu9250: dmp set tap time multi %d ms.\n", m);
1011 res = mpu9250_dmp_get_tap_time_multi(&gs_handle, &m_check);
1012 if (res != 0)
1013 {
1014 mpu9250_interface_debug_print("mpu9250: dmp get tap time multi failed.\n");
1015 (void)mpu9250_deinit(&gs_handle);
1016
1017 return 1;
1018 }
1019 mpu9250_interface_debug_print("mpu9250: check tap time multi %s.\n", m_check == m ? "ok" : "error");
1020
1021 /* mpu9250_dmp_set_tap_time/mpu9250_dmp_get_tap_time test */
1022 mpu9250_interface_debug_print("mpu9250: mpu9250_dmp_set_tap_time/mpu9250_dmp_get_tap_time test.\n");
1023
1024 m = 100;
1025 res = mpu9250_dmp_set_tap_time(&gs_handle, m);
1026 if (res != 0)
1027 {
1028 mpu9250_interface_debug_print("mpu9250: dmp set tap time failed.\n");
1029 (void)mpu9250_deinit(&gs_handle);
1030
1031 return 1;
1032 }
1033 mpu9250_interface_debug_print("mpu9250: dmp set tap time %d ms.\n", m);
1034 res = mpu9250_dmp_get_tap_time(&gs_handle, &m_check);
1035 if (res != 0)
1036 {
1037 mpu9250_interface_debug_print("mpu9250: dmp get tap time failed.\n");
1038 (void)mpu9250_deinit(&gs_handle);
1039
1040 return 1;
1041 }
1042 mpu9250_interface_debug_print("mpu9250: check tap time %s.\n", m_check == m ? "ok" : "error");
1043
1044 /* mpu9250_dmp_set_min_tap_count/mpu9250_dmp_get_min_tap_count test */
1045 mpu9250_interface_debug_print("mpu9250: mpu9250_dmp_set_min_tap_count/mpu9250_dmp_get_min_tap_count test.\n");
1046
1047 c = 1;
1048 res = mpu9250_dmp_set_min_tap_count(&gs_handle, c);
1049 if (res != 0)
1050 {
1051 mpu9250_interface_debug_print("mpu9250: dmp set min tap count failed.\n");
1052 (void)mpu9250_deinit(&gs_handle);
1053
1054 return 1;
1055 }
1056 mpu9250_interface_debug_print("mpu9250: dmp set min tap count %d.\n", c);
1057 res = mpu9250_dmp_get_min_tap_count(&gs_handle, &c_check);
1058 if (res != 0)
1059 {
1060 mpu9250_interface_debug_print("mpu9250: dmp get min tap count failed.\n");
1061 (void)mpu9250_deinit(&gs_handle);
1062
1063 return 1;
1064 }
1065 mpu9250_interface_debug_print("mpu9250: check min tap count %s.\n", c_check == c ? "ok" : "error");
1066
1067 /* mpu9250_dmp_set_tap_axes/mpu9250_dmp_get_tap_axes test */
1068 mpu9250_interface_debug_print("mpu9250: mpu9250_dmp_set_tap_axes/mpu9250_dmp_get_tap_axes test.\n");
1069
1070 /* disable axis x */
1071 res = mpu9250_dmp_set_tap_axes(&gs_handle, MPU9250_AXIS_X, MPU9250_BOOL_FALSE);
1072 if (res != 0)
1073 {
1074 mpu9250_interface_debug_print("mpu9250: dmp set tap axes failed.\n");
1075 (void)mpu9250_deinit(&gs_handle);
1076
1077 return 1;
1078 }
1079 mpu9250_interface_debug_print("mpu9250: disable tap axes x.\n");
1080 res = mpu9250_dmp_get_tap_axes(&gs_handle, MPU9250_AXIS_X, &enable);
1081 if (res != 0)
1082 {
1083 mpu9250_interface_debug_print("mpu9250: dmp get tap axes failed.\n");
1084 (void)mpu9250_deinit(&gs_handle);
1085
1086 return 1;
1087 }
1088 mpu9250_interface_debug_print("mpu9250: check tap axes %s.\n", enable == MPU9250_BOOL_FALSE ? "ok" : "error");
1089
1090 /* enable axis x */
1091 res = mpu9250_dmp_set_tap_axes(&gs_handle, MPU9250_AXIS_X, MPU9250_BOOL_TRUE);
1092 if (res != 0)
1093 {
1094 mpu9250_interface_debug_print("mpu9250: dmp set tap axes failed.\n");
1095 (void)mpu9250_deinit(&gs_handle);
1096
1097 return 1;
1098 }
1099 mpu9250_interface_debug_print("mpu9250: enable tap axes x.\n");
1100 res = mpu9250_dmp_get_tap_axes(&gs_handle, MPU9250_AXIS_X, &enable);
1101 if (res != 0)
1102 {
1103 mpu9250_interface_debug_print("mpu9250: dmp get tap axes failed.\n");
1104 (void)mpu9250_deinit(&gs_handle);
1105
1106 return 1;
1107 }
1108 mpu9250_interface_debug_print("mpu9250: check tap axes %s.\n", enable == MPU9250_BOOL_TRUE ? "ok" : "error");
1109
1110 /* disable axis y */
1111 res = mpu9250_dmp_set_tap_axes(&gs_handle, MPU9250_AXIS_Y, MPU9250_BOOL_FALSE);
1112 if (res != 0)
1113 {
1114 mpu9250_interface_debug_print("mpu9250: dmp set tap axes failed.\n");
1115 (void)mpu9250_deinit(&gs_handle);
1116
1117 return 1;
1118 }
1119 mpu9250_interface_debug_print("mpu9250: disable tap axes y.\n");
1120 res = mpu9250_dmp_get_tap_axes(&gs_handle, MPU9250_AXIS_Y, &enable);
1121 if (res != 0)
1122 {
1123 mpu9250_interface_debug_print("mpu9250: dmp get tap axes failed.\n");
1124 (void)mpu9250_deinit(&gs_handle);
1125
1126 return 1;
1127 }
1128 mpu9250_interface_debug_print("mpu9250: check tap axes %s.\n", enable == MPU9250_BOOL_FALSE ? "ok" : "error");
1129
1130 /* enable axis y */
1131 res = mpu9250_dmp_set_tap_axes(&gs_handle, MPU9250_AXIS_Y, MPU9250_BOOL_TRUE);
1132 if (res != 0)
1133 {
1134 mpu9250_interface_debug_print("mpu9250: dmp set tap axes failed.\n");
1135 (void)mpu9250_deinit(&gs_handle);
1136
1137 return 1;
1138 }
1139 mpu9250_interface_debug_print("mpu9250: enable tap axes y.\n");
1140 res = mpu9250_dmp_get_tap_axes(&gs_handle, MPU9250_AXIS_Y, &enable);
1141 if (res != 0)
1142 {
1143 mpu9250_interface_debug_print("mpu9250: dmp get tap axes failed.\n");
1144 (void)mpu9250_deinit(&gs_handle);
1145
1146 return 1;
1147 }
1148 mpu9250_interface_debug_print("mpu9250: check tap axes %s.\n", enable == MPU9250_BOOL_TRUE ? "ok" : "error");
1149
1150 /* disable axis z */
1151 res = mpu9250_dmp_set_tap_axes(&gs_handle, MPU9250_AXIS_Z, MPU9250_BOOL_FALSE);
1152 if (res != 0)
1153 {
1154 mpu9250_interface_debug_print("mpu9250: dmp set tap axes failed.\n");
1155 (void)mpu9250_deinit(&gs_handle);
1156
1157 return 1;
1158 }
1159 mpu9250_interface_debug_print("mpu9250: disable tap axes z.\n");
1160 res = mpu9250_dmp_get_tap_axes(&gs_handle, MPU9250_AXIS_Z, &enable);
1161 if (res != 0)
1162 {
1163 mpu9250_interface_debug_print("mpu9250: dmp get tap axes failed.\n");
1164 (void)mpu9250_deinit(&gs_handle);
1165
1166 return 1;
1167 }
1168 mpu9250_interface_debug_print("mpu9250: check tap axes %s.\n", enable == MPU9250_BOOL_FALSE ? "ok" : "error");
1169
1170 /* enable axis z */
1171 res = mpu9250_dmp_set_tap_axes(&gs_handle, MPU9250_AXIS_Z, MPU9250_BOOL_TRUE);
1172 if (res != 0)
1173 {
1174 mpu9250_interface_debug_print("mpu9250: dmp set tap axes failed.\n");
1175 (void)mpu9250_deinit(&gs_handle);
1176
1177 return 1;
1178 }
1179 mpu9250_interface_debug_print("mpu9250: enable tap axes z.\n");
1180 res = mpu9250_dmp_get_tap_axes(&gs_handle, MPU9250_AXIS_Z, &enable);
1181 if (res != 0)
1182 {
1183 mpu9250_interface_debug_print("mpu9250: dmp get tap axes failed.\n");
1184 (void)mpu9250_deinit(&gs_handle);
1185
1186 return 1;
1187 }
1188 mpu9250_interface_debug_print("mpu9250: check tap axes %s.\n", enable == MPU9250_BOOL_TRUE ? "ok" : "error");
1189
1190 /* mpu9250_dmp_set_tap_thresh/mpu9250_dmp_get_tap_thresh test */
1191 mpu9250_interface_debug_print("mpu9250: mpu9250_dmp_set_tap_thresh/mpu9250_dmp_get_tap_thresh test.\n");
1192
1193 /* set tap thresh x */
1194 m = 250;
1195 res = mpu9250_dmp_set_tap_thresh(&gs_handle, MPU9250_AXIS_X, m);
1196 if (res != 0)
1197 {
1198 mpu9250_interface_debug_print("mpu9250: dmp set tap thresh failed.\n");
1199 (void)mpu9250_deinit(&gs_handle);
1200
1201 return 1;
1202 }
1203 mpu9250_interface_debug_print("mpu9250: dmp set tap thresh x %d mg/ms.\n", m);
1204 res = mpu9250_dmp_get_tap_thresh(&gs_handle, MPU9250_AXIS_X, &m_check);
1205 if (res != 0)
1206 {
1207 mpu9250_interface_debug_print("mpu9250: dmp get tap thresh failed.\n");
1208 (void)mpu9250_deinit(&gs_handle);
1209
1210 return 1;
1211 }
1212 mpu9250_interface_debug_print("mpu9250: check tap thresh %s.\n", m_check == m ? "ok" : "error");
1213
1214 /* set tap thresh y */
1215 m = 250;
1216 res = mpu9250_dmp_set_tap_thresh(&gs_handle, MPU9250_AXIS_Y, m);
1217 if (res != 0)
1218 {
1219 mpu9250_interface_debug_print("mpu9250: dmp set tap thresh failed.\n");
1220 (void)mpu9250_deinit(&gs_handle);
1221
1222 return 1;
1223 }
1224 mpu9250_interface_debug_print("mpu9250: dmp set tap thresh y %d mg/ms.\n", m);
1225 res = mpu9250_dmp_get_tap_thresh(&gs_handle, MPU9250_AXIS_Y, &m_check);
1226 if (res != 0)
1227 {
1228 mpu9250_interface_debug_print("mpu9250: dmp get tap thresh failed.\n");
1229 (void)mpu9250_deinit(&gs_handle);
1230
1231 return 1;
1232 }
1233 mpu9250_interface_debug_print("mpu9250: check tap thresh %s.\n", m_check == m ? "ok" : "error");
1234
1235 /* set tap thresh z */
1236 m = 250;
1237 res = mpu9250_dmp_set_tap_thresh(&gs_handle, MPU9250_AXIS_Z, m);
1238 if (res != 0)
1239 {
1240 mpu9250_interface_debug_print("mpu9250: dmp set tap thresh failed.\n");
1241 (void)mpu9250_deinit(&gs_handle);
1242
1243 return 1;
1244 }
1245 mpu9250_interface_debug_print("mpu9250: dmp set tap thresh z %d mg/ms.\n", m);
1246 res = mpu9250_dmp_get_tap_thresh(&gs_handle, MPU9250_AXIS_Z, &m_check);
1247 if (res != 0)
1248 {
1249 mpu9250_interface_debug_print("mpu9250: dmp get tap thresh failed.\n");
1250 (void)mpu9250_deinit(&gs_handle);
1251
1252 return 1;
1253 }
1254 mpu9250_interface_debug_print("mpu9250: check tap thresh %s.\n", m_check == m ? "ok" : "error");
1255
1256 /* mpu9250_dmp_set_fifo_rate/mpu9250_dmp_get_fifo_rate test */
1257 mpu9250_interface_debug_print("mpu9250: mpu9250_dmp_set_fifo_rate/mpu9250_dmp_get_fifo_rate test.\n");
1258
1259 m = 50;
1260 res = mpu9250_dmp_set_fifo_rate(&gs_handle, m);
1261 if (res != 0)
1262 {
1263 mpu9250_interface_debug_print("mpu9250: dmp set fifo rate failed.\n");
1264 (void)mpu9250_deinit(&gs_handle);
1265
1266 return 1;
1267 }
1268 mpu9250_interface_debug_print("mpu9250: dmp set fifo rate %dHz.\n", m);
1269 res = mpu9250_dmp_get_fifo_rate(&gs_handle, &m_check);
1270 if (res != 0)
1271 {
1272 mpu9250_interface_debug_print("mpu9250: dmp get fifo rate failed.\n");
1273 (void)mpu9250_deinit(&gs_handle);
1274
1275 return 1;
1276 }
1277 mpu9250_interface_debug_print("mpu9250: check fifo rate %s.\n", m_check == m ? "ok" : "error");
1278
1279 /* mpu9250_dmp_set_gyro_calibrate test */
1280 mpu9250_interface_debug_print("mpu9250: mpu9250_dmp_set_gyro_calibrate test.\n");
1281
1282 /* enable gyro calibrate */
1283 res = mpu9250_dmp_set_gyro_calibrate(&gs_handle, MPU9250_BOOL_TRUE);
1284 if (res != 0)
1285 {
1286 mpu9250_interface_debug_print("mpu9250: dmp set gyro calibrate failed.\n");
1287 (void)mpu9250_deinit(&gs_handle);
1288
1289 return 1;
1290 }
1291 mpu9250_interface_debug_print("mpu9250: enable gyro calibrate.\n");
1292
1293 /* disable gyro calibrate */
1294 res = mpu9250_dmp_set_gyro_calibrate(&gs_handle, MPU9250_BOOL_FALSE);
1295 if (res != 0)
1296 {
1297 mpu9250_interface_debug_print("mpu9250: dmp set gyro calibrate failed.\n");
1298 (void)mpu9250_deinit(&gs_handle);
1299
1300 return 1;
1301 }
1302 mpu9250_interface_debug_print("mpu9250: disable gyro calibrate.\n");
1303
1304 /* mpu9250_dmp_set_3x_quaternion test */
1305 mpu9250_interface_debug_print("mpu9250: mpu9250_dmp_set_3x_quaternion test.\n");
1306
1307 /* enable 3x quaternion */
1308 res = mpu9250_dmp_set_3x_quaternion(&gs_handle, MPU9250_BOOL_TRUE);
1309 if (res != 0)
1310 {
1311 mpu9250_interface_debug_print("mpu9250: dmp set 3x quaternion failed.\n");
1312 (void)mpu9250_deinit(&gs_handle);
1313
1314 return 1;
1315 }
1316 mpu9250_interface_debug_print("mpu9250: enable 3x quaternion.\n");
1317
1318 /* disable 3x quaternion */
1319 res = mpu9250_dmp_set_3x_quaternion(&gs_handle, MPU9250_BOOL_FALSE);
1320 if (res != 0)
1321 {
1322 mpu9250_interface_debug_print("mpu9250: dmp set 3x quaternion failed.\n");
1323 (void)mpu9250_deinit(&gs_handle);
1324
1325 return 1;
1326 }
1327 mpu9250_interface_debug_print("mpu9250: disable 3x quaternion.\n");
1328
1329 /* mpu9250_dmp_set_6x_quaternion test */
1330 mpu9250_interface_debug_print("mpu9250: mpu9250_dmp_set_6x_quaternion test.\n");
1331
1332 /* enable 6x quaternion */
1333 res = mpu9250_dmp_set_6x_quaternion(&gs_handle, MPU9250_BOOL_TRUE);
1334 if (res != 0)
1335 {
1336 mpu9250_interface_debug_print("mpu9250: dmp set 6x quaternion failed.\n");
1337 (void)mpu9250_deinit(&gs_handle);
1338
1339 return 1;
1340 }
1341 mpu9250_interface_debug_print("mpu9250: enable 6x quaternion.\n");
1342
1343 /* disable 6x quaternion */
1344 res = mpu9250_dmp_set_6x_quaternion(&gs_handle, MPU9250_BOOL_FALSE);
1345 if (res != 0)
1346 {
1347 mpu9250_interface_debug_print("mpu9250: dmp set 6x quaternion failed.\n");
1348 (void)mpu9250_deinit(&gs_handle);
1349
1350 return 1;
1351 }
1352 mpu9250_interface_debug_print("mpu9250: disable 6x quaternion.\n");
1353
1354 /* mpu9250_dmp_set_interrupt_mode test */
1355 mpu9250_interface_debug_print("mpu9250: mpu9250_dmp_set_interrupt_mode test.\n");
1356
1357 /* gesture mode */
1358 res = mpu9250_dmp_set_interrupt_mode(&gs_handle, MPU9250_DMP_INTERRUPT_MODE_GESTURE);
1359 if (res != 0)
1360 {
1361 mpu9250_interface_debug_print("mpu9250: dmp set interrupt mode failed.\n");
1362 (void)mpu9250_deinit(&gs_handle);
1363
1364 return 1;
1365 }
1366 mpu9250_interface_debug_print("mpu9250: dmp set gesture interrupt mode.\n");
1367
1368 /* continuous mode */
1369 res = mpu9250_dmp_set_interrupt_mode(&gs_handle, MPU9250_DMP_INTERRUPT_MODE_CONTINUOUS);
1370 if (res != 0)
1371 {
1372 mpu9250_interface_debug_print("mpu9250: dmp set interrupt mode failed.\n");
1373 (void)mpu9250_deinit(&gs_handle);
1374
1375 return 1;
1376 }
1377 mpu9250_interface_debug_print("mpu9250: dmp set gesture continuous mode.\n");
1378
1379 /* mpu9250_dmp_set_orientation test */
1380 mpu9250_interface_debug_print("mpu9250: mpu9250_dmp_set_orientation test.\n");
1381
1382 /* set the dmp orientation */
1383 res = mpu9250_dmp_set_orientation(&gs_handle, gyro_orientation);
1384 if (res != 0)
1385 {
1386 mpu9250_interface_debug_print("mpu9250: dmp set orientation failed.\n");
1387 (void)mpu9250_deinit(&gs_handle);
1388
1389 return 1;
1390 }
1391 mpu9250_interface_debug_print("mpu9250: set the dmp orientation.\n");
1392
1393 /* mpu9250_dmp_set_feature test */
1394 mpu9250_interface_debug_print("mpu9250: mpu9250_dmp_set_feature test.\n");
1395
1396 /* enable feature */
1397 res = mpu9250_dmp_set_feature(&gs_handle, MPU9250_DMP_FEATURE_6X_QUAT | MPU9250_DMP_FEATURE_TAP | MPU9250_DMP_FEATURE_PEDOMETER |
1398 MPU9250_DMP_FEATURE_ORIENT | MPU9250_DMP_FEATURE_SEND_RAW_ACCEL |
1399 MPU9250_DMP_FEATURE_SEND_CAL_GYRO | MPU9250_DMP_FEATURE_GYRO_CAL);
1400 if (res != 0)
1401 {
1402 mpu9250_interface_debug_print("mpu9250: dmp set feature failed.\n");
1403 (void)mpu9250_deinit(&gs_handle);
1404
1405 return 1;
1406 }
1407 mpu9250_interface_debug_print("mpu9250: enable feature 6x quat.\n");
1408 mpu9250_interface_debug_print("mpu9250: enable feature tap.\n");
1409 mpu9250_interface_debug_print("mpu9250: enable feature pedometer.\n");
1410 mpu9250_interface_debug_print("mpu9250: enable feature orient.\n");
1411 mpu9250_interface_debug_print("mpu9250: enable feature send raw accel.\n");
1412 mpu9250_interface_debug_print("mpu9250: enable feature send cal gyro.\n");
1413 mpu9250_interface_debug_print("mpu9250: enable feature gyro cal.\n");
1414
1415 /* dmp set tap callback */
1416 res = mpu9250_dmp_set_tap_callback(&gs_handle, a_dmp_tap_callback);
1417 if (res != 0)
1418 {
1419 mpu9250_interface_debug_print("mpu9250: dmp set tap callback failed.\n");
1420 (void)mpu9250_deinit(&gs_handle);
1421
1422 return 1;
1423 }
1424
1425 /* dmp set orient callback */
1426 res = mpu9250_dmp_set_orient_callback(&gs_handle, a_dmp_orient_callback);
1427 if (res != 0)
1428 {
1429 mpu9250_interface_debug_print("mpu9250: dmp set orient callback failed.\n");
1430 (void)mpu9250_deinit(&gs_handle);
1431
1432 return 1;
1433 }
1434
1435 /* dmp gyro accel raw offset convert */
1436 res = mpu9250_dmp_gyro_accel_raw_offset_convert(&gs_handle, gyro_offset_raw, accel_offset_raw,
1437 gyro_offset, accel_offset);
1438 if (res != 0)
1439 {
1440 mpu9250_interface_debug_print("mpu9250: dmp gyro accel raw offset convert failed.\n");
1441 (void)mpu9250_deinit(&gs_handle);
1442
1443 return 1;
1444 }
1445
1446 /* dmp set accel bias */
1447 res = mpu9250_dmp_set_accel_bias(&gs_handle, accel_offset);
1448 if (res != 0)
1449 {
1450 mpu9250_interface_debug_print("mpu9250: dmp set accel bias failed.\n");
1451 (void)mpu9250_deinit(&gs_handle);
1452
1453 return 1;
1454 }
1455
1456 /* dmp set gyro bias */
1457 res = mpu9250_dmp_set_gyro_bias(&gs_handle, gyro_offset);
1458 if (res != 0)
1459 {
1460 mpu9250_interface_debug_print("mpu9250: dmp set gyro bias failed.\n");
1461 (void)mpu9250_deinit(&gs_handle);
1462
1463 return 1;
1464 }
1465
1466 /* enable the dmp */
1467 res = mpu9250_dmp_set_enable(&gs_handle, MPU9250_BOOL_TRUE);
1468 if (res != 0)
1469 {
1470 mpu9250_interface_debug_print("mpu9250: dmp set enable failed.\n");
1471 (void)mpu9250_deinit(&gs_handle);
1472
1473 return 1;
1474 }
1475
1476 /* force reset the fifo */
1477 res = mpu9250_force_fifo_reset(&gs_handle);
1478 if (res != 0)
1479 {
1480 mpu9250_interface_debug_print("mpu9250: force fifo reset failed.\n");
1481 (void)mpu9250_deinit(&gs_handle);
1482
1483 return 1;
1484 }
1485
1486 /* delay 200 ms */
1487 mpu9250_interface_delay_ms(200);
1488
1489 /* set 0 */
1490 gs_flag = 0;
1491
1492 for (i = 0; i < 1000; i++)
1493 {
1494 uint16_t l;
1495
1496 /* read the data */
1497 l = 128;
1498 res = mpu9250_dmp_read(&gs_handle,
1499 gs_accel_raw, gs_accel_g,
1500 gs_gyro_raw, gs_gyro_dps,
1501 gs_quat,
1502 gs_pitch, gs_roll, gs_yaw,
1503 &l
1504 );
1505 if (res != 0)
1506 {
1507 /* output data */
1508 mpu9250_interface_debug_print("mpu9250: dmp read failed.\n");
1509 }
1510 mpu9250_interface_delay_ms(200);
1511
1512 /* check the flag */
1513 if ((gs_flag & 0x7) == 0x7)
1514 {
1515 break;
1516 }
1517 }
1518
1519 /* finish dmp tap orient motion test */
1520 mpu9250_interface_debug_print("mpu9250: finish dmp tap orient motion test.\n");
1521 (void)mpu9250_deinit(&gs_handle);
1522
1523 return 0;
1524 }
driver_mpu9250_dmp_tap_orient_motion_test.h
driver mpu9250 dmp tap orient motion 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_self_test
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
Definition: driver_mpu9250.c:10094
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_irq_handler
uint8_t mpu9250_irq_handler(mpu9250_handle_t *handle)
irq handler
Definition: driver_mpu9250.c:4668
mpu9250_interface_t
mpu9250_interface_t
mpu9250 interface enumeration definition
Definition: driver_mpu9250.h:63
mpu9250_bool_t
mpu9250_bool_t
mpu9250 bool enumeration definition
Definition: driver_mpu9250.h:81
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_motion_threshold
uint8_t mpu9250_set_motion_threshold(mpu9250_handle_t *handle, uint8_t threshold)
set the motion_threshold
Definition: driver_mpu9250.c:9969
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_set_fifo_1024kb
uint8_t mpu9250_set_fifo_1024kb(mpu9250_handle_t *handle)
set fifo 1024kb
Definition: driver_mpu9250.c:7751
mpu9250_motion_threshold_convert_to_register
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
Definition: driver_mpu9250.c:10039
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_force_fifo_reset
uint8_t mpu9250_force_fifo_reset(mpu9250_handle_t *handle)
force reset the fifo
Definition: driver_mpu9250.c:5844
MPU9250_ACCELEROMETER_RANGE_2G
@ MPU9250_ACCELEROMETER_RANGE_2G
Definition: driver_mpu9250.h:212
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_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_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_dmp_set_accel_bias
uint8_t mpu9250_dmp_set_accel_bias(mpu9250_handle_t *handle, int32_t bias[3])
dmp set the accel bias
Definition: driver_mpu9250.c:2289
mpu9250_dmp_set_tap_callback
uint8_t mpu9250_dmp_set_tap_callback(mpu9250_handle_t *handle, void(*callback)(uint8_t count, uint8_t direction))
dmp set the tap callback
Definition: driver_mpu9250.c:3699
mpu9250_dmp_get_fifo_rate
uint8_t mpu9250_dmp_get_fifo_rate(mpu9250_handle_t *handle, uint16_t *rate)
dmp get the fifo rate
Definition: driver_mpu9250.c:3004
mpu9250_dmp_set_gyro_bias
uint8_t mpu9250_dmp_set_gyro_bias(mpu9250_handle_t *handle, int32_t bias[3])
dmp set the gyro bias
Definition: driver_mpu9250.c:2199
mpu9250_dmp_set_shake_reject_timeout
uint8_t mpu9250_dmp_set_shake_reject_timeout(mpu9250_handle_t *handle, uint16_t ms)
dmp set the shake reject timeout
Definition: driver_mpu9250.c:1352
mpu9250_dmp_get_pedometer_walk_time
uint8_t mpu9250_dmp_get_pedometer_walk_time(mpu9250_handle_t *handle, uint32_t *ms)
dmp get the pedometer walk time
Definition: driver_mpu9250.c:1214
mpu9250_dmp_get_tap_time_multi
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
Definition: driver_mpu9250.c:1681
mpu9250_dmp_set_6x_quaternion
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
Definition: driver_mpu9250.c:2053
mpu9250_dmp_set_orientation
uint8_t mpu9250_dmp_set_orientation(mpu9250_handle_t *handle, int8_t mat[9])
dmp set the orientation
Definition: driver_mpu9250.c:2392
mpu9250_dmp_set_fifo_rate
uint8_t mpu9250_dmp_set_fifo_rate(mpu9250_handle_t *handle, uint16_t rate)
dmp set the fifo rate
Definition: driver_mpu9250.c:2938
mpu9250_dmp_load_firmware
uint8_t mpu9250_dmp_load_firmware(mpu9250_handle_t *handle)
load the dmp firmware
Definition: driver_mpu9250.c:1087
mpu9250_dmp_set_3x_quaternion
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
Definition: driver_mpu9250.c:1976
mpu9250_dmp_set_tap_axes
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
Definition: driver_mpu9250.c:3051
mpu9250_dmp_get_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
Definition: driver_mpu9250.c:3112
mpu9250_dmp_set_enable
uint8_t mpu9250_dmp_set_enable(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the dmp
Definition: driver_mpu9250.c:3767
mpu9250_dmp_set_feature
uint8_t mpu9250_dmp_set_feature(mpu9250_handle_t *handle, uint16_t mask)
dmp enable or disable the dmp feature
Definition: driver_mpu9250.c:2496
mpu9250_dmp_set_shake_reject_thresh
uint8_t mpu9250_dmp_set_shake_reject_thresh(mpu9250_handle_t *handle, uint16_t dps)
dmp set the shake reject thresh
Definition: driver_mpu9250.c:1536
mpu9250_dmp_set_orient_callback
uint8_t mpu9250_dmp_set_orient_callback(mpu9250_handle_t *handle, void(*callback)(uint8_t orientation))
dmp set the orient callback
Definition: driver_mpu9250.c:3733
mpu9250_dmp_set_interrupt_mode
uint8_t mpu9250_dmp_set_interrupt_mode(mpu9250_handle_t *handle, mpu9250_dmp_interrupt_mode_t mode)
dmp set the interrupt mode
Definition: driver_mpu9250.c:2130
mpu9250_dmp_get_shake_reject_time
uint8_t mpu9250_dmp_get_shake_reject_time(mpu9250_handle_t *handle, uint16_t *ms)
dmp get the shake reject time
Definition: driver_mpu9250.c:1491
mpu9250_dmp_get_pedometer_step_count
uint8_t mpu9250_dmp_get_pedometer_step_count(mpu9250_handle_t *handle, uint32_t *count)
dmp get the pedometer step count
Definition: driver_mpu9250.c:1307
mpu9250_dmp_set_pedometer_step_count
uint8_t mpu9250_dmp_set_pedometer_step_count(mpu9250_handle_t *handle, uint32_t count)
dmp set the pedometer step count
Definition: driver_mpu9250.c:1259
mpu9250_dmp_get_tap_thresh
uint8_t mpu9250_dmp_get_tap_thresh(mpu9250_handle_t *handle, mpu9250_axis_t axis, uint16_t *mg_ms)
dmp get the tap thresh
Definition: driver_mpu9250.c:3313
mpu9250_dmp_set_shake_reject_time
uint8_t mpu9250_dmp_set_shake_reject_time(mpu9250_handle_t *handle, uint16_t ms)
dmp set the shake reject time
Definition: driver_mpu9250.c:1444
mpu9250_dmp_get_min_tap_count
uint8_t mpu9250_dmp_get_min_tap_count(mpu9250_handle_t *handle, uint8_t *cnt)
dmp get the min tap count
Definition: driver_mpu9250.c:1869
mpu9250_dmp_get_tap_time
uint8_t mpu9250_dmp_get_tap_time(mpu9250_handle_t *handle, uint16_t *ms)
dmp get the tap time
Definition: driver_mpu9250.c:1773
mpu9250_dmp_set_gyro_calibrate
uint8_t mpu9250_dmp_set_gyro_calibrate(mpu9250_handle_t *handle, mpu9250_bool_t enable)
dmp enable or disable gyro calibrate
Definition: driver_mpu9250.c:1913
mpu9250_dmp_get_shake_reject_timeout
uint8_t mpu9250_dmp_get_shake_reject_timeout(mpu9250_handle_t *handle, uint16_t *ms)
dmp get the shake reject timeout
Definition: driver_mpu9250.c:1399
mpu9250_dmp_gyro_accel_raw_offset_convert
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
Definition: driver_mpu9250.c:3822
mpu9250_dmp_set_tap_time
uint8_t mpu9250_dmp_set_tap_time(mpu9250_handle_t *handle, uint16_t ms)
dmp set the tap time
Definition: driver_mpu9250.c:1726
mpu9250_dmp_set_tap_thresh
uint8_t mpu9250_dmp_set_tap_thresh(mpu9250_handle_t *handle, mpu9250_axis_t axis, uint16_t mg_ms)
dmp set the tap thresh
Definition: driver_mpu9250.c:3168
mpu9250_dmp_set_min_tap_count
uint8_t mpu9250_dmp_set_min_tap_count(mpu9250_handle_t *handle, uint8_t cnt)
dmp set the min tap count
Definition: driver_mpu9250.c:1819
mpu9250_dmp_set_pedometer_walk_time
uint8_t mpu9250_dmp_set_pedometer_walk_time(mpu9250_handle_t *handle, uint32_t ms)
dmp set the pedometer walk time
Definition: driver_mpu9250.c:1165
mpu9250_dmp_read
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
Definition: driver_mpu9250.c:3429
mpu9250_dmp_set_tap_time_multi
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
Definition: driver_mpu9250.c:1634
mpu9250_dmp_get_shake_reject_thresh
uint8_t mpu9250_dmp_get_shake_reject_thresh(mpu9250_handle_t *handle, uint16_t *dps)
dmp get the shake reject thresh
Definition: driver_mpu9250.c:1586
MPU9250_DMP_FEATURE_6X_QUAT
@ MPU9250_DMP_FEATURE_6X_QUAT
Definition: driver_mpu9250.h:458
MPU9250_DMP_FEATURE_GYRO_CAL
@ MPU9250_DMP_FEATURE_GYRO_CAL
Definition: driver_mpu9250.h:459
MPU9250_DMP_FEATURE_PEDOMETER
@ MPU9250_DMP_FEATURE_PEDOMETER
Definition: driver_mpu9250.h:457
MPU9250_DMP_FEATURE_SEND_CAL_GYRO
@ MPU9250_DMP_FEATURE_SEND_CAL_GYRO
Definition: driver_mpu9250.h:462
MPU9250_DMP_FEATURE_SEND_RAW_ACCEL
@ MPU9250_DMP_FEATURE_SEND_RAW_ACCEL
Definition: driver_mpu9250.h:460
MPU9250_DMP_FEATURE_TAP
@ MPU9250_DMP_FEATURE_TAP
Definition: driver_mpu9250.h:454
MPU9250_DMP_FEATURE_ORIENT
@ MPU9250_DMP_FEATURE_ORIENT
Definition: driver_mpu9250.h:455
MPU9250_DMP_ORIENT_REVERSE_PORTRAIT
@ MPU9250_DMP_ORIENT_REVERSE_PORTRAIT
Definition: driver_mpu9250.h:485
MPU9250_DMP_ORIENT_REVERSE_LANDSCAPE
@ MPU9250_DMP_ORIENT_REVERSE_LANDSCAPE
Definition: driver_mpu9250.h:486
MPU9250_DMP_ORIENT_PORTRAIT
@ MPU9250_DMP_ORIENT_PORTRAIT
Definition: driver_mpu9250.h:483
MPU9250_DMP_ORIENT_LANDSCAPE
@ MPU9250_DMP_ORIENT_LANDSCAPE
Definition: driver_mpu9250.h:484
MPU9250_DMP_INTERRUPT_MODE_CONTINUOUS
@ MPU9250_DMP_INTERRUPT_MODE_CONTINUOUS
Definition: driver_mpu9250.h:445
MPU9250_DMP_INTERRUPT_MODE_GESTURE
@ MPU9250_DMP_INTERRUPT_MODE_GESTURE
Definition: driver_mpu9250.h:446
MPU9250_DMP_TAP_X_DOWN
@ MPU9250_DMP_TAP_X_DOWN
Definition: driver_mpu9250.h:471
MPU9250_DMP_TAP_X_UP
@ MPU9250_DMP_TAP_X_UP
Definition: driver_mpu9250.h:470
MPU9250_DMP_TAP_Y_DOWN
@ MPU9250_DMP_TAP_Y_DOWN
Definition: driver_mpu9250.h:473
MPU9250_DMP_TAP_Z_UP
@ MPU9250_DMP_TAP_Z_UP
Definition: driver_mpu9250.h:474
MPU9250_DMP_TAP_Z_DOWN
@ MPU9250_DMP_TAP_Z_DOWN
Definition: driver_mpu9250.h:475
MPU9250_DMP_TAP_Y_UP
@ MPU9250_DMP_TAP_Y_UP
Definition: driver_mpu9250.h:472
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_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_dmp_tap_orient_motion_test_irq_handler
uint8_t mpu9250_dmp_tap_orient_motion_test_irq_handler(void)
dmp tap orient motion test irq
Definition: driver_mpu9250_dmp_tap_orient_motion_test.c:58
mpu9250_dmp_tap_orient_motion_test
uint8_t mpu9250_dmp_tap_orient_motion_test(mpu9250_interface_t interface, mpu9250_address_t addr)
dmp test
Definition: driver_mpu9250_dmp_tap_orient_motion_test.c:231
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