LibDriver MPU6050
Loading...
Searching...
No Matches
driver_mpu6050_dmp_tap_orient_motion_test.c
Go to the documentation of this file.
1
36
38#include <stdlib.h>
39
40static mpu6050_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 (mpu6050_irq_handler(&gs_handle) != 0)
61 {
62 return 1;
63 }
64 else
65 {
66 return 0;
67 }
68}
69
75static void a_receive_callback(uint8_t type)
76{
77 switch (type)
78 {
80 {
81 gs_flag |= 1 << 0;
82 mpu6050_interface_debug_print("mpu6050: irq motion.\n");
83
84 break;
85 }
87 {
88 mpu6050_interface_debug_print("mpu6050: irq fifo overflow.\n");
89
90 break;
91 }
93 {
94 mpu6050_interface_debug_print("mpu6050: irq i2c master.\n");
95
96 break;
97 }
99 {
100 mpu6050_interface_debug_print("mpu6050: irq dmp\n");
101
102 break;
103 }
105 {
106 mpu6050_interface_debug_print("mpu6050: irq data ready\n");
107
108 break;
109 }
110 default :
111 {
112 mpu6050_interface_debug_print("mpu6050: irq unknown code.\n");
113
114 break;
115 }
116 }
117}
118
125static void a_dmp_tap_callback(uint8_t count, uint8_t direction)
126{
127 switch (direction)
128 {
130 {
131 gs_flag |= 1 << 1;
132 mpu6050_interface_debug_print("mpu6050: tap irq x up with %d.\n", count);
133
134 break;
135 }
137 {
138 gs_flag |= 1 << 1;
139 mpu6050_interface_debug_print("mpu6050: tap irq x down with %d.\n", count);
140
141 break;
142 }
144 {
145 gs_flag |= 1 << 1;
146 mpu6050_interface_debug_print("mpu6050: tap irq y up with %d.\n", count);
147
148 break;
149 }
151 {
152 gs_flag |= 1 << 1;
153 mpu6050_interface_debug_print("mpu6050: tap irq y down with %d.\n", count);
154
155 break;
156 }
158 {
159 gs_flag |= 1 << 1;
160 mpu6050_interface_debug_print("mpu6050: tap irq z up with %d.\n", count);
161
162 break;
163 }
165 {
166 gs_flag |= 1 << 1;
167 mpu6050_interface_debug_print("mpu6050: tap irq z down with %d.\n", count);
168
169 break;
170 }
171 default :
172 {
173 mpu6050_interface_debug_print("mpu6050: tap irq unknown code.\n");
174
175 break;
176 }
177 }
178}
179
185static void a_dmp_orient_callback(uint8_t orientation)
186{
187 switch (orientation)
188 {
190 {
191 gs_flag |= 1 << 2;
192 mpu6050_interface_debug_print("mpu6050: orient irq portrait.\n");
193
194 break;
195 }
197 {
198 gs_flag |= 1 << 2;
199 mpu6050_interface_debug_print("mpu6050: orient irq landscape.\n");
200
201 break;
202 }
204 {
205 gs_flag |= 1 << 2;
206 mpu6050_interface_debug_print("mpu6050: orient irq reverse portrait.\n");
207
208 break;
209 }
211 {
212 gs_flag |= 1 << 2;
213 mpu6050_interface_debug_print("mpu6050: orient irq reverse landscape.\n");
214
215 break;
216 }
217 default :
218 {
219 mpu6050_interface_debug_print("mpu6050: orient irq unknown code.\n");
220
221 break;
222 }
223 }
224}
225
235{
236 uint8_t res;
237 uint8_t reg;
238 uint32_t ms;
239 uint32_t ms_check;
240 uint32_t cnt;
241 uint32_t cnt_check;
242 uint32_t i;
243 uint16_t m;
244 uint16_t m_check;
245 uint8_t c;
246 uint8_t c_check;
247 int32_t gyro_offset_raw[3];
248 int32_t accel_offset_raw[3];
249 int32_t gyro_offset[3];
250 int32_t accel_offset[3];
251 mpu6050_bool_t enable;
252 mpu6050_info_t info;
253 int8_t gyro_orientation[9] = {1, 0, 0,
254 0, 1, 0,
255 0, 0, 1};
256
257 /* link interface function */
265 DRIVER_MPU6050_LINK_RECEIVE_CALLBACK(&gs_handle, a_receive_callback);
266
267 /* get information */
268 res = mpu6050_info(&info);
269 if (res != 0)
270 {
271 mpu6050_interface_debug_print("mpu6050: get info failed.\n");
272
273 return 1;
274 }
275 else
276 {
277 /* print chip info */
278 mpu6050_interface_debug_print("mpu6050: chip is %s.\n", info.chip_name);
279 mpu6050_interface_debug_print("mpu6050: manufacturer is %s.\n", info.manufacturer_name);
280 mpu6050_interface_debug_print("mpu6050: interface is %s.\n", info.interface);
281 mpu6050_interface_debug_print("mpu6050: driver version is %d.%d.\n", info.driver_version / 1000, (info.driver_version % 1000) / 100);
282 mpu6050_interface_debug_print("mpu6050: min supply voltage is %0.1fV.\n", info.supply_voltage_min_v);
283 mpu6050_interface_debug_print("mpu6050: max supply voltage is %0.1fV.\n", info.supply_voltage_max_v);
284 mpu6050_interface_debug_print("mpu6050: max current is %0.2fmA.\n", info.max_current_ma);
285 mpu6050_interface_debug_print("mpu6050: max temperature is %0.1fC.\n", info.temperature_max);
286 mpu6050_interface_debug_print("mpu6050: min temperature is %0.1fC.\n", info.temperature_min);
287 }
288
289 /* start dmp tap orient motion test */
290 mpu6050_interface_debug_print("mpu6050: start dmp tap orient motion test.\n");
291
292 /* set the addr pin */
293 res = mpu6050_set_addr_pin(&gs_handle, addr);
294 if (res != 0)
295 {
296 mpu6050_interface_debug_print("mpu6050: set addr pin failed.\n");
297
298 return 1;
299 }
300
301 /* init */
302 res = mpu6050_init(&gs_handle);
303 if (res != 0)
304 {
305 mpu6050_interface_debug_print("mpu6050: init failed.\n");
306
307 return 1;
308 }
309
310 /* delay 100 ms */
312
313 /* disable sleep */
314 res = mpu6050_set_sleep(&gs_handle, MPU6050_BOOL_FALSE);
315 if (res != 0)
316 {
317 mpu6050_interface_debug_print("mpu6050: set sleep failed.\n");
318 (void)mpu6050_deinit(&gs_handle);
319
320 return 1;
321 }
322
323 /* run the self test */
324 res = mpu6050_self_test(&gs_handle, gyro_offset_raw, accel_offset_raw);
325 if (res != 0)
326 {
327 mpu6050_interface_debug_print("mpu6050: self test failed.\n");
328 (void)mpu6050_deinit(&gs_handle);
329
330 return 1;
331 }
332
333 /* set pll x */
335 if (res != 0)
336 {
337 mpu6050_interface_debug_print("mpu6050: set clock source failed.\n");
338 (void)mpu6050_deinit(&gs_handle);
339
340 return 1;
341 }
342
343 /* set 50Hz */
344 res = mpu6050_set_sample_rate_divider(&gs_handle, (1000 / 50) - 1);
345 if (res != 0)
346 {
347 mpu6050_interface_debug_print("mpu6050: set sample rate divider failed.\n");
348 (void)mpu6050_deinit(&gs_handle);
349
350 return 1;
351 }
352
353 /* ±2g */
355 if (res != 0)
356 {
357 mpu6050_interface_debug_print("mpu6050: set accelerometer range failed.\n");
358 (void)mpu6050_deinit(&gs_handle);
359
360 return 1;
361 }
362
363 /* ±2000dps */
365 if (res != 0)
366 {
367 mpu6050_interface_debug_print("mpu6050: set gyroscope range failed.\n");
368 (void)mpu6050_deinit(&gs_handle);
369
370 return 1;
371 }
372
373 /* set low pass filter 3 */
375 if (res != 0)
376 {
377 mpu6050_interface_debug_print("mpu6050: set low pass filter failed.\n");
378 (void)mpu6050_deinit(&gs_handle);
379
380 return 1;
381 }
382
383 /* enable temperature sensor */
385 if (res != 0)
386 {
387 mpu6050_interface_debug_print("mpu6050: set temperature sensor failed.\n");
388 (void)mpu6050_deinit(&gs_handle);
389
390 return 1;
391 }
392
393 /* disable cycle wake up */
395 if (res != 0)
396 {
397 mpu6050_interface_debug_print("mpu6050: set cycle wake up failed.\n");
398 (void)mpu6050_deinit(&gs_handle);
399
400 return 1;
401 }
402
403 /* set wake up frequency 1.25Hz */
405 if (res != 0)
406 {
407 mpu6050_interface_debug_print("mpu6050: set wake up frequency failed.\n");
408 (void)mpu6050_deinit(&gs_handle);
409
410 return 1;
411 }
412
413 /* enable acc x */
415 if (res != 0)
416 {
417 mpu6050_interface_debug_print("mpu6050: set standby mode failed.\n");
418 (void)mpu6050_deinit(&gs_handle);
419
420 return 1;
421 }
422
423 /* enable acc y */
425 if (res != 0)
426 {
427 mpu6050_interface_debug_print("mpu6050: set standby mode failed.\n");
428 (void)mpu6050_deinit(&gs_handle);
429
430 return 1;
431 }
432
433 /* enable acc z */
435 if (res != 0)
436 {
437 mpu6050_interface_debug_print("mpu6050: set standby mode failed.\n");
438 (void)mpu6050_deinit(&gs_handle);
439
440 return 1;
441 }
442
443 /* enable gyro x */
445 if (res != 0)
446 {
447 mpu6050_interface_debug_print("mpu6050: set standby mode failed.\n");
448 (void)mpu6050_deinit(&gs_handle);
449
450 return 1;
451 }
452
453 /* enable gyro y */
455 if (res != 0)
456 {
457 mpu6050_interface_debug_print("mpu6050: set standby mode failed.\n");
458 (void)mpu6050_deinit(&gs_handle);
459
460 return 1;
461 }
462
463 /* enable gyro z */
465 if (res != 0)
466 {
467 mpu6050_interface_debug_print("mpu6050: set standby mode failed.\n");
468 (void)mpu6050_deinit(&gs_handle);
469
470 return 1;
471 }
472
473 /* disable gyroscope x test */
475 if (res != 0)
476 {
477 mpu6050_interface_debug_print("mpu6050: set gyroscope test failed.\n");
478 (void)mpu6050_deinit(&gs_handle);
479
480 return 1;
481 }
482
483 /* disable gyroscope y test */
485 if (res != 0)
486 {
487 mpu6050_interface_debug_print("mpu6050: set gyroscope test failed.\n");
488 (void)mpu6050_deinit(&gs_handle);
489
490 return 1;
491 }
492
493 /* disable gyroscope z test */
495 if (res != 0)
496 {
497 mpu6050_interface_debug_print("mpu6050: set gyroscope test failed.\n");
498 (void)mpu6050_deinit(&gs_handle);
499
500 return 1;
501 }
502
503 /* disable accelerometer x test */
505 if (res != 0)
506 {
507 mpu6050_interface_debug_print("mpu6050: set accelerometer test failed.\n");
508 (void)mpu6050_deinit(&gs_handle);
509
510 return 1;
511 }
512
513 /* disable accelerometer y test */
515 if (res != 0)
516 {
517 mpu6050_interface_debug_print("mpu6050: set accelerometer test failed.\n");
518 (void)mpu6050_deinit(&gs_handle);
519
520 return 1;
521 }
522
523 /* disable accelerometer z test */
525 if (res != 0)
526 {
527 mpu6050_interface_debug_print("mpu6050: set accelerometer test failed.\n");
528 (void)mpu6050_deinit(&gs_handle);
529
530 return 1;
531 }
532
533 /* disable temp fifo */
535 if (res != 0)
536 {
537 mpu6050_interface_debug_print("mpu6050: set fifo enable failed.\n");
538 (void)mpu6050_deinit(&gs_handle);
539
540 return 1;
541 }
542
543 /* disable xg fifo */
545 if (res != 0)
546 {
547 mpu6050_interface_debug_print("mpu6050: set fifo enable failed.\n");
548 (void)mpu6050_deinit(&gs_handle);
549
550 return 1;
551 }
552
553 /* disable yg fifo */
555 if (res != 0)
556 {
557 mpu6050_interface_debug_print("mpu6050: set fifo enable failed.\n");
558 (void)mpu6050_deinit(&gs_handle);
559
560 return 1;
561 }
562
563 /* disable zg fifo */
565 if (res != 0)
566 {
567 mpu6050_interface_debug_print("mpu6050: set fifo enable failed.\n");
568 (void)mpu6050_deinit(&gs_handle);
569
570 return 1;
571 }
572
573 /* disable accel fifo */
575 if (res != 0)
576 {
577 mpu6050_interface_debug_print("mpu6050: set fifo enable failed.\n");
578 (void)mpu6050_deinit(&gs_handle);
579
580 return 1;
581 }
582
583 /* enable fifo */
584 res = mpu6050_set_fifo(&gs_handle, MPU6050_BOOL_TRUE);
585 if (res != 0)
586 {
587 mpu6050_interface_debug_print("mpu6050: set fifo failed.\n");
588 (void)mpu6050_deinit(&gs_handle);
589
590 return 1;
591 }
592
593 /* set interrupt level low */
595 if (res != 0)
596 {
597 mpu6050_interface_debug_print("mpu6050: set interrupt level failed.\n");
598 (void)mpu6050_deinit(&gs_handle);
599
600 return 1;
601 }
602
603 /* push pull */
605 if (res != 0)
606 {
607 mpu6050_interface_debug_print("mpu6050: set interrupt pin type failed.\n");
608 (void)mpu6050_deinit(&gs_handle);
609
610 return 1;
611 }
612
613 /* set 200mg */
614 res = mpu6050_motion_threshold_convert_to_register(&gs_handle, 200.0f, &reg);
615 if (res != 0)
616 {
617 mpu6050_interface_debug_print("mpu6050: motion threshold convert to register failed.\n");
618 (void)mpu6050_deinit(&gs_handle);
619
620 return 1;
621 }
622
623 /* set the motion threshold */
624 res = mpu6050_set_motion_threshold(&gs_handle, reg);
625 if (res != 0)
626 {
627 mpu6050_interface_debug_print("mpu6050: set motion threshold failed.\n");
628 (void)mpu6050_deinit(&gs_handle);
629
630 return 1;
631 }
632
633 /* 200ms */
634 res = mpu6050_motion_duration_convert_to_register(&gs_handle, 200, &reg);
635 if (res != 0)
636 {
637 mpu6050_interface_debug_print("mpu6050: motion duration convert to register failed.\n");
638 (void)mpu6050_deinit(&gs_handle);
639
640 return 1;
641 }
642
643 /* set the motion duration */
644 res = mpu6050_set_motion_duration(&gs_handle, reg);
645 if (res != 0)
646 {
647 mpu6050_interface_debug_print("mpu6050: set motion duration failed.\n");
648 (void)mpu6050_deinit(&gs_handle);
649
650 return 1;
651 }
652
653 /* enable the force accel sample */
655 if (res != 0)
656 {
657 mpu6050_interface_debug_print("mpu6050: set force accel sample failed.\n");
658 (void)mpu6050_deinit(&gs_handle);
659
660 return 1;
661 }
662
663 /* enable motion */
665 if (res != 0)
666 {
667 mpu6050_interface_debug_print("mpu6050: set interrupt failed.\n");
668 (void)mpu6050_deinit(&gs_handle);
669
670 return 1;
671 }
672
673 /* enable fifo overflow */
675 if (res != 0)
676 {
677 mpu6050_interface_debug_print("mpu6050: set interrupt failed.\n");
678 (void)mpu6050_deinit(&gs_handle);
679
680 return 1;
681 }
682
683 /* disable dmp interrupt */
685 if (res != 0)
686 {
687 mpu6050_interface_debug_print("mpu6050: set interrupt failed.\n");
688 (void)mpu6050_deinit(&gs_handle);
689
690 return 1;
691 }
692
693 /* disable i2c master */
695 if (res != 0)
696 {
697 mpu6050_interface_debug_print("mpu6050: set interrupt failed.\n");
698 (void)mpu6050_deinit(&gs_handle);
699
700 return 1;
701 }
702
703 /* disable data ready */
705 if (res != 0)
706 {
707 mpu6050_interface_debug_print("mpu6050: set interrupt failed.\n");
708 (void)mpu6050_deinit(&gs_handle);
709
710 return 1;
711 }
712
713 /* enable latch */
715 if (res != 0)
716 {
717 mpu6050_interface_debug_print("mpu6050: set interrupt latch failed.\n");
718 (void)mpu6050_deinit(&gs_handle);
719
720 return 1;
721 }
722
723 /* enable interrupt read clear */
725 if (res != 0)
726 {
727 mpu6050_interface_debug_print("mpu6050: set interrupt read clear failed.\n");
728 (void)mpu6050_deinit(&gs_handle);
729
730 return 1;
731 }
732
733 /* disable sync input */
735 if (res != 0)
736 {
737 mpu6050_interface_debug_print("mpu6050: set extern sync failed.\n");
738 (void)mpu6050_deinit(&gs_handle);
739
740 return 1;
741 }
742
743 /* disable fsync interrupt */
745 if (res != 0)
746 {
747 mpu6050_interface_debug_print("mpu6050: set fsync interrupt failed.\n");
748 (void)mpu6050_deinit(&gs_handle);
749
750 return 1;
751 }
752
753 /* fsync interrupt level low */
755 if (res != 0)
756 {
757 mpu6050_interface_debug_print("mpu6050: set fsync interrupt level failed.\n");
758 (void)mpu6050_deinit(&gs_handle);
759
760 return 1;
761 }
762
763 /* disable iic master */
765 if (res != 0)
766 {
767 mpu6050_interface_debug_print("mpu6050: set iic master failed.\n");
768 (void)mpu6050_deinit(&gs_handle);
769
770 return 1;
771 }
772
773 /* disable iic bypass */
775 if (res != 0)
776 {
777 mpu6050_interface_debug_print("mpu6050: set iic bypass failed.\n");
778 (void)mpu6050_deinit(&gs_handle);
779
780 return 1;
781 }
782
783 /* load dmp firmware */
784 mpu6050_interface_debug_print("mpu6050: load dmp firmware.\n");
785
786 /* dmp load firmware */
787 res = mpu6050_dmp_load_firmware(&gs_handle);
788 if (res != 0)
789 {
790 mpu6050_interface_debug_print("mpu6050: dmp load firmware failed.\n");
791 (void)mpu6050_deinit(&gs_handle);
792
793 return 1;
794 }
795
796 /* load dmp firmware successful */
797 mpu6050_interface_debug_print("mpu6050: load dmp firmware successful .\n");
798
799 /* mpu6050_dmp_set_pedometer_walk_time/mpu6050_dmp_get_pedometer_walk_time test */
800 mpu6050_interface_debug_print("mpu6050: mpu6050_dmp_set_pedometer_walk_time/mpu6050_dmp_get_pedometer_walk_time test.\n");
801
802 ms = 200;
803 res = mpu6050_dmp_set_pedometer_walk_time(&gs_handle, ms);
804 if (res != 0)
805 {
806 mpu6050_interface_debug_print("mpu6050: dmp set pedometer walk time failed.\n");
807 (void)mpu6050_deinit(&gs_handle);
808
809 return 1;
810 }
811 mpu6050_interface_debug_print("mpu6050: dmp set pedometer walk time %d ms.\n", ms);
812 res = mpu6050_dmp_get_pedometer_walk_time(&gs_handle, &ms_check);
813 if (res != 0)
814 {
815 mpu6050_interface_debug_print("mpu6050: dmp get pedometer walk time failed.\n");
816 (void)mpu6050_deinit(&gs_handle);
817
818 return 1;
819 }
820 mpu6050_interface_debug_print("mpu6050: check pedometer walk time %s.\n", ms_check == ms ? "ok" : "error");
821
822 /* mpu6050_dmp_set_pedometer_step_count/mpu6050_dmp_get_pedometer_step_count test */
823 mpu6050_interface_debug_print("mpu6050: mpu6050_dmp_set_pedometer_step_count/mpu6050_dmp_get_pedometer_step_count test.\n");
824
825 cnt = rand() % 1000;
826 res = mpu6050_dmp_set_pedometer_step_count(&gs_handle, cnt);
827 if (res != 0)
828 {
829 mpu6050_interface_debug_print("mpu6050: dmp set pedometer step count failed.\n");
830 (void)mpu6050_deinit(&gs_handle);
831
832 return 1;
833 }
834 mpu6050_interface_debug_print("mpu6050: dmp set pedometer step count %d.\n", cnt);
835 res = mpu6050_dmp_get_pedometer_step_count(&gs_handle, &cnt_check);
836 if (res != 0)
837 {
838 mpu6050_interface_debug_print("mpu6050: dmp get pedometer step count failed.\n");
839 (void)mpu6050_deinit(&gs_handle);
840
841 return 1;
842 }
843 mpu6050_interface_debug_print("mpu6050: check pedometer step count %s.\n", cnt_check == cnt ? "ok" : "error");
844
845 /* mpu6050_dmp_set_shake_reject_timeout/mpu6050_dmp_get_shake_reject_timeout test */
846 mpu6050_interface_debug_print("mpu6050: mpu6050_dmp_set_shake_reject_timeout/mpu6050_dmp_get_shake_reject_timeout test.\n");
847
848 m = 10;
849 res = mpu6050_dmp_set_shake_reject_timeout(&gs_handle, m);
850 if (res != 0)
851 {
852 mpu6050_interface_debug_print("mpu6050: dmp set shake reject timeout failed.\n");
853 (void)mpu6050_deinit(&gs_handle);
854
855 return 1;
856 }
857 mpu6050_interface_debug_print("mpu6050: dmp set shake reject timeout %d ms.\n", m);
858 res = mpu6050_dmp_get_shake_reject_timeout(&gs_handle, &m_check);
859 if (res != 0)
860 {
861 mpu6050_interface_debug_print("mpu6050: dmp get shake reject timeout failed.\n");
862 (void)mpu6050_deinit(&gs_handle);
863
864 return 1;
865 }
866 mpu6050_interface_debug_print("mpu6050: check shake reject timeout %s.\n", m_check == m ? "ok" : "error");
867
868 /* mpu6050_dmp_set_shake_reject_time/mpu6050_dmp_get_shake_reject_time test */
869 mpu6050_interface_debug_print("mpu6050: mpu6050_dmp_set_shake_reject_time/mpu6050_dmp_get_shake_reject_time test.\n");
870
871 m = 40;
872 res = mpu6050_dmp_set_shake_reject_time(&gs_handle, m);
873 if (res != 0)
874 {
875 mpu6050_interface_debug_print("mpu6050: dmp set shake reject time failed.\n");
876 (void)mpu6050_deinit(&gs_handle);
877
878 return 1;
879 }
880 mpu6050_interface_debug_print("mpu6050: dmp set shake reject time %d ms.\n", m);
881 res = mpu6050_dmp_get_shake_reject_time(&gs_handle, &m_check);
882 if (res != 0)
883 {
884 mpu6050_interface_debug_print("mpu6050: dmp get shake reject time failed.\n");
885 (void)mpu6050_deinit(&gs_handle);
886
887 return 1;
888 }
889 mpu6050_interface_debug_print("mpu6050: check shake reject time %s.\n", m_check == m ? "ok" : "error");
890
891 /* mpu6050_dmp_set_shake_reject_thresh/mpu6050_dmp_get_shake_reject_thresh test */
892 mpu6050_interface_debug_print("mpu6050: mpu6050_dmp_set_shake_reject_thresh/mpu6050_dmp_get_shake_reject_thresh test.\n");
893
894 m = 200;
895 res = mpu6050_dmp_set_shake_reject_thresh(&gs_handle, m);
896 if (res != 0)
897 {
898 mpu6050_interface_debug_print("mpu6050: dmp set shake reject thresh failed.\n");
899 (void)mpu6050_deinit(&gs_handle);
900
901 return 1;
902 }
903 mpu6050_interface_debug_print("mpu6050: set shake reject thresh %d dps.\n", m);
904 res = mpu6050_dmp_get_shake_reject_thresh(&gs_handle, &m_check);
905 if (res != 0)
906 {
907 mpu6050_interface_debug_print("mpu6050: dmp get shake reject thresh failed.\n");
908 (void)mpu6050_deinit(&gs_handle);
909
910 return 1;
911 }
912 mpu6050_interface_debug_print("mpu6050: check shake reject thresh %s.\n", m_check == m ? "ok" : "error");
913
914 /* mpu6050_dmp_set_tap_time_multi/mpu6050_dmp_get_tap_time_multi test */
915 mpu6050_interface_debug_print("mpu6050: mpu6050_dmp_set_tap_time_multi/mpu6050_dmp_get_tap_time_multi test.\n");
916
917 m = 200;
918 res = mpu6050_dmp_set_tap_time_multi(&gs_handle, m);
919 if (res != 0)
920 {
921 mpu6050_interface_debug_print("mpu6050: dmp set tap time multi failed.\n");
922 (void)mpu6050_deinit(&gs_handle);
923
924 return 1;
925 }
926 mpu6050_interface_debug_print("mpu6050: dmp set tap time multi %d ms.\n", m);
927 res = mpu6050_dmp_get_tap_time_multi(&gs_handle, &m_check);
928 if (res != 0)
929 {
930 mpu6050_interface_debug_print("mpu6050: dmp get tap time multi failed.\n");
931 (void)mpu6050_deinit(&gs_handle);
932
933 return 1;
934 }
935 mpu6050_interface_debug_print("mpu6050: check tap time multi %s.\n", m_check == m ? "ok" : "error");
936
937 /* mpu6050_dmp_set_tap_time/mpu6050_dmp_get_tap_time test */
938 mpu6050_interface_debug_print("mpu6050: mpu6050_dmp_set_tap_time/mpu6050_dmp_get_tap_time test.\n");
939
940 m = 100;
941 res = mpu6050_dmp_set_tap_time(&gs_handle, m);
942 if (res != 0)
943 {
944 mpu6050_interface_debug_print("mpu6050: dmp set tap time failed.\n");
945 (void)mpu6050_deinit(&gs_handle);
946
947 return 1;
948 }
949 mpu6050_interface_debug_print("mpu6050: dmp set tap time %d ms.\n", m);
950 res = mpu6050_dmp_get_tap_time(&gs_handle, &m_check);
951 if (res != 0)
952 {
953 mpu6050_interface_debug_print("mpu6050: dmp get tap time failed.\n");
954 (void)mpu6050_deinit(&gs_handle);
955
956 return 1;
957 }
958 mpu6050_interface_debug_print("mpu6050: check tap time %s.\n", m_check == m ? "ok" : "error");
959
960 /* mpu6050_dmp_set_min_tap_count/mpu6050_dmp_get_min_tap_count test */
961 mpu6050_interface_debug_print("mpu6050: mpu6050_dmp_set_min_tap_count/mpu6050_dmp_get_min_tap_count test.\n");
962
963 c = 1;
964 res = mpu6050_dmp_set_min_tap_count(&gs_handle, c);
965 if (res != 0)
966 {
967 mpu6050_interface_debug_print("mpu6050: dmp set min tap count failed.\n");
968 (void)mpu6050_deinit(&gs_handle);
969
970 return 1;
971 }
972 mpu6050_interface_debug_print("mpu6050: dmp set min tap count %d.\n", c);
973 res = mpu6050_dmp_get_min_tap_count(&gs_handle, &c_check);
974 if (res != 0)
975 {
976 mpu6050_interface_debug_print("mpu6050: dmp get min tap count failed.\n");
977 (void)mpu6050_deinit(&gs_handle);
978
979 return 1;
980 }
981 mpu6050_interface_debug_print("mpu6050: check min tap count %s.\n", c_check == c ? "ok" : "error");
982
983 /* mpu6050_dmp_set_tap_axes/mpu6050_dmp_get_tap_axes test */
984 mpu6050_interface_debug_print("mpu6050: mpu6050_dmp_set_tap_axes/mpu6050_dmp_get_tap_axes test.\n");
985
986 /* disable axis x */
988 if (res != 0)
989 {
990 mpu6050_interface_debug_print("mpu6050: dmp set tap axes failed.\n");
991 (void)mpu6050_deinit(&gs_handle);
992
993 return 1;
994 }
995 mpu6050_interface_debug_print("mpu6050: disable tap axes x.\n");
996 res = mpu6050_dmp_get_tap_axes(&gs_handle, MPU6050_AXIS_X, &enable);
997 if (res != 0)
998 {
999 mpu6050_interface_debug_print("mpu6050: dmp get tap axes failed.\n");
1000 (void)mpu6050_deinit(&gs_handle);
1001
1002 return 1;
1003 }
1004 mpu6050_interface_debug_print("mpu6050: check tap axes %s.\n", enable == MPU6050_BOOL_FALSE ? "ok" : "error");
1005
1006 /* enable axis x */
1008 if (res != 0)
1009 {
1010 mpu6050_interface_debug_print("mpu6050: dmp set tap axes failed.\n");
1011 (void)mpu6050_deinit(&gs_handle);
1012
1013 return 1;
1014 }
1015 mpu6050_interface_debug_print("mpu6050: enable tap axes x.\n");
1016 res = mpu6050_dmp_get_tap_axes(&gs_handle, MPU6050_AXIS_X, &enable);
1017 if (res != 0)
1018 {
1019 mpu6050_interface_debug_print("mpu6050: dmp get tap axes failed.\n");
1020 (void)mpu6050_deinit(&gs_handle);
1021
1022 return 1;
1023 }
1024 mpu6050_interface_debug_print("mpu6050: check tap axes %s.\n", enable == MPU6050_BOOL_TRUE ? "ok" : "error");
1025
1026 /* disable axis y */
1028 if (res != 0)
1029 {
1030 mpu6050_interface_debug_print("mpu6050: dmp set tap axes failed.\n");
1031 (void)mpu6050_deinit(&gs_handle);
1032
1033 return 1;
1034 }
1035 mpu6050_interface_debug_print("mpu6050: disable tap axes y.\n");
1036 res = mpu6050_dmp_get_tap_axes(&gs_handle, MPU6050_AXIS_Y, &enable);
1037 if (res != 0)
1038 {
1039 mpu6050_interface_debug_print("mpu6050: dmp get tap axes failed.\n");
1040 (void)mpu6050_deinit(&gs_handle);
1041
1042 return 1;
1043 }
1044 mpu6050_interface_debug_print("mpu6050: check tap axes %s.\n", enable == MPU6050_BOOL_FALSE ? "ok" : "error");
1045
1046 /* enable axis y */
1048 if (res != 0)
1049 {
1050 mpu6050_interface_debug_print("mpu6050: dmp set tap axes failed.\n");
1051 (void)mpu6050_deinit(&gs_handle);
1052
1053 return 1;
1054 }
1055 mpu6050_interface_debug_print("mpu6050: enable tap axes y.\n");
1056 res = mpu6050_dmp_get_tap_axes(&gs_handle, MPU6050_AXIS_Y, &enable);
1057 if (res != 0)
1058 {
1059 mpu6050_interface_debug_print("mpu6050: dmp get tap axes failed.\n");
1060 (void)mpu6050_deinit(&gs_handle);
1061
1062 return 1;
1063 }
1064 mpu6050_interface_debug_print("mpu6050: check tap axes %s.\n", enable == MPU6050_BOOL_TRUE ? "ok" : "error");
1065
1066 /* disable axis z */
1068 if (res != 0)
1069 {
1070 mpu6050_interface_debug_print("mpu6050: dmp set tap axes failed.\n");
1071 (void)mpu6050_deinit(&gs_handle);
1072
1073 return 1;
1074 }
1075 mpu6050_interface_debug_print("mpu6050: disable tap axes z.\n");
1076 res = mpu6050_dmp_get_tap_axes(&gs_handle, MPU6050_AXIS_Z, &enable);
1077 if (res != 0)
1078 {
1079 mpu6050_interface_debug_print("mpu6050: dmp get tap axes failed.\n");
1080 (void)mpu6050_deinit(&gs_handle);
1081
1082 return 1;
1083 }
1084 mpu6050_interface_debug_print("mpu6050: check tap axes %s.\n", enable == MPU6050_BOOL_FALSE ? "ok" : "error");
1085
1086 /* enable axis z */
1088 if (res != 0)
1089 {
1090 mpu6050_interface_debug_print("mpu6050: dmp set tap axes failed.\n");
1091 (void)mpu6050_deinit(&gs_handle);
1092
1093 return 1;
1094 }
1095 mpu6050_interface_debug_print("mpu6050: enable tap axes z.\n");
1096 res = mpu6050_dmp_get_tap_axes(&gs_handle, MPU6050_AXIS_Z, &enable);
1097 if (res != 0)
1098 {
1099 mpu6050_interface_debug_print("mpu6050: dmp get tap axes failed.\n");
1100 (void)mpu6050_deinit(&gs_handle);
1101
1102 return 1;
1103 }
1104 mpu6050_interface_debug_print("mpu6050: check tap axes %s.\n", enable == MPU6050_BOOL_TRUE ? "ok" : "error");
1105
1106 /* mpu6050_dmp_set_tap_thresh/mpu6050_dmp_get_tap_thresh test */
1107 mpu6050_interface_debug_print("mpu6050: mpu6050_dmp_set_tap_thresh/mpu6050_dmp_get_tap_thresh test.\n");
1108
1109 /* set tap thresh x */
1110 m = 250;
1111 res = mpu6050_dmp_set_tap_thresh(&gs_handle, MPU6050_AXIS_X, m);
1112 if (res != 0)
1113 {
1114 mpu6050_interface_debug_print("mpu6050: dmp set tap thresh failed.\n");
1115 (void)mpu6050_deinit(&gs_handle);
1116
1117 return 1;
1118 }
1119 mpu6050_interface_debug_print("mpu6050: dmp set tap thresh x %d mg/ms.\n", m);
1120 res = mpu6050_dmp_get_tap_thresh(&gs_handle, MPU6050_AXIS_X, &m_check);
1121 if (res != 0)
1122 {
1123 mpu6050_interface_debug_print("mpu6050: dmp get tap thresh failed.\n");
1124 (void)mpu6050_deinit(&gs_handle);
1125
1126 return 1;
1127 }
1128 mpu6050_interface_debug_print("mpu6050: check tap thresh %s.\n", m_check == m ? "ok" : "error");
1129
1130 /* set tap thresh y */
1131 m = 250;
1132 res = mpu6050_dmp_set_tap_thresh(&gs_handle, MPU6050_AXIS_Y, m);
1133 if (res != 0)
1134 {
1135 mpu6050_interface_debug_print("mpu6050: dmp set tap thresh failed.\n");
1136 (void)mpu6050_deinit(&gs_handle);
1137
1138 return 1;
1139 }
1140 mpu6050_interface_debug_print("mpu6050: dmp set tap thresh y %d mg/ms.\n", m);
1141 res = mpu6050_dmp_get_tap_thresh(&gs_handle, MPU6050_AXIS_Y, &m_check);
1142 if (res != 0)
1143 {
1144 mpu6050_interface_debug_print("mpu6050: dmp get tap thresh failed.\n");
1145 (void)mpu6050_deinit(&gs_handle);
1146
1147 return 1;
1148 }
1149 mpu6050_interface_debug_print("mpu6050: check tap thresh %s.\n", m_check == m ? "ok" : "error");
1150
1151 /* set tap thresh z */
1152 m = 250;
1153 res = mpu6050_dmp_set_tap_thresh(&gs_handle, MPU6050_AXIS_Z, m);
1154 if (res != 0)
1155 {
1156 mpu6050_interface_debug_print("mpu6050: dmp set tap thresh failed.\n");
1157 (void)mpu6050_deinit(&gs_handle);
1158
1159 return 1;
1160 }
1161 mpu6050_interface_debug_print("mpu6050: dmp set tap thresh z %d mg/ms.\n", m);
1162 res = mpu6050_dmp_get_tap_thresh(&gs_handle, MPU6050_AXIS_Z, &m_check);
1163 if (res != 0)
1164 {
1165 mpu6050_interface_debug_print("mpu6050: dmp get tap thresh failed.\n");
1166 (void)mpu6050_deinit(&gs_handle);
1167
1168 return 1;
1169 }
1170 mpu6050_interface_debug_print("mpu6050: check tap thresh %s.\n", m_check == m ? "ok" : "error");
1171
1172 /* mpu6050_dmp_set_fifo_rate/mpu6050_dmp_get_fifo_rate test */
1173 mpu6050_interface_debug_print("mpu6050: mpu6050_dmp_set_fifo_rate/mpu6050_dmp_get_fifo_rate test.\n");
1174
1175 m = 50;
1176 res = mpu6050_dmp_set_fifo_rate(&gs_handle, m);
1177 if (res != 0)
1178 {
1179 mpu6050_interface_debug_print("mpu6050: dmp set fifo rate failed.\n");
1180 (void)mpu6050_deinit(&gs_handle);
1181
1182 return 1;
1183 }
1184 mpu6050_interface_debug_print("mpu6050: dmp set fifo rate %dHz.\n", m);
1185 res = mpu6050_dmp_get_fifo_rate(&gs_handle, &m_check);
1186 if (res != 0)
1187 {
1188 mpu6050_interface_debug_print("mpu6050: dmp get fifo rate failed.\n");
1189 (void)mpu6050_deinit(&gs_handle);
1190
1191 return 1;
1192 }
1193 mpu6050_interface_debug_print("mpu6050: check fifo rate %s.\n", m_check == m ? "ok" : "error");
1194
1195 /* mpu6050_dmp_set_gyro_calibrate test */
1196 mpu6050_interface_debug_print("mpu6050: mpu6050_dmp_set_gyro_calibrate test.\n");
1197
1198 /* enable gyro calibrate */
1200 if (res != 0)
1201 {
1202 mpu6050_interface_debug_print("mpu6050: dmp set gyro calibrate failed.\n");
1203 (void)mpu6050_deinit(&gs_handle);
1204
1205 return 1;
1206 }
1207 mpu6050_interface_debug_print("mpu6050: enable gyro calibrate.\n");
1208
1209 /* disable gyro calibrate */
1211 if (res != 0)
1212 {
1213 mpu6050_interface_debug_print("mpu6050: dmp set gyro calibrate failed.\n");
1214 (void)mpu6050_deinit(&gs_handle);
1215
1216 return 1;
1217 }
1218 mpu6050_interface_debug_print("mpu6050: disable gyro calibrate.\n");
1219
1220 /* mpu6050_dmp_set_3x_quaternion test */
1221 mpu6050_interface_debug_print("mpu6050: mpu6050_dmp_set_3x_quaternion test.\n");
1222
1223 /* enable 3x quaternion */
1225 if (res != 0)
1226 {
1227 mpu6050_interface_debug_print("mpu6050: dmp set 3x quaternion failed.\n");
1228 (void)mpu6050_deinit(&gs_handle);
1229
1230 return 1;
1231 }
1232 mpu6050_interface_debug_print("mpu6050: enable 3x quaternion.\n");
1233
1234 /* disable 3x quaternion */
1236 if (res != 0)
1237 {
1238 mpu6050_interface_debug_print("mpu6050: dmp set 3x quaternion failed.\n");
1239 (void)mpu6050_deinit(&gs_handle);
1240
1241 return 1;
1242 }
1243 mpu6050_interface_debug_print("mpu6050: disable 3x quaternion.\n");
1244
1245 /* mpu6050_dmp_set_6x_quaternion test */
1246 mpu6050_interface_debug_print("mpu6050: mpu6050_dmp_set_6x_quaternion test.\n");
1247
1248 /* enable 6x quaternion */
1250 if (res != 0)
1251 {
1252 mpu6050_interface_debug_print("mpu6050: dmp set 6x quaternion failed.\n");
1253 (void)mpu6050_deinit(&gs_handle);
1254
1255 return 1;
1256 }
1257 mpu6050_interface_debug_print("mpu6050: enable 6x quaternion.\n");
1258
1259 /* disable 6x quaternion */
1261 if (res != 0)
1262 {
1263 mpu6050_interface_debug_print("mpu6050: dmp set 6x quaternion failed.\n");
1264 (void)mpu6050_deinit(&gs_handle);
1265
1266 return 1;
1267 }
1268 mpu6050_interface_debug_print("mpu6050: disable 6x quaternion.\n");
1269
1270 /* mpu6050_dmp_set_interrupt_mode test */
1271 mpu6050_interface_debug_print("mpu6050: mpu6050_dmp_set_interrupt_mode test.\n");
1272
1273 /* gesture mode */
1275 if (res != 0)
1276 {
1277 mpu6050_interface_debug_print("mpu6050: dmp set interrupt mode failed.\n");
1278 (void)mpu6050_deinit(&gs_handle);
1279
1280 return 1;
1281 }
1282 mpu6050_interface_debug_print("mpu6050: dmp set gesture interrupt mode.\n");
1283
1284 /* continuous mode */
1286 if (res != 0)
1287 {
1288 mpu6050_interface_debug_print("mpu6050: dmp set interrupt mode failed.\n");
1289 (void)mpu6050_deinit(&gs_handle);
1290
1291 return 1;
1292 }
1293 mpu6050_interface_debug_print("mpu6050: dmp set gesture continuous mode.\n");
1294
1295 /* mpu6050_dmp_set_orientation test */
1296 mpu6050_interface_debug_print("mpu6050: mpu6050_dmp_set_orientation test.\n");
1297
1298 /* set the dmp orientation */
1299 res = mpu6050_dmp_set_orientation(&gs_handle, gyro_orientation);
1300 if (res != 0)
1301 {
1302 mpu6050_interface_debug_print("mpu6050: dmp set orientation failed.\n");
1303 (void)mpu6050_deinit(&gs_handle);
1304
1305 return 1;
1306 }
1307 mpu6050_interface_debug_print("mpu6050: set the dmp orientation.\n");
1308
1309 /* mpu6050_dmp_set_feature test */
1310 mpu6050_interface_debug_print("mpu6050: mpu6050_dmp_set_feature test.\n");
1311
1312 /* enable feature */
1316 if (res != 0)
1317 {
1318 mpu6050_interface_debug_print("mpu6050: dmp set feature failed.\n");
1319 (void)mpu6050_deinit(&gs_handle);
1320
1321 return 1;
1322 }
1323 mpu6050_interface_debug_print("mpu6050: enable feature 6x quat.\n");
1324 mpu6050_interface_debug_print("mpu6050: enable feature tap.\n");
1325 mpu6050_interface_debug_print("mpu6050: enable feature pedometer.\n");
1326 mpu6050_interface_debug_print("mpu6050: enable feature orient.\n");
1327 mpu6050_interface_debug_print("mpu6050: enable feature send raw accel.\n");
1328 mpu6050_interface_debug_print("mpu6050: enable feature send cal gyro.\n");
1329 mpu6050_interface_debug_print("mpu6050: enable feature gyro cal.\n");
1330
1331 /* dmp set tap callback */
1332 res = mpu6050_dmp_set_tap_callback(&gs_handle, a_dmp_tap_callback);
1333 if (res != 0)
1334 {
1335 mpu6050_interface_debug_print("mpu6050: dmp set tap callback failed.\n");
1336 (void)mpu6050_deinit(&gs_handle);
1337
1338 return 1;
1339 }
1340
1341 /* dmp set orient callback */
1342 res = mpu6050_dmp_set_orient_callback(&gs_handle, a_dmp_orient_callback);
1343 if (res != 0)
1344 {
1345 mpu6050_interface_debug_print("mpu6050: dmp set orient callback failed.\n");
1346 (void)mpu6050_deinit(&gs_handle);
1347
1348 return 1;
1349 }
1350
1351 /* dmp gyro accel raw offset convert */
1352 res = mpu6050_dmp_gyro_accel_raw_offset_convert(&gs_handle, gyro_offset_raw, accel_offset_raw,
1353 gyro_offset, accel_offset);
1354 if (res != 0)
1355 {
1356 mpu6050_interface_debug_print("mpu6050: dmp gyro accel raw offset convert failed.\n");
1357 (void)mpu6050_deinit(&gs_handle);
1358
1359 return 1;
1360 }
1361
1362 /* dmp set accel bias */
1363 res = mpu6050_dmp_set_accel_bias(&gs_handle, accel_offset);
1364 if (res != 0)
1365 {
1366 mpu6050_interface_debug_print("mpu6050: dmp set accel bias failed.\n");
1367 (void)mpu6050_deinit(&gs_handle);
1368
1369 return 1;
1370 }
1371
1372 /* dmp set gyro bias */
1373 res = mpu6050_dmp_set_gyro_bias(&gs_handle, gyro_offset);
1374 if (res != 0)
1375 {
1376 mpu6050_interface_debug_print("mpu6050: dmp set gyro bias failed.\n");
1377 (void)mpu6050_deinit(&gs_handle);
1378
1379 return 1;
1380 }
1381
1382 /* enable the dmp */
1383 res = mpu6050_dmp_set_enable(&gs_handle, MPU6050_BOOL_TRUE);
1384 if (res != 0)
1385 {
1386 mpu6050_interface_debug_print("mpu6050: dmp set enable failed.\n");
1387 (void)mpu6050_deinit(&gs_handle);
1388
1389 return 1;
1390 }
1391
1392 /* force fifo reset */
1393 res = mpu6050_force_fifo_reset(&gs_handle);
1394 if (res != 0)
1395 {
1396 mpu6050_interface_debug_print("mpu6050: force fifo reset failed.\n");
1397 (void)mpu6050_deinit(&gs_handle);
1398
1399 return 1;
1400 }
1401
1402 /* delay 200 ms */
1404
1405 /* set 0 */
1406 gs_flag = 0;
1407
1408 for (i = 0; i < 1000; i++)
1409 {
1410 uint16_t l;
1411
1412 /* read the data */
1413 l = 128;
1414 res = mpu6050_dmp_read(&gs_handle,
1415 gs_accel_raw, gs_accel_g,
1416 gs_gyro_raw, gs_gyro_dps,
1417 gs_quat,
1418 gs_pitch, gs_roll, gs_yaw,
1419 &l
1420 );
1421 if (res != 0)
1422 {
1423 /* output data */
1424 mpu6050_interface_debug_print("mpu6050: dmp read failed.\n");
1425 }
1426
1427 /* delay 200 ms */
1429
1430 /* check the flag */
1431 if ((gs_flag & 0x7) == 0x7)
1432 {
1433 break;
1434 }
1435 }
1436
1437 /* finish dmp tap orient motion test */
1438 mpu6050_interface_debug_print("mpu6050: finish dmp tap orient motion test.\n");
1439 (void)mpu6050_deinit(&gs_handle);
1440
1441 return 0;
1442}
driver mpu6050 dmp tap orient motion test header file
struct mpu6050_info_s mpu6050_info_t
mpu6050 information structure definition
uint8_t mpu6050_set_wake_up_frequency(mpu6050_handle_t *handle, mpu6050_wake_up_frequency_t frequency)
set the wake up frequency
uint8_t mpu6050_init(mpu6050_handle_t *handle)
initialize the chip
uint8_t mpu6050_set_accelerometer_range(mpu6050_handle_t *handle, mpu6050_accelerometer_range_t range)
set the accelerometer range
mpu6050_address_t
mpu6050 address enumeration definition
uint8_t mpu6050_set_standby_mode(mpu6050_handle_t *handle, mpu6050_source_t source, mpu6050_bool_t enable)
set source into standby mode
uint8_t mpu6050_motion_threshold_convert_to_register(mpu6050_handle_t *handle, float mg, uint8_t *reg)
convert the motion threshold to the register raw data
uint8_t mpu6050_self_test(mpu6050_handle_t *handle, int32_t gyro_offset_raw[3], int32_t accel_offset_raw[3])
run the self test
uint8_t mpu6050_set_motion_threshold(mpu6050_handle_t *handle, uint8_t threshold)
set the motion_threshold
uint8_t mpu6050_set_sample_rate_divider(mpu6050_handle_t *handle, uint8_t d)
set the sample rate divider
uint8_t mpu6050_set_motion_duration(mpu6050_handle_t *handle, uint8_t duration)
set the motion duration
uint8_t mpu6050_set_gyroscope_range(mpu6050_handle_t *handle, mpu6050_gyroscope_range_t range)
set the gyroscope range
uint8_t mpu6050_set_addr_pin(mpu6050_handle_t *handle, mpu6050_address_t addr_pin)
set the chip address pin
uint8_t mpu6050_set_interrupt_read_clear(mpu6050_handle_t *handle, mpu6050_bool_t enable)
enable or disable the interrupt reading clear
uint8_t mpu6050_set_fifo_enable(mpu6050_handle_t *handle, mpu6050_fifo_t fifo, mpu6050_bool_t enable)
enable or disable the fifo function
uint8_t mpu6050_set_interrupt(mpu6050_handle_t *handle, mpu6050_interrupt_t type, mpu6050_bool_t enable)
enable or disable the interrupt
uint8_t mpu6050_set_iic_bypass(mpu6050_handle_t *handle, mpu6050_bool_t enable)
enable or disable the iic bypass
uint8_t mpu6050_info(mpu6050_info_t *info)
get the chip's information
uint8_t mpu6050_set_gyroscope_test(mpu6050_handle_t *handle, mpu6050_axis_t axis, mpu6050_bool_t enable)
set the gyroscope test
uint8_t mpu6050_set_cycle_wake_up(mpu6050_handle_t *handle, mpu6050_bool_t enable)
enable or disable the cycle wake up mode
uint8_t mpu6050_set_interrupt_pin_type(mpu6050_handle_t *handle, mpu6050_pin_type_t type)
set the interrupt pin type
uint8_t mpu6050_irq_handler(mpu6050_handle_t *handle)
irq handler
uint8_t mpu6050_set_iic_master(mpu6050_handle_t *handle, mpu6050_bool_t enable)
enable or disable the iic master mode
uint8_t mpu6050_force_fifo_reset(mpu6050_handle_t *handle)
force reset the fifo
uint8_t mpu6050_set_temperature_sensor(mpu6050_handle_t *handle, mpu6050_bool_t enable)
enable or disable the temperature sensor
uint8_t mpu6050_set_interrupt_latch(mpu6050_handle_t *handle, mpu6050_bool_t enable)
enable or disable the interrupt latch
uint8_t mpu6050_set_accelerometer_test(mpu6050_handle_t *handle, mpu6050_axis_t axis, mpu6050_bool_t enable)
set the accelerometer test
uint8_t mpu6050_set_extern_sync(mpu6050_handle_t *handle, mpu6050_extern_sync_t sync)
set the extern sync type
uint8_t mpu6050_set_sleep(mpu6050_handle_t *handle, mpu6050_bool_t enable)
enable or disable the sleep mode
struct mpu6050_handle_s mpu6050_handle_t
mpu6050 handle structure definition
mpu6050_bool_t
mpu6050 bool enumeration definition
uint8_t mpu6050_set_fifo(mpu6050_handle_t *handle, mpu6050_bool_t enable)
enable or disable fifo
uint8_t mpu6050_set_interrupt_level(mpu6050_handle_t *handle, mpu6050_pin_level_t level)
set the interrupt level
uint8_t mpu6050_motion_duration_convert_to_register(mpu6050_handle_t *handle, uint8_t ms, uint8_t *reg)
convert the motion duration to the register raw data
uint8_t mpu6050_set_clock_source(mpu6050_handle_t *handle, mpu6050_clock_source_t clock_source)
set the chip clock source
uint8_t mpu6050_set_fsync_interrupt(mpu6050_handle_t *handle, mpu6050_bool_t enable)
enable or disable the fsync interrupt
uint8_t mpu6050_set_low_pass_filter(mpu6050_handle_t *handle, mpu6050_low_pass_filter_t filter)
set the low pass filter
uint8_t mpu6050_deinit(mpu6050_handle_t *handle)
close the chip
uint8_t mpu6050_set_fsync_interrupt_level(mpu6050_handle_t *handle, mpu6050_pin_level_t level)
set the fsync interrupt level
uint8_t mpu6050_set_force_accel_sample(mpu6050_handle_t *handle, mpu6050_bool_t enable)
enable or disable force accel sample
@ MPU6050_PIN_TYPE_PUSH_PULL
@ MPU6050_WAKE_UP_FREQUENCY_1P25_HZ
@ MPU6050_GYROSCOPE_RANGE_2000DPS
@ MPU6050_EXTERN_SYNC_INPUT_DISABLED
@ MPU6050_SOURCE_ACC_Y
@ MPU6050_SOURCE_GYRO_Y
@ MPU6050_SOURCE_ACC_Z
@ MPU6050_SOURCE_ACC_X
@ MPU6050_SOURCE_GYRO_Z
@ MPU6050_SOURCE_GYRO_X
@ MPU6050_FIFO_XG
@ MPU6050_FIFO_ACCEL
@ MPU6050_FIFO_TEMP
@ MPU6050_FIFO_ZG
@ MPU6050_FIFO_YG
@ MPU6050_CLOCK_SOURCE_PLL_X_GYRO
@ MPU6050_PIN_LEVEL_LOW
@ MPU6050_INTERRUPT_DMP
@ MPU6050_INTERRUPT_I2C_MAST
@ MPU6050_INTERRUPT_DATA_READY
@ MPU6050_INTERRUPT_FIFO_OVERFLOW
@ MPU6050_INTERRUPT_MOTION
@ MPU6050_ACCELEROMETER_RANGE_2G
@ MPU6050_BOOL_TRUE
@ MPU6050_BOOL_FALSE
@ MPU6050_LOW_PASS_FILTER_3
@ MPU6050_AXIS_X
@ MPU6050_AXIS_Z
@ MPU6050_AXIS_Y
uint8_t mpu6050_dmp_set_tap_thresh(mpu6050_handle_t *handle, mpu6050_axis_t axis, uint16_t mg_ms)
dmp set the tap thresh
uint8_t mpu6050_dmp_set_gyro_bias(mpu6050_handle_t *handle, int32_t bias[3])
dmp set the gyro bias
uint8_t mpu6050_dmp_set_orientation(mpu6050_handle_t *handle, int8_t mat[9])
dmp set the orientation
uint8_t mpu6050_dmp_get_shake_reject_time(mpu6050_handle_t *handle, uint16_t *ms)
dmp get the shake reject time
uint8_t mpu6050_dmp_get_shake_reject_thresh(mpu6050_handle_t *handle, uint16_t *dps)
dmp get the shake reject thresh
uint8_t mpu6050_dmp_set_enable(mpu6050_handle_t *handle, mpu6050_bool_t enable)
enable or disable the dmp
uint8_t mpu6050_dmp_load_firmware(mpu6050_handle_t *handle)
load the dmp firmware
uint8_t mpu6050_dmp_set_tap_callback(mpu6050_handle_t *handle, void(*callback)(uint8_t count, uint8_t direction))
dmp set the tap callback
uint8_t mpu6050_dmp_set_orient_callback(mpu6050_handle_t *handle, void(*callback)(uint8_t orientation))
dmp set the orient callback
uint8_t mpu6050_dmp_set_shake_reject_timeout(mpu6050_handle_t *handle, uint16_t ms)
dmp set the shake reject timeout
uint8_t mpu6050_dmp_read(mpu6050_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 mpu6050_dmp_set_tap_time_multi(mpu6050_handle_t *handle, uint16_t ms)
dmp set max time between taps to register as a multi tap
uint8_t mpu6050_dmp_set_accel_bias(mpu6050_handle_t *handle, int32_t bias[3])
dmp set the accel bias
uint8_t mpu6050_dmp_get_pedometer_step_count(mpu6050_handle_t *handle, uint32_t *count)
dmp get the pedometer step count
uint8_t mpu6050_dmp_set_pedometer_step_count(mpu6050_handle_t *handle, uint32_t count)
dmp set the pedometer step count
uint8_t mpu6050_dmp_get_tap_axes(mpu6050_handle_t *handle, mpu6050_axis_t axis, mpu6050_bool_t *enable)
dmp get the tap axes status
uint8_t mpu6050_dmp_set_feature(mpu6050_handle_t *handle, uint16_t mask)
dmp enable or disable the dmp feature
uint8_t mpu6050_dmp_gyro_accel_raw_offset_convert(mpu6050_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 mpu6050_dmp_get_tap_thresh(mpu6050_handle_t *handle, mpu6050_axis_t axis, uint16_t *mg_ms)
dmp get the tap thresh
uint8_t mpu6050_dmp_set_6x_quaternion(mpu6050_handle_t *handle, mpu6050_bool_t enable)
dmp enable or disable generate 6 axis quaternions from dmp
uint8_t mpu6050_dmp_get_pedometer_walk_time(mpu6050_handle_t *handle, uint32_t *ms)
dmp get the pedometer walk time
uint8_t mpu6050_dmp_set_shake_reject_thresh(mpu6050_handle_t *handle, uint16_t dps)
dmp set the shake reject thresh
uint8_t mpu6050_dmp_get_tap_time(mpu6050_handle_t *handle, uint16_t *ms)
dmp get the tap time
uint8_t mpu6050_dmp_set_fifo_rate(mpu6050_handle_t *handle, uint16_t rate)
dmp set the fifo rate
uint8_t mpu6050_dmp_set_tap_axes(mpu6050_handle_t *handle, mpu6050_axis_t axis, mpu6050_bool_t enable)
dmp enable or disable the tap axes
uint8_t mpu6050_dmp_set_shake_reject_time(mpu6050_handle_t *handle, uint16_t ms)
dmp set the shake reject time
uint8_t mpu6050_dmp_get_fifo_rate(mpu6050_handle_t *handle, uint16_t *rate)
dmp get the fifo rate
uint8_t mpu6050_dmp_set_min_tap_count(mpu6050_handle_t *handle, uint8_t cnt)
dmp set the min tap count
uint8_t mpu6050_dmp_get_shake_reject_timeout(mpu6050_handle_t *handle, uint16_t *ms)
dmp get the shake reject timeout
uint8_t mpu6050_dmp_get_min_tap_count(mpu6050_handle_t *handle, uint8_t *cnt)
dmp get the min tap count
uint8_t mpu6050_dmp_get_tap_time_multi(mpu6050_handle_t *handle, uint16_t *ms)
dmp get max time between taps to register as a multi tap
uint8_t mpu6050_dmp_set_gyro_calibrate(mpu6050_handle_t *handle, mpu6050_bool_t enable)
dmp enable or disable gyro calibrate
uint8_t mpu6050_dmp_set_tap_time(mpu6050_handle_t *handle, uint16_t ms)
dmp set the tap time
uint8_t mpu6050_dmp_set_3x_quaternion(mpu6050_handle_t *handle, mpu6050_bool_t enable)
dmp enable or disable generate 3 axis quaternions from dmp
uint8_t mpu6050_dmp_set_interrupt_mode(mpu6050_handle_t *handle, mpu6050_dmp_interrupt_mode_t mode)
dmp set the interrupt mode
uint8_t mpu6050_dmp_set_pedometer_walk_time(mpu6050_handle_t *handle, uint32_t ms)
dmp set the pedometer walk time
@ MPU6050_DMP_ORIENT_PORTRAIT
@ MPU6050_DMP_ORIENT_REVERSE_LANDSCAPE
@ MPU6050_DMP_ORIENT_LANDSCAPE
@ MPU6050_DMP_ORIENT_REVERSE_PORTRAIT
@ MPU6050_DMP_FEATURE_PEDOMETER
@ MPU6050_DMP_FEATURE_TAP
@ MPU6050_DMP_FEATURE_ORIENT
@ MPU6050_DMP_FEATURE_6X_QUAT
@ MPU6050_DMP_FEATURE_GYRO_CAL
@ MPU6050_DMP_FEATURE_SEND_RAW_ACCEL
@ MPU6050_DMP_FEATURE_SEND_CAL_GYRO
@ MPU6050_DMP_INTERRUPT_MODE_CONTINUOUS
@ MPU6050_DMP_INTERRUPT_MODE_GESTURE
@ MPU6050_DMP_TAP_X_UP
@ MPU6050_DMP_TAP_X_DOWN
@ MPU6050_DMP_TAP_Y_UP
@ MPU6050_DMP_TAP_Y_DOWN
@ MPU6050_DMP_TAP_Z_DOWN
@ MPU6050_DMP_TAP_Z_UP
uint8_t mpu6050_interface_iic_deinit(void)
interface iic bus deinit
uint8_t mpu6050_interface_iic_read(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
interface iic bus read
void mpu6050_interface_debug_print(const char *const fmt,...)
interface print format data
uint8_t mpu6050_interface_iic_write(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
interface iic bus write
uint8_t mpu6050_interface_iic_init(void)
interface iic bus init
void mpu6050_interface_delay_ms(uint32_t ms)
interface delay ms
uint8_t mpu6050_dmp_tap_orient_motion_test_irq_handler(void)
dmp tap orient motion test irq
uint8_t mpu6050_dmp_tap_orient_motion_test(mpu6050_address_t addr)
dmp test
uint32_t driver_version
char manufacturer_name[32]