Skip to content

Instantly share code, notes, and snippets.

@reefwing
Created March 22, 2023 07:24
Show Gist options
  • Save reefwing/74bb9a288314b721034810328e6e6656 to your computer and use it in GitHub Desktop.
Save reefwing/74bb9a288314b721034810328e6e6656 to your computer and use it in GitHub Desktop.
LSM9DS1 Who Am I register check
uint8_t ReefwingLSM9DS1::whoAmIGyro() {
// Read WHO_AM_I register for LSM9DS1 accel/gyro
return readByte(LSM9DS1AG_ADDRESS, LSM9DS1AG_WHO_AM_I);
}
uint8_t ReefwingLSM9DS1::whoAmIMag() {
// Read WHO_AM_I register for LSM9DS1 magnetometer
return readByte(LSM9DS1M_ADDRESS, LSM9DS1M_WHO_AM_I);
}
bool ReefwingLSM9DS1::connected() {
return (whoAmIGyro() == LSM9DS1AG_WHO_AM_I_VALUE &&
whoAmIMag() == LSM9DS1M_WHO_AM_I_VALUE);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment