| LibDriver MPU9250 1.0.0 MPU9250 full function driver

driver_mpu9250_dmp_pedometer_test.c
Go to the documentation of this file.
1
37 #include "driver_mpu9250_dmp_pedometer_test.h"
38 #include <stdlib.h>
39
40 static mpu9250_handle_t gs_handle;
41 static int16_t gs_accel_raw[128][3];
42 static float gs_accel_g[128][3];
43 static int16_t gs_gyro_raw[128][3];
44 static float gs_gyro_dps[128][3];
45 static int32_t gs_quat[128][4];
46 static float gs_pitch[128];
47 static float gs_roll[128];
48 static float gs_yaw[128];
57 uint8_t mpu9250_dmp_pedometer_test_irq_handler(void)
58 {
59 if (mpu9250_irq_handler(&gs_handle) != 0)
60 {
61 return 1;
62 }
63 else
64 {
65 return 0;
66 }
67 }
68
79 uint8_t mpu9250_dmp_pedometer_test(mpu9250_interface_t interface, mpu9250_address_t addr, uint32_t times)
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 */
96 DRIVER_MPU9250_LINK_INIT(&gs_handle, mpu9250_handle_t);
97 DRIVER_MPU9250_LINK_IIC_INIT(&gs_handle, mpu9250_interface_iic_init);
98 DRIVER_MPU9250_LINK_IIC_DEINIT(&gs_handle, mpu9250_interface_iic_deinit);
99 DRIVER_MPU9250_LINK_IIC_READ(&gs_handle, mpu9250_interface_iic_read);
100 DRIVER_MPU9250_LINK_IIC_WRITE(&gs_handle, mpu9250_interface_iic_write);
101 DRIVER_MPU9250_LINK_SPI_INIT(&gs_handle, mpu9250_interface_spi_init);
102 DRIVER_MPU9250_LINK_SPI_DEINIT(&gs_handle, mpu9250_interface_spi_deinit);
103 DRIVER_MPU9250_LINK_SPI_READ(&gs_handle, mpu9250_interface_spi_read);
104 DRIVER_MPU9250_LINK_SPI_WRITE(&gs_handle, mpu9250_interface_spi_write);
105 DRIVER_MPU9250_LINK_DELAY_MS(&gs_handle, mpu9250_interface_delay_ms);
106 DRIVER_MPU9250_LINK_DEBUG_PRINT(&gs_handle, mpu9250_interface_debug_print);
107 DRIVER_MPU9250_LINK_RECEIVE_CALLBACK(&gs_handle, mpu9250_interface_receive_callback);
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 */
162 mpu9250_interface_delay_ms(100);
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 */
178 res = mpu9250_set_disable_iic_slave(&gs_handle, MPU9250_BOOL_TRUE);
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 */
209 res = mpu9250_set_clock_source(&gs_handle, MPU9250_CLOCK_SOURCE_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 */
229 res = mpu9250_set_accelerometer_range(&gs_handle, MPU9250_ACCELEROMETER_RANGE_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 */
239 res = mpu9250_set_gyroscope_range(&gs_handle, MPU9250_GYROSCOPE_RANGE_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 */
249 res = mpu9250_set_low_pass_filter(&gs_handle, MPU9250_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 */
269 res = mpu9250_set_cycle_wake_up(&gs_handle, MPU9250_BOOL_FALSE);
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 */
279 res = mpu9250_set_standby_mode(&gs_handle, MPU9250_SOURCE_ACC_X, MPU9250_BOOL_FALSE);
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 */
289 res = mpu9250_set_standby_mode(&gs_handle, MPU9250_SOURCE_ACC_Y, MPU9250_BOOL_FALSE);
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 */
299 res = mpu9250_set_standby_mode(&gs_handle, MPU9250_SOURCE_ACC_Z, MPU9250_BOOL_FALSE);
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 */
309 res = mpu9250_set_standby_mode(&gs_handle, MPU9250_SOURCE_GYRO_X, MPU9250_BOOL_FALSE);
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 */
319 res = mpu9250_set_standby_mode(&gs_handle, MPU9250_SOURCE_GYRO_Y, MPU9250_BOOL_FALSE);
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 */
329 res = mpu9250_set_standby_mode(&gs_handle, MPU9250_SOURCE_GYRO_Z, MPU9250_BOOL_FALSE);
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 */
339 res = mpu9250_set_gyroscope_test(&gs_handle, MPU9250_AXIS_X, MPU9250_BOOL_FALSE);
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 */
349 res = mpu9250_set_gyroscope_test(&gs_handle, MPU9250_AXIS_Y, MPU9250_BOOL_FALSE);
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 */
359 res = mpu9250_set_gyroscope_test(&gs_handle, MPU9250_AXIS_Z, MPU9250_BOOL_FALSE);
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 */
369 res = mpu9250_set_accelerometer_test(&gs_handle, MPU9250_AXIS_X, MPU9250_BOOL_FALSE);
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 */
379 res = mpu9250_set_accelerometer_test(&gs_handle, MPU9250_AXIS_Y, MPU9250_BOOL_FALSE);
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 */
389 res = mpu9250_set_accelerometer_test(&gs_handle, MPU9250_AXIS_Z, MPU9250_BOOL_FALSE);
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 */
399 res = mpu9250_set_fifo_enable(&gs_handle, MPU9250_FIFO_TEMP, MPU9250_BOOL_FALSE);
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 */
409 res = mpu9250_set_fifo_enable(&gs_handle, MPU9250_FIFO_XG, MPU9250_BOOL_FALSE);
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 */
419 res = mpu9250_set_fifo_enable(&gs_handle, MPU9250_FIFO_YG, MPU9250_BOOL_FALSE);
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 */
429 res = mpu9250_set_fifo_enable(&gs_handle, MPU9250_FIFO_ZG, MPU9250_BOOL_FALSE);
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 */
439 res = mpu9250_set_fifo_enable(&gs_handle, MPU9250_FIFO_ACCEL, MPU9250_BOOL_FALSE);
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 */
459 res = mpu9250_set_interrupt_level(&gs_handle, MPU9250_PIN_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 */
469 res = mpu9250_set_interrupt_pin_type(&gs_handle, MPU9250_PIN_TYPE_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 */
479 res = mpu9250_set_interrupt(&gs_handle, MPU9250_INTERRUPT_MOTION, MPU9250_BOOL_FALSE);
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 */
489 res = mpu9250_set_interrupt(&gs_handle, MPU9250_INTERRUPT_FIFO_OVERFLOW, MPU9250_BOOL_TRUE);
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 */
499 res = mpu9250_set_interrupt(&gs_handle, MPU9250_INTERRUPT_DMP, MPU9250_BOOL_FALSE);
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 */
509 res = mpu9250_set_interrupt(&gs_handle, MPU9250_INTERRUPT_FSYNC_INT, MPU9250_BOOL_FALSE);
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 */
519 res = mpu9250_set_interrupt(&gs_handle, MPU9250_INTERRUPT_DATA_READY, MPU9250_BOOL_FALSE);
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 */
529 res = mpu9250_set_interrupt_latch(&gs_handle, MPU9250_BOOL_TRUE);
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 */
539 res = mpu9250_set_interrupt_read_clear(&gs_handle, MPU9250_BOOL_TRUE);
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 */
549 res = mpu9250_set_extern_sync(&gs_handle, MPU9250_EXTERN_SYNC_INPUT_DISABLED);
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 */
559 res = mpu9250_set_fsync_interrupt(&gs_handle, MPU9250_BOOL_FALSE);
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 */
569 res = mpu9250_set_fsync_interrupt_level(&gs_handle, MPU9250_PIN_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 */
579 res = mpu9250_set_iic_master(&gs_handle, MPU9250_BOOL_FALSE);
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 */
589 res = mpu9250_set_iic_bypass(&gs_handle, MPU9250_BOOL_FALSE);
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 */
599 res = mpu9250_set_gyro_standby(&gs_handle, MPU9250_BOOL_FALSE);
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 */
609 res = mpu9250_set_fifo_mode(&gs_handle, MPU9250_FIFO_MODE_NORMAL);
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 */
629 res = mpu9250_set_low_pass_filter(&gs_handle, MPU9250_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 */
649 res = mpu9250_set_accelerometer_low_pass_filter(&gs_handle, MPU9250_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 */
659 res = mpu9250_set_low_power_accel_output_rate(&gs_handle, MPU9250_LOW_POWER_ACCEL_OUTPUT_RATE_62P50);
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 */
669 res = mpu9250_set_wake_on_motion(&gs_handle, MPU9250_BOOL_TRUE);
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 */
679 res = mpu9250_set_accel_compare_with_previous_sample(&gs_handle, MPU9250_BOOL_TRUE);
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 */
751 res = mpu9250_dmp_set_interrupt_mode(&gs_handle, MPU9250_DMP_INTERRUPT_MODE_CONTINUOUS);
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 */
788 res = mpu9250_dmp_set_feature(&gs_handle, MPU9250_DMP_FEATURE_6X_QUAT | MPU9250_DMP_FEATURE_GYRO_CAL |
789 MPU9250_DMP_FEATURE_PEDOMETER);
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 */
851 mpu9250_interface_delay_ms(200);
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 */
895 mpu9250_interface_delay_ms(200);
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.h
driver mpu9250 dmp pedometer test header file
mpu9250_set_accelerometer_low_pass_filter
uint8_t mpu9250_set_accelerometer_low_pass_filter(mpu9250_handle_t *handle, mpu9250_accelerometer_low_pass_filter_t filter)
set the accelerometer low pass filter
Definition: driver_mpu9250.c:7886
mpu9250_set_wake_on_motion
uint8_t mpu9250_set_wake_on_motion(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable wake on motion
Definition: driver_mpu9250.c:8050
mpu9250_set_accel_compare_with_previous_sample
uint8_t mpu9250_set_accel_compare_with_previous_sample(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable accel compare with previous sample
Definition: driver_mpu9250.c:8132
mpu9250_set_fifo_mode
uint8_t mpu9250_set_fifo_mode(mpu9250_handle_t *handle, mpu9250_fifo_mode mode)
set the fifo mode
Definition: driver_mpu9250.c:7249
mpu9250_self_test
uint8_t mpu9250_self_test(mpu9250_handle_t *handle, int32_t gyro_offset_raw[3], int32_t accel_offset_raw[3])
run the self test
Definition: driver_mpu9250.c:10094
mpu9250_set_addr_pin
uint8_t mpu9250_set_addr_pin(mpu9250_handle_t *handle, mpu9250_address_t addr_pin)
set the chip address pin
Definition: driver_mpu9250.c:3964
mpu9250_set_ptat
uint8_t mpu9250_set_ptat(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the temperature sensor
Definition: driver_mpu9250.c:6449
mpu9250_set_fifo_enable
uint8_t mpu9250_set_fifo_enable(mpu9250_handle_t *handle, mpu9250_fifo_t fifo, mpu9250_bool_t enable)
enable or disable the fifo function
Definition: driver_mpu9250.c:8215
mpu9250_set_standby_mode
uint8_t mpu9250_set_standby_mode(mpu9250_handle_t *handle, mpu9250_source_t source, mpu9250_bool_t enable)
set source into standby mode
Definition: driver_mpu9250.c:6778
mpu9250_set_cycle_wake_up
uint8_t mpu9250_set_cycle_wake_up(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the cycle wake up mode
Definition: driver_mpu9250.c:6531
mpu9250_set_interrupt_latch
uint8_t mpu9250_set_interrupt_latch(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the interrupt latch
Definition: driver_mpu9250.c:8462
mpu9250_set_extern_sync
uint8_t mpu9250_set_extern_sync(mpu9250_handle_t *handle, mpu9250_extern_sync_t sync)
set the extern sync type
Definition: driver_mpu9250.c:7085
mpu9250_set_gyro_standby
uint8_t mpu9250_set_gyro_standby(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the gyro standby
Definition: driver_mpu9250.c:6695
mpu9250_address_t
mpu9250_address_t
mpu9250 address enumeration definition
Definition: driver_mpu9250.h:72
mpu9250_set_fsync_interrupt
uint8_t mpu9250_set_fsync_interrupt(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the fsync interrupt
Definition: driver_mpu9250.c:8708
mpu9250_set_iic_bypass
uint8_t mpu9250_set_iic_bypass(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the iic bypass
Definition: driver_mpu9250.c:8790
mpu9250_info
uint8_t mpu9250_info(mpu9250_info_t *info)
get the chip's information
Definition: driver_mpu9250.c:13083
mpu9250_set_accelerometer_test
uint8_t mpu9250_set_accelerometer_test(mpu9250_handle_t *handle, mpu9250_axis_t axis, mpu9250_bool_t enable)
set the accelerometer test
Definition: driver_mpu9250.c:7587
mpu9250_set_interrupt_level
uint8_t mpu9250_set_interrupt_level(mpu9250_handle_t *handle, mpu9250_pin_level_t level)
set the interrupt level
Definition: driver_mpu9250.c:8298
mpu9250_set_interrupt_read_clear
uint8_t mpu9250_set_interrupt_read_clear(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the interrupt reading clear
Definition: driver_mpu9250.c:8544
mpu9250_set_interface
uint8_t mpu9250_set_interface(mpu9250_handle_t *handle, mpu9250_interface_t interface)
set the chip interface
Definition: driver_mpu9250.c:3922
mpu9250_irq_handler
uint8_t mpu9250_irq_handler(mpu9250_handle_t *handle)
irq handler
Definition: driver_mpu9250.c:4668
mpu9250_interface_t
mpu9250_interface_t
mpu9250 interface enumeration definition
Definition: driver_mpu9250.h:63
mpu9250_set_interrupt
uint8_t mpu9250_set_interrupt(mpu9250_handle_t *handle, mpu9250_interrupt_t type, mpu9250_bool_t enable)
enable or disable the interrupt
Definition: driver_mpu9250.c:8873
mpu9250_set_fsync_interrupt_level
uint8_t mpu9250_set_fsync_interrupt_level(mpu9250_handle_t *handle, mpu9250_pin_level_t level)
set the fsync interrupt level
Definition: driver_mpu9250.c:8626
mpu9250_set_gyroscope_choice
uint8_t mpu9250_set_gyroscope_choice(mpu9250_handle_t *handle, uint8_t choice)
set the gyroscope choice
Definition: driver_mpu9250.c:7498
mpu9250_deinit
uint8_t mpu9250_deinit(mpu9250_handle_t *handle)
close the chip
Definition: driver_mpu9250.c:4168
mpu9250_set_fifo_1024kb
uint8_t mpu9250_set_fifo_1024kb(mpu9250_handle_t *handle)
set fifo 1024kb
Definition: driver_mpu9250.c:7751
mpu9250_set_low_pass_filter
uint8_t mpu9250_set_low_pass_filter(mpu9250_handle_t *handle, mpu9250_low_pass_filter_t filter)
set the low pass filter
Definition: driver_mpu9250.c:7167
mpu9250_set_gyroscope_test
uint8_t mpu9250_set_gyroscope_test(mpu9250_handle_t *handle, mpu9250_axis_t axis, mpu9250_bool_t enable)
set the gyroscope test
Definition: driver_mpu9250.c:7332
mpu9250_set_clock_source
uint8_t mpu9250_set_clock_source(mpu9250_handle_t *handle, mpu9250_clock_source_t clock_source)
set the chip clock source
Definition: driver_mpu9250.c:6367
mpu9250_set_low_power_accel_output_rate
uint8_t mpu9250_set_low_power_accel_output_rate(mpu9250_handle_t *handle, mpu9250_low_power_accel_output_rate_t rate)
set the low power accel output rate
Definition: driver_mpu9250.c:7968
mpu9250_set_disable_iic_slave
uint8_t mpu9250_set_disable_iic_slave(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the iic slave mode
Definition: driver_mpu9250.c:5961
mpu9250_set_sample_rate_divider
uint8_t mpu9250_set_sample_rate_divider(mpu9250_handle_t *handle, uint8_t d)
set the sample rate divider
Definition: driver_mpu9250.c:7015
mpu9250_set_fifo
uint8_t mpu9250_set_fifo(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable fifo
Definition: driver_mpu9250.c:5763
mpu9250_init
uint8_t mpu9250_init(mpu9250_handle_t *handle)
initialize the chip
Definition: driver_mpu9250.c:4009
mpu9250_set_accelerometer_choice
uint8_t mpu9250_set_accelerometer_choice(mpu9250_handle_t *handle, uint8_t choice)
set the accelerometer choice
Definition: driver_mpu9250.c:7797
mpu9250_set_gyroscope_range
uint8_t mpu9250_set_gyroscope_range(mpu9250_handle_t *handle, mpu9250_gyroscope_range_t range)
set the gyroscope range
Definition: driver_mpu9250.c:7415
mpu9250_set_interrupt_pin_type
uint8_t mpu9250_set_interrupt_pin_type(mpu9250_handle_t *handle, mpu9250_pin_type_t type)
set the interrupt pin type
Definition: driver_mpu9250.c:8380
mpu9250_set_iic_master
uint8_t mpu9250_set_iic_master(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the iic master mode
Definition: driver_mpu9250.c:5879
mpu9250_set_accelerometer_range
uint8_t mpu9250_set_accelerometer_range(mpu9250_handle_t *handle, mpu9250_accelerometer_range_t range)
set the accelerometer range
Definition: driver_mpu9250.c:7670
mpu9250_set_sleep
uint8_t mpu9250_set_sleep(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the sleep mode
Definition: driver_mpu9250.c:6613
mpu9250_force_fifo_reset
uint8_t mpu9250_force_fifo_reset(mpu9250_handle_t *handle)
force reset the fifo
Definition: driver_mpu9250.c:5844
MPU9250_ACCELEROMETER_RANGE_2G
@ MPU9250_ACCELEROMETER_RANGE_2G
Definition: driver_mpu9250.h:212
MPU9250_PIN_TYPE_PUSH_PULL
@ MPU9250_PIN_TYPE_PUSH_PULL
Definition: driver_mpu9250.h:254
MPU9250_GYROSCOPE_RANGE_2000DPS
@ MPU9250_GYROSCOPE_RANGE_2000DPS
Definition: driver_mpu9250.h:204
MPU9250_INTERRUPT_MOTION
@ MPU9250_INTERRUPT_MOTION
Definition: driver_mpu9250.h:263
MPU9250_INTERRUPT_DATA_READY
@ MPU9250_INTERRUPT_DATA_READY
Definition: driver_mpu9250.h:267
MPU9250_INTERRUPT_FSYNC_INT
@ MPU9250_INTERRUPT_FSYNC_INT
Definition: driver_mpu9250.h:265
MPU9250_INTERRUPT_DMP
@ MPU9250_INTERRUPT_DMP
Definition: driver_mpu9250.h:266
MPU9250_INTERRUPT_FIFO_OVERFLOW
@ MPU9250_INTERRUPT_FIFO_OVERFLOW
Definition: driver_mpu9250.h:264
MPU9250_EXTERN_SYNC_INPUT_DISABLED
@ MPU9250_EXTERN_SYNC_INPUT_DISABLED
Definition: driver_mpu9250.h:124
MPU9250_SOURCE_GYRO_X
@ MPU9250_SOURCE_GYRO_X
Definition: driver_mpu9250.h:94
MPU9250_SOURCE_ACC_Z
@ MPU9250_SOURCE_ACC_Z
Definition: driver_mpu9250.h:93
MPU9250_SOURCE_GYRO_Y
@ MPU9250_SOURCE_GYRO_Y
Definition: driver_mpu9250.h:95
MPU9250_SOURCE_GYRO_Z
@ MPU9250_SOURCE_GYRO_Z
Definition: driver_mpu9250.h:96
MPU9250_SOURCE_ACC_X
@ MPU9250_SOURCE_ACC_X
Definition: driver_mpu9250.h:91
MPU9250_SOURCE_ACC_Y
@ MPU9250_SOURCE_ACC_Y
Definition: driver_mpu9250.h:92
MPU9250_INTERFACE_SPI
@ MPU9250_INTERFACE_SPI
Definition: driver_mpu9250.h:65
MPU9250_BOOL_TRUE
@ MPU9250_BOOL_TRUE
Definition: driver_mpu9250.h:83
MPU9250_BOOL_FALSE
@ MPU9250_BOOL_FALSE
Definition: driver_mpu9250.h:82
MPU9250_LOW_PASS_FILTER_3
@ MPU9250_LOW_PASS_FILTER_3
Definition: driver_mpu9250.h:144
MPU9250_FIFO_MODE_NORMAL
@ MPU9250_FIFO_MODE_NORMAL
Definition: driver_mpu9250.h:237
MPU9250_LOW_POWER_ACCEL_OUTPUT_RATE_62P50
@ MPU9250_LOW_POWER_ACCEL_OUTPUT_RATE_62P50
Definition: driver_mpu9250.h:180
MPU9250_AXIS_X
@ MPU9250_AXIS_X
Definition: driver_mpu9250.h:193
MPU9250_AXIS_Z
@ MPU9250_AXIS_Z
Definition: driver_mpu9250.h:191
MPU9250_AXIS_Y
@ MPU9250_AXIS_Y
Definition: driver_mpu9250.h:192
MPU9250_ACCELEROMETER_LOW_PASS_FILTER_3
@ MPU9250_ACCELEROMETER_LOW_PASS_FILTER_3
Definition: driver_mpu9250.h:160
MPU9250_PIN_LEVEL_LOW
@ MPU9250_PIN_LEVEL_LOW
Definition: driver_mpu9250.h:246
MPU9250_FIFO_XG
@ MPU9250_FIFO_XG
Definition: driver_mpu9250.h:224
MPU9250_FIFO_YG
@ MPU9250_FIFO_YG
Definition: driver_mpu9250.h:225
MPU9250_FIFO_ZG
@ MPU9250_FIFO_ZG
Definition: driver_mpu9250.h:226
MPU9250_FIFO_ACCEL
@ MPU9250_FIFO_ACCEL
Definition: driver_mpu9250.h:227
MPU9250_FIFO_TEMP
@ MPU9250_FIFO_TEMP
Definition: driver_mpu9250.h:223
MPU9250_CLOCK_SOURCE_PLL
@ MPU9250_CLOCK_SOURCE_PLL
Definition: driver_mpu9250.h:105
mpu9250_dmp_set_accel_bias
uint8_t mpu9250_dmp_set_accel_bias(mpu9250_handle_t *handle, int32_t bias[3])
dmp set the accel bias
Definition: driver_mpu9250.c:2289
mpu9250_dmp_get_fifo_rate
uint8_t mpu9250_dmp_get_fifo_rate(mpu9250_handle_t *handle, uint16_t *rate)
dmp get the fifo rate
Definition: driver_mpu9250.c:3004
mpu9250_dmp_set_gyro_bias
uint8_t mpu9250_dmp_set_gyro_bias(mpu9250_handle_t *handle, int32_t bias[3])
dmp set the gyro bias
Definition: driver_mpu9250.c:2199
mpu9250_dmp_get_pedometer_walk_time
uint8_t mpu9250_dmp_get_pedometer_walk_time(mpu9250_handle_t *handle, uint32_t *ms)
dmp get the pedometer walk time
Definition: driver_mpu9250.c:1214
mpu9250_dmp_set_fifo_rate
uint8_t mpu9250_dmp_set_fifo_rate(mpu9250_handle_t *handle, uint16_t rate)
dmp set the fifo rate
Definition: driver_mpu9250.c:2938
mpu9250_dmp_load_firmware
uint8_t mpu9250_dmp_load_firmware(mpu9250_handle_t *handle)
load the dmp firmware
Definition: driver_mpu9250.c:1087
mpu9250_dmp_set_enable
uint8_t mpu9250_dmp_set_enable(mpu9250_handle_t *handle, mpu9250_bool_t enable)
enable or disable the dmp
Definition: driver_mpu9250.c:3767
mpu9250_dmp_set_feature
uint8_t mpu9250_dmp_set_feature(mpu9250_handle_t *handle, uint16_t mask)
dmp enable or disable the dmp feature
Definition: driver_mpu9250.c:2496
mpu9250_dmp_set_interrupt_mode
uint8_t mpu9250_dmp_set_interrupt_mode(mpu9250_handle_t *handle, mpu9250_dmp_interrupt_mode_t mode)
dmp set the interrupt mode
Definition: driver_mpu9250.c:2130
mpu9250_dmp_get_pedometer_step_count
uint8_t mpu9250_dmp_get_pedometer_step_count(mpu9250_handle_t *handle, uint32_t *count)
dmp get the pedometer step count
Definition: driver_mpu9250.c:1307
mpu9250_dmp_set_pedometer_step_count
uint8_t mpu9250_dmp_set_pedometer_step_count(mpu9250_handle_t *handle, uint32_t count)
dmp set the pedometer step count
Definition: driver_mpu9250.c:1259
mpu9250_dmp_gyro_accel_raw_offset_convert
uint8_t mpu9250_dmp_gyro_accel_raw_offset_convert(mpu9250_handle_t *handle, int32_t gyro_offset_raw[3], int32_t accel_offset_raw[3], int32_t gyro_offset[3], int32_t accel_offset[3])
dmp gyro accel raw offset convert
Definition: driver_mpu9250.c:3822
mpu9250_dmp_set_pedometer_walk_time
uint8_t mpu9250_dmp_set_pedometer_walk_time(mpu9250_handle_t *handle, uint32_t ms)
dmp set the pedometer walk time
Definition: driver_mpu9250.c:1165
mpu9250_dmp_read
uint8_t mpu9250_dmp_read(mpu9250_handle_t *handle, int16_t(*accel_raw)[3], float(*accel_g)[3], int16_t(*gyro_raw)[3], float(*gyro_dps)[3], int32_t(*quat)[4], float *pitch, float *roll, float *yaw, uint16_t *l)
dmp read the data
Definition: driver_mpu9250.c:3429
MPU9250_DMP_FEATURE_6X_QUAT
@ MPU9250_DMP_FEATURE_6X_QUAT
Definition: driver_mpu9250.h:458
MPU9250_DMP_FEATURE_GYRO_CAL
@ MPU9250_DMP_FEATURE_GYRO_CAL
Definition: driver_mpu9250.h:459
MPU9250_DMP_FEATURE_PEDOMETER
@ MPU9250_DMP_FEATURE_PEDOMETER
Definition: driver_mpu9250.h:457
MPU9250_DMP_INTERRUPT_MODE_CONTINUOUS
@ MPU9250_DMP_INTERRUPT_MODE_CONTINUOUS
Definition: driver_mpu9250.h:445
mpu9250_interface_debug_print
void mpu9250_interface_debug_print(const char *const fmt,...)
interface print format data
Definition: driver_mpu9250_interface_template.c:164
mpu9250_interface_spi_write
uint8_t mpu9250_interface_spi_write(uint8_t reg, uint8_t *buf, uint16_t len)
interface spi bus write
Definition: driver_mpu9250_interface_template.c:144
mpu9250_interface_iic_deinit
uint8_t mpu9250_interface_iic_deinit(void)
interface iic bus deinit
Definition: driver_mpu9250_interface_template.c:58
mpu9250_interface_iic_write
uint8_t mpu9250_interface_iic_write(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
interface iic bus write
Definition: driver_mpu9250_interface_template.c:90
mpu9250_interface_iic_read
uint8_t mpu9250_interface_iic_read(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
interface iic bus read
Definition: driver_mpu9250_interface_template.c:74
mpu9250_interface_iic_init
uint8_t mpu9250_interface_iic_init(void)
interface iic bus init
Definition: driver_mpu9250_interface_template.c:46
mpu9250_interface_spi_read
uint8_t mpu9250_interface_spi_read(uint8_t reg, uint8_t *buf, uint16_t len)
interface spi bus read
Definition: driver_mpu9250_interface_template.c:129
mpu9250_interface_spi_init
uint8_t mpu9250_interface_spi_init(void)
interface spi bus init
Definition: driver_mpu9250_interface_template.c:102
mpu9250_interface_receive_callback
void mpu9250_interface_receive_callback(uint8_t type)
interface receive callback
Definition: driver_mpu9250_interface_template.c:174
mpu9250_interface_delay_ms
void mpu9250_interface_delay_ms(uint32_t ms)
interface delay ms
Definition: driver_mpu9250_interface_template.c:154
mpu9250_interface_spi_deinit
uint8_t mpu9250_interface_spi_deinit(void)
interface spi bus deinit
Definition: driver_mpu9250_interface_template.c:114
DRIVER_MPU9250_LINK_INIT
#define DRIVER_MPU9250_LINK_INIT(HANDLE, STRUCTURE)
initialize mpu9250_handle_t structure
Definition: driver_mpu9250.h:560
DRIVER_MPU9250_LINK_RECEIVE_CALLBACK
#define DRIVER_MPU9250_LINK_RECEIVE_CALLBACK(HANDLE, FUC)
link receive_callback function
Definition: driver_mpu9250.h:648
DRIVER_MPU9250_LINK_IIC_DEINIT
#define DRIVER_MPU9250_LINK_IIC_DEINIT(HANDLE, FUC)
link iic_deinit function
Definition: driver_mpu9250.h:576
DRIVER_MPU9250_LINK_SPI_INIT
#define DRIVER_MPU9250_LINK_SPI_INIT(HANDLE, FUC)
link spi_init function
Definition: driver_mpu9250.h:600
DRIVER_MPU9250_LINK_SPI_READ
#define DRIVER_MPU9250_LINK_SPI_READ(HANDLE, FUC)
link spi_read function
Definition: driver_mpu9250.h:616
DRIVER_MPU9250_LINK_IIC_READ
#define DRIVER_MPU9250_LINK_IIC_READ(HANDLE, FUC)
link iic_read function
Definition: driver_mpu9250.h:584
DRIVER_MPU9250_LINK_IIC_WRITE
#define DRIVER_MPU9250_LINK_IIC_WRITE(HANDLE, FUC)
link iic_write function
Definition: driver_mpu9250.h:592
DRIVER_MPU9250_LINK_SPI_DEINIT
#define DRIVER_MPU9250_LINK_SPI_DEINIT(HANDLE, FUC)
link spi_deinit function
Definition: driver_mpu9250.h:608
DRIVER_MPU9250_LINK_IIC_INIT
#define DRIVER_MPU9250_LINK_IIC_INIT(HANDLE, FUC)
link iic_init function
Definition: driver_mpu9250.h:568
DRIVER_MPU9250_LINK_DEBUG_PRINT
#define DRIVER_MPU9250_LINK_DEBUG_PRINT(HANDLE, FUC)
link debug_print function
Definition: driver_mpu9250.h:640
DRIVER_MPU9250_LINK_DELAY_MS
#define DRIVER_MPU9250_LINK_DELAY_MS(HANDLE, FUC)
link delay_ms function
Definition: driver_mpu9250.h:632
DRIVER_MPU9250_LINK_SPI_WRITE
#define DRIVER_MPU9250_LINK_SPI_WRITE(HANDLE, FUC)
link spi_write function
Definition: driver_mpu9250.h:624
mpu9250_dmp_pedometer_test
uint8_t mpu9250_dmp_pedometer_test(mpu9250_interface_t interface, mpu9250_address_t addr, uint32_t times)
dmp pedometer test
Definition: driver_mpu9250_dmp_pedometer_test.c:79
mpu9250_dmp_pedometer_test_irq_handler
uint8_t mpu9250_dmp_pedometer_test_irq_handler(void)
dmp pedometer test irq
Definition: driver_mpu9250_dmp_pedometer_test.c:57
mpu9250_handle_s
mpu9250 handle structure definition
Definition: driver_mpu9250.h:502
mpu9250_info_s
mpu9250 information structure definition
Definition: driver_mpu9250.h:531
mpu9250_info_s::temperature_max
float temperature_max
Definition: driver_mpu9250.h:539
mpu9250_info_s::supply_voltage_max_v
float supply_voltage_max_v
Definition: driver_mpu9250.h:536
mpu9250_info_s::driver_version
uint32_t driver_version
Definition: driver_mpu9250.h:540
mpu9250_info_s::temperature_min
float temperature_min
Definition: driver_mpu9250.h:538
mpu9250_info_s::max_current_ma
float max_current_ma
Definition: driver_mpu9250.h:537
mpu9250_info_s::manufacturer_name
char manufacturer_name[32]
Definition: driver_mpu9250.h:533
mpu9250_info_s::supply_voltage_min_v
float supply_voltage_min_v
Definition: driver_mpu9250.h:535
mpu9250_info_s::interface
char interface[8]
Definition: driver_mpu9250.h:534
mpu9250_info_s::chip_name
char chip_name[32]
Definition: driver_mpu9250.h:532