LibDriver MPU6500
Loading...
Searching...
No Matches
driver_mpu6500_dmp_pedometer_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];
49
58{
59 if (mpu6500_irq_handler(&gs_handle) != 0)
60 {
61 return 1;
62 }
63
64 return 0;
65}
66
78{
79 uint8_t res;
80 uint32_t ms;
81 uint32_t ms_check;
82 uint32_t cnt;
83 uint32_t cnt_check;
84 uint32_t i;
85 uint16_t m;
86 uint16_t m_check;
87 int32_t gyro_offset_raw[3];
88 int32_t accel_offset_raw[3];
89 int32_t gyro_offset[3];
90 int32_t accel_offset[3];
91 mpu6500_info_t info;
92
93 /* link interface function */
106
107 /* get information */
108 res = mpu6500_info(&info);
109 if (res != 0)
110 {
111 mpu6500_interface_debug_print("mpu6500: get info failed.\n");
112
113 return 1;
114 }
115 else
116 {
117 /* print chip info */
118 mpu6500_interface_debug_print("mpu6500: chip is %s.\n", info.chip_name);
119 mpu6500_interface_debug_print("mpu6500: manufacturer is %s.\n", info.manufacturer_name);
120 mpu6500_interface_debug_print("mpu6500: interface is %s.\n", info.interface);
121 mpu6500_interface_debug_print("mpu6500: driver version is %d.%d.\n", info.driver_version / 1000, (info.driver_version % 1000) / 100);
122 mpu6500_interface_debug_print("mpu6500: min supply voltage is %0.1fV.\n", info.supply_voltage_min_v);
123 mpu6500_interface_debug_print("mpu6500: max supply voltage is %0.1fV.\n", info.supply_voltage_max_v);
124 mpu6500_interface_debug_print("mpu6500: max current is %0.2fmA.\n", info.max_current_ma);
125 mpu6500_interface_debug_print("mpu6500: max temperature is %0.1fC.\n", info.temperature_max);
126 mpu6500_interface_debug_print("mpu6500: min temperature is %0.1fC.\n", info.temperature_min);
127 }
128
129 /* start dmp pedometer test */
130 mpu6500_interface_debug_print("mpu6500: start dmp pedometer test.\n");
131
132 /* set the interface */
133 res = mpu6500_set_interface(&gs_handle, interface);
134 if (res != 0)
135 {
136 mpu6500_interface_debug_print("mpu6500: set interface failed.\n");
137
138 return 1;
139 }
140
141 /* set the addr pin */
142 res = mpu6500_set_addr_pin(&gs_handle, addr);
143 if (res != 0)
144 {
145 mpu6500_interface_debug_print("mpu6500: set addr pin failed.\n");
146
147 return 1;
148 }
149
150 /* init */
151 res = mpu6500_init(&gs_handle);
152 if (res != 0)
153 {
154 mpu6500_interface_debug_print("mpu6500: init failed.\n");
155
156 return 1;
157 }
158
159 /* delay 100 ms */
161
162 /* disable sleep */
163 res = mpu6500_set_sleep(&gs_handle, MPU6500_BOOL_FALSE);
164 if (res != 0)
165 {
166 mpu6500_interface_debug_print("mpu6500: set sleep failed.\n");
167 (void)mpu6500_deinit(&gs_handle);
168
169 return 1;
170 }
171
172 /* if spi interface, disable iic interface */
173 if (interface == MPU6500_INTERFACE_SPI)
174 {
175 /* disable iic */
177 if (res != 0)
178 {
179 mpu6500_interface_debug_print("mpu6500: set disable iic slave failed.\n");
180 (void)mpu6500_deinit(&gs_handle);
181
182 return 1;
183 }
184 }
185
186 /* set fifo 1024kb */
187 res = mpu6500_set_fifo_1024kb(&gs_handle);
188 if (res != 0)
189 {
190 mpu6500_interface_debug_print("mpu6500: set fifo 1024kb failed.\n");
191 (void)mpu6500_deinit(&gs_handle);
192
193 return 1;
194 }
195
196 /* run the self test */
197 res = mpu6500_self_test(&gs_handle, gyro_offset_raw, accel_offset_raw);
198 if (res != 0)
199 {
200 mpu6500_interface_debug_print("mpu6500: self test failed.\n");
201 (void)mpu6500_deinit(&gs_handle);
202
203 return 1;
204 }
205
206 /* set pll */
208 if (res != 0)
209 {
210 mpu6500_interface_debug_print("mpu6500: set clock source failed.\n");
211 (void)mpu6500_deinit(&gs_handle);
212
213 return 1;
214 }
215
216 /* set 50Hz */
217 res = mpu6500_set_sample_rate_divider(&gs_handle, (1000 / 50) - 1);
218 if (res != 0)
219 {
220 mpu6500_interface_debug_print("mpu6500: set sample rate divider failed.\n");
221 (void)mpu6500_deinit(&gs_handle);
222
223 return 1;
224 }
225
226 /* ±2g */
228 if (res != 0)
229 {
230 mpu6500_interface_debug_print("mpu6500: set accelerometer range failed.\n");
231 (void)mpu6500_deinit(&gs_handle);
232
233 return 1;
234 }
235
236 /* ±2000dps */
238 if (res != 0)
239 {
240 mpu6500_interface_debug_print("mpu6500: set gyroscope range failed.\n");
241 (void)mpu6500_deinit(&gs_handle);
242
243 return 1;
244 }
245
246 /* set low pass filter 3 */
248 if (res != 0)
249 {
250 mpu6500_interface_debug_print("mpu6500: set low pass filter failed.\n");
251 (void)mpu6500_deinit(&gs_handle);
252
253 return 1;
254 }
255
256 /* enable temperature sensor */
257 res = mpu6500_set_ptat(&gs_handle, MPU6500_BOOL_TRUE);
258 if (res != 0)
259 {
260 mpu6500_interface_debug_print("mpu6500: set ptat failed.\n");
261 (void)mpu6500_deinit(&gs_handle);
262
263 return 1;
264 }
265
266 /* disable cycle wake up */
268 if (res != 0)
269 {
270 mpu6500_interface_debug_print("mpu6500: set cycle wake up failed.\n");
271 (void)mpu6500_deinit(&gs_handle);
272
273 return 1;
274 }
275
276 /* enable acc x */
278 if (res != 0)
279 {
280 mpu6500_interface_debug_print("mpu6500: set standby mode failed.\n");
281 (void)mpu6500_deinit(&gs_handle);
282
283 return 1;
284 }
285
286 /* enable acc y */
288 if (res != 0)
289 {
290 mpu6500_interface_debug_print("mpu6500: set standby mode failed.\n");
291 (void)mpu6500_deinit(&gs_handle);
292
293 return 1;
294 }
295
296 /* enable acc z */
298 if (res != 0)
299 {
300 mpu6500_interface_debug_print("mpu6500: set standby mode failed.\n");
301 (void)mpu6500_deinit(&gs_handle);
302
303 return 1;
304 }
305
306 /* enable gyro x */
308 if (res != 0)
309 {
310 mpu6500_interface_debug_print("mpu6500: set standby mode failed.\n");
311 (void)mpu6500_deinit(&gs_handle);
312
313 return 1;
314 }
315
316 /* enable gyro y */
318 if (res != 0)
319 {
320 mpu6500_interface_debug_print("mpu6500: set standby mode failed.\n");
321 (void)mpu6500_deinit(&gs_handle);
322
323 return 1;
324 }
325
326 /* enable gyro z */
328 if (res != 0)
329 {
330 mpu6500_interface_debug_print("mpu6500: set standby mode failed.\n");
331 (void)mpu6500_deinit(&gs_handle);
332
333 return 1;
334 }
335
336 /* disable gyroscope x test */
338 if (res != 0)
339 {
340 mpu6500_interface_debug_print("mpu6500: set gyroscope test failed.\n");
341 (void)mpu6500_deinit(&gs_handle);
342
343 return 1;
344 }
345
346 /* disable gyroscope y test */
348 if (res != 0)
349 {
350 mpu6500_interface_debug_print("mpu6500: set gyroscope test failed.\n");
351 (void)mpu6500_deinit(&gs_handle);
352
353 return 1;
354 }
355
356 /* disable gyroscope z test */
358 if (res != 0)
359 {
360 mpu6500_interface_debug_print("mpu6500: set gyroscope test failed.\n");
361 (void)mpu6500_deinit(&gs_handle);
362
363 return 1;
364 }
365
366 /* disable accelerometer x test */
368 if (res != 0)
369 {
370 mpu6500_interface_debug_print("mpu6500: set accelerometer test failed.\n");
371 (void)mpu6500_deinit(&gs_handle);
372
373 return 1;
374 }
375
376 /* disable accelerometer y test */
378 if (res != 0)
379 {
380 mpu6500_interface_debug_print("mpu6500: set accelerometer test failed.\n");
381 (void)mpu6500_deinit(&gs_handle);
382
383 return 1;
384 }
385
386 /* disable accelerometer z test */
388 if (res != 0)
389 {
390 mpu6500_interface_debug_print("mpu6500: set accelerometer test failed.\n");
391 (void)mpu6500_deinit(&gs_handle);
392
393 return 1;
394 }
395
396 /* disable temp fifo */
398 if (res != 0)
399 {
400 mpu6500_interface_debug_print("mpu6500: set fifo enable failed.\n");
401 (void)mpu6500_deinit(&gs_handle);
402
403 return 1;
404 }
405
406 /* disable xg fifo */
408 if (res != 0)
409 {
410 mpu6500_interface_debug_print("mpu6500: set fifo enable failed.\n");
411 (void)mpu6500_deinit(&gs_handle);
412
413 return 1;
414 }
415
416 /* disable yg fifo */
418 if (res != 0)
419 {
420 mpu6500_interface_debug_print("mpu6500: set fifo enable failed.\n");
421 (void)mpu6500_deinit(&gs_handle);
422
423 return 1;
424 }
425
426 /* disable zg fifo */
428 if (res != 0)
429 {
430 mpu6500_interface_debug_print("mpu6500: set fifo enable failed.\n");
431 (void)mpu6500_deinit(&gs_handle);
432
433 return 1;
434 }
435
436 /* disable accel fifo */
438 if (res != 0)
439 {
440 mpu6500_interface_debug_print("mpu6500: set fifo enable failed.\n");
441 (void)mpu6500_deinit(&gs_handle);
442
443 return 1;
444 }
445
446 /* enable fifo */
447 res = mpu6500_set_fifo(&gs_handle, MPU6500_BOOL_TRUE);
448 if (res != 0)
449 {
450 mpu6500_interface_debug_print("mpu6500: set fifo failed.\n");
451 (void)mpu6500_deinit(&gs_handle);
452
453 return 1;
454 }
455
456 /* set interrupt level low */
458 if (res != 0)
459 {
460 mpu6500_interface_debug_print("mpu6500: set interrupt level failed.\n");
461 (void)mpu6500_deinit(&gs_handle);
462
463 return 1;
464 }
465
466 /* push-pull */
468 if (res != 0)
469 {
470 mpu6500_interface_debug_print("mpu6500: set interrupt pin type failed.\n");
471 (void)mpu6500_deinit(&gs_handle);
472
473 return 1;
474 }
475
476 /* disable motion */
478 if (res != 0)
479 {
480 mpu6500_interface_debug_print("mpu6500: set interrupt failed.\n");
481 (void)mpu6500_deinit(&gs_handle);
482
483 return 1;
484 }
485
486 /* enable fifo overflow */
488 if (res != 0)
489 {
490 mpu6500_interface_debug_print("mpu6500: set interrupt failed.\n");
491 (void)mpu6500_deinit(&gs_handle);
492
493 return 1;
494 }
495
496 /* disable dmp interrupt */
498 if (res != 0)
499 {
500 mpu6500_interface_debug_print("mpu6500: set interrupt failed.\n");
501 (void)mpu6500_deinit(&gs_handle);
502
503 return 1;
504 }
505
506 /* disable fsync int */
508 if (res != 0)
509 {
510 mpu6500_interface_debug_print("mpu6500: set interrupt failed.\n");
511 (void)mpu6500_deinit(&gs_handle);
512
513 return 1;
514 }
515
516 /* disable data ready */
518 if (res != 0)
519 {
520 mpu6500_interface_debug_print("mpu6500: set interrupt failed.\n");
521 (void)mpu6500_deinit(&gs_handle);
522
523 return 1;
524 }
525
526 /* enable latch */
528 if (res != 0)
529 {
530 mpu6500_interface_debug_print("mpu6500: set interrupt latch failed.\n");
531 (void)mpu6500_deinit(&gs_handle);
532
533 return 1;
534 }
535
536 /* enable interrupt read clear */
538 if (res != 0)
539 {
540 mpu6500_interface_debug_print("mpu6500: set interrupt read clear failed.\n");
541 (void)mpu6500_deinit(&gs_handle);
542
543 return 1;
544 }
545
546 /* disable sync input */
548 if (res != 0)
549 {
550 mpu6500_interface_debug_print("mpu6500: set extern sync failed.\n");
551 (void)mpu6500_deinit(&gs_handle);
552
553 return 1;
554 }
555
556 /* disable fsync interrupt */
558 if (res != 0)
559 {
560 mpu6500_interface_debug_print("mpu6500: set fsync interrupt failed.\n");
561 (void)mpu6500_deinit(&gs_handle);
562
563 return 1;
564 }
565
566 /* fsync interrupt level low */
568 if (res != 0)
569 {
570 mpu6500_interface_debug_print("mpu6500: set fsync interrupt level failed.\n");
571 (void)mpu6500_deinit(&gs_handle);
572
573 return 1;
574 }
575
576 /* disable iic master */
578 if (res != 0)
579 {
580 mpu6500_interface_debug_print("mpu6500: set iic master failed.\n");
581 (void)mpu6500_deinit(&gs_handle);
582
583 return 1;
584 }
585
586 /* disable iic bypass */
588 if (res != 0)
589 {
590 mpu6500_interface_debug_print("mpu6500: set iic bypass failed.\n");
591 (void)mpu6500_deinit(&gs_handle);
592
593 return 1;
594 }
595
596 /* disable gyro standby */
598 if (res != 0)
599 {
600 mpu6500_interface_debug_print("mpu6500: set gyro standby failed.\n");
601 (void)mpu6500_deinit(&gs_handle);
602
603 return 1;
604 }
605
606 /* set the fifo normal mode */
608 if (res != 0)
609 {
610 mpu6500_interface_debug_print("mpu6500: set fifo mode failed.\n");
611 (void)mpu6500_deinit(&gs_handle);
612
613 return 1;
614 }
615
616 /* set gyroscope choice 0 */
617 res = mpu6500_set_gyroscope_choice(&gs_handle, 0);
618 if (res != 0)
619 {
620 mpu6500_interface_debug_print("mpu6500: set gyroscope choice failed.\n");
621 (void)mpu6500_deinit(&gs_handle);
622
623 return 1;
624 }
625
626 /* set low pass filter 3 */
628 if (res != 0)
629 {
630 mpu6500_interface_debug_print("mpu6500: set low pass filter failed.\n");
631 (void)mpu6500_deinit(&gs_handle);
632
633 return 1;
634 }
635
636 /* set accelerometer choice 0 */
637 res = mpu6500_set_accelerometer_choice(&gs_handle, 0);
638 if (res != 0)
639 {
640 mpu6500_interface_debug_print("mpu6500: set accelerometer choice failed.\n");
641 (void)mpu6500_deinit(&gs_handle);
642
643 return 1;
644 }
645
646 /* set accelerometer low pass filter 3 */
648 if (res != 0)
649 {
650 mpu6500_interface_debug_print("mpu6500: set accelerometer low pass filter failed.\n");
651 (void)mpu6500_deinit(&gs_handle);
652
653 return 1;
654 }
655
656 /* set low power accel output rate 62.5Hz */
658 if (res != 0)
659 {
660 mpu6500_interface_debug_print("mpu6500: set low power accel output rate failed.\n");
661 (void)mpu6500_deinit(&gs_handle);
662
663 return 1;
664 }
665
666 /* enable wake on motion */
668 if (res != 0)
669 {
670 mpu6500_interface_debug_print("mpu6500: set wake on motion failed.\n");
671 (void)mpu6500_deinit(&gs_handle);
672
673 return 1;
674 }
675
676 /* enable accel compare with previous sample */
678 if (res != 0)
679 {
680 mpu6500_interface_debug_print("mpu6500: set accel compare with previous sample failed.\n");
681 (void)mpu6500_deinit(&gs_handle);
682
683 return 1;
684 }
685
686 /* load dmp firmware */
687 mpu6500_interface_debug_print("mpu6500: load dmp firmware.\n");
688
689 /* dmp load firmware */
690 res = mpu6500_dmp_load_firmware(&gs_handle);
691 if (res != 0)
692 {
693 mpu6500_interface_debug_print("mpu6500: dmp load firmware failed.\n");
694 (void)mpu6500_deinit(&gs_handle);
695
696 return 1;
697 }
698
699 /* load dmp firmware successful */
700 mpu6500_interface_debug_print("mpu6500: load dmp firmware successful .\n");
701
702 /* mpu6500_dmp_set_pedometer_walk_time/mpu6500_dmp_get_pedometer_walk_time test */
703 mpu6500_interface_debug_print("mpu6500: mpu6500_dmp_set_pedometer_walk_time/mpu6500_dmp_get_pedometer_walk_time test.\n");
704
705 ms = 200;
706 res = mpu6500_dmp_set_pedometer_walk_time(&gs_handle, ms);
707 if (res != 0)
708 {
709 mpu6500_interface_debug_print("mpu6500: dmp set pedometer walk time failed.\n");
710 (void)mpu6500_deinit(&gs_handle);
711
712 return 1;
713 }
714 mpu6500_interface_debug_print("mpu6500: dmp set pedometer walk time %d ms.\n", ms);
715 res = mpu6500_dmp_get_pedometer_walk_time(&gs_handle, &ms_check);
716 if (res != 0)
717 {
718 mpu6500_interface_debug_print("mpu6500: dmp get pedometer walk time failed.\n");
719 (void)mpu6500_deinit(&gs_handle);
720
721 return 1;
722 }
723 mpu6500_interface_debug_print("mpu6500: check pedometer walk time %s.\n", ms_check == ms ? "ok" : "error");
724
725 /* mpu6500_dmp_set_pedometer_step_count/mpu6500_dmp_get_pedometer_step_count test */
726 mpu6500_interface_debug_print("mpu6500: mpu6500_dmp_set_pedometer_step_count/mpu6500_dmp_get_pedometer_step_count test.\n");
727
728 cnt = rand() % 1000;
729 res = mpu6500_dmp_set_pedometer_step_count(&gs_handle, cnt);
730 if (res != 0)
731 {
732 mpu6500_interface_debug_print("mpu6500: dmp set pedometer step count failed.\n");
733 (void)mpu6500_deinit(&gs_handle);
734
735 return 1;
736 }
737 mpu6500_interface_debug_print("mpu6500: dmp set pedometer step count %d.\n", cnt);
738 res = mpu6500_dmp_get_pedometer_step_count(&gs_handle, &cnt_check);
739 if (res != 0)
740 {
741 mpu6500_interface_debug_print("mpu6500: dmp get pedometer step count failed.\n");
742 (void)mpu6500_deinit(&gs_handle);
743
744 return 1;
745 }
746 mpu6500_interface_debug_print("mpu6500: check pedometer step count %s.\n", cnt_check == cnt ? "ok" : "error");
747
748 /* continuous mode */
750 if (res != 0)
751 {
752 mpu6500_interface_debug_print("mpu6500: dmp set interrupt mode failed.\n");
753 (void)mpu6500_deinit(&gs_handle);
754
755 return 1;
756 }
757 mpu6500_interface_debug_print("mpu6500: dmp set gesture continuous mode.\n");
758
759 /* mpu6500_dmp_set_fifo_rate/mpu6500_dmp_get_fifo_rate test */
760 mpu6500_interface_debug_print("mpu6500: mpu6500_dmp_set_fifo_rate/mpu6500_dmp_get_fifo_rate test.\n");
761
762 m = 50;
763 res = mpu6500_dmp_set_fifo_rate(&gs_handle, m);
764 if (res != 0)
765 {
766 mpu6500_interface_debug_print("mpu6500: dmp set fifo rate failed.\n");
767 (void)mpu6500_deinit(&gs_handle);
768
769 return 1;
770 }
771 mpu6500_interface_debug_print("mpu6500: dmp set fifo rate %dHz.\n", m);
772 res = mpu6500_dmp_get_fifo_rate(&gs_handle, &m_check);
773 if (res != 0)
774 {
775 mpu6500_interface_debug_print("mpu6500: dmp get fifo rate failed.\n");
776 (void)mpu6500_deinit(&gs_handle);
777
778 return 1;
779 }
780 mpu6500_interface_debug_print("mpu6500: check fifo rate %s.\n", m_check == m ? "ok" : "error");
781
782 /* mpu6500_dmp_set_feature test */
783 mpu6500_interface_debug_print("mpu6500: mpu6500_dmp_set_feature test.\n");
784
785 /* enable feature */
788 if (res != 0)
789 {
790 mpu6500_interface_debug_print("mpu6500: dmp set feature failed.\n");
791 (void)mpu6500_deinit(&gs_handle);
792
793 return 1;
794 }
795 mpu6500_interface_debug_print("mpu6500: enable feature pedometer.\n");
796
797 /* dmp gyro accel raw offset convert */
798 res = mpu6500_dmp_gyro_accel_raw_offset_convert(&gs_handle, gyro_offset_raw, accel_offset_raw,
799 gyro_offset, accel_offset);
800 if (res != 0)
801 {
802 mpu6500_interface_debug_print("mpu6500: dmp gyro accel raw offset convert failed.\n");
803 (void)mpu6500_deinit(&gs_handle);
804
805 return 1;
806 }
807
808 /* dmp set accel bias */
809 res = mpu6500_dmp_set_accel_bias(&gs_handle, accel_offset);
810 if (res != 0)
811 {
812 mpu6500_interface_debug_print("mpu6500: dmp set accel bias failed.\n");
813 (void)mpu6500_deinit(&gs_handle);
814
815 return 1;
816 }
817
818 /* dmp set gyro bias */
819 res = mpu6500_dmp_set_gyro_bias(&gs_handle, gyro_offset);
820 if (res != 0)
821 {
822 mpu6500_interface_debug_print("mpu6500: dmp set gyro bias failed.\n");
823 (void)mpu6500_deinit(&gs_handle);
824
825 return 1;
826 }
827
828 /* enable the dmp */
829 res = mpu6500_dmp_set_enable(&gs_handle, MPU6500_BOOL_TRUE);
830 if (res != 0)
831 {
832 mpu6500_interface_debug_print("mpu6500: dmp set enable failed.\n");
833 (void)mpu6500_deinit(&gs_handle);
834
835 return 1;
836 }
837
838 /* force reset the fifo */
839 res = mpu6500_force_fifo_reset(&gs_handle);
840 if (res != 0)
841 {
842 mpu6500_interface_debug_print("mpu6500: force fifo reset failed.\n");
843 (void)mpu6500_deinit(&gs_handle);
844
845 return 1;
846 }
847
848 /* delay 200 ms */
850
851 i = 0;
852 while (times != 0)
853 {
854 uint16_t l;
855
856 /* read the data */
857 l = 128;
858 res = mpu6500_dmp_read(&gs_handle,
859 gs_accel_raw, gs_accel_g,
860 gs_gyro_raw, gs_gyro_dps,
861 gs_quat,
862 gs_pitch, gs_roll, gs_yaw,
863 &l
864 );
865 if (res == 0)
866 {
867 i++;
868 if (i > 5)
869 {
870 i = 0;
871
872 /* get the pedometer step count */
873 res = mpu6500_dmp_get_pedometer_step_count(&gs_handle, &cnt);
874 if (res != 0)
875 {
876 mpu6500_interface_debug_print("mpu6500: dmp get pedometer step count failed.\n");
877 (void)mpu6500_deinit(&gs_handle);
878
879 return 1;
880 }
881
882 /* check the cnt */
883 if (cnt != cnt_check)
884 {
885 mpu6500_interface_debug_print("mpu6500: pedometer step count is %d.\n", cnt);
886 cnt_check = cnt;
887 times--;
888 }
889 }
890 }
891
892 /* delay 200 ms */
894 }
895
896 /* finish dmp pedometer test */
897 mpu6500_interface_debug_print("mpu6500: finish dmp pedometer test.\n");
898 (void)mpu6500_deinit(&gs_handle);
899
900 return 0;
901}
driver mpu6500 dmp pedometer test header file
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
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_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_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_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_fifo_rate(mpu6500_handle_t *handle, uint16_t rate)
dmp set the fifo rate
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_pedometer_step_count(mpu6500_handle_t *handle, uint32_t count)
dmp set the pedometer step count
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_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_enable(mpu6500_handle_t *handle, mpu6500_bool_t enable)
enable or disable the dmp
uint8_t mpu6500_dmp_get_pedometer_step_count(mpu6500_handle_t *handle, uint32_t *count)
dmp get the pedometer step count
@ MPU6500_DMP_FEATURE_GYRO_CAL
@ MPU6500_DMP_FEATURE_PEDOMETER
@ MPU6500_DMP_FEATURE_6X_QUAT
@ MPU6500_DMP_INTERRUPT_MODE_CONTINUOUS
uint8_t mpu6500_interface_spi_deinit(void)
interface spi bus deinit
void mpu6500_interface_delay_ms(uint32_t ms)
interface delay ms
void mpu6500_interface_receive_callback(uint8_t type)
interface receive callback
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_pedometer_test_irq_handler(void)
dmp pedometer test irq
uint8_t mpu6500_dmp_pedometer_test(mpu6500_interface_t interface, mpu6500_address_t addr, uint32_t times)
dmp pedometer test
uint32_t driver_version
char manufacturer_name[32]