This one compatable with brobot V3, V4, Lab6 Part 3. first commit to BroBot

Dependencies:   I2Cdev

Dependents:   robotcode

Fork of MPU6050_V3 by Carter Sharer

Committer:
syundo0730
Date:
Sun Jan 31 09:12:19 2016 +0000
Revision:
7:d5845b617139
Parent:
6:f38dfe62d74c
Child:
8:4ee054567b6c
trace changes in arduino project

Who changed what in which revision?

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