read acceleration and angler ratio from mpu6050 and estimate pitch and roll angle

Dependencies:   mbed

Revision:
3:40559ebef0f1
diff -r 4a6b46653abf -r 40559ebef0f1 MPU6050.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MPU6050.h	Wed May 13 04:02:27 2015 +0000
@@ -0,0 +1,47 @@
+#pragma once
+
+const static int mpu_addr = 0xd0;
+
+typedef union {
+    uint8_t reg[14]; 
+    struct {
+        uint8_t acc_x_L;
+        uint8_t acc_x_H;
+        uint8_t acc_y_L;
+        uint8_t acc_y_H;
+        uint8_t acc_z_L;
+        uint8_t acc_z_H;
+        
+        uint8_t T_L;
+        uint8_t T_H;
+        
+        uint8_t gyro_x_L;
+        uint8_t gyro_x_H;
+        uint8_t gyro_y_L;
+        uint8_t gyro_y_H;
+        uint8_t gyro_z_L;
+        uint8_t gyro_z_H;
+    } byte;
+    
+    struct {
+        int16_t acc[3];
+        
+        int16_t T;
+        
+        int16_t gyro[3];
+    } value;
+} MPU_DATA;
+
+class MPU6050 {
+public:
+    MPU6050(I2C* i2c);
+    ~MPU6050();
+    
+    int init();
+    int read();
+    
+    MPU_DATA data;
+    
+private:
+    I2C* i2c;
+};
\ No newline at end of file