MPU9250

Dependents:   FreeIMU

Fork of MPU6050 by Yifei Teng

Revision:
13:a74f2d622b54
Parent:
12:e32a6beb0a41
Child:
14:057ce8fa00ab
--- a/MPU6050.h	Tue Mar 27 22:31:21 2018 +0000
+++ b/MPU6050.h	Wed Mar 28 20:25:13 2018 +0000
@@ -43,9 +43,20 @@
 #ifndef _MPU6050_H_
 #define _MPU6050_H_
 
+#include "mbed.h"
 #include "I2Cdev.h"
 #include "helper_3dmath.h"
 
+
+// select MPU9250 or MPU6050
+#define MPU9250
+//#define MPU6050
+
+
+#ifdef MPU9250
+#include "AK8963.h"
+#endif
+
 #define MPU6050_ADDRESS_AD0_LOW     0x68 // address pin low (GND), default for InvenSense evaluation board
 #define MPU6050_ADDRESS_AD0_HIGH    0x69 // address pin high (VCC)
 #define MPU6050_DEFAULT_ADDRESS     MPU6050_ADDRESS_AD0_LOW
@@ -415,10 +426,17 @@
         
         void mpu_sample_func();
         volatile int16_t ax_cache, ay_cache, az_cache, gx_cache, gy_cache, gz_cache;
+#ifdef MPU9250
+        volatile int16_t hx_cache, hy_cache, hz_cache;
+#endif
         
         Ticker mpu_sampling;
         char mpu_cmd;
+#ifdef MPU9250
+        uint8_t mpu_buffer[21];
+#else
         uint8_t mpu_buffer[14];
+#endif
         
         void start_sampling();
 
@@ -798,11 +816,12 @@
         void setDMPConfig2(uint8_t config);
         
         void initialize();
+
+#ifdef MPU9250
         void initialize9250();
         void initialize9250MasterMode();
         void get9250Motion9Counts(int16_t* ax, int16_t* ay, int16_t* az, int16_t* gx, int16_t* gy, int16_t* gz, int16_t* hx, int16_t* hy, int16_t* hz);
         void get9250Motion9(float* ax, float* ay, float* az, float* gx, float* gy, float* gz, float* hx, float* hy, float* hz);
-        void get9250Motion10Counts(int16_t* ax, int16_t* ay, int16_t* az, int16_t* gx, int16_t* gy, int16_t* gz, int16_t* hx, int16_t* hy, int16_t* hz, int16_t* t);
         void get9250AccelCounts(int16_t* ax, int16_t* ay, int16_t* az);
         void get9250GyroCounts(int16_t* gx, int16_t* gy, int16_t* gz);
         void get9250MagCounts(int16_t* hx, int16_t* hy, int16_t* hz);
@@ -813,6 +832,7 @@
         bool writeAKRegister(uint8_t subAddress, uint8_t data);
         bool writeRegister(uint8_t subAddress, uint8_t data);
         void readRegister(uint8_t subAddress, uint8_t count, uint8_t* dest);
+#endif
 
         // special methods for MotionApps 2.0 implementation
         #ifdef MPU6050_INCLUDE_DMP_MOTIONAPPS20
@@ -1019,7 +1039,11 @@
 
     private:
         uint8_t devAddr;
+#ifdef MPU9250
+        uint8_t buffer[21];
+#else
         uint8_t buffer[14];
+#endif
         uint8_t magDevAddr;
 };