![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Bluepill version of mpu9250-dmp library of sparkfun
Dependencies: MotionDriver_6_1 SparkFunMPU9250-DMP mbed-STM32F103C8T6 mbed
Fork of MPU9250-dmp by
Diff: main.cpp
- Revision:
- 9:ef46e12b4560
- Parent:
- 8:b9206956f396
- Child:
- 10:e7fffe32c12c
--- a/main.cpp Mon Aug 14 09:03:52 2017 +0000 +++ b/main.cpp Mon Aug 14 14:09:50 2017 +0000 @@ -1,7 +1,9 @@ #include "SparkFunMPU9250-DMP.h" #include "mdcompat.h" +#include "stm32f103c8t6.h" +//In order to compile, you should define MPU9250 in build macros -Serial pc(USBTX,USBRX); +Serial pc(SERIAL_TX,SERIAL_RX); DigitalOut led(LED1); MPU9250_DMP imu; unsigned char whoami[1]={0}; @@ -32,7 +34,7 @@ if(imu.dmpBegin(DMP_FEATURE_6X_LP_QUAT | // Enable 6-axis quat DMP_FEATURE_GYRO_CAL, // Use gyro calibration - 150)==INV_ERROR){ // Set DMP FIFO rate to 150 Hz + 10)==INV_ERROR){ // Set DMP FIFO rate to 150 Hz pc.printf("imu.dmpBegin have failed\n");//dmpLoad function under it fails which is caused by memcmp(firmware+ii, cur, this_write) (it is located at row 2871 of inv_mpu.c) } else{ @@ -59,31 +61,23 @@ mbed_i2c_read(0x68,(unsigned)regadd,1,registerdata); pc.printf("%d is gotten from serial port, data at that register is %d\n",regadd,registerdata[0]); } - /*if(imu.dmpBegin(DMP_FEATURE_6X_LP_QUAT | // Enable 6-axis quat - DMP_FEATURE_GYRO_CAL, // Use gyro calibration - 20)==INV_ERROR){ // Set DMP FIFO rate to 20 Hz - pc.printf("imu.dmpBegin have failed\n");//dmpLoad function under it fails which is caused by memcmp(firmware+ii, cur, this_write) (it is located at row 2871 of inv_mpu.c) - } + // Check for new data in the FIFO + if (imu.fifoAvailable()){//fifo is not being available + led=0; + wait_ms(1); + led=1; + wait_ms(1); + // Use dmpUpdateFifo to update the ax, gx, mx, etc. values + if ( imu.dmpUpdateFifo() == INV_SUCCESS){ + // computeEulerAngles can be used -- after updating the + // quaternion values -- to estimate roll, pitch, and yaw + imu.computeEulerAngles(); + printIMUData(); + } + } else{ - pc.printf("imu.dmpBegin() suceeded\n"); - }*/ - // Check for new data in the FIFO - if (imu.fifoAvailable()){//fifo is not being available - led=0; - wait_ms(1); - led=1; - wait_ms(1); - // Use dmpUpdateFifo to update the ax, gx, mx, etc. values - if ( imu.dmpUpdateFifo() == INV_SUCCESS){ - // computeEulerAngles can be used -- after updating the - // quaternion values -- to estimate roll, pitch, and yaw - imu.computeEulerAngles(); - printIMUData(); + led=0; } - } - else{ - led=0; - } } return 0; }