Skip to content

Instantly share code, notes, and snippets.

@reefwing
Created April 4, 2023 00:48
Show Gist options
  • Save reefwing/32b6145b033de5caac71422e3828eba9 to your computer and use it in GitHub Desktop.
Save reefwing/32b6145b033de5caac71422e3828eba9 to your computer and use it in GitHub Desktop.
void ReefwingLSM9DS1::start() {
// Initialise the Gyro - assumes configuration is done
// Control Register 4 - enable gyro axis output bits (5, 4 & 3)
// The other bits default to 0. CTRL_REG4 = 0b00111000 = 0x38
writeByte(LSM9DS1AG_ADDRESS, LSM9DS1AG_CTRL_REG4, 0x38);
// Initialise the Accelerometer
// Control Register 5 XL - enable accel axis output bits (5, 4 & 3)
// The other bits default to 0. CTRL_REG5_XL = 0b00111000 = 0x38
writeByte(LSM9DS1AG_ADDRESS, LSM9DS1AG_CTRL_REG5_XL, 0x38);
// Enable block data update, allow auto-increment during multiple byte read,
// data LSB @ lower address. CTRL_REG8 = 0b01000100 = 0x44
writeByte(LSM9DS1AG_ADDRESS, LSM9DS1AG_CTRL_REG8, 0x44);
// Initialise the Magnetometer
// Enable block data update
writeByte(LSM9DS1M_ADDRESS, LSM9DS1M_CTRL_REG5_M, 0x40 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment