| LibDriver MPU9250 1.0.0 MPU9250 full function driver

driver_mpu9250_dmp.c
Go to the documentation of this file.
1
37 #include "driver_mpu9250_dmp.h"
38
39 static mpu9250_handle_t gs_handle;
48 uint8_t mpu9250_dmp_irq_handler(void)
49 {
50 if (mpu9250_irq_handler(&gs_handle) != 0)
51 {
52 return 1;
53 }
54 else
55 {
56 return 0;
57 }
58 }
59
72 uint8_t mpu9250_dmp_init(mpu9250_interface_t interface, mpu9250_address_t addr_pin,
73 void (*receive_callback)(uint8_t type),
74 void (*tap_callback)(uint8_t count, uint8_t direction),
75 void (*orient_callback)(uint8_t orientation)
76 )
77 {
78 uint8_t res;
79 uint8_t reg;
80 int32_t gyro_offset_raw[3];
81 int32_t accel_offset_raw[3];
82 int32_t gyro_offset[3];
83 int32_t accel_offset[3];
84 int8_t gyro_orientation[9] = {1, 0, 0,
85 0, 1, 0,
86 0, 0, 1};
87
88 /* link interface function */
89 DRIVER_MPU9250_LINK_INIT(&gs_handle, mpu9250_handle_t);
90 DRIVER_MPU9250_LINK_IIC_INIT(&gs_handle, mpu9250_interface_iic_init);
91 DRIVER_MPU9250_LINK_IIC_DEINIT(&gs_handle, mpu9250_interface_iic_deinit);
92 DRIVER_MPU9250_LINK_IIC_READ(&gs_handle, mpu9250_interface_iic_read);
93 DRIVER_MPU9250_LINK_IIC_WRITE(&gs_handle, mpu9250_interface_iic_write);
94 DRIVER_MPU9250_LINK_SPI_INIT(&gs_handle, mpu9250_interface_spi_init);
95 DRIVER_MPU9250_LINK_SPI_DEINIT(&gs_handle, mpu9250_interface_spi_deinit);
96 DRIVER_MPU9250_LINK_SPI_READ(&gs_handle, mpu9250_interface_spi_read);
97 DRIVER_MPU9250_LINK_SPI_WRITE(&gs_handle, mpu9250_interface_spi_write);
98 DRIVER_MPU9250_LINK_DELAY_MS(&gs_handle, mpu9250_interface_delay_ms);
99 DRIVER_MPU9250_LINK_DEBUG_PRINT(&gs_handle, mpu9250_interface_debug_print);
100 DRIVER_MPU9250_LINK_RECEIVE_CALLBACK(&gs_handle, receive_callback);
101
102 /* set the interface */
103 res = mpu9250_set_interface(&gs_handle, interface);
104 if (res != 0)
105 {
106 mpu9250_interface_debug_print("mpu9250: set interface failed.\n");
107
108 return 1;
109 }
110
111 /* set the addr pin */
112 res = mpu9250_set_addr_pin(&gs_handle, addr_pin);
113 if (res != 0)
114 {
115 mpu9250_interface_debug_print("mpu9250: set addr pin failed.\n");
116
117 return 1;
118 }
119
120 /* init */
121 res = mpu9250_init(&gs_handle);
122 if (res != 0)
123 {
124 mpu9250_interface_debug_print("mpu9250: init failed.\n");
125
126 return 1;
127 }
128
129 /* delay 100 ms */
130 mpu9250_interface_delay_ms(100);
131
132 /* disable sleep */
133 res = mpu9250_set_sleep(&gs_handle, MPU9250_BOOL_FALSE);
134 if (res != 0)
135 {
136 mpu9250_interface_debug_print("mpu9250: set sleep failed.\n");
137 (void)mpu9250_deinit(&gs_handle);
138
139 return 1;
140 }
141
142 /* set fifo 1024kb */
143 res = mpu9250_set_fifo_1024kb(&gs_handle);
144 if (res != 0)
145 {
146 mpu9250_interface_debug_print("mpu9250: set fifo 1024kb failed.\n");
147 (void)mpu9250_deinit(&gs_handle);
148
149 return 1;
150 }
151
152 /* run the self test */
153 res = mpu9250_self_test(&gs_handle, gyro_offset_raw, accel_offset_raw);
154 if (res != 0)
155 {
156 mpu9250_interface_debug_print("mpu9250: self test failed.\n");
157 (void)mpu9250_deinit(&gs_handle);
158
159 return 1;
160 }
161
162
163 /* if spi interface, disable iic interface */
164 if (interface == MPU9250_INTERFACE_SPI)
165 {
166 /* disable iic */
167 res = mpu9250_set_disable_iic_slave(&gs_handle, MPU9250_BOOL_TRUE);
168 if (res != 0)
169 {
170 mpu9250_interface_debug_print("mpu9250: set disable iic slave failed.\n");
171 (void)mpu9250_deinit(&gs_handle);
172
173 return 1;
174 }
175 }
176
177 /* set fifo 1024kb */
178 res = mpu9250_set_fifo_1024kb(&gs_handle);
179 if (res != 0)
180 {
181 mpu9250_interface_debug_print("mpu9250: set fifo 1024kb failed.\n");
182 (void)mpu9250_deinit(&gs_handle);
183
184 return 1;
185 }
186
187 /* set the default clock source */
188 res = mpu9250_set_clock_source(&gs_handle, MPU9250_DMP_DEFAULT_CLOCK_SOURCE);
189 if (res != 0)
190 {
191 mpu9250_interface_debug_print("mpu9250: set clock source failed.\n");
192 (void)mpu9250_deinit(&gs_handle);
193
194 return 1;
195 }
196
197 /* set the default rate */
198 res = mpu9250_set_sample_rate_divider(&gs_handle, (1000 / MPU9250_DMP_DEFAULT_RATE) - 1);
199 if (res != 0)
200 {
201 mpu9250_interface_debug_print("mpu9250: set sample rate divider failed.\n");
202 (void)mpu9250_deinit(&gs_handle);
203
204 return 1;
205 }
206
207 /* set the default accelerometer range */
208 res = mpu9250_set_accelerometer_range(&gs_handle, MPU9250_DMP_DEFAULT_ACCELEROMETER_RANGE);
209 if (res != 0)
210 {
211 mpu9250_interface_debug_print("mpu9250: set accelerometer range failed.\n");
212 (void)mpu9250_deinit(&gs_handle);
213
214 return 1;
215 }
216
217 /* set the default gyroscope_range */
218 res = mpu9250_set_gyroscope_range(&gs_handle, MPU9250_DMP_DEFAULT_GYROSCOPE_RANGE);
219 if (res != 0)
220 {
221 mpu9250_interface_debug_print("mpu9250: set gyroscope range failed.\n");
222 (void)mpu9250_deinit(&gs_handle);
223
224 return 1;
225 }
226
227 /* set the default low pass filter */
228 res = mpu9250_set_low_pass_filter(&gs_handle, MPU9250_DMP_DEFAULT_LOW_PASS_FILTER);
229 if (res != 0)
230 {
231 mpu9250_interface_debug_print("mpu9250: set low pass filter failed.\n");
232 (void)mpu9250_deinit(&gs_handle);
233
234 return 1;
235 }
236
237 /* enable temperature sensor */
238 res = mpu9250_set_ptat(&gs_handle, MPU9250_BOOL_TRUE);
239 if (res != 0)
240 {
241 mpu9250_interface_debug_print("mpu9250: set ptat failed.\n");
242 (void)mpu9250_deinit(&gs_handle);
243
244 return 1;
245 }
246
247 /* set the default cycle wake up */
248 res = mpu9250_set_cycle_wake_up(&gs_handle, MPU9250_DMP_DEFAULT_CYCLE_WAKE_UP);
249 if (res != 0)
250 {
251 mpu9250_interface_debug_print("mpu9250: set cycle wake up failed.\n");
252 (void)mpu9250_deinit(&gs_handle);
253
254 return 1;
255 }
256
257 /* enable acc x */
258 res = mpu9250_set_standby_mode(&gs_handle, MPU9250_SOURCE_ACC_X, MPU9250_BOOL_FALSE);
259 if (res != 0)
260 {
261 mpu9250_interface_debug_print("mpu9250: set standby mode failed.\n");
262 (void)mpu9250_deinit(&gs_handle);
263
264 return 1;
265 }
266
267 /* enable acc y */
268 res = mpu9250_set_standby_mode(&gs_handle, MPU9250_SOURCE_ACC_Y, MPU9250_BOOL_FALSE);
269 if (res != 0)
270 {
271 mpu9250_interface_debug_print("mpu9250: set standby mode failed.\n");
272 (void)mpu9250_deinit(&gs_handle);
273
274 return 1;
275 }
276
277 /* enable acc z */
278 res = mpu9250_set_standby_mode(&gs_handle, MPU9250_SOURCE_ACC_Z, MPU9250_BOOL_FALSE);
279 if (res != 0)
280 {
281 mpu9250_interface_debug_print("mpu9250: set standby mode failed.\n");
282 (void)mpu9250_deinit(&gs_handle);
283
284 return 1;
285 }
286
287 /* enable gyro x */
288 res = mpu9250_set_standby_mode(&gs_handle, MPU9250_SOURCE_GYRO_X, MPU9250_BOOL_FALSE);
289 if (res != 0)
290 {
291 mpu9250_interface_debug_print("mpu9250: set standby mode failed.\n");
292 (void)mpu9250_deinit(&gs_handle);
293
294 return 1;
295 }
296
297 /* enable gyro y */
298 res = mpu9250_set_standby_mode(&gs_handle, MPU9250_SOURCE_GYRO_Y, MPU9250_BOOL_FALSE);
299 if (res != 0)
300 {
301 mpu9250_interface_debug_print("mpu9250: set standby mode failed.\n");
302 (void)mpu9250_deinit(&gs_handle);
303
304 return 1;
305 }
306
307 /* enable gyro z */
308 res = mpu9250_set_standby_mode(&gs_handle, MPU9250_SOURCE_GYRO_Z, MPU9250_BOOL_FALSE);
309 if (res != 0)
310 {
311 mpu9250_interface_debug_print("mpu9250: set standby mode failed.\n");
312 (void)mpu9250_deinit(&gs_handle);
313
314 return 1;
315 }
316
317 /* disable gyroscope x test */
318 res = mpu9250_set_gyroscope_test(&gs_handle, MPU9250_AXIS_X, MPU9250_BOOL_FALSE);
319 if (res != 0)
320 {
321 mpu9250_interface_debug_print("mpu9250: set gyroscope test failed.\n");
322 (void)mpu9250_deinit(&gs_handle);
323
324 return 1;
325 }
326
327 /* disable gyroscope y test */
328 res = mpu9250_set_gyroscope_test(&gs_handle, MPU9250_AXIS_Y, MPU9250_BOOL_FALSE);
329 if (res != 0)
330 {
331 mpu9250_interface_debug_print("mpu9250: set gyroscope test failed.\n");
332 (void)mpu9250_deinit(&gs_handle);
333
334 return 1;
335 }
336
337 /* disable gyroscope z test */
338 res = mpu9250_set_gyroscope_test(&gs_handle, MPU9250_AXIS_Z, MPU9250_BOOL_FALSE);
339 if (res != 0)
340 {
341 mpu9250_interface_debug_print("mpu9250: set gyroscope test failed.\n");
342 (void)mpu9250_deinit(&gs_handle);
343
344 return 1;
345 }
346
347 /* disable accelerometer x test */
348 res = mpu9250_set_accelerometer_test(&gs_handle, MPU9250_AXIS_X, MPU9250_BOOL_FALSE);
349 if (res != 0)
350 {
351 mpu9250_interface_debug_print("mpu9250: set accelerometer test failed.\n");
352 (void)mpu9250_deinit(&gs_handle);
353
354 return 1;
355 }
356
357 /* disable accelerometer y test */
358 res = mpu9250_set_accelerometer_test(&gs_handle, MPU9250_AXIS_Y, MPU9250_BOOL_FALSE);
359 if (res != 0)
360 {
361 mpu9250_interface_debug_print("mpu9250: set accelerometer test failed.\n");
362 (void)mpu9250_deinit(&gs_handle);
363
364 return 1;
365 }
366
367 /* disable accelerometer z test */
368 res = mpu9250_set_accelerometer_test(&gs_handle, MPU9250_AXIS_Z, MPU9250_BOOL_FALSE);
369 if (res != 0)
370 {
371 mpu9250_interface_debug_print("mpu9250: set accelerometer test failed.\n");
372 (void)mpu9250_deinit(&gs_handle);
373
374 return 1;
375 }
376
377 /* disable temp fifo */
378 res = mpu9250_set_fifo_enable(&gs_handle, MPU9250_FIFO_TEMP, MPU9250_BOOL_FALSE);
379 if (res != 0)
380 {
381 mpu9250_interface_debug_print("mpu9250: set fifo enable failed.\n");
382 (void)mpu9250_deinit(&gs_handle);
383
384 return 1;
385 }
386
387 /* disable xg fifo */
388 res = mpu9250_set_fifo_enable(&gs_handle, MPU9250_FIFO_XG, MPU9250_BOOL_FALSE);
389 if (res != 0)
390 {
391 mpu9250_interface_debug_print("mpu9250: set fifo enable failed.\n");
392 (void)mpu9250_deinit(&gs_handle);
393
394 return 1;
395 }
396
397 /* disable yg fifo */
398 res = mpu9250_set_fifo_enable(&gs_handle, MPU9250_FIFO_YG, MPU9250_BOOL_FALSE);
399 if (res != 0)
400 {
401 mpu9250_interface_debug_print("mpu9250: set fifo enable failed.\n");
402 (void)mpu9250_deinit(&gs_handle);
403
404 return 1;
405 }
406
407 /* disable zg fifo */
408 res = mpu9250_set_fifo_enable(&gs_handle, MPU9250_FIFO_ZG, MPU9250_BOOL_FALSE);
409 if (res != 0)
410 {
411 mpu9250_interface_debug_print("mpu9250: set fifo enable failed.\n");
412 (void)mpu9250_deinit(&gs_handle);
413
414 return 1;
415 }
416
417 /* disable accel fifo */
418 res = mpu9250_set_fifo_enable(&gs_handle, MPU9250_FIFO_ACCEL, MPU9250_BOOL_FALSE);
419 if (res != 0)
420 {
421 mpu9250_interface_debug_print("mpu9250: set fifo enable failed.\n");
422 (void)mpu9250_deinit(&gs_handle);
423
424 return 1;
425 }
426
427 /* enable fifo */
428 res = mpu9250_set_fifo(&gs_handle, MPU9250_BOOL_TRUE);
429 if (res != 0)
430 {
431 mpu9250_interface_debug_print("mpu9250: set fifo failed.\n");
432 (void)mpu9250_deinit(&gs_handle);
433
434 return 1;
435 }
436
437 /* set the default interrupt level */
438 res = mpu9250_set_interrupt_level(&gs_handle, MPU9250_DMP_DEFAULT_INTERRUPT_PIN_LEVEL);
439 if (res != 0)
440 {
441 mpu9250_interface_debug_print("mpu9250: set interrupt level failed.\n");
442 (void)mpu9250_deinit(&gs_handle);
443
444 return 1;
445 }
446
447 /* set the default interrupt pin type */
448 res = mpu9250_set_interrupt_pin_type(&gs_handle, MPU9250_DMP_DEFAULT_INTERRUPT_PIN_TYPE);
449 if (res != 0)
450 {
451 mpu9250_interface_debug_print("mpu9250: set interrupt pin type failed.\n");
452 (void)mpu9250_deinit(&gs_handle);
453
454 return 1;
455 }
456
457 if (tap_callback != NULL)
458 {
459 /* set the default motion threshold */
460 res = mpu9250_motion_threshold_convert_to_register(&gs_handle, MPU9250_DMP_DEFAULT_MOTION_THRESHOLD, &reg);
461 if (res != 0)
462 {
463 mpu9250_interface_debug_print("mpu9250: motion threshold convert to register failed.\n");
464 (void)mpu9250_deinit(&gs_handle);
465
466 return 1;
467 }
468
469 /* set the motion threshold */
470 res = mpu9250_set_motion_threshold(&gs_handle, reg);
471 if (res != 0)
472 {
473 mpu9250_interface_debug_print("mpu9250: set motion threshold failed.\n");
474 (void)mpu9250_deinit(&gs_handle);
475
476 return 1;
477 }
478
479 /* enable wake on motion */
480 res = mpu9250_set_wake_on_motion(&gs_handle, MPU9250_BOOL_TRUE);
481 if (res != 0)
482 {
483 mpu9250_interface_debug_print("mpu9250: set wake on motion failed.\n");
484 (void)mpu9250_deinit(&gs_handle);
485
486 return 1;
487 }
488 }
489
490 /* set the default motion interrupt */
491 res = mpu9250_set_interrupt(&gs_handle, MPU9250_INTERRUPT_MOTION, MPU9250_DMP_DEFAULT_INTERRUPT_MOTION);
492 if (res != 0)
493 {
494 mpu9250_interface_debug_print("mpu9250: set interrupt failed.\n");
495 (void)mpu9250_deinit(&gs_handle);
496
497 return 1;
498 }
499
500 /* set the default fifo overflow interrupt */
501 res = mpu9250_set_interrupt(&gs_handle, MPU9250_INTERRUPT_FIFO_OVERFLOW, MPU9250_DMP_DEFAULT_INTERRUPT_FIFO_OVERFLOW);
502 if (res != 0)
503 {
504 mpu9250_interface_debug_print("mpu9250: set interrupt failed.\n");
505 (void)mpu9250_deinit(&gs_handle);
506
507 return 1;
508 }
509
510 /* set the default dmp interrupt */
511 res = mpu9250_set_interrupt(&gs_handle, MPU9250_INTERRUPT_DMP, MPU9250_DMP_DEFAULT_INTERRUPT_DMP);
512 if (res != 0)
513 {
514 mpu9250_interface_debug_print("mpu9250: set interrupt failed.\n");
515 (void)mpu9250_deinit(&gs_handle);
516
517 return 1;
518 }
519
520 /* set the default fsync int interrupt */
521 res = mpu9250_set_interrupt(&gs_handle, MPU9250_INTERRUPT_FSYNC_INT, MPU9250_DMP_DEFAULT_INTERRUPT_FSYNC_INT);
522 if (res != 0)
523 {
524 mpu9250_interface_debug_print("mpu9250: set interrupt failed.\n");
525 (void)mpu9250_deinit(&gs_handle);
526
527 return 1;
528 }
529
530 /* set the default data ready interrupt */
531 res = mpu9250_set_interrupt(&gs_handle, MPU9250_INTERRUPT_DATA_READY, MPU9250_DMP_DEFAULT_INTERRUPT_DATA_READY);
532 if (res != 0)
533 {
534 mpu9250_interface_debug_print("mpu9250: set interrupt failed.\n");
535 (void)mpu9250_deinit(&gs_handle);
536
537 return 1;
538 }
539
540 /* set the default latch */
541 res = mpu9250_set_interrupt_latch(&gs_handle, MPU9250_DMP_DEFAULT_INTERRUPT_LATCH);
542 if (res != 0)
543 {
544 mpu9250_interface_debug_print("mpu9250: set interrupt latch failed.\n");
545 (void)mpu9250_deinit(&gs_handle);
546
547 return 1;
548 }
549
550 /* set the default interrupt read clear */
551 res = mpu9250_set_interrupt_read_clear(&gs_handle, MPU9250_DMP_DEFAULT_INTERRUPT_READ_CLEAR);
552 if (res != 0)
553 {
554 mpu9250_interface_debug_print("mpu9250: set interrupt read clear failed.\n");
555 (void)mpu9250_deinit(&gs_handle);
556
557 return 1;
558 }
559
560 /* set the default extern sync */
561 res = mpu9250_set_extern_sync(&gs_handle, MPU9250_DMP_DEFAULT_EXTERN_SYNC);
562 if (res != 0)
563 {
564 mpu9250_interface_debug_print("mpu9250: set extern sync failed.\n");
565 (void)mpu9250_deinit(&gs_handle);
566
567 return 1;
568 }
569
570 /* set the default fsync interrupt */
571 res = mpu9250_set_fsync_interrupt(&gs_handle, MPU9250_DMP_DEFAULT_FSYNC_INTERRUPT);
572 if (res != 0)
573 {
574 mpu9250_interface_debug_print("mpu9250: set fsync interrupt failed.\n");
575 (void)mpu9250_deinit(&gs_handle);
576
577 return 1;
578 }
579
580 /* set the default fsync interrupt level */
581 res = mpu9250_set_fsync_interrupt_level(&gs_handle, MPU9250_DMP_DEFAULT_FSYNC_INTERRUPT_LEVEL);
582 if (res != 0)
583 {
584 mpu9250_interface_debug_print("mpu9250: set fsync interrupt level failed.\n");
585 (void)mpu9250_deinit(&gs_handle);
586
587 return 1;
588 }
589
590 /* set the default iic master */
591 res = mpu9250_set_iic_master(&gs_handle, MPU9250_DMP_DEFAULT_IIC_MASTER);
592 if (res != 0)
593 {
594 mpu9250_interface_debug_print("mpu9250: set iic master failed.\n");
595 (void)mpu9250_deinit(&gs_handle);
596
597 return 1;
598 }
599
600 /* set the default iic bypass */
601 res = mpu9250_set_iic_bypass(&gs_handle, MPU9250_DMP_DEFAULT_IIC_BYPASS);
602 if (res != 0)
603 {
604 mpu9250_interface_debug_print("mpu9250: set iic bypass failed.\n");
605 (void)mpu9250_deinit(&gs_handle);
606
607 return 1;
608 }
609
610 /* set the default gyro standby */
611 res = mpu9250_set_gyro_standby(&gs_handle, MPU9250_DMP_DEFAULT_GYROSCOPE_STANDBY);
612 if (res != 0)
613 {
614 mpu9250_interface_debug_print("mpu9250: set gyro standby failed.\n");
615 (void)mpu9250_deinit(&gs_handle);
616
617 return 1;
618 }
619
620 /* set the default fifo mode */
621 res = mpu9250_set_fifo_mode(&gs_handle, MPU9250_DMP_DEFAULT_FIFO_MODE);
622 if (res != 0)
623 {
624 mpu9250_interface_debug_print("mpu9250: set fifo mode failed.\n");
625 (void)mpu9250_deinit(&gs_handle);
626
627 return 1;
628 }
629
630 /* set the default gyroscope choice */
631 res = mpu9250_set_gyroscope_choice(&gs_handle, MPU9250_DMP_DEFAULT_GYROSCOPE_CHOICE);
632 if (res != 0)
633 {
634 mpu9250_interface_debug_print("mpu9250: set gyroscope choice failed.\n");
635 (void)mpu9250_deinit(&gs_handle);
636
637 return 1;
638 }
639
640 /* set the default low pass filter */
641 res = mpu9250_set_low_pass_filter(&gs_handle, MPU9250_DMP_DEFAULT_LOW_PASS_FILTER);
642 if (res != 0)
643 {
644 mpu9250_interface_debug_print("mpu9250: set low pass filter failed.\n");
645 (void)mpu9250_deinit(&gs_handle);
646
647 return 1;
648 }
649
650 /* set the default accelerometer choice */
651 res = mpu9250_set_accelerometer_choice(&gs_handle, MPU9250_DMP_DEFAULT_ACCELEROMETER_CHOICE);
652 if (res != 0)
653 {
654 mpu9250_interface_debug_print("mpu9250: set accelerometer choice failed.\n");
655 (void)mpu9250_deinit(&gs_handle);
656
657 return 1;
658 }
659
660 /* set the default accelerometer low pass filter */
661 res = mpu9250_set_accelerometer_low_pass_filter(&gs_handle, MPU9250_DMP_DEFAULT_ACCELEROMETER_LOW_PASS_FILTER);
662 if (res != 0)
663 {
664 mpu9250_interface_debug_print("mpu9250: set accelerometer low pass filter failed.\n");
665 (void)mpu9250_deinit(&gs_handle);
666
667 return 1;
668 }
669
670 /* set the default low power accel output rate */
671 res = mpu9250_set_low_power_accel_output_rate(&gs_handle, MPU9250_DMP_DEFAULT_LOW_POWER_ACCEL_OUTPUT_RATE);
672 if (res != 0)
673 {
674 mpu9250_interface_debug_print("mpu9250: set low power accel output rate failed.\n");
675 (void)mpu9250_deinit(&gs_handle);
676
677 return 1;
678 }
679
680 /* set the default accel compare with previous sample */
681 res = mpu9250_set_accel_compare_with_previous_sample(&gs_handle, MPU9250_DMP_DEFAULT_ACCELEROMETER_COMPARE);
682 if (res != 0)
683 {
684 mpu9250_interface_debug_print("mpu9250: set accel compare with previous sample failed.\n");
685 (void)mpu9250_deinit(&gs_handle);
686
687 return 1;
688 }
689
690 /* dmp load firmware */
691 res = mpu9250_dmp_load_firmware(&gs_handle);
692 if (res != 0)
693 {
694 mpu9250_interface_debug_print("mpu9250: dmp load firmware failed.\n");
695 (void)mpu9250_deinit(&gs_handle);
696
697 return 1;
698 }
699
700 /* enable axis x */
701 res = mpu9250_dmp_set_tap_axes(&gs_handle, MPU9250_AXIS_X, MPU9250_BOOL_TRUE);
702 if (res != 0)
703 {
704 mpu9250_interface_debug_print("mpu9250: dmp set tap axes failed.\n");
705 (void)mpu9250_deinit(&gs_handle);
706
707 return 1;
708 }
709
710 /* enable axis y */
711 res = mpu9250_dmp_set_tap_axes(&gs_handle, MPU9250_AXIS_Y, MPU9250_BOOL_TRUE);
712 if (res != 0)
713 {
714 mpu9250_interface_debug_print("mpu9250: dmp set tap axes failed.\n");
715 (void)mpu9250_deinit(&gs_handle);
716
717 return 1;
718 }
719
720 /* enable axis z */
721 res = mpu9250_dmp_set_tap_axes(&gs_handle, MPU9250_AXIS_Z, MPU9250_BOOL_TRUE);
722 if (res != 0)
723 {
724 mpu9250_interface_debug_print("mpu9250: dmp set tap axes failed.\n");
725 (void)mpu9250_deinit(&gs_handle);
726
727 return 1;
728 }
729
730 /* set the default fifo rate */
731 res = mpu9250_dmp_set_fifo_rate(&gs_handle, MPU9250_DMP_DEFAULT_RATE);
732 if (res != 0)
733 {
734 mpu9250_interface_debug_print("mpu9250: dmp set fifo rate failed.\n");
735 (void)mpu9250_deinit(&gs_handle);
736
737 return 1;
738 }
739
740 /* set the default interrupt mode */
741 res = mpu9250_dmp_set_interrupt_mode(&gs_handle, MPU9250_DMP_DEFAULT_INTERRUPT_MODE);
742 if (res != 0)
743 {
744 mpu9250_interface_debug_print("mpu9250: dmp set interrupt mode failed.\n");
745 (void)mpu9250_deinit(&gs_handle);
746
747 return 1;
748 }
749
750 /* set the default dmp orientation */
751 res = mpu9250_dmp_set_orientation(&gs_handle, gyro_orientation);
752 if (res != 0)
753 {
754 mpu9250_interface_debug_print("mpu9250: dmp set orientation failed.\n");
755 (void)mpu9250_deinit(&gs_handle);
756
757 return 1;
758 }
759
760 /* enable feature */
761 res = mpu9250_dmp_set_feature(&gs_handle, MPU9250_DMP_FEATURE_6X_QUAT | MPU9250_DMP_FEATURE_TAP | MPU9250_DMP_FEATURE_PEDOMETER |
762 MPU9250_DMP_FEATURE_ORIENT | MPU9250_DMP_FEATURE_SEND_RAW_ACCEL |
763 MPU9250_DMP_FEATURE_SEND_CAL_GYRO | MPU9250_DMP_FEATURE_GYRO_CAL);
764 if (res != 0)
765 {
766 mpu9250_interface_debug_print("mpu9250: dmp set feature failed.\n");
767 (void)mpu9250_deinit(&gs_handle);
768
769 return 1;
770 }
771
772 /* dmp set tap callback */
773 res = mpu9250_dmp_set_tap_callback(&gs_handle, tap_callback);
774 if (res != 0)
775 {
776 mpu9250_interface_debug_print("mpu9250: dmp set tap callback failed.\n");
777 (void)mpu9250_deinit(&gs_handle);
778
779 return 1;
780 }
781
782 /* dmp set orient callback */
783 res = mpu9250_dmp_set_orient_callback(&gs_handle, orient_callback);
784 if (res != 0)
785 {
786 mpu9250_interface_debug_print("mpu9250: dmp set orient callback failed.\n");
787 (void)mpu9250_deinit(&gs_handle);
788
789 return 1;
790 }
791
792 /* set the default pedometer walk time */
793 res = mpu9250_dmp_set_pedometer_walk_time(&gs_handle, MPU9250_DMP_DEFAULT_PEOMETER_WALK_TIME);
794 if (res != 0)
795 {
796 mpu9250_interface_debug_print("mpu9250: dmp set pedometer walk time failed.\n");
797 (void)mpu9250_deinit(&gs_handle);
798
799 return 1;
800 }
801
802 /* set the default pedometer step count */
803 res = mpu9250_dmp_set_pedometer_step_count(&gs_handle, MPU9250_DMP_DEFAULT_PEOMETER_STEP_COUNT);
804 if (res != 0)
805 {
806 mpu9250_interface_debug_print("mpu9250: dmp set pedometer step count failed.\n");
807 (void)mpu9250_deinit(&gs_handle);
808
809 return 1;
810 }
811
812 /* set the default shake reject timeout */
813 res = mpu9250_dmp_set_shake_reject_timeout(&gs_handle, MPU9250_DMP_DEFAULT_SHAKE_REJECT_TIMEOUT);
814 if (res != 0)
815 {
816 mpu9250_interface_debug_print("mpu9250: dmp set shake reject timeout failed.\n");
817 (void)mpu9250_deinit(&gs_handle);
818
819 return 1;
820 }
821
822 /* set the default shake reject time */
823 res = mpu9250_dmp_set_shake_reject_time(&gs_handle, MPU9250_DMP_DEFAULT_SHAKE_REJECT_TIME);
824 if (res != 0)
825 {
826 mpu9250_interface_debug_print("mpu9250: dmp set shake reject time failed.\n");
827 (void)mpu9250_deinit(&gs_handle);
828
829 return 1;
830 }
831
832 /* set the default shake reject thresh */
833 res = mpu9250_dmp_set_shake_reject_thresh(&gs_handle, MPU9250_DMP_DEFAULT_SHAKE_REJECT_THRESH);
834 if (res != 0)
835 {
836 mpu9250_interface_debug_print("mpu9250: dmp set shake reject thresh failed.\n");
837 (void)mpu9250_deinit(&gs_handle);
838
839 return 1;
840 }
841
842 /* set the default tap time multi */
843 res = mpu9250_dmp_set_tap_time_multi(&gs_handle, MPU9250_DMP_DEFAULT_TAP_TIME_MULTI);
844 if (res != 0)
845 {
846 mpu9250_interface_debug_print("mpu9250: dmp set tap time multi failed.\n");
847 (void)mpu9250_deinit(&gs_handle);
848
849 return 1;
850 }
851
852 /* set the default tap time */
853 res = mpu9250_dmp_set_tap_time(&gs_handle, MPU9250_DMP_DEFAULT_TAP_TIME);
854 if (res != 0)
855 {
856 mpu9250_interface_debug_print("mpu9250: dmp set tap time failed.\n");
857 (void)mpu9250_deinit(&gs_handle);
858
859 return 1;
860 }
861
862 /* set the default min tap count */
863 res = mpu9250_dmp_set_min_tap_count(&gs_handle, MPU9250_DMP_DEFAULT_MIN_TAP_COUNT);
864 if (res != 0)
865 {
866 mpu9250_interface_debug_print("mpu9250: dmp set min tap count failed.\n");
867 (void)mpu9250_deinit(&gs_handle);
868
869 return 1;
870 }
871
872 /* set the default tap thresh x */
873 res = mpu9250_dmp_set_tap_thresh(&gs_handle, MPU9250_AXIS_X, MPU9250_DMP_DEFAULT_TAP_X_THRESH);
874 if (res != 0)
875 {
876 mpu9250_interface_debug_print("mpu9250: dmp set tap thresh failed.\n");
877 (void)mpu9250_deinit(&gs_handle);
878
879 return 1;
880 }
881
882 /* set the default tap thresh y */
883 res = mpu9250_dmp_set_tap_thresh(&gs_handle, MPU9250_AXIS_Y,MPU9250_DMP_DEFAULT_TAP_Y_THRESH);
884 if (res != 0)
885 {
886 mpu9250_interface_debug_print("mpu9250: dmp set tap thresh failed.\n");
887 (void)mpu9250_deinit(&gs_handle);
888
889 return 1;
890 }
891
892 /* set the default tap thresh z */
893 res = mpu9250_dmp_set_tap_thresh(&gs_handle, MPU9250_AXIS_Z, MPU9250_DMP_DEFAULT_TAP_Z_THRESH);
894 if (res != 0)
895 {
896 mpu9250_interface_debug_print("mpu9250: dmp set tap thresh failed.\n");
897 (void)mpu9250_deinit(&gs_handle);
898
899 return 1;
900 }
901
902 /* dmp gyro accel raw offset convert */
903 res = mpu9250_dmp_gyro_accel_raw_offset_convert(&gs_handle, gyro_offset_raw, accel_offset_raw,
904 gyro_offset, accel_offset);
905 if (res != 0)
906 {
907 mpu9250_interface_debug_print("mpu9250: dmp gyro accel raw offset convert failed.\n");
908 (void)mpu9250_deinit(&gs_handle);
909
910 return 1;
911 }
912
913 /* dmp set accel bias */
914 res = mpu9250_dmp_set_accel_bias(&gs_handle, accel_offset);
915 if (res != 0)
916 {
917 mpu9250_interface_debug_print("mpu9250: dmp set accel bias failed.\n");
918 (void)mpu9250_deinit(&gs_handle);
919
920 return 1;
921 }
922
923 /* dmp set gyro bias */
924 res = mpu9250_dmp_set_gyro_bias(&gs_handle, gyro_offset);
925 if (res != 0)
926 {
927 mpu9250_interface_debug_print("mpu9250: dmp set gyro bias failed.\n");
928 (void)mpu9250_deinit(&gs_handle);
929
930 return 1;
931 }
932
933 /* enable the dmp */
934 res = mpu9250_dmp_set_enable(&gs_handle, MPU9250_BOOL_TRUE);
935 if (res != 0)
936 {
937 mpu9250_interface_debug_print("mpu9250: dmp set enable failed.\n");
938 (void)mpu9250_deinit(&gs_handle);
939
940 return 1;
941 }
942
943 /* force fifo reset */
944 res = mpu9250_force_fifo_reset(&gs_handle);
945 if (res != 0)
946 {
947 mpu9250_interface_debug_print("mpu9250: force fifo reset failed.\n");
948 (void)mpu9250_deinit(&gs_handle);
949
950 return 1;
951 }
952
953 return 0;
954 }
955
964 uint8_t mpu9250_dmp_get_pedometer_counter(uint32_t *cnt)
965 {
966 /* get the pedometer counter */
967 if (mpu9250_dmp_get_pedometer_step_count(&gs_handle, cnt) != 0)
968 {
969 return 1;
970 }
971
972 return 0;
973 }
974
991 uint8_t mpu9250_dmp_read_all(int16_t (*accel_raw)[3], float (*accel_g)[3],
992 int16_t (*gyro_raw)[3], float (*gyro_dps)[3],
993 int32_t (*quat)[4],
994 float *pitch, float *roll, float *yaw,
995 uint16_t *l
996 )
997 {
998 /* dmp read */
999 if (mpu9250_dmp_read(&gs_handle, accel_raw, accel_g,
1000 gyro_raw, gyro_dps, quat,
1001 pitch, roll, yaw, l) != 0
1002 )
1003 {
1004 return 1;
1005 }
1006
1007 return 0;
1008 }
1009
1017 uint8_t mpu9250_dmp_deinit(void)
1018 {
1019 /* deinit */
1020 if (mpu9250_deinit(&gs_handle) != 0)
1021 {
1022 return 1;
1023 }
1024
1025 return 0;
1026 }
driver_mpu9250_dmp.h
driver mpu9250 dmp 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_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_motion_threshold
uint8_t mpu9250_set_motion_threshold(mpu9250_handle_t *handle, uint8_t threshold)
set the motion_threshold
Definition: driver_mpu9250.c:9969
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_motion_threshold_convert_to_register
uint8_t mpu9250_motion_threshold_convert_to_register(mpu9250_handle_t *handle, float mg, uint8_t *reg)
convert the motion threshold to the register raw data
Definition: driver_mpu9250.c:10039
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_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_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_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_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_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_set_tap_callback
uint8_t mpu9250_dmp_set_tap_callback(mpu9250_handle_t *handle, void(*callback)(uint8_t count, uint8_t direction))
dmp set the tap callback
Definition: driver_mpu9250.c:3699
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_set_shake_reject_timeout
uint8_t mpu9250_dmp_set_shake_reject_timeout(mpu9250_handle_t *handle, uint16_t ms)
dmp set the shake reject timeout
Definition: driver_mpu9250.c:1352
mpu9250_dmp_set_orientation
uint8_t mpu9250_dmp_set_orientation(mpu9250_handle_t *handle, int8_t mat[9])
dmp set the orientation
Definition: driver_mpu9250.c:2392
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_tap_axes
uint8_t mpu9250_dmp_set_tap_axes(mpu9250_handle_t *handle, mpu9250_axis_t axis, mpu9250_bool_t enable)
dmp enable or disable the tap axes
Definition: driver_mpu9250.c:3051
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_shake_reject_thresh
uint8_t mpu9250_dmp_set_shake_reject_thresh(mpu9250_handle_t *handle, uint16_t dps)
dmp set the shake reject thresh
Definition: driver_mpu9250.c:1536
mpu9250_dmp_set_orient_callback
uint8_t mpu9250_dmp_set_orient_callback(mpu9250_handle_t *handle, void(*callback)(uint8_t orientation))
dmp set the orient callback
Definition: driver_mpu9250.c:3733
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_set_shake_reject_time
uint8_t mpu9250_dmp_set_shake_reject_time(mpu9250_handle_t *handle, uint16_t ms)
dmp set the shake reject time
Definition: driver_mpu9250.c:1444
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_tap_time
uint8_t mpu9250_dmp_set_tap_time(mpu9250_handle_t *handle, uint16_t ms)
dmp set the tap time
Definition: driver_mpu9250.c:1726
mpu9250_dmp_set_tap_thresh
uint8_t mpu9250_dmp_set_tap_thresh(mpu9250_handle_t *handle, mpu9250_axis_t axis, uint16_t mg_ms)
dmp set the tap thresh
Definition: driver_mpu9250.c:3168
mpu9250_dmp_set_min_tap_count
uint8_t mpu9250_dmp_set_min_tap_count(mpu9250_handle_t *handle, uint8_t cnt)
dmp set the min tap count
Definition: driver_mpu9250.c:1819
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_set_tap_time_multi
uint8_t mpu9250_dmp_set_tap_time_multi(mpu9250_handle_t *handle, uint16_t ms)
dmp set max time between taps to register as a multi tap
Definition: driver_mpu9250.c:1634
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_FEATURE_SEND_CAL_GYRO
@ MPU9250_DMP_FEATURE_SEND_CAL_GYRO
Definition: driver_mpu9250.h:462
MPU9250_DMP_FEATURE_SEND_RAW_ACCEL
@ MPU9250_DMP_FEATURE_SEND_RAW_ACCEL
Definition: driver_mpu9250.h:460
MPU9250_DMP_FEATURE_TAP
@ MPU9250_DMP_FEATURE_TAP
Definition: driver_mpu9250.h:454
MPU9250_DMP_FEATURE_ORIENT
@ MPU9250_DMP_FEATURE_ORIENT
Definition: driver_mpu9250.h:455
MPU9250_DMP_DEFAULT_EXTERN_SYNC
#define MPU9250_DMP_DEFAULT_EXTERN_SYNC
Definition: driver_mpu9250_dmp.h:69
MPU9250_DMP_DEFAULT_TAP_Z_THRESH
#define MPU9250_DMP_DEFAULT_TAP_Z_THRESH
Definition: driver_mpu9250_dmp.h:84
MPU9250_DMP_DEFAULT_IIC_BYPASS
#define MPU9250_DMP_DEFAULT_IIC_BYPASS
Definition: driver_mpu9250_dmp.h:73
mpu9250_dmp_irq_handler
uint8_t mpu9250_dmp_irq_handler(void)
dmp irq
Definition: driver_mpu9250_dmp.c:48
mpu9250_dmp_deinit
uint8_t mpu9250_dmp_deinit(void)
dmp example deinit
Definition: driver_mpu9250_dmp.c:1017
MPU9250_DMP_DEFAULT_CYCLE_WAKE_UP
#define MPU9250_DMP_DEFAULT_CYCLE_WAKE_UP
Definition: driver_mpu9250_dmp.h:59
mpu9250_dmp_init
uint8_t mpu9250_dmp_init(mpu9250_interface_t interface, mpu9250_address_t addr_pin, void(*receive_callback)(uint8_t type), void(*tap_callback)(uint8_t count, uint8_t direction), void(*orient_callback)(uint8_t orientation))
dmp example init
Definition: driver_mpu9250_dmp.c:72
MPU9250_DMP_DEFAULT_GYROSCOPE_CHOICE
#define MPU9250_DMP_DEFAULT_GYROSCOPE_CHOICE
Definition: driver_mpu9250_dmp.h:89
MPU9250_DMP_DEFAULT_INTERRUPT_PIN_TYPE
#define MPU9250_DMP_DEFAULT_INTERRUPT_PIN_TYPE
Definition: driver_mpu9250_dmp.h:61
MPU9250_DMP_DEFAULT_INTERRUPT_LATCH
#define MPU9250_DMP_DEFAULT_INTERRUPT_LATCH
Definition: driver_mpu9250_dmp.h:67
MPU9250_DMP_DEFAULT_PEOMETER_STEP_COUNT
#define MPU9250_DMP_DEFAULT_PEOMETER_STEP_COUNT
Definition: driver_mpu9250_dmp.h:75
MPU9250_DMP_DEFAULT_IIC_MASTER
#define MPU9250_DMP_DEFAULT_IIC_MASTER
Definition: driver_mpu9250_dmp.h:72
MPU9250_DMP_DEFAULT_SHAKE_REJECT_TIME
#define MPU9250_DMP_DEFAULT_SHAKE_REJECT_TIME
Definition: driver_mpu9250_dmp.h:77
MPU9250_DMP_DEFAULT_INTERRUPT_DATA_READY
#define MPU9250_DMP_DEFAULT_INTERRUPT_DATA_READY
Definition: driver_mpu9250_dmp.h:66
MPU9250_DMP_DEFAULT_FSYNC_INTERRUPT_LEVEL
#define MPU9250_DMP_DEFAULT_FSYNC_INTERRUPT_LEVEL
Definition: driver_mpu9250_dmp.h:71
MPU9250_DMP_DEFAULT_SHAKE_REJECT_THRESH
#define MPU9250_DMP_DEFAULT_SHAKE_REJECT_THRESH
Definition: driver_mpu9250_dmp.h:78
MPU9250_DMP_DEFAULT_SHAKE_REJECT_TIMEOUT
#define MPU9250_DMP_DEFAULT_SHAKE_REJECT_TIMEOUT
Definition: driver_mpu9250_dmp.h:76
MPU9250_DMP_DEFAULT_PEOMETER_WALK_TIME
#define MPU9250_DMP_DEFAULT_PEOMETER_WALK_TIME
Definition: driver_mpu9250_dmp.h:74
MPU9250_DMP_DEFAULT_FSYNC_INTERRUPT
#define MPU9250_DMP_DEFAULT_FSYNC_INTERRUPT
Definition: driver_mpu9250_dmp.h:70
MPU9250_DMP_DEFAULT_INTERRUPT_DMP
#define MPU9250_DMP_DEFAULT_INTERRUPT_DMP
Definition: driver_mpu9250_dmp.h:64
MPU9250_DMP_DEFAULT_INTERRUPT_MOTION
#define MPU9250_DMP_DEFAULT_INTERRUPT_MOTION
Definition: driver_mpu9250_dmp.h:62
mpu9250_dmp_get_pedometer_counter
uint8_t mpu9250_dmp_get_pedometer_counter(uint32_t *cnt)
dmp example get pedometer counter
Definition: driver_mpu9250_dmp.c:964
MPU9250_DMP_DEFAULT_CLOCK_SOURCE
#define MPU9250_DMP_DEFAULT_CLOCK_SOURCE
mpu9250 dmp example default definition
Definition: driver_mpu9250_dmp.h:54
MPU9250_DMP_DEFAULT_TAP_TIME_MULTI
#define MPU9250_DMP_DEFAULT_TAP_TIME_MULTI
Definition: driver_mpu9250_dmp.h:79
MPU9250_DMP_DEFAULT_RATE
#define MPU9250_DMP_DEFAULT_RATE
Definition: driver_mpu9250_dmp.h:55
MPU9250_DMP_DEFAULT_MIN_TAP_COUNT
#define MPU9250_DMP_DEFAULT_MIN_TAP_COUNT
Definition: driver_mpu9250_dmp.h:81
MPU9250_DMP_DEFAULT_TAP_Y_THRESH
#define MPU9250_DMP_DEFAULT_TAP_Y_THRESH
Definition: driver_mpu9250_dmp.h:83
MPU9250_DMP_DEFAULT_LOW_POWER_ACCEL_OUTPUT_RATE
#define MPU9250_DMP_DEFAULT_LOW_POWER_ACCEL_OUTPUT_RATE
Definition: driver_mpu9250_dmp.h:92
MPU9250_DMP_DEFAULT_INTERRUPT_READ_CLEAR
#define MPU9250_DMP_DEFAULT_INTERRUPT_READ_CLEAR
Definition: driver_mpu9250_dmp.h:68
mpu9250_dmp_read_all
uint8_t mpu9250_dmp_read_all(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 example read
Definition: driver_mpu9250_dmp.c:991
MPU9250_DMP_DEFAULT_ACCELEROMETER_COMPARE
#define MPU9250_DMP_DEFAULT_ACCELEROMETER_COMPARE
Definition: driver_mpu9250_dmp.h:93
MPU9250_DMP_DEFAULT_TAP_TIME
#define MPU9250_DMP_DEFAULT_TAP_TIME
Definition: driver_mpu9250_dmp.h:80
MPU9250_DMP_DEFAULT_ACCELEROMETER_LOW_PASS_FILTER
#define MPU9250_DMP_DEFAULT_ACCELEROMETER_LOW_PASS_FILTER
Definition: driver_mpu9250_dmp.h:91
MPU9250_DMP_DEFAULT_TAP_X_THRESH
#define MPU9250_DMP_DEFAULT_TAP_X_THRESH
Definition: driver_mpu9250_dmp.h:82
MPU9250_DMP_DEFAULT_INTERRUPT_PIN_LEVEL
#define MPU9250_DMP_DEFAULT_INTERRUPT_PIN_LEVEL
Definition: driver_mpu9250_dmp.h:60
MPU9250_DMP_DEFAULT_FIFO_MODE
#define MPU9250_DMP_DEFAULT_FIFO_MODE
Definition: driver_mpu9250_dmp.h:88
MPU9250_DMP_DEFAULT_MOTION_THRESHOLD
#define MPU9250_DMP_DEFAULT_MOTION_THRESHOLD
Definition: driver_mpu9250_dmp.h:86
MPU9250_DMP_DEFAULT_INTERRUPT_FIFO_OVERFLOW
#define MPU9250_DMP_DEFAULT_INTERRUPT_FIFO_OVERFLOW
Definition: driver_mpu9250_dmp.h:63
MPU9250_DMP_DEFAULT_INTERRUPT_FSYNC_INT
#define MPU9250_DMP_DEFAULT_INTERRUPT_FSYNC_INT
Definition: driver_mpu9250_dmp.h:65
MPU9250_DMP_DEFAULT_INTERRUPT_MODE
#define MPU9250_DMP_DEFAULT_INTERRUPT_MODE
Definition: driver_mpu9250_dmp.h:85
MPU9250_DMP_DEFAULT_ACCELEROMETER_RANGE
#define MPU9250_DMP_DEFAULT_ACCELEROMETER_RANGE
Definition: driver_mpu9250_dmp.h:56
MPU9250_DMP_DEFAULT_LOW_PASS_FILTER
#define MPU9250_DMP_DEFAULT_LOW_PASS_FILTER
Definition: driver_mpu9250_dmp.h:58
MPU9250_DMP_DEFAULT_GYROSCOPE_RANGE
#define MPU9250_DMP_DEFAULT_GYROSCOPE_RANGE
Definition: driver_mpu9250_dmp.h:57
MPU9250_DMP_DEFAULT_ACCELEROMETER_CHOICE
#define MPU9250_DMP_DEFAULT_ACCELEROMETER_CHOICE
Definition: driver_mpu9250_dmp.h:90
MPU9250_DMP_DEFAULT_GYROSCOPE_STANDBY
#define MPU9250_DMP_DEFAULT_GYROSCOPE_STANDBY
Definition: driver_mpu9250_dmp.h:87
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_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_handle_s
mpu9250 handle structure definition
Definition: driver_mpu9250.h:502