Library to talk with MPU6050 IMUs

Fork of MPU6050 by Mark Vandermeulen

Revision:
4:ffdb79b00e32
Parent:
3:16cb051b0702
--- a/MPU6050.cpp	Sun Dec 01 06:20:11 2013 +0000
+++ b/MPU6050.cpp	Fri Apr 15 11:30:36 2016 +0000
@@ -37,17 +37,17 @@
 
 void MPU6050::setSleepMode(bool state) {
     char temp;
-    temp = this->read(MPU6050_PWR_MGMT_1_REG);
+    temp = this->read(MPU6050_PWR_MGMT_1);
     if (state == true)
         temp |= 1<<MPU6050_SLP_BIT;
     if (state == false)
         temp &= ~(1<<MPU6050_SLP_BIT);
-    this->write(MPU6050_PWR_MGMT_1_REG, temp);
+    this->write(MPU6050_PWR_MGMT_1, temp);
 }
 
 char MPU6050::testConnection( void ) {
     char temp;
-    temp = this->read(MPU6050_WHO_AM_I_REG);
+    temp = this->read(MPU6050_WHO_AM_I);
     //return (temp == (MPU6050_ADDRESS & 0xFE));
     return temp;
 }
@@ -55,10 +55,10 @@
 void MPU6050::setBW(char BW) {
     char temp;
     BW=BW & 0x07;
-    temp = this->read(MPU6050_CONFIG_REG);
+    temp = this->read(MPU6050_CONFIG);
     temp &= 0xF8;
     temp = temp + BW;
-    this->write(MPU6050_CONFIG_REG, temp);
+    this->write(MPU6050_CONFIG, temp);
 }
 
 void MPU6050::setI2CBypass(bool state) {
@@ -80,16 +80,16 @@
     range = range & 0x03;
     currentAcceleroRange = range;
     
-    temp = this->read(MPU6050_ACCELERO_CONFIG_REG);
+    temp = this->read(MPU6050_ACCEL_CONFIG);
     temp &= ~(3<<3);
     temp = temp + (range<<3);
-    this->write(MPU6050_ACCELERO_CONFIG_REG, temp);
+    this->write(MPU6050_ACCEL_CONFIG, temp);
 }
 
 int MPU6050::getAcceleroRawX( void ) {
     short retval;
     char data[2];
-    this->read(MPU6050_ACCEL_XOUT_H_REG, data, 2);
+    this->read(MPU6050_ACCEL_XOUT_H, data, 2);
     retval = (data[0]<<8) + data[1];
     return (int)retval;
 }
@@ -97,7 +97,7 @@
 int MPU6050::getAcceleroRawY( void ) {
     short retval;
     char data[2];
-    this->read(MPU6050_ACCEL_YOUT_H_REG, data, 2);
+    this->read(MPU6050_ACCEL_YOUT_H, data, 2);
     retval = (data[0]<<8) + data[1];
     return (int)retval;
 }
@@ -105,14 +105,14 @@
 int MPU6050::getAcceleroRawZ( void ) {
     short retval;
     char data[2];
-    this->read(MPU6050_ACCEL_ZOUT_H_REG, data, 2);
+    this->read(MPU6050_ACCEL_ZOUT_H, data, 2);
     retval = (data[0]<<8) + data[1];
     return (int)retval;
 }
 
 void MPU6050::getAcceleroRaw( int *data ) {
     char temp[6];
-    this->read(MPU6050_ACCEL_XOUT_H_REG, temp, 6);
+    this->read(MPU6050_ACCEL_XOUT_H, temp, 6);
     data[0] = (int)(short)((temp[0]<<8) + temp[1]);
     data[1] = (int)(short)((temp[2]<<8) + temp[3]);
     data[2] = (int)(short)((temp[4]<<8) + temp[5]);
@@ -156,16 +156,16 @@
     char temp;
     currentGyroRange = range;
     range = range & 0x03;
-    temp = this->read(MPU6050_GYRO_CONFIG_REG);
+    temp = this->read(MPU6050_GYRO_CONFIG);
     temp &= ~(3<<3);
     temp = temp + range<<3;
-    this->write(MPU6050_GYRO_CONFIG_REG, temp);
+    this->write(MPU6050_GYRO_CONFIG, temp);
 }
 
 int MPU6050::getGyroRawX( void ) {
     short retval;
     char data[2];
-    this->read(MPU6050_GYRO_XOUT_H_REG, data, 2);
+    this->read(MPU6050_GYRO_XOUT_H, data, 2);
     retval = (data[0]<<8) + data[1];
     return (int)retval;
 }
@@ -173,7 +173,7 @@
 int MPU6050::getGyroRawY( void ) {
     short retval;
     char data[2];
-    this->read(MPU6050_GYRO_YOUT_H_REG, data, 2);
+    this->read(MPU6050_GYRO_YOUT_H, data, 2);
     retval = (data[0]<<8) + data[1];
     return (int)retval;
 }
@@ -181,14 +181,14 @@
 int MPU6050::getGyroRawZ( void ) {
     short retval;
     char data[2];
-    this->read(MPU6050_GYRO_ZOUT_H_REG, data, 2);
+    this->read(MPU6050_GYRO_ZOUT_H, data, 2);
     retval = (data[0]<<8) + data[1];
     return (int)retval;
 }
 
 void MPU6050::getGyroRaw( int *data ) {
     char temp[6];
-    this->read(MPU6050_GYRO_XOUT_H_REG, temp, 6);
+    this->read(MPU6050_GYRO_XOUT_H, temp, 6);
     data[0] = (int)(short)((temp[0]<<8) + temp[1]);
     data[1] = (int)(short)((temp[2]<<8) + temp[3]);
     data[2] = (int)(short)((temp[4]<<8) + temp[5]);
@@ -224,7 +224,7 @@
 int MPU6050::getTempRaw( void ) {
     short retval;
     char data[2];
-    this->read(MPU6050_TEMP_H_REG, data, 2);
+    this->read(MPU6050_TEMP_OUT_H, data, 2);
     retval = (data[0]<<8) + data[1];
     return (int)retval;
 }