9Axis IMU MPU9150 's library. This project is ported from this Arduino's project https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU9150. Connect pinName 27 to SCL, PinName 28 to SDA, GND to GND, and VOUT to VCC to try this library. The example is here

Dependencies:   ArduinoSerial I2Cdev

Dependents:   MPU9150_Example

Committer:
syundo0730
Date:
Mon Feb 01 16:13:13 2016 +0000
Revision:
1:1a6f1948f43d
Parent:
0:78ba160ba5f3
added LICENSE file

Who changed what in which revision?

UserRevisionLine numberNew contents of line
syundo0730 0:78ba160ba5f3 1 #ifndef _MPU9150_H_
syundo0730 0:78ba160ba5f3 2 #define _MPU9150_H_
syundo0730 0:78ba160ba5f3 3
syundo0730 0:78ba160ba5f3 4 #include "I2Cdev.h"
syundo0730 0:78ba160ba5f3 5
syundo0730 0:78ba160ba5f3 6 // supporting link: http://forum.arduino.cc/index.php?&topic=143444.msg1079517#msg1079517
syundo0730 0:78ba160ba5f3 7 // also: http://forum.arduino.cc/index.php?&topic=141571.msg1062899#msg1062899s
syundo0730 0:78ba160ba5f3 8 #ifdef __AVR__
syundo0730 0:78ba160ba5f3 9 #include <avr/pgmspace.h>
syundo0730 0:78ba160ba5f3 10 #else
syundo0730 0:78ba160ba5f3 11 #define PROGMEM /* empty */
syundo0730 0:78ba160ba5f3 12 #define pgm_read_byte(x) (*(x))
syundo0730 0:78ba160ba5f3 13 #define pgm_read_word(x) (*(x))
syundo0730 0:78ba160ba5f3 14 #define pgm_read_float(x) (*(x))
syundo0730 0:78ba160ba5f3 15 #define PSTR(STR) STR
syundo0730 0:78ba160ba5f3 16 #endif
syundo0730 0:78ba160ba5f3 17
syundo0730 0:78ba160ba5f3 18 //Magnetometer Registers
syundo0730 0:78ba160ba5f3 19 #define MPU9150_RA_MAG_ADDRESS 0x0C
syundo0730 0:78ba160ba5f3 20 #define MPU9150_RA_MAG_XOUT_L 0x03
syundo0730 0:78ba160ba5f3 21 #define MPU9150_RA_MAG_XOUT_H 0x04
syundo0730 0:78ba160ba5f3 22 #define MPU9150_RA_MAG_YOUT_L 0x05
syundo0730 0:78ba160ba5f3 23 #define MPU9150_RA_MAG_YOUT_H 0x06
syundo0730 0:78ba160ba5f3 24 #define MPU9150_RA_MAG_ZOUT_L 0x07
syundo0730 0:78ba160ba5f3 25 #define MPU9150_RA_MAG_ZOUT_H 0x08
syundo0730 0:78ba160ba5f3 26
syundo0730 0:78ba160ba5f3 27 #define MPU9150_ADDRESS_AD0_LOW 0x68 // address pin low (GND), default for InvenSense evaluation board
syundo0730 0:78ba160ba5f3 28 #define MPU9150_ADDRESS_AD0_HIGH 0x69 // address pin high (VCC)
syundo0730 0:78ba160ba5f3 29 #define MPU9150_DEFAULT_ADDRESS MPU9150_ADDRESS_AD0_LOW
syundo0730 0:78ba160ba5f3 30
syundo0730 0:78ba160ba5f3 31 #define MPU9150_RA_XG_OFFS_TC 0x00 //[7] PWR_MODE, [6:1] XG_OFFS_TC, [0] OTP_BNK_VLD
syundo0730 0:78ba160ba5f3 32 #define MPU9150_RA_YG_OFFS_TC 0x01 //[7] PWR_MODE, [6:1] YG_OFFS_TC, [0] OTP_BNK_VLD
syundo0730 0:78ba160ba5f3 33 #define MPU9150_RA_ZG_OFFS_TC 0x02 //[7] PWR_MODE, [6:1] ZG_OFFS_TC, [0] OTP_BNK_VLD
syundo0730 0:78ba160ba5f3 34 #define MPU9150_RA_X_FINE_GAIN 0x03 //[7:0] X_FINE_GAIN
syundo0730 0:78ba160ba5f3 35 #define MPU9150_RA_Y_FINE_GAIN 0x04 //[7:0] Y_FINE_GAIN
syundo0730 0:78ba160ba5f3 36 #define MPU9150_RA_Z_FINE_GAIN 0x05 //[7:0] Z_FINE_GAIN
syundo0730 0:78ba160ba5f3 37 #define MPU9150_RA_XA_OFFS_H 0x06 //[15:0] XA_OFFS
syundo0730 0:78ba160ba5f3 38 #define MPU9150_RA_XA_OFFS_L_TC 0x07
syundo0730 0:78ba160ba5f3 39 #define MPU9150_RA_YA_OFFS_H 0x08 //[15:0] YA_OFFS
syundo0730 0:78ba160ba5f3 40 #define MPU9150_RA_YA_OFFS_L_TC 0x09
syundo0730 0:78ba160ba5f3 41 #define MPU9150_RA_ZA_OFFS_H 0x0A //[15:0] ZA_OFFS
syundo0730 0:78ba160ba5f3 42 #define MPU9150_RA_ZA_OFFS_L_TC 0x0B
syundo0730 0:78ba160ba5f3 43 #define MPU9150_RA_XG_OFFS_USRH 0x13 //[15:0] XG_OFFS_USR
syundo0730 0:78ba160ba5f3 44 #define MPU9150_RA_XG_OFFS_USRL 0x14
syundo0730 0:78ba160ba5f3 45 #define MPU9150_RA_YG_OFFS_USRH 0x15 //[15:0] YG_OFFS_USR
syundo0730 0:78ba160ba5f3 46 #define MPU9150_RA_YG_OFFS_USRL 0x16
syundo0730 0:78ba160ba5f3 47 #define MPU9150_RA_ZG_OFFS_USRH 0x17 //[15:0] ZG_OFFS_USR
syundo0730 0:78ba160ba5f3 48 #define MPU9150_RA_ZG_OFFS_USRL 0x18
syundo0730 0:78ba160ba5f3 49 #define MPU9150_RA_SMPLRT_DIV 0x19
syundo0730 0:78ba160ba5f3 50 #define MPU9150_RA_CONFIG 0x1A
syundo0730 0:78ba160ba5f3 51 #define MPU9150_RA_GYRO_CONFIG 0x1B
syundo0730 0:78ba160ba5f3 52 #define MPU9150_RA_ACCEL_CONFIG 0x1C
syundo0730 0:78ba160ba5f3 53 #define MPU9150_RA_FF_THR 0x1D
syundo0730 0:78ba160ba5f3 54 #define MPU9150_RA_FF_DUR 0x1E
syundo0730 0:78ba160ba5f3 55 #define MPU9150_RA_MOT_THR 0x1F
syundo0730 0:78ba160ba5f3 56 #define MPU9150_RA_MOT_DUR 0x20
syundo0730 0:78ba160ba5f3 57 #define MPU9150_RA_ZRMOT_THR 0x21
syundo0730 0:78ba160ba5f3 58 #define MPU9150_RA_ZRMOT_DUR 0x22
syundo0730 0:78ba160ba5f3 59 #define MPU9150_RA_FIFO_EN 0x23
syundo0730 0:78ba160ba5f3 60 #define MPU9150_RA_I2C_MST_CTRL 0x24
syundo0730 0:78ba160ba5f3 61 #define MPU9150_RA_I2C_SLV0_ADDR 0x25
syundo0730 0:78ba160ba5f3 62 #define MPU9150_RA_I2C_SLV0_REG 0x26
syundo0730 0:78ba160ba5f3 63 #define MPU9150_RA_I2C_SLV0_CTRL 0x27
syundo0730 0:78ba160ba5f3 64 #define MPU9150_RA_I2C_SLV1_ADDR 0x28
syundo0730 0:78ba160ba5f3 65 #define MPU9150_RA_I2C_SLV1_REG 0x29
syundo0730 0:78ba160ba5f3 66 #define MPU9150_RA_I2C_SLV1_CTRL 0x2A
syundo0730 0:78ba160ba5f3 67 #define MPU9150_RA_I2C_SLV2_ADDR 0x2B
syundo0730 0:78ba160ba5f3 68 #define MPU9150_RA_I2C_SLV2_REG 0x2C
syundo0730 0:78ba160ba5f3 69 #define MPU9150_RA_I2C_SLV2_CTRL 0x2D
syundo0730 0:78ba160ba5f3 70 #define MPU9150_RA_I2C_SLV3_ADDR 0x2E
syundo0730 0:78ba160ba5f3 71 #define MPU9150_RA_I2C_SLV3_REG 0x2F
syundo0730 0:78ba160ba5f3 72 #define MPU9150_RA_I2C_SLV3_CTRL 0x30
syundo0730 0:78ba160ba5f3 73 #define MPU9150_RA_I2C_SLV4_ADDR 0x31
syundo0730 0:78ba160ba5f3 74 #define MPU9150_RA_I2C_SLV4_REG 0x32
syundo0730 0:78ba160ba5f3 75 #define MPU9150_RA_I2C_SLV4_DO 0x33
syundo0730 0:78ba160ba5f3 76 #define MPU9150_RA_I2C_SLV4_CTRL 0x34
syundo0730 0:78ba160ba5f3 77 #define MPU9150_RA_I2C_SLV4_DI 0x35
syundo0730 0:78ba160ba5f3 78 #define MPU9150_RA_I2C_MST_STATUS 0x36
syundo0730 0:78ba160ba5f3 79 #define MPU9150_RA_INT_PIN_CFG 0x37
syundo0730 0:78ba160ba5f3 80 #define MPU9150_RA_INT_ENABLE 0x38
syundo0730 0:78ba160ba5f3 81 #define MPU9150_RA_DMP_INT_STATUS 0x39
syundo0730 0:78ba160ba5f3 82 #define MPU9150_RA_INT_STATUS 0x3A
syundo0730 0:78ba160ba5f3 83 #define MPU9150_RA_ACCEL_XOUT_H 0x3B
syundo0730 0:78ba160ba5f3 84 #define MPU9150_RA_ACCEL_XOUT_L 0x3C
syundo0730 0:78ba160ba5f3 85 #define MPU9150_RA_ACCEL_YOUT_H 0x3D
syundo0730 0:78ba160ba5f3 86 #define MPU9150_RA_ACCEL_YOUT_L 0x3E
syundo0730 0:78ba160ba5f3 87 #define MPU9150_RA_ACCEL_ZOUT_H 0x3F
syundo0730 0:78ba160ba5f3 88 #define MPU9150_RA_ACCEL_ZOUT_L 0x40
syundo0730 0:78ba160ba5f3 89 #define MPU9150_RA_TEMP_OUT_H 0x41
syundo0730 0:78ba160ba5f3 90 #define MPU9150_RA_TEMP_OUT_L 0x42
syundo0730 0:78ba160ba5f3 91 #define MPU9150_RA_GYRO_XOUT_H 0x43
syundo0730 0:78ba160ba5f3 92 #define MPU9150_RA_GYRO_XOUT_L 0x44
syundo0730 0:78ba160ba5f3 93 #define MPU9150_RA_GYRO_YOUT_H 0x45
syundo0730 0:78ba160ba5f3 94 #define MPU9150_RA_GYRO_YOUT_L 0x46
syundo0730 0:78ba160ba5f3 95 #define MPU9150_RA_GYRO_ZOUT_H 0x47
syundo0730 0:78ba160ba5f3 96 #define MPU9150_RA_GYRO_ZOUT_L 0x48
syundo0730 0:78ba160ba5f3 97 #define MPU9150_RA_EXT_SENS_DATA_00 0x49
syundo0730 0:78ba160ba5f3 98 #define MPU9150_RA_EXT_SENS_DATA_01 0x4A
syundo0730 0:78ba160ba5f3 99 #define MPU9150_RA_EXT_SENS_DATA_02 0x4B
syundo0730 0:78ba160ba5f3 100 #define MPU9150_RA_EXT_SENS_DATA_03 0x4C
syundo0730 0:78ba160ba5f3 101 #define MPU9150_RA_EXT_SENS_DATA_04 0x4D
syundo0730 0:78ba160ba5f3 102 #define MPU9150_RA_EXT_SENS_DATA_05 0x4E
syundo0730 0:78ba160ba5f3 103 #define MPU9150_RA_EXT_SENS_DATA_06 0x4F
syundo0730 0:78ba160ba5f3 104 #define MPU9150_RA_EXT_SENS_DATA_07 0x50
syundo0730 0:78ba160ba5f3 105 #define MPU9150_RA_EXT_SENS_DATA_08 0x51
syundo0730 0:78ba160ba5f3 106 #define MPU9150_RA_EXT_SENS_DATA_09 0x52
syundo0730 0:78ba160ba5f3 107 #define MPU9150_RA_EXT_SENS_DATA_10 0x53
syundo0730 0:78ba160ba5f3 108 #define MPU9150_RA_EXT_SENS_DATA_11 0x54
syundo0730 0:78ba160ba5f3 109 #define MPU9150_RA_EXT_SENS_DATA_12 0x55
syundo0730 0:78ba160ba5f3 110 #define MPU9150_RA_EXT_SENS_DATA_13 0x56
syundo0730 0:78ba160ba5f3 111 #define MPU9150_RA_EXT_SENS_DATA_14 0x57
syundo0730 0:78ba160ba5f3 112 #define MPU9150_RA_EXT_SENS_DATA_15 0x58
syundo0730 0:78ba160ba5f3 113 #define MPU9150_RA_EXT_SENS_DATA_16 0x59
syundo0730 0:78ba160ba5f3 114 #define MPU9150_RA_EXT_SENS_DATA_17 0x5A
syundo0730 0:78ba160ba5f3 115 #define MPU9150_RA_EXT_SENS_DATA_18 0x5B
syundo0730 0:78ba160ba5f3 116 #define MPU9150_RA_EXT_SENS_DATA_19 0x5C
syundo0730 0:78ba160ba5f3 117 #define MPU9150_RA_EXT_SENS_DATA_20 0x5D
syundo0730 0:78ba160ba5f3 118 #define MPU9150_RA_EXT_SENS_DATA_21 0x5E
syundo0730 0:78ba160ba5f3 119 #define MPU9150_RA_EXT_SENS_DATA_22 0x5F
syundo0730 0:78ba160ba5f3 120 #define MPU9150_RA_EXT_SENS_DATA_23 0x60
syundo0730 0:78ba160ba5f3 121 #define MPU9150_RA_MOT_DETECT_STATUS 0x61
syundo0730 0:78ba160ba5f3 122 #define MPU9150_RA_I2C_SLV0_DO 0x63
syundo0730 0:78ba160ba5f3 123 #define MPU9150_RA_I2C_SLV1_DO 0x64
syundo0730 0:78ba160ba5f3 124 #define MPU9150_RA_I2C_SLV2_DO 0x65
syundo0730 0:78ba160ba5f3 125 #define MPU9150_RA_I2C_SLV3_DO 0x66
syundo0730 0:78ba160ba5f3 126 #define MPU9150_RA_I2C_MST_DELAY_CTRL 0x67
syundo0730 0:78ba160ba5f3 127 #define MPU9150_RA_SIGNAL_PATH_RESET 0x68
syundo0730 0:78ba160ba5f3 128 #define MPU9150_RA_MOT_DETECT_CTRL 0x69
syundo0730 0:78ba160ba5f3 129 #define MPU9150_RA_USER_CTRL 0x6A
syundo0730 0:78ba160ba5f3 130 #define MPU9150_RA_PWR_MGMT_1 0x6B
syundo0730 0:78ba160ba5f3 131 #define MPU9150_RA_PWR_MGMT_2 0x6C
syundo0730 0:78ba160ba5f3 132 #define MPU9150_RA_BANK_SEL 0x6D
syundo0730 0:78ba160ba5f3 133 #define MPU9150_RA_MEM_START_ADDR 0x6E
syundo0730 0:78ba160ba5f3 134 #define MPU9150_RA_MEM_R_W 0x6F
syundo0730 0:78ba160ba5f3 135 #define MPU9150_RA_DMP_CFG_1 0x70
syundo0730 0:78ba160ba5f3 136 #define MPU9150_RA_DMP_CFG_2 0x71
syundo0730 0:78ba160ba5f3 137 #define MPU9150_RA_FIFO_COUNTH 0x72
syundo0730 0:78ba160ba5f3 138 #define MPU9150_RA_FIFO_COUNTL 0x73
syundo0730 0:78ba160ba5f3 139 #define MPU9150_RA_FIFO_R_W 0x74
syundo0730 0:78ba160ba5f3 140 #define MPU9150_RA_WHO_AM_I 0x75
syundo0730 0:78ba160ba5f3 141
syundo0730 0:78ba160ba5f3 142 #define MPU9150_TC_PWR_MODE_BIT 7
syundo0730 0:78ba160ba5f3 143 #define MPU9150_TC_OFFSET_BIT 6
syundo0730 0:78ba160ba5f3 144 #define MPU9150_TC_OFFSET_LENGTH 6
syundo0730 0:78ba160ba5f3 145 #define MPU9150_TC_OTP_BNK_VLD_BIT 0
syundo0730 0:78ba160ba5f3 146
syundo0730 0:78ba160ba5f3 147 #define MPU9150_VDDIO_LEVEL_VLOGIC 0
syundo0730 0:78ba160ba5f3 148 #define MPU9150_VDDIO_LEVEL_VDD 1
syundo0730 0:78ba160ba5f3 149
syundo0730 0:78ba160ba5f3 150 #define MPU9150_CFG_EXT_SYNC_SET_BIT 5
syundo0730 0:78ba160ba5f3 151 #define MPU9150_CFG_EXT_SYNC_SET_LENGTH 3
syundo0730 0:78ba160ba5f3 152 #define MPU9150_CFG_DLPF_CFG_BIT 2
syundo0730 0:78ba160ba5f3 153 #define MPU9150_CFG_DLPF_CFG_LENGTH 3
syundo0730 0:78ba160ba5f3 154
syundo0730 0:78ba160ba5f3 155 #define MPU9150_EXT_SYNC_DISABLED 0x0
syundo0730 0:78ba160ba5f3 156 #define MPU9150_EXT_SYNC_TEMP_OUT_L 0x1
syundo0730 0:78ba160ba5f3 157 #define MPU9150_EXT_SYNC_GYRO_XOUT_L 0x2
syundo0730 0:78ba160ba5f3 158 #define MPU9150_EXT_SYNC_GYRO_YOUT_L 0x3
syundo0730 0:78ba160ba5f3 159 #define MPU9150_EXT_SYNC_GYRO_ZOUT_L 0x4
syundo0730 0:78ba160ba5f3 160 #define MPU9150_EXT_SYNC_ACCEL_XOUT_L 0x5
syundo0730 0:78ba160ba5f3 161 #define MPU9150_EXT_SYNC_ACCEL_YOUT_L 0x6
syundo0730 0:78ba160ba5f3 162 #define MPU9150_EXT_SYNC_ACCEL_ZOUT_L 0x7
syundo0730 0:78ba160ba5f3 163
syundo0730 0:78ba160ba5f3 164 #define MPU9150_DLPF_BW_256 0x00
syundo0730 0:78ba160ba5f3 165 #define MPU9150_DLPF_BW_188 0x01
syundo0730 0:78ba160ba5f3 166 #define MPU9150_DLPF_BW_98 0x02
syundo0730 0:78ba160ba5f3 167 #define MPU9150_DLPF_BW_42 0x03
syundo0730 0:78ba160ba5f3 168 #define MPU9150_DLPF_BW_20 0x04
syundo0730 0:78ba160ba5f3 169 #define MPU9150_DLPF_BW_10 0x05
syundo0730 0:78ba160ba5f3 170 #define MPU9150_DLPF_BW_5 0x06
syundo0730 0:78ba160ba5f3 171
syundo0730 0:78ba160ba5f3 172 #define MPU9150_GCONFIG_FS_SEL_BIT 4
syundo0730 0:78ba160ba5f3 173 #define MPU9150_GCONFIG_FS_SEL_LENGTH 2
syundo0730 0:78ba160ba5f3 174
syundo0730 0:78ba160ba5f3 175 #define MPU9150_GYRO_FS_250 0x00
syundo0730 0:78ba160ba5f3 176 #define MPU9150_GYRO_FS_500 0x01
syundo0730 0:78ba160ba5f3 177 #define MPU9150_GYRO_FS_1000 0x02
syundo0730 0:78ba160ba5f3 178 #define MPU9150_GYRO_FS_2000 0x03
syundo0730 0:78ba160ba5f3 179
syundo0730 0:78ba160ba5f3 180 #define MPU9150_ACONFIG_XA_ST_BIT 7
syundo0730 0:78ba160ba5f3 181 #define MPU9150_ACONFIG_YA_ST_BIT 6
syundo0730 0:78ba160ba5f3 182 #define MPU9150_ACONFIG_ZA_ST_BIT 5
syundo0730 0:78ba160ba5f3 183 #define MPU9150_ACONFIG_AFS_SEL_BIT 4
syundo0730 0:78ba160ba5f3 184 #define MPU9150_ACONFIG_AFS_SEL_LENGTH 2
syundo0730 0:78ba160ba5f3 185 #define MPU9150_ACONFIG_ACCEL_HPF_BIT 2
syundo0730 0:78ba160ba5f3 186 #define MPU9150_ACONFIG_ACCEL_HPF_LENGTH 3
syundo0730 0:78ba160ba5f3 187
syundo0730 0:78ba160ba5f3 188 #define MPU9150_ACCEL_FS_2 0x00
syundo0730 0:78ba160ba5f3 189 #define MPU9150_ACCEL_FS_4 0x01
syundo0730 0:78ba160ba5f3 190 #define MPU9150_ACCEL_FS_8 0x02
syundo0730 0:78ba160ba5f3 191 #define MPU9150_ACCEL_FS_16 0x03
syundo0730 0:78ba160ba5f3 192
syundo0730 0:78ba160ba5f3 193 #define MPU9150_DHPF_RESET 0x00
syundo0730 0:78ba160ba5f3 194 #define MPU9150_DHPF_5 0x01
syundo0730 0:78ba160ba5f3 195 #define MPU9150_DHPF_2P5 0x02
syundo0730 0:78ba160ba5f3 196 #define MPU9150_DHPF_1P25 0x03
syundo0730 0:78ba160ba5f3 197 #define MPU9150_DHPF_0P63 0x04
syundo0730 0:78ba160ba5f3 198 #define MPU9150_DHPF_HOLD 0x07
syundo0730 0:78ba160ba5f3 199
syundo0730 0:78ba160ba5f3 200 #define MPU9150_TEMP_FIFO_EN_BIT 7
syundo0730 0:78ba160ba5f3 201 #define MPU9150_XG_FIFO_EN_BIT 6
syundo0730 0:78ba160ba5f3 202 #define MPU9150_YG_FIFO_EN_BIT 5
syundo0730 0:78ba160ba5f3 203 #define MPU9150_ZG_FIFO_EN_BIT 4
syundo0730 0:78ba160ba5f3 204 #define MPU9150_ACCEL_FIFO_EN_BIT 3
syundo0730 0:78ba160ba5f3 205 #define MPU9150_SLV2_FIFO_EN_BIT 2
syundo0730 0:78ba160ba5f3 206 #define MPU9150_SLV1_FIFO_EN_BIT 1
syundo0730 0:78ba160ba5f3 207 #define MPU9150_SLV0_FIFO_EN_BIT 0
syundo0730 0:78ba160ba5f3 208
syundo0730 0:78ba160ba5f3 209 #define MPU9150_MULT_MST_EN_BIT 7
syundo0730 0:78ba160ba5f3 210 #define MPU9150_WAIT_FOR_ES_BIT 6
syundo0730 0:78ba160ba5f3 211 #define MPU9150_SLV_3_FIFO_EN_BIT 5
syundo0730 0:78ba160ba5f3 212 #define MPU9150_I2C_MST_P_NSR_BIT 4
syundo0730 0:78ba160ba5f3 213 #define MPU9150_I2C_MST_CLK_BIT 3
syundo0730 0:78ba160ba5f3 214 #define MPU9150_I2C_MST_CLK_LENGTH 4
syundo0730 0:78ba160ba5f3 215
syundo0730 0:78ba160ba5f3 216 #define MPU9150_CLOCK_DIV_348 0x0
syundo0730 0:78ba160ba5f3 217 #define MPU9150_CLOCK_DIV_333 0x1
syundo0730 0:78ba160ba5f3 218 #define MPU9150_CLOCK_DIV_320 0x2
syundo0730 0:78ba160ba5f3 219 #define MPU9150_CLOCK_DIV_308 0x3
syundo0730 0:78ba160ba5f3 220 #define MPU9150_CLOCK_DIV_296 0x4
syundo0730 0:78ba160ba5f3 221 #define MPU9150_CLOCK_DIV_286 0x5
syundo0730 0:78ba160ba5f3 222 #define MPU9150_CLOCK_DIV_276 0x6
syundo0730 0:78ba160ba5f3 223 #define MPU9150_CLOCK_DIV_267 0x7
syundo0730 0:78ba160ba5f3 224 #define MPU9150_CLOCK_DIV_258 0x8
syundo0730 0:78ba160ba5f3 225 #define MPU9150_CLOCK_DIV_500 0x9
syundo0730 0:78ba160ba5f3 226 #define MPU9150_CLOCK_DIV_471 0xA
syundo0730 0:78ba160ba5f3 227 #define MPU9150_CLOCK_DIV_444 0xB
syundo0730 0:78ba160ba5f3 228 #define MPU9150_CLOCK_DIV_421 0xC
syundo0730 0:78ba160ba5f3 229 #define MPU9150_CLOCK_DIV_400 0xD
syundo0730 0:78ba160ba5f3 230 #define MPU9150_CLOCK_DIV_381 0xE
syundo0730 0:78ba160ba5f3 231 #define MPU9150_CLOCK_DIV_364 0xF
syundo0730 0:78ba160ba5f3 232
syundo0730 0:78ba160ba5f3 233 #define MPU9150_I2C_SLV_RW_BIT 7
syundo0730 0:78ba160ba5f3 234 #define MPU9150_I2C_SLV_ADDR_BIT 6
syundo0730 0:78ba160ba5f3 235 #define MPU9150_I2C_SLV_ADDR_LENGTH 7
syundo0730 0:78ba160ba5f3 236 #define MPU9150_I2C_SLV_EN_BIT 7
syundo0730 0:78ba160ba5f3 237 #define MPU9150_I2C_SLV_BYTE_SW_BIT 6
syundo0730 0:78ba160ba5f3 238 #define MPU9150_I2C_SLV_REG_DIS_BIT 5
syundo0730 0:78ba160ba5f3 239 #define MPU9150_I2C_SLV_GRP_BIT 4
syundo0730 0:78ba160ba5f3 240 #define MPU9150_I2C_SLV_LEN_BIT 3
syundo0730 0:78ba160ba5f3 241 #define MPU9150_I2C_SLV_LEN_LENGTH 4
syundo0730 0:78ba160ba5f3 242
syundo0730 0:78ba160ba5f3 243 #define MPU9150_I2C_SLV4_RW_BIT 7
syundo0730 0:78ba160ba5f3 244 #define MPU9150_I2C_SLV4_ADDR_BIT 6
syundo0730 0:78ba160ba5f3 245 #define MPU9150_I2C_SLV4_ADDR_LENGTH 7
syundo0730 0:78ba160ba5f3 246 #define MPU9150_I2C_SLV4_EN_BIT 7
syundo0730 0:78ba160ba5f3 247 #define MPU9150_I2C_SLV4_INT_EN_BIT 6
syundo0730 0:78ba160ba5f3 248 #define MPU9150_I2C_SLV4_REG_DIS_BIT 5
syundo0730 0:78ba160ba5f3 249 #define MPU9150_I2C_SLV4_MST_DLY_BIT 4
syundo0730 0:78ba160ba5f3 250 #define MPU9150_I2C_SLV4_MST_DLY_LENGTH 5
syundo0730 0:78ba160ba5f3 251
syundo0730 0:78ba160ba5f3 252 #define MPU9150_MST_PASS_THROUGH_BIT 7
syundo0730 0:78ba160ba5f3 253 #define MPU9150_MST_I2C_SLV4_DONE_BIT 6
syundo0730 0:78ba160ba5f3 254 #define MPU9150_MST_I2C_LOST_ARB_BIT 5
syundo0730 0:78ba160ba5f3 255 #define MPU9150_MST_I2C_SLV4_NACK_BIT 4
syundo0730 0:78ba160ba5f3 256 #define MPU9150_MST_I2C_SLV3_NACK_BIT 3
syundo0730 0:78ba160ba5f3 257 #define MPU9150_MST_I2C_SLV2_NACK_BIT 2
syundo0730 0:78ba160ba5f3 258 #define MPU9150_MST_I2C_SLV1_NACK_BIT 1
syundo0730 0:78ba160ba5f3 259 #define MPU9150_MST_I2C_SLV0_NACK_BIT 0
syundo0730 0:78ba160ba5f3 260
syundo0730 0:78ba160ba5f3 261 #define MPU9150_INTCFG_INT_LEVEL_BIT 7
syundo0730 0:78ba160ba5f3 262 #define MPU9150_INTCFG_INT_OPEN_BIT 6
syundo0730 0:78ba160ba5f3 263 #define MPU9150_INTCFG_LATCH_INT_EN_BIT 5
syundo0730 0:78ba160ba5f3 264 #define MPU9150_INTCFG_INT_RD_CLEAR_BIT 4
syundo0730 0:78ba160ba5f3 265 #define MPU9150_INTCFG_FSYNC_INT_LEVEL_BIT 3
syundo0730 0:78ba160ba5f3 266 #define MPU9150_INTCFG_FSYNC_INT_EN_BIT 2
syundo0730 0:78ba160ba5f3 267 #define MPU9150_INTCFG_I2C_BYPASS_EN_BIT 1
syundo0730 0:78ba160ba5f3 268 #define MPU9150_INTCFG_CLKOUT_EN_BIT 0
syundo0730 0:78ba160ba5f3 269
syundo0730 0:78ba160ba5f3 270 #define MPU9150_INTMODE_ACTIVEHIGH 0x00
syundo0730 0:78ba160ba5f3 271 #define MPU9150_INTMODE_ACTIVELOW 0x01
syundo0730 0:78ba160ba5f3 272
syundo0730 0:78ba160ba5f3 273 #define MPU9150_INTDRV_PUSHPULL 0x00
syundo0730 0:78ba160ba5f3 274 #define MPU9150_INTDRV_OPENDRAIN 0x01
syundo0730 0:78ba160ba5f3 275
syundo0730 0:78ba160ba5f3 276 #define MPU9150_INTLATCH_50USPULSE 0x00
syundo0730 0:78ba160ba5f3 277 #define MPU9150_INTLATCH_WAITCLEAR 0x01
syundo0730 0:78ba160ba5f3 278
syundo0730 0:78ba160ba5f3 279 #define MPU9150_INTCLEAR_STATUSREAD 0x00
syundo0730 0:78ba160ba5f3 280 #define MPU9150_INTCLEAR_ANYREAD 0x01
syundo0730 0:78ba160ba5f3 281
syundo0730 0:78ba160ba5f3 282 #define MPU9150_INTERRUPT_FF_BIT 7
syundo0730 0:78ba160ba5f3 283 #define MPU9150_INTERRUPT_MOT_BIT 6
syundo0730 0:78ba160ba5f3 284 #define MPU9150_INTERRUPT_ZMOT_BIT 5
syundo0730 0:78ba160ba5f3 285 #define MPU9150_INTERRUPT_FIFO_OFLOW_BIT 4
syundo0730 0:78ba160ba5f3 286 #define MPU9150_INTERRUPT_I2C_MST_INT_BIT 3
syundo0730 0:78ba160ba5f3 287 #define MPU9150_INTERRUPT_PLL_RDY_INT_BIT 2
syundo0730 0:78ba160ba5f3 288 #define MPU9150_INTERRUPT_DMP_INT_BIT 1
syundo0730 0:78ba160ba5f3 289 #define MPU9150_INTERRUPT_DATA_RDY_BIT 0
syundo0730 0:78ba160ba5f3 290
syundo0730 0:78ba160ba5f3 291 // TODO: figure out what these actually do
syundo0730 0:78ba160ba5f3 292 // UMPL source code is not very obivous
syundo0730 0:78ba160ba5f3 293 #define MPU9150_DMPINT_5_BIT 5
syundo0730 0:78ba160ba5f3 294 #define MPU9150_DMPINT_4_BIT 4
syundo0730 0:78ba160ba5f3 295 #define MPU9150_DMPINT_3_BIT 3
syundo0730 0:78ba160ba5f3 296 #define MPU9150_DMPINT_2_BIT 2
syundo0730 0:78ba160ba5f3 297 #define MPU9150_DMPINT_1_BIT 1
syundo0730 0:78ba160ba5f3 298 #define MPU9150_DMPINT_0_BIT 0
syundo0730 0:78ba160ba5f3 299
syundo0730 0:78ba160ba5f3 300 #define MPU9150_MOTION_MOT_XNEG_BIT 7
syundo0730 0:78ba160ba5f3 301 #define MPU9150_MOTION_MOT_XPOS_BIT 6
syundo0730 0:78ba160ba5f3 302 #define MPU9150_MOTION_MOT_YNEG_BIT 5
syundo0730 0:78ba160ba5f3 303 #define MPU9150_MOTION_MOT_YPOS_BIT 4
syundo0730 0:78ba160ba5f3 304 #define MPU9150_MOTION_MOT_ZNEG_BIT 3
syundo0730 0:78ba160ba5f3 305 #define MPU9150_MOTION_MOT_ZPOS_BIT 2
syundo0730 0:78ba160ba5f3 306 #define MPU9150_MOTION_MOT_ZRMOT_BIT 0
syundo0730 0:78ba160ba5f3 307
syundo0730 0:78ba160ba5f3 308 #define MPU9150_DELAYCTRL_DELAY_ES_SHADOW_BIT 7
syundo0730 0:78ba160ba5f3 309 #define MPU9150_DELAYCTRL_I2C_SLV4_DLY_EN_BIT 4
syundo0730 0:78ba160ba5f3 310 #define MPU9150_DELAYCTRL_I2C_SLV3_DLY_EN_BIT 3
syundo0730 0:78ba160ba5f3 311 #define MPU9150_DELAYCTRL_I2C_SLV2_DLY_EN_BIT 2
syundo0730 0:78ba160ba5f3 312 #define MPU9150_DELAYCTRL_I2C_SLV1_DLY_EN_BIT 1
syundo0730 0:78ba160ba5f3 313 #define MPU9150_DELAYCTRL_I2C_SLV0_DLY_EN_BIT 0
syundo0730 0:78ba160ba5f3 314
syundo0730 0:78ba160ba5f3 315 #define MPU9150_PATHRESET_GYRO_RESET_BIT 2
syundo0730 0:78ba160ba5f3 316 #define MPU9150_PATHRESET_ACCEL_RESET_BIT 1
syundo0730 0:78ba160ba5f3 317 #define MPU9150_PATHRESET_TEMP_RESET_BIT 0
syundo0730 0:78ba160ba5f3 318
syundo0730 0:78ba160ba5f3 319 #define MPU9150_DETECT_ACCEL_ON_DELAY_BIT 5
syundo0730 0:78ba160ba5f3 320 #define MPU9150_DETECT_ACCEL_ON_DELAY_LENGTH 2
syundo0730 0:78ba160ba5f3 321 #define MPU9150_DETECT_FF_COUNT_BIT 3
syundo0730 0:78ba160ba5f3 322 #define MPU9150_DETECT_FF_COUNT_LENGTH 2
syundo0730 0:78ba160ba5f3 323 #define MPU9150_DETECT_MOT_COUNT_BIT 1
syundo0730 0:78ba160ba5f3 324 #define MPU9150_DETECT_MOT_COUNT_LENGTH 2
syundo0730 0:78ba160ba5f3 325
syundo0730 0:78ba160ba5f3 326 #define MPU9150_DETECT_DECREMENT_RESET 0x0
syundo0730 0:78ba160ba5f3 327 #define MPU9150_DETECT_DECREMENT_1 0x1
syundo0730 0:78ba160ba5f3 328 #define MPU9150_DETECT_DECREMENT_2 0x2
syundo0730 0:78ba160ba5f3 329 #define MPU9150_DETECT_DECREMENT_4 0x3
syundo0730 0:78ba160ba5f3 330
syundo0730 0:78ba160ba5f3 331 #define MPU9150_USERCTRL_DMP_EN_BIT 7
syundo0730 0:78ba160ba5f3 332 #define MPU9150_USERCTRL_FIFO_EN_BIT 6
syundo0730 0:78ba160ba5f3 333 #define MPU9150_USERCTRL_I2C_MST_EN_BIT 5
syundo0730 0:78ba160ba5f3 334 #define MPU9150_USERCTRL_I2C_IF_DIS_BIT 4
syundo0730 0:78ba160ba5f3 335 #define MPU9150_USERCTRL_DMP_RESET_BIT 3
syundo0730 0:78ba160ba5f3 336 #define MPU9150_USERCTRL_FIFO_RESET_BIT 2
syundo0730 0:78ba160ba5f3 337 #define MPU9150_USERCTRL_I2C_MST_RESET_BIT 1
syundo0730 0:78ba160ba5f3 338 #define MPU9150_USERCTRL_SIG_COND_RESET_BIT 0
syundo0730 0:78ba160ba5f3 339
syundo0730 0:78ba160ba5f3 340 #define MPU9150_PWR1_DEVICE_RESET_BIT 7
syundo0730 0:78ba160ba5f3 341 #define MPU9150_PWR1_SLEEP_BIT 6
syundo0730 0:78ba160ba5f3 342 #define MPU9150_PWR1_CYCLE_BIT 5
syundo0730 0:78ba160ba5f3 343 #define MPU9150_PWR1_TEMP_DIS_BIT 3
syundo0730 0:78ba160ba5f3 344 #define MPU9150_PWR1_CLKSEL_BIT 2
syundo0730 0:78ba160ba5f3 345 #define MPU9150_PWR1_CLKSEL_LENGTH 3
syundo0730 0:78ba160ba5f3 346
syundo0730 0:78ba160ba5f3 347 #define MPU9150_CLOCK_INTERNAL 0x00
syundo0730 0:78ba160ba5f3 348 #define MPU9150_CLOCK_PLL_XGYRO 0x01
syundo0730 0:78ba160ba5f3 349 #define MPU9150_CLOCK_PLL_YGYRO 0x02
syundo0730 0:78ba160ba5f3 350 #define MPU9150_CLOCK_PLL_ZGYRO 0x03
syundo0730 0:78ba160ba5f3 351 #define MPU9150_CLOCK_PLL_EXT32K 0x04
syundo0730 0:78ba160ba5f3 352 #define MPU9150_CLOCK_PLL_EXT19M 0x05
syundo0730 0:78ba160ba5f3 353 #define MPU9150_CLOCK_KEEP_RESET 0x07
syundo0730 0:78ba160ba5f3 354
syundo0730 0:78ba160ba5f3 355 #define MPU9150_PWR2_LP_WAKE_CTRL_BIT 7
syundo0730 0:78ba160ba5f3 356 #define MPU9150_PWR2_LP_WAKE_CTRL_LENGTH 2
syundo0730 0:78ba160ba5f3 357 #define MPU9150_PWR2_STBY_XA_BIT 5
syundo0730 0:78ba160ba5f3 358 #define MPU9150_PWR2_STBY_YA_BIT 4
syundo0730 0:78ba160ba5f3 359 #define MPU9150_PWR2_STBY_ZA_BIT 3
syundo0730 0:78ba160ba5f3 360 #define MPU9150_PWR2_STBY_XG_BIT 2
syundo0730 0:78ba160ba5f3 361 #define MPU9150_PWR2_STBY_YG_BIT 1
syundo0730 0:78ba160ba5f3 362 #define MPU9150_PWR2_STBY_ZG_BIT 0
syundo0730 0:78ba160ba5f3 363
syundo0730 0:78ba160ba5f3 364 #define MPU9150_WAKE_FREQ_1P25 0x0
syundo0730 0:78ba160ba5f3 365 #define MPU9150_WAKE_FREQ_2P5 0x1
syundo0730 0:78ba160ba5f3 366 #define MPU9150_WAKE_FREQ_5 0x2
syundo0730 0:78ba160ba5f3 367 #define MPU9150_WAKE_FREQ_10 0x3
syundo0730 0:78ba160ba5f3 368
syundo0730 0:78ba160ba5f3 369 #define MPU9150_BANKSEL_PRFTCH_EN_BIT 6
syundo0730 0:78ba160ba5f3 370 #define MPU9150_BANKSEL_CFG_USER_BANK_BIT 5
syundo0730 0:78ba160ba5f3 371 #define MPU9150_BANKSEL_MEM_SEL_BIT 4
syundo0730 0:78ba160ba5f3 372 #define MPU9150_BANKSEL_MEM_SEL_LENGTH 5
syundo0730 0:78ba160ba5f3 373
syundo0730 0:78ba160ba5f3 374 #define MPU9150_WHO_AM_I_BIT 6
syundo0730 0:78ba160ba5f3 375 #define MPU9150_WHO_AM_I_LENGTH 6
syundo0730 0:78ba160ba5f3 376
syundo0730 0:78ba160ba5f3 377 #define MPU9150_DMP_MEMORY_BANKS 8
syundo0730 0:78ba160ba5f3 378 #define MPU9150_DMP_MEMORY_BANK_SIZE 256
syundo0730 0:78ba160ba5f3 379 #define MPU9150_DMP_MEMORY_CHUNK_SIZE 16
syundo0730 0:78ba160ba5f3 380
syundo0730 0:78ba160ba5f3 381 // note: DMP code memory blocks defined at end of header file
syundo0730 0:78ba160ba5f3 382
syundo0730 0:78ba160ba5f3 383 class MPU9150 {
syundo0730 0:78ba160ba5f3 384 public:
syundo0730 0:78ba160ba5f3 385 MPU9150();
syundo0730 0:78ba160ba5f3 386 MPU9150(uint8_t address);
syundo0730 0:78ba160ba5f3 387
syundo0730 0:78ba160ba5f3 388 void initialize();
syundo0730 0:78ba160ba5f3 389 bool testConnection();
syundo0730 0:78ba160ba5f3 390
syundo0730 0:78ba160ba5f3 391 // AUX_VDDIO register
syundo0730 0:78ba160ba5f3 392 uint8_t getAuxVDDIOLevel();
syundo0730 0:78ba160ba5f3 393 void setAuxVDDIOLevel(uint8_t level);
syundo0730 0:78ba160ba5f3 394
syundo0730 0:78ba160ba5f3 395 // SMPLRT_DIV register
syundo0730 0:78ba160ba5f3 396 uint8_t getRate();
syundo0730 0:78ba160ba5f3 397 void setRate(uint8_t rate);
syundo0730 0:78ba160ba5f3 398
syundo0730 0:78ba160ba5f3 399 // CONFIG register
syundo0730 0:78ba160ba5f3 400 uint8_t getExternalFrameSync();
syundo0730 0:78ba160ba5f3 401 void setExternalFrameSync(uint8_t sync);
syundo0730 0:78ba160ba5f3 402 uint8_t getDLPFMode();
syundo0730 0:78ba160ba5f3 403 void setDLPFMode(uint8_t bandwidth);
syundo0730 0:78ba160ba5f3 404
syundo0730 0:78ba160ba5f3 405 // GYRO_CONFIG register
syundo0730 0:78ba160ba5f3 406 uint8_t getFullScaleGyroRange();
syundo0730 0:78ba160ba5f3 407 void setFullScaleGyroRange(uint8_t range);
syundo0730 0:78ba160ba5f3 408
syundo0730 0:78ba160ba5f3 409 // ACCEL_CONFIG register
syundo0730 0:78ba160ba5f3 410 bool getAccelXSelfTest();
syundo0730 0:78ba160ba5f3 411 void setAccelXSelfTest(bool enabled);
syundo0730 0:78ba160ba5f3 412 bool getAccelYSelfTest();
syundo0730 0:78ba160ba5f3 413 void setAccelYSelfTest(bool enabled);
syundo0730 0:78ba160ba5f3 414 bool getAccelZSelfTest();
syundo0730 0:78ba160ba5f3 415 void setAccelZSelfTest(bool enabled);
syundo0730 0:78ba160ba5f3 416 uint8_t getFullScaleAccelRange();
syundo0730 0:78ba160ba5f3 417 void setFullScaleAccelRange(uint8_t range);
syundo0730 0:78ba160ba5f3 418 uint8_t getDHPFMode();
syundo0730 0:78ba160ba5f3 419 void setDHPFMode(uint8_t mode);
syundo0730 0:78ba160ba5f3 420
syundo0730 0:78ba160ba5f3 421 // FF_THR register
syundo0730 0:78ba160ba5f3 422 uint8_t getFreefallDetectionThreshold();
syundo0730 0:78ba160ba5f3 423 void setFreefallDetectionThreshold(uint8_t threshold);
syundo0730 0:78ba160ba5f3 424
syundo0730 0:78ba160ba5f3 425 // FF_DUR register
syundo0730 0:78ba160ba5f3 426 uint8_t getFreefallDetectionDuration();
syundo0730 0:78ba160ba5f3 427 void setFreefallDetectionDuration(uint8_t duration);
syundo0730 0:78ba160ba5f3 428
syundo0730 0:78ba160ba5f3 429 // MOT_THR register
syundo0730 0:78ba160ba5f3 430 uint8_t getMotionDetectionThreshold();
syundo0730 0:78ba160ba5f3 431 void setMotionDetectionThreshold(uint8_t threshold);
syundo0730 0:78ba160ba5f3 432
syundo0730 0:78ba160ba5f3 433 // MOT_DUR register
syundo0730 0:78ba160ba5f3 434 uint8_t getMotionDetectionDuration();
syundo0730 0:78ba160ba5f3 435 void setMotionDetectionDuration(uint8_t duration);
syundo0730 0:78ba160ba5f3 436
syundo0730 0:78ba160ba5f3 437 // ZRMOT_THR register
syundo0730 0:78ba160ba5f3 438 uint8_t getZeroMotionDetectionThreshold();
syundo0730 0:78ba160ba5f3 439 void setZeroMotionDetectionThreshold(uint8_t threshold);
syundo0730 0:78ba160ba5f3 440
syundo0730 0:78ba160ba5f3 441 // ZRMOT_DUR register
syundo0730 0:78ba160ba5f3 442 uint8_t getZeroMotionDetectionDuration();
syundo0730 0:78ba160ba5f3 443 void setZeroMotionDetectionDuration(uint8_t duration);
syundo0730 0:78ba160ba5f3 444
syundo0730 0:78ba160ba5f3 445 // FIFO_EN register
syundo0730 0:78ba160ba5f3 446 bool getTempFIFOEnabled();
syundo0730 0:78ba160ba5f3 447 void setTempFIFOEnabled(bool enabled);
syundo0730 0:78ba160ba5f3 448 bool getXGyroFIFOEnabled();
syundo0730 0:78ba160ba5f3 449 void setXGyroFIFOEnabled(bool enabled);
syundo0730 0:78ba160ba5f3 450 bool getYGyroFIFOEnabled();
syundo0730 0:78ba160ba5f3 451 void setYGyroFIFOEnabled(bool enabled);
syundo0730 0:78ba160ba5f3 452 bool getZGyroFIFOEnabled();
syundo0730 0:78ba160ba5f3 453 void setZGyroFIFOEnabled(bool enabled);
syundo0730 0:78ba160ba5f3 454 bool getAccelFIFOEnabled();
syundo0730 0:78ba160ba5f3 455 void setAccelFIFOEnabled(bool enabled);
syundo0730 0:78ba160ba5f3 456 bool getSlave2FIFOEnabled();
syundo0730 0:78ba160ba5f3 457 void setSlave2FIFOEnabled(bool enabled);
syundo0730 0:78ba160ba5f3 458 bool getSlave1FIFOEnabled();
syundo0730 0:78ba160ba5f3 459 void setSlave1FIFOEnabled(bool enabled);
syundo0730 0:78ba160ba5f3 460 bool getSlave0FIFOEnabled();
syundo0730 0:78ba160ba5f3 461 void setSlave0FIFOEnabled(bool enabled);
syundo0730 0:78ba160ba5f3 462
syundo0730 0:78ba160ba5f3 463 // I2C_MST_CTRL register
syundo0730 0:78ba160ba5f3 464 bool getMultiMasterEnabled();
syundo0730 0:78ba160ba5f3 465 void setMultiMasterEnabled(bool enabled);
syundo0730 0:78ba160ba5f3 466 bool getWaitForExternalSensorEnabled();
syundo0730 0:78ba160ba5f3 467 void setWaitForExternalSensorEnabled(bool enabled);
syundo0730 0:78ba160ba5f3 468 bool getSlave3FIFOEnabled();
syundo0730 0:78ba160ba5f3 469 void setSlave3FIFOEnabled(bool enabled);
syundo0730 0:78ba160ba5f3 470 bool getSlaveReadWriteTransitionEnabled();
syundo0730 0:78ba160ba5f3 471 void setSlaveReadWriteTransitionEnabled(bool enabled);
syundo0730 0:78ba160ba5f3 472 uint8_t getMasterClockSpeed();
syundo0730 0:78ba160ba5f3 473 void setMasterClockSpeed(uint8_t speed);
syundo0730 0:78ba160ba5f3 474
syundo0730 0:78ba160ba5f3 475 // I2C_SLV* registers (Slave 0-3)
syundo0730 0:78ba160ba5f3 476 uint8_t getSlaveAddress(uint8_t num);
syundo0730 0:78ba160ba5f3 477 void setSlaveAddress(uint8_t num, uint8_t address);
syundo0730 0:78ba160ba5f3 478 uint8_t getSlaveRegister(uint8_t num);
syundo0730 0:78ba160ba5f3 479 void setSlaveRegister(uint8_t num, uint8_t reg);
syundo0730 0:78ba160ba5f3 480 bool getSlaveEnabled(uint8_t num);
syundo0730 0:78ba160ba5f3 481 void setSlaveEnabled(uint8_t num, bool enabled);
syundo0730 0:78ba160ba5f3 482 bool getSlaveWordByteSwap(uint8_t num);
syundo0730 0:78ba160ba5f3 483 void setSlaveWordByteSwap(uint8_t num, bool enabled);
syundo0730 0:78ba160ba5f3 484 bool getSlaveWriteMode(uint8_t num);
syundo0730 0:78ba160ba5f3 485 void setSlaveWriteMode(uint8_t num, bool mode);
syundo0730 0:78ba160ba5f3 486 bool getSlaveWordGroupOffset(uint8_t num);
syundo0730 0:78ba160ba5f3 487 void setSlaveWordGroupOffset(uint8_t num, bool enabled);
syundo0730 0:78ba160ba5f3 488 uint8_t getSlaveDataLength(uint8_t num);
syundo0730 0:78ba160ba5f3 489 void setSlaveDataLength(uint8_t num, uint8_t length);
syundo0730 0:78ba160ba5f3 490
syundo0730 0:78ba160ba5f3 491 // I2C_SLV* registers (Slave 4)
syundo0730 0:78ba160ba5f3 492 uint8_t getSlave4Address();
syundo0730 0:78ba160ba5f3 493 void setSlave4Address(uint8_t address);
syundo0730 0:78ba160ba5f3 494 uint8_t getSlave4Register();
syundo0730 0:78ba160ba5f3 495 void setSlave4Register(uint8_t reg);
syundo0730 0:78ba160ba5f3 496 void setSlave4OutputByte(uint8_t data);
syundo0730 0:78ba160ba5f3 497 bool getSlave4Enabled();
syundo0730 0:78ba160ba5f3 498 void setSlave4Enabled(bool enabled);
syundo0730 0:78ba160ba5f3 499 bool getSlave4InterruptEnabled();
syundo0730 0:78ba160ba5f3 500 void setSlave4InterruptEnabled(bool enabled);
syundo0730 0:78ba160ba5f3 501 bool getSlave4WriteMode();
syundo0730 0:78ba160ba5f3 502 void setSlave4WriteMode(bool mode);
syundo0730 0:78ba160ba5f3 503 uint8_t getSlave4MasterDelay();
syundo0730 0:78ba160ba5f3 504 void setSlave4MasterDelay(uint8_t delay);
syundo0730 0:78ba160ba5f3 505 uint8_t getSlate4InputByte();
syundo0730 0:78ba160ba5f3 506
syundo0730 0:78ba160ba5f3 507 // I2C_MST_STATUS register
syundo0730 0:78ba160ba5f3 508 bool getPassthroughStatus();
syundo0730 0:78ba160ba5f3 509 bool getSlave4IsDone();
syundo0730 0:78ba160ba5f3 510 bool getLostArbitration();
syundo0730 0:78ba160ba5f3 511 bool getSlave4Nack();
syundo0730 0:78ba160ba5f3 512 bool getSlave3Nack();
syundo0730 0:78ba160ba5f3 513 bool getSlave2Nack();
syundo0730 0:78ba160ba5f3 514 bool getSlave1Nack();
syundo0730 0:78ba160ba5f3 515 bool getSlave0Nack();
syundo0730 0:78ba160ba5f3 516
syundo0730 0:78ba160ba5f3 517 // INT_PIN_CFG register
syundo0730 0:78ba160ba5f3 518 bool getInterruptMode();
syundo0730 0:78ba160ba5f3 519 void setInterruptMode(bool mode);
syundo0730 0:78ba160ba5f3 520 bool getInterruptDrive();
syundo0730 0:78ba160ba5f3 521 void setInterruptDrive(bool drive);
syundo0730 0:78ba160ba5f3 522 bool getInterruptLatch();
syundo0730 0:78ba160ba5f3 523 void setInterruptLatch(bool latch);
syundo0730 0:78ba160ba5f3 524 bool getInterruptLatchClear();
syundo0730 0:78ba160ba5f3 525 void setInterruptLatchClear(bool clear);
syundo0730 0:78ba160ba5f3 526 bool getFSyncInterruptLevel();
syundo0730 0:78ba160ba5f3 527 void setFSyncInterruptLevel(bool level);
syundo0730 0:78ba160ba5f3 528 bool getFSyncInterruptEnabled();
syundo0730 0:78ba160ba5f3 529 void setFSyncInterruptEnabled(bool enabled);
syundo0730 0:78ba160ba5f3 530 bool getI2CBypassEnabled();
syundo0730 0:78ba160ba5f3 531 void setI2CBypassEnabled(bool enabled);
syundo0730 0:78ba160ba5f3 532 bool getClockOutputEnabled();
syundo0730 0:78ba160ba5f3 533 void setClockOutputEnabled(bool enabled);
syundo0730 0:78ba160ba5f3 534
syundo0730 0:78ba160ba5f3 535 // INT_ENABLE register
syundo0730 0:78ba160ba5f3 536 uint8_t getIntEnabled();
syundo0730 0:78ba160ba5f3 537 void setIntEnabled(uint8_t enabled);
syundo0730 0:78ba160ba5f3 538 bool getIntFreefallEnabled();
syundo0730 0:78ba160ba5f3 539 void setIntFreefallEnabled(bool enabled);
syundo0730 0:78ba160ba5f3 540 bool getIntMotionEnabled();
syundo0730 0:78ba160ba5f3 541 void setIntMotionEnabled(bool enabled);
syundo0730 0:78ba160ba5f3 542 bool getIntZeroMotionEnabled();
syundo0730 0:78ba160ba5f3 543 void setIntZeroMotionEnabled(bool enabled);
syundo0730 0:78ba160ba5f3 544 bool getIntFIFOBufferOverflowEnabled();
syundo0730 0:78ba160ba5f3 545 void setIntFIFOBufferOverflowEnabled(bool enabled);
syundo0730 0:78ba160ba5f3 546 bool getIntI2CMasterEnabled();
syundo0730 0:78ba160ba5f3 547 void setIntI2CMasterEnabled(bool enabled);
syundo0730 0:78ba160ba5f3 548 bool getIntDataReadyEnabled();
syundo0730 0:78ba160ba5f3 549 void setIntDataReadyEnabled(bool enabled);
syundo0730 0:78ba160ba5f3 550
syundo0730 0:78ba160ba5f3 551 // INT_STATUS register
syundo0730 0:78ba160ba5f3 552 uint8_t getIntStatus();
syundo0730 0:78ba160ba5f3 553 bool getIntFreefallStatus();
syundo0730 0:78ba160ba5f3 554 bool getIntMotionStatus();
syundo0730 0:78ba160ba5f3 555 bool getIntZeroMotionStatus();
syundo0730 0:78ba160ba5f3 556 bool getIntFIFOBufferOverflowStatus();
syundo0730 0:78ba160ba5f3 557 bool getIntI2CMasterStatus();
syundo0730 0:78ba160ba5f3 558 bool getIntDataReadyStatus();
syundo0730 0:78ba160ba5f3 559
syundo0730 0:78ba160ba5f3 560 // ACCEL_*OUT_* registers
syundo0730 0:78ba160ba5f3 561 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);
syundo0730 0:78ba160ba5f3 562 void getMotion6(int16_t* ax, int16_t* ay, int16_t* az, int16_t* gx, int16_t* gy, int16_t* gz);
syundo0730 0:78ba160ba5f3 563 void getAcceleration(int16_t* x, int16_t* y, int16_t* z);
syundo0730 0:78ba160ba5f3 564 int16_t getAccelerationX();
syundo0730 0:78ba160ba5f3 565 int16_t getAccelerationY();
syundo0730 0:78ba160ba5f3 566 int16_t getAccelerationZ();
syundo0730 0:78ba160ba5f3 567
syundo0730 0:78ba160ba5f3 568 // TEMP_OUT_* registers
syundo0730 0:78ba160ba5f3 569 int16_t getTemperature();
syundo0730 0:78ba160ba5f3 570
syundo0730 0:78ba160ba5f3 571 // GYRO_*OUT_* registers
syundo0730 0:78ba160ba5f3 572 void getRotation(int16_t* x, int16_t* y, int16_t* z);
syundo0730 0:78ba160ba5f3 573 int16_t getRotationX();
syundo0730 0:78ba160ba5f3 574 int16_t getRotationY();
syundo0730 0:78ba160ba5f3 575 int16_t getRotationZ();
syundo0730 0:78ba160ba5f3 576
syundo0730 0:78ba160ba5f3 577 // EXT_SENS_DATA_* registers
syundo0730 0:78ba160ba5f3 578 uint8_t getExternalSensorByte(int position);
syundo0730 0:78ba160ba5f3 579 uint16_t getExternalSensorWord(int position);
syundo0730 0:78ba160ba5f3 580 uint32_t getExternalSensorDWord(int position);
syundo0730 0:78ba160ba5f3 581
syundo0730 0:78ba160ba5f3 582 // MOT_DETECT_STATUS register
syundo0730 0:78ba160ba5f3 583 bool getXNegMotionDetected();
syundo0730 0:78ba160ba5f3 584 bool getXPosMotionDetected();
syundo0730 0:78ba160ba5f3 585 bool getYNegMotionDetected();
syundo0730 0:78ba160ba5f3 586 bool getYPosMotionDetected();
syundo0730 0:78ba160ba5f3 587 bool getZNegMotionDetected();
syundo0730 0:78ba160ba5f3 588 bool getZPosMotionDetected();
syundo0730 0:78ba160ba5f3 589 bool getZeroMotionDetected();
syundo0730 0:78ba160ba5f3 590
syundo0730 0:78ba160ba5f3 591 // I2C_SLV*_DO register
syundo0730 0:78ba160ba5f3 592 void setSlaveOutputByte(uint8_t num, uint8_t data);
syundo0730 0:78ba160ba5f3 593
syundo0730 0:78ba160ba5f3 594 // I2C_MST_DELAY_CTRL register
syundo0730 0:78ba160ba5f3 595 bool getExternalShadowDelayEnabled();
syundo0730 0:78ba160ba5f3 596 void setExternalShadowDelayEnabled(bool enabled);
syundo0730 0:78ba160ba5f3 597 bool getSlaveDelayEnabled(uint8_t num);
syundo0730 0:78ba160ba5f3 598 void setSlaveDelayEnabled(uint8_t num, bool enabled);
syundo0730 0:78ba160ba5f3 599
syundo0730 0:78ba160ba5f3 600 // SIGNAL_PATH_RESET register
syundo0730 0:78ba160ba5f3 601 void resetGyroscopePath();
syundo0730 0:78ba160ba5f3 602 void resetAccelerometerPath();
syundo0730 0:78ba160ba5f3 603 void resetTemperaturePath();
syundo0730 0:78ba160ba5f3 604
syundo0730 0:78ba160ba5f3 605 // MOT_DETECT_CTRL register
syundo0730 0:78ba160ba5f3 606 uint8_t getAccelerometerPowerOnDelay();
syundo0730 0:78ba160ba5f3 607 void setAccelerometerPowerOnDelay(uint8_t delay);
syundo0730 0:78ba160ba5f3 608 uint8_t getFreefallDetectionCounterDecrement();
syundo0730 0:78ba160ba5f3 609 void setFreefallDetectionCounterDecrement(uint8_t decrement);
syundo0730 0:78ba160ba5f3 610 uint8_t getMotionDetectionCounterDecrement();
syundo0730 0:78ba160ba5f3 611 void setMotionDetectionCounterDecrement(uint8_t decrement);
syundo0730 0:78ba160ba5f3 612
syundo0730 0:78ba160ba5f3 613 // USER_CTRL register
syundo0730 0:78ba160ba5f3 614 bool getFIFOEnabled();
syundo0730 0:78ba160ba5f3 615 void setFIFOEnabled(bool enabled);
syundo0730 0:78ba160ba5f3 616 bool getI2CMasterModeEnabled();
syundo0730 0:78ba160ba5f3 617 void setI2CMasterModeEnabled(bool enabled);
syundo0730 0:78ba160ba5f3 618 void switchSPIEnabled(bool enabled);
syundo0730 0:78ba160ba5f3 619 void resetFIFO();
syundo0730 0:78ba160ba5f3 620 void resetI2CMaster();
syundo0730 0:78ba160ba5f3 621 void resetSensors();
syundo0730 0:78ba160ba5f3 622
syundo0730 0:78ba160ba5f3 623 // PWR_MGMT_1 register
syundo0730 0:78ba160ba5f3 624 void reset();
syundo0730 0:78ba160ba5f3 625 bool getSleepEnabled();
syundo0730 0:78ba160ba5f3 626 void setSleepEnabled(bool enabled);
syundo0730 0:78ba160ba5f3 627 bool getWakeCycleEnabled();
syundo0730 0:78ba160ba5f3 628 void setWakeCycleEnabled(bool enabled);
syundo0730 0:78ba160ba5f3 629 bool getTempSensorEnabled();
syundo0730 0:78ba160ba5f3 630 void setTempSensorEnabled(bool enabled);
syundo0730 0:78ba160ba5f3 631 uint8_t getClockSource();
syundo0730 0:78ba160ba5f3 632 void setClockSource(uint8_t source);
syundo0730 0:78ba160ba5f3 633
syundo0730 0:78ba160ba5f3 634 // PWR_MGMT_2 register
syundo0730 0:78ba160ba5f3 635 uint8_t getWakeFrequency();
syundo0730 0:78ba160ba5f3 636 void setWakeFrequency(uint8_t frequency);
syundo0730 0:78ba160ba5f3 637 bool getStandbyXAccelEnabled();
syundo0730 0:78ba160ba5f3 638 void setStandbyXAccelEnabled(bool enabled);
syundo0730 0:78ba160ba5f3 639 bool getStandbyYAccelEnabled();
syundo0730 0:78ba160ba5f3 640 void setStandbyYAccelEnabled(bool enabled);
syundo0730 0:78ba160ba5f3 641 bool getStandbyZAccelEnabled();
syundo0730 0:78ba160ba5f3 642 void setStandbyZAccelEnabled(bool enabled);
syundo0730 0:78ba160ba5f3 643 bool getStandbyXGyroEnabled();
syundo0730 0:78ba160ba5f3 644 void setStandbyXGyroEnabled(bool enabled);
syundo0730 0:78ba160ba5f3 645 bool getStandbyYGyroEnabled();
syundo0730 0:78ba160ba5f3 646 void setStandbyYGyroEnabled(bool enabled);
syundo0730 0:78ba160ba5f3 647 bool getStandbyZGyroEnabled();
syundo0730 0:78ba160ba5f3 648 void setStandbyZGyroEnabled(bool enabled);
syundo0730 0:78ba160ba5f3 649
syundo0730 0:78ba160ba5f3 650 // FIFO_COUNT_* registers
syundo0730 0:78ba160ba5f3 651 uint16_t getFIFOCount();
syundo0730 0:78ba160ba5f3 652
syundo0730 0:78ba160ba5f3 653 // FIFO_R_W register
syundo0730 0:78ba160ba5f3 654 uint8_t getFIFOByte();
syundo0730 0:78ba160ba5f3 655 void setFIFOByte(uint8_t data);
syundo0730 0:78ba160ba5f3 656 void getFIFOBytes(uint8_t *data, uint8_t length);
syundo0730 0:78ba160ba5f3 657
syundo0730 0:78ba160ba5f3 658 // WHO_AM_I register
syundo0730 0:78ba160ba5f3 659 uint8_t getDeviceID();
syundo0730 0:78ba160ba5f3 660 void setDeviceID(uint8_t id);
syundo0730 0:78ba160ba5f3 661
syundo0730 0:78ba160ba5f3 662 // ======== UNDOCUMENTED/DMP REGISTERS/METHODS ========
syundo0730 0:78ba160ba5f3 663
syundo0730 0:78ba160ba5f3 664 // XG_OFFS_TC register
syundo0730 0:78ba160ba5f3 665 uint8_t getOTPBankValid();
syundo0730 0:78ba160ba5f3 666 void setOTPBankValid(bool enabled);
syundo0730 0:78ba160ba5f3 667 int8_t getXGyroOffsetTC();
syundo0730 0:78ba160ba5f3 668 void setXGyroOffsetTC(int8_t offset);
syundo0730 0:78ba160ba5f3 669
syundo0730 0:78ba160ba5f3 670 // YG_OFFS_TC register
syundo0730 0:78ba160ba5f3 671 int8_t getYGyroOffsetTC();
syundo0730 0:78ba160ba5f3 672 void setYGyroOffsetTC(int8_t offset);
syundo0730 0:78ba160ba5f3 673
syundo0730 0:78ba160ba5f3 674 // ZG_OFFS_TC register
syundo0730 0:78ba160ba5f3 675 int8_t getZGyroOffsetTC();
syundo0730 0:78ba160ba5f3 676 void setZGyroOffsetTC(int8_t offset);
syundo0730 0:78ba160ba5f3 677
syundo0730 0:78ba160ba5f3 678 // X_FINE_GAIN register
syundo0730 0:78ba160ba5f3 679 int8_t getXFineGain();
syundo0730 0:78ba160ba5f3 680 void setXFineGain(int8_t gain);
syundo0730 0:78ba160ba5f3 681
syundo0730 0:78ba160ba5f3 682 // Y_FINE_GAIN register
syundo0730 0:78ba160ba5f3 683 int8_t getYFineGain();
syundo0730 0:78ba160ba5f3 684 void setYFineGain(int8_t gain);
syundo0730 0:78ba160ba5f3 685
syundo0730 0:78ba160ba5f3 686 // Z_FINE_GAIN register
syundo0730 0:78ba160ba5f3 687 int8_t getZFineGain();
syundo0730 0:78ba160ba5f3 688 void setZFineGain(int8_t gain);
syundo0730 0:78ba160ba5f3 689
syundo0730 0:78ba160ba5f3 690 // XA_OFFS_* registers
syundo0730 0:78ba160ba5f3 691 int16_t getXAccelOffset();
syundo0730 0:78ba160ba5f3 692 void setXAccelOffset(int16_t offset);
syundo0730 0:78ba160ba5f3 693
syundo0730 0:78ba160ba5f3 694 // YA_OFFS_* register
syundo0730 0:78ba160ba5f3 695 int16_t getYAccelOffset();
syundo0730 0:78ba160ba5f3 696 void setYAccelOffset(int16_t offset);
syundo0730 0:78ba160ba5f3 697
syundo0730 0:78ba160ba5f3 698 // ZA_OFFS_* register
syundo0730 0:78ba160ba5f3 699 int16_t getZAccelOffset();
syundo0730 0:78ba160ba5f3 700 void setZAccelOffset(int16_t offset);
syundo0730 0:78ba160ba5f3 701
syundo0730 0:78ba160ba5f3 702 // XG_OFFS_USR* registers
syundo0730 0:78ba160ba5f3 703 int16_t getXGyroOffset();
syundo0730 0:78ba160ba5f3 704 void setXGyroOffset(int16_t offset);
syundo0730 0:78ba160ba5f3 705
syundo0730 0:78ba160ba5f3 706 // YG_OFFS_USR* register
syundo0730 0:78ba160ba5f3 707 int16_t getYGyroOffset();
syundo0730 0:78ba160ba5f3 708 void setYGyroOffset(int16_t offset);
syundo0730 0:78ba160ba5f3 709
syundo0730 0:78ba160ba5f3 710 // ZG_OFFS_USR* register
syundo0730 0:78ba160ba5f3 711 int16_t getZGyroOffset();
syundo0730 0:78ba160ba5f3 712 void setZGyroOffset(int16_t offset);
syundo0730 0:78ba160ba5f3 713
syundo0730 0:78ba160ba5f3 714 // INT_ENABLE register (DMP functions)
syundo0730 0:78ba160ba5f3 715 bool getIntPLLReadyEnabled();
syundo0730 0:78ba160ba5f3 716 void setIntPLLReadyEnabled(bool enabled);
syundo0730 0:78ba160ba5f3 717 bool getIntDMPEnabled();
syundo0730 0:78ba160ba5f3 718 void setIntDMPEnabled(bool enabled);
syundo0730 0:78ba160ba5f3 719
syundo0730 0:78ba160ba5f3 720 // DMP_INT_STATUS
syundo0730 0:78ba160ba5f3 721 bool getDMPInt5Status();
syundo0730 0:78ba160ba5f3 722 bool getDMPInt4Status();
syundo0730 0:78ba160ba5f3 723 bool getDMPInt3Status();
syundo0730 0:78ba160ba5f3 724 bool getDMPInt2Status();
syundo0730 0:78ba160ba5f3 725 bool getDMPInt1Status();
syundo0730 0:78ba160ba5f3 726 bool getDMPInt0Status();
syundo0730 0:78ba160ba5f3 727
syundo0730 0:78ba160ba5f3 728 // INT_STATUS register (DMP functions)
syundo0730 0:78ba160ba5f3 729 bool getIntPLLReadyStatus();
syundo0730 0:78ba160ba5f3 730 bool getIntDMPStatus();
syundo0730 0:78ba160ba5f3 731
syundo0730 0:78ba160ba5f3 732 // USER_CTRL register (DMP functions)
syundo0730 0:78ba160ba5f3 733 bool getDMPEnabled();
syundo0730 0:78ba160ba5f3 734 void setDMPEnabled(bool enabled);
syundo0730 0:78ba160ba5f3 735 void resetDMP();
syundo0730 0:78ba160ba5f3 736
syundo0730 0:78ba160ba5f3 737 // BANK_SEL register
syundo0730 0:78ba160ba5f3 738 void setMemoryBank(uint8_t bank, bool prefetchEnabled=false, bool userBank=false);
syundo0730 0:78ba160ba5f3 739
syundo0730 0:78ba160ba5f3 740 // MEM_START_ADDR register
syundo0730 0:78ba160ba5f3 741 void setMemoryStartAddress(uint8_t address);
syundo0730 0:78ba160ba5f3 742
syundo0730 0:78ba160ba5f3 743 // MEM_R_W register
syundo0730 0:78ba160ba5f3 744 uint8_t readMemoryByte();
syundo0730 0:78ba160ba5f3 745 void writeMemoryByte(uint8_t data);
syundo0730 0:78ba160ba5f3 746 void readMemoryBlock(uint8_t *data, uint16_t dataSize, uint8_t bank=0, uint8_t address=0);
syundo0730 0:78ba160ba5f3 747 bool writeMemoryBlock(const uint8_t *data, uint16_t dataSize, uint8_t bank=0, uint8_t address=0, bool verify=true, bool useProgMem=false);
syundo0730 0:78ba160ba5f3 748 bool writeProgMemoryBlock(const uint8_t *data, uint16_t dataSize, uint8_t bank=0, uint8_t address=0, bool verify=true);
syundo0730 0:78ba160ba5f3 749
syundo0730 0:78ba160ba5f3 750 bool writeDMPConfigurationSet(const uint8_t *data, uint16_t dataSize, bool useProgMem=false);
syundo0730 0:78ba160ba5f3 751 bool writeProgDMPConfigurationSet(const uint8_t *data, uint16_t dataSize);
syundo0730 0:78ba160ba5f3 752
syundo0730 0:78ba160ba5f3 753 // DMP_CFG_1 register
syundo0730 0:78ba160ba5f3 754 uint8_t getDMPConfig1();
syundo0730 0:78ba160ba5f3 755 void setDMPConfig1(uint8_t config);
syundo0730 0:78ba160ba5f3 756
syundo0730 0:78ba160ba5f3 757 // DMP_CFG_2 register
syundo0730 0:78ba160ba5f3 758 uint8_t getDMPConfig2();
syundo0730 0:78ba160ba5f3 759 void setDMPConfig2(uint8_t config);
syundo0730 0:78ba160ba5f3 760
syundo0730 0:78ba160ba5f3 761 // special methods for MotionApps 2.0 implementation
syundo0730 0:78ba160ba5f3 762 #ifdef MPU9150_INCLUDE_DMP_MOTIONAPPS20
syundo0730 0:78ba160ba5f3 763 uint8_t *dmpPacketBuffer;
syundo0730 0:78ba160ba5f3 764 uint16_t dmpPacketSize;
syundo0730 0:78ba160ba5f3 765
syundo0730 0:78ba160ba5f3 766 uint8_t dmpInitialize();
syundo0730 0:78ba160ba5f3 767 bool dmpPacketAvailable();
syundo0730 0:78ba160ba5f3 768
syundo0730 0:78ba160ba5f3 769 uint8_t dmpSetFIFORate(uint8_t fifoRate);
syundo0730 0:78ba160ba5f3 770 uint8_t dmpGetFIFORate();
syundo0730 0:78ba160ba5f3 771 uint8_t dmpGetSampleStepSizeMS();
syundo0730 0:78ba160ba5f3 772 uint8_t dmpGetSampleFrequency();
syundo0730 0:78ba160ba5f3 773 int32_t dmpDecodeTemperature(int8_t tempReg);
syundo0730 0:78ba160ba5f3 774
syundo0730 0:78ba160ba5f3 775 // Register callbacks after a packet of FIFO data is processed
syundo0730 0:78ba160ba5f3 776 //uint8_t dmpRegisterFIFORateProcess(inv_obj_func func, int16_t priority);
syundo0730 0:78ba160ba5f3 777 //uint8_t dmpUnregisterFIFORateProcess(inv_obj_func func);
syundo0730 0:78ba160ba5f3 778 uint8_t dmpRunFIFORateProcesses();
syundo0730 0:78ba160ba5f3 779
syundo0730 0:78ba160ba5f3 780 // Setup FIFO for various output
syundo0730 0:78ba160ba5f3 781 uint8_t dmpSendQuaternion(uint_fast16_t accuracy);
syundo0730 0:78ba160ba5f3 782 uint8_t dmpSendGyro(uint_fast16_t elements, uint_fast16_t accuracy);
syundo0730 0:78ba160ba5f3 783 uint8_t dmpSendAccel(uint_fast16_t elements, uint_fast16_t accuracy);
syundo0730 0:78ba160ba5f3 784 uint8_t dmpSendLinearAccel(uint_fast16_t elements, uint_fast16_t accuracy);
syundo0730 0:78ba160ba5f3 785 uint8_t dmpSendLinearAccelInWorld(uint_fast16_t elements, uint_fast16_t accuracy);
syundo0730 0:78ba160ba5f3 786 uint8_t dmpSendControlData(uint_fast16_t elements, uint_fast16_t accuracy);
syundo0730 0:78ba160ba5f3 787 uint8_t dmpSendSensorData(uint_fast16_t elements, uint_fast16_t accuracy);
syundo0730 0:78ba160ba5f3 788 uint8_t dmpSendExternalSensorData(uint_fast16_t elements, uint_fast16_t accuracy);
syundo0730 0:78ba160ba5f3 789 uint8_t dmpSendGravity(uint_fast16_t elements, uint_fast16_t accuracy);
syundo0730 0:78ba160ba5f3 790 uint8_t dmpSendPacketNumber(uint_fast16_t accuracy);
syundo0730 0:78ba160ba5f3 791 uint8_t dmpSendQuantizedAccel(uint_fast16_t elements, uint_fast16_t accuracy);
syundo0730 0:78ba160ba5f3 792 uint8_t dmpSendEIS(uint_fast16_t elements, uint_fast16_t accuracy);
syundo0730 0:78ba160ba5f3 793
syundo0730 0:78ba160ba5f3 794 // Get Fixed Point data from FIFO
syundo0730 0:78ba160ba5f3 795 uint8_t dmpGetAccel(int32_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 796 uint8_t dmpGetAccel(int16_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 797 uint8_t dmpGetAccel(VectorInt16 *v, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 798 uint8_t dmpGetQuaternion(int32_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 799 uint8_t dmpGetQuaternion(int16_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 800 uint8_t dmpGetQuaternion(Quaternion *q, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 801 uint8_t dmpGet6AxisQuaternion(int32_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 802 uint8_t dmpGet6AxisQuaternion(int16_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 803 uint8_t dmpGet6AxisQuaternion(Quaternion *q, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 804 uint8_t dmpGetRelativeQuaternion(int32_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 805 uint8_t dmpGetRelativeQuaternion(int16_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 806 uint8_t dmpGetRelativeQuaternion(Quaternion *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 807 uint8_t dmpGetGyro(int32_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 808 uint8_t dmpGetGyro(int16_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 809 uint8_t dmpGetGyro(VectorInt16 *v, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 810 uint8_t dmpSetLinearAccelFilterCoefficient(float coef);
syundo0730 0:78ba160ba5f3 811 uint8_t dmpGetLinearAccel(int32_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 812 uint8_t dmpGetLinearAccel(int16_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 813 uint8_t dmpGetLinearAccel(VectorInt16 *v, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 814 uint8_t dmpGetLinearAccel(VectorInt16 *v, VectorInt16 *vRaw, VectorFloat *gravity);
syundo0730 0:78ba160ba5f3 815 uint8_t dmpGetLinearAccelInWorld(int32_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 816 uint8_t dmpGetLinearAccelInWorld(int16_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 817 uint8_t dmpGetLinearAccelInWorld(VectorInt16 *v, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 818 uint8_t dmpGetLinearAccelInWorld(VectorInt16 *v, VectorInt16 *vReal, Quaternion *q);
syundo0730 0:78ba160ba5f3 819 uint8_t dmpGetGyroAndAccelSensor(int32_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 820 uint8_t dmpGetGyroAndAccelSensor(int16_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 821 uint8_t dmpGetGyroAndAccelSensor(VectorInt16 *g, VectorInt16 *a, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 822 uint8_t dmpGetGyroSensor(int32_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 823 uint8_t dmpGetGyroSensor(int16_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 824 uint8_t dmpGetGyroSensor(VectorInt16 *v, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 825 uint8_t dmpGetControlData(int32_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 826 uint8_t dmpGetTemperature(int32_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 827 uint8_t dmpGetGravity(int32_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 828 uint8_t dmpGetGravity(int16_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 829 uint8_t dmpGetGravity(VectorInt16 *v, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 830 uint8_t dmpGetGravity(VectorFloat *v, Quaternion *q);
syundo0730 0:78ba160ba5f3 831 uint8_t dmpGetUnquantizedAccel(int32_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 832 uint8_t dmpGetUnquantizedAccel(int16_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 833 uint8_t dmpGetUnquantizedAccel(VectorInt16 *v, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 834 uint8_t dmpGetQuantizedAccel(int32_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 835 uint8_t dmpGetQuantizedAccel(int16_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 836 uint8_t dmpGetQuantizedAccel(VectorInt16 *v, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 837 uint8_t dmpGetExternalSensorData(int32_t *data, uint16_t size, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 838 uint8_t dmpGetEIS(int32_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 839
syundo0730 0:78ba160ba5f3 840 uint8_t dmpGetEuler(float *data, Quaternion *q);
syundo0730 0:78ba160ba5f3 841 uint8_t dmpGetYawPitchRoll(float *data, Quaternion *q, VectorFloat *gravity);
syundo0730 0:78ba160ba5f3 842
syundo0730 0:78ba160ba5f3 843 // Get Floating Point data from FIFO
syundo0730 0:78ba160ba5f3 844 uint8_t dmpGetAccelFloat(float *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 845 uint8_t dmpGetQuaternionFloat(float *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 846
syundo0730 0:78ba160ba5f3 847 uint8_t dmpProcessFIFOPacket(const unsigned char *dmpData);
syundo0730 0:78ba160ba5f3 848 uint8_t dmpReadAndProcessFIFOPacket(uint8_t numPackets, uint8_t *processed=NULL);
syundo0730 0:78ba160ba5f3 849
syundo0730 0:78ba160ba5f3 850 uint8_t dmpSetFIFOProcessedCallback(void (*func) (void));
syundo0730 0:78ba160ba5f3 851
syundo0730 0:78ba160ba5f3 852 uint8_t dmpInitFIFOParam();
syundo0730 0:78ba160ba5f3 853 uint8_t dmpCloseFIFO();
syundo0730 0:78ba160ba5f3 854 uint8_t dmpSetGyroDataSource(uint8_t source);
syundo0730 0:78ba160ba5f3 855 uint8_t dmpDecodeQuantizedAccel();
syundo0730 0:78ba160ba5f3 856 uint32_t dmpGetGyroSumOfSquare();
syundo0730 0:78ba160ba5f3 857 uint32_t dmpGetAccelSumOfSquare();
syundo0730 0:78ba160ba5f3 858 void dmpOverrideQuaternion(long *q);
syundo0730 0:78ba160ba5f3 859 uint16_t dmpGetFIFOPacketSize();
syundo0730 0:78ba160ba5f3 860 #endif
syundo0730 0:78ba160ba5f3 861
syundo0730 0:78ba160ba5f3 862 // special methods for MotionApps 4.1 implementation
syundo0730 0:78ba160ba5f3 863 #ifdef MPU9150_INCLUDE_DMP_MOTIONAPPS41
syundo0730 0:78ba160ba5f3 864 uint8_t *dmpPacketBuffer;
syundo0730 0:78ba160ba5f3 865 uint16_t dmpPacketSize;
syundo0730 0:78ba160ba5f3 866
syundo0730 0:78ba160ba5f3 867 uint8_t dmpInitialize();
syundo0730 0:78ba160ba5f3 868 bool dmpPacketAvailable();
syundo0730 0:78ba160ba5f3 869
syundo0730 0:78ba160ba5f3 870 uint8_t dmpSetFIFORate(uint8_t fifoRate);
syundo0730 0:78ba160ba5f3 871 uint8_t dmpGetFIFORate();
syundo0730 0:78ba160ba5f3 872 uint8_t dmpGetSampleStepSizeMS();
syundo0730 0:78ba160ba5f3 873 uint8_t dmpGetSampleFrequency();
syundo0730 0:78ba160ba5f3 874 int32_t dmpDecodeTemperature(int8_t tempReg);
syundo0730 0:78ba160ba5f3 875
syundo0730 0:78ba160ba5f3 876 // Register callbacks after a packet of FIFO data is processed
syundo0730 0:78ba160ba5f3 877 //uint8_t dmpRegisterFIFORateProcess(inv_obj_func func, int16_t priority);
syundo0730 0:78ba160ba5f3 878 //uint8_t dmpUnregisterFIFORateProcess(inv_obj_func func);
syundo0730 0:78ba160ba5f3 879 uint8_t dmpRunFIFORateProcesses();
syundo0730 0:78ba160ba5f3 880
syundo0730 0:78ba160ba5f3 881 // Setup FIFO for various output
syundo0730 0:78ba160ba5f3 882 uint8_t dmpSendQuaternion(uint_fast16_t accuracy);
syundo0730 0:78ba160ba5f3 883 uint8_t dmpSendGyro(uint_fast16_t elements, uint_fast16_t accuracy);
syundo0730 0:78ba160ba5f3 884 uint8_t dmpSendAccel(uint_fast16_t elements, uint_fast16_t accuracy);
syundo0730 0:78ba160ba5f3 885 uint8_t dmpSendLinearAccel(uint_fast16_t elements, uint_fast16_t accuracy);
syundo0730 0:78ba160ba5f3 886 uint8_t dmpSendLinearAccelInWorld(uint_fast16_t elements, uint_fast16_t accuracy);
syundo0730 0:78ba160ba5f3 887 uint8_t dmpSendControlData(uint_fast16_t elements, uint_fast16_t accuracy);
syundo0730 0:78ba160ba5f3 888 uint8_t dmpSendSensorData(uint_fast16_t elements, uint_fast16_t accuracy);
syundo0730 0:78ba160ba5f3 889 uint8_t dmpSendExternalSensorData(uint_fast16_t elements, uint_fast16_t accuracy);
syundo0730 0:78ba160ba5f3 890 uint8_t dmpSendGravity(uint_fast16_t elements, uint_fast16_t accuracy);
syundo0730 0:78ba160ba5f3 891 uint8_t dmpSendPacketNumber(uint_fast16_t accuracy);
syundo0730 0:78ba160ba5f3 892 uint8_t dmpSendQuantizedAccel(uint_fast16_t elements, uint_fast16_t accuracy);
syundo0730 0:78ba160ba5f3 893 uint8_t dmpSendEIS(uint_fast16_t elements, uint_fast16_t accuracy);
syundo0730 0:78ba160ba5f3 894
syundo0730 0:78ba160ba5f3 895 // Get Fixed Point data from FIFO
syundo0730 0:78ba160ba5f3 896 uint8_t dmpGetAccel(int32_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 897 uint8_t dmpGetAccel(int16_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 898 uint8_t dmpGetAccel(VectorInt16 *v, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 899 uint8_t dmpGetQuaternion(int32_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 900 uint8_t dmpGetQuaternion(int16_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 901 uint8_t dmpGetQuaternion(Quaternion *q, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 902 uint8_t dmpGet6AxisQuaternion(int32_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 903 uint8_t dmpGet6AxisQuaternion(int16_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 904 uint8_t dmpGet6AxisQuaternion(Quaternion *q, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 905 uint8_t dmpGetRelativeQuaternion(int32_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 906 uint8_t dmpGetRelativeQuaternion(int16_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 907 uint8_t dmpGetRelativeQuaternion(Quaternion *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 908 uint8_t dmpGetGyro(int32_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 909 uint8_t dmpGetGyro(int16_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 910 uint8_t dmpGetGyro(VectorInt16 *v, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 911 uint8_t dmpGetMag(int16_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 912 uint8_t dmpSetLinearAccelFilterCoefficient(float coef);
syundo0730 0:78ba160ba5f3 913 uint8_t dmpGetLinearAccel(int32_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 914 uint8_t dmpGetLinearAccel(int16_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 915 uint8_t dmpGetLinearAccel(VectorInt16 *v, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 916 uint8_t dmpGetLinearAccel(VectorInt16 *v, VectorInt16 *vRaw, VectorFloat *gravity);
syundo0730 0:78ba160ba5f3 917 uint8_t dmpGetLinearAccelInWorld(int32_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 918 uint8_t dmpGetLinearAccelInWorld(int16_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 919 uint8_t dmpGetLinearAccelInWorld(VectorInt16 *v, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 920 uint8_t dmpGetLinearAccelInWorld(VectorInt16 *v, VectorInt16 *vReal, Quaternion *q);
syundo0730 0:78ba160ba5f3 921 uint8_t dmpGetGyroAndAccelSensor(int32_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 922 uint8_t dmpGetGyroAndAccelSensor(int16_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 923 uint8_t dmpGetGyroAndAccelSensor(VectorInt16 *g, VectorInt16 *a, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 924 uint8_t dmpGetGyroSensor(int32_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 925 uint8_t dmpGetGyroSensor(int16_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 926 uint8_t dmpGetGyroSensor(VectorInt16 *v, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 927 uint8_t dmpGetControlData(int32_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 928 uint8_t dmpGetTemperature(int32_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 929 uint8_t dmpGetGravity(int32_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 930 uint8_t dmpGetGravity(int16_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 931 uint8_t dmpGetGravity(VectorInt16 *v, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 932 uint8_t dmpGetGravity(VectorFloat *v, Quaternion *q);
syundo0730 0:78ba160ba5f3 933 uint8_t dmpGetUnquantizedAccel(int32_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 934 uint8_t dmpGetUnquantizedAccel(int16_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 935 uint8_t dmpGetUnquantizedAccel(VectorInt16 *v, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 936 uint8_t dmpGetQuantizedAccel(int32_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 937 uint8_t dmpGetQuantizedAccel(int16_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 938 uint8_t dmpGetQuantizedAccel(VectorInt16 *v, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 939 uint8_t dmpGetExternalSensorData(int32_t *data, uint16_t size, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 940 uint8_t dmpGetEIS(int32_t *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 941
syundo0730 0:78ba160ba5f3 942 uint8_t dmpGetEuler(float *data, Quaternion *q);
syundo0730 0:78ba160ba5f3 943 uint8_t dmpGetYawPitchRoll(float *data, Quaternion *q, VectorFloat *gravity);
syundo0730 0:78ba160ba5f3 944
syundo0730 0:78ba160ba5f3 945 // Get Floating Point data from FIFO
syundo0730 0:78ba160ba5f3 946 uint8_t dmpGetAccelFloat(float *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 947 uint8_t dmpGetQuaternionFloat(float *data, const uint8_t* packet=0);
syundo0730 0:78ba160ba5f3 948
syundo0730 0:78ba160ba5f3 949 uint8_t dmpProcessFIFOPacket(const unsigned char *dmpData);
syundo0730 0:78ba160ba5f3 950 uint8_t dmpReadAndProcessFIFOPacket(uint8_t numPackets, uint8_t *processed=NULL);
syundo0730 0:78ba160ba5f3 951
syundo0730 0:78ba160ba5f3 952 uint8_t dmpSetFIFOProcessedCallback(void (*func) (void));
syundo0730 0:78ba160ba5f3 953
syundo0730 0:78ba160ba5f3 954 uint8_t dmpInitFIFOParam();
syundo0730 0:78ba160ba5f3 955 uint8_t dmpCloseFIFO();
syundo0730 0:78ba160ba5f3 956 uint8_t dmpSetGyroDataSource(uint8_t source);
syundo0730 0:78ba160ba5f3 957 uint8_t dmpDecodeQuantizedAccel();
syundo0730 0:78ba160ba5f3 958 uint32_t dmpGetGyroSumOfSquare();
syundo0730 0:78ba160ba5f3 959 uint32_t dmpGetAccelSumOfSquare();
syundo0730 0:78ba160ba5f3 960 void dmpOverrideQuaternion(long *q);
syundo0730 0:78ba160ba5f3 961 uint16_t dmpGetFIFOPacketSize();
syundo0730 0:78ba160ba5f3 962 #endif
syundo0730 0:78ba160ba5f3 963
syundo0730 0:78ba160ba5f3 964 private:
syundo0730 0:78ba160ba5f3 965 uint8_t devAddr;
syundo0730 0:78ba160ba5f3 966 uint8_t buffer[14];
syundo0730 0:78ba160ba5f3 967 };
syundo0730 0:78ba160ba5f3 968
syundo0730 0:78ba160ba5f3 969 #endif /* _MPU9150_H_ */