Rearranged original code port/fork to: * Make library compatible with TiltyQuad IMU; * Prevent multiple definition, and added inclusion guard; * Cleaner access to library functions and file structure; and * "Broke out" code to control Sampling Rate and FIFO buffer update rate. By Trung Tin Ian HUA 2014. Credit to Jeff Rowberg for his original code, the best DMP implementation thus far; and szymon gaertig for porting the arduino library to mbed.
Fork of MPU6050 by
MPU6050.h
00001 //ported from arduino library: https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050 00002 //written by szymon gaertig (email: szymon@gaertig.com.pl) 00003 // 00004 //Changelog: 00005 //2013-01-08 - first beta release 00006 00007 // I2Cdev library collection - MPU6050 I2C device class 00008 // Based on InvenSense MPU-6050 register map document rev. 2.0, 5/19/2011 (RM-MPU-6000A-00) 00009 // 8/24/2011 by Jeff Rowberg <jeff@rowberg.net> 00010 // Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib 00011 // 00012 // Changelog: 00013 // ... - ongoing debug release 00014 00015 // NOTE: THIS IS ONLY A PARIAL RELEASE. THIS DEVICE CLASS IS CURRENTLY UNDERGOING ACTIVE 00016 // DEVELOPMENT AND IS STILL MISSING SOME IMPORTANT FEATURES. PLEASE KEEP THIS IN MIND IF 00017 // YOU DECIDE TO USE THIS PARTICULAR CODE FOR ANYTHING. 00018 00019 /* ============================================ 00020 I2Cdev device library code is placed under the MIT license 00021 Copyright (c) 2012 Jeff Rowberg 00022 00023 Permission is hereby granted, free of charge, to any person obtaining a copy 00024 of this software and associated documentation files (the "Software"), to deal 00025 in the Software without restriction, including without limitation the rights 00026 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00027 copies of the Software, and to permit persons to whom the Software is 00028 furnished to do so, subject to the following conditions: 00029 00030 The above copyright notice and this permission notice shall be included in 00031 all copies or substantial portions of the Software. 00032 00033 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00034 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00035 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00036 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00037 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00038 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00039 THE SOFTWARE. 00040 =============================================== 00041 */ 00042 00043 #ifndef _MPU6050_H_ 00044 #define _MPU6050_H_ 00045 00046 #include "I2Cdev.h" 00047 #include "helper_3dmath.h" 00048 00049 #define MPU6050_ADDRESS_AD0_LOW 0x68 // address pin low (GND), default for InvenSense evaluation board 00050 #define MPU6050_ADDRESS_AD0_HIGH 0x69 // address pin high (VCC) 00051 #define MPU6050_DEFAULT_ADDRESS MPU6050_ADDRESS_AD0_LOW 00052 00053 #define MPU6050_INCLUDE_DMP_MOTIONAPPS20 00054 00055 #define MPU6050_RA_XG_OFFS_TC 0x00 //[7] PWR_MODE, [6:1] XG_OFFS_TC, [0] OTP_BNK_VLD 00056 #define MPU6050_RA_YG_OFFS_TC 0x01 //[7] PWR_MODE, [6:1] YG_OFFS_TC, [0] OTP_BNK_VLD 00057 #define MPU6050_RA_ZG_OFFS_TC 0x02 //[7] PWR_MODE, [6:1] ZG_OFFS_TC, [0] OTP_BNK_VLD 00058 #define MPU6050_RA_X_FINE_GAIN 0x03 //[7:0] X_FINE_GAIN 00059 #define MPU6050_RA_Y_FINE_GAIN 0x04 //[7:0] Y_FINE_GAIN 00060 #define MPU6050_RA_Z_FINE_GAIN 0x05 //[7:0] Z_FINE_GAIN 00061 #define MPU6050_RA_XA_OFFS_H 0x06 //[15:0] XA_OFFS 00062 #define MPU6050_RA_XA_OFFS_L_TC 0x07 00063 #define MPU6050_RA_YA_OFFS_H 0x08 //[15:0] YA_OFFS 00064 #define MPU6050_RA_YA_OFFS_L_TC 0x09 00065 #define MPU6050_RA_ZA_OFFS_H 0x0A //[15:0] ZA_OFFS 00066 #define MPU6050_RA_ZA_OFFS_L_TC 0x0B 00067 #define MPU6050_RA_XG_OFFS_USRH 0x13 //[15:0] XG_OFFS_USR 00068 #define MPU6050_RA_XG_OFFS_USRL 0x14 00069 #define MPU6050_RA_YG_OFFS_USRH 0x15 //[15:0] YG_OFFS_USR 00070 #define MPU6050_RA_YG_OFFS_USRL 0x16 00071 #define MPU6050_RA_ZG_OFFS_USRH 0x17 //[15:0] ZG_OFFS_USR 00072 #define MPU6050_RA_ZG_OFFS_USRL 0x18 00073 #define MPU6050_RA_SMPLRT_DIV 0x19 00074 #define MPU6050_RA_CONFIG 0x1A 00075 #define MPU6050_RA_GYRO_CONFIG 0x1B 00076 #define MPU6050_RA_ACCEL_CONFIG 0x1C 00077 #define MPU6050_RA_FF_THR 0x1D 00078 #define MPU6050_RA_FF_DUR 0x1E 00079 #define MPU6050_RA_MOT_THR 0x1F 00080 #define MPU6050_RA_MOT_DUR 0x20 00081 #define MPU6050_RA_ZRMOT_THR 0x21 00082 #define MPU6050_RA_ZRMOT_DUR 0x22 00083 #define MPU6050_RA_FIFO_EN 0x23 00084 #define MPU6050_RA_I2C_MST_CTRL 0x24 00085 #define MPU6050_RA_I2C_SLV0_ADDR 0x25 00086 #define MPU6050_RA_I2C_SLV0_REG 0x26 00087 #define MPU6050_RA_I2C_SLV0_CTRL 0x27 00088 #define MPU6050_RA_I2C_SLV1_ADDR 0x28 00089 #define MPU6050_RA_I2C_SLV1_REG 0x29 00090 #define MPU6050_RA_I2C_SLV1_CTRL 0x2A 00091 #define MPU6050_RA_I2C_SLV2_ADDR 0x2B 00092 #define MPU6050_RA_I2C_SLV2_REG 0x2C 00093 #define MPU6050_RA_I2C_SLV2_CTRL 0x2D 00094 #define MPU6050_RA_I2C_SLV3_ADDR 0x2E 00095 #define MPU6050_RA_I2C_SLV3_REG 0x2F 00096 #define MPU6050_RA_I2C_SLV3_CTRL 0x30 00097 #define MPU6050_RA_I2C_SLV4_ADDR 0x31 00098 #define MPU6050_RA_I2C_SLV4_REG 0x32 00099 #define MPU6050_RA_I2C_SLV4_DO 0x33 00100 #define MPU6050_RA_I2C_SLV4_CTRL 0x34 00101 #define MPU6050_RA_I2C_SLV4_DI 0x35 00102 #define MPU6050_RA_I2C_MST_STATUS 0x36 00103 #define MPU6050_RA_INT_PIN_CFG 0x37 00104 #define MPU6050_RA_INT_ENABLE 0x38 00105 #define MPU6050_RA_DMP_INT_STATUS 0x39 00106 #define MPU6050_RA_INT_STATUS 0x3A 00107 00108 #define MPU6050_RA_ACCEL_XOUT_H 0x3B 00109 #define MPU6050_RA_ACCEL_XOUT_L 0x3C 00110 #define MPU6050_RA_ACCEL_YOUT_H 0x3D 00111 #define MPU6050_RA_ACCEL_YOUT_L 0x3E 00112 #define MPU6050_RA_ACCEL_ZOUT_H 0x3F 00113 #define MPU6050_RA_ACCEL_ZOUT_L 0x40 00114 00115 #define MPU6050_RA_TEMP_OUT_H 0x41 00116 #define MPU6050_RA_TEMP_OUT_L 0x42 00117 00118 #define MPU6050_RA_GYRO_XOUT_H 0x43 00119 #define MPU6050_RA_GYRO_XOUT_L 0x44 00120 #define MPU6050_RA_GYRO_YOUT_H 0x45 00121 #define MPU6050_RA_GYRO_YOUT_L 0x46 00122 #define MPU6050_RA_GYRO_ZOUT_H 0x47 00123 #define MPU6050_RA_GYRO_ZOUT_L 0x48 00124 00125 #define MPU9150_RA_MAG_ADDRESS 0x0C 00126 #define MPU9150_RA_MAG_XOUT_L 0x03 00127 #define MPU9150_RA_MAG_XOUT_H 0x04 00128 #define MPU9150_RA_MAG_YOUT_L 0x05 00129 #define MPU9150_RA_MAG_YOUT_H 0x06 00130 #define MPU9150_RA_MAG_ZOUT_L 0x07 00131 #define MPU9150_RA_MAG_ZOUT_H 0x08 00132 00133 #define MPU6050_RA_EXT_SENS_DATA_00 0x49 00134 #define MPU6050_RA_EXT_SENS_DATA_01 0x4A 00135 #define MPU6050_RA_EXT_SENS_DATA_02 0x4B 00136 #define MPU6050_RA_EXT_SENS_DATA_03 0x4C 00137 #define MPU6050_RA_EXT_SENS_DATA_04 0x4D 00138 #define MPU6050_RA_EXT_SENS_DATA_05 0x4E 00139 #define MPU6050_RA_EXT_SENS_DATA_06 0x4F 00140 #define MPU6050_RA_EXT_SENS_DATA_07 0x50 00141 #define MPU6050_RA_EXT_SENS_DATA_08 0x51 00142 #define MPU6050_RA_EXT_SENS_DATA_09 0x52 00143 #define MPU6050_RA_EXT_SENS_DATA_10 0x53 00144 #define MPU6050_RA_EXT_SENS_DATA_11 0x54 00145 #define MPU6050_RA_EXT_SENS_DATA_12 0x55 00146 #define MPU6050_RA_EXT_SENS_DATA_13 0x56 00147 #define MPU6050_RA_EXT_SENS_DATA_14 0x57 00148 #define MPU6050_RA_EXT_SENS_DATA_15 0x58 00149 #define MPU6050_RA_EXT_SENS_DATA_16 0x59 00150 #define MPU6050_RA_EXT_SENS_DATA_17 0x5A 00151 #define MPU6050_RA_EXT_SENS_DATA_18 0x5B 00152 #define MPU6050_RA_EXT_SENS_DATA_19 0x5C 00153 #define MPU6050_RA_EXT_SENS_DATA_20 0x5D 00154 #define MPU6050_RA_EXT_SENS_DATA_21 0x5E 00155 #define MPU6050_RA_EXT_SENS_DATA_22 0x5F 00156 #define MPU6050_RA_EXT_SENS_DATA_23 0x60 00157 #define MPU6050_RA_MOT_DETECT_STATUS 0x61 00158 #define MPU6050_RA_I2C_SLV0_DO 0x63 00159 #define MPU6050_RA_I2C_SLV1_DO 0x64 00160 #define MPU6050_RA_I2C_SLV2_DO 0x65 00161 #define MPU6050_RA_I2C_SLV3_DO 0x66 00162 #define MPU6050_RA_I2C_MST_DELAY_CTRL 0x67 00163 #define MPU6050_RA_SIGNAL_PATH_RESET 0x68 00164 #define MPU6050_RA_MOT_DETECT_CTRL 0x69 00165 #define MPU6050_RA_USER_CTRL 0x6A 00166 #define MPU6050_RA_PWR_MGMT_1 0x6B 00167 #define MPU6050_RA_PWR_MGMT_2 0x6C 00168 #define MPU6050_RA_BANK_SEL 0x6D 00169 #define MPU6050_RA_MEM_START_ADDR 0x6E 00170 #define MPU6050_RA_MEM_R_W 0x6F 00171 #define MPU6050_RA_DMP_CFG_1 0x70 00172 #define MPU6050_RA_DMP_CFG_2 0x71 00173 #define MPU6050_RA_FIFO_COUNTH 0x72 00174 #define MPU6050_RA_FIFO_COUNTL 0x73 00175 #define MPU6050_RA_FIFO_R_W 0x74 00176 #define MPU6050_RA_WHO_AM_I 0x75 00177 00178 #define MPU6050_TC_PWR_MODE_BIT 7 00179 #define MPU6050_TC_OFFSET_BIT 6 00180 #define MPU6050_TC_OFFSET_LENGTH 6 00181 #define MPU6050_TC_OTP_BNK_VLD_BIT 0 00182 00183 #define MPU6050_VDDIO_LEVEL_VLOGIC 0 00184 #define MPU6050_VDDIO_LEVEL_VDD 1 00185 00186 #define MPU6050_CFG_EXT_SYNC_SET_BIT 5 00187 #define MPU6050_CFG_EXT_SYNC_SET_LENGTH 3 00188 #define MPU6050_CFG_DLPF_CFG_BIT 2 00189 #define MPU6050_CFG_DLPF_CFG_LENGTH 3 00190 00191 #define MPU6050_EXT_SYNC_DISABLED 0x0 00192 #define MPU6050_EXT_SYNC_TEMP_OUT_L 0x1 00193 #define MPU6050_EXT_SYNC_GYRO_XOUT_L 0x2 00194 #define MPU6050_EXT_SYNC_GYRO_YOUT_L 0x3 00195 #define MPU6050_EXT_SYNC_GYRO_ZOUT_L 0x4 00196 #define MPU6050_EXT_SYNC_ACCEL_XOUT_L 0x5 00197 #define MPU6050_EXT_SYNC_ACCEL_YOUT_L 0x6 00198 #define MPU6050_EXT_SYNC_ACCEL_ZOUT_L 0x7 00199 00200 #define MPU6050_DLPF_BW_256 0x00 00201 #define MPU6050_DLPF_BW_188 0x01 00202 #define MPU6050_DLPF_BW_98 0x02 00203 #define MPU6050_DLPF_BW_42 0x03 00204 #define MPU6050_DLPF_BW_20 0x04 00205 #define MPU6050_DLPF_BW_10 0x05 00206 #define MPU6050_DLPF_BW_5 0x06 00207 00208 #define MPU6050_GCONFIG_FS_SEL_BIT 4 00209 #define MPU6050_GCONFIG_FS_SEL_LENGTH 2 00210 00211 #define MPU6050_GYRO_FS_250 0x00 00212 #define MPU6050_GYRO_FS_500 0x01 00213 #define MPU6050_GYRO_FS_1000 0x02 00214 #define MPU6050_GYRO_FS_2000 0x03 00215 00216 #define MPU6050_ACONFIG_XA_ST_BIT 7 00217 #define MPU6050_ACONFIG_YA_ST_BIT 6 00218 #define MPU6050_ACONFIG_ZA_ST_BIT 5 00219 #define MPU6050_ACONFIG_AFS_SEL_BIT 4 00220 #define MPU6050_ACONFIG_AFS_SEL_LENGTH 2 00221 #define MPU6050_ACONFIG_ACCEL_HPF_BIT 2 00222 #define MPU6050_ACONFIG_ACCEL_HPF_LENGTH 3 00223 00224 #define MPU6050_ACCEL_FS_2 0x00 00225 #define MPU6050_ACCEL_FS_4 0x01 00226 #define MPU6050_ACCEL_FS_8 0x02 00227 #define MPU6050_ACCEL_FS_16 0x03 00228 00229 #define MPU6050_DHPF_RESET 0x00 00230 #define MPU6050_DHPF_5 0x01 00231 #define MPU6050_DHPF_2P5 0x02 00232 #define MPU6050_DHPF_1P25 0x03 00233 #define MPU6050_DHPF_0P63 0x04 00234 #define MPU6050_DHPF_HOLD 0x07 00235 00236 #define MPU6050_TEMP_FIFO_EN_BIT 7 00237 #define MPU6050_XG_FIFO_EN_BIT 6 00238 #define MPU6050_YG_FIFO_EN_BIT 5 00239 #define MPU6050_ZG_FIFO_EN_BIT 4 00240 #define MPU6050_ACCEL_FIFO_EN_BIT 3 00241 #define MPU6050_SLV2_FIFO_EN_BIT 2 00242 #define MPU6050_SLV1_FIFO_EN_BIT 1 00243 #define MPU6050_SLV0_FIFO_EN_BIT 0 00244 00245 #define MPU6050_MULT_MST_EN_BIT 7 00246 #define MPU6050_WAIT_FOR_ES_BIT 6 00247 #define MPU6050_SLV_3_FIFO_EN_BIT 5 00248 #define MPU6050_I2C_MST_P_NSR_BIT 4 00249 #define MPU6050_I2C_MST_CLK_BIT 3 00250 #define MPU6050_I2C_MST_CLK_LENGTH 4 00251 00252 #define MPU6050_CLOCK_DIV_348 0x0 00253 #define MPU6050_CLOCK_DIV_333 0x1 00254 #define MPU6050_CLOCK_DIV_320 0x2 00255 #define MPU6050_CLOCK_DIV_308 0x3 00256 #define MPU6050_CLOCK_DIV_296 0x4 00257 #define MPU6050_CLOCK_DIV_286 0x5 00258 #define MPU6050_CLOCK_DIV_276 0x6 00259 #define MPU6050_CLOCK_DIV_267 0x7 00260 #define MPU6050_CLOCK_DIV_258 0x8 00261 #define MPU6050_CLOCK_DIV_500 0x9 00262 #define MPU6050_CLOCK_DIV_471 0xA 00263 #define MPU6050_CLOCK_DIV_444 0xB 00264 #define MPU6050_CLOCK_DIV_421 0xC 00265 #define MPU6050_CLOCK_DIV_400 0xD 00266 #define MPU6050_CLOCK_DIV_381 0xE 00267 #define MPU6050_CLOCK_DIV_364 0xF 00268 00269 #define MPU6050_I2C_SLV_RW_BIT 7 00270 #define MPU6050_I2C_SLV_ADDR_BIT 6 00271 #define MPU6050_I2C_SLV_ADDR_LENGTH 7 00272 #define MPU6050_I2C_SLV_EN_BIT 7 00273 #define MPU6050_I2C_SLV_BYTE_SW_BIT 6 00274 #define MPU6050_I2C_SLV_REG_DIS_BIT 5 00275 #define MPU6050_I2C_SLV_GRP_BIT 4 00276 #define MPU6050_I2C_SLV_LEN_BIT 3 00277 #define MPU6050_I2C_SLV_LEN_LENGTH 4 00278 00279 #define MPU6050_I2C_SLV4_RW_BIT 7 00280 #define MPU6050_I2C_SLV4_ADDR_BIT 6 00281 #define MPU6050_I2C_SLV4_ADDR_LENGTH 7 00282 #define MPU6050_I2C_SLV4_EN_BIT 7 00283 #define MPU6050_I2C_SLV4_INT_EN_BIT 6 00284 #define MPU6050_I2C_SLV4_REG_DIS_BIT 5 00285 #define MPU6050_I2C_SLV4_MST_DLY_BIT 4 00286 #define MPU6050_I2C_SLV4_MST_DLY_LENGTH 5 00287 00288 #define MPU6050_MST_PASS_THROUGH_BIT 7 00289 #define MPU6050_MST_I2C_SLV4_DONE_BIT 6 00290 #define MPU6050_MST_I2C_LOST_ARB_BIT 5 00291 #define MPU6050_MST_I2C_SLV4_NACK_BIT 4 00292 #define MPU6050_MST_I2C_SLV3_NACK_BIT 3 00293 #define MPU6050_MST_I2C_SLV2_NACK_BIT 2 00294 #define MPU6050_MST_I2C_SLV1_NACK_BIT 1 00295 #define MPU6050_MST_I2C_SLV0_NACK_BIT 0 00296 00297 #define MPU6050_INTCFG_INT_LEVEL_BIT 7 00298 #define MPU6050_INTCFG_INT_OPEN_BIT 6 00299 #define MPU6050_INTCFG_LATCH_INT_EN_BIT 5 00300 #define MPU6050_INTCFG_INT_RD_CLEAR_BIT 4 00301 #define MPU6050_INTCFG_FSYNC_INT_LEVEL_BIT 3 00302 #define MPU6050_INTCFG_FSYNC_INT_EN_BIT 2 00303 #define MPU6050_INTCFG_I2C_BYPASS_EN_BIT 1 00304 #define MPU6050_INTCFG_CLKOUT_EN_BIT 0 00305 00306 #define MPU6050_INTMODE_ACTIVEHIGH 0x00 00307 #define MPU6050_INTMODE_ACTIVELOW 0x01 00308 00309 #define MPU6050_INTDRV_PUSHPULL 0x00 00310 #define MPU6050_INTDRV_OPENDRAIN 0x01 00311 00312 #define MPU6050_INTLATCH_50USPULSE 0x00 00313 #define MPU6050_INTLATCH_WAITCLEAR 0x01 00314 00315 #define MPU6050_INTCLEAR_STATUSREAD 0x00 00316 #define MPU6050_INTCLEAR_ANYREAD 0x01 00317 00318 #define MPU6050_INTERRUPT_FF_BIT 7 00319 #define MPU6050_INTERRUPT_MOT_BIT 6 00320 #define MPU6050_INTERRUPT_ZMOT_BIT 5 00321 #define MPU6050_INTERRUPT_FIFO_OFLOW_BIT 4 00322 #define MPU6050_INTERRUPT_I2C_MST_INT_BIT 3 00323 #define MPU6050_INTERRUPT_PLL_RDY_INT_BIT 2 00324 #define MPU6050_INTERRUPT_DMP_INT_BIT 1 00325 #define MPU6050_INTERRUPT_DATA_RDY_BIT 0 00326 00327 // TODO: figure out what these actually do 00328 // UMPL source code is not very obivous 00329 #define MPU6050_DMPINT_5_BIT 5 00330 #define MPU6050_DMPINT_4_BIT 4 00331 #define MPU6050_DMPINT_3_BIT 3 00332 #define MPU6050_DMPINT_2_BIT 2 00333 #define MPU6050_DMPINT_1_BIT 1 00334 #define MPU6050_DMPINT_0_BIT 0 00335 00336 #define MPU6050_MOTION_MOT_XNEG_BIT 7 00337 #define MPU6050_MOTION_MOT_XPOS_BIT 6 00338 #define MPU6050_MOTION_MOT_YNEG_BIT 5 00339 #define MPU6050_MOTION_MOT_YPOS_BIT 4 00340 #define MPU6050_MOTION_MOT_ZNEG_BIT 3 00341 #define MPU6050_MOTION_MOT_ZPOS_BIT 2 00342 #define MPU6050_MOTION_MOT_ZRMOT_BIT 0 00343 00344 #define MPU6050_DELAYCTRL_DELAY_ES_SHADOW_BIT 7 00345 #define MPU6050_DELAYCTRL_I2C_SLV4_DLY_EN_BIT 4 00346 #define MPU6050_DELAYCTRL_I2C_SLV3_DLY_EN_BIT 3 00347 #define MPU6050_DELAYCTRL_I2C_SLV2_DLY_EN_BIT 2 00348 #define MPU6050_DELAYCTRL_I2C_SLV1_DLY_EN_BIT 1 00349 #define MPU6050_DELAYCTRL_I2C_SLV0_DLY_EN_BIT 0 00350 00351 #define MPU6050_PATHRESET_GYRO_RESET_BIT 2 00352 #define MPU6050_PATHRESET_ACCEL_RESET_BIT 1 00353 #define MPU6050_PATHRESET_TEMP_RESET_BIT 0 00354 00355 #define MPU6050_DETECT_ACCEL_ON_DELAY_BIT 5 00356 #define MPU6050_DETECT_ACCEL_ON_DELAY_LENGTH 2 00357 #define MPU6050_DETECT_FF_COUNT_BIT 3 00358 #define MPU6050_DETECT_FF_COUNT_LENGTH 2 00359 #define MPU6050_DETECT_MOT_COUNT_BIT 1 00360 #define MPU6050_DETECT_MOT_COUNT_LENGTH 2 00361 00362 #define MPU6050_DETECT_DECREMENT_RESET 0x0 00363 #define MPU6050_DETECT_DECREMENT_1 0x1 00364 #define MPU6050_DETECT_DECREMENT_2 0x2 00365 #define MPU6050_DETECT_DECREMENT_4 0x3 00366 00367 #define MPU6050_USERCTRL_DMP_EN_BIT 7 00368 #define MPU6050_USERCTRL_FIFO_EN_BIT 6 00369 #define MPU6050_USERCTRL_I2C_MST_EN_BIT 5 00370 #define MPU6050_USERCTRL_I2C_IF_DIS_BIT 4 00371 #define MPU6050_USERCTRL_DMP_RESET_BIT 3 00372 #define MPU6050_USERCTRL_FIFO_RESET_BIT 2 00373 #define MPU6050_USERCTRL_I2C_MST_RESET_BIT 1 00374 #define MPU6050_USERCTRL_SIG_COND_RESET_BIT 0 00375 00376 #define MPU6050_PWR1_DEVICE_RESET_BIT 7 00377 #define MPU6050_PWR1_SLEEP_BIT 6 00378 #define MPU6050_PWR1_CYCLE_BIT 5 00379 #define MPU6050_PWR1_TEMP_DIS_BIT 3 00380 #define MPU6050_PWR1_CLKSEL_BIT 2 00381 #define MPU6050_PWR1_CLKSEL_LENGTH 3 00382 00383 #define MPU6050_CLOCK_INTERNAL 0x00 00384 #define MPU6050_CLOCK_PLL_XGYRO 0x01 00385 #define MPU6050_CLOCK_PLL_YGYRO 0x02 00386 #define MPU6050_CLOCK_PLL_ZGYRO 0x03 00387 #define MPU6050_CLOCK_PLL_EXT32K 0x04 00388 #define MPU6050_CLOCK_PLL_EXT19M 0x05 00389 #define MPU6050_CLOCK_KEEP_RESET 0x07 00390 00391 #define MPU6050_PWR2_LP_WAKE_CTRL_BIT 7 00392 #define MPU6050_PWR2_LP_WAKE_CTRL_LENGTH 2 00393 #define MPU6050_PWR2_STBY_XA_BIT 5 00394 #define MPU6050_PWR2_STBY_YA_BIT 4 00395 #define MPU6050_PWR2_STBY_ZA_BIT 3 00396 #define MPU6050_PWR2_STBY_XG_BIT 2 00397 #define MPU6050_PWR2_STBY_YG_BIT 1 00398 #define MPU6050_PWR2_STBY_ZG_BIT 0 00399 00400 #define MPU6050_WAKE_FREQ_1P25 0x0 00401 #define MPU6050_WAKE_FREQ_2P5 0x1 00402 #define MPU6050_WAKE_FREQ_5 0x2 00403 #define MPU6050_WAKE_FREQ_10 0x3 00404 00405 #define MPU6050_BANKSEL_PRFTCH_EN_BIT 6 00406 #define MPU6050_BANKSEL_CFG_USER_BANK_BIT 5 00407 #define MPU6050_BANKSEL_MEM_SEL_BIT 4 00408 #define MPU6050_BANKSEL_MEM_SEL_LENGTH 5 00409 00410 #define MPU6050_WHO_AM_I_BIT 6 00411 #define MPU6050_WHO_AM_I_LENGTH 6 00412 00413 #define MPU6050_DMP_MEMORY_BANKS 8 00414 #define MPU6050_DMP_MEMORY_BANK_SIZE 256 00415 #define MPU6050_DMP_MEMORY_CHUNK_SIZE 16 00416 00417 // note: DMP code memory blocks defined at end of header file 00418 00419 class MPU6050 00420 { 00421 private: 00422 I2Cdev i2Cdev; 00423 00424 public: 00425 Serial debugSerial; 00426 MPU6050(); 00427 MPU6050(uint8_t address); 00428 MPU6050(PinName i2cSDA, PinName i2cSCL); 00429 00430 void initialize(); 00431 bool testConnection(); 00432 00433 // AUX_VDDIO register 00434 uint8_t getAuxVDDIOLevel(); 00435 void setAuxVDDIOLevel(uint8_t level); 00436 00437 // SMPLRT_DIV register 00438 uint8_t getRate(); 00439 void setRate(uint8_t rate); 00440 00441 // CONFIG register 00442 uint8_t getExternalFrameSync(); 00443 void setExternalFrameSync(uint8_t sync); 00444 uint8_t getDLPFMode(); 00445 void setDLPFMode(uint8_t bandwidth); 00446 00447 // GYRO_CONFIG register 00448 uint8_t getFullScaleGyroRange(); 00449 void setFullScaleGyroRange(uint8_t range); 00450 00451 // ACCEL_CONFIG register 00452 bool getAccelXSelfTest(); 00453 void setAccelXSelfTest(bool enabled); 00454 bool getAccelYSelfTest(); 00455 void setAccelYSelfTest(bool enabled); 00456 bool getAccelZSelfTest(); 00457 void setAccelZSelfTest(bool enabled); 00458 uint8_t getFullScaleAccelRange(); 00459 void setFullScaleAccelRange(uint8_t range); 00460 uint8_t getDHPFMode(); 00461 void setDHPFMode(uint8_t mode); 00462 00463 // FF_THR register 00464 uint8_t getFreefallDetectionThreshold(); 00465 void setFreefallDetectionThreshold(uint8_t threshold); 00466 00467 // FF_DUR register 00468 uint8_t getFreefallDetectionDuration(); 00469 void setFreefallDetectionDuration(uint8_t duration); 00470 00471 // MOT_THR register 00472 uint8_t getMotionDetectionThreshold(); 00473 void setMotionDetectionThreshold(uint8_t threshold); 00474 00475 // MOT_DUR register 00476 uint8_t getMotionDetectionDuration(); 00477 void setMotionDetectionDuration(uint8_t duration); 00478 00479 // ZRMOT_THR register 00480 uint8_t getZeroMotionDetectionThreshold(); 00481 void setZeroMotionDetectionThreshold(uint8_t threshold); 00482 00483 // ZRMOT_DUR register 00484 uint8_t getZeroMotionDetectionDuration(); 00485 void setZeroMotionDetectionDuration(uint8_t duration); 00486 00487 // FIFO_EN register 00488 bool getTempFIFOEnabled(); 00489 void setTempFIFOEnabled(bool enabled); 00490 bool getXGyroFIFOEnabled(); 00491 void setXGyroFIFOEnabled(bool enabled); 00492 bool getYGyroFIFOEnabled(); 00493 void setYGyroFIFOEnabled(bool enabled); 00494 bool getZGyroFIFOEnabled(); 00495 void setZGyroFIFOEnabled(bool enabled); 00496 bool getAccelFIFOEnabled(); 00497 void setAccelFIFOEnabled(bool enabled); 00498 bool getSlave2FIFOEnabled(); 00499 void setSlave2FIFOEnabled(bool enabled); 00500 bool getSlave1FIFOEnabled(); 00501 void setSlave1FIFOEnabled(bool enabled); 00502 bool getSlave0FIFOEnabled(); 00503 void setSlave0FIFOEnabled(bool enabled); 00504 00505 // I2C_MST_CTRL register 00506 bool getMultiMasterEnabled(); 00507 void setMultiMasterEnabled(bool enabled); 00508 bool getWaitForExternalSensorEnabled(); 00509 void setWaitForExternalSensorEnabled(bool enabled); 00510 bool getSlave3FIFOEnabled(); 00511 void setSlave3FIFOEnabled(bool enabled); 00512 bool getSlaveReadWriteTransitionEnabled(); 00513 void setSlaveReadWriteTransitionEnabled(bool enabled); 00514 uint8_t getMasterClockSpeed(); 00515 void setMasterClockSpeed(uint8_t speed); 00516 00517 // I2C_SLV* registers (Slave 0-3) 00518 uint8_t getSlaveAddress(uint8_t num); 00519 void setSlaveAddress(uint8_t num, uint8_t address); 00520 uint8_t getSlaveRegister(uint8_t num); 00521 void setSlaveRegister(uint8_t num, uint8_t reg); 00522 bool getSlaveEnabled(uint8_t num); 00523 void setSlaveEnabled(uint8_t num, bool enabled); 00524 bool getSlaveWordByteSwap(uint8_t num); 00525 void setSlaveWordByteSwap(uint8_t num, bool enabled); 00526 bool getSlaveWriteMode(uint8_t num); 00527 void setSlaveWriteMode(uint8_t num, bool mode); 00528 bool getSlaveWordGroupOffset(uint8_t num); 00529 void setSlaveWordGroupOffset(uint8_t num, bool enabled); 00530 uint8_t getSlaveDataLength(uint8_t num); 00531 void setSlaveDataLength(uint8_t num, uint8_t length); 00532 00533 // I2C_SLV* registers (Slave 4) 00534 uint8_t getSlave4Address(); 00535 void setSlave4Address(uint8_t address); 00536 uint8_t getSlave4Register(); 00537 void setSlave4Register(uint8_t reg); 00538 void setSlave4OutputByte(uint8_t data); 00539 bool getSlave4Enabled(); 00540 void setSlave4Enabled(bool enabled); 00541 bool getSlave4InterruptEnabled(); 00542 void setSlave4InterruptEnabled(bool enabled); 00543 bool getSlave4WriteMode(); 00544 void setSlave4WriteMode(bool mode); 00545 uint8_t getSlave4MasterDelay(); 00546 void setSlave4MasterDelay(uint8_t delay); 00547 uint8_t getSlate4InputByte(); 00548 00549 // I2C_MST_STATUS register 00550 bool getPassthroughStatus(); 00551 bool getSlave4IsDone(); 00552 bool getLostArbitration(); 00553 bool getSlave4Nack(); 00554 bool getSlave3Nack(); 00555 bool getSlave2Nack(); 00556 bool getSlave1Nack(); 00557 bool getSlave0Nack(); 00558 00559 // INT_PIN_CFG register 00560 bool getInterruptMode(); 00561 void setInterruptMode(bool mode); 00562 bool getInterruptDrive(); 00563 void setInterruptDrive(bool drive); 00564 bool getInterruptLatch(); 00565 void setInterruptLatch(bool latch); 00566 bool getInterruptLatchClear(); 00567 void setInterruptLatchClear(bool clear); 00568 bool getFSyncInterruptLevel(); 00569 void setFSyncInterruptLevel(bool level); 00570 bool getFSyncInterruptEnabled(); 00571 void setFSyncInterruptEnabled(bool enabled); 00572 bool getI2CBypassEnabled(); 00573 void setI2CBypassEnabled(bool enabled); 00574 bool getClockOutputEnabled(); 00575 void setClockOutputEnabled(bool enabled); 00576 00577 // INT_ENABLE register 00578 uint8_t getIntEnabled(); 00579 void setIntEnabled(uint8_t enabled); 00580 bool getIntFreefallEnabled(); 00581 void setIntFreefallEnabled(bool enabled); 00582 bool getIntMotionEnabled(); 00583 void setIntMotionEnabled(bool enabled); 00584 bool getIntZeroMotionEnabled(); 00585 void setIntZeroMotionEnabled(bool enabled); 00586 bool getIntFIFOBufferOverflowEnabled(); 00587 void setIntFIFOBufferOverflowEnabled(bool enabled); 00588 bool getIntI2CMasterEnabled(); 00589 void setIntI2CMasterEnabled(bool enabled); 00590 bool getIntDataReadyEnabled(); 00591 void setIntDataReadyEnabled(bool enabled); 00592 00593 // INT_STATUS register 00594 uint8_t getIntStatus(); 00595 bool getIntFreefallStatus(); 00596 bool getIntMotionStatus(); 00597 bool getIntZeroMotionStatus(); 00598 bool getIntFIFOBufferOverflowStatus(); 00599 bool getIntI2CMasterStatus(); 00600 bool getIntDataReadyStatus(); 00601 00602 // ACCEL_*OUT_* registers 00603 void getMotion9(int16_t* ax, int16_t* ay, int16_t* az, int16_t* gx, int16_t* gy, int16_t* gz, int16_t* mx, int16_t* my, int16_t* mz); 00604 void getMotion6(int16_t* ax, int16_t* ay, int16_t* az, int16_t* gx, int16_t* gy, int16_t* gz); 00605 void getAcceleration(int16_t* x, int16_t* y, int16_t* z); 00606 int16_t getAccelerationX(); 00607 int16_t getAccelerationY(); 00608 int16_t getAccelerationZ(); 00609 00610 // TEMP_OUT_* registers 00611 int16_t getTemperature(); 00612 00613 // GYRO_*OUT_* registers 00614 void getRotation(int16_t* x, int16_t* y, int16_t* z); 00615 int16_t getRotationX(); 00616 int16_t getRotationY(); 00617 int16_t getRotationZ(); 00618 00619 // EXT_SENS_DATA_* registers 00620 uint8_t getExternalSensorByte(int position); 00621 uint16_t getExternalSensorWord(int position); 00622 uint32_t getExternalSensorDWord(int position); 00623 00624 // MOT_DETECT_STATUS register 00625 bool getXNegMotionDetected(); 00626 bool getXPosMotionDetected(); 00627 bool getYNegMotionDetected(); 00628 bool getYPosMotionDetected(); 00629 bool getZNegMotionDetected(); 00630 bool getZPosMotionDetected(); 00631 bool getZeroMotionDetected(); 00632 00633 // I2C_SLV*_DO register 00634 void setSlaveOutputByte(uint8_t num, uint8_t data); 00635 00636 // I2C_MST_DELAY_CTRL register 00637 bool getExternalShadowDelayEnabled(); 00638 void setExternalShadowDelayEnabled(bool enabled); 00639 bool getSlaveDelayEnabled(uint8_t num); 00640 void setSlaveDelayEnabled(uint8_t num, bool enabled); 00641 00642 // SIGNAL_PATH_RESET register 00643 void resetGyroscopePath(); 00644 void resetAccelerometerPath(); 00645 void resetTemperaturePath(); 00646 00647 // MOT_DETECT_CTRL register 00648 uint8_t getAccelerometerPowerOnDelay(); 00649 void setAccelerometerPowerOnDelay(uint8_t delay); 00650 uint8_t getFreefallDetectionCounterDecrement(); 00651 void setFreefallDetectionCounterDecrement(uint8_t decrement); 00652 uint8_t getMotionDetectionCounterDecrement(); 00653 void setMotionDetectionCounterDecrement(uint8_t decrement); 00654 00655 // USER_CTRL register 00656 bool getFIFOEnabled(); 00657 void setFIFOEnabled(bool enabled); 00658 bool getI2CMasterModeEnabled(); 00659 void setI2CMasterModeEnabled(bool enabled); 00660 void switchSPIEnabled(bool enabled); 00661 void resetFIFO(); 00662 void resetI2CMaster(); 00663 void resetSensors(); 00664 00665 // PWR_MGMT_1 register 00666 void reset(); 00667 bool getSleepEnabled(); 00668 void setSleepEnabled(bool enabled); 00669 bool getWakeCycleEnabled(); 00670 void setWakeCycleEnabled(bool enabled); 00671 bool getTempSensorEnabled(); 00672 void setTempSensorEnabled(bool enabled); 00673 uint8_t getClockSource(); 00674 void setClockSource(uint8_t source); 00675 00676 // PWR_MGMT_2 register 00677 uint8_t getWakeFrequency(); 00678 void setWakeFrequency(uint8_t frequency); 00679 bool getStandbyXAccelEnabled(); 00680 void setStandbyXAccelEnabled(bool enabled); 00681 bool getStandbyYAccelEnabled(); 00682 void setStandbyYAccelEnabled(bool enabled); 00683 bool getStandbyZAccelEnabled(); 00684 void setStandbyZAccelEnabled(bool enabled); 00685 bool getStandbyXGyroEnabled(); 00686 void setStandbyXGyroEnabled(bool enabled); 00687 bool getStandbyYGyroEnabled(); 00688 void setStandbyYGyroEnabled(bool enabled); 00689 bool getStandbyZGyroEnabled(); 00690 void setStandbyZGyroEnabled(bool enabled); 00691 00692 // FIFO_COUNT_* registers 00693 uint16_t getFIFOCount(); 00694 00695 // FIFO_R_W register 00696 uint8_t getFIFOByte(); 00697 void setFIFOByte(uint8_t data); 00698 void getFIFOBytes(uint8_t *data, uint8_t length); 00699 00700 // WHO_AM_I register 00701 uint8_t getDeviceID(); 00702 void setDeviceID(uint8_t id); 00703 00704 // ======== UNDOCUMENTED/DMP REGISTERS/METHODS ======== 00705 00706 // XG_OFFS_TC register 00707 uint8_t getOTPBankValid(); 00708 void setOTPBankValid(bool enabled); 00709 int8_t getXGyroOffset(); 00710 void setXGyroOffset(int8_t offset); 00711 00712 // YG_OFFS_TC register 00713 int8_t getYGyroOffset(); 00714 void setYGyroOffset(int8_t offset); 00715 00716 // ZG_OFFS_TC register 00717 int8_t getZGyroOffset(); 00718 void setZGyroOffset(int8_t offset); 00719 00720 // X_FINE_GAIN register 00721 int8_t getXFineGain(); 00722 void setXFineGain(int8_t gain); 00723 00724 // Y_FINE_GAIN register 00725 int8_t getYFineGain(); 00726 void setYFineGain(int8_t gain); 00727 00728 // Z_FINE_GAIN register 00729 int8_t getZFineGain(); 00730 void setZFineGain(int8_t gain); 00731 00732 // XA_OFFS_* registers 00733 int16_t getXAccelOffset(); 00734 void setXAccelOffset(int16_t offset); 00735 00736 // YA_OFFS_* register 00737 int16_t getYAccelOffset(); 00738 void setYAccelOffset(int16_t offset); 00739 00740 // ZA_OFFS_* register 00741 int16_t getZAccelOffset(); 00742 void setZAccelOffset(int16_t offset); 00743 00744 // XG_OFFS_USR* registers 00745 int16_t getXGyroOffsetUser(); 00746 void setXGyroOffsetUser(int16_t offset); 00747 00748 // YG_OFFS_USR* register 00749 int16_t getYGyroOffsetUser(); 00750 void setYGyroOffsetUser(int16_t offset); 00751 00752 // ZG_OFFS_USR* register 00753 int16_t getZGyroOffsetUser(); 00754 void setZGyroOffsetUser(int16_t offset); 00755 00756 // INT_ENABLE register (DMP functions) 00757 bool getIntPLLReadyEnabled(); 00758 void setIntPLLReadyEnabled(bool enabled); 00759 bool getIntDMPEnabled(); 00760 void setIntDMPEnabled(bool enabled); 00761 00762 // DMP_INT_STATUS 00763 bool getDMPInt5Status(); 00764 bool getDMPInt4Status(); 00765 bool getDMPInt3Status(); 00766 bool getDMPInt2Status(); 00767 bool getDMPInt1Status(); 00768 bool getDMPInt0Status(); 00769 00770 // INT_STATUS register (DMP functions) 00771 bool getIntPLLReadyStatus(); 00772 bool getIntDMPStatus(); 00773 00774 // USER_CTRL register (DMP functions) 00775 bool getDMPEnabled(); 00776 void setDMPEnabled(bool enabled); 00777 void resetDMP(); 00778 00779 // BANK_SEL register 00780 void setMemoryBank(uint8_t bank, bool prefetchEnabled=false, bool userBank=false); 00781 00782 // MEM_START_ADDR register 00783 void setMemoryStartAddress(uint8_t address); 00784 00785 // MEM_R_W register 00786 uint8_t readMemoryByte(); 00787 void writeMemoryByte(uint8_t data); 00788 void readMemoryBlock(uint8_t *data, uint16_t dataSize, uint8_t bank=0, uint8_t address=0); 00789 bool writeMemoryBlock(const uint8_t *data, uint16_t dataSize, uint8_t bank=0, uint8_t address=0, bool verify=true, bool useProgMem=false); 00790 bool writeProgMemoryBlock(const uint8_t *data, uint16_t dataSize, uint8_t bank=0, uint8_t address=0, bool verify=true); 00791 00792 bool writeDMPConfigurationSet(const uint8_t *data, uint16_t dataSize, bool useProgMem=false); 00793 bool writeProgDMPConfigurationSet(const uint8_t *data, uint16_t dataSize); 00794 00795 // DMP_CFG_1 register 00796 uint8_t getDMPConfig1(); 00797 void setDMPConfig1(uint8_t config); 00798 00799 // DMP_CFG_2 register 00800 uint8_t getDMPConfig2(); 00801 void setDMPConfig2(uint8_t config); 00802 00803 // special methods for MotionApps 2.0 implementation 00804 #ifdef MPU6050_INCLUDE_DMP_MOTIONAPPS20 00805 /* From MotionApps header: */ 00806 uint8_t dmpInitialize(); 00807 bool dmpPacketAvailable(); 00808 00809 uint8_t dmpGetAccel(int32_t *data, const uint8_t* packet); 00810 uint8_t dmpGetAccel(int16_t *data, const uint8_t* packet); 00811 uint8_t dmpGetAccel(VectorInt16 *v, const uint8_t* packet); 00812 uint8_t dmpGetQuaternion(int32_t *data, const uint8_t* packet); 00813 uint8_t dmpGetQuaternion(int16_t *data, const uint8_t* packet); 00814 uint8_t dmpGetQuaternion(Quaternion *q, const uint8_t* packet); 00815 00816 uint8_t dmpGetGyro(int32_t *data, const uint8_t* packet); 00817 uint8_t dmpGetGyro(int16_t *data, const uint8_t* packet); 00818 00819 uint8_t dmpGetLinearAccel(VectorInt16 *v, VectorInt16 *vRaw, VectorFloat *gravity); 00820 00821 uint8_t dmpGetLinearAccelInWorld(VectorInt16 *v, VectorInt16 *vReal, Quaternion *q); 00822 00823 uint8_t dmpGetGravity(VectorFloat *v, Quaternion *q); 00824 00825 uint8_t dmpGetEuler(float *data, Quaternion *q); 00826 uint8_t dmpGetYawPitchRoll(float *data, Quaternion *q, VectorFloat *gravity); 00827 00828 uint8_t dmpProcessFIFOPacket(const unsigned char *dmpData); 00829 uint8_t dmpReadAndProcessFIFOPacket(uint8_t numPackets, uint8_t *processed); 00830 00831 uint16_t dmpGetFIFOPacketSize(); 00832 /* End from MotionApps header */ 00833 00834 uint8_t *dmpPacketBuffer; 00835 uint16_t dmpPacketSize; 00836 00837 uint8_t dmpSetFIFORate(uint8_t fifoRate); 00838 uint8_t dmpGetFIFORate(); 00839 uint8_t dmpGetSampleStepSizeMS(); 00840 uint8_t dmpGetSampleFrequency(); 00841 int32_t dmpDecodeTemperature(int8_t tempReg); 00842 00843 // Register callbacks after a packet of FIFO data is processed 00844 //uint8_t dmpRegisterFIFORateProcess(inv_obj_func func, int16_t priority); 00845 //uint8_t dmpUnregisterFIFORateProcess(inv_obj_func func); 00846 uint8_t dmpRunFIFORateProcesses(); 00847 00848 // Setup FIFO for various output 00849 uint8_t dmpSendQuaternion(uint_fast16_t accuracy); 00850 uint8_t dmpSendGyro(uint_fast16_t elements, uint_fast16_t accuracy); 00851 uint8_t dmpSendAccel(uint_fast16_t elements, uint_fast16_t accuracy); 00852 uint8_t dmpSendLinearAccel(uint_fast16_t elements, uint_fast16_t accuracy); 00853 uint8_t dmpSendLinearAccelInWorld(uint_fast16_t elements, uint_fast16_t accuracy); 00854 uint8_t dmpSendControlData(uint_fast16_t elements, uint_fast16_t accuracy); 00855 uint8_t dmpSendSensorData(uint_fast16_t elements, uint_fast16_t accuracy); 00856 uint8_t dmpSendExternalSensorData(uint_fast16_t elements, uint_fast16_t accuracy); 00857 uint8_t dmpSendGravity(uint_fast16_t elements, uint_fast16_t accuracy); 00858 uint8_t dmpSendPacketNumber(uint_fast16_t accuracy); 00859 uint8_t dmpSendQuantizedAccel(uint_fast16_t elements, uint_fast16_t accuracy); 00860 uint8_t dmpSendEIS(uint_fast16_t elements, uint_fast16_t accuracy); 00861 00862 // Get Fixed Point data from FIFO 00863 uint8_t dmpGet6AxisQuaternion(int32_t *data, const uint8_t* packet=0); 00864 uint8_t dmpGet6AxisQuaternion(int16_t *data, const uint8_t* packet=0); 00865 uint8_t dmpGet6AxisQuaternion(Quaternion *q, const uint8_t* packet=0); 00866 uint8_t dmpGetRelativeQuaternion(int32_t *data, const uint8_t* packet=0); 00867 uint8_t dmpGetRelativeQuaternion(int16_t *data, const uint8_t* packet=0); 00868 uint8_t dmpGetRelativeQuaternion(Quaternion *data, const uint8_t* packet=0); 00869 uint8_t dmpGetGyro(VectorInt16 *v, const uint8_t* packet=0); 00870 uint8_t dmpSetLinearAccelFilterCoefficient(float coef); 00871 uint8_t dmpGetLinearAccel(int32_t *data, const uint8_t* packet=0); 00872 uint8_t dmpGetLinearAccel(int16_t *data, const uint8_t* packet=0); 00873 uint8_t dmpGetLinearAccel(VectorInt16 *v, const uint8_t* packet=0); 00874 uint8_t dmpGetLinearAccelInWorld(int32_t *data, const uint8_t* packet=0); 00875 uint8_t dmpGetLinearAccelInWorld(int16_t *data, const uint8_t* packet=0); 00876 uint8_t dmpGetLinearAccelInWorld(VectorInt16 *v, const uint8_t* packet=0); 00877 uint8_t dmpGetGyroAndAccelSensor(int32_t *data, const uint8_t* packet=0); 00878 uint8_t dmpGetGyroAndAccelSensor(int16_t *data, const uint8_t* packet=0); 00879 uint8_t dmpGetGyroAndAccelSensor(VectorInt16 *g, VectorInt16 *a, const uint8_t* packet=0); 00880 uint8_t dmpGetGyroSensor(int32_t *data, const uint8_t* packet=0); 00881 uint8_t dmpGetGyroSensor(int16_t *data, const uint8_t* packet=0); 00882 uint8_t dmpGetGyroSensor(VectorInt16 *v, const uint8_t* packet=0); 00883 uint8_t dmpGetControlData(int32_t *data, const uint8_t* packet=0); 00884 uint8_t dmpGetTemperature(int32_t *data, const uint8_t* packet=0); 00885 uint8_t dmpGetGravity(int32_t *data, const uint8_t* packet=0); 00886 uint8_t dmpGetGravity(int16_t *data, const uint8_t* packet=0); 00887 uint8_t dmpGetGravity(VectorInt16 *v, const uint8_t* packet=0); 00888 uint8_t dmpGetUnquantizedAccel(int32_t *data, const uint8_t* packet=0); 00889 uint8_t dmpGetUnquantizedAccel(int16_t *data, const uint8_t* packet=0); 00890 uint8_t dmpGetUnquantizedAccel(VectorInt16 *v, const uint8_t* packet=0); 00891 uint8_t dmpGetQuantizedAccel(int32_t *data, const uint8_t* packet=0); 00892 uint8_t dmpGetQuantizedAccel(int16_t *data, const uint8_t* packet=0); 00893 uint8_t dmpGetQuantizedAccel(VectorInt16 *v, const uint8_t* packet=0); 00894 uint8_t dmpGetExternalSensorData(int32_t *data, uint16_t size, const uint8_t* packet=0); 00895 uint8_t dmpGetEIS(int32_t *data, const uint8_t* packet=0); 00896 00897 // Get Floating Point data from FIFO 00898 uint8_t dmpGetAccelFloat(float *data, const uint8_t* packet=0); 00899 uint8_t dmpGetQuaternionFloat(float *data, const uint8_t* packet=0); 00900 00901 uint8_t dmpSetFIFOProcessedCallback(void (*func) (void)); 00902 00903 uint8_t dmpInitFIFOParam(); 00904 uint8_t dmpCloseFIFO(); 00905 uint8_t dmpSetGyroDataSource(uint8_t source); 00906 uint8_t dmpDecodeQuantizedAccel(); 00907 uint32_t dmpGetGyroSumOfSquare(); 00908 uint32_t dmpGetAccelSumOfSquare(); 00909 void dmpOverrideQuaternion(long *q); 00910 #endif 00911 00912 // special methods for MotionApps 4.1 implementation 00913 #ifdef MPU6050_INCLUDE_DMP_MOTIONAPPS41 00914 uint8_t *dmpPacketBuffer; 00915 uint16_t dmpPacketSize; 00916 00917 uint8_t dmpInitialize(); 00918 bool dmpPacketAvailable(); 00919 00920 uint8_t dmpSetFIFORate(uint8_t fifoRate); 00921 uint8_t dmpGetFIFORate(); 00922 uint8_t dmpGetSampleStepSizeMS(); 00923 uint8_t dmpGetSampleFrequency(); 00924 int32_t dmpDecodeTemperature(int8_t tempReg); 00925 00926 // Register callbacks after a packet of FIFO data is processed 00927 //uint8_t dmpRegisterFIFORateProcess(inv_obj_func func, int16_t priority); 00928 //uint8_t dmpUnregisterFIFORateProcess(inv_obj_func func); 00929 uint8_t dmpRunFIFORateProcesses(); 00930 00931 // Setup FIFO for various output 00932 uint8_t dmpSendQuaternion(uint_fast16_t accuracy); 00933 uint8_t dmpSendGyro(uint_fast16_t elements, uint_fast16_t accuracy); 00934 uint8_t dmpSendAccel(uint_fast16_t elements, uint_fast16_t accuracy); 00935 uint8_t dmpSendLinearAccel(uint_fast16_t elements, uint_fast16_t accuracy); 00936 uint8_t dmpSendLinearAccelInWorld(uint_fast16_t elements, uint_fast16_t accuracy); 00937 uint8_t dmpSendControlData(uint_fast16_t elements, uint_fast16_t accuracy); 00938 uint8_t dmpSendSensorData(uint_fast16_t elements, uint_fast16_t accuracy); 00939 uint8_t dmpSendExternalSensorData(uint_fast16_t elements, uint_fast16_t accuracy); 00940 uint8_t dmpSendGravity(uint_fast16_t elements, uint_fast16_t accuracy); 00941 uint8_t dmpSendPacketNumber(uint_fast16_t accuracy); 00942 uint8_t dmpSendQuantizedAccel(uint_fast16_t elements, uint_fast16_t accuracy); 00943 uint8_t dmpSendEIS(uint_fast16_t elements, uint_fast16_t accuracy); 00944 00945 // Get Fixed Point data from FIFO 00946 uint8_t dmpGetAccel(int32_t *data, const uint8_t* packet=0); 00947 uint8_t dmpGetAccel(int16_t *data, const uint8_t* packet=0); 00948 uint8_t dmpGetAccel(VectorInt16 *v, const uint8_t* packet=0); 00949 uint8_t dmpGetQuaternion(int32_t *data, const uint8_t* packet=0); 00950 uint8_t dmpGetQuaternion(int16_t *data, const uint8_t* packet=0); 00951 uint8_t dmpGetQuaternion(Quaternion *q, const uint8_t* packet=0); 00952 uint8_t dmpGet6AxisQuaternion(int32_t *data, const uint8_t* packet=0); 00953 uint8_t dmpGet6AxisQuaternion(int16_t *data, const uint8_t* packet=0); 00954 uint8_t dmpGet6AxisQuaternion(Quaternion *q, const uint8_t* packet=0); 00955 uint8_t dmpGetRelativeQuaternion(int32_t *data, const uint8_t* packet=0); 00956 uint8_t dmpGetRelativeQuaternion(int16_t *data, const uint8_t* packet=0); 00957 uint8_t dmpGetRelativeQuaternion(Quaternion *data, const uint8_t* packet=0); 00958 uint8_t dmpGetGyro(int32_t *data, const uint8_t* packet=0); 00959 uint8_t dmpGetGyro(int16_t *data, const uint8_t* packet=0); 00960 uint8_t dmpGetGyro(VectorInt16 *v, const uint8_t* packet=0); 00961 uint8_t dmpGetMag(int16_t *data, const uint8_t* packet=0); 00962 uint8_t dmpSetLinearAccelFilterCoefficient(float coef); 00963 uint8_t dmpGetLinearAccel(int32_t *data, const uint8_t* packet=0); 00964 uint8_t dmpGetLinearAccel(int16_t *data, const uint8_t* packet=0); 00965 uint8_t dmpGetLinearAccel(VectorInt16 *v, const uint8_t* packet=0); 00966 uint8_t dmpGetLinearAccel(VectorInt16 *v, VectorInt16 *vRaw, VectorFloat *gravity); 00967 uint8_t dmpGetLinearAccelInWorld(int32_t *data, const uint8_t* packet=0); 00968 uint8_t dmpGetLinearAccelInWorld(int16_t *data, const uint8_t* packet=0); 00969 uint8_t dmpGetLinearAccelInWorld(VectorInt16 *v, const uint8_t* packet=0); 00970 uint8_t dmpGetLinearAccelInWorld(VectorInt16 *v, VectorInt16 *vReal, Quaternion *q); 00971 uint8_t dmpGetGyroAndAccelSensor(int32_t *data, const uint8_t* packet=0); 00972 uint8_t dmpGetGyroAndAccelSensor(int16_t *data, const uint8_t* packet=0); 00973 uint8_t dmpGetGyroAndAccelSensor(VectorInt16 *g, VectorInt16 *a, const uint8_t* packet=0); 00974 uint8_t dmpGetGyroSensor(int32_t *data, const uint8_t* packet=0); 00975 uint8_t dmpGetGyroSensor(int16_t *data, const uint8_t* packet=0); 00976 uint8_t dmpGetGyroSensor(VectorInt16 *v, const uint8_t* packet=0); 00977 uint8_t dmpGetControlData(int32_t *data, const uint8_t* packet=0); 00978 uint8_t dmpGetTemperature(int32_t *data, const uint8_t* packet=0); 00979 uint8_t dmpGetGravity(int32_t *data, const uint8_t* packet=0); 00980 uint8_t dmpGetGravity(int16_t *data, const uint8_t* packet=0); 00981 uint8_t dmpGetGravity(VectorInt16 *v, const uint8_t* packet=0); 00982 uint8_t dmpGetGravity(VectorFloat *v, Quaternion *q); 00983 uint8_t dmpGetUnquantizedAccel(int32_t *data, const uint8_t* packet=0); 00984 uint8_t dmpGetUnquantizedAccel(int16_t *data, const uint8_t* packet=0); 00985 uint8_t dmpGetUnquantizedAccel(VectorInt16 *v, const uint8_t* packet=0); 00986 uint8_t dmpGetQuantizedAccel(int32_t *data, const uint8_t* packet=0); 00987 uint8_t dmpGetQuantizedAccel(int16_t *data, const uint8_t* packet=0); 00988 uint8_t dmpGetQuantizedAccel(VectorInt16 *v, const uint8_t* packet=0); 00989 uint8_t dmpGetExternalSensorData(int32_t *data, uint16_t size, const uint8_t* packet=0); 00990 uint8_t dmpGetEIS(int32_t *data, const uint8_t* packet=0); 00991 00992 uint8_t dmpGetEuler(float *data, Quaternion *q); 00993 uint8_t dmpGetYawPitchRoll(float *data, Quaternion *q, VectorFloat *gravity); 00994 00995 // Get Floating Point data from FIFO 00996 uint8_t dmpGetAccelFloat(float *data, const uint8_t* packet=0); 00997 uint8_t dmpGetQuaternionFloat(float *data, const uint8_t* packet=0); 00998 00999 uint8_t dmpProcessFIFOPacket(const unsigned char *dmpData); 01000 uint8_t dmpReadAndProcessFIFOPacket(uint8_t numPackets, uint8_t *processed=NULL); 01001 01002 uint8_t dmpSetFIFOProcessedCallback(void (*func) (void)); 01003 01004 uint8_t dmpInitFIFOParam(); 01005 uint8_t dmpCloseFIFO(); 01006 uint8_t dmpSetGyroDataSource(uint8_t source); 01007 uint8_t dmpDecodeQuantizedAccel(); 01008 uint32_t dmpGetGyroSumOfSquare(); 01009 uint32_t dmpGetAccelSumOfSquare(); 01010 void dmpOverrideQuaternion(long *q); 01011 uint16_t dmpGetFIFOPacketSize(); 01012 #endif 01013 01014 private: 01015 uint8_t devAddr; 01016 uint8_t buffer[14]; 01017 }; 01018 01019 #endif /* _MPU6050_H_ */
Generated on Thu Jul 14 2022 01:27:45 by 1.7.2