5 #define LSM6DS33_WHO_ID 0x69
6 #define LIS3MDL_WHO_ID 0x3D
13 if (testReg(LSM6DS33_ADDR, LSM6DS33_REG_WHO_AM_I) == LSM6DS33_WHO_ID &&
14 testReg( LIS3MDL_ADDR, LIS3MDL_REG_WHO_AM_I) == LIS3MDL_WHO_ID)
35 writeReg(LSM6DS33_ADDR, LSM6DS33_REG_CTRL1_XL, 0x30);
36 if (lastError) {
return; }
42 writeReg(LSM6DS33_ADDR, LSM6DS33_REG_CTRL2_G, 0x50);
43 if (lastError) {
return; }
49 writeReg(LSM6DS33_ADDR, LSM6DS33_REG_CTRL3_C, 0x04);
50 if (lastError) {
return; }
56 writeReg(LIS3MDL_ADDR, LIS3MDL_REG_CTRL_REG1, 0x70);
57 if (lastError) {
return; }
61 writeReg(LIS3MDL_ADDR, LIS3MDL_REG_CTRL_REG2, 0x00);
62 if (lastError) {
return; }
66 writeReg(LIS3MDL_ADDR, LIS3MDL_REG_CTRL_REG3, 0x00);
67 if (lastError) {
return; }
71 writeReg(LIS3MDL_ADDR, LIS3MDL_REG_CTRL_REG4, 0x0C);
88 writeReg(LSM6DS33_ADDR, LSM6DS33_REG_CTRL2_G, 0x7C);
105 writeReg(LSM6DS33_ADDR, LSM6DS33_REG_CTRL1_XL, 0x10);
122 writeReg(LIS3MDL_ADDR, LIS3MDL_REG_CTRL_REG1, 0x7C);
136 readAxes16Bit(LSM6DS33_ADDR, LSM6DS33_REG_OUTX_L_XL,
a);
150 readAxes16Bit(LSM6DS33_ADDR, LSM6DS33_REG_OUTX_L_G,
g);
164 readAxes16Bit(LIS3MDL_ADDR, LIS3MDL_REG_OUT_X_L | (1 << 7),
m);
176 if (lastError) {
return; }
178 if (lastError) {
return; }
187 return readReg(LSM6DS33_ADDR, LSM6DS33_REG_STATUS_REG) & 0x01;
198 return readReg(LSM6DS33_ADDR, LSM6DS33_REG_STATUS_REG) & 0x02;
209 return readReg(LIS3MDL_ADDR, LIS3MDL_REG_STATUS_REG) & 0x08;
void configureForFaceUphill()
Configures the sensors with settings optimized for the FaceUphill example program.
void readGyro()
Takes a reading from the gyro and makes the measurements available in g.
bool gyroDataReady()
Indicates whether the gyro has new measurement data ready.
bool accDataReady()
Indicates whether the accelerometer has new measurement data ready.
bool init()
Initializes the inertial sensors and detects their type.
void writeReg(uint8_t addr, uint8_t reg, uint8_t value)
Writes an 8-bit sensor register.
vector< int16_t > m
Raw magnetometer readings.
void configureForCompassHeading()
Configures the sensors with settings optimized for determining a compass heading with the magnetomete...
void readAcc()
Takes a reading from the accelerometer and makes the measurements available in a.
void readMag()
Takes a reading from the magnetometer and makes the measurements available in m.
void enableDefault()
Enables all of the inertial sensors with a default configuration.
uint8_t readReg(uint8_t addr, uint8_t reg)
Reads an 8-bit sensor register.
vector< int16_t > a
Raw accelerometer readings.
vector< int16_t > g
Raw gyro readings.
void read()
Takes a reading from all three sensors (accelerometer, gyro, and magnetometer) and makes their measur...
void configureForTurnSensing()
Configures the sensors with settings optimized for turn sensing.
bool magDataReady()
Indicates whether the magnetometer has new measurement data ready.
Top-level namespace for the Pololu3piPlus32U4 library.
@ LSM6DS33_LIS3MDL
LSM6DS33 gyro + accelerometer, LIS3MDL magnetometer.