Last active
April 8, 2023 08:21
-
-
Save reefwing/3148f06d883a0060bcaf89f4880119d9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void ReefwingLSM9DS1::setAccelBandwidth(AccelBW bandwidth) { | |
if (!_config.accel.autoBandwidthEnable) { | |
uint8_t CTRL_REG6_XL = readByte(LSM9DS1AG_ADDRESS, LSM9DS1AG_CTRL_REG6_XL); | |
// Clear the BW_XL bits (1 & 0), maintain the rest | |
// 0xFC = 0b11111100, BW_XL = 00, bandwidth = 408 Hz (default) | |
CTRL_REG6_XL &= 0xFC; | |
switch(bandwidth) { | |
case AccelBW::BW_50Hz: // BW_XL = 11 | |
CTRL_REG6_XL |= 0x03; | |
break; | |
case AccelBW::BW_105Hz: // BW_XL = 10 | |
CTRL_REG6_XL |= 0x02; | |
break; | |
case AccelBW::BW_211Hz: // BW_XL = 01 | |
CTRL_REG6_XL |= 0x01; | |
break; | |
default: // BW_XL = 00, bandwidth = 408 Hz (default) | |
break; | |
} | |
_config.accel.bandwidth = bandwidth; | |
writeByte(LSM9DS1AG_ADDRESS, LSM9DS1AG_CTRL_REG6_XL, CTRL_REG6_XL); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment