Segue

Fork of MPU6050 by Simon Garfieldsg

Committer:
Gaetios
Date:
Mon Oct 02 16:42:34 2017 +0000
Revision:
2:85734ad35573
foi alterado para utilizar 4 acelerometros

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Gaetios 2:85734ad35573 1 //ported from arduino library: https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050
Gaetios 2:85734ad35573 2 //written by szymon gaertig (email: szymon@gaertig.com.pl)
Gaetios 2:85734ad35573 3 //
Gaetios 2:85734ad35573 4 //Changelog:
Gaetios 2:85734ad35573 5 //2013-01-08 - first beta release
Gaetios 2:85734ad35573 6
Gaetios 2:85734ad35573 7 // I2Cdev library collection - MPU6050 I2C device class
Gaetios 2:85734ad35573 8 // Based on InvenSense MPU-6050 register map document rev. 2.0, 5/19/2011 (RM-MPU-6000A-00)
Gaetios 2:85734ad35573 9 // 10/3/2011 by Jeff Rowberg <jeff@rowberg.net>
Gaetios 2:85734ad35573 10 // Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib
Gaetios 2:85734ad35573 11 //
Gaetios 2:85734ad35573 12 // Changelog:
Gaetios 2:85734ad35573 13 // ... - ongoing debug release
Gaetios 2:85734ad35573 14
Gaetios 2:85734ad35573 15 // NOTE: THIS IS ONLY A PARIAL RELEASE. THIS DEVICE CLASS IS CURRENTLY UNDERGOING ACTIVE
Gaetios 2:85734ad35573 16 // DEVELOPMENT AND IS STILL MISSING SOME IMPORTANT FEATURES. PLEASE KEEP THIS IN MIND IF
Gaetios 2:85734ad35573 17 // YOU DECIDE TO USE THIS PARTICULAR CODE FOR ANYTHING.
Gaetios 2:85734ad35573 18
Gaetios 2:85734ad35573 19 /* ============================================
Gaetios 2:85734ad35573 20 I2Cdev device library code is placed under the MIT license
Gaetios 2:85734ad35573 21 Copyright (c) 2012 Jeff Rowberg
Gaetios 2:85734ad35573 22
Gaetios 2:85734ad35573 23 Permission is hereby granted, free of charge, to any person obtaining a copy
Gaetios 2:85734ad35573 24 of this software and associated documentation files (the "Software"), to deal
Gaetios 2:85734ad35573 25 in the Software without restriction, including without limitation the rights
Gaetios 2:85734ad35573 26 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
Gaetios 2:85734ad35573 27 copies of the Software, and to permit persons to whom the Software is
Gaetios 2:85734ad35573 28 furnished to do so, subject to the following conditions:
Gaetios 2:85734ad35573 29
Gaetios 2:85734ad35573 30 The above copyright notice and this permission notice shall be included in
Gaetios 2:85734ad35573 31 all copies or substantial portions of the Software.
Gaetios 2:85734ad35573 32
Gaetios 2:85734ad35573 33 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Gaetios 2:85734ad35573 34 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Gaetios 2:85734ad35573 35 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Gaetios 2:85734ad35573 36 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Gaetios 2:85734ad35573 37 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Gaetios 2:85734ad35573 38 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
Gaetios 2:85734ad35573 39 THE SOFTWARE.
Gaetios 2:85734ad35573 40 ===============================================
Gaetios 2:85734ad35573 41 */
Gaetios 2:85734ad35573 42
Gaetios 2:85734ad35573 43 #ifndef _MPU60502_H_
Gaetios 2:85734ad35573 44 #define _MPU60502_H_
Gaetios 2:85734ad35573 45
Gaetios 2:85734ad35573 46 #include "I2C1dev.h"
Gaetios 2:85734ad35573 47 #include "helper_3dmath.h"
Gaetios 2:85734ad35573 48
Gaetios 2:85734ad35573 49 #define MPU6050_ADDRESS_AD0_LOW 0x68 // address pin low (GND), default for InvenSense evaluation board
Gaetios 2:85734ad35573 50 #define MPU6050_ADDRESS_AD0_HIGH 0x69 // address pin high (VCC)
Gaetios 2:85734ad35573 51 #define MPU6050_DEFAULT_ADDRESS MPU6050_ADDRESS_AD0_LOW
Gaetios 2:85734ad35573 52
Gaetios 2:85734ad35573 53 #define MPU6050_RA_XG_OFFS_TC 0x00 //[7] PWR_MODE, [6:1] XG_OFFS_TC, [0] OTP_BNK_VLD
Gaetios 2:85734ad35573 54 #define MPU6050_RA_YG_OFFS_TC 0x01 //[7] PWR_MODE, [6:1] YG_OFFS_TC, [0] OTP_BNK_VLD
Gaetios 2:85734ad35573 55 #define MPU6050_RA_ZG_OFFS_TC 0x02 //[7] PWR_MODE, [6:1] ZG_OFFS_TC, [0] OTP_BNK_VLD
Gaetios 2:85734ad35573 56 #define MPU6050_RA_X_FINE_GAIN 0x03 //[7:0] X_FINE_GAIN
Gaetios 2:85734ad35573 57 #define MPU6050_RA_Y_FINE_GAIN 0x04 //[7:0] Y_FINE_GAIN
Gaetios 2:85734ad35573 58 #define MPU6050_RA_Z_FINE_GAIN 0x05 //[7:0] Z_FINE_GAIN
Gaetios 2:85734ad35573 59 #define MPU6050_RA_XA_OFFS_H 0x06 //[15:0] XA_OFFS
Gaetios 2:85734ad35573 60 #define MPU6050_RA_XA_OFFS_L_TC 0x07
Gaetios 2:85734ad35573 61 #define MPU6050_RA_YA_OFFS_H 0x08 //[15:0] YA_OFFS
Gaetios 2:85734ad35573 62 #define MPU6050_RA_YA_OFFS_L_TC 0x09
Gaetios 2:85734ad35573 63 #define MPU6050_RA_ZA_OFFS_H 0x0A //[15:0] ZA_OFFS
Gaetios 2:85734ad35573 64 #define MPU6050_RA_ZA_OFFS_L_TC 0x0B
Gaetios 2:85734ad35573 65 #define MPU6050_RA_XG_OFFS_USRH 0x13 //[15:0] XG_OFFS_USR
Gaetios 2:85734ad35573 66 #define MPU6050_RA_XG_OFFS_USRL 0x14
Gaetios 2:85734ad35573 67 #define MPU6050_RA_YG_OFFS_USRH 0x15 //[15:0] YG_OFFS_USR
Gaetios 2:85734ad35573 68 #define MPU6050_RA_YG_OFFS_USRL 0x16
Gaetios 2:85734ad35573 69 #define MPU6050_RA_ZG_OFFS_USRH 0x17 //[15:0] ZG_OFFS_USR
Gaetios 2:85734ad35573 70 #define MPU6050_RA_ZG_OFFS_USRL 0x18
Gaetios 2:85734ad35573 71 #define MPU6050_RA_SMPLRT_DIV 0x19
Gaetios 2:85734ad35573 72 #define MPU6050_RA_CONFIG 0x1A
Gaetios 2:85734ad35573 73 #define MPU6050_RA_GYRO_CONFIG 0x1B
Gaetios 2:85734ad35573 74 #define MPU6050_RA_ACCEL_CONFIG 0x1C
Gaetios 2:85734ad35573 75 #define MPU6050_RA_FF_THR 0x1D
Gaetios 2:85734ad35573 76 #define MPU6050_RA_FF_DUR 0x1E
Gaetios 2:85734ad35573 77 #define MPU6050_RA_MOT_THR 0x1F
Gaetios 2:85734ad35573 78 #define MPU6050_RA_MOT_DUR 0x20
Gaetios 2:85734ad35573 79 #define MPU6050_RA_ZRMOT_THR 0x21
Gaetios 2:85734ad35573 80 #define MPU6050_RA_ZRMOT_DUR 0x22
Gaetios 2:85734ad35573 81 #define MPU6050_RA_FIFO_EN 0x23
Gaetios 2:85734ad35573 82 #define MPU6050_RA_I2C_MST_CTRL 0x24
Gaetios 2:85734ad35573 83 #define MPU6050_RA_I2C_SLV0_ADDR 0x25
Gaetios 2:85734ad35573 84 #define MPU6050_RA_I2C_SLV0_REG 0x26
Gaetios 2:85734ad35573 85 #define MPU6050_RA_I2C_SLV0_CTRL 0x27
Gaetios 2:85734ad35573 86 #define MPU6050_RA_I2C_SLV1_ADDR 0x28
Gaetios 2:85734ad35573 87 #define MPU6050_RA_I2C_SLV1_REG 0x29
Gaetios 2:85734ad35573 88 #define MPU6050_RA_I2C_SLV1_CTRL 0x2A
Gaetios 2:85734ad35573 89 #define MPU6050_RA_I2C_SLV2_ADDR 0x2B
Gaetios 2:85734ad35573 90 #define MPU6050_RA_I2C_SLV2_REG 0x2C
Gaetios 2:85734ad35573 91 #define MPU6050_RA_I2C_SLV2_CTRL 0x2D
Gaetios 2:85734ad35573 92 #define MPU6050_RA_I2C_SLV3_ADDR 0x2E
Gaetios 2:85734ad35573 93 #define MPU6050_RA_I2C_SLV3_REG 0x2F
Gaetios 2:85734ad35573 94 #define MPU6050_RA_I2C_SLV3_CTRL 0x30
Gaetios 2:85734ad35573 95 #define MPU6050_RA_I2C_SLV4_ADDR 0x31
Gaetios 2:85734ad35573 96 #define MPU6050_RA_I2C_SLV4_REG 0x32
Gaetios 2:85734ad35573 97 #define MPU6050_RA_I2C_SLV4_DO 0x33
Gaetios 2:85734ad35573 98 #define MPU6050_RA_I2C_SLV4_CTRL 0x34
Gaetios 2:85734ad35573 99 #define MPU6050_RA_I2C_SLV4_DI 0x35
Gaetios 2:85734ad35573 100 #define MPU6050_RA_I2C_MST_STATUS 0x36
Gaetios 2:85734ad35573 101 #define MPU6050_RA_INT_PIN_CFG 0x37
Gaetios 2:85734ad35573 102 #define MPU6050_RA_INT_ENABLE 0x38
Gaetios 2:85734ad35573 103 #define MPU6050_RA_DMP_INT_STATUS 0x39
Gaetios 2:85734ad35573 104 #define MPU6050_RA_INT_STATUS 0x3A
Gaetios 2:85734ad35573 105 #define MPU6050_RA_ACCEL_XOUT_H 0x3B
Gaetios 2:85734ad35573 106 #define MPU6050_RA_ACCEL_XOUT_L 0x3C
Gaetios 2:85734ad35573 107 #define MPU6050_RA_ACCEL_YOUT_H 0x3D
Gaetios 2:85734ad35573 108 #define MPU6050_RA_ACCEL_YOUT_L 0x3E
Gaetios 2:85734ad35573 109 #define MPU6050_RA_ACCEL_ZOUT_H 0x3F
Gaetios 2:85734ad35573 110 #define MPU6050_RA_ACCEL_ZOUT_L 0x40
Gaetios 2:85734ad35573 111 #define MPU6050_RA_TEMP_OUT_H 0x41
Gaetios 2:85734ad35573 112 #define MPU6050_RA_TEMP_OUT_L 0x42
Gaetios 2:85734ad35573 113 #define MPU6050_RA_GYRO_XOUT_H 0x43
Gaetios 2:85734ad35573 114 #define MPU6050_RA_GYRO_XOUT_L 0x44
Gaetios 2:85734ad35573 115 #define MPU6050_RA_GYRO_YOUT_H 0x45
Gaetios 2:85734ad35573 116 #define MPU6050_RA_GYRO_YOUT_L 0x46
Gaetios 2:85734ad35573 117 #define MPU6050_RA_GYRO_ZOUT_H 0x47
Gaetios 2:85734ad35573 118 #define MPU6050_RA_GYRO_ZOUT_L 0x48
Gaetios 2:85734ad35573 119 #define MPU6050_RA_EXT_SENS_DATA_00 0x49
Gaetios 2:85734ad35573 120 #define MPU6050_RA_EXT_SENS_DATA_01 0x4A
Gaetios 2:85734ad35573 121 #define MPU6050_RA_EXT_SENS_DATA_02 0x4B
Gaetios 2:85734ad35573 122 #define MPU6050_RA_EXT_SENS_DATA_03 0x4C
Gaetios 2:85734ad35573 123 #define MPU6050_RA_EXT_SENS_DATA_04 0x4D
Gaetios 2:85734ad35573 124 #define MPU6050_RA_EXT_SENS_DATA_05 0x4E
Gaetios 2:85734ad35573 125 #define MPU6050_RA_EXT_SENS_DATA_06 0x4F
Gaetios 2:85734ad35573 126 #define MPU6050_RA_EXT_SENS_DATA_07 0x50
Gaetios 2:85734ad35573 127 #define MPU6050_RA_EXT_SENS_DATA_08 0x51
Gaetios 2:85734ad35573 128 #define MPU6050_RA_EXT_SENS_DATA_09 0x52
Gaetios 2:85734ad35573 129 #define MPU6050_RA_EXT_SENS_DATA_10 0x53
Gaetios 2:85734ad35573 130 #define MPU6050_RA_EXT_SENS_DATA_11 0x54
Gaetios 2:85734ad35573 131 #define MPU6050_RA_EXT_SENS_DATA_12 0x55
Gaetios 2:85734ad35573 132 #define MPU6050_RA_EXT_SENS_DATA_13 0x56
Gaetios 2:85734ad35573 133 #define MPU6050_RA_EXT_SENS_DATA_14 0x57
Gaetios 2:85734ad35573 134 #define MPU6050_RA_EXT_SENS_DATA_15 0x58
Gaetios 2:85734ad35573 135 #define MPU6050_RA_EXT_SENS_DATA_16 0x59
Gaetios 2:85734ad35573 136 #define MPU6050_RA_EXT_SENS_DATA_17 0x5A
Gaetios 2:85734ad35573 137 #define MPU6050_RA_EXT_SENS_DATA_18 0x5B
Gaetios 2:85734ad35573 138 #define MPU6050_RA_EXT_SENS_DATA_19 0x5C
Gaetios 2:85734ad35573 139 #define MPU6050_RA_EXT_SENS_DATA_20 0x5D
Gaetios 2:85734ad35573 140 #define MPU6050_RA_EXT_SENS_DATA_21 0x5E
Gaetios 2:85734ad35573 141 #define MPU6050_RA_EXT_SENS_DATA_22 0x5F
Gaetios 2:85734ad35573 142 #define MPU6050_RA_EXT_SENS_DATA_23 0x60
Gaetios 2:85734ad35573 143 #define MPU6050_RA_MOT_DETECT_STATUS 0x61
Gaetios 2:85734ad35573 144 #define MPU6050_RA_I2C_SLV0_DO 0x63
Gaetios 2:85734ad35573 145 #define MPU6050_RA_I2C_SLV1_DO 0x64
Gaetios 2:85734ad35573 146 #define MPU6050_RA_I2C_SLV2_DO 0x65
Gaetios 2:85734ad35573 147 #define MPU6050_RA_I2C_SLV3_DO 0x66
Gaetios 2:85734ad35573 148 #define MPU6050_RA_I2C_MST_DELAY_CTRL 0x67
Gaetios 2:85734ad35573 149 #define MPU6050_RA_SIGNAL_PATH_RESET 0x68
Gaetios 2:85734ad35573 150 #define MPU6050_RA_MOT_DETECT_CTRL 0x69
Gaetios 2:85734ad35573 151 #define MPU6050_RA_USER_CTRL 0x6A
Gaetios 2:85734ad35573 152 #define MPU6050_RA_PWR_MGMT_1 0x6B
Gaetios 2:85734ad35573 153 #define MPU6050_RA_PWR_MGMT_2 0x6C
Gaetios 2:85734ad35573 154 #define MPU6050_RA_BANK_SEL 0x6D
Gaetios 2:85734ad35573 155 #define MPU6050_RA_MEM_START_ADDR 0x6E
Gaetios 2:85734ad35573 156 #define MPU6050_RA_MEM_R_W 0x6F
Gaetios 2:85734ad35573 157 #define MPU6050_RA_DMP_CFG_1 0x70
Gaetios 2:85734ad35573 158 #define MPU6050_RA_DMP_CFG_2 0x71
Gaetios 2:85734ad35573 159 #define MPU6050_RA_FIFO_COUNTH 0x72
Gaetios 2:85734ad35573 160 #define MPU6050_RA_FIFO_COUNTL 0x73
Gaetios 2:85734ad35573 161 #define MPU6050_RA_FIFO_R_W 0x74
Gaetios 2:85734ad35573 162 #define MPU6050_RA_WHO_AM_I 0x75
Gaetios 2:85734ad35573 163
Gaetios 2:85734ad35573 164 #define MPU6050_TC_PWR_MODE_BIT 7
Gaetios 2:85734ad35573 165 #define MPU6050_TC_OFFSET_BIT 6
Gaetios 2:85734ad35573 166 #define MPU6050_TC_OFFSET_LENGTH 6
Gaetios 2:85734ad35573 167 #define MPU6050_TC_OTP_BNK_VLD_BIT 0
Gaetios 2:85734ad35573 168
Gaetios 2:85734ad35573 169 #define MPU6050_VDDIO_LEVEL_VLOGIC 0
Gaetios 2:85734ad35573 170 #define MPU6050_VDDIO_LEVEL_VDD 1
Gaetios 2:85734ad35573 171
Gaetios 2:85734ad35573 172 #define MPU6050_CFG_EXT_SYNC_SET_BIT 5
Gaetios 2:85734ad35573 173 #define MPU6050_CFG_EXT_SYNC_SET_LENGTH 3
Gaetios 2:85734ad35573 174 #define MPU6050_CFG_DLPF_CFG_BIT 2
Gaetios 2:85734ad35573 175 #define MPU6050_CFG_DLPF_CFG_LENGTH 3
Gaetios 2:85734ad35573 176
Gaetios 2:85734ad35573 177 #define MPU6050_EXT_SYNC_DISABLED 0x0
Gaetios 2:85734ad35573 178 #define MPU6050_EXT_SYNC_TEMP_OUT_L 0x1
Gaetios 2:85734ad35573 179 #define MPU6050_EXT_SYNC_GYRO_XOUT_L 0x2
Gaetios 2:85734ad35573 180 #define MPU6050_EXT_SYNC_GYRO_YOUT_L 0x3
Gaetios 2:85734ad35573 181 #define MPU6050_EXT_SYNC_GYRO_ZOUT_L 0x4
Gaetios 2:85734ad35573 182 #define MPU6050_EXT_SYNC_ACCEL_XOUT_L 0x5
Gaetios 2:85734ad35573 183 #define MPU6050_EXT_SYNC_ACCEL_YOUT_L 0x6
Gaetios 2:85734ad35573 184 #define MPU6050_EXT_SYNC_ACCEL_ZOUT_L 0x7
Gaetios 2:85734ad35573 185
Gaetios 2:85734ad35573 186 #define MPU6050_DLPF_BW_256 0x00
Gaetios 2:85734ad35573 187 #define MPU6050_DLPF_BW_188 0x01
Gaetios 2:85734ad35573 188 #define MPU6050_DLPF_BW_98 0x02
Gaetios 2:85734ad35573 189 #define MPU6050_DLPF_BW_42 0x03
Gaetios 2:85734ad35573 190 #define MPU6050_DLPF_BW_20 0x04
Gaetios 2:85734ad35573 191 #define MPU6050_DLPF_BW_10 0x05
Gaetios 2:85734ad35573 192 #define MPU6050_DLPF_BW_5 0x06
Gaetios 2:85734ad35573 193
Gaetios 2:85734ad35573 194 #define MPU6050_GCONFIG_FS_SEL_BIT 4
Gaetios 2:85734ad35573 195 #define MPU6050_GCONFIG_FS_SEL_LENGTH 2
Gaetios 2:85734ad35573 196
Gaetios 2:85734ad35573 197 #define MPU6050_GYRO_FS_250 0x00
Gaetios 2:85734ad35573 198 #define MPU6050_GYRO_FS_500 0x01
Gaetios 2:85734ad35573 199 #define MPU6050_GYRO_FS_1000 0x02
Gaetios 2:85734ad35573 200 #define MPU6050_GYRO_FS_2000 0x03
Gaetios 2:85734ad35573 201
Gaetios 2:85734ad35573 202 #define MPU6050_ACONFIG_XA_ST_BIT 7
Gaetios 2:85734ad35573 203 #define MPU6050_ACONFIG_YA_ST_BIT 6
Gaetios 2:85734ad35573 204 #define MPU6050_ACONFIG_ZA_ST_BIT 5
Gaetios 2:85734ad35573 205 #define MPU6050_ACONFIG_AFS_SEL_BIT 4
Gaetios 2:85734ad35573 206 #define MPU6050_ACONFIG_AFS_SEL_LENGTH 2
Gaetios 2:85734ad35573 207 #define MPU6050_ACONFIG_ACCEL_HPF_BIT 2
Gaetios 2:85734ad35573 208 #define MPU6050_ACONFIG_ACCEL_HPF_LENGTH 3
Gaetios 2:85734ad35573 209
Gaetios 2:85734ad35573 210 #define MPU6050_ACCEL_FS_2 0x00
Gaetios 2:85734ad35573 211 #define MPU6050_ACCEL_FS_4 0x01
Gaetios 2:85734ad35573 212 #define MPU6050_ACCEL_FS_8 0x02
Gaetios 2:85734ad35573 213 #define MPU6050_ACCEL_FS_16 0x03
Gaetios 2:85734ad35573 214
Gaetios 2:85734ad35573 215 #define MPU6050_DHPF_RESET 0x00
Gaetios 2:85734ad35573 216 #define MPU6050_DHPF_5 0x01
Gaetios 2:85734ad35573 217 #define MPU6050_DHPF_2P5 0x02
Gaetios 2:85734ad35573 218 #define MPU6050_DHPF_1P25 0x03
Gaetios 2:85734ad35573 219 #define MPU6050_DHPF_0P63 0x04
Gaetios 2:85734ad35573 220 #define MPU6050_DHPF_HOLD 0x07
Gaetios 2:85734ad35573 221
Gaetios 2:85734ad35573 222 #define MPU6050_TEMP_FIFO_EN_BIT 7
Gaetios 2:85734ad35573 223 #define MPU6050_XG_FIFO_EN_BIT 6
Gaetios 2:85734ad35573 224 #define MPU6050_YG_FIFO_EN_BIT 5
Gaetios 2:85734ad35573 225 #define MPU6050_ZG_FIFO_EN_BIT 4
Gaetios 2:85734ad35573 226 #define MPU6050_ACCEL_FIFO_EN_BIT 3
Gaetios 2:85734ad35573 227 #define MPU6050_SLV2_FIFO_EN_BIT 2
Gaetios 2:85734ad35573 228 #define MPU6050_SLV1_FIFO_EN_BIT 1
Gaetios 2:85734ad35573 229 #define MPU6050_SLV0_FIFO_EN_BIT 0
Gaetios 2:85734ad35573 230
Gaetios 2:85734ad35573 231 #define MPU6050_MULT_MST_EN_BIT 7
Gaetios 2:85734ad35573 232 #define MPU6050_WAIT_FOR_ES_BIT 6
Gaetios 2:85734ad35573 233 #define MPU6050_SLV_3_FIFO_EN_BIT 5
Gaetios 2:85734ad35573 234 #define MPU6050_I2C_MST_P_NSR_BIT 4
Gaetios 2:85734ad35573 235 #define MPU6050_I2C_MST_CLK_BIT 3
Gaetios 2:85734ad35573 236 #define MPU6050_I2C_MST_CLK_LENGTH 4
Gaetios 2:85734ad35573 237
Gaetios 2:85734ad35573 238 #define MPU6050_CLOCK_DIV_348 0x0
Gaetios 2:85734ad35573 239 #define MPU6050_CLOCK_DIV_333 0x1
Gaetios 2:85734ad35573 240 #define MPU6050_CLOCK_DIV_320 0x2
Gaetios 2:85734ad35573 241 #define MPU6050_CLOCK_DIV_308 0x3
Gaetios 2:85734ad35573 242 #define MPU6050_CLOCK_DIV_296 0x4
Gaetios 2:85734ad35573 243 #define MPU6050_CLOCK_DIV_286 0x5
Gaetios 2:85734ad35573 244 #define MPU6050_CLOCK_DIV_276 0x6
Gaetios 2:85734ad35573 245 #define MPU6050_CLOCK_DIV_267 0x7
Gaetios 2:85734ad35573 246 #define MPU6050_CLOCK_DIV_258 0x8
Gaetios 2:85734ad35573 247 #define MPU6050_CLOCK_DIV_500 0x9
Gaetios 2:85734ad35573 248 #define MPU6050_CLOCK_DIV_471 0xA
Gaetios 2:85734ad35573 249 #define MPU6050_CLOCK_DIV_444 0xB
Gaetios 2:85734ad35573 250 #define MPU6050_CLOCK_DIV_421 0xC
Gaetios 2:85734ad35573 251 #define MPU6050_CLOCK_DIV_400 0xD
Gaetios 2:85734ad35573 252 #define MPU6050_CLOCK_DIV_381 0xE
Gaetios 2:85734ad35573 253 #define MPU6050_CLOCK_DIV_364 0xF
Gaetios 2:85734ad35573 254
Gaetios 2:85734ad35573 255 #define MPU6050_I2C_SLV_RW_BIT 7
Gaetios 2:85734ad35573 256 #define MPU6050_I2C_SLV_ADDR_BIT 6
Gaetios 2:85734ad35573 257 #define MPU6050_I2C_SLV_ADDR_LENGTH 7
Gaetios 2:85734ad35573 258 #define MPU6050_I2C_SLV_EN_BIT 7
Gaetios 2:85734ad35573 259 #define MPU6050_I2C_SLV_BYTE_SW_BIT 6
Gaetios 2:85734ad35573 260 #define MPU6050_I2C_SLV_REG_DIS_BIT 5
Gaetios 2:85734ad35573 261 #define MPU6050_I2C_SLV_GRP_BIT 4
Gaetios 2:85734ad35573 262 #define MPU6050_I2C_SLV_LEN_BIT 3
Gaetios 2:85734ad35573 263 #define MPU6050_I2C_SLV_LEN_LENGTH 4
Gaetios 2:85734ad35573 264
Gaetios 2:85734ad35573 265 #define MPU6050_I2C_SLV4_RW_BIT 7
Gaetios 2:85734ad35573 266 #define MPU6050_I2C_SLV4_ADDR_BIT 6
Gaetios 2:85734ad35573 267 #define MPU6050_I2C_SLV4_ADDR_LENGTH 7
Gaetios 2:85734ad35573 268 #define MPU6050_I2C_SLV4_EN_BIT 7
Gaetios 2:85734ad35573 269 #define MPU6050_I2C_SLV4_INT_EN_BIT 6
Gaetios 2:85734ad35573 270 #define MPU6050_I2C_SLV4_REG_DIS_BIT 5
Gaetios 2:85734ad35573 271 #define MPU6050_I2C_SLV4_MST_DLY_BIT 4
Gaetios 2:85734ad35573 272 #define MPU6050_I2C_SLV4_MST_DLY_LENGTH 5
Gaetios 2:85734ad35573 273
Gaetios 2:85734ad35573 274 #define MPU6050_MST_PASS_THROUGH_BIT 7
Gaetios 2:85734ad35573 275 #define MPU6050_MST_I2C_SLV4_DONE_BIT 6
Gaetios 2:85734ad35573 276 #define MPU6050_MST_I2C_LOST_ARB_BIT 5
Gaetios 2:85734ad35573 277 #define MPU6050_MST_I2C_SLV4_NACK_BIT 4
Gaetios 2:85734ad35573 278 #define MPU6050_MST_I2C_SLV3_NACK_BIT 3
Gaetios 2:85734ad35573 279 #define MPU6050_MST_I2C_SLV2_NACK_BIT 2
Gaetios 2:85734ad35573 280 #define MPU6050_MST_I2C_SLV1_NACK_BIT 1
Gaetios 2:85734ad35573 281 #define MPU6050_MST_I2C_SLV0_NACK_BIT 0
Gaetios 2:85734ad35573 282
Gaetios 2:85734ad35573 283 #define MPU6050_INTCFG_INT_LEVEL_BIT 7
Gaetios 2:85734ad35573 284 #define MPU6050_INTCFG_INT_OPEN_BIT 6
Gaetios 2:85734ad35573 285 #define MPU6050_INTCFG_LATCH_INT_EN_BIT 5
Gaetios 2:85734ad35573 286 #define MPU6050_INTCFG_INT_RD_CLEAR_BIT 4
Gaetios 2:85734ad35573 287 #define MPU6050_INTCFG_FSYNC_INT_LEVEL_BIT 3
Gaetios 2:85734ad35573 288 #define MPU6050_INTCFG_FSYNC_INT_EN_BIT 2
Gaetios 2:85734ad35573 289 #define MPU6050_INTCFG_I2C_BYPASS_EN_BIT 1
Gaetios 2:85734ad35573 290 #define MPU6050_INTCFG_CLKOUT_EN_BIT 0
Gaetios 2:85734ad35573 291
Gaetios 2:85734ad35573 292 #define MPU6050_INTMODE_ACTIVEHIGH 0x00
Gaetios 2:85734ad35573 293 #define MPU6050_INTMODE_ACTIVELOW 0x01
Gaetios 2:85734ad35573 294
Gaetios 2:85734ad35573 295 #define MPU6050_INTDRV_PUSHPULL 0x00
Gaetios 2:85734ad35573 296 #define MPU6050_INTDRV_OPENDRAIN 0x01
Gaetios 2:85734ad35573 297
Gaetios 2:85734ad35573 298 #define MPU6050_INTLATCH_50USPULSE 0x00
Gaetios 2:85734ad35573 299 #define MPU6050_INTLATCH_WAITCLEAR 0x01
Gaetios 2:85734ad35573 300
Gaetios 2:85734ad35573 301 #define MPU6050_INTCLEAR_STATUSREAD 0x00
Gaetios 2:85734ad35573 302 #define MPU6050_INTCLEAR_ANYREAD 0x01
Gaetios 2:85734ad35573 303
Gaetios 2:85734ad35573 304 #define MPU6050_INTERRUPT_FF_BIT 7
Gaetios 2:85734ad35573 305 #define MPU6050_INTERRUPT_MOT_BIT 6
Gaetios 2:85734ad35573 306 #define MPU6050_INTERRUPT_ZMOT_BIT 5
Gaetios 2:85734ad35573 307 #define MPU6050_INTERRUPT_FIFO_OFLOW_BIT 4
Gaetios 2:85734ad35573 308 #define MPU6050_INTERRUPT_I2C_MST_INT_BIT 3
Gaetios 2:85734ad35573 309 #define MPU6050_INTERRUPT_PLL_RDY_INT_BIT 2
Gaetios 2:85734ad35573 310 #define MPU6050_INTERRUPT_DMP_INT_BIT 1
Gaetios 2:85734ad35573 311 #define MPU6050_INTERRUPT_DATA_RDY_BIT 0
Gaetios 2:85734ad35573 312
Gaetios 2:85734ad35573 313 // TODO: figure out what these actually do
Gaetios 2:85734ad35573 314 // UMPL source code is not very obivous
Gaetios 2:85734ad35573 315 #define MPU6050_DMPINT_5_BIT 5
Gaetios 2:85734ad35573 316 #define MPU6050_DMPINT_4_BIT 4
Gaetios 2:85734ad35573 317 #define MPU6050_DMPINT_3_BIT 3
Gaetios 2:85734ad35573 318 #define MPU6050_DMPINT_2_BIT 2
Gaetios 2:85734ad35573 319 #define MPU6050_DMPINT_1_BIT 1
Gaetios 2:85734ad35573 320 #define MPU6050_DMPINT_0_BIT 0
Gaetios 2:85734ad35573 321
Gaetios 2:85734ad35573 322 #define MPU6050_MOTION_MOT_XNEG_BIT 7
Gaetios 2:85734ad35573 323 #define MPU6050_MOTION_MOT_XPOS_BIT 6
Gaetios 2:85734ad35573 324 #define MPU6050_MOTION_MOT_YNEG_BIT 5
Gaetios 2:85734ad35573 325 #define MPU6050_MOTION_MOT_YPOS_BIT 4
Gaetios 2:85734ad35573 326 #define MPU6050_MOTION_MOT_ZNEG_BIT 3
Gaetios 2:85734ad35573 327 #define MPU6050_MOTION_MOT_ZPOS_BIT 2
Gaetios 2:85734ad35573 328 #define MPU6050_MOTION_MOT_ZRMOT_BIT 0
Gaetios 2:85734ad35573 329
Gaetios 2:85734ad35573 330 #define MPU6050_DELAYCTRL_DELAY_ES_SHADOW_BIT 7
Gaetios 2:85734ad35573 331 #define MPU6050_DELAYCTRL_I2C_SLV4_DLY_EN_BIT 4
Gaetios 2:85734ad35573 332 #define MPU6050_DELAYCTRL_I2C_SLV3_DLY_EN_BIT 3
Gaetios 2:85734ad35573 333 #define MPU6050_DELAYCTRL_I2C_SLV2_DLY_EN_BIT 2
Gaetios 2:85734ad35573 334 #define MPU6050_DELAYCTRL_I2C_SLV1_DLY_EN_BIT 1
Gaetios 2:85734ad35573 335 #define MPU6050_DELAYCTRL_I2C_SLV0_DLY_EN_BIT 0
Gaetios 2:85734ad35573 336
Gaetios 2:85734ad35573 337 #define MPU6050_PATHRESET_GYRO_RESET_BIT 2
Gaetios 2:85734ad35573 338 #define MPU6050_PATHRESET_ACCEL_RESET_BIT 1
Gaetios 2:85734ad35573 339 #define MPU6050_PATHRESET_TEMP_RESET_BIT 0
Gaetios 2:85734ad35573 340
Gaetios 2:85734ad35573 341 #define MPU6050_DETECT_ACCEL_ON_DELAY_BIT 5
Gaetios 2:85734ad35573 342 #define MPU6050_DETECT_ACCEL_ON_DELAY_LENGTH 2
Gaetios 2:85734ad35573 343 #define MPU6050_DETECT_FF_COUNT_BIT 3
Gaetios 2:85734ad35573 344 #define MPU6050_DETECT_FF_COUNT_LENGTH 2
Gaetios 2:85734ad35573 345 #define MPU6050_DETECT_MOT_COUNT_BIT 1
Gaetios 2:85734ad35573 346 #define MPU6050_DETECT_MOT_COUNT_LENGTH 2
Gaetios 2:85734ad35573 347
Gaetios 2:85734ad35573 348 #define MPU6050_DETECT_DECREMENT_RESET 0x0
Gaetios 2:85734ad35573 349 #define MPU6050_DETECT_DECREMENT_1 0x1
Gaetios 2:85734ad35573 350 #define MPU6050_DETECT_DECREMENT_2 0x2
Gaetios 2:85734ad35573 351 #define MPU6050_DETECT_DECREMENT_4 0x3
Gaetios 2:85734ad35573 352
Gaetios 2:85734ad35573 353 #define MPU6050_USERCTRL_DMP_EN_BIT 7
Gaetios 2:85734ad35573 354 #define MPU6050_USERCTRL_FIFO_EN_BIT 6
Gaetios 2:85734ad35573 355 #define MPU6050_USERCTRL_I2C_MST_EN_BIT 5
Gaetios 2:85734ad35573 356 #define MPU6050_USERCTRL_I2C_IF_DIS_BIT 4
Gaetios 2:85734ad35573 357 #define MPU6050_USERCTRL_DMP_RESET_BIT 3
Gaetios 2:85734ad35573 358 #define MPU6050_USERCTRL_FIFO_RESET_BIT 2
Gaetios 2:85734ad35573 359 #define MPU6050_USERCTRL_I2C_MST_RESET_BIT 1
Gaetios 2:85734ad35573 360 #define MPU6050_USERCTRL_SIG_COND_RESET_BIT 0
Gaetios 2:85734ad35573 361
Gaetios 2:85734ad35573 362 #define MPU6050_PWR1_DEVICE_RESET_BIT 7
Gaetios 2:85734ad35573 363 #define MPU6050_PWR1_SLEEP_BIT 6
Gaetios 2:85734ad35573 364 #define MPU6050_PWR1_CYCLE_BIT 5
Gaetios 2:85734ad35573 365 #define MPU6050_PWR1_TEMP_DIS_BIT 3
Gaetios 2:85734ad35573 366 #define MPU6050_PWR1_CLKSEL_BIT 2
Gaetios 2:85734ad35573 367 #define MPU6050_PWR1_CLKSEL_LENGTH 3
Gaetios 2:85734ad35573 368
Gaetios 2:85734ad35573 369 #define MPU6050_CLOCK_INTERNAL 0x00
Gaetios 2:85734ad35573 370 #define MPU6050_CLOCK_PLL_XGYRO 0x01
Gaetios 2:85734ad35573 371 #define MPU6050_CLOCK_PLL_YGYRO 0x02
Gaetios 2:85734ad35573 372 #define MPU6050_CLOCK_PLL_ZGYRO 0x03
Gaetios 2:85734ad35573 373 #define MPU6050_CLOCK_PLL_EXT32K 0x04
Gaetios 2:85734ad35573 374 #define MPU6050_CLOCK_PLL_EXT19M 0x05
Gaetios 2:85734ad35573 375 #define MPU6050_CLOCK_KEEP_RESET 0x07
Gaetios 2:85734ad35573 376
Gaetios 2:85734ad35573 377 #define MPU6050_PWR2_LP_WAKE_CTRL_BIT 7
Gaetios 2:85734ad35573 378 #define MPU6050_PWR2_LP_WAKE_CTRL_LENGTH 2
Gaetios 2:85734ad35573 379 #define MPU6050_PWR2_STBY_XA_BIT 5
Gaetios 2:85734ad35573 380 #define MPU6050_PWR2_STBY_YA_BIT 4
Gaetios 2:85734ad35573 381 #define MPU6050_PWR2_STBY_ZA_BIT 3
Gaetios 2:85734ad35573 382 #define MPU6050_PWR2_STBY_XG_BIT 2
Gaetios 2:85734ad35573 383 #define MPU6050_PWR2_STBY_YG_BIT 1
Gaetios 2:85734ad35573 384 #define MPU6050_PWR2_STBY_ZG_BIT 0
Gaetios 2:85734ad35573 385
Gaetios 2:85734ad35573 386 #define MPU6050_WAKE_FREQ_1P25 0x0
Gaetios 2:85734ad35573 387 #define MPU6050_WAKE_FREQ_2P5 0x1
Gaetios 2:85734ad35573 388 #define MPU6050_WAKE_FREQ_5 0x2
Gaetios 2:85734ad35573 389 #define MPU6050_WAKE_FREQ_10 0x3
Gaetios 2:85734ad35573 390
Gaetios 2:85734ad35573 391 #define MPU6050_BANKSEL_PRFTCH_EN_BIT 6
Gaetios 2:85734ad35573 392 #define MPU6050_BANKSEL_CFG_USER_BANK_BIT 5
Gaetios 2:85734ad35573 393 #define MPU6050_BANKSEL_MEM_SEL_BIT 4
Gaetios 2:85734ad35573 394 #define MPU6050_BANKSEL_MEM_SEL_LENGTH 5
Gaetios 2:85734ad35573 395
Gaetios 2:85734ad35573 396 #define MPU6050_WHO_AM_I_BIT 6
Gaetios 2:85734ad35573 397 #define MPU6050_WHO_AM_I_LENGTH 6
Gaetios 2:85734ad35573 398
Gaetios 2:85734ad35573 399 #define MPU6050_DMP_MEMORY_BANKS 8
Gaetios 2:85734ad35573 400 #define MPU6050_DMP_MEMORY_BANK_SIZE 256
Gaetios 2:85734ad35573 401 #define MPU6050_DMP_MEMORY_CHUNK_SIZE 16
Gaetios 2:85734ad35573 402
Gaetios 2:85734ad35573 403 // note: DMP code memory blocks defined at end of header file
Gaetios 2:85734ad35573 404
Gaetios 2:85734ad35573 405 class MPU60502 {
Gaetios 2:85734ad35573 406 private:
Gaetios 2:85734ad35573 407 I2C1dev i2Cdev;
Gaetios 2:85734ad35573 408 Serial debugSerial;
Gaetios 2:85734ad35573 409 public:
Gaetios 2:85734ad35573 410 MPU60502();
Gaetios 2:85734ad35573 411 MPU60502(uint8_t address);
Gaetios 2:85734ad35573 412
Gaetios 2:85734ad35573 413 void initialize();
Gaetios 2:85734ad35573 414 bool testConnection();
Gaetios 2:85734ad35573 415
Gaetios 2:85734ad35573 416 // AUX_VDDIO register
Gaetios 2:85734ad35573 417 uint8_t getAuxVDDIOLevel();
Gaetios 2:85734ad35573 418 void setAuxVDDIOLevel(uint8_t level);
Gaetios 2:85734ad35573 419
Gaetios 2:85734ad35573 420 // SMPLRT_DIV register
Gaetios 2:85734ad35573 421 uint8_t getRate();
Gaetios 2:85734ad35573 422 void setRate(uint8_t rate);
Gaetios 2:85734ad35573 423
Gaetios 2:85734ad35573 424 // CONFIG register
Gaetios 2:85734ad35573 425 uint8_t getExternalFrameSync();
Gaetios 2:85734ad35573 426 void setExternalFrameSync(uint8_t sync);
Gaetios 2:85734ad35573 427 uint8_t getDLPFMode();
Gaetios 2:85734ad35573 428 void setDLPFMode(uint8_t bandwidth);
Gaetios 2:85734ad35573 429
Gaetios 2:85734ad35573 430 // GYRO_CONFIG register
Gaetios 2:85734ad35573 431 uint8_t getFullScaleGyroRange();
Gaetios 2:85734ad35573 432 void setFullScaleGyroRange(uint8_t range);
Gaetios 2:85734ad35573 433
Gaetios 2:85734ad35573 434 // ACCEL_CONFIG register
Gaetios 2:85734ad35573 435 bool getAccelXSelfTest();
Gaetios 2:85734ad35573 436 void setAccelXSelfTest(bool enabled);
Gaetios 2:85734ad35573 437 bool getAccelYSelfTest();
Gaetios 2:85734ad35573 438 void setAccelYSelfTest(bool enabled);
Gaetios 2:85734ad35573 439 bool getAccelZSelfTest();
Gaetios 2:85734ad35573 440 void setAccelZSelfTest(bool enabled);
Gaetios 2:85734ad35573 441 uint8_t getFullScaleAccelRange();
Gaetios 2:85734ad35573 442 void setFullScaleAccelRange(uint8_t range);
Gaetios 2:85734ad35573 443 uint8_t getDHPFMode();
Gaetios 2:85734ad35573 444 void setDHPFMode(uint8_t mode);
Gaetios 2:85734ad35573 445
Gaetios 2:85734ad35573 446 // FF_THR register
Gaetios 2:85734ad35573 447 uint8_t getFreefallDetectionThreshold();
Gaetios 2:85734ad35573 448 void setFreefallDetectionThreshold(uint8_t threshold);
Gaetios 2:85734ad35573 449
Gaetios 2:85734ad35573 450 // FF_DUR register
Gaetios 2:85734ad35573 451 uint8_t getFreefallDetectionDuration();
Gaetios 2:85734ad35573 452 void setFreefallDetectionDuration(uint8_t duration);
Gaetios 2:85734ad35573 453
Gaetios 2:85734ad35573 454 // MOT_THR register
Gaetios 2:85734ad35573 455 uint8_t getMotionDetectionThreshold();
Gaetios 2:85734ad35573 456 void setMotionDetectionThreshold(uint8_t threshold);
Gaetios 2:85734ad35573 457
Gaetios 2:85734ad35573 458 // MOT_DUR register
Gaetios 2:85734ad35573 459 uint8_t getMotionDetectionDuration();
Gaetios 2:85734ad35573 460 void setMotionDetectionDuration(uint8_t duration);
Gaetios 2:85734ad35573 461
Gaetios 2:85734ad35573 462 // ZRMOT_THR register
Gaetios 2:85734ad35573 463 uint8_t getZeroMotionDetectionThreshold();
Gaetios 2:85734ad35573 464 void setZeroMotionDetectionThreshold(uint8_t threshold);
Gaetios 2:85734ad35573 465
Gaetios 2:85734ad35573 466 // ZRMOT_DUR register
Gaetios 2:85734ad35573 467 uint8_t getZeroMotionDetectionDuration();
Gaetios 2:85734ad35573 468 void setZeroMotionDetectionDuration(uint8_t duration);
Gaetios 2:85734ad35573 469
Gaetios 2:85734ad35573 470 // FIFO_EN register
Gaetios 2:85734ad35573 471 bool getTempFIFOEnabled();
Gaetios 2:85734ad35573 472 void setTempFIFOEnabled(bool enabled);
Gaetios 2:85734ad35573 473 bool getXGyroFIFOEnabled();
Gaetios 2:85734ad35573 474 void setXGyroFIFOEnabled(bool enabled);
Gaetios 2:85734ad35573 475 bool getYGyroFIFOEnabled();
Gaetios 2:85734ad35573 476 void setYGyroFIFOEnabled(bool enabled);
Gaetios 2:85734ad35573 477 bool getZGyroFIFOEnabled();
Gaetios 2:85734ad35573 478 void setZGyroFIFOEnabled(bool enabled);
Gaetios 2:85734ad35573 479 bool getAccelFIFOEnabled();
Gaetios 2:85734ad35573 480 void setAccelFIFOEnabled(bool enabled);
Gaetios 2:85734ad35573 481 bool getSlave2FIFOEnabled();
Gaetios 2:85734ad35573 482 void setSlave2FIFOEnabled(bool enabled);
Gaetios 2:85734ad35573 483 bool getSlave1FIFOEnabled();
Gaetios 2:85734ad35573 484 void setSlave1FIFOEnabled(bool enabled);
Gaetios 2:85734ad35573 485 bool getSlave0FIFOEnabled();
Gaetios 2:85734ad35573 486 void setSlave0FIFOEnabled(bool enabled);
Gaetios 2:85734ad35573 487
Gaetios 2:85734ad35573 488 // I2C_MST_CTRL register
Gaetios 2:85734ad35573 489 bool getMultiMasterEnabled();
Gaetios 2:85734ad35573 490 void setMultiMasterEnabled(bool enabled);
Gaetios 2:85734ad35573 491 bool getWaitForExternalSensorEnabled();
Gaetios 2:85734ad35573 492 void setWaitForExternalSensorEnabled(bool enabled);
Gaetios 2:85734ad35573 493 bool getSlave3FIFOEnabled();
Gaetios 2:85734ad35573 494 void setSlave3FIFOEnabled(bool enabled);
Gaetios 2:85734ad35573 495 bool getSlaveReadWriteTransitionEnabled();
Gaetios 2:85734ad35573 496 void setSlaveReadWriteTransitionEnabled(bool enabled);
Gaetios 2:85734ad35573 497 uint8_t getMasterClockSpeed();
Gaetios 2:85734ad35573 498 void setMasterClockSpeed(uint8_t speed);
Gaetios 2:85734ad35573 499
Gaetios 2:85734ad35573 500 // I2C_SLV* registers (Slave 0-3)
Gaetios 2:85734ad35573 501 uint8_t getSlaveAddress(uint8_t num);
Gaetios 2:85734ad35573 502 void setSlaveAddress(uint8_t num, uint8_t address);
Gaetios 2:85734ad35573 503 uint8_t getSlaveRegister(uint8_t num);
Gaetios 2:85734ad35573 504 void setSlaveRegister(uint8_t num, uint8_t reg);
Gaetios 2:85734ad35573 505 bool getSlaveEnabled(uint8_t num);
Gaetios 2:85734ad35573 506 void setSlaveEnabled(uint8_t num, bool enabled);
Gaetios 2:85734ad35573 507 bool getSlaveWordByteSwap(uint8_t num);
Gaetios 2:85734ad35573 508 void setSlaveWordByteSwap(uint8_t num, bool enabled);
Gaetios 2:85734ad35573 509 bool getSlaveWriteMode(uint8_t num);
Gaetios 2:85734ad35573 510 void setSlaveWriteMode(uint8_t num, bool mode);
Gaetios 2:85734ad35573 511 bool getSlaveWordGroupOffset(uint8_t num);
Gaetios 2:85734ad35573 512 void setSlaveWordGroupOffset(uint8_t num, bool enabled);
Gaetios 2:85734ad35573 513 uint8_t getSlaveDataLength(uint8_t num);
Gaetios 2:85734ad35573 514 void setSlaveDataLength(uint8_t num, uint8_t length);
Gaetios 2:85734ad35573 515
Gaetios 2:85734ad35573 516 // I2C_SLV* registers (Slave 4)
Gaetios 2:85734ad35573 517 uint8_t getSlave4Address();
Gaetios 2:85734ad35573 518 void setSlave4Address(uint8_t address);
Gaetios 2:85734ad35573 519 uint8_t getSlave4Register();
Gaetios 2:85734ad35573 520 void setSlave4Register(uint8_t reg);
Gaetios 2:85734ad35573 521 void setSlave4OutputByte(uint8_t data);
Gaetios 2:85734ad35573 522 bool getSlave4Enabled();
Gaetios 2:85734ad35573 523 void setSlave4Enabled(bool enabled);
Gaetios 2:85734ad35573 524 bool getSlave4InterruptEnabled();
Gaetios 2:85734ad35573 525 void setSlave4InterruptEnabled(bool enabled);
Gaetios 2:85734ad35573 526 bool getSlave4WriteMode();
Gaetios 2:85734ad35573 527 void setSlave4WriteMode(bool mode);
Gaetios 2:85734ad35573 528 uint8_t getSlave4MasterDelay();
Gaetios 2:85734ad35573 529 void setSlave4MasterDelay(uint8_t delay);
Gaetios 2:85734ad35573 530 uint8_t getSlate4InputByte();
Gaetios 2:85734ad35573 531
Gaetios 2:85734ad35573 532 // I2C_MST_STATUS register
Gaetios 2:85734ad35573 533 bool getPassthroughStatus();
Gaetios 2:85734ad35573 534 bool getSlave4IsDone();
Gaetios 2:85734ad35573 535 bool getLostArbitration();
Gaetios 2:85734ad35573 536 bool getSlave4Nack();
Gaetios 2:85734ad35573 537 bool getSlave3Nack();
Gaetios 2:85734ad35573 538 bool getSlave2Nack();
Gaetios 2:85734ad35573 539 bool getSlave1Nack();
Gaetios 2:85734ad35573 540 bool getSlave0Nack();
Gaetios 2:85734ad35573 541
Gaetios 2:85734ad35573 542 // INT_PIN_CFG register
Gaetios 2:85734ad35573 543 bool getInterruptMode();
Gaetios 2:85734ad35573 544 void setInterruptMode(bool mode);
Gaetios 2:85734ad35573 545 bool getInterruptDrive();
Gaetios 2:85734ad35573 546 void setInterruptDrive(bool drive);
Gaetios 2:85734ad35573 547 bool getInterruptLatch();
Gaetios 2:85734ad35573 548 void setInterruptLatch(bool latch);
Gaetios 2:85734ad35573 549 bool getInterruptLatchClear();
Gaetios 2:85734ad35573 550 void setInterruptLatchClear(bool clear);
Gaetios 2:85734ad35573 551 bool getFSyncInterruptLevel();
Gaetios 2:85734ad35573 552 void setFSyncInterruptLevel(bool level);
Gaetios 2:85734ad35573 553 bool getFSyncInterruptEnabled();
Gaetios 2:85734ad35573 554 void setFSyncInterruptEnabled(bool enabled);
Gaetios 2:85734ad35573 555 bool getI2CBypassEnabled();
Gaetios 2:85734ad35573 556 void setI2CBypassEnabled(bool enabled);
Gaetios 2:85734ad35573 557 bool getClockOutputEnabled();
Gaetios 2:85734ad35573 558 void setClockOutputEnabled(bool enabled);
Gaetios 2:85734ad35573 559
Gaetios 2:85734ad35573 560 // INT_ENABLE register
Gaetios 2:85734ad35573 561 uint8_t getIntEnabled();
Gaetios 2:85734ad35573 562 void setIntEnabled(uint8_t enabled);
Gaetios 2:85734ad35573 563 bool getIntFreefallEnabled();
Gaetios 2:85734ad35573 564 void setIntFreefallEnabled(bool enabled);
Gaetios 2:85734ad35573 565 bool getIntMotionEnabled();
Gaetios 2:85734ad35573 566 void setIntMotionEnabled(bool enabled);
Gaetios 2:85734ad35573 567 bool getIntZeroMotionEnabled();
Gaetios 2:85734ad35573 568 void setIntZeroMotionEnabled(bool enabled);
Gaetios 2:85734ad35573 569 bool getIntFIFOBufferOverflowEnabled();
Gaetios 2:85734ad35573 570 void setIntFIFOBufferOverflowEnabled(bool enabled);
Gaetios 2:85734ad35573 571 bool getIntI2CMasterEnabled();
Gaetios 2:85734ad35573 572 void setIntI2CMasterEnabled(bool enabled);
Gaetios 2:85734ad35573 573 bool getIntDataReadyEnabled();
Gaetios 2:85734ad35573 574 void setIntDataReadyEnabled(bool enabled);
Gaetios 2:85734ad35573 575
Gaetios 2:85734ad35573 576 // INT_STATUS register
Gaetios 2:85734ad35573 577 uint8_t getIntStatus();
Gaetios 2:85734ad35573 578 bool getIntFreefallStatus();
Gaetios 2:85734ad35573 579 bool getIntMotionStatus();
Gaetios 2:85734ad35573 580 bool getIntZeroMotionStatus();
Gaetios 2:85734ad35573 581 bool getIntFIFOBufferOverflowStatus();
Gaetios 2:85734ad35573 582 bool getIntI2CMasterStatus();
Gaetios 2:85734ad35573 583 bool getIntDataReadyStatus();
Gaetios 2:85734ad35573 584
Gaetios 2:85734ad35573 585 // ACCEL_*OUT_* registers
Gaetios 2:85734ad35573 586 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);
Gaetios 2:85734ad35573 587 void getMotion6(int16_t* ax, int16_t* ay, int16_t* az, int16_t* gx, int16_t* gy, int16_t* gz);
Gaetios 2:85734ad35573 588 void getAcceleration(int16_t* x, int16_t* y, int16_t* z);
Gaetios 2:85734ad35573 589 int16_t getAccelerationX();
Gaetios 2:85734ad35573 590 int16_t getAccelerationY();
Gaetios 2:85734ad35573 591 int16_t getAccelerationZ();
Gaetios 2:85734ad35573 592
Gaetios 2:85734ad35573 593 // TEMP_OUT_* registers
Gaetios 2:85734ad35573 594 int16_t getTemperature();
Gaetios 2:85734ad35573 595
Gaetios 2:85734ad35573 596 // GYRO_*OUT_* registers
Gaetios 2:85734ad35573 597 void getRotation(int16_t* x, int16_t* y, int16_t* z);
Gaetios 2:85734ad35573 598 int16_t getRotationX();
Gaetios 2:85734ad35573 599 int16_t getRotationY();
Gaetios 2:85734ad35573 600 int16_t getRotationZ();
Gaetios 2:85734ad35573 601
Gaetios 2:85734ad35573 602 // EXT_SENS_DATA_* registers
Gaetios 2:85734ad35573 603 uint8_t getExternalSensorByte(int position);
Gaetios 2:85734ad35573 604 uint16_t getExternalSensorWord(int position);
Gaetios 2:85734ad35573 605 uint32_t getExternalSensorDWord(int position);
Gaetios 2:85734ad35573 606
Gaetios 2:85734ad35573 607 // MOT_DETECT_STATUS register
Gaetios 2:85734ad35573 608 bool getXNegMotionDetected();
Gaetios 2:85734ad35573 609 bool getXPosMotionDetected();
Gaetios 2:85734ad35573 610 bool getYNegMotionDetected();
Gaetios 2:85734ad35573 611 bool getYPosMotionDetected();
Gaetios 2:85734ad35573 612 bool getZNegMotionDetected();
Gaetios 2:85734ad35573 613 bool getZPosMotionDetected();
Gaetios 2:85734ad35573 614 bool getZeroMotionDetected();
Gaetios 2:85734ad35573 615
Gaetios 2:85734ad35573 616 // I2C_SLV*_DO register
Gaetios 2:85734ad35573 617 void setSlaveOutputByte(uint8_t num, uint8_t data);
Gaetios 2:85734ad35573 618
Gaetios 2:85734ad35573 619 // I2C_MST_DELAY_CTRL register
Gaetios 2:85734ad35573 620 bool getExternalShadowDelayEnabled();
Gaetios 2:85734ad35573 621 void setExternalShadowDelayEnabled(bool enabled);
Gaetios 2:85734ad35573 622 bool getSlaveDelayEnabled(uint8_t num);
Gaetios 2:85734ad35573 623 void setSlaveDelayEnabled(uint8_t num, bool enabled);
Gaetios 2:85734ad35573 624
Gaetios 2:85734ad35573 625 // SIGNAL_PATH_RESET register
Gaetios 2:85734ad35573 626 void resetGyroscopePath();
Gaetios 2:85734ad35573 627 void resetAccelerometerPath();
Gaetios 2:85734ad35573 628 void resetTemperaturePath();
Gaetios 2:85734ad35573 629
Gaetios 2:85734ad35573 630 // MOT_DETECT_CTRL register
Gaetios 2:85734ad35573 631 uint8_t getAccelerometerPowerOnDelay();
Gaetios 2:85734ad35573 632 void setAccelerometerPowerOnDelay(uint8_t delay);
Gaetios 2:85734ad35573 633 uint8_t getFreefallDetectionCounterDecrement();
Gaetios 2:85734ad35573 634 void setFreefallDetectionCounterDecrement(uint8_t decrement);
Gaetios 2:85734ad35573 635 uint8_t getMotionDetectionCounterDecrement();
Gaetios 2:85734ad35573 636 void setMotionDetectionCounterDecrement(uint8_t decrement);
Gaetios 2:85734ad35573 637
Gaetios 2:85734ad35573 638 // USER_CTRL register
Gaetios 2:85734ad35573 639 bool getFIFOEnabled();
Gaetios 2:85734ad35573 640 void setFIFOEnabled(bool enabled);
Gaetios 2:85734ad35573 641 bool getI2CMasterModeEnabled();
Gaetios 2:85734ad35573 642 void setI2CMasterModeEnabled(bool enabled);
Gaetios 2:85734ad35573 643 void switchSPIEnabled(bool enabled);
Gaetios 2:85734ad35573 644 void resetFIFO();
Gaetios 2:85734ad35573 645 void resetI2CMaster();
Gaetios 2:85734ad35573 646 void resetSensors();
Gaetios 2:85734ad35573 647
Gaetios 2:85734ad35573 648 // PWR_MGMT_1 register
Gaetios 2:85734ad35573 649 void reset();
Gaetios 2:85734ad35573 650 bool getSleepEnabled();
Gaetios 2:85734ad35573 651 void setSleepEnabled(bool enabled);
Gaetios 2:85734ad35573 652 bool getWakeCycleEnabled();
Gaetios 2:85734ad35573 653 void setWakeCycleEnabled(bool enabled);
Gaetios 2:85734ad35573 654 bool getTempSensorEnabled();
Gaetios 2:85734ad35573 655 void setTempSensorEnabled(bool enabled);
Gaetios 2:85734ad35573 656 uint8_t getClockSource();
Gaetios 2:85734ad35573 657 void setClockSource(uint8_t source);
Gaetios 2:85734ad35573 658
Gaetios 2:85734ad35573 659 // PWR_MGMT_2 register
Gaetios 2:85734ad35573 660 uint8_t getWakeFrequency();
Gaetios 2:85734ad35573 661 void setWakeFrequency(uint8_t frequency);
Gaetios 2:85734ad35573 662 bool getStandbyXAccelEnabled();
Gaetios 2:85734ad35573 663 void setStandbyXAccelEnabled(bool enabled);
Gaetios 2:85734ad35573 664 bool getStandbyYAccelEnabled();
Gaetios 2:85734ad35573 665 void setStandbyYAccelEnabled(bool enabled);
Gaetios 2:85734ad35573 666 bool getStandbyZAccelEnabled();
Gaetios 2:85734ad35573 667 void setStandbyZAccelEnabled(bool enabled);
Gaetios 2:85734ad35573 668 bool getStandbyXGyroEnabled();
Gaetios 2:85734ad35573 669 void setStandbyXGyroEnabled(bool enabled);
Gaetios 2:85734ad35573 670 bool getStandbyYGyroEnabled();
Gaetios 2:85734ad35573 671 void setStandbyYGyroEnabled(bool enabled);
Gaetios 2:85734ad35573 672 bool getStandbyZGyroEnabled();
Gaetios 2:85734ad35573 673 void setStandbyZGyroEnabled(bool enabled);
Gaetios 2:85734ad35573 674
Gaetios 2:85734ad35573 675 // FIFO_COUNT_* registers
Gaetios 2:85734ad35573 676 uint16_t getFIFOCount();
Gaetios 2:85734ad35573 677
Gaetios 2:85734ad35573 678 // FIFO_R_W register
Gaetios 2:85734ad35573 679 uint8_t getFIFOByte();
Gaetios 2:85734ad35573 680 void setFIFOByte(uint8_t data);
Gaetios 2:85734ad35573 681 void getFIFOBytes(uint8_t *data, uint8_t length);
Gaetios 2:85734ad35573 682
Gaetios 2:85734ad35573 683 // WHO_AM_I register
Gaetios 2:85734ad35573 684 uint8_t getDeviceID();
Gaetios 2:85734ad35573 685 void setDeviceID(uint8_t id);
Gaetios 2:85734ad35573 686
Gaetios 2:85734ad35573 687 // ======== UNDOCUMENTED/DMP REGISTERS/METHODS ========
Gaetios 2:85734ad35573 688
Gaetios 2:85734ad35573 689 // XG_OFFS_TC register
Gaetios 2:85734ad35573 690 uint8_t getOTPBankValid();
Gaetios 2:85734ad35573 691 void setOTPBankValid(bool enabled);
Gaetios 2:85734ad35573 692 int8_t getXGyroOffset();
Gaetios 2:85734ad35573 693 void setXGyroOffset(int8_t offset);
Gaetios 2:85734ad35573 694
Gaetios 2:85734ad35573 695 // YG_OFFS_TC register
Gaetios 2:85734ad35573 696 int8_t getYGyroOffset();
Gaetios 2:85734ad35573 697 void setYGyroOffset(int8_t offset);
Gaetios 2:85734ad35573 698
Gaetios 2:85734ad35573 699 // ZG_OFFS_TC register
Gaetios 2:85734ad35573 700 int8_t getZGyroOffset();
Gaetios 2:85734ad35573 701 void setZGyroOffset(int8_t offset);
Gaetios 2:85734ad35573 702
Gaetios 2:85734ad35573 703 // X_FINE_GAIN register
Gaetios 2:85734ad35573 704 int8_t getXFineGain();
Gaetios 2:85734ad35573 705 void setXFineGain(int8_t gain);
Gaetios 2:85734ad35573 706
Gaetios 2:85734ad35573 707 // Y_FINE_GAIN register
Gaetios 2:85734ad35573 708 int8_t getYFineGain();
Gaetios 2:85734ad35573 709 void setYFineGain(int8_t gain);
Gaetios 2:85734ad35573 710
Gaetios 2:85734ad35573 711 // Z_FINE_GAIN register
Gaetios 2:85734ad35573 712 int8_t getZFineGain();
Gaetios 2:85734ad35573 713 void setZFineGain(int8_t gain);
Gaetios 2:85734ad35573 714
Gaetios 2:85734ad35573 715 // XA_OFFS_* registers
Gaetios 2:85734ad35573 716 int16_t getXAccelOffset();
Gaetios 2:85734ad35573 717 void setXAccelOffset(int16_t offset);
Gaetios 2:85734ad35573 718
Gaetios 2:85734ad35573 719 // YA_OFFS_* register
Gaetios 2:85734ad35573 720 int16_t getYAccelOffset();
Gaetios 2:85734ad35573 721 void setYAccelOffset(int16_t offset);
Gaetios 2:85734ad35573 722
Gaetios 2:85734ad35573 723 // ZA_OFFS_* register
Gaetios 2:85734ad35573 724 int16_t getZAccelOffset();
Gaetios 2:85734ad35573 725 void setZAccelOffset(int16_t offset);
Gaetios 2:85734ad35573 726
Gaetios 2:85734ad35573 727 // XG_OFFS_USR* registers
Gaetios 2:85734ad35573 728 int16_t getXGyroOffsetUser();
Gaetios 2:85734ad35573 729 void setXGyroOffsetUser(int16_t offset);
Gaetios 2:85734ad35573 730
Gaetios 2:85734ad35573 731 // YG_OFFS_USR* register
Gaetios 2:85734ad35573 732 int16_t getYGyroOffsetUser();
Gaetios 2:85734ad35573 733 void setYGyroOffsetUser(int16_t offset);
Gaetios 2:85734ad35573 734
Gaetios 2:85734ad35573 735 // ZG_OFFS_USR* register
Gaetios 2:85734ad35573 736 int16_t getZGyroOffsetUser();
Gaetios 2:85734ad35573 737 void setZGyroOffsetUser(int16_t offset);
Gaetios 2:85734ad35573 738
Gaetios 2:85734ad35573 739 // INT_ENABLE register (DMP functions)
Gaetios 2:85734ad35573 740 bool getIntPLLReadyEnabled();
Gaetios 2:85734ad35573 741 void setIntPLLReadyEnabled(bool enabled);
Gaetios 2:85734ad35573 742 bool getIntDMPEnabled();
Gaetios 2:85734ad35573 743 void setIntDMPEnabled(bool enabled);
Gaetios 2:85734ad35573 744
Gaetios 2:85734ad35573 745 // DMP_INT_STATUS
Gaetios 2:85734ad35573 746 bool getDMPInt5Status();
Gaetios 2:85734ad35573 747 bool getDMPInt4Status();
Gaetios 2:85734ad35573 748 bool getDMPInt3Status();
Gaetios 2:85734ad35573 749 bool getDMPInt2Status();
Gaetios 2:85734ad35573 750 bool getDMPInt1Status();
Gaetios 2:85734ad35573 751 bool getDMPInt0Status();
Gaetios 2:85734ad35573 752
Gaetios 2:85734ad35573 753 // INT_STATUS register (DMP functions)
Gaetios 2:85734ad35573 754 bool getIntPLLReadyStatus();
Gaetios 2:85734ad35573 755 bool getIntDMPStatus();
Gaetios 2:85734ad35573 756
Gaetios 2:85734ad35573 757 // USER_CTRL register (DMP functions)
Gaetios 2:85734ad35573 758 bool getDMPEnabled();
Gaetios 2:85734ad35573 759 void setDMPEnabled(bool enabled);
Gaetios 2:85734ad35573 760 void resetDMP();
Gaetios 2:85734ad35573 761
Gaetios 2:85734ad35573 762 // BANK_SEL register
Gaetios 2:85734ad35573 763 void setMemoryBank(uint8_t bank, bool prefetchEnabled=false, bool userBank=false);
Gaetios 2:85734ad35573 764
Gaetios 2:85734ad35573 765 // MEM_START_ADDR register
Gaetios 2:85734ad35573 766 void setMemoryStartAddress(uint8_t address);
Gaetios 2:85734ad35573 767
Gaetios 2:85734ad35573 768 // MEM_R_W register
Gaetios 2:85734ad35573 769 uint8_t readMemoryByte();
Gaetios 2:85734ad35573 770 void writeMemoryByte(uint8_t data);
Gaetios 2:85734ad35573 771 void readMemoryBlock(uint8_t *data, uint16_t dataSize, uint8_t bank=0, uint8_t address=0);
Gaetios 2:85734ad35573 772 bool writeMemoryBlock(const uint8_t *data, uint16_t dataSize, uint8_t bank=0, uint8_t address=0, bool verify=true, bool useProgMem=false);
Gaetios 2:85734ad35573 773 bool writeProgMemoryBlock(const uint8_t *data, uint16_t dataSize, uint8_t bank=0, uint8_t address=0, bool verify=true);
Gaetios 2:85734ad35573 774
Gaetios 2:85734ad35573 775 bool writeDMPConfigurationSet(const uint8_t *data, uint16_t dataSize, bool useProgMem=false);
Gaetios 2:85734ad35573 776 bool writeProgDMPConfigurationSet(const uint8_t *data, uint16_t dataSize);
Gaetios 2:85734ad35573 777
Gaetios 2:85734ad35573 778 // DMP_CFG_1 register
Gaetios 2:85734ad35573 779 uint8_t getDMPConfig1();
Gaetios 2:85734ad35573 780 void setDMPConfig1(uint8_t config);
Gaetios 2:85734ad35573 781
Gaetios 2:85734ad35573 782 // DMP_CFG_2 register
Gaetios 2:85734ad35573 783 uint8_t getDMPConfig2();
Gaetios 2:85734ad35573 784 void setDMPConfig2(uint8_t config);
Gaetios 2:85734ad35573 785
Gaetios 2:85734ad35573 786 // special methods for MotionApps 2.0 implementation
Gaetios 2:85734ad35573 787 #ifdef MPU6050_INCLUDE_DMP_MOTIONAPPS20
Gaetios 2:85734ad35573 788 uint8_t *dmpPacketBuffer;
Gaetios 2:85734ad35573 789 uint16_t dmpPacketSize;
Gaetios 2:85734ad35573 790
Gaetios 2:85734ad35573 791 uint8_t dmpInitialize();
Gaetios 2:85734ad35573 792 bool dmpPacketAvailable();
Gaetios 2:85734ad35573 793
Gaetios 2:85734ad35573 794 uint8_t dmpSetFIFORate(uint8_t fifoRate);
Gaetios 2:85734ad35573 795 uint8_t dmpGetFIFORate();
Gaetios 2:85734ad35573 796 uint8_t dmpGetSampleStepSizeMS();
Gaetios 2:85734ad35573 797 uint8_t dmpGetSampleFrequency();
Gaetios 2:85734ad35573 798 int32_t dmpDecodeTemperature(int8_t tempReg);
Gaetios 2:85734ad35573 799
Gaetios 2:85734ad35573 800 // Register callbacks after a packet of FIFO data is processed
Gaetios 2:85734ad35573 801 //uint8_t dmpRegisterFIFORateProcess(inv_obj_func func, int16_t priority);
Gaetios 2:85734ad35573 802 //uint8_t dmpUnregisterFIFORateProcess(inv_obj_func func);
Gaetios 2:85734ad35573 803 uint8_t dmpRunFIFORateProcesses();
Gaetios 2:85734ad35573 804
Gaetios 2:85734ad35573 805 // Setup FIFO for various output
Gaetios 2:85734ad35573 806 uint8_t dmpSendQuaternion(uint_fast16_t accuracy);
Gaetios 2:85734ad35573 807 uint8_t dmpSendGyro(uint_fast16_t elements, uint_fast16_t accuracy);
Gaetios 2:85734ad35573 808 uint8_t dmpSendAccel(uint_fast16_t elements, uint_fast16_t accuracy);
Gaetios 2:85734ad35573 809 uint8_t dmpSendLinearAccel(uint_fast16_t elements, uint_fast16_t accuracy);
Gaetios 2:85734ad35573 810 uint8_t dmpSendLinearAccelInWorld(uint_fast16_t elements, uint_fast16_t accuracy);
Gaetios 2:85734ad35573 811 uint8_t dmpSendControlData(uint_fast16_t elements, uint_fast16_t accuracy);
Gaetios 2:85734ad35573 812 uint8_t dmpSendSensorData(uint_fast16_t elements, uint_fast16_t accuracy);
Gaetios 2:85734ad35573 813 uint8_t dmpSendExternalSensorData(uint_fast16_t elements, uint_fast16_t accuracy);
Gaetios 2:85734ad35573 814 uint8_t dmpSendGravity(uint_fast16_t elements, uint_fast16_t accuracy);
Gaetios 2:85734ad35573 815 uint8_t dmpSendPacketNumber(uint_fast16_t accuracy);
Gaetios 2:85734ad35573 816 uint8_t dmpSendQuantizedAccel(uint_fast16_t elements, uint_fast16_t accuracy);
Gaetios 2:85734ad35573 817 uint8_t dmpSendEIS(uint_fast16_t elements, uint_fast16_t accuracy);
Gaetios 2:85734ad35573 818
Gaetios 2:85734ad35573 819 // Get Fixed Point data from FIFO
Gaetios 2:85734ad35573 820 uint8_t dmpGetAccel(int32_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 821 uint8_t dmpGetAccel(int16_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 822 uint8_t dmpGetAccel(VectorInt16 *v, const uint8_t* packet=0);
Gaetios 2:85734ad35573 823 uint8_t dmpGetQuaternion(int32_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 824 uint8_t dmpGetQuaternion(int16_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 825 uint8_t dmpGetQuaternion(Quaternion *q, const uint8_t* packet=0);
Gaetios 2:85734ad35573 826 uint8_t dmpGet6AxisQuaternion(int32_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 827 uint8_t dmpGet6AxisQuaternion(int16_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 828 uint8_t dmpGet6AxisQuaternion(Quaternion *q, const uint8_t* packet=0);
Gaetios 2:85734ad35573 829 uint8_t dmpGetRelativeQuaternion(int32_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 830 uint8_t dmpGetRelativeQuaternion(int16_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 831 uint8_t dmpGetRelativeQuaternion(Quaternion *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 832 uint8_t dmpGetGyro(int32_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 833 uint8_t dmpGetGyro(int16_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 834 uint8_t dmpGetGyro(VectorInt16 *v, const uint8_t* packet=0);
Gaetios 2:85734ad35573 835 uint8_t dmpSetLinearAccelFilterCoefficient(float coef);
Gaetios 2:85734ad35573 836 uint8_t dmpGetLinearAccel(int32_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 837 uint8_t dmpGetLinearAccel(int16_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 838 uint8_t dmpGetLinearAccel(VectorInt16 *v, const uint8_t* packet=0);
Gaetios 2:85734ad35573 839 uint8_t dmpGetLinearAccel(VectorInt16 *v, VectorInt16 *vRaw, VectorFloat *gravity);
Gaetios 2:85734ad35573 840 uint8_t dmpGetLinearAccelInWorld(int32_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 841 uint8_t dmpGetLinearAccelInWorld(int16_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 842 uint8_t dmpGetLinearAccelInWorld(VectorInt16 *v, const uint8_t* packet=0);
Gaetios 2:85734ad35573 843 uint8_t dmpGetLinearAccelInWorld(VectorInt16 *v, VectorInt16 *vReal, Quaternion *q);
Gaetios 2:85734ad35573 844 uint8_t dmpGetGyroAndAccelSensor(int32_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 845 uint8_t dmpGetGyroAndAccelSensor(int16_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 846 uint8_t dmpGetGyroAndAccelSensor(VectorInt16 *g, VectorInt16 *a, const uint8_t* packet=0);
Gaetios 2:85734ad35573 847 uint8_t dmpGetGyroSensor(int32_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 848 uint8_t dmpGetGyroSensor(int16_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 849 uint8_t dmpGetGyroSensor(VectorInt16 *v, const uint8_t* packet=0);
Gaetios 2:85734ad35573 850 uint8_t dmpGetControlData(int32_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 851 uint8_t dm pGetTemperature(int32_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 852 uint8_t dmpGetGravity(int32_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 853 uint8_t dmpGetGravity(int16_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 854 uint8_t dmpGetGravity(VectorInt16 *v, const uint8_t* packet=0);
Gaetios 2:85734ad35573 855 uint8_t dmpGetGravity(VectorFloat *v, Quaternion *q);
Gaetios 2:85734ad35573 856 uint8_t dmpGetUnquantizedAccel(int32_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 857 uint8_t dmpGetUnquantizedAccel(int16_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 858 uint8_t dmpGetUnquantizedAccel(VectorInt16 *v, const uint8_t* packet=0);
Gaetios 2:85734ad35573 859 uint8_t dmpGetQuantizedAccel(int32_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 860 uint8_t dmpGetQuantizedAccel(int16_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 861 uint8_t dmpGetQuantizedAccel(VectorInt16 *v, const uint8_t* packet=0);
Gaetios 2:85734ad35573 862 uint8_t dmpGetExternalSensorData(int32_t *data, uint16_t size, const uint8_t* packet=0);
Gaetios 2:85734ad35573 863 uint8_t dmpGetEIS(int32_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 864
Gaetios 2:85734ad35573 865 uint8_t dmpGetEuler(float *data, Quaternion *q);
Gaetios 2:85734ad35573 866 uint8_t dmpGetYawPitchRoll(float *data, Quaternion *q, VectorFloat *gravity);
Gaetios 2:85734ad35573 867
Gaetios 2:85734ad35573 868 // Get Floating Point data from FIFO
Gaetios 2:85734ad35573 869 uint8_t dmpGetAccelFloat(float *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 870 uint8_t dmpGetQuaternionFloat(float *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 871
Gaetios 2:85734ad35573 872 uint8_t dmpProcessFIFOPacket(const unsigned char *dmpData);
Gaetios 2:85734ad35573 873 uint8_t dmpReadAndProcessFIFOPacket(uint8_t numPackets, uint8_t *processed=NULL);
Gaetios 2:85734ad35573 874
Gaetios 2:85734ad35573 875 uint8_t dmpSetFIFOProcessedCallback(void (*func) (void));
Gaetios 2:85734ad35573 876
Gaetios 2:85734ad35573 877 uint8_t dmpInitFIFOParam();
Gaetios 2:85734ad35573 878 uint8_t dmpCloseFIFO();
Gaetios 2:85734ad35573 879 uint8_t dmpSetGyroDataSource(uint8_t source);
Gaetios 2:85734ad35573 880 uint8_t dmpDecodeQuantizedAccel();
Gaetios 2:85734ad35573 881 uint32_t dmpGetGyroSumOfSquare();
Gaetios 2:85734ad35573 882 uint32_t dmpGetAccelSumOfSquare();
Gaetios 2:85734ad35573 883 void dmpOverrideQuaternion(long *q);
Gaetios 2:85734ad35573 884 uint16_t dmpGetFIFOPacketSize();
Gaetios 2:85734ad35573 885 #endif
Gaetios 2:85734ad35573 886
Gaetios 2:85734ad35573 887 // special methods for MotionApps 4.1 implementation
Gaetios 2:85734ad35573 888 #ifdef MPU6050_INCLUDE_DMP_MOTIONAPPS41
Gaetios 2:85734ad35573 889 uint8_t *dmpPacketBuffer;
Gaetios 2:85734ad35573 890 uint16_t dmpPacketSize;
Gaetios 2:85734ad35573 891
Gaetios 2:85734ad35573 892 uint8_t dmpInitialize();
Gaetios 2:85734ad35573 893 bool dmpPacketAvailable();
Gaetios 2:85734ad35573 894
Gaetios 2:85734ad35573 895 uint8_t dmpSetFIFORate(uint8_t fifoRate);
Gaetios 2:85734ad35573 896 uint8_t dmpGetFIFORate();
Gaetios 2:85734ad35573 897 uint8_t dmpGetSampleStepSizeMS();
Gaetios 2:85734ad35573 898 uint8_t dmpGetSampleFrequency();
Gaetios 2:85734ad35573 899 int32_t dmpDecodeTemperature(int8_t tempReg);
Gaetios 2:85734ad35573 900
Gaetios 2:85734ad35573 901 // Register callbacks after a packet of FIFO data is processed
Gaetios 2:85734ad35573 902 //uint8_t dmpRegisterFIFORateProcess(inv_obj_func func, int16_t priority);
Gaetios 2:85734ad35573 903 //uint8_t dmpUnregisterFIFORateProcess(inv_obj_func func);
Gaetios 2:85734ad35573 904 uint8_t dmpRunFIFORateProcesses();
Gaetios 2:85734ad35573 905
Gaetios 2:85734ad35573 906 // Setup FIFO for various output
Gaetios 2:85734ad35573 907 uint8_t dmpSendQuaternion(uint_fast16_t accuracy);
Gaetios 2:85734ad35573 908 uint8_t dmpSendGyro(uint_fast16_t elements, uint_fast16_t accuracy);
Gaetios 2:85734ad35573 909 uint8_t dmpSendAccel(uint_fast16_t elements, uint_fast16_t accuracy);
Gaetios 2:85734ad35573 910 uint8_t dmpSendLinearAccel(uint_fast16_t elements, uint_fast16_t accuracy);
Gaetios 2:85734ad35573 911 uint8_t dmpSendLinearAccelInWorld(uint_fast16_t elements, uint_fast16_t accuracy);
Gaetios 2:85734ad35573 912 uint8_t dmpSendControlData(uint_fast16_t elements, uint_fast16_t accuracy);
Gaetios 2:85734ad35573 913 uint8_t dmpSendSensorData(uint_fast16_t elements, uint_fast16_t accuracy);
Gaetios 2:85734ad35573 914 uint8_t dmpSendExternalSensorData(uint_fast16_t elements, uint_fast16_t accuracy);
Gaetios 2:85734ad35573 915 uint8_t dmpSendGravity(uint_fast16_t elements, uint_fast16_t accuracy);
Gaetios 2:85734ad35573 916 uint8_t dmpSendPacketNumber(uint_fast16_t accuracy);
Gaetios 2:85734ad35573 917 uint8_t dmpSendQuantizedAccel(uint_fast16_t elements, uint_fast16_t accuracy);
Gaetios 2:85734ad35573 918 uint8_t dmpSendEIS(uint_fast16_t elements, uint_fast16_t accuracy);
Gaetios 2:85734ad35573 919
Gaetios 2:85734ad35573 920 // Get Fixed Point data from FIFO
Gaetios 2:85734ad35573 921 uint8_t dmpGetAccel(int32_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 922 uint8_t dmpGetAccel(int16_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 923 uint8_t dmpGetAccel(VectorInt16 *v, const uint8_t* packet=0);
Gaetios 2:85734ad35573 924 uint8_t dmpGetQuaternion(int32_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 925 uint8_t dmpGetQuaternion(int16_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 926 uint8_t dmpGetQuaternion(Quaternion *q, const uint8_t* packet=0);
Gaetios 2:85734ad35573 927 uint8_t dmpGet6AxisQuaternion(int32_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 928 uint8_t dmpGet6AxisQuaternion(int16_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 929 uint8_t dmpGet6AxisQuaternion(Quaternion *q, const uint8_t* packet=0);
Gaetios 2:85734ad35573 930 uint8_t dmpGetRelativeQuaternion(int32_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 931 uint8_t dmpGetRelativeQuaternion(int16_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 932 uint8_t dmpGetRelativeQuaternion(Quaternion *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 933 uint8_t dmpGetGyro(int32_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 934 uint8_t dmpGetGyro(int16_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 935 uint8_t dmpGetGyro(VectorInt16 *v, const uint8_t* packet=0);
Gaetios 2:85734ad35573 936 uint8_t dmpGetMag(int16_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 937 uint8_t dmpSetLinearAccelFilterCoefficient(float coef);
Gaetios 2:85734ad35573 938 uint8_t dmpGetLinearAccel(int32_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 939 uint8_t dmpGetLinearAccel(int16_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 940 uint8_t dmpGetLinearAccel(VectorInt16 *v, const uint8_t* packet=0);
Gaetios 2:85734ad35573 941 uint8_t dmpGetLinearAccel(VectorInt16 *v, VectorInt16 *vRaw, VectorFloat *gravity);
Gaetios 2:85734ad35573 942 uint8_t dmpGetLinearAccelInWorld(int32_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 943 uint8_t dmpGetLinearAccelInWorld(int16_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 944 uint8_t dmpGetLinearAccelInWorld(VectorInt16 *v, const uint8_t* packet=0);
Gaetios 2:85734ad35573 945 uint8_t dmpGetLinearAccelInWorld(VectorInt16 *v, VectorInt16 *vReal, Quaternion *q);
Gaetios 2:85734ad35573 946 uint8_t dmpGetGyroAndAccelSensor(int32_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 947 uint8_t dmpGetGyroAndAccelSensor(int16_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 948 uint8_t dmpGetGyroAndAccelSensor(VectorInt16 *g, VectorInt16 *a, const uint8_t* packet=0);
Gaetios 2:85734ad35573 949 uint8_t dmpGetGyroSensor(int32_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 950 uint8_t dmpGetGyroSensor(int16_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 951 uint8_t dmpGetGyroSensor(VectorInt16 *v, const uint8_t* packet=0);
Gaetios 2:85734ad35573 952 uint8_t dmpGetControlData(int32_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 953 uint8_t dmpGetTemperature(int32_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 954 uint8_t dmpGetGravity(int32_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 955 uint8_t dmpGetGravity(int16_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 956 uint8_t dmpGetGravity(VectorInt16 *v, const uint8_t* packet=0);
Gaetios 2:85734ad35573 957 uint8_t dmpGetGravity(VectorFloat *v, Quaternion *q);
Gaetios 2:85734ad35573 958 uint8_t dmpGetUnquantizedAccel(int32_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 959 uint8_t dmpGetUnquantizedAccel(int16_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 960 uint8_t dmpGetUnquantizedAccel(VectorInt16 *v, const uint8_t* packet=0);
Gaetios 2:85734ad35573 961 uint8_t dmpGetQuantizedAccel(int32_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 962 uint8_t dmpGetQuantizedAccel(int16_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 963 uint8_t dmpGetQuantizedAccel(VectorInt16 *v, const uint8_t* packet=0);
Gaetios 2:85734ad35573 964 uint8_t dmpGetExternalSensorData(int32_t *data, uint16_t size, const uint8_t* packet=0);
Gaetios 2:85734ad35573 965 uint8_t dmpGetEIS(int32_t *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 966
Gaetios 2:85734ad35573 967 uint8_t dmpGetEuler(float *data, Quaternion *q);
Gaetios 2:85734ad35573 968 uint8_t dmpGetYawPitchRoll(float *data, Quaternion *q, VectorFloat *gravity);
Gaetios 2:85734ad35573 969
Gaetios 2:85734ad35573 970 // Get Floating Point data from FIFO
Gaetios 2:85734ad35573 971 uint8_t dmpGetAccelFloat(float *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 972 uint8_t dmpGetQuaternionFloat(float *data, const uint8_t* packet=0);
Gaetios 2:85734ad35573 973
Gaetios 2:85734ad35573 974 uint8_t dmpProcessFIFOPacket(const unsigned char *dmpData);
Gaetios 2:85734ad35573 975 uint8_t dmpReadAndProcessFIFOPacket(uint8_t numPackets, uint8_t *processed=NULL);
Gaetios 2:85734ad35573 976
Gaetios 2:85734ad35573 977 uint8_t dmpSetFIFOProcessedCallback(void (*func) (void));
Gaetios 2:85734ad35573 978
Gaetios 2:85734ad35573 979 uint8_t dmpInitFIFOParam();
Gaetios 2:85734ad35573 980 uint8_t dmpCloseFIFO();
Gaetios 2:85734ad35573 981 uint8_t dmpSetGyroDataSource(uint8_t source);
Gaetios 2:85734ad35573 982 uint8_t dmpDecodeQuantizedAccel();
Gaetios 2:85734ad35573 983 uint32_t dmpGetGyroSumOfSquare();
Gaetios 2:85734ad35573 984 uint32_t dmpGetAccelSumOfSquare();
Gaetios 2:85734ad35573 985 void dmpOverrideQuaternion(long *q);
Gaetios 2:85734ad35573 986 uint16_t dmpGetFIFOPacketSize();
Gaetios 2:85734ad35573 987 #endif
Gaetios 2:85734ad35573 988
Gaetios 2:85734ad35573 989 private:
Gaetios 2:85734ad35573 990 uint8_t devAddr;
Gaetios 2:85734ad35573 991 uint8_t buffer[14];
Gaetios 2:85734ad35573 992 };
Gaetios 2:85734ad35573 993
Gaetios 2:85734ad35573 994 #endif /* _MPU6050_H_ */