LibDriver MPU9250
Loading...
Searching...
No Matches
driver_mpu9250_dmp_pedometer_test.c
Go to the documentation of this file.
1
36
38#include <stdlib.h>
39
40static mpu9250_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 (mpu9250_irq_handler(&gs_handle) != 0)
60 {
61 return 1;
62 }
63 else
64 {
65 return 0;
66 }
67}
68
80{
81 uint8_t res;
82 uint32_t ms;
83 uint32_t ms_check;
84 uint32_t cnt;
85 uint32_t cnt_check;
86 uint32_t i;
87 uint16_t m;
88 uint16_t m_check;
89 int32_t gyro_offset_raw[3];
90 int32_t accel_offset_raw[3];
91 int32_t gyro_offset[3];
92 int32_t accel_offset[3];
93 mpu9250_info_t info;
94
95 /* link interface function */
108
109 /* get information */
110 res = mpu9250_info(&info);
111 if (res != 0)
112 {
113 mpu9250_interface_debug_print("mpu9250: get info failed.\n");
114
115 return 1;
116 }
117 else
118 {
119 /* print chip info */
120 mpu9250_interface_debug_print("mpu9250: chip is %s.\n", info.chip_name);
121 mpu9250_interface_debug_print("mpu9250: manufacturer is %s.\n", info.manufacturer_name);
122 mpu9250_interface_debug_print("mpu9250: interface is %s.\n", info.interface);
123 mpu9250_interface_debug_print("mpu9250: driver version is %d.%d.\n", info.driver_version / 1000, (info.driver_version % 1000) / 100);
124 mpu9250_interface_debug_print("mpu9250: min supply voltage is %0.1fV.\n", info.supply_voltage_min_v);
125 mpu9250_interface_debug_print("mpu9250: max supply voltage is %0.1fV.\n", info.supply_voltage_max_v);
126 mpu9250_interface_debug_print("mpu9250: max current is %0.2fmA.\n", info.max_current_ma);
127 mpu9250_interface_debug_print("mpu9250: max temperature is %0.1fC.\n", info.temperature_max);
128 mpu9250_interface_debug_print("mpu9250: min temperature is %0.1fC.\n", info.temperature_min);
129 }
130
131 /* start dmp pedometer test */
132 mpu9250_interface_debug_print("mpu9250: start dmp pedometer test.\n");
133
134 /* set the interface */
135 res = mpu9250_set_interface(&gs_handle, interface);
136 if (res != 0)
137 {
138 mpu9250_interface_debug_print("mpu9250: set interface failed.\n");
139
140 return 1;
141 }
142
143 /* set the addr pin */
144 res = mpu9250_set_addr_pin(&gs_handle, addr);
145 if (res != 0)
146 {
147 mpu9250_interface_debug_print("mpu9250: set addr pin failed.\n");
148
149 return 1;
150 }
151
152 /* init */
153 res = mpu9250_init(&gs_handle);
154 if (res != 0)
155 {
156 mpu9250_interface_debug_print("mpu9250: init failed.\n");
157
158 return 1;
159 }
160
161 /* delay 100 ms */
163
164 /* disable sleep */
165 res = mpu9250_set_sleep(&gs_handle, MPU9250_BOOL_FALSE);
166 if (res != 0)
167 {
168 mpu9250_interface_debug_print("mpu9250: set sleep failed.\n");
169 (void)mpu9250_deinit(&gs_handle);
170
171 return 1;
172 }
173
174 /* if spi interface, disable iic interface */
175 if (interface == MPU9250_INTERFACE_SPI)
176 {
177 /* disable iic */
179 if (res != 0)
180 {
181 mpu9250_interface_debug_print("mpu9250: set disable iic slave failed.\n");
182 (void)mpu9250_deinit(&gs_handle);
183
184 return 1;
185 }
186 }
187
188 /* set fifo 1024kb */
189 res = mpu9250_set_fifo_1024kb(&gs_handle);
190 if (res != 0)
191 {
192 mpu9250_interface_debug_print("mpu9250: set fifo 1024kb failed.\n");
193 (void)mpu9250_deinit(&gs_handle);
194
195 return 1;
196 }
197
198 /* run the self test */
199 res = mpu9250_self_test(&gs_handle, gyro_offset_raw, accel_offset_raw);
200 if (res != 0)
201 {
202 mpu9250_interface_debug_print("mpu9250: self test failed.\n");
203 (void)mpu9250_deinit(&gs_handle);
204
205 return 1;
206 }
207
208 /* set pll */
210 if (res != 0)
211 {
212 mpu9250_interface_debug_print("mpu9250: set clock source failed.\n");
213 (void)mpu9250_deinit(&gs_handle);
214
215 return 1;
216 }
217
218 /* set 50Hz */
219 res = mpu9250_set_sample_rate_divider(&gs_handle, (1000 / 50) - 1);
220 if (res != 0)
221 {
222 mpu9250_interface_debug_print("mpu9250: set sample rate divider failed.\n");
223 (void)mpu9250_deinit(&gs_handle);
224
225 return 1;
226 }
227
228 /* ±2g */
230 if (res != 0)
231 {
232 mpu9250_interface_debug_print("mpu9250: set accelerometer range failed.\n");
233 (void)mpu9250_deinit(&gs_handle);
234
235 return 1;
236 }
237
238 /* ±2000dps */
240 if (res != 0)
241 {
242 mpu9250_interface_debug_print("mpu9250: set gyroscope range failed.\n");
243 (void)mpu9250_deinit(&gs_handle);
244
245 return 1;
246 }
247
248 /* set low pass filter 3 */
250 if (res != 0)
251 {
252 mpu9250_interface_debug_print("mpu9250: set low pass filter failed.\n");
253 (void)mpu9250_deinit(&gs_handle);
254
255 return 1;
256 }
257
258 /* enable temperature sensor */
259 res = mpu9250_set_ptat(&gs_handle, MPU9250_BOOL_TRUE);
260 if (res != 0)
261 {
262 mpu9250_interface_debug_print("mpu9250: set ptat failed.\n");
263 (void)mpu9250_deinit(&gs_handle);
264
265 return 1;
266 }
267
268 /* disable cycle wake up */
270 if (res != 0)
271 {
272 mpu9250_interface_debug_print("mpu9250: set cycle wake up failed.\n");
273 (void)mpu9250_deinit(&gs_handle);
274
275 return 1;
276 }
277
278 /* enable acc x */
280 if (res != 0)
281 {
282 mpu9250_interface_debug_print("mpu9250: set standby mode failed.\n");
283 (void)mpu9250_deinit(&gs_handle);
284
285 return 1;
286 }
287
288 /* enable acc y */
290 if (res != 0)
291 {
292 mpu9250_interface_debug_print("mpu9250: set standby mode failed.\n");
293 (void)mpu9250_deinit(&gs_handle);
294
295 return 1;
296 }
297
298 /* enable acc z */
300 if (res != 0)
301 {
302 mpu9250_interface_debug_print("mpu9250: set standby mode failed.\n");
303 (void)mpu9250_deinit(&gs_handle);
304
305 return 1;
306 }
307
308 /* enable gyro x */
310 if (res != 0)
311 {
312 mpu9250_interface_debug_print("mpu9250: set standby mode failed.\n");
313 (void)mpu9250_deinit(&gs_handle);
314
315 return 1;
316 }
317
318 /* enable gyro y */
320 if (res != 0)
321 {
322 mpu9250_interface_debug_print("mpu9250: set standby mode failed.\n");
323 (void)mpu9250_deinit(&gs_handle);
324
325 return 1;
326 }
327
328 /* enable gyro z */
330 if (res != 0)
331 {
332 mpu9250_interface_debug_print("mpu9250: set standby mode failed.\n");
333 (void)mpu9250_deinit(&gs_handle);
334
335 return 1;
336 }
337
338 /* disable gyroscope x test */
340 if (res != 0)
341 {
342 mpu9250_interface_debug_print("mpu9250: set gyroscope test failed.\n");
343 (void)mpu9250_deinit(&gs_handle);
344
345 return 1;
346 }
347
348 /* disable gyroscope y test */
350 if (res != 0)
351 {
352 mpu9250_interface_debug_print("mpu9250: set gyroscope test failed.\n");
353 (void)mpu9250_deinit(&gs_handle);
354
355 return 1;
356 }
357
358 /* disable gyroscope z test */
360 if (res != 0)
361 {
362 mpu9250_interface_debug_print("mpu9250: set gyroscope test failed.\n");
363 (void)mpu9250_deinit(&gs_handle);
364
365 return 1;
366 }
367
368 /* disable accelerometer x test */
370 if (res != 0)
371 {
372 mpu9250_interface_debug_print("mpu9250: set accelerometer test failed.\n");
373 (void)mpu9250_deinit(&gs_handle);
374
375 return 1;
376 }
377
378 /* disable accelerometer y test */
380 if (res != 0)
381 {
382 mpu9250_interface_debug_print("mpu9250: set accelerometer test failed.\n");
383 (void)mpu9250_deinit(&gs_handle);
384
385 return 1;
386 }
387
388 /* disable accelerometer z test */
390 if (res != 0)
391 {
392 mpu9250_interface_debug_print("mpu9250: set accelerometer test failed.\n");
393 (void)mpu9250_deinit(&gs_handle);
394
395 return 1;
396 }
397
398 /* disable temp fifo */
400 if (res != 0)
401 {
402 mpu9250_interface_debug_print("mpu9250: set fifo enable failed.\n");
403 (void)mpu9250_deinit(&gs_handle);
404
405 return 1;
406 }
407
408 /* disable xg fifo */
410 if (res != 0)
411 {
412 mpu9250_interface_debug_print("mpu9250: set fifo enable failed.\n");
413 (void)mpu9250_deinit(&gs_handle);
414
415 return 1;
416 }
417
418 /* disable yg fifo */
420 if (res != 0)
421 {
422 mpu9250_interface_debug_print("mpu9250: set fifo enable failed.\n");
423 (void)mpu9250_deinit(&gs_handle);
424
425 return 1;
426 }
427
428 /* disable zg fifo */
430 if (res != 0)
431 {
432 mpu9250_interface_debug_print("mpu9250: set fifo enable failed.\n");
433 (void)mpu9250_deinit(&gs_handle);
434
435 return 1;
436 }
437
438 /* disable accel fifo */
440 if (res != 0)
441 {
442 mpu9250_interface_debug_print("mpu9250: set fifo enable failed.\n");
443 (void)mpu9250_deinit(&gs_handle);
444
445 return 1;
446 }
447
448 /* enable fifo */
449 res = mpu9250_set_fifo(&gs_handle, MPU9250_BOOL_TRUE);
450 if (res != 0)
451 {
452 mpu9250_interface_debug_print("mpu9250: set fifo failed.\n");
453 (void)mpu9250_deinit(&gs_handle);
454
455 return 1;
456 }
457
458 /* set interrupt level low */
460 if (res != 0)
461 {
462 mpu9250_interface_debug_print("mpu9250: set interrupt level failed.\n");
463 (void)mpu9250_deinit(&gs_handle);
464
465 return 1;
466 }
467
468 /* push-pull */
470 if (res != 0)
471 {
472 mpu9250_interface_debug_print("mpu9250: set interrupt pin type failed.\n");
473 (void)mpu9250_deinit(&gs_handle);
474
475 return 1;
476 }
477
478 /* disable motion */
480 if (res != 0)
481 {
482 mpu9250_interface_debug_print("mpu9250: set interrupt failed.\n");
483 (void)mpu9250_deinit(&gs_handle);
484
485 return 1;
486 }
487
488 /* enable fifo overflow */
490 if (res != 0)
491 {
492 mpu9250_interface_debug_print("mpu9250: set interrupt failed.\n");
493 (void)mpu9250_deinit(&gs_handle);
494
495 return 1;
496 }
497
498 /* disable dmp interrupt */
500 if (res != 0)
501 {
502 mpu9250_interface_debug_print("mpu9250: set interrupt failed.\n");
503 (void)mpu9250_deinit(&gs_handle);
504
505 return 1;
506 }
507
508 /* disable fsync int */
510 if (res != 0)
511 {
512 mpu9250_interface_debug_print("mpu9250: set interrupt failed.\n");
513 (void)mpu9250_deinit(&gs_handle);
514
515 return 1;
516 }
517
518 /* disable data ready */
520 if (res != 0)
521 {
522 mpu9250_interface_debug_print("mpu9250: set interrupt failed.\n");
523 (void)mpu9250_deinit(&gs_handle);
524
525 return 1;
526 }
527
528 /* enable latch */
530 if (res != 0)
531 {
532 mpu9250_interface_debug_print("mpu9250: set interrupt latch failed.\n");
533 (void)mpu9250_deinit(&gs_handle);
534
535 return 1;
536 }
537
538 /* enable interrupt read clear */
540 if (res != 0)
541 {
542 mpu9250_interface_debug_print("mpu9250: set interrupt read clear failed.\n");
543 (void)mpu9250_deinit(&gs_handle);
544
545 return 1;
546 }
547
548 /* disable sync input */
550 if (res != 0)
551 {
552 mpu9250_interface_debug_print("mpu9250: set extern sync failed.\n");
553 (void)mpu9250_deinit(&gs_handle);
554
555 return 1;
556 }
557
558 /* disable fsync interrupt */
560 if (res != 0)
561 {
562 mpu9250_interface_debug_print("mpu9250: set fsync interrupt failed.\n");
563 (void)mpu9250_deinit(&gs_handle);
564
565 return 1;
566 }
567
568 /* fsync interrupt level low */
570 if (res != 0)
571 {
572 mpu9250_interface_debug_print("mpu9250: set fsync interrupt level failed.\n");
573 (void)mpu9250_deinit(&gs_handle);
574
575 return 1;
576 }
577
578 /* disable iic master */
580 if (res != 0)
581 {
582 mpu9250_interface_debug_print("mpu9250: set iic master failed.\n");
583 (void)mpu9250_deinit(&gs_handle);
584
585 return 1;
586 }
587
588 /* disable iic bypass */
590 if (res != 0)
591 {
592 mpu9250_interface_debug_print("mpu9250: set iic bypass failed.\n");
593 (void)mpu9250_deinit(&gs_handle);
594
595 return 1;
596 }
597
598 /* disable gyro standby */
600 if (res != 0)
601 {
602 mpu9250_interface_debug_print("mpu9250: set gyro standby failed.\n");
603 (void)mpu9250_deinit(&gs_handle);
604
605 return 1;
606 }
607
608 /* set the fifo normal mode */
610 if (res != 0)
611 {
612 mpu9250_interface_debug_print("mpu9250: set fifo mode failed.\n");
613 (void)mpu9250_deinit(&gs_handle);
614
615 return 1;
616 }
617
618 /* set gyroscope choice 0 */
619 res = mpu9250_set_gyroscope_choice(&gs_handle, 0);
620 if (res != 0)
621 {
622 mpu9250_interface_debug_print("mpu9250: set gyroscope choice failed.\n");
623 (void)mpu9250_deinit(&gs_handle);
624
625 return 1;
626 }
627
628 /* set low pass filter 3 */
630 if (res != 0)
631 {
632 mpu9250_interface_debug_print("mpu9250: set low pass filter failed.\n");
633 (void)mpu9250_deinit(&gs_handle);
634
635 return 1;
636 }
637
638 /* set accelerometer choice 0 */
639 res = mpu9250_set_accelerometer_choice(&gs_handle, 0);
640 if (res != 0)
641 {
642 mpu9250_interface_debug_print("mpu9250: set accelerometer choice failed.\n");
643 (void)mpu9250_deinit(&gs_handle);
644
645 return 1;
646 }
647
648 /* set accelerometer low pass filter 3 */
650 if (res != 0)
651 {
652 mpu9250_interface_debug_print("mpu9250: set accelerometer low pass filter failed.\n");
653 (void)mpu9250_deinit(&gs_handle);
654
655 return 1;
656 }
657
658 /* set low power accel output rate 62.5Hz */
660 if (res != 0)
661 {
662 mpu9250_interface_debug_print("mpu9250: set low power accel output rate failed.\n");
663 (void)mpu9250_deinit(&gs_handle);
664
665 return 1;
666 }
667
668 /* enable wake on motion */
670 if (res != 0)
671 {
672 mpu9250_interface_debug_print("mpu9250: set wake on motion failed.\n");
673 (void)mpu9250_deinit(&gs_handle);
674
675 return 1;
676 }
677
678 /* enable accel compare with previous sample */
680 if (res != 0)
681 {
682 mpu9250_interface_debug_print("mpu9250: set accel compare with previous sample failed.\n");
683 (void)mpu9250_deinit(&gs_handle);
684
685 return 1;
686 }
687
688 /* load dmp firmware */
689 mpu9250_interface_debug_print("mpu9250: load dmp firmware.\n");
690
691 /* dmp load firmware */
692 res = mpu9250_dmp_load_firmware(&gs_handle);
693 if (res != 0)
694 {
695 mpu9250_interface_debug_print("mpu9250: dmp load firmware failed.\n");
696 (void)mpu9250_deinit(&gs_handle);
697
698 return 1;
699 }
700
701 /* load dmp firmware successful */
702 mpu9250_interface_debug_print("mpu9250: load dmp firmware successful .\n");
703
704 /* mpu9250_dmp_set_pedometer_walk_time/mpu9250_dmp_get_pedometer_walk_time test */
705 mpu9250_interface_debug_print("mpu9250: mpu9250_dmp_set_pedometer_walk_time/mpu9250_dmp_get_pedometer_walk_time test.\n");
706
707 ms = 200;
708 res = mpu9250_dmp_set_pedometer_walk_time(&gs_handle, ms);
709 if (res != 0)
710 {
711 mpu9250_interface_debug_print("mpu9250: dmp set pedometer walk time failed.\n");
712 (void)mpu9250_deinit(&gs_handle);
713
714 return 1;
715 }
716 mpu9250_interface_debug_print("mpu9250: dmp set pedometer walk time %d ms.\n", ms);
717 res = mpu9250_dmp_get_pedometer_walk_time(&gs_handle, &ms_check);
718 if (res != 0)
719 {
720 mpu9250_interface_debug_print("mpu9250: dmp get pedometer walk time failed.\n");
721 (void)mpu9250_deinit(&gs_handle);
722
723 return 1;
724 }
725 mpu9250_interface_debug_print("mpu9250: check pedometer walk time %s.\n", ms_check == ms ? "ok" : "error");
726
727 /* mpu9250_dmp_set_pedometer_step_count/mpu9250_dmp_get_pedometer_step_count test */
728 mpu9250_interface_debug_print("mpu9250: mpu9250_dmp_set_pedometer_step_count/mpu9250_dmp_get_pedometer_step_count test.\n");
729
730 cnt = rand() % 1000;
731 res = mpu9250_dmp_set_pedometer_step_count(&gs_handle, cnt);
732 if (res != 0)
733 {
734 mpu9250_interface_debug_print("mpu9250: dmp set pedometer step count failed.\n");
735 (void)mpu9250_deinit(&gs_handle);
736
737 return 1;
738 }
739 mpu9250_interface_debug_print("mpu9250: dmp set pedometer step count %d.\n", cnt);
740 res = mpu9250_dmp_get_pedometer_step_count(&gs_handle, &cnt_check);
741 if (res != 0)
742 {
743 mpu9250_interface_debug_print("mpu9250: dmp get pedometer step count failed.\n");
744 (void)mpu9250_deinit(&gs_handle);
745
746 return 1;
747 }
748 mpu9250_interface_debug_print("mpu9250: check pedometer step count %s.\n", cnt_check == cnt ? "ok" : "error");
749
750 /* continuous mode */
752 if (res != 0)
753 {
754 mpu9250_interface_debug_print("mpu9250: dmp set interrupt mode failed.\n");
755 (void)mpu9250_deinit(&gs_handle);
756
757 return 1;
758 }
759 mpu9250_interface_debug_print("mpu9250: dmp set gesture continuous mode.\n");
760
761 /* mpu9250_dmp_set_fifo_rate/mpu9250_dmp_get_fifo_rate test */
762 mpu9250_interface_debug_print("mpu9250: mpu9250_dmp_set_fifo_rate/mpu9250_dmp_get_fifo_rate test.\n");
763
764 m = 50;
765 res = mpu9250_dmp_set_fifo_rate(&gs_handle, m);
766 if (res != 0)
767 {
768 mpu9250_interface_debug_print("mpu9250: dmp set fifo rate failed.\n");
769 (void)mpu9250_deinit(&gs_handle);
770
771 return 1;
772 }
773 mpu9250_interface_debug_print("mpu9250: dmp set fifo rate %dHz.\n", m);
774 res = mpu9250_dmp_get_fifo_rate(&gs_handle, &m_check);
775 if (res != 0)
776 {
777 mpu9250_interface_debug_print("mpu9250: dmp get fifo rate failed.\n");
778 (void)mpu9250_deinit(&gs_handle);
779
780 return 1;
781 }
782 mpu9250_interface_debug_print("mpu9250: check fifo rate %s.\n", m_check == m ? "ok" : "error");
783
784 /* mpu9250_dmp_set_feature test */
785 mpu9250_interface_debug_print("mpu9250: mpu9250_dmp_set_feature test.\n");
786
787 /* enable feature */
790 if (res != 0)
791 {
792 mpu9250_interface_debug_print("mpu9250: dmp set feature failed.\n");
793 (void)mpu9250_deinit(&gs_handle);
794
795 return 1;
796 }
797 mpu9250_interface_debug_print("mpu9250: enable feature pedometer.\n");
798
799 /* dmp gyro accel raw offset convert */
800 res = mpu9250_dmp_gyro_accel_raw_offset_convert(&gs_handle, gyro_offset_raw, accel_offset_raw,
801 gyro_offset, accel_offset);
802 if (res != 0)
803 {
804 mpu9250_interface_debug_print("mpu9250: dmp gyro accel raw offset convert failed.\n");
805 (void)mpu9250_deinit(&gs_handle);
806
807 return 1;
808 }
809
810 /* dmp set accel bias */
811 res = mpu9250_dmp_set_accel_bias(&gs_handle, accel_offset);
812 if (res != 0)
813 {
814 mpu9250_interface_debug_print("mpu9250: dmp set accel bias failed.\n");
815 (void)mpu9250_deinit(&gs_handle);
816
817 return 1;
818 }
819
820 /* dmp set gyro bias */
821 res = mpu9250_dmp_set_gyro_bias(&gs_handle, gyro_offset);
822 if (res != 0)
823 {
824 mpu9250_interface_debug_print("mpu9250: dmp set gyro bias failed.\n");
825 (void)mpu9250_deinit(&gs_handle);
826
827 return 1;
828 }
829
830 /* enable the dmp */
831 res = mpu9250_dmp_set_enable(&gs_handle, MPU9250_BOOL_TRUE);
832 if (res != 0)
833 {
834 mpu9250_interface_debug_print("mpu9250: dmp set enable failed.\n");
835 (void)mpu9250_deinit(&gs_handle);
836
837 return 1;
838 }
839
840 /* force reset the fifo */
841 res = mpu9250_force_fifo_reset(&gs_handle);
842 if (res != 0)
843 {
844 mpu9250_interface_debug_print("mpu9250: force fifo reset failed.\n");
845 (void)mpu9250_deinit(&gs_handle);
846
847 return 1;
848 }
849
850 /* delay 200 ms */
852
853 i = 0;
854 while (times != 0)
855 {
856 uint16_t l;
857
858 /* read the data */
859 l = 128;
860 res = mpu9250_dmp_read(&gs_handle,
861 gs_accel_raw, gs_accel_g,
862 gs_gyro_raw, gs_gyro_dps,
863 gs_quat,
864 gs_pitch, gs_roll, gs_yaw,
865 &l
866 );
867 if (res == 0)
868 {
869 i++;
870 if (i > 5)
871 {
872 i = 0;
873
874 /* get the pedometer step count */
875 res = mpu9250_dmp_get_pedometer_step_count(&gs_handle, &cnt);
876 if (res != 0)
877 {
878 mpu9250_interface_debug_print("mpu9250: dmp get pedometer step count failed.\n");
879 (void)mpu9250_deinit(&gs_handle);
880
881 return 1;
882 }
883
884 /* check the cnt */
885 if (cnt != cnt_check)
886 {
887 mpu9250_interface_debug_print("mpu9250: pedometer step count is %d.\n", cnt);
888 cnt_check = cnt;
889 times--;
890 }
891 }
892 }
893
894 /* delay 200 ms */
896 }
897
898 /* finish dmp pedometer test */
899 mpu9250_interface_debug_print("mpu9250: finish dmp pedometer test.\n");
900 (void)mpu9250_deinit(&gs_handle);
901
902 return 0;
903}
driver mpu9250 dmp pedometer test header file
uint8_t mpu9250_set_accelerometer_low_pass_filter(mpu9250_handle_t *handle, mpu9250_accelerometer_low_pass_filter_t filter)
set the accelerometer low pass filter
uint8_t mpu9250_set_wake_on_motion(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable wake on motion
uint8_t mpu9250_set_accel_compare_with_previous_sample(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable accel compare with previous sample
uint8_t mpu9250_set_fifo_mode(mpu9250_handle_t *handle, mpu9250_fifo_mode mode)
set the fifo mode
uint8_t mpu9250_self_test(mpu9250_handle_t *handle, int32_t gyro_offset_raw[3], int32_t accel_offset_raw[3])
run the self test
uint8_t mpu9250_set_addr_pin(mpu9250_handle_t *handle, mpu9250_address_t addr_pin)
set the chip address pin
uint8_t mpu9250_set_ptat(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the temperature sensor
uint8_t mpu9250_set_fifo_enable(mpu9250_handle_t *handle, mpu9250_fifo_t fifo, mpu9250_bool_t enable)
enable or disable the fifo function
uint8_t mpu9250_set_standby_mode(mpu9250_handle_t *handle, mpu9250_source_t source, mpu9250_bool_t enable)
set source into standby mode
uint8_t mpu9250_set_cycle_wake_up(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the cycle wake up mode
uint8_t mpu9250_set_interrupt_latch(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the interrupt latch
uint8_t mpu9250_set_extern_sync(mpu9250_handle_t *handle, mpu9250_extern_sync_t sync)
set the extern sync type
uint8_t mpu9250_set_gyro_standby(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the gyro standby
mpu9250_address_t
mpu9250 address enumeration definition
uint8_t mpu9250_set_fsync_interrupt(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the fsync interrupt
uint8_t mpu9250_set_iic_bypass(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the iic bypass
uint8_t mpu9250_info(mpu9250_info_t *info)
get the chip's information
uint8_t mpu9250_set_accelerometer_test(mpu9250_handle_t *handle, mpu9250_axis_t axis, mpu9250_bool_t enable)
set the accelerometer test
uint8_t mpu9250_set_interrupt_level(mpu9250_handle_t *handle, mpu9250_pin_level_t level)
set the interrupt level
uint8_t mpu9250_set_interrupt_read_clear(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the interrupt reading clear
uint8_t mpu9250_set_interface(mpu9250_handle_t *handle, mpu9250_interface_t interface)
set the chip interface
uint8_t mpu9250_irq_handler(mpu9250_handle_t *handle)
irq handler
struct mpu9250_info_s mpu9250_info_t
mpu9250 information structure definition
mpu9250_interface_t
mpu9250 interface enumeration definition
uint8_t mpu9250_set_interrupt(mpu9250_handle_t *handle, mpu9250_interrupt_t type, mpu9250_bool_t enable)
enable or disable the interrupt
uint8_t mpu9250_set_fsync_interrupt_level(mpu9250_handle_t *handle, mpu9250_pin_level_t level)
set the fsync interrupt level
uint8_t mpu9250_set_gyroscope_choice(mpu9250_handle_t *handle, uint8_t choice)
set the gyroscope choice
uint8_t mpu9250_deinit(mpu9250_handle_t *handle)
close the chip
struct mpu9250_handle_s mpu9250_handle_t
mpu9250 handle structure definition
uint8_t mpu9250_set_fifo_1024kb(mpu9250_handle_t *handle)
set fifo 1024kb
uint8_t mpu9250_set_low_pass_filter(mpu9250_handle_t *handle, mpu9250_low_pass_filter_t filter)
set the low pass filter
uint8_t mpu9250_set_gyroscope_test(mpu9250_handle_t *handle, mpu9250_axis_t axis, mpu9250_bool_t enable)
set the gyroscope test
uint8_t mpu9250_set_clock_source(mpu9250_handle_t *handle, mpu9250_clock_source_t clock_source)
set the chip clock source
uint8_t mpu9250_set_low_power_accel_output_rate(mpu9250_handle_t *handle, mpu9250_low_power_accel_output_rate_t rate)
set the low power accel output rate
uint8_t mpu9250_set_disable_iic_slave(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the iic slave mode
uint8_t mpu9250_set_sample_rate_divider(mpu9250_handle_t *handle, uint8_t d)
set the sample rate divider
uint8_t mpu9250_set_fifo(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable fifo
uint8_t mpu9250_init(mpu9250_handle_t *handle)
initialize the chip
uint8_t mpu9250_set_accelerometer_choice(mpu9250_handle_t *handle, uint8_t choice)
set the accelerometer choice
uint8_t mpu9250_set_gyroscope_range(mpu9250_handle_t *handle, mpu9250_gyroscope_range_t range)
set the gyroscope range
uint8_t mpu9250_set_interrupt_pin_type(mpu9250_handle_t *handle, mpu9250_pin_type_t type)
set the interrupt pin type
uint8_t mpu9250_set_iic_master(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the iic master mode
uint8_t mpu9250_set_accelerometer_range(mpu9250_handle_t *handle, mpu9250_accelerometer_range_t range)
set the accelerometer range
uint8_t mpu9250_set_sleep(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the sleep mode
uint8_t mpu9250_force_fifo_reset(mpu9250_handle_t *handle)
force reset the fifo
@ MPU9250_ACCELEROMETER_RANGE_2G
@ MPU9250_PIN_TYPE_PUSH_PULL
@ MPU9250_GYROSCOPE_RANGE_2000DPS
@ MPU9250_INTERRUPT_MOTION
@ MPU9250_INTERRUPT_DATA_READY
@ MPU9250_INTERRUPT_FSYNC_INT
@ MPU9250_INTERRUPT_DMP
@ MPU9250_INTERRUPT_FIFO_OVERFLOW
@ MPU9250_EXTERN_SYNC_INPUT_DISABLED
@ MPU9250_SOURCE_GYRO_X
@ MPU9250_SOURCE_ACC_Z
@ MPU9250_SOURCE_GYRO_Y
@ MPU9250_SOURCE_GYRO_Z
@ MPU9250_SOURCE_ACC_X
@ MPU9250_SOURCE_ACC_Y
@ MPU9250_INTERFACE_SPI
@ MPU9250_BOOL_TRUE
@ MPU9250_BOOL_FALSE
@ MPU9250_LOW_PASS_FILTER_3
@ MPU9250_FIFO_MODE_NORMAL
@ MPU9250_LOW_POWER_ACCEL_OUTPUT_RATE_62P50
@ MPU9250_AXIS_X
@ MPU9250_AXIS_Z
@ MPU9250_AXIS_Y
@ MPU9250_ACCELEROMETER_LOW_PASS_FILTER_3
@ MPU9250_PIN_LEVEL_LOW
@ MPU9250_FIFO_XG
@ MPU9250_FIFO_YG
@ MPU9250_FIFO_ZG
@ MPU9250_FIFO_ACCEL
@ MPU9250_FIFO_TEMP
@ MPU9250_CLOCK_SOURCE_PLL
uint8_t mpu9250_dmp_set_accel_bias(mpu9250_handle_t *handle, int32_t bias[3])
dmp set the accel bias
uint8_t mpu9250_dmp_get_fifo_rate(mpu9250_handle_t *handle, uint16_t *rate)
dmp get the fifo rate
uint8_t mpu9250_dmp_set_gyro_bias(mpu9250_handle_t *handle, int32_t bias[3])
dmp set the gyro bias
uint8_t mpu9250_dmp_get_pedometer_walk_time(mpu9250_handle_t *handle, uint32_t *ms)
dmp get the pedometer walk time
uint8_t mpu9250_dmp_set_fifo_rate(mpu9250_handle_t *handle, uint16_t rate)
dmp set the fifo rate
uint8_t mpu9250_dmp_load_firmware(mpu9250_handle_t *handle)
load the dmp firmware
uint8_t mpu9250_dmp_set_enable(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the dmp
uint8_t mpu9250_dmp_set_feature(mpu9250_handle_t *handle, uint16_t mask)
dmp enable or disable the dmp feature
uint8_t mpu9250_dmp_set_interrupt_mode(mpu9250_handle_t *handle, mpu9250_dmp_interrupt_mode_t mode)
dmp set the interrupt mode
uint8_t mpu9250_dmp_get_pedometer_step_count(mpu9250_handle_t *handle, uint32_t *count)
dmp get the pedometer step count
uint8_t mpu9250_dmp_set_pedometer_step_count(mpu9250_handle_t *handle, uint32_t count)
dmp set the pedometer step count
uint8_t mpu9250_dmp_gyro_accel_raw_offset_convert(mpu9250_handle_t *handle, int32_t gyro_offset_raw[3], int32_t accel_offset_raw[3], int32_t gyro_offset[3], int32_t accel_offset[3])
dmp gyro accel raw offset convert
uint8_t mpu9250_dmp_set_pedometer_walk_time(mpu9250_handle_t *handle, uint32_t ms)
dmp set the pedometer walk time
uint8_t mpu9250_dmp_read(mpu9250_handle_t *handle, int16_t(*accel_raw)[3], float(*accel_g)[3], int16_t(*gyro_raw)[3], float(*gyro_dps)[3], int32_t(*quat)[4], float *pitch, float *roll, float *yaw, uint16_t *l)
dmp read the data
@ MPU9250_DMP_FEATURE_6X_QUAT
@ MPU9250_DMP_FEATURE_GYRO_CAL
@ MPU9250_DMP_FEATURE_PEDOMETER
@ MPU9250_DMP_INTERRUPT_MODE_CONTINUOUS
void mpu9250_interface_debug_print(const char *const fmt,...)
interface print format data
uint8_t mpu9250_interface_spi_write(uint8_t reg, uint8_t *buf, uint16_t len)
interface spi bus write
uint8_t mpu9250_interface_iic_deinit(void)
interface iic bus deinit
uint8_t mpu9250_interface_iic_write(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
interface iic bus write
uint8_t mpu9250_interface_iic_read(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
interface iic bus read
uint8_t mpu9250_interface_iic_init(void)
interface iic bus init
uint8_t mpu9250_interface_spi_read(uint8_t reg, uint8_t *buf, uint16_t len)
interface spi bus read
uint8_t mpu9250_interface_spi_init(void)
interface spi bus init
void mpu9250_interface_receive_callback(uint8_t type)
interface receive callback
void mpu9250_interface_delay_ms(uint32_t ms)
interface delay ms
uint8_t mpu9250_interface_spi_deinit(void)
interface spi bus deinit
uint8_t mpu9250_dmp_pedometer_test(mpu9250_interface_t interface, mpu9250_address_t addr, uint32_t times)
dmp pedometer test
uint8_t mpu9250_dmp_pedometer_test_irq_handler(void)
dmp pedometer test irq
uint32_t driver_version
char manufacturer_name[32]