This one compatable with brobot V3. first commit to BroBot

Dependencies:   I2Cdev

Dependents:   BroBot_ESE350_Skeleton

Fork of MPU6050 by Carter Sharer

Revision:
7:d5845b617139
Parent:
6:f38dfe62d74c
Child:
8:4ee054567b6c
diff -r f38dfe62d74c -r d5845b617139 MPU6050.h
--- a/MPU6050.h	Sat Jan 30 17:12:45 2016 +0000
+++ b/MPU6050.h	Sun Jan 31 09:12:19 2016 +0000
@@ -1,39 +1,3 @@
-// I2Cdev library collection - MPU6050 I2C device class
-// Based on InvenSense MPU-6050 register map document rev. 2.0, 5/19/2011 (RM-MPU-6000A-00)
-// 10/3/2011 by Jeff Rowberg <jeff@rowberg.net>
-// Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib
-//
-// Changelog:
-//     ... - ongoing debug release
-
-// NOTE: THIS IS ONLY A PARIAL RELEASE. THIS DEVICE CLASS IS CURRENTLY UNDERGOING ACTIVE
-// DEVELOPMENT AND IS STILL MISSING SOME IMPORTANT FEATURES. PLEASE KEEP THIS IN MIND IF
-// YOU DECIDE TO USE THIS PARTICULAR CODE FOR ANYTHING.
-
-/* ============================================
-I2Cdev device library code is placed under the MIT license
-Copyright (c) 2012 Jeff Rowberg
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-===============================================
-*/
-
 #ifndef _MPU6050_H_
 #define _MPU6050_H_
 
@@ -41,14 +5,16 @@
 
 // supporting link:  http://forum.arduino.cc/index.php?&topic=143444.msg1079517#msg1079517
 // also: http://forum.arduino.cc/index.php?&topic=141571.msg1062899#msg1062899s
-#ifndef __arm__
+
+#ifdef __AVR__
 #include <avr/pgmspace.h>
 #else
 #define PROGMEM /* empty */
-#define pgm_read_byte(x) (*(x))
-#define pgm_read_word(x) (*(x))
-#define pgm_read_float(x) (*(x))
-#define PSTR(STR) STR
+#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
+#define pgm_read_word(addr) (*(const unsigned short *)(addr))
+#define pgm_read_dword(addr) (*(const unsigned long *)(addr))
+#define pgm_read_float(addr) (*(const float *)(addr))
+#define PSTR(str) (str)
 #endif
 
 
@@ -68,6 +34,10 @@
 #define MPU6050_RA_YA_OFFS_L_TC     0x09
 #define MPU6050_RA_ZA_OFFS_H        0x0A //[15:0] ZA_OFFS
 #define MPU6050_RA_ZA_OFFS_L_TC     0x0B
+#define MPU6050_RA_SELF_TEST_X      0x0D //[7:5] XA_TEST[4-2], [4:0] XG_TEST[4-0]
+#define MPU6050_RA_SELF_TEST_Y      0x0E //[7:5] YA_TEST[4-2], [4:0] YG_TEST[4-0]
+#define MPU6050_RA_SELF_TEST_Z      0x0F //[7:5] ZA_TEST[4-2], [4:0] ZG_TEST[4-0]
+#define MPU6050_RA_SELF_TEST_A      0x10 //[5:4] XA_TEST[1-0], [3:2] YA_TEST[1-0], [1:0] ZA_TEST[1-0]
 #define MPU6050_RA_XG_OFFS_USRH     0x13 //[15:0] XG_OFFS_USR
 #define MPU6050_RA_XG_OFFS_USRL     0x14
 #define MPU6050_RA_YG_OFFS_USRH     0x15 //[15:0] YG_OFFS_USR
@@ -167,6 +137,26 @@
 #define MPU6050_RA_FIFO_R_W         0x74
 #define MPU6050_RA_WHO_AM_I         0x75
 
+#define MPU6050_SELF_TEST_XA_1_BIT     0x07
+#define MPU6050_SELF_TEST_XA_1_LENGTH  0x03
+#define MPU6050_SELF_TEST_XA_2_BIT     0x05
+#define MPU6050_SELF_TEST_XA_2_LENGTH  0x02
+#define MPU6050_SELF_TEST_YA_1_BIT     0x07
+#define MPU6050_SELF_TEST_YA_1_LENGTH  0x03
+#define MPU6050_SELF_TEST_YA_2_BIT     0x03
+#define MPU6050_SELF_TEST_YA_2_LENGTH  0x02
+#define MPU6050_SELF_TEST_ZA_1_BIT     0x07
+#define MPU6050_SELF_TEST_ZA_1_LENGTH  0x03
+#define MPU6050_SELF_TEST_ZA_2_BIT     0x01
+#define MPU6050_SELF_TEST_ZA_2_LENGTH  0x02
+
+#define MPU6050_SELF_TEST_XG_1_BIT     0x04
+#define MPU6050_SELF_TEST_XG_1_LENGTH  0x05
+#define MPU6050_SELF_TEST_YG_1_BIT     0x04
+#define MPU6050_SELF_TEST_YG_1_LENGTH  0x05
+#define MPU6050_SELF_TEST_ZG_1_BIT     0x04
+#define MPU6050_SELF_TEST_ZG_1_LENGTH  0x05
+
 #define MPU6050_TC_PWR_MODE_BIT     7
 #define MPU6050_TC_OFFSET_BIT       6
 #define MPU6050_TC_OFFSET_LENGTH    6
@@ -409,8 +399,6 @@
 // note: DMP code memory blocks defined at end of header file
 
 class MPU6050 {
-    private:
-        I2Cdev i2cdev;
     public:
         MPU6050();
         MPU6050(uint8_t address);
@@ -436,6 +424,15 @@
         uint8_t getFullScaleGyroRange();
         void setFullScaleGyroRange(uint8_t range);
 
+        // SELF_TEST registers
+        uint8_t getAccelXSelfTestFactoryTrim();
+        uint8_t getAccelYSelfTestFactoryTrim();
+        uint8_t getAccelZSelfTestFactoryTrim();
+
+        uint8_t getGyroXSelfTestFactoryTrim();
+        uint8_t getGyroYSelfTestFactoryTrim();
+        uint8_t getGyroZSelfTestFactoryTrim();
+
         // ACCEL_CONFIG register
         bool getAccelXSelfTest();
         void setAccelXSelfTest(bool enabled);
@@ -689,9 +686,9 @@
         // WHO_AM_I register
         uint8_t getDeviceID();
         void setDeviceID(uint8_t id);
-        
+
         // ======== UNDOCUMENTED/DMP REGISTERS/METHODS ========
-        
+
         // XG_OFFS_TC register
         uint8_t getOTPBankValid();
         void setOTPBankValid(bool enabled);
@@ -741,13 +738,13 @@
         // ZG_OFFS_USR* register
         int16_t getZGyroOffset();
         void setZGyroOffset(int16_t offset);
-        
+
         // INT_ENABLE register (DMP functions)
         bool getIntPLLReadyEnabled();
         void setIntPLLReadyEnabled(bool enabled);
         bool getIntDMPEnabled();
         void setIntDMPEnabled(bool enabled);
-        
+
         // DMP_INT_STATUS
         bool getDMPInt5Status();
         bool getDMPInt4Status();
@@ -759,18 +756,18 @@
         // INT_STATUS register (DMP functions)
         bool getIntPLLReadyStatus();
         bool getIntDMPStatus();
-        
+
         // USER_CTRL register (DMP functions)
         bool getDMPEnabled();
         void setDMPEnabled(bool enabled);
         void resetDMP();
-        
+
         // BANK_SEL register
         void setMemoryBank(uint8_t bank, bool prefetchEnabled=false, bool userBank=false);
-        
+
         // MEM_START_ADDR register
         void setMemoryStartAddress(uint8_t address);
-        
+
         // MEM_R_W register
         uint8_t readMemoryByte();
         void writeMemoryByte(uint8_t data);
@@ -802,12 +799,12 @@
             uint8_t dmpGetSampleStepSizeMS();
             uint8_t dmpGetSampleFrequency();
             int32_t dmpDecodeTemperature(int8_t tempReg);
-            
+
             // Register callbacks after a packet of FIFO data is processed
             //uint8_t dmpRegisterFIFORateProcess(inv_obj_func func, int16_t priority);
             //uint8_t dmpUnregisterFIFORateProcess(inv_obj_func func);
             uint8_t dmpRunFIFORateProcesses();
-            
+
             // Setup FIFO for various output
             uint8_t dmpSendQuaternion(uint_fast16_t accuracy);
             uint8_t dmpSendGyro(uint_fast16_t elements, uint_fast16_t accuracy);
@@ -867,7 +864,7 @@
             uint8_t dmpGetQuantizedAccel(VectorInt16 *v, const uint8_t* packet=0);
             uint8_t dmpGetExternalSensorData(int32_t *data, uint16_t size, const uint8_t* packet=0);
             uint8_t dmpGetEIS(int32_t *data, const uint8_t* packet=0);
-            
+
             uint8_t dmpGetEuler(float *data, Quaternion *q);
             uint8_t dmpGetYawPitchRoll(float *data, Quaternion *q, VectorFloat *gravity);
 
@@ -903,12 +900,12 @@
             uint8_t dmpGetSampleStepSizeMS();
             uint8_t dmpGetSampleFrequency();
             int32_t dmpDecodeTemperature(int8_t tempReg);
-            
+
             // Register callbacks after a packet of FIFO data is processed
             //uint8_t dmpRegisterFIFORateProcess(inv_obj_func func, int16_t priority);
             //uint8_t dmpUnregisterFIFORateProcess(inv_obj_func func);
             uint8_t dmpRunFIFORateProcesses();
-            
+
             // Setup FIFO for various output
             uint8_t dmpSendQuaternion(uint_fast16_t accuracy);
             uint8_t dmpSendGyro(uint_fast16_t elements, uint_fast16_t accuracy);
@@ -969,7 +966,7 @@
             uint8_t dmpGetQuantizedAccel(VectorInt16 *v, const uint8_t* packet=0);
             uint8_t dmpGetExternalSensorData(int32_t *data, uint16_t size, const uint8_t* packet=0);
             uint8_t dmpGetEIS(int32_t *data, const uint8_t* packet=0);
-            
+
             uint8_t dmpGetEuler(float *data, Quaternion *q);
             uint8_t dmpGetYawPitchRoll(float *data, Quaternion *q, VectorFloat *gravity);