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 80 REG_SELF_TEST_X = 0x0d,
81 REG_SELF_TEST_Y = 0x0e,
82 REG_SELF_TEST_Z = 0x0f,
83 REG_SELF_TEST_A = 0x10,
85 REG_SMPLRT_DIV = 0x19,
88 REG_GYRO_CONFIG = 0x1b,
89 REG_ACCEL_CONFIG = 0x1c,
102 REG_I2C_MST_CTRL = 0x24,
104 REG_I2C_SLV0_ADDR = 0x25,
105 REG_I2C_SLV0_REG = 0x26,
106 REG_I2C_SLV0_CTRL = 0x27,
108 REG_I2C_SLV1_ADDR = 0x28,
109 REG_I2C_SLV1_REG = 0x29,
110 REG_I2C_SLV1_CTRL = 0x2a,
112 REG_I2C_SLV2_ADDR = 0x2b,
113 REG_I2C_SLV2_REG = 0x2c,
114 REG_I2C_SLV2_CTRL = 0x2d,
116 REG_I2C_SLV3_ADDR = 0x2e,
117 REG_I2C_SLV3_REG = 0x2f,
118 REG_I2C_SLV3_CTRL = 0x30,
120 REG_I2C_SLV4_ADDR = 0x31,
121 REG_I2C_SLV4_REG = 0x32,
122 REG_I2C_SLV4_DO = 0x33,
123 REG_I2C_SLV4_CTRL = 0x34,
124 REG_I2C_SLV4_DI = 0x35,
126 REG_I2C_MST_STATUS = 0x36,
128 REG_INT_PIN_CFG = 0x37,
129 REG_INT_ENABLE = 0x38,
133 REG_INT_STATUS = 0x3a,
135 REG_ACCEL_XOUT_H = 0x3b,
136 REG_ACCEL_XOUT_L = 0x3c,
138 REG_ACCEL_YOUT_H = 0x3d,
139 REG_ACCEL_YOUT_L = 0x3e,
141 REG_ACCEL_ZOUT_H = 0x3f,
142 REG_ACCEL_ZOUT_L = 0x40,
144 REG_TEMP_OUT_H = 0x41,
145 REG_TEMP_OUT_L = 0x42,
147 REG_GYRO_XOUT_H = 0x43,
148 REG_GYRO_XOUT_L = 0x44,
150 REG_GYRO_YOUT_H = 0x45,
151 REG_GYRO_YOUT_L = 0x46,
153 REG_GYRO_ZOUT_H = 0x47,
154 REG_GYRO_ZOUT_L = 0x48,
156 REG_EXT_SENS_DATA_00 = 0x49,
157 REG_EXT_SENS_DATA_01 = 0x4a,
158 REG_EXT_SENS_DATA_02 = 0x4b,
159 REG_EXT_SENS_DATA_03 = 0x4c,
160 REG_EXT_SENS_DATA_04 = 0x4d,
161 REG_EXT_SENS_DATA_05 = 0x4e,
162 REG_EXT_SENS_DATA_06 = 0x4f,
163 REG_EXT_SENS_DATA_07 = 0x50,
164 REG_EXT_SENS_DATA_08 = 0x51,
165 REG_EXT_SENS_DATA_09 = 0x52,
166 REG_EXT_SENS_DATA_10 = 0x53,
167 REG_EXT_SENS_DATA_11 = 0x54,
168 REG_EXT_SENS_DATA_12 = 0x55,
169 REG_EXT_SENS_DATA_13 = 0x56,
170 REG_EXT_SENS_DATA_14 = 0x57,
171 REG_EXT_SENS_DATA_15 = 0x58,
172 REG_EXT_SENS_DATA_16 = 0x59,
173 REG_EXT_SENS_DATA_17 = 0x5a,
174 REG_EXT_SENS_DATA_18 = 0x5b,
175 REG_EXT_SENS_DATA_19 = 0x5c,
176 REG_EXT_SENS_DATA_20 = 0x5d,
177 REG_EXT_SENS_DATA_21 = 0x5e,
178 REG_EXT_SENS_DATA_22 = 0x5f,
179 REG_EXT_SENS_DATA_23 = 0x60,
181 REG_MOT_DETECT_STATUS = 0x61,
185 REG_I2C_SLV0_DO = 0x63,
186 REG_I2C_SLV1_DO = 0x64,
187 REG_I2C_SLV2_DO = 0x65,
188 REG_I2C_SLV3_DO = 0x66,
190 REG_I2C_MST_DELAY_CTRL = 0x67,
192 REG_SIGNAL_PATH_RESET = 0x68,
194 REG_MOT_DETECT_CTRL = 0x69,
196 REG_USER_CTRL = 0x6a,
198 REG_PWR_MGMT_1 = 0x6b,
199 REG_PWR_MGMT_2 = 0x6c,
203 REG_FIFO_COUNTH = 0x72,
204 REG_FIFO_COUNTL = 0x73,
215 CONFIG_DLPF_CFG0 = 0x01,
216 CONFIG_DLPF_CFG1 = 0x02,
217 CONFIG_DLPF_CFG2 = 0x04,
218 _CONFIG_DLPF_SHIFT = 0,
219 _CONFIG_DLPF_MASK = 7,
221 CONFIG_EXT_SYNC_SET0 = 0x08,
222 CONFIG_EXT_SYNC_SET1 = 0x10,
223 CONFIG_EXT_SYNC_SET2 = 0x20,
224 _CONFIG_EXT_SYNC_SET_SHIFT = 3,
225 _CONFIG_EXT_SYNC_SET_MASK = 7
246 EXT_SYNC_DISABLED = 0,
247 EXT_SYNC_TEMP_OUT = 1,
248 EXT_SYNC_GYRO_XOUT = 2,
249 EXT_SYNC_GYRO_YOUT = 3,
250 EXT_SYNC_GYRO_ZOUT = 4,
251 EXT_SYNC_ACCEL_XOUT = 5,
252 EXT_SYNC_ACCEL_YOUT = 6,
253 EXT_SYNC_ACCEL_ZOUT = 7
314 ACCEL_FIFO_EN = 0x08,
331 _I2C_MST_CLK_SHIFT = 0,
332 _I2C_MST_CLK_MASK = 15,
334 I2C_MST_P_NSR = 0x10,
336 SLV_3_FIFO_EN = 0x20,
369 I2C_SLV_ADDR0 = 0x01,
370 I2C_SLV_ADDR1 = 0x02,
371 I2C_SLV_ADDR2 = 0x04,
372 I2C_SLV_ADDR3 = 0x08,
373 I2C_SLV_ADDR4 = 0x10,
374 I2C_SLV_ADDR5 = 0x20,
375 I2C_SLV_ADDR6 = 0x40,
376 _I2C_SLV_ADDR_SHIFT = 0,
377 _I2C_SLV_ADDR_MASK = 127,
390 _I2C_SLV_LEN_SHIFT = 0,
391 _I2C_SLV_LEN_MASK = 15,
394 I2C_SLV_REG_DIS = 0x20,
395 I2C_SLV_BYTE_SW = 0x40,
415 _I2C_MST_DLY_SHIFT = 0,
416 _I2C_MST_DLY_MASK = 31,
418 I2C_SLV4_REG_DIS = 0x20,
419 I2C_SLV4_INT_EN = 0x40,
427 I2C_SLV0_NACK = 0x01,
428 I2C_SLV1_NACK = 0x02,
429 I2C_SLV2_NACK = 0x04,
430 I2C_SLV3_NACK = 0x08,
431 I2C_SLV4_NACK = 0x10,
434 I2C_SLV4_DONE = 0x40,
444 I2C_BYPASS_ENABLE = 0x02,
447 FSYNC_INT_LEVEL = 0x08,
465 I2C_MST_INT_EN = 0x08,
467 FIFO_OFLOW_EN = 0x10,
484 FIFO_OFLOW_INT = 0x10,
513 I2C_SLV0_DLY_EN = 0x01,
514 I2C_SLV1_DLY_EN = 0x02,
515 I2C_SLV2_DLY_EN = 0x04,
516 I2C_SLV3_DLY_EN = 0x08,
517 I2C_SLV4_DLY_EN = 0x10,
521 DELAY_ES_SHADOW = 0x80
541 _MOT_COUNT_SHIFT = 0,
549 ACCEL_ON_DELAY0 = 0x10,
550 ACCEL_ON_DELAY1 = 0x20,
551 _ACCEL_ON_DELAY_SHIFT = 4,
552 _ACCEL_ON_DELAY_MASK = 3
580 SIG_COND_RESET = 0x01,
581 I2C_MST_RESET = 0x02,
637 LP_WAKE_CTRL0 = 0x40,
638 LP_WAKE_CTRL1 = 0x80,
639 _LP_WAKE_CTRL_SHIFT = 6,
640 _LP_WAKE_CTRL_MASK = 3
660 MPU60X0(
int bus=MPU60X0_I2C_BUS, uint8_t address=MPU60X0_DEFAULT_I2C_ADDR);
705 void readRegs(uint8_t reg, uint8_t *buffer,
int len);
714 bool writeReg(uint8_t reg, uint8_t val);
905 void installISR(
int gpio, mraa::Edge level,
void (*isr)(
void *),
void *arg);
913 mraa::Gpio* get_gpioIRQ();
941 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.hpp:299
MOT_DETECT_STATUS_BITS_T
Definition: mpu60x0.hpp:494
bool enableTemperatureSensor(bool enable)
Definition: mpu60x0.cxx:322
MOT_FF_COUNT_T
Definition: mpu60x0.hpp:559
MOT_DETECT_CTRL_BITS_T
Definition: mpu60x0.hpp:538
void getGyroscope(float *x, float *y, float *z)
Definition: mpu60x0.cxx:304
INT_STATUS_BITS_T
Definition: mpu60x0.hpp:477
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.hpp:284
bool writeReg(uint8_t reg, uint8_t val)
Definition: mpu60x0.cxx:149
EXT_SYNC_SET_T
Definition: mpu60x0.hpp:245
bool setClockSource(CLKSEL_T clk)
Definition: mpu60x0.cxx:174
uint8_t getSampleRateDivider()
Definition: mpu60x0.cxx:287
PWR_MGMT_2_BITS_T
Definition: mpu60x0.hpp:629
PWR_MGMT_1_BITS_T
Definition: mpu60x0.hpp:596
void update()
Definition: mpu60x0.cxx:105
FS_SEL_T
Definition: mpu60x0.hpp:274
SIGNAL_PATH_RESET_BITS_T
Definition: mpu60x0.hpp:527
DLPF_CFG_T
Definition: mpu60x0.hpp:231
MPU60X0(int bus=MPU60X0_I2C_BUS, uint8_t address=MPU60X0_DEFAULT_I2C_ADDR)
Definition: mpu60x0.cxx:35
MST_DELAY_CTRL_BITS_T
Definition: mpu60x0.hpp:512
I2C_SLV_ADDR_BITS_T
Definition: mpu60x0.hpp:368
INT_PIN_CFG_BITS_T
Definition: mpu60x0.hpp:441
MPU60X0_REG_T
Definition: mpu60x0.hpp:79
C++ API wrapper for the bh1749 driver.
Definition: a110x.hpp:29
void uninstallISR()
Definition: mpu60x0.cxx:402
USER_CTRL_BITS_T
Definition: mpu60x0.hpp:579
uint8_t getInterruptEnables()
Definition: mpu60x0.cxx:372
I2C_SLV_CTRL_BITS_T
Definition: mpu60x0.hpp:385
FIFO_EN_BITS_T
Definition: mpu60x0.hpp:309
bool setDigitalLowPassFilter(DLPF_CFG_T dlp)
Definition: mpu60x0.cxx:271
CLKSEL_T
Definition: mpu60x0.hpp:615
LP_WAKE_CRTL_T
Definition: mpu60x0.hpp:646
void installISR(int gpio, mraa::Edge level, void(*isr)(void *), void *arg)
Definition: mpu60x0.cxx:388
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.hpp:409
bool init()
Definition: mpu60x0.cxx:67
ACCEL_ON_DELAY_T
Definition: mpu60x0.hpp:569
bool setSleep(bool enable)
Definition: mpu60x0.cxx:162
I2C_MST_STATUS_BITS_T
Definition: mpu60x0.hpp:426
I2C_MST_CTRL_BITS_T
Definition: mpu60x0.hpp:326
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.hpp:259
bool setInterruptEnables(uint8_t enables)
Definition: mpu60x0.cxx:367
I2C_MST_CLK_T
Definition: mpu60x0.hpp:346
API for the MPU60X0 3-axis Gyroscope and 3-axis Accelerometer.
Definition: mpu60x0.hpp:62
INT_ENABLE_BITS_T
Definition: mpu60x0.hpp:460
virtual ~MPU60X0()
Definition: mpu60x0.cxx:62
CONFIG_BITS_T
Definition: mpu60x0.hpp:214