Seeed / MPU6050

Dependents:   sgam-lib sgam_mdw_NUCLEOF429ZI_impl

Fork of MPU6050 by Yihui Xiong

Usage

#include "mbed.h"
#include "MPU6050.h"

DigitalOut myled(LED1);
Serial pc(USBTX, USBRX);
I2C    i2c(I2C_SDA, I2C_SCL);
MPU6050 mpu(i2c);
 
int16_t ax, ay, az;
int16_t gx, gy, gz;
 
int main()
{
    pc.printf("MPU6050 test\n\n");
    pc.printf("MPU6050 initialize \n");
 
    mpu.initialize();
    
    pc.printf("MPU6050 testConnection \n");
 
    bool mpu6050TestResult = mpu.testConnection();
    if(mpu6050TestResult) {
        pc.printf("MPU6050 test passed \n");
    } else {
        pc.printf("MPU6050 test failed \n");
    }
   
    while(1) {
        wait(1);
        mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
        //writing current accelerometer and gyro position 
        pc.printf("%d;%d;%d;%d;%d;%d\n",ax,ay,az,gx,gy,gz);
    }
}

Files at this revision

API Documentation at this revision

Comitter:
garfieldsg
Date:
Wed May 08 00:34:55 2013 +0000
Parent:
0:662207e34fba
Child:
2:8c562a8fed36
Commit message:
Bugfix of memory issu

Changed in this revision

I2Cdev.cpp Show annotated file Show diff for this revision Revisions of this file
MPU6050.h Show annotated file Show diff for this revision Revisions of this file
--- a/I2Cdev.cpp	Fri Jan 11 00:54:28 2013 +0000
+++ b/I2Cdev.cpp	Wed May 08 00:34:55 2013 +0000
@@ -137,6 +137,7 @@
     for(int i =0; i < length; i++) {
         data[i] = redData[i];
     }
+    free (redData);
     return length;
 }
 
--- a/MPU6050.h	Fri Jan 11 00:54:28 2013 +0000
+++ b/MPU6050.h	Wed May 08 00:34:55 2013 +0000
@@ -848,7 +848,7 @@
             uint8_t dmpGetGyroSensor(int16_t *data, const uint8_t* packet=0);
             uint8_t dmpGetGyroSensor(VectorInt16 *v, const uint8_t* packet=0);
             uint8_t dmpGetControlData(int32_t *data, const uint8_t* packet=0);
-            uint8_t dmpGetTemperature(int32_t *data, const uint8_t* packet=0);
+            uint8_t dm  pGetTemperature(int32_t *data, const uint8_t* packet=0);
             uint8_t dmpGetGravity(int32_t *data, const uint8_t* packet=0);
             uint8_t dmpGetGravity(int16_t *data, const uint8_t* packet=0);
             uint8_t dmpGetGravity(VectorInt16 *v, const uint8_t* packet=0);