MPU9250 library using dmp, it uses sparkfun arduino library and invensense Motion driver 6.1.

Dependencies:   MotionDriver_6_1 SparkFunMPU9250-DMP mbed

Files at this revision

API Documentation at this revision

Comitter:
mbedoguz
Date:
Mon Aug 14 14:18:23 2017 +0000
Branch:
Bluepill
Parent:
8:b9206956f396
Commit message:
Informative comments are added.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r b9206956f396 -r 9045a44aff24 main.cpp
--- a/main.cpp	Mon Aug 14 09:03:52 2017 +0000
+++ b/main.cpp	Mon Aug 14 14:18:23 2017 +0000
@@ -1,25 +1,34 @@
 #include "SparkFunMPU9250-DMP.h"
 #include "mdcompat.h"
-
+//In order to compile, you should define MPU9250 in build macros
+//definitions
+#define DEBUG 0
+//classes
 Serial pc(USBTX,USBRX);
 DigitalOut led(LED1);
 MPU9250_DMP imu;
-unsigned char whoami[1]={0};
-unsigned char fifo_count[2]={32,32};
-unsigned char temp[1]={32};
-unsigned char outbuff[4];
-unsigned char inbuff[4];
+
+//variables
+#if DEBUG
+    unsigned char whoami[1]={0};
+    unsigned char outbuff[4];
+    unsigned char inbuff[4];
+#endif
+
 unsigned char regadd;
 char registeradress[5];
 unsigned char registerdata[]={33};
+
+//Prorotypes
 void printIMUData(void);
+
 int main() 
 {
   pc.baud(115200);
   pc.printf("Hello World\n");
   imu_init();
   stamper_init();
-#if 1//Regular program
+#if ~DEBUG//Regular program
   // Call imu.begin() to verify communication and initialize
   if (imu.begin() != INV_SUCCESS){
     while (1){
@@ -40,7 +49,7 @@
     }
     pc.printf("$GETEU,*\n");
 #endif
-#if 0//this scope is only for debugging purposes of mbed_i2c_read and write functions
+#if DEBUG //this scope is only for debugging purposes of mbed_i2c_read and write functions
     mbed_i2c_read(0x68,0x75,1,whoami);
     pc.printf("whoami=%d\n",whoami[0]);
     mbed_i2c_read(0x68,0x23,2,inbuff);
@@ -59,14 +68,7 @@
         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)
-              }
-    else{
-        pc.printf("imu.dmpBegin() suceeded\n");
-    }*/
+
   // Check for new data in the FIFO
   if (imu.fifoAvailable()){//fifo is not being available
     led=0;
@@ -82,7 +84,7 @@
     }
   }
   else{
-          led=0;
+    led=0;
   }
 }
   return 0;