| LibDriver MPU9250 1.0.0 MPU9250 full function driver

driver_mpu9250_dmp_read_test.c
Go to the documentation of this file.
1
37 #include "driver_mpu9250_dmp_read_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_read_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_read_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 uint8_t c;
90 uint8_t c_check;
91 int32_t gyro_offset_raw[3];
92 int32_t accel_offset_raw[3];
93 int32_t gyro_offset[3];
94 int32_t accel_offset[3];
95 mpu9250_bool_t enable;
96 mpu9250_info_t info;
97 int8_t gyro_orientation[9] = {1, 0, 0,
98 0, 1, 0,
99 0, 0, 1};
100
101 /* link interface function */
102 DRIVER_MPU9250_LINK_INIT(&gs_handle, mpu9250_handle_t);
103 DRIVER_MPU9250_LINK_IIC_INIT(&gs_handle, mpu9250_interface_iic_init);
104 DRIVER_MPU9250_LINK_IIC_DEINIT(&gs_handle, mpu9250_interface_iic_deinit);
105 DRIVER_MPU9250_LINK_IIC_READ(&gs_handle, mpu9250_interface_iic_read);
106 DRIVER_MPU9250_LINK_IIC_WRITE(&gs_handle, mpu9250_interface_iic_write);
107 DRIVER_MPU9250_LINK_SPI_INIT(&gs_handle, mpu9250_interface_spi_init);
108 DRIVER_MPU9250_LINK_SPI_DEINIT(&gs_handle, mpu9250_interface_spi_deinit);
109 DRIVER_MPU9250_LINK_SPI_READ(&gs_handle, mpu9250_interface_spi_read);
110 DRIVER_MPU9250_LINK_SPI_WRITE(&gs_handle, mpu9250_interface_spi_write);
111 DRIVER_MPU9250_LINK_DELAY_MS(&gs_handle, mpu9250_interface_delay_ms);
112 DRIVER_MPU9250_LINK_DEBUG_PRINT(&gs_handle, mpu9250_interface_debug_print);
113 DRIVER_MPU9250_LINK_RECEIVE_CALLBACK(&gs_handle, mpu9250_interface_receive_callback);
114
115 /* get information */
116 res = mpu9250_info(&info);
117 if (res != 0)
118 {
119 mpu9250_interface_debug_print("mpu9250: get info failed.\n");
120
121 return 1;
122 }
123 else
124 {
125 /* print chip info */
126 mpu9250_interface_debug_print("mpu9250: chip is %s.\n", info.chip_name);
127 mpu9250_interface_debug_print("mpu9250: manufacturer is %s.\n", info.manufacturer_name);
128 mpu9250_interface_debug_print("mpu9250: interface is %s.\n", info.interface);
129 mpu9250_interface_debug_print("mpu9250: driver version is %d.%d.\n", info.driver_version / 1000, (info.driver_version % 1000) / 100);
130 mpu9250_interface_debug_print("mpu9250: min supply voltage is %0.1fV.\n", info.supply_voltage_min_v);
131 mpu9250_interface_debug_print("mpu9250: max supply voltage is %0.1fV.\n", info.supply_voltage_max_v);
132 mpu9250_interface_debug_print("mpu9250: max current is %0.2fmA.\n", info.max_current_ma);
133 mpu9250_interface_debug_print("mpu9250: max temperature is %0.1fC.\n", info.temperature_max);
134 mpu9250_interface_debug_print("mpu9250: min temperature is %0.1fC.\n", info.temperature_min);
135 }
136
137 /* start dmp read test */
138 mpu9250_interface_debug_print("mpu9250: start dmp read test.\n");
139
140 /* set the interface */
141 res = mpu9250_set_interface(&gs_handle, interface);
142 if (res != 0)
143 {
144 mpu9250_interface_debug_print("mpu9250: set interface failed.\n");
145
146 return 1;
147 }
148
149 /* set the addr pin */
150 res = mpu9250_set_addr_pin(&gs_handle, addr);
151 if (res != 0)
152 {
153 mpu9250_interface_debug_print("mpu9250: set addr pin failed.\n");
154
155 return 1;
156 }
157
158 /* init */
159 res = mpu9250_init(&gs_handle);
160 if (res != 0)
161 {
162 mpu9250_interface_debug_print("mpu9250: init failed.\n");
163
164 return 1;
165 }
166
167 /* delay 100 ms */
168 mpu9250_interface_delay_ms(100);
169
170 /* disable sleep */
171 res = mpu9250_set_sleep(&gs_handle, MPU9250_BOOL_FALSE);
172 if (res != 0)
173 {
174 mpu9250_interface_debug_print("mpu9250: set sleep failed.\n");
175 (void)mpu9250_deinit(&gs_handle);
176
177 return 1;
178 }
179
180 /* if spi interface, disable iic interface */
181 if (interface == MPU9250_INTERFACE_SPI)
182 {
183 /* disable iic */
184 res = mpu9250_set_disable_iic_slave(&gs_handle, MPU9250_BOOL_TRUE);
185 if (res != 0)
186 {
187 mpu9250_interface_debug_print("mpu9250: set disable iic slave failed.\n");
188 (void)mpu9250_deinit(&gs_handle);
189
190 return 1;
191 }
192 }
193
194 /* set fifo 1024kb */
195 res = mpu9250_set_fifo_1024kb(&gs_handle);
196 if (res != 0)
197 {
198 mpu9250_interface_debug_print("mpu9250: set fifo 1024kb failed.\n");
199 (void)mpu9250_deinit(&gs_handle);
200
201 return 1;
202 }
203
204 /* run the self test */
205 res = mpu9250_self_test(&gs_handle, gyro_offset_raw, accel_offset_raw);
206 if (res != 0)
207 {
208 mpu9250_interface_debug_print("mpu9250: self test failed.\n");
209 (void)mpu9250_deinit(&gs_handle);
210
211 return 1;
212 }
213
214 /* set fifo 1024kb */
215 res = mpu9250_set_fifo_1024kb(&gs_handle);
216 if (res != 0)
217 {
218 mpu9250_interface_debug_print("mpu9250: set fifo 1024kb failed.\n");
219 (void)mpu9250_deinit(&gs_handle);
220
221 return 1;
222 }
223
224 /* set pll */
225 res = mpu9250_set_clock_source(&gs_handle, MPU9250_CLOCK_SOURCE_PLL);
226 if (res != 0)
227 {
228 mpu9250_interface_debug_print("mpu9250: set clock source failed.\n");
229 (void)mpu9250_deinit(&gs_handle);
230
231 return 1;
232 }
233
234 /* set 50Hz */
235 res = mpu9250_set_sample_rate_divider(&gs_handle, (1000 / 50) - 1);
236 if (res != 0)
237 {
238 mpu9250_interface_debug_print("mpu9250: set sample rate divider failed.\n");
239 (void)mpu9250_deinit(&gs_handle);
240
241 return 1;
242 }
243
244 /* ±2g */
245 res = mpu9250_set_accelerometer_range(&gs_handle, MPU9250_ACCELEROMETER_RANGE_2G);
246 if (res != 0)
247 {
248 mpu9250_interface_debug_print("mpu9250: set accelerometer range failed.\n");
249 (void)mpu9250_deinit(&gs_handle);
250
251 return 1;
252 }
253
254 /* ±2000dps */
255 res = mpu9250_set_gyroscope_range(&gs_handle, MPU9250_GYROSCOPE_RANGE_2000DPS);
256 if (res != 0)
257 {
258 mpu9250_interface_debug_print("mpu9250: set gyroscope range failed.\n");
259 (void)mpu9250_deinit(&gs_handle);
260
261 return 1;
262 }
263
264 /* set low pass filter 3 */
265 res = mpu9250_set_low_pass_filter(&gs_handle, MPU9250_LOW_PASS_FILTER_3);
266 if (res != 0)
267 {
268 mpu9250_interface_debug_print("mpu9250: set low pass filter failed.\n");
269 (void)mpu9250_deinit(&gs_handle);
270
271 return 1;
272 }
273
274 /* enable temperature sensor */
275 res = mpu9250_set_ptat(&gs_handle, MPU9250_BOOL_TRUE);
276 if (res != 0)
277 {
278 mpu9250_interface_debug_print("mpu9250: set ptat failed.\n");
279 (void)mpu9250_deinit(&gs_handle);
280
281 return 1;
282 }
283
284 /* disable cycle wake up */
285 res = mpu9250_set_cycle_wake_up(&gs_handle, MPU9250_BOOL_FALSE);
286 if (res != 0)
287 {
288 mpu9250_interface_debug_print("mpu9250: set cycle wake up failed.\n");
289 (void)mpu9250_deinit(&gs_handle);
290
291 return 1;
292 }
293
294 /* enable acc x */
295 res = mpu9250_set_standby_mode(&gs_handle, MPU9250_SOURCE_ACC_X, MPU9250_BOOL_FALSE);
296 if (res != 0)
297 {
298 mpu9250_interface_debug_print("mpu9250: set standby mode failed.\n");
299 (void)mpu9250_deinit(&gs_handle);
300
301 return 1;
302 }
303
304 /* enable acc y */
305 res = mpu9250_set_standby_mode(&gs_handle, MPU9250_SOURCE_ACC_Y, MPU9250_BOOL_FALSE);
306 if (res != 0)
307 {
308 mpu9250_interface_debug_print("mpu9250: set standby mode failed.\n");
309 (void)mpu9250_deinit(&gs_handle);
310
311 return 1;
312 }
313
314 /* enable acc z */
315 res = mpu9250_set_standby_mode(&gs_handle, MPU9250_SOURCE_ACC_Z, MPU9250_BOOL_FALSE);
316 if (res != 0)
317 {
318 mpu9250_interface_debug_print("mpu9250: set standby mode failed.\n");
319 (void)mpu9250_deinit(&gs_handle);
320
321 return 1;
322 }
323
324 /* enable gyro x */
325 res = mpu9250_set_standby_mode(&gs_handle, MPU9250_SOURCE_GYRO_X, MPU9250_BOOL_FALSE);
326 if (res != 0)
327 {
328 mpu9250_interface_debug_print("mpu9250: set standby mode failed.\n");
329 (void)mpu9250_deinit(&gs_handle);
330
331 return 1;
332 }
333
334 /* enable gyro y */
335 res = mpu9250_set_standby_mode(&gs_handle, MPU9250_SOURCE_GYRO_Y, MPU9250_BOOL_FALSE);
336 if (res != 0)
337 {
338 mpu9250_interface_debug_print("mpu9250: set standby mode failed.\n");
339 (void)mpu9250_deinit(&gs_handle);
340
341 return 1;
342 }
343
344 /* enable gyro z */
345 res = mpu9250_set_standby_mode(&gs_handle, MPU9250_SOURCE_GYRO_Z, MPU9250_BOOL_FALSE);
346 if (res != 0)
347 {
348 mpu9250_interface_debug_print("mpu9250: set standby mode failed.\n");
349 (void)mpu9250_deinit(&gs_handle);
350
351 return 1;
352 }
353
354 /* disable gyroscope x test */
355 res = mpu9250_set_gyroscope_test(&gs_handle, MPU9250_AXIS_X, MPU9250_BOOL_FALSE);
356 if (res != 0)
357 {
358 mpu9250_interface_debug_print("mpu9250: set gyroscope test failed.\n");
359 (void)mpu9250_deinit(&gs_handle);
360
361 return 1;
362 }
363
364 /* disable gyroscope y test */
365 res = mpu9250_set_gyroscope_test(&gs_handle, MPU9250_AXIS_Y, MPU9250_BOOL_FALSE);
366 if (res != 0)
367 {
368 mpu9250_interface_debug_print("mpu9250: set gyroscope test failed.\n");
369 (void)mpu9250_deinit(&gs_handle);
370
371 return 1;
372 }
373
374 /* disable gyroscope z test */
375 res = mpu9250_set_gyroscope_test(&gs_handle, MPU9250_AXIS_Z, MPU9250_BOOL_FALSE);
376 if (res != 0)
377 {
378 mpu9250_interface_debug_print("mpu9250: set gyroscope test failed.\n");
379 (void)mpu9250_deinit(&gs_handle);
380
381 return 1;
382 }
383
384 /* disable accelerometer x test */
385 res = mpu9250_set_accelerometer_test(&gs_handle, MPU9250_AXIS_X, MPU9250_BOOL_FALSE);
386 if (res != 0)
387 {
388 mpu9250_interface_debug_print("mpu9250: set accelerometer test failed.\n");
389 (void)mpu9250_deinit(&gs_handle);
390
391 return 1;
392 }
393
394 /* disable accelerometer y test */
395 res = mpu9250_set_accelerometer_test(&gs_handle, MPU9250_AXIS_Y, MPU9250_BOOL_FALSE);
396 if (res != 0)
397 {
398 mpu9250_interface_debug_print("mpu9250: set accelerometer test failed.\n");
399 (void)mpu9250_deinit(&gs_handle);
400
401 return 1;
402 }
403
404 /* disable accelerometer z test */
405 res = mpu9250_set_accelerometer_test(&gs_handle, MPU9250_AXIS_Z, MPU9250_BOOL_FALSE);
406 if (res != 0)
407 {
408 mpu9250_interface_debug_print("mpu9250: set accelerometer test failed.\n");
409 (void)mpu9250_deinit(&gs_handle);
410
411 return 1;
412 }
413
414 /* disable temp fifo */
415 res = mpu9250_set_fifo_enable(&gs_handle, MPU9250_FIFO_TEMP, MPU9250_BOOL_FALSE);
416 if (res != 0)
417 {
418 mpu9250_interface_debug_print("mpu9250: set fifo enable failed.\n");
419 (void)mpu9250_deinit(&gs_handle);
420
421 return 1;
422 }
423
424 /* disable xg fifo */
425 res = mpu9250_set_fifo_enable(&gs_handle, MPU9250_FIFO_XG, MPU9250_BOOL_FALSE);
426 if (res != 0)
427 {
428 mpu9250_interface_debug_print("mpu9250: set fifo enable failed.\n");
429 (void)mpu9250_deinit(&gs_handle);
430
431 return 1;
432 }
433
434 /* disable yg fifo */
435 res = mpu9250_set_fifo_enable(&gs_handle, MPU9250_FIFO_YG, MPU9250_BOOL_FALSE);
436 if (res != 0)
437 {
438 mpu9250_interface_debug_print("mpu9250: set fifo enable failed.\n");
439 (void)mpu9250_deinit(&gs_handle);
440
441 return 1;
442 }
443
444 /* disable zg fifo */
445 res = mpu9250_set_fifo_enable(&gs_handle, MPU9250_FIFO_ZG, MPU9250_BOOL_FALSE);
446 if (res != 0)
447 {
448 mpu9250_interface_debug_print("mpu9250: set fifo enable failed.\n");
449 (void)mpu9250_deinit(&gs_handle);
450
451 return 1;
452 }
453
454 /* disable accel fifo */
455 res = mpu9250_set_fifo_enable(&gs_handle, MPU9250_FIFO_ACCEL, MPU9250_BOOL_FALSE);
456 if (res != 0)
457 {
458 mpu9250_interface_debug_print("mpu9250: set fifo enable failed.\n");
459 (void)mpu9250_deinit(&gs_handle);
460
461 return 1;
462 }
463
464 /* enable fifo */
465 res = mpu9250_set_fifo(&gs_handle, MPU9250_BOOL_TRUE);
466 if (res != 0)
467 {
468 mpu9250_interface_debug_print("mpu9250: set fifo failed.\n");
469 (void)mpu9250_deinit(&gs_handle);
470
471 return 1;
472 }
473
474 /* set interrupt level low */
475 res = mpu9250_set_interrupt_level(&gs_handle, MPU9250_PIN_LEVEL_LOW);
476 if (res != 0)
477 {
478 mpu9250_interface_debug_print("mpu9250: set interrupt level failed.\n");
479 (void)mpu9250_deinit(&gs_handle);
480
481 return 1;
482 }
483
484 /* push-pull */
485 res = mpu9250_set_interrupt_pin_type(&gs_handle, MPU9250_PIN_TYPE_PUSH_PULL);
486 if (res != 0)
487 {
488 mpu9250_interface_debug_print("mpu9250: set interrupt pin type failed.\n");
489 (void)mpu9250_deinit(&gs_handle);
490
491 return 1;
492 }
493
494 /* disable motion */
495 res = mpu9250_set_interrupt(&gs_handle, MPU9250_INTERRUPT_MOTION, MPU9250_BOOL_FALSE);
496 if (res != 0)
497 {
498 mpu9250_interface_debug_print("mpu9250: set interrupt failed.\n");
499 (void)mpu9250_deinit(&gs_handle);
500
501 return 1;
502 }
503
504 /* enable fifo overflow */
505 res = mpu9250_set_interrupt(&gs_handle, MPU9250_INTERRUPT_FIFO_OVERFLOW, MPU9250_BOOL_TRUE);
506 if (res != 0)
507 {
508 mpu9250_interface_debug_print("mpu9250: set interrupt failed.\n");
509 (void)mpu9250_deinit(&gs_handle);
510
511 return 1;
512 }
513
514 /* disable dmp interrupt */
515 res = mpu9250_set_interrupt(&gs_handle, MPU9250_INTERRUPT_DMP, MPU9250_BOOL_FALSE);
516 if (res != 0)
517 {
518 mpu9250_interface_debug_print("mpu9250: set interrupt failed.\n");
519 (void)mpu9250_deinit(&gs_handle);
520
521 return 1;
522 }
523
524 /* disable fsync int */
525 res = mpu9250_set_interrupt(&gs_handle, MPU9250_INTERRUPT_FSYNC_INT, MPU9250_BOOL_FALSE);
526 if (res != 0)
527 {
528 mpu9250_interface_debug_print("mpu9250: set interrupt failed.\n");
529 (void)mpu9250_deinit(&gs_handle);
530
531 return 1;
532 }
533
534 /* disable data ready */
535 res = mpu9250_set_interrupt(&gs_handle, MPU9250_INTERRUPT_DATA_READY, MPU9250_BOOL_FALSE);
536 if (res != 0)
537 {
538 mpu9250_interface_debug_print("mpu9250: set interrupt failed.\n");
539 (void)mpu9250_deinit(&gs_handle);
540
541 return 1;
542 }
543
544 /* enable latch */
545 res = mpu9250_set_interrupt_latch(&gs_handle, MPU9250_BOOL_TRUE);
546 if (res != 0)
547 {
548 mpu9250_interface_debug_print("mpu9250: set interrupt latch failed.\n");
549 (void)mpu9250_deinit(&gs_handle);
550
551 return 1;
552 }
553
554 /* enable interrupt read clear */
555 res = mpu9250_set_interrupt_read_clear(&gs_handle, MPU9250_BOOL_TRUE);
556 if (res != 0)
557 {
558 mpu9250_interface_debug_print("mpu9250: set interrupt read clear failed.\n");
559 (void)mpu9250_deinit(&gs_handle);
560
561 return 1;
562 }
563
564 /* disable sync input */
565 res = mpu9250_set_extern_sync(&gs_handle, MPU9250_EXTERN_SYNC_INPUT_DISABLED);
566 if (res != 0)
567 {
568 mpu9250_interface_debug_print("mpu9250: set extern sync failed.\n");
569 (void)mpu9250_deinit(&gs_handle);
570
571 return 1;
572 }
573
574 /* disable fsync interrupt */
575 res = mpu9250_set_fsync_interrupt(&gs_handle, MPU9250_BOOL_FALSE);
576 if (res != 0)
577 {
578 mpu9250_interface_debug_print("mpu9250: set fsync interrupt failed.\n");
579 (void)mpu9250_deinit(&gs_handle);
580
581 return 1;
582 }
583
584 /* fsync interrupt level low */
585 res = mpu9250_set_fsync_interrupt_level(&gs_handle, MPU9250_PIN_LEVEL_LOW);
586 if (res != 0)
587 {
588 mpu9250_interface_debug_print("mpu9250: set fsync interrupt level failed.\n");
589 (void)mpu9250_deinit(&gs_handle);
590
591 return 1;
592 }
593
594 /* disable iic master */
595 res = mpu9250_set_iic_master(&gs_handle, MPU9250_BOOL_FALSE);
596 if (res != 0)
597 {
598 mpu9250_interface_debug_print("mpu9250: set iic master failed.\n");
599 (void)mpu9250_deinit(&gs_handle);
600
601 return 1;
602 }
603
604 /* disable iic bypass */
605 res = mpu9250_set_iic_bypass(&gs_handle, MPU9250_BOOL_FALSE);
606 if (res != 0)
607 {
608 mpu9250_interface_debug_print("mpu9250: set iic bypass failed.\n");
609 (void)mpu9250_deinit(&gs_handle);
610
611 return 1;
612 }
613
614 /* disable gyro standby */
615 res = mpu9250_set_gyro_standby(&gs_handle, MPU9250_BOOL_FALSE);
616 if (res != 0)
617 {
618 mpu9250_interface_debug_print("mpu9250: set gyro standby failed.\n");
619 (void)mpu9250_deinit(&gs_handle);
620
621 return 1;
622 }
623
624 /* set the fifo normal mode */
625 res = mpu9250_set_fifo_mode(&gs_handle, MPU9250_FIFO_MODE_NORMAL);
626 if (res != 0)
627 {
628 mpu9250_interface_debug_print("mpu9250: set fifo mode failed.\n");
629 (void)mpu9250_deinit(&gs_handle);
630
631 return 1;
632 }
633
634 /* set gyroscope choice 0 */
635 res = mpu9250_set_gyroscope_choice(&gs_handle, 0);
636 if (res != 0)
637 {
638 mpu9250_interface_debug_print("mpu9250: set gyroscope choice failed.\n");
639 (void)mpu9250_deinit(&gs_handle);
640
641 return 1;
642 }
643
644 /* set low pass filter 3 */
645 res = mpu9250_set_low_pass_filter(&gs_handle, MPU9250_LOW_PASS_FILTER_3);
646 if (res != 0)
647 {
648 mpu9250_interface_debug_print("mpu9250: set low pass filter failed.\n");
649 (void)mpu9250_deinit(&gs_handle);
650
651 return 1;
652 }
653
654 /* set accelerometer choice 0 */
655 res = mpu9250_set_accelerometer_choice(&gs_handle, 0);
656 if (res != 0)
657 {
658 mpu9250_interface_debug_print("mpu9250: set accelerometer choice failed.\n");
659 (void)mpu9250_deinit(&gs_handle);
660
661 return 1;
662 }
663
664 /* set accelerometer low pass filter 3 */
665 res = mpu9250_set_accelerometer_low_pass_filter(&gs_handle, MPU9250_ACCELEROMETER_LOW_PASS_FILTER_3);
666 if (res != 0)
667 {
668 mpu9250_interface_debug_print("mpu9250: set accelerometer low pass filter failed.\n");
669 (void)mpu9250_deinit(&gs_handle);
670
671 return 1;
672 }
673
674 /* set low power accel output rate 62.5Hz */
675 res = mpu9250_set_low_power_accel_output_rate(&gs_handle, MPU9250_LOW_POWER_ACCEL_OUTPUT_RATE_62P50);
676 if (res != 0)
677 {
678 mpu9250_interface_debug_print("mpu9250: set low power accel output rate failed.\n");
679 (void)mpu9250_deinit(&gs_handle);
680
681 return 1;
682 }
683
684 /* disable wake on motion */
685 res = mpu9250_set_wake_on_motion(&gs_handle, MPU9250_BOOL_FALSE);
686 if (res != 0)
687 {
688 mpu9250_interface_debug_print("mpu9250: set wake on motion failed.\n");
689 (void)mpu9250_deinit(&gs_handle);
690
691 return 1;
692 }
693
694 /* enable accel compare with previous sample */
695 res = mpu9250_set_accel_compare_with_previous_sample(&gs_handle, MPU9250_BOOL_TRUE);
696 if (res != 0)
697 {
698 mpu9250_interface_debug_print("mpu9250: set accel compare with previous sample failed.\n");
699 (void)mpu9250_deinit(&gs_handle);
700
701 return 1;
702 }
703
704 /* load dmp firmware */
705 mpu9250_interface_debug_print("mpu9250: load dmp firmware.\n");
706
707 /* dmp load firmware */
708 res = mpu9250_dmp_load_firmware(&gs_handle);
709 if (res != 0)
710 {
711 mpu9250_interface_debug_print("mpu9250: dmp load firmware failed.\n");
712 (void)mpu9250_deinit(&gs_handle);
713
714 return 1;
715 }
716
717 /* load dmp firmware successful */
718 mpu9250_interface_debug_print("mpu9250: load dmp firmware successful .\n");
719
720 /* mpu9250_dmp_set_pedometer_walk_time/mpu9250_dmp_get_pedometer_walk_time test */
721 mpu9250_interface_debug_print("mpu9250: mpu9250_dmp_set_pedometer_walk_time/mpu9250_dmp_get_pedometer_walk_time test.\n");
722
723 ms = 200;
724 res = mpu9250_dmp_set_pedometer_walk_time(&gs_handle, ms);
725 if (res != 0)
726 {
727 mpu9250_interface_debug_print("mpu9250: dmp set pedometer walk time failed.\n");
728 (void)mpu9250_deinit(&gs_handle);
729
730 return 1;
731 }
732 mpu9250_interface_debug_print("mpu9250: dmp set pedometer walk time %d ms.\n", ms);
733 res = mpu9250_dmp_get_pedometer_walk_time(&gs_handle, &ms_check);
734 if (res != 0)
735 {
736 mpu9250_interface_debug_print("mpu9250: dmp get pedometer walk time failed.\n");
737 (void)mpu9250_deinit(&gs_handle);
738
739 return 1;
740 }
741 mpu9250_interface_debug_print("mpu9250: check pedometer walk time %s.\n", ms_check == ms ? "ok" : "error");
742
743 /* mpu9250_dmp_set_pedometer_step_count/mpu9250_dmp_get_pedometer_step_count test */
744 mpu9250_interface_debug_print("mpu9250: mpu9250_dmp_set_pedometer_step_count/mpu9250_dmp_get_pedometer_step_count test.\n");
745
746 cnt = rand() % 1000;
747 res = mpu9250_dmp_set_pedometer_step_count(&gs_handle, cnt);
748 if (res != 0)
749 {
750 mpu9250_interface_debug_print("mpu9250: dmp set pedometer step count failed.\n");
751 (void)mpu9250_deinit(&gs_handle);
752
753 return 1;
754 }
755 mpu9250_interface_debug_print("mpu9250: dmp set pedometer step count %d.\n", cnt);
756 res = mpu9250_dmp_get_pedometer_step_count(&gs_handle, &cnt_check);
757 if (res != 0)
758 {
759 mpu9250_interface_debug_print("mpu9250: dmp get pedometer step count failed.\n");
760 (void)mpu9250_deinit(&gs_handle);
761
762 return 1;
763 }
764 mpu9250_interface_debug_print("mpu9250: check pedometer step count %s.\n", cnt_check == cnt ? "ok" : "error");
765
766 /* mpu9250_dmp_set_shake_reject_timeout/mpu9250_dmp_get_shake_reject_timeout test */
767 mpu9250_interface_debug_print("mpu9250: mpu9250_dmp_set_shake_reject_timeout/mpu9250_dmp_get_shake_reject_timeout test.\n");
768
769 m = 10;
770 res = mpu9250_dmp_set_shake_reject_timeout(&gs_handle, m);
771 if (res != 0)
772 {
773 mpu9250_interface_debug_print("mpu9250: dmp set shake reject timeout failed.\n");
774 (void)mpu9250_deinit(&gs_handle);
775
776 return 1;
777 }
778 mpu9250_interface_debug_print("mpu9250: dmp set shake reject timeout %d ms.\n", m);
779 res = mpu9250_dmp_get_shake_reject_timeout(&gs_handle, &m_check);
780 if (res != 0)
781 {
782 mpu9250_interface_debug_print("mpu9250: dmp get shake reject timeout failed.\n");
783 (void)mpu9250_deinit(&gs_handle);
784
785 return 1;
786 }
787 mpu9250_interface_debug_print("mpu9250: check shake reject timeout %s.\n", m_check == m ? "ok" : "error");
788
789 /* mpu9250_dmp_set_shake_reject_time/mpu9250_dmp_get_shake_reject_time test */
790 mpu9250_interface_debug_print("mpu9250: mpu9250_dmp_set_shake_reject_time/mpu9250_dmp_get_shake_reject_time test.\n");
791
792 m = 40;
793 res = mpu9250_dmp_set_shake_reject_time(&gs_handle, m);
794 if (res != 0)
795 {
796 mpu9250_interface_debug_print("mpu9250: dmp set shake reject time failed.\n");
797 (void)mpu9250_deinit(&gs_handle);
798
799 return 1;
800 }
801 mpu9250_interface_debug_print("mpu9250: dmp set shake reject time %d ms.\n", m);
802 res = mpu9250_dmp_get_shake_reject_time(&gs_handle, &m_check);
803 if (res != 0)
804 {
805 mpu9250_interface_debug_print("mpu9250: dmp get shake reject time failed.\n");
806 (void)mpu9250_deinit(&gs_handle);
807
808 return 1;
809 }
810 mpu9250_interface_debug_print("mpu9250: check shake reject time %s.\n", m_check == m ? "ok" : "error");
811
812 /* mpu9250_dmp_set_shake_reject_thresh/mpu9250_dmp_get_shake_reject_thresh test */
813 mpu9250_interface_debug_print("mpu9250: mpu9250_dmp_set_shake_reject_thresh/mpu9250_dmp_get_shake_reject_thresh test.\n");
814
815 m = 0;
816 res = mpu9250_dmp_set_shake_reject_thresh(&gs_handle, m);
817 if (res != 0)
818 {
819 mpu9250_interface_debug_print("mpu9250: dmp set shake reject thresh failed.\n");
820 (void)mpu9250_deinit(&gs_handle);
821
822 return 1;
823 }
824 mpu9250_interface_debug_print("mpu9250: set shake reject thresh %d dps.\n", m);
825 res = mpu9250_dmp_get_shake_reject_thresh(&gs_handle, &m_check);
826 if (res != 0)
827 {
828 mpu9250_interface_debug_print("mpu9250: dmp get shake reject thresh failed.\n");
829 (void)mpu9250_deinit(&gs_handle);
830
831 return 1;
832 }
833 mpu9250_interface_debug_print("mpu9250: check shake reject thresh %s.\n", m_check == m ? "ok" : "error");
834
835 /* mpu9250_dmp_set_tap_time_multi/mpu9250_dmp_get_tap_time_multi test */
836 mpu9250_interface_debug_print("mpu9250: mpu9250_dmp_set_tap_time_multi/mpu9250_dmp_get_tap_time_multi test.\n");
837
838 m = 500;
839 res = mpu9250_dmp_set_tap_time_multi(&gs_handle, m);
840 if (res != 0)
841 {
842 mpu9250_interface_debug_print("mpu9250: dmp set tap time multi failed.\n");
843 (void)mpu9250_deinit(&gs_handle);
844
845 return 1;
846 }
847 mpu9250_interface_debug_print("mpu9250: dmp set tap time multi %d ms.\n", m);
848 res = mpu9250_dmp_get_tap_time_multi(&gs_handle, &m_check);
849 if (res != 0)
850 {
851 mpu9250_interface_debug_print("mpu9250: dmp get tap time multi failed.\n");
852 (void)mpu9250_deinit(&gs_handle);
853
854 return 1;
855 }
856 mpu9250_interface_debug_print("mpu9250: check tap time multi %s.\n", m_check == m ? "ok" : "error");
857
858 /* mpu9250_dmp_set_tap_time/mpu9250_dmp_get_tap_time test */
859 mpu9250_interface_debug_print("mpu9250: mpu9250_dmp_set_tap_time/mpu9250_dmp_get_tap_time test.\n");
860
861 m = 100;
862 res = mpu9250_dmp_set_tap_time(&gs_handle, m);
863 if (res != 0)
864 {
865 mpu9250_interface_debug_print("mpu9250: dmp set tap time failed.\n");
866 (void)mpu9250_deinit(&gs_handle);
867
868 return 1;
869 }
870 mpu9250_interface_debug_print("mpu9250: dmp set tap time %d ms.\n", m);
871 res = mpu9250_dmp_get_tap_time(&gs_handle, &m_check);
872 if (res != 0)
873 {
874 mpu9250_interface_debug_print("mpu9250: dmp get tap time failed.\n");
875 (void)mpu9250_deinit(&gs_handle);
876
877 return 1;
878 }
879 mpu9250_interface_debug_print("mpu9250: check tap time %s.\n", m_check == m ? "ok" : "error");
880
881 /* mpu9250_dmp_set_min_tap_count/mpu9250_dmp_get_min_tap_count test */
882 mpu9250_interface_debug_print("mpu9250: mpu9250_dmp_set_min_tap_count/mpu9250_dmp_get_min_tap_count test.\n");
883
884 c = 1;
885 res = mpu9250_dmp_set_min_tap_count(&gs_handle, c);
886 if (res != 0)
887 {
888 mpu9250_interface_debug_print("mpu9250: dmp set min tap count failed.\n");
889 (void)mpu9250_deinit(&gs_handle);
890
891 return 1;
892 }
893 mpu9250_interface_debug_print("mpu9250: dmp set min tap count %d.\n", c);
894 res = mpu9250_dmp_get_min_tap_count(&gs_handle, &c_check);
895 if (res != 0)
896 {
897 mpu9250_interface_debug_print("mpu9250: dmp get min tap count failed.\n");
898 (void)mpu9250_deinit(&gs_handle);
899
900 return 1;
901 }
902 mpu9250_interface_debug_print("mpu9250: check min tap count %s.\n", c_check == c ? "ok" : "error");
903
904 /* mpu9250_dmp_set_tap_axes/mpu9250_dmp_get_tap_axes test */
905 mpu9250_interface_debug_print("mpu9250: mpu9250_dmp_set_tap_axes/mpu9250_dmp_get_tap_axes test.\n");
906
907 /* disable axis x */
908 res = mpu9250_dmp_set_tap_axes(&gs_handle, MPU9250_AXIS_X, MPU9250_BOOL_FALSE);
909 if (res != 0)
910 {
911 mpu9250_interface_debug_print("mpu9250: dmp set tap axes failed.\n");
912 (void)mpu9250_deinit(&gs_handle);
913
914 return 1;
915 }
916 mpu9250_interface_debug_print("mpu9250: disable tap axes x.\n");
917 res = mpu9250_dmp_get_tap_axes(&gs_handle, MPU9250_AXIS_X, &enable);
918 if (res != 0)
919 {
920 mpu9250_interface_debug_print("mpu9250: dmp get tap axes failed.\n");
921 (void)mpu9250_deinit(&gs_handle);
922
923 return 1;
924 }
925 mpu9250_interface_debug_print("mpu9250: check tap axes %s.\n", enable == MPU9250_BOOL_FALSE ? "ok" : "error");
926
927 /* enable axis x */
928 res = mpu9250_dmp_set_tap_axes(&gs_handle, MPU9250_AXIS_X, MPU9250_BOOL_TRUE);
929 if (res != 0)
930 {
931 mpu9250_interface_debug_print("mpu9250: dmp set tap axes failed.\n");
932 (void)mpu9250_deinit(&gs_handle);
933
934 return 1;
935 }
936 mpu9250_interface_debug_print("mpu9250: enable tap axes x.\n");
937 res = mpu9250_dmp_get_tap_axes(&gs_handle, MPU9250_AXIS_X, &enable);
938 if (res != 0)
939 {
940 mpu9250_interface_debug_print("mpu9250: dmp get tap axes failed.\n");
941 (void)mpu9250_deinit(&gs_handle);
942
943 return 1;
944 }
945 mpu9250_interface_debug_print("mpu9250: check tap axes %s.\n", enable == MPU9250_BOOL_TRUE ? "ok" : "error");
946
947 /* disable axis y */
948 res = mpu9250_dmp_set_tap_axes(&gs_handle, MPU9250_AXIS_Y, MPU9250_BOOL_FALSE);
949 if (res != 0)
950 {
951 mpu9250_interface_debug_print("mpu9250: dmp set tap axes failed.\n");
952 (void)mpu9250_deinit(&gs_handle);
953
954 return 1;
955 }
956 mpu9250_interface_debug_print("mpu9250: disable tap axes y.\n");
957 res = mpu9250_dmp_get_tap_axes(&gs_handle, MPU9250_AXIS_Y, &enable);
958 if (res != 0)
959 {
960 mpu9250_interface_debug_print("mpu9250: dmp get tap axes failed.\n");
961 (void)mpu9250_deinit(&gs_handle);
962
963 return 1;
964 }
965 mpu9250_interface_debug_print("mpu9250: check tap axes %s.\n", enable == MPU9250_BOOL_FALSE ? "ok" : "error");
966
967 /* enable axis y */
968 res = mpu9250_dmp_set_tap_axes(&gs_handle, MPU9250_AXIS_Y, MPU9250_BOOL_TRUE);
969 if (res != 0)
970 {
971 mpu9250_interface_debug_print("mpu9250: dmp set tap axes failed.\n");
972 (void)mpu9250_deinit(&gs_handle);
973
974 return 1;
975 }
976 mpu9250_interface_debug_print("mpu9250: enable tap axes y.\n");
977 res = mpu9250_dmp_get_tap_axes(&gs_handle, MPU9250_AXIS_Y, &enable);
978 if (res != 0)
979 {
980 mpu9250_interface_debug_print("mpu9250: dmp get tap axes failed.\n");
981 (void)mpu9250_deinit(&gs_handle);
982
983 return 1;
984 }
985 mpu9250_interface_debug_print("mpu9250: check tap axes %s.\n", enable == MPU9250_BOOL_TRUE ? "ok" : "error");
986
987 /* disable axis z */
988 res = mpu9250_dmp_set_tap_axes(&gs_handle, MPU9250_AXIS_Z, MPU9250_BOOL_FALSE);
989 if (res != 0)
990 {
991 mpu9250_interface_debug_print("mpu9250: dmp set tap axes failed.\n");
992 (void)mpu9250_deinit(&gs_handle);
993
994 return 1;
995 }
996 mpu9250_interface_debug_print("mpu9250: disable tap axes z.\n");
997 res = mpu9250_dmp_get_tap_axes(&gs_handle, MPU9250_AXIS_Z, &enable);
998 if (res != 0)
999 {
1000 mpu9250_interface_debug_print("mpu9250: dmp get tap axes failed.\n");
1001 (void)mpu9250_deinit(&gs_handle);
1002
1003 return 1;
1004 }
1005 mpu9250_interface_debug_print("mpu9250: check tap axes %s.\n", enable == MPU9250_BOOL_FALSE ? "ok" : "error");
1006
1007 /* enable axis z */
1008 res = mpu9250_dmp_set_tap_axes(&gs_handle, MPU9250_AXIS_Z, MPU9250_BOOL_TRUE);
1009 if (res != 0)
1010 {
1011 mpu9250_interface_debug_print("mpu9250: dmp set tap axes failed.\n");
1012 (void)mpu9250_deinit(&gs_handle);
1013
1014 return 1;
1015 }
1016 mpu9250_interface_debug_print("mpu9250: enable tap axes z.\n");
1017 res = mpu9250_dmp_get_tap_axes(&gs_handle, MPU9250_AXIS_Z, &enable);
1018 if (res != 0)
1019 {
1020 mpu9250_interface_debug_print("mpu9250: dmp get tap axes failed.\n");
1021 (void)mpu9250_deinit(&gs_handle);
1022
1023 return 1;
1024 }
1025 mpu9250_interface_debug_print("mpu9250: check tap axes %s.\n", enable == MPU9250_BOOL_TRUE ? "ok" : "error");
1026
1027 /* mpu9250_dmp_set_tap_thresh/mpu9250_dmp_get_tap_thresh test */
1028 mpu9250_interface_debug_print("mpu9250: mpu9250_dmp_set_tap_thresh/mpu9250_dmp_get_tap_thresh test.\n");
1029
1030 /* set tap thresh x */
1031 m = 250;
1032 res = mpu9250_dmp_set_tap_thresh(&gs_handle, MPU9250_AXIS_X, m);
1033 if (res != 0)
1034 {
1035 mpu9250_interface_debug_print("mpu9250: dmp set tap thresh failed.\n");
1036 (void)mpu9250_deinit(&gs_handle);
1037
1038 return 1;
1039 }
1040 mpu9250_interface_debug_print("mpu9250: dmp set tap thresh x %d mg/ms.\n", m);
1041 res = mpu9250_dmp_get_tap_thresh(&gs_handle, MPU9250_AXIS_X, &m_check);
1042 if (res != 0)
1043 {
1044 mpu9250_interface_debug_print("mpu9250: dmp get tap thresh failed.\n");
1045 (void)mpu9250_deinit(&gs_handle);
1046
1047 return 1;
1048 }
1049 mpu9250_interface_debug_print("mpu9250: check tap thresh %s.\n", m_check == m ? "ok" : "error");
1050
1051 /* set tap thresh y */
1052 m = 250;
1053 res = mpu9250_dmp_set_tap_thresh(&gs_handle, MPU9250_AXIS_Y, m);
1054 if (res != 0)
1055 {
1056 mpu9250_interface_debug_print("mpu9250: dmp set tap thresh failed.\n");
1057 (void)mpu9250_deinit(&gs_handle);
1058
1059 return 1;
1060 }
1061 mpu9250_interface_debug_print("mpu9250: dmp set tap thresh y %d mg/ms.\n", m);
1062 res = mpu9250_dmp_get_tap_thresh(&gs_handle, MPU9250_AXIS_Y, &m_check);
1063 if (res != 0)
1064 {
1065 mpu9250_interface_debug_print("mpu9250: dmp get tap thresh failed.\n");
1066 (void)mpu9250_deinit(&gs_handle);
1067
1068 return 1;
1069 }
1070 mpu9250_interface_debug_print("mpu9250: check tap thresh %s.\n", m_check == m ? "ok" : "error");
1071
1072 /* set tap thresh z */
1073 m = 250;
1074 res = mpu9250_dmp_set_tap_thresh(&gs_handle, MPU9250_AXIS_Z, m);
1075 if (res != 0)
1076 {
1077 mpu9250_interface_debug_print("mpu9250: dmp set tap thresh failed.\n");
1078 (void)mpu9250_deinit(&gs_handle);
1079
1080 return 1;
1081 }
1082 mpu9250_interface_debug_print("mpu9250: dmp set tap thresh z %d mg/ms.\n", m);
1083 res = mpu9250_dmp_get_tap_thresh(&gs_handle, MPU9250_AXIS_Z, &m_check);
1084 if (res != 0)
1085 {
1086 mpu9250_interface_debug_print("mpu9250: dmp get tap thresh failed.\n");
1087 (void)mpu9250_deinit(&gs_handle);
1088
1089 return 1;
1090 }
1091 mpu9250_interface_debug_print("mpu9250: check tap thresh %s.\n", m_check == m ? "ok" : "error");
1092
1093 /* mpu9250_dmp_set_fifo_rate/mpu9250_dmp_get_fifo_rate test */
1094 mpu9250_interface_debug_print("mpu9250: mpu9250_dmp_set_fifo_rate/mpu9250_dmp_get_fifo_rate test.\n");
1095
1096 m = 200;
1097 res = mpu9250_dmp_set_fifo_rate(&gs_handle, m);
1098 if (res != 0)
1099 {
1100 mpu9250_interface_debug_print("mpu9250: dmp set fifo rate failed.\n");
1101 (void)mpu9250_deinit(&gs_handle);
1102
1103 return 1;
1104 }
1105 mpu9250_interface_debug_print("mpu9250: dmp set fifo rate %dHz.\n", m);
1106 res = mpu9250_dmp_get_fifo_rate(&gs_handle, &m_check);
1107 if (res != 0)
1108 {
1109 mpu9250_interface_debug_print("mpu9250: dmp get fifo rate failed.\n");
1110 (void)mpu9250_deinit(&gs_handle);
1111
1112 return 1;
1113 }
1114 mpu9250_interface_debug_print("mpu9250: check fifo rate %s.\n", m_check == m ? "ok" : "error");
1115
1116 /* mpu9250_dmp_set_gyro_calibrate test */
1117 mpu9250_interface_debug_print("mpu9250: mpu9250_dmp_set_gyro_calibrate test.\n");
1118
1119 /* enable gyro calibrate */
1120 res = mpu9250_dmp_set_gyro_calibrate(&gs_handle, MPU9250_BOOL_TRUE);
1121 if (res != 0)
1122 {
1123 mpu9250_interface_debug_print("mpu9250: dmp set gyro calibrate failed.\n");
1124 (void)mpu9250_deinit(&gs_handle);
1125
1126 return 1;
1127 }
1128 mpu9250_interface_debug_print("mpu9250: enable gyro calibrate.\n");
1129
1130 /* disable gyro calibrate */
1131 res = mpu9250_dmp_set_gyro_calibrate(&gs_handle, MPU9250_BOOL_FALSE);
1132 if (res != 0)
1133 {
1134 mpu9250_interface_debug_print("mpu9250: dmp set gyro calibrate failed.\n");
1135 (void)mpu9250_deinit(&gs_handle);
1136
1137 return 1;
1138 }
1139 mpu9250_interface_debug_print("mpu9250: disable gyro calibrate.\n");
1140
1141 /* mpu9250_dmp_set_3x_quaternion test */
1142 mpu9250_interface_debug_print("mpu9250: mpu9250_dmp_set_3x_quaternion test.\n");
1143
1144 /* enable 3x quaternion */
1145 res = mpu9250_dmp_set_3x_quaternion(&gs_handle, MPU9250_BOOL_TRUE);
1146 if (res != 0)
1147 {
1148 mpu9250_interface_debug_print("mpu9250: dmp set 3x quaternion failed.\n");
1149 (void)mpu9250_deinit(&gs_handle);
1150
1151 return 1;
1152 }
1153 mpu9250_interface_debug_print("mpu9250: enable 3x quaternion.\n");
1154
1155 /* disable 3x quaternion */
1156 res = mpu9250_dmp_set_3x_quaternion(&gs_handle, MPU9250_BOOL_FALSE);
1157 if (res != 0)
1158 {
1159 mpu9250_interface_debug_print("mpu9250: dmp set 3x quaternion failed.\n");
1160 (void)mpu9250_deinit(&gs_handle);
1161
1162 return 1;
1163 }
1164 mpu9250_interface_debug_print("mpu9250: disable 3x quaternion.\n");
1165
1166 /* mpu9250_dmp_set_6x_quaternion test */
1167 mpu9250_interface_debug_print("mpu9250: mpu9250_dmp_set_6x_quaternion test.\n");
1168
1169 /* enable 6x quaternion */
1170 res = mpu9250_dmp_set_6x_quaternion(&gs_handle, MPU9250_BOOL_TRUE);
1171 if (res != 0)
1172 {
1173 mpu9250_interface_debug_print("mpu9250: dmp set 6x quaternion failed.\n");
1174 (void)mpu9250_deinit(&gs_handle);
1175
1176 return 1;
1177 }
1178 mpu9250_interface_debug_print("mpu9250: enable 6x quaternion.\n");
1179
1180 /* disable 6x quaternion */
1181 res = mpu9250_dmp_set_6x_quaternion(&gs_handle, MPU9250_BOOL_FALSE);
1182 if (res != 0)
1183 {
1184 mpu9250_interface_debug_print("mpu9250: dmp set 6x quaternion failed.\n");
1185 (void)mpu9250_deinit(&gs_handle);
1186
1187 return 1;
1188 }
1189 mpu9250_interface_debug_print("mpu9250: disable 6x quaternion.\n");
1190
1191 /* mpu9250_dmp_set_interrupt_mode test */
1192 mpu9250_interface_debug_print("mpu9250: mpu9250_dmp_set_interrupt_mode test.\n");
1193
1194 /* gesture mode */
1195 res = mpu9250_dmp_set_interrupt_mode(&gs_handle, MPU9250_DMP_INTERRUPT_MODE_GESTURE);
1196 if (res != 0)
1197 {
1198 mpu9250_interface_debug_print("mpu9250: dmp set interrupt mode failed.\n");
1199 (void)mpu9250_deinit(&gs_handle);
1200
1201 return 1;
1202 }
1203 mpu9250_interface_debug_print("mpu9250: dmp set gesture interrupt mode.\n");
1204
1205 /* continuous mode */
1206 res = mpu9250_dmp_set_interrupt_mode(&gs_handle, MPU9250_DMP_INTERRUPT_MODE_CONTINUOUS);
1207 if (res != 0)
1208 {
1209 mpu9250_interface_debug_print("mpu9250: dmp set interrupt mode failed.\n");
1210 (void)mpu9250_deinit(&gs_handle);
1211
1212 return 1;
1213 }
1214 mpu9250_interface_debug_print("mpu9250: dmp set gesture continuous mode.\n");
1215
1216 /* mpu9250_dmp_set_orientation test */
1217 mpu9250_interface_debug_print("mpu9250: mpu9250_dmp_set_orientation test.\n");
1218
1219 /* set the dmp orientation */
1220 res = mpu9250_dmp_set_orientation(&gs_handle, gyro_orientation);
1221 if (res != 0)
1222 {
1223 mpu9250_interface_debug_print("mpu9250: dmp set orientation failed.\n");
1224 (void)mpu9250_deinit(&gs_handle);
1225
1226 return 1;
1227 }
1228 mpu9250_interface_debug_print("mpu9250: set the dmp orientation.\n");
1229
1230 /* mpu9250_dmp_set_feature test */
1231 mpu9250_interface_debug_print("mpu9250: mpu9250_dmp_set_feature test.\n");
1232
1233 /* enable feature */
1234 res = mpu9250_dmp_set_feature(&gs_handle, MPU9250_DMP_FEATURE_6X_QUAT | MPU9250_DMP_FEATURE_TAP | MPU9250_DMP_FEATURE_PEDOMETER |
1235 MPU9250_DMP_FEATURE_ORIENT | MPU9250_DMP_FEATURE_SEND_RAW_ACCEL |
1236 MPU9250_DMP_FEATURE_SEND_CAL_GYRO | MPU9250_DMP_FEATURE_GYRO_CAL);
1237 if (res != 0)
1238 {
1239 mpu9250_interface_debug_print("mpu9250: dmp set feature failed.\n");
1240 (void)mpu9250_deinit(&gs_handle);
1241
1242 return 1;
1243 }
1244 mpu9250_interface_debug_print("mpu9250: enable feature 6x quat.\n");
1245 mpu9250_interface_debug_print("mpu9250: enable feature tap.\n");
1246 mpu9250_interface_debug_print("mpu9250: enable feature pedometer.\n");
1247 mpu9250_interface_debug_print("mpu9250: enable feature orient.\n");
1248 mpu9250_interface_debug_print("mpu9250: enable feature send raw accel.\n");
1249 mpu9250_interface_debug_print("mpu9250: enable feature send cal gyro.\n");
1250 mpu9250_interface_debug_print("mpu9250: enable feature gyro cal.\n");
1251
1252 /* dmp set tap callback */
1253 res = mpu9250_dmp_set_tap_callback(&gs_handle, mpu9250_interface_dmp_tap_callback);
1254 if (res != 0)
1255 {
1256 mpu9250_interface_debug_print("mpu9250: dmp set tap callback failed.\n");
1257 (void)mpu9250_deinit(&gs_handle);
1258
1259 return 1;
1260 }
1261
1262 /* dmp set orient callback */
1263 res = mpu9250_dmp_set_orient_callback(&gs_handle, mpu9250_interface_dmp_orient_callback);
1264 if (res != 0)
1265 {
1266 mpu9250_interface_debug_print("mpu9250: dmp set orient callback failed.\n");
1267 (void)mpu9250_deinit(&gs_handle);
1268
1269 return 1;
1270 }
1271
1272 /* dmp gyro accel raw offset convert */
1273 res = mpu9250_dmp_gyro_accel_raw_offset_convert(&gs_handle, gyro_offset_raw, accel_offset_raw,
1274 gyro_offset, accel_offset);
1275 if (res != 0)
1276 {
1277 mpu9250_interface_debug_print("mpu9250: dmp gyro accel raw offset convert failed.\n");
1278 (void)mpu9250_deinit(&gs_handle);
1279
1280 return 1;
1281 }
1282
1283 /* dmp set accel bias */
1284 res = mpu9250_dmp_set_accel_bias(&gs_handle, accel_offset);
1285 if (res != 0)
1286 {
1287 mpu9250_interface_debug_print("mpu9250: dmp set accel bias failed.\n");
1288 (void)mpu9250_deinit(&gs_handle);
1289
1290 return 1;
1291 }
1292
1293 /* dmp set gyro bias */
1294 res = mpu9250_dmp_set_gyro_bias(&gs_handle, gyro_offset);
1295 if (res != 0)
1296 {
1297 mpu9250_interface_debug_print("mpu9250: dmp set gyro bias failed.\n");
1298 (void)mpu9250_deinit(&gs_handle);
1299
1300 return 1;
1301 }
1302
1303 /* enable the dmp */
1304 res = mpu9250_dmp_set_enable(&gs_handle, MPU9250_BOOL_TRUE);
1305 if (res != 0)
1306 {
1307 mpu9250_interface_debug_print("mpu9250: dmp set enable failed.\n");
1308 (void)mpu9250_deinit(&gs_handle);
1309
1310 return 1;
1311 }
1312
1313 /* force reset the fifo */
1314 res = mpu9250_force_fifo_reset(&gs_handle);
1315 if (res != 0)
1316 {
1317 mpu9250_interface_debug_print("mpu9250: force fifo reset failed.\n");
1318 (void)mpu9250_deinit(&gs_handle);
1319
1320 return 1;
1321 }
1322
1323 /* delay 50 ms */
1324 mpu9250_interface_delay_ms(50);
1325
1326 for (i = 0; i < times; i++)
1327 {
1328 uint16_t l;
1329
1330 /* read the data */
1331 l = 128;
1332 res = mpu9250_dmp_read(&gs_handle,
1333 gs_accel_raw, gs_accel_g,
1334 gs_gyro_raw, gs_gyro_dps,
1335 gs_quat,
1336 gs_pitch, gs_roll, gs_yaw,
1337 &l
1338 );
1339 if (res == 0)
1340 {
1341 /* output data */
1342 mpu9250_interface_debug_print("mpu9250: fifo %d.\n", l);
1343 mpu9250_interface_debug_print("mpu9250: pitch[0] is %0.2fdeg.\n", gs_pitch[0]);
1344 mpu9250_interface_debug_print("mpu9250: roll[0] is %0.2fdeg.\n", gs_roll[0]);
1345 mpu9250_interface_debug_print("mpu9250: yaw[0] is %0.2fdeg.\n", gs_yaw[0]);
1346 mpu9250_interface_debug_print("mpu9250: acc x[0] is %0.2fg.\n", gs_accel_g[0][0]);
1347 mpu9250_interface_debug_print("mpu9250: acc y[0] is %0.2fg.\n", gs_accel_g[0][1]);
1348 mpu9250_interface_debug_print("mpu9250: acc z[0] is %0.2fg.\n", gs_accel_g[0][2]);
1349 mpu9250_interface_debug_print("mpu9250: gyro x[0] is %0.2fdps.\n", gs_gyro_dps[0][0]);
1350 mpu9250_interface_debug_print("mpu9250: gyro y[0] is %0.2fdps.\n", gs_gyro_dps[0][1]);
1351 mpu9250_interface_debug_print("mpu9250: gyro z[0] is %0.2fdps.\n", gs_gyro_dps[0][2]);
1352 }
1353
1354 /* delay 50 ms */
1355 mpu9250_interface_delay_ms(50);
1356 }
1357
1358 /* finish dmp read test */
1359 mpu9250_interface_debug_print("mpu9250: finish dmp read test.\n");
1360 (void)mpu9250_deinit(&gs_handle);
1361
1362 return 0;
1363 }
driver_mpu9250_dmp_read_test.h
driver mpu9250 dmp read 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_bool_t
mpu9250_bool_t
mpu9250 bool enumeration definition
Definition: driver_mpu9250.h:81
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_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_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_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_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_get_tap_time_multi
uint8_t mpu9250_dmp_get_tap_time_multi(mpu9250_handle_t *handle, uint16_t *ms)
dmp get max time between taps to register as a multi tap
Definition: driver_mpu9250.c:1681
mpu9250_dmp_set_6x_quaternion
uint8_t mpu9250_dmp_set_6x_quaternion(mpu9250_handle_t *handle, mpu9250_bool_t enable)
dmp enable or disable generate 6 axis quaternions from dmp
Definition: driver_mpu9250.c:2053
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_3x_quaternion
uint8_t mpu9250_dmp_set_3x_quaternion(mpu9250_handle_t *handle, mpu9250_bool_t enable)
dmp enable or disable generate 3 axis quaternions from dmp
Definition: driver_mpu9250.c:1976
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_get_tap_axes
uint8_t mpu9250_dmp_get_tap_axes(mpu9250_handle_t *handle, mpu9250_axis_t axis, mpu9250_bool_t *enable)
dmp get the tap axes status
Definition: driver_mpu9250.c:3112
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_shake_reject_time
uint8_t mpu9250_dmp_get_shake_reject_time(mpu9250_handle_t *handle, uint16_t *ms)
dmp get the shake reject time
Definition: driver_mpu9250.c:1491
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_get_tap_thresh
uint8_t mpu9250_dmp_get_tap_thresh(mpu9250_handle_t *handle, mpu9250_axis_t axis, uint16_t *mg_ms)
dmp get the tap thresh
Definition: driver_mpu9250.c:3313
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_get_min_tap_count
uint8_t mpu9250_dmp_get_min_tap_count(mpu9250_handle_t *handle, uint8_t *cnt)
dmp get the min tap count
Definition: driver_mpu9250.c:1869
mpu9250_dmp_get_tap_time
uint8_t mpu9250_dmp_get_tap_time(mpu9250_handle_t *handle, uint16_t *ms)
dmp get the tap time
Definition: driver_mpu9250.c:1773
mpu9250_dmp_set_gyro_calibrate
uint8_t mpu9250_dmp_set_gyro_calibrate(mpu9250_handle_t *handle, mpu9250_bool_t enable)
dmp enable or disable gyro calibrate
Definition: driver_mpu9250.c:1913
mpu9250_dmp_get_shake_reject_timeout
uint8_t mpu9250_dmp_get_shake_reject_timeout(mpu9250_handle_t *handle, uint16_t *ms)
dmp get the shake reject timeout
Definition: driver_mpu9250.c:1399
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_get_shake_reject_thresh
uint8_t mpu9250_dmp_get_shake_reject_thresh(mpu9250_handle_t *handle, uint16_t *dps)
dmp get the shake reject thresh
Definition: driver_mpu9250.c:1586
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_INTERRUPT_MODE_CONTINUOUS
@ MPU9250_DMP_INTERRUPT_MODE_CONTINUOUS
Definition: driver_mpu9250.h:445
MPU9250_DMP_INTERRUPT_MODE_GESTURE
@ MPU9250_DMP_INTERRUPT_MODE_GESTURE
Definition: driver_mpu9250.h:446
mpu9250_interface_dmp_orient_callback
void mpu9250_interface_dmp_orient_callback(uint8_t orientation)
interface dmp orient callback
Definition: driver_mpu9250_interface_template.c:277
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_dmp_tap_callback
void mpu9250_interface_dmp_tap_callback(uint8_t count, uint8_t direction)
interface dmp tap callback
Definition: driver_mpu9250_interface_template.c:223
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_read_test_irq_handler
uint8_t mpu9250_dmp_read_test_irq_handler(void)
dmp read test irq
Definition: driver_mpu9250_dmp_read_test.c:57
mpu9250_dmp_read_test
uint8_t mpu9250_dmp_read_test(mpu9250_interface_t interface, mpu9250_address_t addr, uint32_t times)
dmp read test
Definition: driver_mpu9250_dmp_read_test.c:79
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