LibDriver MPU6500
Loading...
Searching...
No Matches
driver_mpu6500_dmp_tap_orient_motion_test.c
Go to the documentation of this file.
1
36
38#include <stdlib.h>
39
40static mpu6500_handle_t gs_handle;
41static int16_t gs_accel_raw[128][3];
42static float gs_accel_g[128][3];
43static int16_t gs_gyro_raw[128][3];
44static float gs_gyro_dps[128][3];
45static int32_t gs_quat[128][4];
46static float gs_pitch[128];
47static float gs_roll[128];
48static float gs_yaw[128];
49static volatile uint8_t gs_flag;
50
59{
60 if (mpu6500_irq_handler(&gs_handle) != 0)
61 {
62 return 1;
63 }
64
65 return 0;
66}
67
73static void a_receive_callback(uint8_t type)
74{
75 switch (type)
76 {
78 {
79 gs_flag |= 1 << 0;
80 mpu6500_interface_debug_print("mpu6500: irq motion.\n");
81
82 break;
83 }
85 {
86 mpu6500_interface_debug_print("mpu6500: irq fifo overflow.\n");
87
88 break;
89 }
91 {
92 mpu6500_interface_debug_print("mpu6500: irq fsync int.\n");
93
94 break;
95 }
97 {
98 break;
99 }
101 {
102 break;
103 }
104 default :
105 {
106 mpu6500_interface_debug_print("mpu6500: irq unknown code.\n");
107
108 break;
109 }
110 }
111}
112
119static void a_dmp_tap_callback(uint8_t count, uint8_t direction)
120{
121 switch (direction)
122 {
124 {
125 gs_flag |= 1 << 1;
126 mpu6500_interface_debug_print("mpu6500: tap irq x up with %d.\n", count);
127
128 break;
129 }
131 {
132 gs_flag |= 1 << 1;
133 mpu6500_interface_debug_print("mpu6500: tap irq x down with %d.\n", count);
134
135 break;
136 }
138 {
139 gs_flag |= 1 << 1;
140 mpu6500_interface_debug_print("mpu6500: tap irq y up with %d.\n", count);
141
142 break;
143 }
145 {
146 gs_flag |= 1 << 1;
147 mpu6500_interface_debug_print("mpu6500: tap irq y down with %d.\n", count);
148
149 break;
150 }
152 {
153 gs_flag |= 1 << 1;
154 mpu6500_interface_debug_print("mpu6500: tap irq z up with %d.\n", count);
155
156 break;
157 }
159 {
160 gs_flag |= 1 << 1;
161 mpu6500_interface_debug_print("mpu6500: tap irq z down with %d.\n", count);
162
163 break;
164 }
165 default :
166 {
167 mpu6500_interface_debug_print("mpu6500: tap irq unknown code.\n");
168
169 break;
170 }
171 }
172}
173
179static void a_dmp_orient_callback(uint8_t orientation)
180{
181 switch (orientation)
182 {
184 {
185 gs_flag |= 1 << 2;
186 mpu6500_interface_debug_print("mpu6500: orient irq portrait.\n");
187
188 break;
189 }
191 {
192 gs_flag |= 1 << 2;
193 mpu6500_interface_debug_print("mpu6500: orient irq landscape.\n");
194
195 break;
196 }
198 {
199 gs_flag |= 1 << 2;
200 mpu6500_interface_debug_print("mpu6500: orient irq reverse portrait.\n");
201
202 break;
203 }
205 {
206 gs_flag |= 1 << 2;
207 mpu6500_interface_debug_print("mpu6500: orient irq reverse landscape.\n");
208
209 break;
210 }
211 default :
212 {
213 mpu6500_interface_debug_print("mpu6500: orient irq unknown code.\n");
214
215 break;
216 }
217 }
218}
219
230{
231 uint8_t res;
232 uint8_t reg;
233 uint32_t ms;
234 uint32_t ms_check;
235 uint32_t cnt;
236 uint32_t cnt_check;
237 uint32_t i;
238 uint16_t m;
239 uint16_t m_check;
240 uint8_t c;
241 uint8_t c_check;
242 int32_t gyro_offset_raw[3];
243 int32_t accel_offset_raw[3];
244 int32_t gyro_offset[3];
245 int32_t accel_offset[3];
246 mpu6500_bool_t enable;
247 mpu6500_info_t info;
248 int8_t gyro_orientation[9] = {1, 0, 0,
249 0, 1, 0,
250 0, 0, 1};
251
252 /* link interface function */
264 DRIVER_MPU6500_LINK_RECEIVE_CALLBACK(&gs_handle, a_receive_callback);
265
266 /* get information */
267 res = mpu6500_info(&info);
268 if (res != 0)
269 {
270 mpu6500_interface_debug_print("mpu6500: get info failed.\n");
271
272 return 1;
273 }
274 else
275 {
276 /* print chip info */
277 mpu6500_interface_debug_print("mpu6500: chip is %s.\n", info.chip_name);
278 mpu6500_interface_debug_print("mpu6500: manufacturer is %s.\n", info.manufacturer_name);
279 mpu6500_interface_debug_print("mpu6500: interface is %s.\n", info.interface);
280 mpu6500_interface_debug_print("mpu6500: driver version is %d.%d.\n", info.driver_version / 1000, (info.driver_version % 1000) / 100);
281 mpu6500_interface_debug_print("mpu6500: min supply voltage is %0.1fV.\n", info.supply_voltage_min_v);
282 mpu6500_interface_debug_print("mpu6500: max supply voltage is %0.1fV.\n", info.supply_voltage_max_v);
283 mpu6500_interface_debug_print("mpu6500: max current is %0.2fmA.\n", info.max_current_ma);
284 mpu6500_interface_debug_print("mpu6500: max temperature is %0.1fC.\n", info.temperature_max);
285 mpu6500_interface_debug_print("mpu6500: min temperature is %0.1fC.\n", info.temperature_min);
286 }
287
288 /* start dmp tap orient motion test */
289 mpu6500_interface_debug_print("mpu6500: start dmp tap orient motion test.\n");
290
291 /* set the interface */
292 res = mpu6500_set_interface(&gs_handle, interface);
293 if (res != 0)
294 {
295 mpu6500_interface_debug_print("mpu6500: set interface failed.\n");
296
297 return 1;
298 }
299
300 /* set the addr pin */
301 res = mpu6500_set_addr_pin(&gs_handle, addr);
302 if (res != 0)
303 {
304 mpu6500_interface_debug_print("mpu6500: set addr pin failed.\n");
305
306 return 1;
307 }
308
309 /* init */
310 res = mpu6500_init(&gs_handle);
311 if (res != 0)
312 {
313 mpu6500_interface_debug_print("mpu6500: init failed.\n");
314
315 return 1;
316 }
317
318 /* delay 100 ms */
320
321 /* disable sleep */
322 res = mpu6500_set_sleep(&gs_handle, MPU6500_BOOL_FALSE);
323 if (res != 0)
324 {
325 mpu6500_interface_debug_print("mpu6500: set sleep failed.\n");
326 (void)mpu6500_deinit(&gs_handle);
327
328 return 1;
329 }
330
331 /* if spi interface, disable iic interface */
332 if (interface == MPU6500_INTERFACE_SPI)
333 {
334 /* disable iic */
336 if (res != 0)
337 {
338 mpu6500_interface_debug_print("mpu6500: set disable iic slave failed.\n");
339 (void)mpu6500_deinit(&gs_handle);
340
341 return 1;
342 }
343 }
344
345 /* set fifo 1024kb */
346 res = mpu6500_set_fifo_1024kb(&gs_handle);
347 if (res != 0)
348 {
349 mpu6500_interface_debug_print("mpu6500: set fifo 1024kb failed.\n");
350 (void)mpu6500_deinit(&gs_handle);
351
352 return 1;
353 }
354
355 /* run the self test */
356 res = mpu6500_self_test(&gs_handle, gyro_offset_raw, accel_offset_raw);
357 if (res != 0)
358 {
359 mpu6500_interface_debug_print("mpu6500: self test failed.\n");
360 (void)mpu6500_deinit(&gs_handle);
361
362 return 1;
363 }
364
365 /* set pll */
367 if (res != 0)
368 {
369 mpu6500_interface_debug_print("mpu6500: set clock source failed.\n");
370 (void)mpu6500_deinit(&gs_handle);
371
372 return 1;
373 }
374
375 /* set 50Hz */
376 res = mpu6500_set_sample_rate_divider(&gs_handle, (1000 / 50) - 1);
377 if (res != 0)
378 {
379 mpu6500_interface_debug_print("mpu6500: set sample rate divider failed.\n");
380 (void)mpu6500_deinit(&gs_handle);
381
382 return 1;
383 }
384
385 /* ±2g */
387 if (res != 0)
388 {
389 mpu6500_interface_debug_print("mpu6500: set accelerometer range failed.\n");
390 (void)mpu6500_deinit(&gs_handle);
391
392 return 1;
393 }
394
395 /* ±2000dps */
397 if (res != 0)
398 {
399 mpu6500_interface_debug_print("mpu6500: set gyroscope range failed.\n");
400 (void)mpu6500_deinit(&gs_handle);
401
402 return 1;
403 }
404
405 /* set low pass filter 3 */
407 if (res != 0)
408 {
409 mpu6500_interface_debug_print("mpu6500: set low pass filter failed.\n");
410 (void)mpu6500_deinit(&gs_handle);
411
412 return 1;
413 }
414
415 /* enable temperature sensor */
416 res = mpu6500_set_ptat(&gs_handle, MPU6500_BOOL_TRUE);
417 if (res != 0)
418 {
419 mpu6500_interface_debug_print("mpu6500: set ptat failed.\n");
420 (void)mpu6500_deinit(&gs_handle);
421
422 return 1;
423 }
424
425 /* disable cycle wake up */
427 if (res != 0)
428 {
429 mpu6500_interface_debug_print("mpu6500: set cycle wake up failed.\n");
430 (void)mpu6500_deinit(&gs_handle);
431
432 return 1;
433 }
434
435 /* enable acc x */
437 if (res != 0)
438 {
439 mpu6500_interface_debug_print("mpu6500: set standby mode failed.\n");
440 (void)mpu6500_deinit(&gs_handle);
441
442 return 1;
443 }
444
445 /* enable acc y */
447 if (res != 0)
448 {
449 mpu6500_interface_debug_print("mpu6500: set standby mode failed.\n");
450 (void)mpu6500_deinit(&gs_handle);
451
452 return 1;
453 }
454
455 /* enable acc z */
457 if (res != 0)
458 {
459 mpu6500_interface_debug_print("mpu6500: set standby mode failed.\n");
460 (void)mpu6500_deinit(&gs_handle);
461
462 return 1;
463 }
464
465 /* enable gyro x */
467 if (res != 0)
468 {
469 mpu6500_interface_debug_print("mpu6500: set standby mode failed.\n");
470 (void)mpu6500_deinit(&gs_handle);
471
472 return 1;
473 }
474
475 /* enable gyro y */
477 if (res != 0)
478 {
479 mpu6500_interface_debug_print("mpu6500: set standby mode failed.\n");
480 (void)mpu6500_deinit(&gs_handle);
481
482 return 1;
483 }
484
485 /* enable gyro z */
487 if (res != 0)
488 {
489 mpu6500_interface_debug_print("mpu6500: set standby mode failed.\n");
490 (void)mpu6500_deinit(&gs_handle);
491
492 return 1;
493 }
494
495 /* disable gyroscope x test */
497 if (res != 0)
498 {
499 mpu6500_interface_debug_print("mpu6500: set gyroscope test failed.\n");
500 (void)mpu6500_deinit(&gs_handle);
501
502 return 1;
503 }
504
505 /* disable gyroscope y test */
507 if (res != 0)
508 {
509 mpu6500_interface_debug_print("mpu6500: set gyroscope test failed.\n");
510 (void)mpu6500_deinit(&gs_handle);
511
512 return 1;
513 }
514
515 /* disable gyroscope z test */
517 if (res != 0)
518 {
519 mpu6500_interface_debug_print("mpu6500: set gyroscope test failed.\n");
520 (void)mpu6500_deinit(&gs_handle);
521
522 return 1;
523 }
524
525 /* disable accelerometer x test */
527 if (res != 0)
528 {
529 mpu6500_interface_debug_print("mpu6500: set accelerometer test failed.\n");
530 (void)mpu6500_deinit(&gs_handle);
531
532 return 1;
533 }
534
535 /* disable accelerometer y test */
537 if (res != 0)
538 {
539 mpu6500_interface_debug_print("mpu6500: set accelerometer test failed.\n");
540 (void)mpu6500_deinit(&gs_handle);
541
542 return 1;
543 }
544
545 /* disable accelerometer z test */
547 if (res != 0)
548 {
549 mpu6500_interface_debug_print("mpu6500: set accelerometer test failed.\n");
550 (void)mpu6500_deinit(&gs_handle);
551
552 return 1;
553 }
554
555 /* disable temp fifo */
557 if (res != 0)
558 {
559 mpu6500_interface_debug_print("mpu6500: set fifo enable failed.\n");
560 (void)mpu6500_deinit(&gs_handle);
561
562 return 1;
563 }
564
565 /* disable xg fifo */
567 if (res != 0)
568 {
569 mpu6500_interface_debug_print("mpu6500: set fifo enable failed.\n");
570 (void)mpu6500_deinit(&gs_handle);
571
572 return 1;
573 }
574
575 /* disable yg fifo */
577 if (res != 0)
578 {
579 mpu6500_interface_debug_print("mpu6500: set fifo enable failed.\n");
580 (void)mpu6500_deinit(&gs_handle);
581
582 return 1;
583 }
584
585 /* disable zg fifo */
587 if (res != 0)
588 {
589 mpu6500_interface_debug_print("mpu6500: set fifo enable failed.\n");
590 (void)mpu6500_deinit(&gs_handle);
591
592 return 1;
593 }
594
595 /* disable accel fifo */
597 if (res != 0)
598 {
599 mpu6500_interface_debug_print("mpu6500: set fifo enable failed.\n");
600 (void)mpu6500_deinit(&gs_handle);
601
602 return 1;
603 }
604
605 /* enable fifo */
606 res = mpu6500_set_fifo(&gs_handle, MPU6500_BOOL_TRUE);
607 if (res != 0)
608 {
609 mpu6500_interface_debug_print("mpu6500: set fifo failed.\n");
610 (void)mpu6500_deinit(&gs_handle);
611
612 return 1;
613 }
614
615 /* set interrupt level low */
617 if (res != 0)
618 {
619 mpu6500_interface_debug_print("mpu6500: set interrupt level failed.\n");
620 (void)mpu6500_deinit(&gs_handle);
621
622 return 1;
623 }
624
625 /* push-pull */
627 if (res != 0)
628 {
629 mpu6500_interface_debug_print("mpu6500: set interrupt pin type failed.\n");
630 (void)mpu6500_deinit(&gs_handle);
631
632 return 1;
633 }
634
635 /* set 200mg */
636 res = mpu6500_motion_threshold_convert_to_register(&gs_handle, 200.0f, &reg);
637 if (res != 0)
638 {
639 mpu6500_interface_debug_print("mpu6500: motion threshold convert to register failed.\n");
640 (void)mpu6500_deinit(&gs_handle);
641
642 return 1;
643 }
644
645 /* set the motion threshold */
646 res = mpu6500_set_motion_threshold(&gs_handle, reg);
647 if (res != 0)
648 {
649 mpu6500_interface_debug_print("mpu6500: set motion threshold failed.\n");
650 (void)mpu6500_deinit(&gs_handle);
651
652 return 1;
653 }
654
655 /* enable motion */
657 if (res != 0)
658 {
659 mpu6500_interface_debug_print("mpu6500: set interrupt failed.\n");
660 (void)mpu6500_deinit(&gs_handle);
661
662 return 1;
663 }
664
665 /* enable fifo overflow */
667 if (res != 0)
668 {
669 mpu6500_interface_debug_print("mpu6500: set interrupt failed.\n");
670 (void)mpu6500_deinit(&gs_handle);
671
672 return 1;
673 }
674
675 /* disable dmp interrupt */
677 if (res != 0)
678 {
679 mpu6500_interface_debug_print("mpu6500: set interrupt failed.\n");
680 (void)mpu6500_deinit(&gs_handle);
681
682 return 1;
683 }
684
685 /* disable fsync int */
687 if (res != 0)
688 {
689 mpu6500_interface_debug_print("mpu6500: set interrupt failed.\n");
690 (void)mpu6500_deinit(&gs_handle);
691
692 return 1;
693 }
694
695 /* disable data ready */
697 if (res != 0)
698 {
699 mpu6500_interface_debug_print("mpu6500: set interrupt failed.\n");
700 (void)mpu6500_deinit(&gs_handle);
701
702 return 1;
703 }
704
705 /* enable latch */
707 if (res != 0)
708 {
709 mpu6500_interface_debug_print("mpu6500: set interrupt latch failed.\n");
710 (void)mpu6500_deinit(&gs_handle);
711
712 return 1;
713 }
714
715 /* enable interrupt read clear */
717 if (res != 0)
718 {
719 mpu6500_interface_debug_print("mpu6500: set interrupt read clear failed.\n");
720 (void)mpu6500_deinit(&gs_handle);
721
722 return 1;
723 }
724
725 /* disable sync input */
727 if (res != 0)
728 {
729 mpu6500_interface_debug_print("mpu6500: set extern sync failed.\n");
730 (void)mpu6500_deinit(&gs_handle);
731
732 return 1;
733 }
734
735 /* disable fsync interrupt */
737 if (res != 0)
738 {
739 mpu6500_interface_debug_print("mpu6500: set fsync interrupt failed.\n");
740 (void)mpu6500_deinit(&gs_handle);
741
742 return 1;
743 }
744
745 /* fsync interrupt level low */
747 if (res != 0)
748 {
749 mpu6500_interface_debug_print("mpu6500: set fsync interrupt level failed.\n");
750 (void)mpu6500_deinit(&gs_handle);
751
752 return 1;
753 }
754
755 /* disable iic master */
757 if (res != 0)
758 {
759 mpu6500_interface_debug_print("mpu6500: set iic master failed.\n");
760 (void)mpu6500_deinit(&gs_handle);
761
762 return 1;
763 }
764
765 /* disable iic bypass */
767 if (res != 0)
768 {
769 mpu6500_interface_debug_print("mpu6500: set iic bypass failed.\n");
770 (void)mpu6500_deinit(&gs_handle);
771
772 return 1;
773 }
774
775 /* disable gyro standby */
777 if (res != 0)
778 {
779 mpu6500_interface_debug_print("mpu6500: set gyro standby failed.\n");
780 (void)mpu6500_deinit(&gs_handle);
781
782 return 1;
783 }
784
785 /* set the fifo normal mode */
787 if (res != 0)
788 {
789 mpu6500_interface_debug_print("mpu6500: set fifo mode failed.\n");
790 (void)mpu6500_deinit(&gs_handle);
791
792 return 1;
793 }
794
795 /* set gyroscope choice 0 */
796 res = mpu6500_set_gyroscope_choice(&gs_handle, 0);
797 if (res != 0)
798 {
799 mpu6500_interface_debug_print("mpu6500: set gyroscope choice failed.\n");
800 (void)mpu6500_deinit(&gs_handle);
801
802 return 1;
803 }
804
805 /* set low pass filter 3 */
807 if (res != 0)
808 {
809 mpu6500_interface_debug_print("mpu6500: set low pass filter failed.\n");
810 (void)mpu6500_deinit(&gs_handle);
811
812 return 1;
813 }
814
815 /* set accelerometer choice 0 */
816 res = mpu6500_set_accelerometer_choice(&gs_handle, 0);
817 if (res != 0)
818 {
819 mpu6500_interface_debug_print("mpu6500: set accelerometer choice failed.\n");
820 (void)mpu6500_deinit(&gs_handle);
821
822 return 1;
823 }
824
825 /* set accelerometer low pass filter 3 */
827 if (res != 0)
828 {
829 mpu6500_interface_debug_print("mpu6500: set accelerometer low pass filter failed.\n");
830 (void)mpu6500_deinit(&gs_handle);
831
832 return 1;
833 }
834
835 /* set low power accel output rate 62.5Hz */
837 if (res != 0)
838 {
839 mpu6500_interface_debug_print("mpu6500: set low power accel output rate failed.\n");
840 (void)mpu6500_deinit(&gs_handle);
841
842 return 1;
843 }
844
845 /* enable wake on motion */
847 if (res != 0)
848 {
849 mpu6500_interface_debug_print("mpu6500: set wake on motion failed.\n");
850 (void)mpu6500_deinit(&gs_handle);
851
852 return 1;
853 }
854
855 /* enable accel compare with previous sample */
857 if (res != 0)
858 {
859 mpu6500_interface_debug_print("mpu6500: set accel compare with previous sample failed.\n");
860 (void)mpu6500_deinit(&gs_handle);
861
862 return 1;
863 }
864
865 /* load dmp firmware */
866 mpu6500_interface_debug_print("mpu6500: load dmp firmware.\n");
867
868 /* dmp load firmware */
869 res = mpu6500_dmp_load_firmware(&gs_handle);
870 if (res != 0)
871 {
872 mpu6500_interface_debug_print("mpu6500: dmp load firmware failed.\n");
873 (void)mpu6500_deinit(&gs_handle);
874
875 return 1;
876 }
877
878 /* load dmp firmware successful */
879 mpu6500_interface_debug_print("mpu6500: load dmp firmware successful .\n");
880
881 /* mpu6500_dmp_set_pedometer_walk_time/mpu6500_dmp_get_pedometer_walk_time test */
882 mpu6500_interface_debug_print("mpu6500: mpu6500_dmp_set_pedometer_walk_time/mpu6500_dmp_get_pedometer_walk_time test.\n");
883
884 ms = 200;
885 res = mpu6500_dmp_set_pedometer_walk_time(&gs_handle, ms);
886 if (res != 0)
887 {
888 mpu6500_interface_debug_print("mpu6500: dmp set pedometer walk time failed.\n");
889 (void)mpu6500_deinit(&gs_handle);
890
891 return 1;
892 }
893 mpu6500_interface_debug_print("mpu6500: dmp set pedometer walk time %d ms.\n", ms);
894 res = mpu6500_dmp_get_pedometer_walk_time(&gs_handle, &ms_check);
895 if (res != 0)
896 {
897 mpu6500_interface_debug_print("mpu6500: dmp get pedometer walk time failed.\n");
898 (void)mpu6500_deinit(&gs_handle);
899
900 return 1;
901 }
902 mpu6500_interface_debug_print("mpu6500: check pedometer walk time %s.\n", ms_check == ms ? "ok" : "error");
903
904 /* mpu6500_dmp_set_pedometer_step_count/mpu6500_dmp_get_pedometer_step_count test */
905 mpu6500_interface_debug_print("mpu6500: mpu6500_dmp_set_pedometer_step_count/mpu6500_dmp_get_pedometer_step_count test.\n");
906
907 cnt = rand() % 1000;
908 res = mpu6500_dmp_set_pedometer_step_count(&gs_handle, cnt);
909 if (res != 0)
910 {
911 mpu6500_interface_debug_print("mpu6500: dmp set pedometer step count failed.\n");
912 (void)mpu6500_deinit(&gs_handle);
913
914 return 1;
915 }
916 mpu6500_interface_debug_print("mpu6500: dmp set pedometer step count %d.\n", cnt);
917 res = mpu6500_dmp_get_pedometer_step_count(&gs_handle, &cnt_check);
918 if (res != 0)
919 {
920 mpu6500_interface_debug_print("mpu6500: dmp get pedometer step count failed.\n");
921 (void)mpu6500_deinit(&gs_handle);
922
923 return 1;
924 }
925 mpu6500_interface_debug_print("mpu6500: check pedometer step count %s.\n", cnt_check == cnt ? "ok" : "error");
926
927 /* mpu6500_dmp_set_shake_reject_timeout/mpu6500_dmp_get_shake_reject_timeout test */
928 mpu6500_interface_debug_print("mpu6500: mpu6500_dmp_set_shake_reject_timeout/mpu6500_dmp_get_shake_reject_timeout test.\n");
929
930 m = 10;
931 res = mpu6500_dmp_set_shake_reject_timeout(&gs_handle, m);
932 if (res != 0)
933 {
934 mpu6500_interface_debug_print("mpu6500: dmp set shake reject timeout failed.\n");
935 (void)mpu6500_deinit(&gs_handle);
936
937 return 1;
938 }
939 mpu6500_interface_debug_print("mpu6500: dmp set shake reject timeout %d ms.\n", m);
940 res = mpu6500_dmp_get_shake_reject_timeout(&gs_handle, &m_check);
941 if (res != 0)
942 {
943 mpu6500_interface_debug_print("mpu6500: dmp get shake reject timeout failed.\n");
944 (void)mpu6500_deinit(&gs_handle);
945
946 return 1;
947 }
948 mpu6500_interface_debug_print("mpu6500: check shake reject timeout %s.\n", m_check == m ? "ok" : "error");
949
950 /* mpu6500_dmp_set_shake_reject_time/mpu6500_dmp_get_shake_reject_time test */
951 mpu6500_interface_debug_print("mpu6500: mpu6500_dmp_set_shake_reject_time/mpu6500_dmp_get_shake_reject_time test.\n");
952
953 m = 40;
954 res = mpu6500_dmp_set_shake_reject_time(&gs_handle, m);
955 if (res != 0)
956 {
957 mpu6500_interface_debug_print("mpu6500: dmp set shake reject time failed.\n");
958 (void)mpu6500_deinit(&gs_handle);
959
960 return 1;
961 }
962 mpu6500_interface_debug_print("mpu6500: dmp set shake reject time %d ms.\n", m);
963 res = mpu6500_dmp_get_shake_reject_time(&gs_handle, &m_check);
964 if (res != 0)
965 {
966 mpu6500_interface_debug_print("mpu6500: dmp get shake reject time failed.\n");
967 (void)mpu6500_deinit(&gs_handle);
968
969 return 1;
970 }
971 mpu6500_interface_debug_print("mpu6500: check shake reject time %s.\n", m_check == m ? "ok" : "error");
972
973 /* mpu6500_dmp_set_shake_reject_thresh/mpu6500_dmp_get_shake_reject_thresh test */
974 mpu6500_interface_debug_print("mpu6500: mpu6500_dmp_set_shake_reject_thresh/mpu6500_dmp_get_shake_reject_thresh test.\n");
975
976 m = 200;
977 res = mpu6500_dmp_set_shake_reject_thresh(&gs_handle, m);
978 if (res != 0)
979 {
980 mpu6500_interface_debug_print("mpu6500: dmp set shake reject thresh failed.\n");
981 (void)mpu6500_deinit(&gs_handle);
982
983 return 1;
984 }
985 mpu6500_interface_debug_print("mpu6500: set shake reject thresh %d dps.\n", m);
986 res = mpu6500_dmp_get_shake_reject_thresh(&gs_handle, &m_check);
987 if (res != 0)
988 {
989 mpu6500_interface_debug_print("mpu6500: dmp get shake reject thresh failed.\n");
990 (void)mpu6500_deinit(&gs_handle);
991
992 return 1;
993 }
994 mpu6500_interface_debug_print("mpu6500: check shake reject thresh %s.\n", m_check == m ? "ok" : "error");
995
996 /* mpu6500_dmp_set_tap_time_multi/mpu6500_dmp_get_tap_time_multi test */
997 mpu6500_interface_debug_print("mpu6500: mpu6500_dmp_set_tap_time_multi/mpu6500_dmp_get_tap_time_multi test.\n");
998
999 m = 200;
1000 res = mpu6500_dmp_set_tap_time_multi(&gs_handle, m);
1001 if (res != 0)
1002 {
1003 mpu6500_interface_debug_print("mpu6500: dmp set tap time multi failed.\n");
1004 (void)mpu6500_deinit(&gs_handle);
1005
1006 return 1;
1007 }
1008 mpu6500_interface_debug_print("mpu6500: dmp set tap time multi %d ms.\n", m);
1009 res = mpu6500_dmp_get_tap_time_multi(&gs_handle, &m_check);
1010 if (res != 0)
1011 {
1012 mpu6500_interface_debug_print("mpu6500: dmp get tap time multi failed.\n");
1013 (void)mpu6500_deinit(&gs_handle);
1014
1015 return 1;
1016 }
1017 mpu6500_interface_debug_print("mpu6500: check tap time multi %s.\n", m_check == m ? "ok" : "error");
1018
1019 /* mpu6500_dmp_set_tap_time/mpu6500_dmp_get_tap_time test */
1020 mpu6500_interface_debug_print("mpu6500: mpu6500_dmp_set_tap_time/mpu6500_dmp_get_tap_time test.\n");
1021
1022 m = 100;
1023 res = mpu6500_dmp_set_tap_time(&gs_handle, m);
1024 if (res != 0)
1025 {
1026 mpu6500_interface_debug_print("mpu6500: dmp set tap time failed.\n");
1027 (void)mpu6500_deinit(&gs_handle);
1028
1029 return 1;
1030 }
1031 mpu6500_interface_debug_print("mpu6500: dmp set tap time %d ms.\n", m);
1032 res = mpu6500_dmp_get_tap_time(&gs_handle, &m_check);
1033 if (res != 0)
1034 {
1035 mpu6500_interface_debug_print("mpu6500: dmp get tap time failed.\n");
1036 (void)mpu6500_deinit(&gs_handle);
1037
1038 return 1;
1039 }
1040 mpu6500_interface_debug_print("mpu6500: check tap time %s.\n", m_check == m ? "ok" : "error");
1041
1042 /* mpu6500_dmp_set_min_tap_count/mpu6500_dmp_get_min_tap_count test */
1043 mpu6500_interface_debug_print("mpu6500: mpu6500_dmp_set_min_tap_count/mpu6500_dmp_get_min_tap_count test.\n");
1044
1045 c = 1;
1046 res = mpu6500_dmp_set_min_tap_count(&gs_handle, c);
1047 if (res != 0)
1048 {
1049 mpu6500_interface_debug_print("mpu6500: dmp set min tap count failed.\n");
1050 (void)mpu6500_deinit(&gs_handle);
1051
1052 return 1;
1053 }
1054 mpu6500_interface_debug_print("mpu6500: dmp set min tap count %d.\n", c);
1055 res = mpu6500_dmp_get_min_tap_count(&gs_handle, &c_check);
1056 if (res != 0)
1057 {
1058 mpu6500_interface_debug_print("mpu6500: dmp get min tap count failed.\n");
1059 (void)mpu6500_deinit(&gs_handle);
1060
1061 return 1;
1062 }
1063 mpu6500_interface_debug_print("mpu6500: check min tap count %s.\n", c_check == c ? "ok" : "error");
1064
1065 /* mpu6500_dmp_set_tap_axes/mpu6500_dmp_get_tap_axes test */
1066 mpu6500_interface_debug_print("mpu6500: mpu6500_dmp_set_tap_axes/mpu6500_dmp_get_tap_axes test.\n");
1067
1068 /* disable axis x */
1070 if (res != 0)
1071 {
1072 mpu6500_interface_debug_print("mpu6500: dmp set tap axes failed.\n");
1073 (void)mpu6500_deinit(&gs_handle);
1074
1075 return 1;
1076 }
1077 mpu6500_interface_debug_print("mpu6500: disable tap axes x.\n");
1078 res = mpu6500_dmp_get_tap_axes(&gs_handle, MPU6500_AXIS_X, &enable);
1079 if (res != 0)
1080 {
1081 mpu6500_interface_debug_print("mpu6500: dmp get tap axes failed.\n");
1082 (void)mpu6500_deinit(&gs_handle);
1083
1084 return 1;
1085 }
1086 mpu6500_interface_debug_print("mpu6500: check tap axes %s.\n", enable == MPU6500_BOOL_FALSE ? "ok" : "error");
1087
1088 /* enable axis x */
1090 if (res != 0)
1091 {
1092 mpu6500_interface_debug_print("mpu6500: dmp set tap axes failed.\n");
1093 (void)mpu6500_deinit(&gs_handle);
1094
1095 return 1;
1096 }
1097 mpu6500_interface_debug_print("mpu6500: enable tap axes x.\n");
1098 res = mpu6500_dmp_get_tap_axes(&gs_handle, MPU6500_AXIS_X, &enable);
1099 if (res != 0)
1100 {
1101 mpu6500_interface_debug_print("mpu6500: dmp get tap axes failed.\n");
1102 (void)mpu6500_deinit(&gs_handle);
1103
1104 return 1;
1105 }
1106 mpu6500_interface_debug_print("mpu6500: check tap axes %s.\n", enable == MPU6500_BOOL_TRUE ? "ok" : "error");
1107
1108 /* disable axis y */
1110 if (res != 0)
1111 {
1112 mpu6500_interface_debug_print("mpu6500: dmp set tap axes failed.\n");
1113 (void)mpu6500_deinit(&gs_handle);
1114
1115 return 1;
1116 }
1117 mpu6500_interface_debug_print("mpu6500: disable tap axes y.\n");
1118 res = mpu6500_dmp_get_tap_axes(&gs_handle, MPU6500_AXIS_Y, &enable);
1119 if (res != 0)
1120 {
1121 mpu6500_interface_debug_print("mpu6500: dmp get tap axes failed.\n");
1122 (void)mpu6500_deinit(&gs_handle);
1123
1124 return 1;
1125 }
1126 mpu6500_interface_debug_print("mpu6500: check tap axes %s.\n", enable == MPU6500_BOOL_FALSE ? "ok" : "error");
1127
1128 /* enable axis y */
1130 if (res != 0)
1131 {
1132 mpu6500_interface_debug_print("mpu6500: dmp set tap axes failed.\n");
1133 (void)mpu6500_deinit(&gs_handle);
1134
1135 return 1;
1136 }
1137 mpu6500_interface_debug_print("mpu6500: enable tap axes y.\n");
1138 res = mpu6500_dmp_get_tap_axes(&gs_handle, MPU6500_AXIS_Y, &enable);
1139 if (res != 0)
1140 {
1141 mpu6500_interface_debug_print("mpu6500: dmp get tap axes failed.\n");
1142 (void)mpu6500_deinit(&gs_handle);
1143
1144 return 1;
1145 }
1146 mpu6500_interface_debug_print("mpu6500: check tap axes %s.\n", enable == MPU6500_BOOL_TRUE ? "ok" : "error");
1147
1148 /* disable axis z */
1150 if (res != 0)
1151 {
1152 mpu6500_interface_debug_print("mpu6500: dmp set tap axes failed.\n");
1153 (void)mpu6500_deinit(&gs_handle);
1154
1155 return 1;
1156 }
1157 mpu6500_interface_debug_print("mpu6500: disable tap axes z.\n");
1158 res = mpu6500_dmp_get_tap_axes(&gs_handle, MPU6500_AXIS_Z, &enable);
1159 if (res != 0)
1160 {
1161 mpu6500_interface_debug_print("mpu6500: dmp get tap axes failed.\n");
1162 (void)mpu6500_deinit(&gs_handle);
1163
1164 return 1;
1165 }
1166 mpu6500_interface_debug_print("mpu6500: check tap axes %s.\n", enable == MPU6500_BOOL_FALSE ? "ok" : "error");
1167
1168 /* enable axis z */
1170 if (res != 0)
1171 {
1172 mpu6500_interface_debug_print("mpu6500: dmp set tap axes failed.\n");
1173 (void)mpu6500_deinit(&gs_handle);
1174
1175 return 1;
1176 }
1177 mpu6500_interface_debug_print("mpu6500: enable tap axes z.\n");
1178 res = mpu6500_dmp_get_tap_axes(&gs_handle, MPU6500_AXIS_Z, &enable);
1179 if (res != 0)
1180 {
1181 mpu6500_interface_debug_print("mpu6500: dmp get tap axes failed.\n");
1182 (void)mpu6500_deinit(&gs_handle);
1183
1184 return 1;
1185 }
1186 mpu6500_interface_debug_print("mpu6500: check tap axes %s.\n", enable == MPU6500_BOOL_TRUE ? "ok" : "error");
1187
1188 /* mpu6500_dmp_set_tap_thresh/mpu6500_dmp_get_tap_thresh test */
1189 mpu6500_interface_debug_print("mpu6500: mpu6500_dmp_set_tap_thresh/mpu6500_dmp_get_tap_thresh test.\n");
1190
1191 /* set tap thresh x */
1192 m = 250;
1193 res = mpu6500_dmp_set_tap_thresh(&gs_handle, MPU6500_AXIS_X, m);
1194 if (res != 0)
1195 {
1196 mpu6500_interface_debug_print("mpu6500: dmp set tap thresh failed.\n");
1197 (void)mpu6500_deinit(&gs_handle);
1198
1199 return 1;
1200 }
1201 mpu6500_interface_debug_print("mpu6500: dmp set tap thresh x %d mg/ms.\n", m);
1202 res = mpu6500_dmp_get_tap_thresh(&gs_handle, MPU6500_AXIS_X, &m_check);
1203 if (res != 0)
1204 {
1205 mpu6500_interface_debug_print("mpu6500: dmp get tap thresh failed.\n");
1206 (void)mpu6500_deinit(&gs_handle);
1207
1208 return 1;
1209 }
1210 mpu6500_interface_debug_print("mpu6500: check tap thresh %s.\n", m_check == m ? "ok" : "error");
1211
1212 /* set tap thresh y */
1213 m = 250;
1214 res = mpu6500_dmp_set_tap_thresh(&gs_handle, MPU6500_AXIS_Y, m);
1215 if (res != 0)
1216 {
1217 mpu6500_interface_debug_print("mpu6500: dmp set tap thresh failed.\n");
1218 (void)mpu6500_deinit(&gs_handle);
1219
1220 return 1;
1221 }
1222 mpu6500_interface_debug_print("mpu6500: dmp set tap thresh y %d mg/ms.\n", m);
1223 res = mpu6500_dmp_get_tap_thresh(&gs_handle, MPU6500_AXIS_Y, &m_check);
1224 if (res != 0)
1225 {
1226 mpu6500_interface_debug_print("mpu6500: dmp get tap thresh failed.\n");
1227 (void)mpu6500_deinit(&gs_handle);
1228
1229 return 1;
1230 }
1231 mpu6500_interface_debug_print("mpu6500: check tap thresh %s.\n", m_check == m ? "ok" : "error");
1232
1233 /* set tap thresh z */
1234 m = 250;
1235 res = mpu6500_dmp_set_tap_thresh(&gs_handle, MPU6500_AXIS_Z, m);
1236 if (res != 0)
1237 {
1238 mpu6500_interface_debug_print("mpu6500: dmp set tap thresh failed.\n");
1239 (void)mpu6500_deinit(&gs_handle);
1240
1241 return 1;
1242 }
1243 mpu6500_interface_debug_print("mpu6500: dmp set tap thresh z %d mg/ms.\n", m);
1244 res = mpu6500_dmp_get_tap_thresh(&gs_handle, MPU6500_AXIS_Z, &m_check);
1245 if (res != 0)
1246 {
1247 mpu6500_interface_debug_print("mpu6500: dmp get tap thresh failed.\n");
1248 (void)mpu6500_deinit(&gs_handle);
1249
1250 return 1;
1251 }
1252 mpu6500_interface_debug_print("mpu6500: check tap thresh %s.\n", m_check == m ? "ok" : "error");
1253
1254 /* mpu6500_dmp_set_fifo_rate/mpu6500_dmp_get_fifo_rate test */
1255 mpu6500_interface_debug_print("mpu6500: mpu6500_dmp_set_fifo_rate/mpu6500_dmp_get_fifo_rate test.\n");
1256
1257 m = 50;
1258 res = mpu6500_dmp_set_fifo_rate(&gs_handle, m);
1259 if (res != 0)
1260 {
1261 mpu6500_interface_debug_print("mpu6500: dmp set fifo rate failed.\n");
1262 (void)mpu6500_deinit(&gs_handle);
1263
1264 return 1;
1265 }
1266 mpu6500_interface_debug_print("mpu6500: dmp set fifo rate %dHz.\n", m);
1267 res = mpu6500_dmp_get_fifo_rate(&gs_handle, &m_check);
1268 if (res != 0)
1269 {
1270 mpu6500_interface_debug_print("mpu6500: dmp get fifo rate failed.\n");
1271 (void)mpu6500_deinit(&gs_handle);
1272
1273 return 1;
1274 }
1275 mpu6500_interface_debug_print("mpu6500: check fifo rate %s.\n", m_check == m ? "ok" : "error");
1276
1277 /* mpu6500_dmp_set_gyro_calibrate test */
1278 mpu6500_interface_debug_print("mpu6500: mpu6500_dmp_set_gyro_calibrate test.\n");
1279
1280 /* enable gyro calibrate */
1282 if (res != 0)
1283 {
1284 mpu6500_interface_debug_print("mpu6500: dmp set gyro calibrate failed.\n");
1285 (void)mpu6500_deinit(&gs_handle);
1286
1287 return 1;
1288 }
1289 mpu6500_interface_debug_print("mpu6500: enable gyro calibrate.\n");
1290
1291 /* disable gyro calibrate */
1293 if (res != 0)
1294 {
1295 mpu6500_interface_debug_print("mpu6500: dmp set gyro calibrate failed.\n");
1296 (void)mpu6500_deinit(&gs_handle);
1297
1298 return 1;
1299 }
1300 mpu6500_interface_debug_print("mpu6500: disable gyro calibrate.\n");
1301
1302 /* mpu6500_dmp_set_3x_quaternion test */
1303 mpu6500_interface_debug_print("mpu6500: mpu6500_dmp_set_3x_quaternion test.\n");
1304
1305 /* enable 3x quaternion */
1307 if (res != 0)
1308 {
1309 mpu6500_interface_debug_print("mpu6500: dmp set 3x quaternion failed.\n");
1310 (void)mpu6500_deinit(&gs_handle);
1311
1312 return 1;
1313 }
1314 mpu6500_interface_debug_print("mpu6500: enable 3x quaternion.\n");
1315
1316 /* disable 3x quaternion */
1318 if (res != 0)
1319 {
1320 mpu6500_interface_debug_print("mpu6500: dmp set 3x quaternion failed.\n");
1321 (void)mpu6500_deinit(&gs_handle);
1322
1323 return 1;
1324 }
1325 mpu6500_interface_debug_print("mpu6500: disable 3x quaternion.\n");
1326
1327 /* mpu6500_dmp_set_6x_quaternion test */
1328 mpu6500_interface_debug_print("mpu6500: mpu6500_dmp_set_6x_quaternion test.\n");
1329
1330 /* enable 6x quaternion */
1332 if (res != 0)
1333 {
1334 mpu6500_interface_debug_print("mpu6500: dmp set 6x quaternion failed.\n");
1335 (void)mpu6500_deinit(&gs_handle);
1336
1337 return 1;
1338 }
1339 mpu6500_interface_debug_print("mpu6500: enable 6x quaternion.\n");
1340
1341 /* disable 6x quaternion */
1343 if (res != 0)
1344 {
1345 mpu6500_interface_debug_print("mpu6500: dmp set 6x quaternion failed.\n");
1346 (void)mpu6500_deinit(&gs_handle);
1347
1348 return 1;
1349 }
1350 mpu6500_interface_debug_print("mpu6500: disable 6x quaternion.\n");
1351
1352 /* mpu6500_dmp_set_interrupt_mode test */
1353 mpu6500_interface_debug_print("mpu6500: mpu6500_dmp_set_interrupt_mode test.\n");
1354
1355 /* gesture mode */
1357 if (res != 0)
1358 {
1359 mpu6500_interface_debug_print("mpu6500: dmp set interrupt mode failed.\n");
1360 (void)mpu6500_deinit(&gs_handle);
1361
1362 return 1;
1363 }
1364 mpu6500_interface_debug_print("mpu6500: dmp set gesture interrupt mode.\n");
1365
1366 /* continuous mode */
1368 if (res != 0)
1369 {
1370 mpu6500_interface_debug_print("mpu6500: dmp set interrupt mode failed.\n");
1371 (void)mpu6500_deinit(&gs_handle);
1372
1373 return 1;
1374 }
1375 mpu6500_interface_debug_print("mpu6500: dmp set gesture continuous mode.\n");
1376
1377 /* mpu6500_dmp_set_orientation test */
1378 mpu6500_interface_debug_print("mpu6500: mpu6500_dmp_set_orientation test.\n");
1379
1380 /* set the dmp orientation */
1381 res = mpu6500_dmp_set_orientation(&gs_handle, gyro_orientation);
1382 if (res != 0)
1383 {
1384 mpu6500_interface_debug_print("mpu6500: dmp set orientation failed.\n");
1385 (void)mpu6500_deinit(&gs_handle);
1386
1387 return 1;
1388 }
1389 mpu6500_interface_debug_print("mpu6500: set the dmp orientation.\n");
1390
1391 /* mpu6500_dmp_set_feature test */
1392 mpu6500_interface_debug_print("mpu6500: mpu6500_dmp_set_feature test.\n");
1393
1394 /* enable feature */
1398 if (res != 0)
1399 {
1400 mpu6500_interface_debug_print("mpu6500: dmp set feature failed.\n");
1401 (void)mpu6500_deinit(&gs_handle);
1402
1403 return 1;
1404 }
1405 mpu6500_interface_debug_print("mpu6500: enable feature 6x quat.\n");
1406 mpu6500_interface_debug_print("mpu6500: enable feature tap.\n");
1407 mpu6500_interface_debug_print("mpu6500: enable feature pedometer.\n");
1408 mpu6500_interface_debug_print("mpu6500: enable feature orient.\n");
1409 mpu6500_interface_debug_print("mpu6500: enable feature send raw accel.\n");
1410 mpu6500_interface_debug_print("mpu6500: enable feature send cal gyro.\n");
1411 mpu6500_interface_debug_print("mpu6500: enable feature gyro cal.\n");
1412
1413 /* dmp set tap callback */
1414 res = mpu6500_dmp_set_tap_callback(&gs_handle, a_dmp_tap_callback);
1415 if (res != 0)
1416 {
1417 mpu6500_interface_debug_print("mpu6500: dmp set tap callback failed.\n");
1418 (void)mpu6500_deinit(&gs_handle);
1419
1420 return 1;
1421 }
1422
1423 /* dmp set orient callback */
1424 res = mpu6500_dmp_set_orient_callback(&gs_handle, a_dmp_orient_callback);
1425 if (res != 0)
1426 {
1427 mpu6500_interface_debug_print("mpu6500: dmp set orient callback failed.\n");
1428 (void)mpu6500_deinit(&gs_handle);
1429
1430 return 1;
1431 }
1432
1433 /* dmp gyro accel raw offset convert */
1434 res = mpu6500_dmp_gyro_accel_raw_offset_convert(&gs_handle, gyro_offset_raw, accel_offset_raw,
1435 gyro_offset, accel_offset);
1436 if (res != 0)
1437 {
1438 mpu6500_interface_debug_print("mpu6500: dmp gyro accel raw offset convert failed.\n");
1439 (void)mpu6500_deinit(&gs_handle);
1440
1441 return 1;
1442 }
1443
1444 /* dmp set accel bias */
1445 res = mpu6500_dmp_set_accel_bias(&gs_handle, accel_offset);
1446 if (res != 0)
1447 {
1448 mpu6500_interface_debug_print("mpu6500: dmp set accel bias failed.\n");
1449 (void)mpu6500_deinit(&gs_handle);
1450
1451 return 1;
1452 }
1453
1454 /* dmp set gyro bias */
1455 res = mpu6500_dmp_set_gyro_bias(&gs_handle, gyro_offset);
1456 if (res != 0)
1457 {
1458 mpu6500_interface_debug_print("mpu6500: dmp set gyro bias failed.\n");
1459 (void)mpu6500_deinit(&gs_handle);
1460
1461 return 1;
1462 }
1463
1464 /* enable the dmp */
1465 res = mpu6500_dmp_set_enable(&gs_handle, MPU6500_BOOL_TRUE);
1466 if (res != 0)
1467 {
1468 mpu6500_interface_debug_print("mpu6500: dmp set enable failed.\n");
1469 (void)mpu6500_deinit(&gs_handle);
1470
1471 return 1;
1472 }
1473
1474 /* force reset the fifo */
1475 res = mpu6500_force_fifo_reset(&gs_handle);
1476 if (res != 0)
1477 {
1478 mpu6500_interface_debug_print("mpu6500: force fifo reset failed.\n");
1479 (void)mpu6500_deinit(&gs_handle);
1480
1481 return 1;
1482 }
1483
1484 /* delay 200 ms */
1486
1487 /* set 0 */
1488 gs_flag = 0;
1489
1490 for (i = 0; i < 1000; i++)
1491 {
1492 uint16_t l;
1493
1494 /* read the data */
1495 l = 128;
1496 res = mpu6500_dmp_read(&gs_handle,
1497 gs_accel_raw, gs_accel_g,
1498 gs_gyro_raw, gs_gyro_dps,
1499 gs_quat,
1500 gs_pitch, gs_roll, gs_yaw,
1501 &l
1502 );
1503 if (res != 0)
1504 {
1505 /* output data */
1506 mpu6500_interface_debug_print("mpu6500: dmp read failed.\n");
1507 }
1509
1510 /* check the flag */
1511 if ((gs_flag & 0x7) == 0x7)
1512 {
1513 break;
1514 }
1515 }
1516
1517 /* finish dmp tap orient motion test */
1518 mpu6500_interface_debug_print("mpu6500: finish dmp tap orient motion test.\n");
1519 (void)mpu6500_deinit(&gs_handle);
1520
1521 return 0;
1522}
driver mpu6500 dmp tap orient motion test header file
uint8_t mpu6500_set_motion_threshold(mpu6500_handle_t *handle, uint8_t threshold)
set the motion_threshold
uint8_t mpu6500_set_ptat(mpu6500_handle_t *handle, mpu6500_bool_t enable)
enable or disable the temperature sensor
uint8_t mpu6500_set_accelerometer_choice(mpu6500_handle_t *handle, uint8_t choice)
set the accelerometer choice
uint8_t mpu6500_set_interface(mpu6500_handle_t *handle, mpu6500_interface_t interface)
set the chip interface
mpu6500_address_t
mpu6500 address enumeration definition
uint8_t mpu6500_set_gyro_standby(mpu6500_handle_t *handle, mpu6500_bool_t enable)
enable or disable the gyro standby
struct mpu6500_info_s mpu6500_info_t
mpu6500 information structure definition
mpu6500_bool_t
mpu6500 bool enumeration definition
uint8_t mpu6500_set_addr_pin(mpu6500_handle_t *handle, mpu6500_address_t addr_pin)
set the chip address pin
uint8_t mpu6500_set_iic_bypass(mpu6500_handle_t *handle, mpu6500_bool_t enable)
enable or disable the iic bypass
uint8_t mpu6500_force_fifo_reset(mpu6500_handle_t *handle)
force reset the fifo
uint8_t mpu6500_set_accel_compare_with_previous_sample(mpu6500_handle_t *handle, mpu6500_bool_t enable)
enable or disable accel compare with previous sample
uint8_t mpu6500_set_fifo(mpu6500_handle_t *handle, mpu6500_bool_t enable)
enable or disable fifo
uint8_t mpu6500_set_interrupt_level(mpu6500_handle_t *handle, mpu6500_pin_level_t level)
set the interrupt level
uint8_t mpu6500_set_fsync_interrupt_level(mpu6500_handle_t *handle, mpu6500_pin_level_t level)
set the fsync interrupt level
struct mpu6500_handle_s mpu6500_handle_t
mpu6500 handle structure definition
uint8_t mpu6500_set_gyroscope_choice(mpu6500_handle_t *handle, uint8_t choice)
set the gyroscope choice
uint8_t mpu6500_set_fsync_interrupt(mpu6500_handle_t *handle, mpu6500_bool_t enable)
enable or disable the fsync interrupt
uint8_t mpu6500_set_sleep(mpu6500_handle_t *handle, mpu6500_bool_t enable)
enable or disable the sleep mode
uint8_t mpu6500_set_interrupt_latch(mpu6500_handle_t *handle, mpu6500_bool_t enable)
enable or disable the interrupt latch
uint8_t mpu6500_set_gyroscope_range(mpu6500_handle_t *handle, mpu6500_gyroscope_range_t range)
set the gyroscope range
uint8_t mpu6500_info(mpu6500_info_t *info)
get the chip's information
uint8_t mpu6500_set_clock_source(mpu6500_handle_t *handle, mpu6500_clock_source_t clock_source)
set the chip clock source
uint8_t mpu6500_set_wake_on_motion(mpu6500_handle_t *handle, mpu6500_bool_t enable)
enable or disable wake on motion
uint8_t mpu6500_set_interrupt_read_clear(mpu6500_handle_t *handle, mpu6500_bool_t enable)
enable or disable the interrupt reading clear
uint8_t mpu6500_set_interrupt(mpu6500_handle_t *handle, mpu6500_interrupt_t type, mpu6500_bool_t enable)
enable or disable the interrupt
uint8_t mpu6500_set_fifo_enable(mpu6500_handle_t *handle, mpu6500_fifo_t fifo, mpu6500_bool_t enable)
enable or disable the fifo function
uint8_t mpu6500_deinit(mpu6500_handle_t *handle)
close the chip
uint8_t mpu6500_set_low_pass_filter(mpu6500_handle_t *handle, mpu6500_low_pass_filter_t filter)
set the low pass filter
uint8_t mpu6500_irq_handler(mpu6500_handle_t *handle)
irq handler
uint8_t mpu6500_set_extern_sync(mpu6500_handle_t *handle, mpu6500_extern_sync_t sync)
set the extern sync type
uint8_t mpu6500_set_low_power_accel_output_rate(mpu6500_handle_t *handle, mpu6500_low_power_accel_output_rate_t rate)
set the low power accel output rate
uint8_t mpu6500_set_fifo_mode(mpu6500_handle_t *handle, mpu6500_fifo_mode mode)
set the fifo mode
uint8_t mpu6500_set_disable_iic_slave(mpu6500_handle_t *handle, mpu6500_bool_t enable)
enable or disable the iic slave mode
uint8_t mpu6500_set_iic_master(mpu6500_handle_t *handle, mpu6500_bool_t enable)
enable or disable the iic master mode
uint8_t mpu6500_set_cycle_wake_up(mpu6500_handle_t *handle, mpu6500_bool_t enable)
enable or disable the cycle wake up mode
uint8_t mpu6500_motion_threshold_convert_to_register(mpu6500_handle_t *handle, float mg, uint8_t *reg)
convert the motion threshold to the register raw data
uint8_t mpu6500_init(mpu6500_handle_t *handle)
initialize the chip
uint8_t mpu6500_set_accelerometer_range(mpu6500_handle_t *handle, mpu6500_accelerometer_range_t range)
set the accelerometer range
uint8_t mpu6500_set_accelerometer_test(mpu6500_handle_t *handle, mpu6500_axis_t axis, mpu6500_bool_t enable)
set the accelerometer test
mpu6500_interface_t
mpu6500 interface enumeration definition
uint8_t mpu6500_set_fifo_1024kb(mpu6500_handle_t *handle)
set fifo 1024kb
uint8_t mpu6500_set_standby_mode(mpu6500_handle_t *handle, mpu6500_source_t source, mpu6500_bool_t enable)
set source into standby mode
uint8_t mpu6500_set_accelerometer_low_pass_filter(mpu6500_handle_t *handle, mpu6500_accelerometer_low_pass_filter_t filter)
set the accelerometer low pass filter
uint8_t mpu6500_set_interrupt_pin_type(mpu6500_handle_t *handle, mpu6500_pin_type_t type)
set the interrupt pin type
uint8_t mpu6500_set_gyroscope_test(mpu6500_handle_t *handle, mpu6500_axis_t axis, mpu6500_bool_t enable)
set the gyroscope test
uint8_t mpu6500_self_test(mpu6500_handle_t *handle, int32_t gyro_offset_raw[3], int32_t accel_offset_raw[3])
run the self test
uint8_t mpu6500_set_sample_rate_divider(mpu6500_handle_t *handle, uint8_t d)
set the sample rate divider
@ MPU6500_ACCELEROMETER_LOW_PASS_FILTER_3
@ MPU6500_BOOL_FALSE
@ MPU6500_BOOL_TRUE
@ MPU6500_PIN_LEVEL_LOW
@ MPU6500_INTERRUPT_DATA_READY
@ MPU6500_INTERRUPT_FIFO_OVERFLOW
@ MPU6500_INTERRUPT_MOTION
@ MPU6500_INTERRUPT_FSYNC_INT
@ MPU6500_INTERRUPT_DMP
@ MPU6500_CLOCK_SOURCE_PLL
@ MPU6500_GYROSCOPE_RANGE_2000DPS
@ MPU6500_SOURCE_ACC_Y
@ MPU6500_SOURCE_GYRO_X
@ MPU6500_SOURCE_GYRO_Y
@ MPU6500_SOURCE_ACC_X
@ MPU6500_SOURCE_ACC_Z
@ MPU6500_SOURCE_GYRO_Z
@ MPU6500_AXIS_Y
@ MPU6500_AXIS_Z
@ MPU6500_AXIS_X
@ MPU6500_FIFO_MODE_NORMAL
@ MPU6500_EXTERN_SYNC_INPUT_DISABLED
@ MPU6500_LOW_POWER_ACCEL_OUTPUT_RATE_62P50
@ MPU6500_FIFO_TEMP
@ MPU6500_FIFO_YG
@ MPU6500_FIFO_ZG
@ MPU6500_FIFO_ACCEL
@ MPU6500_FIFO_XG
@ MPU6500_ACCELEROMETER_RANGE_2G
@ MPU6500_PIN_TYPE_PUSH_PULL
@ MPU6500_INTERFACE_SPI
@ MPU6500_LOW_PASS_FILTER_3
uint8_t mpu6500_dmp_set_tap_time(mpu6500_handle_t *handle, uint16_t ms)
dmp set the tap time
uint8_t mpu6500_dmp_get_shake_reject_thresh(mpu6500_handle_t *handle, uint16_t *dps)
dmp get the shake reject thresh
uint8_t mpu6500_dmp_get_tap_time(mpu6500_handle_t *handle, uint16_t *ms)
dmp get the tap time
uint8_t mpu6500_dmp_get_fifo_rate(mpu6500_handle_t *handle, uint16_t *rate)
dmp get the fifo rate
uint8_t mpu6500_dmp_set_accel_bias(mpu6500_handle_t *handle, int32_t bias[3])
dmp set the accel bias
uint8_t mpu6500_dmp_get_min_tap_count(mpu6500_handle_t *handle, uint8_t *cnt)
dmp get the min tap count
uint8_t mpu6500_dmp_set_gyro_bias(mpu6500_handle_t *handle, int32_t bias[3])
dmp set the gyro bias
uint8_t mpu6500_dmp_gyro_accel_raw_offset_convert(mpu6500_handle_t *handle, int32_t gyro_offset_raw[3], int32_t accel_offset_raw[3], int32_t gyro_offset[3], int32_t accel_offset[3])
dmp gyro accel raw offset convert
uint8_t mpu6500_dmp_set_tap_thresh(mpu6500_handle_t *handle, mpu6500_axis_t axis, uint16_t mg_ms)
dmp set the tap thresh
uint8_t mpu6500_dmp_set_shake_reject_time(mpu6500_handle_t *handle, uint16_t ms)
dmp set the shake reject time
uint8_t mpu6500_dmp_set_min_tap_count(mpu6500_handle_t *handle, uint8_t cnt)
dmp set the min tap count
uint8_t mpu6500_dmp_set_fifo_rate(mpu6500_handle_t *handle, uint16_t rate)
dmp set the fifo rate
uint8_t mpu6500_dmp_set_orient_callback(mpu6500_handle_t *handle, void(*callback)(uint8_t orientation))
dmp set the orient callback
uint8_t mpu6500_dmp_read(mpu6500_handle_t *handle, int16_t(*accel_raw)[3], float(*accel_g)[3], int16_t(*gyro_raw)[3], float(*gyro_dps)[3], int32_t(*quat)[4], float *pitch, float *roll, float *yaw, uint16_t *l)
dmp read the data
uint8_t mpu6500_dmp_set_shake_reject_timeout(mpu6500_handle_t *handle, uint16_t ms)
dmp set the shake reject timeout
uint8_t mpu6500_dmp_get_shake_reject_timeout(mpu6500_handle_t *handle, uint16_t *ms)
dmp get the shake reject timeout
uint8_t mpu6500_dmp_set_tap_callback(mpu6500_handle_t *handle, void(*callback)(uint8_t count, uint8_t direction))
dmp set the tap callback
uint8_t mpu6500_dmp_get_tap_axes(mpu6500_handle_t *handle, mpu6500_axis_t axis, mpu6500_bool_t *enable)
dmp get the tap axes status
uint8_t mpu6500_dmp_set_pedometer_step_count(mpu6500_handle_t *handle, uint32_t count)
dmp set the pedometer step count
uint8_t mpu6500_dmp_set_tap_axes(mpu6500_handle_t *handle, mpu6500_axis_t axis, mpu6500_bool_t enable)
dmp enable or disable the tap axes
uint8_t mpu6500_dmp_get_shake_reject_time(mpu6500_handle_t *handle, uint16_t *ms)
dmp get the shake reject time
uint8_t mpu6500_dmp_load_firmware(mpu6500_handle_t *handle)
load the dmp firmware
uint8_t mpu6500_dmp_get_pedometer_walk_time(mpu6500_handle_t *handle, uint32_t *ms)
dmp get the pedometer walk time
uint8_t mpu6500_dmp_set_feature(mpu6500_handle_t *handle, uint16_t mask)
dmp enable or disable the dmp feature
uint8_t mpu6500_dmp_set_gyro_calibrate(mpu6500_handle_t *handle, mpu6500_bool_t enable)
dmp enable or disable gyro calibrate
uint8_t mpu6500_dmp_get_tap_time_multi(mpu6500_handle_t *handle, uint16_t *ms)
dmp get max time between taps to register as a multi tap
uint8_t mpu6500_dmp_get_tap_thresh(mpu6500_handle_t *handle, mpu6500_axis_t axis, uint16_t *mg_ms)
dmp get the tap thresh
uint8_t mpu6500_dmp_set_orientation(mpu6500_handle_t *handle, int8_t mat[9])
dmp set the orientation
uint8_t mpu6500_dmp_set_pedometer_walk_time(mpu6500_handle_t *handle, uint32_t ms)
dmp set the pedometer walk time
uint8_t mpu6500_dmp_set_interrupt_mode(mpu6500_handle_t *handle, mpu6500_dmp_interrupt_mode_t mode)
dmp set the interrupt mode
uint8_t mpu6500_dmp_set_tap_time_multi(mpu6500_handle_t *handle, uint16_t ms)
dmp set max time between taps to register as a multi tap
uint8_t mpu6500_dmp_set_shake_reject_thresh(mpu6500_handle_t *handle, uint16_t dps)
dmp set the shake reject thresh
uint8_t mpu6500_dmp_set_enable(mpu6500_handle_t *handle, mpu6500_bool_t enable)
enable or disable the dmp
uint8_t mpu6500_dmp_set_6x_quaternion(mpu6500_handle_t *handle, mpu6500_bool_t enable)
dmp enable or disable generate 6 axis quaternions from dmp
uint8_t mpu6500_dmp_set_3x_quaternion(mpu6500_handle_t *handle, mpu6500_bool_t enable)
dmp enable or disable generate 3 axis quaternions from dmp
uint8_t mpu6500_dmp_get_pedometer_step_count(mpu6500_handle_t *handle, uint32_t *count)
dmp get the pedometer step count
@ MPU6500_DMP_ORIENT_REVERSE_LANDSCAPE
@ MPU6500_DMP_ORIENT_LANDSCAPE
@ MPU6500_DMP_ORIENT_REVERSE_PORTRAIT
@ MPU6500_DMP_ORIENT_PORTRAIT
@ MPU6500_DMP_FEATURE_GYRO_CAL
@ MPU6500_DMP_FEATURE_PEDOMETER
@ MPU6500_DMP_FEATURE_SEND_CAL_GYRO
@ MPU6500_DMP_FEATURE_TAP
@ MPU6500_DMP_FEATURE_ORIENT
@ MPU6500_DMP_FEATURE_SEND_RAW_ACCEL
@ MPU6500_DMP_FEATURE_6X_QUAT
@ MPU6500_DMP_INTERRUPT_MODE_GESTURE
@ MPU6500_DMP_INTERRUPT_MODE_CONTINUOUS
@ MPU6500_DMP_TAP_Y_UP
@ MPU6500_DMP_TAP_Y_DOWN
@ MPU6500_DMP_TAP_Z_UP
@ MPU6500_DMP_TAP_X_DOWN
@ MPU6500_DMP_TAP_Z_DOWN
@ MPU6500_DMP_TAP_X_UP
uint8_t mpu6500_interface_spi_deinit(void)
interface spi bus deinit
void mpu6500_interface_delay_ms(uint32_t ms)
interface delay ms
uint8_t mpu6500_interface_iic_init(void)
interface iic bus init
uint8_t mpu6500_interface_iic_write(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
interface iic bus write
uint8_t mpu6500_interface_iic_deinit(void)
interface iic bus deinit
uint8_t mpu6500_interface_spi_init(void)
interface spi bus init
uint8_t mpu6500_interface_spi_read(uint8_t reg, uint8_t *buf, uint16_t len)
interface spi bus read
void mpu6500_interface_debug_print(const char *const fmt,...)
interface print format data
uint8_t mpu6500_interface_iic_read(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
interface iic bus read
uint8_t mpu6500_interface_spi_write(uint8_t reg, uint8_t *buf, uint16_t len)
interface spi bus write
uint8_t mpu6500_dmp_tap_orient_motion_test(mpu6500_interface_t interface, mpu6500_address_t addr)
dmp test
uint8_t mpu6500_dmp_tap_orient_motion_test_irq_handler(void)
dmp tap orient motion test irq
uint32_t driver_version
char manufacturer_name[32]