27 #include <mraa/common.hpp>
28 #include <mraa/i2c.hpp>
30 #include <mraa/gpio.hpp>
32 #define MPU60X0_I2C_BUS 0
33 #define MPU60X0_DEFAULT_I2C_ADDR 0x68
79 REG_SELF_TEST_X = 0x0d,
80 REG_SELF_TEST_Y = 0x0e,
81 REG_SELF_TEST_Z = 0x0f,
82 REG_SELF_TEST_A = 0x10,
84 REG_SMPLRT_DIV = 0x19,
87 REG_GYRO_CONFIG = 0x1b,
88 REG_ACCEL_CONFIG = 0x1c,
101 REG_I2C_MST_CTRL = 0x24,
103 REG_I2C_SLV0_ADDR = 0x25,
104 REG_I2C_SLV0_REG = 0x26,
105 REG_I2C_SLV0_CTRL = 0x27,
107 REG_I2C_SLV1_ADDR = 0x28,
108 REG_I2C_SLV1_REG = 0x29,
109 REG_I2C_SLV1_CTRL = 0x2a,
111 REG_I2C_SLV2_ADDR = 0x2b,
112 REG_I2C_SLV2_REG = 0x2c,
113 REG_I2C_SLV2_CTRL = 0x2d,
115 REG_I2C_SLV3_ADDR = 0x2e,
116 REG_I2C_SLV3_REG = 0x2f,
117 REG_I2C_SLV3_CTRL = 0x30,
119 REG_I2C_SLV4_ADDR = 0x31,
120 REG_I2C_SLV4_REG = 0x32,
121 REG_I2C_SLV4_DO = 0x33,
122 REG_I2C_SLV4_CTRL = 0x34,
123 REG_I2C_SLV4_DI = 0x35,
125 REG_I2C_MST_STATUS = 0x36,
127 REG_INT_PIN_CFG = 0x37,
128 REG_INT_ENABLE = 0x38,
132 REG_INT_STATUS = 0x3a,
134 REG_ACCEL_XOUT_H = 0x3b,
135 REG_ACCEL_XOUT_L = 0x3c,
137 REG_ACCEL_YOUT_H = 0x3d,
138 REG_ACCEL_YOUT_L = 0x3e,
140 REG_ACCEL_ZOUT_H = 0x3f,
141 REG_ACCEL_ZOUT_L = 0x40,
143 REG_TEMP_OUT_H = 0x41,
144 REG_TEMP_OUT_L = 0x42,
146 REG_GYRO_XOUT_H = 0x43,
147 REG_GYRO_XOUT_L = 0x44,
149 REG_GYRO_YOUT_H = 0x45,
150 REG_GYRO_YOUT_L = 0x46,
152 REG_GYRO_ZOUT_H = 0x47,
153 REG_GYRO_ZOUT_L = 0x48,
155 REG_EXT_SENS_DATA_00 = 0x49,
156 REG_EXT_SENS_DATA_01 = 0x4a,
157 REG_EXT_SENS_DATA_02 = 0x4b,
158 REG_EXT_SENS_DATA_03 = 0x4c,
159 REG_EXT_SENS_DATA_04 = 0x4d,
160 REG_EXT_SENS_DATA_05 = 0x4e,
161 REG_EXT_SENS_DATA_06 = 0x4f,
162 REG_EXT_SENS_DATA_07 = 0x50,
163 REG_EXT_SENS_DATA_08 = 0x51,
164 REG_EXT_SENS_DATA_09 = 0x52,
165 REG_EXT_SENS_DATA_10 = 0x53,
166 REG_EXT_SENS_DATA_11 = 0x54,
167 REG_EXT_SENS_DATA_12 = 0x55,
168 REG_EXT_SENS_DATA_13 = 0x56,
169 REG_EXT_SENS_DATA_14 = 0x57,
170 REG_EXT_SENS_DATA_15 = 0x58,
171 REG_EXT_SENS_DATA_16 = 0x59,
172 REG_EXT_SENS_DATA_17 = 0x5a,
173 REG_EXT_SENS_DATA_18 = 0x5b,
174 REG_EXT_SENS_DATA_19 = 0x5c,
175 REG_EXT_SENS_DATA_20 = 0x5d,
176 REG_EXT_SENS_DATA_21 = 0x5e,
177 REG_EXT_SENS_DATA_22 = 0x5f,
178 REG_EXT_SENS_DATA_23 = 0x60,
180 REG_MOT_DETECT_STATUS = 0x61,
184 REG_I2C_SLV0_DO = 0x63,
185 REG_I2C_SLV1_DO = 0x64,
186 REG_I2C_SLV2_DO = 0x65,
187 REG_I2C_SLV3_DO = 0x66,
189 REG_I2C_MST_DELAY_CTRL = 0x67,
191 REG_SIGNAL_PATH_RESET = 0x68,
193 REG_MOT_DETECT_CTRL = 0x69,
195 REG_USER_CTRL = 0x6a,
197 REG_PWR_MGMT_1 = 0x6b,
198 REG_PWR_MGMT_2 = 0x6c,
202 REG_FIFO_COUNTH = 0x72,
203 REG_FIFO_COUNTL = 0x73,
214 CONFIG_DLPF_CFG0 = 0x01,
215 CONFIG_DLPF_CFG1 = 0x02,
216 CONFIG_DLPF_CFG2 = 0x04,
217 _CONFIG_DLPF_SHIFT = 0,
218 _CONFIG_DLPF_MASK = 7,
220 CONFIG_EXT_SYNC_SET0 = 0x08,
221 CONFIG_EXT_SYNC_SET1 = 0x10,
222 CONFIG_EXT_SYNC_SET2 = 0x20,
223 _CONFIG_EXT_SYNC_SET_SHIFT = 3,
224 _CONFIG_EXT_SYNC_SET_MASK = 7
245 EXT_SYNC_DISABLED = 0,
246 EXT_SYNC_TEMP_OUT = 1,
247 EXT_SYNC_GYRO_XOUT = 2,
248 EXT_SYNC_GYRO_YOUT = 3,
249 EXT_SYNC_GYRO_ZOUT = 4,
250 EXT_SYNC_ACCEL_XOUT = 5,
251 EXT_SYNC_ACCEL_YOUT = 6,
252 EXT_SYNC_ACCEL_ZOUT = 7
313 ACCEL_FIFO_EN = 0x08,
330 _I2C_MST_CLK_SHIFT = 0,
331 _I2C_MST_CLK_MASK = 15,
333 I2C_MST_P_NSR = 0x10,
335 SLV_3_FIFO_EN = 0x20,
368 I2C_SLV_ADDR0 = 0x01,
369 I2C_SLV_ADDR1 = 0x02,
370 I2C_SLV_ADDR2 = 0x04,
371 I2C_SLV_ADDR3 = 0x08,
372 I2C_SLV_ADDR4 = 0x10,
373 I2C_SLV_ADDR5 = 0x20,
374 I2C_SLV_ADDR6 = 0x40,
375 _I2C_SLV_ADDR_SHIFT = 0,
376 _I2C_SLV_ADDR_MASK = 127,
389 _I2C_SLV_LEN_SHIFT = 0,
390 _I2C_SLV_LEN_MASK = 15,
393 I2C_SLV_REG_DIS = 0x20,
394 I2C_SLV_BYTE_SW = 0x40,
414 _I2C_MST_DLY_SHIFT = 0,
415 _I2C_MST_DLY_MASK = 31,
417 I2C_SLV4_REG_DIS = 0x20,
418 I2C_SLV4_INT_EN = 0x40,
426 I2C_SLV0_NACK = 0x01,
427 I2C_SLV1_NACK = 0x02,
428 I2C_SLV2_NACK = 0x04,
429 I2C_SLV3_NACK = 0x08,
430 I2C_SLV4_NACK = 0x10,
433 I2C_SLV4_DONE = 0x40,
443 I2C_BYPASS_ENABLE = 0x02,
446 FSYNC_INT_LEVEL = 0x08,
464 I2C_MST_INT_EN = 0x08,
466 FIFO_OFLOW_EN = 0x10,
483 FIFO_OFLOW_INT = 0x10,
512 I2C_SLV0_DLY_EN = 0x01,
513 I2C_SLV1_DLY_EN = 0x02,
514 I2C_SLV2_DLY_EN = 0x04,
515 I2C_SLV3_DLY_EN = 0x08,
516 I2C_SLV4_DLY_EN = 0x10,
520 DELAY_ES_SHADOW = 0x80
540 _MOT_COUNT_SHIFT = 0,
548 ACCEL_ON_DELAY0 = 0x10,
549 ACCEL_ON_DELAY1 = 0x20,
550 _ACCEL_ON_DELAY_SHIFT = 4,
551 _ACCEL_ON_DELAY_MASK = 3
579 SIG_COND_RESET = 0x01,
580 I2C_MST_RESET = 0x02,
636 LP_WAKE_CTRL0 = 0x40,
637 LP_WAKE_CTRL1 = 0x80,
638 _LP_WAKE_CTRL_SHIFT = 6,
639 _LP_WAKE_CTRL_MASK = 3
659 MPU60X0(
int bus=MPU60X0_I2C_BUS, uint8_t address=MPU60X0_DEFAULT_I2C_ADDR);
704 void readRegs(uint8_t reg, uint8_t *buffer,
int len);
713 bool writeReg(uint8_t reg, uint8_t val);
803 #if defined(SWIGJAVA) || defined(JAVACALLBACK)
920 #if defined(SWIGJAVA) || defined(JAVACALLBACK)
921 void installISR(
int gpio, mraa::Edge level, jobject runnable);
923 void installISR(
int gpio, mraa::Edge level,
void (*isr)(
void *),
void *arg);
954 mraa::Gpio *m_gpioIRQ;
bool setSampleRateDivider(uint8_t div)
Definition: mpu60x0.cxx:282
bool setMotionDetectionThreshold(uint8_t thr)
Definition: mpu60x0.cxx:357
bool setExternalSync(EXT_SYNC_SET_T val)
Definition: mpu60x0.cxx:334
AFS_SEL_T
Definition: mpu60x0.h:298
MOT_DETECT_STATUS_BITS_T
Definition: mpu60x0.h:493
bool enableTemperatureSensor(bool enable)
Definition: mpu60x0.cxx:322
MOT_FF_COUNT_T
Definition: mpu60x0.h:558
MOT_DETECT_CTRL_BITS_T
Definition: mpu60x0.h:537
void getGyroscope(float *x, float *y, float *z)
Definition: mpu60x0.cxx:304
INT_STATUS_BITS_T
Definition: mpu60x0.h:476
bool setAccelerometerScale(AFS_SEL_T scale)
Definition: mpu60x0.cxx:228
uint8_t readReg(uint8_t reg)
Definition: mpu60x0.cxx:139
ACCEL_CONFIG_BITS_T
Definition: mpu60x0.h:283
bool writeReg(uint8_t reg, uint8_t val)
Definition: mpu60x0.cxx:149
EXT_SYNC_SET_T
Definition: mpu60x0.h:244
bool setClockSource(CLKSEL_T clk)
Definition: mpu60x0.cxx:174
uint8_t getSampleRateDivider()
Definition: mpu60x0.cxx:287
PWR_MGMT_2_BITS_T
Definition: mpu60x0.h:628
PWR_MGMT_1_BITS_T
Definition: mpu60x0.h:595
void update()
Definition: mpu60x0.cxx:105
FS_SEL_T
Definition: mpu60x0.h:273
SIGNAL_PATH_RESET_BITS_T
Definition: mpu60x0.h:526
DLPF_CFG_T
Definition: mpu60x0.h:230
MPU60X0(int bus=MPU60X0_I2C_BUS, uint8_t address=MPU60X0_DEFAULT_I2C_ADDR)
Definition: mpu60x0.cxx:35
MST_DELAY_CTRL_BITS_T
Definition: mpu60x0.h:511
I2C_SLV_ADDR_BITS_T
Definition: mpu60x0.h:367
INT_PIN_CFG_BITS_T
Definition: mpu60x0.h:440
MPU60X0_REG_T
Definition: mpu60x0.h:78
void uninstallISR()
Definition: mpu60x0.cxx:415
USER_CTRL_BITS_T
Definition: mpu60x0.h:578
uint8_t getInterruptEnables()
Definition: mpu60x0.cxx:372
I2C_SLV_CTRL_BITS_T
Definition: mpu60x0.h:384
FIFO_EN_BITS_T
Definition: mpu60x0.h:308
bool setDigitalLowPassFilter(DLPF_CFG_T dlp)
Definition: mpu60x0.cxx:271
CLKSEL_T
Definition: mpu60x0.h:614
LP_WAKE_CRTL_T
Definition: mpu60x0.h:645
void installISR(int gpio, mraa::Edge level, void(*isr)(void *), void *arg)
Definition: mpu60x0.cxx:401
void readRegs(uint8_t reg, uint8_t *buffer, int len)
Definition: mpu60x0.cxx:144
virtual float getTemperature()
Definition: mpu60x0.cxx:316
bool setInterruptPinConfig(uint8_t cfg)
Definition: mpu60x0.cxx:377
bool setGyroscopeScale(FS_SEL_T scale)
Definition: mpu60x0.cxx:185
uint8_t getInterruptStatus()
Definition: mpu60x0.cxx:362
I2C_SLV4_CTRL_BITS_T
Definition: mpu60x0.h:408
bool init()
Definition: mpu60x0.cxx:67
ACCEL_ON_DELAY_T
Definition: mpu60x0.h:568
bool setSleep(bool enable)
Definition: mpu60x0.cxx:162
I2C_MST_STATUS_BITS_T
Definition: mpu60x0.h:425
I2C_MST_CTRL_BITS_T
Definition: mpu60x0.h:325
bool enableI2CBypass(bool enable)
Definition: mpu60x0.cxx:345
void getAccelerometer(float *x, float *y, float *z)
Definition: mpu60x0.cxx:292
uint8_t getInterruptPinConfig()
Definition: mpu60x0.cxx:382
GRYO_CONFIG_BITS_T
Definition: mpu60x0.h:258
bool setInterruptEnables(uint8_t enables)
Definition: mpu60x0.cxx:367
I2C_MST_CLK_T
Definition: mpu60x0.h:345
API for the MPU60X0 3-axis Gyroscope and 3-axis Accelerometer.
Definition: mpu60x0.h:61
INT_ENABLE_BITS_T
Definition: mpu60x0.h:459
~MPU60X0()
Definition: mpu60x0.cxx:62
CONFIG_BITS_T
Definition: mpu60x0.h:213