Last active
April 12, 2023 23:42
-
-
Save reefwing/6e40b08da47abe43630d5c3f7914cb76 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::setGyroBandwidth(GyroBW bandwidth) { | |
uint8_t CTRL_REG1_G = readByte(LSM9DS1AG_ADDRESS, LSM9DS1AG_CTRL_REG1_G); | |
// Clear the BW_G bits (0 & 1), maintain the rest | |
// 0xFC = 0b11111100, BW_G = 00, bandwidth = LOW (default) | |
CTRL_REG1_G &= 0xFC; | |
switch(bandwidth) { | |
case GyroBW::MIDDLE: // BW_G = 01 | |
CTRL_REG1_G |= 0x01; | |
break; | |
case GyroBW::HIGHEST: // BW_G = 10 | |
CTRL_REG1_G |= 0x02; | |
break; | |
case GyroBW::MAXIMUM: // BW_G = 11 | |
CTRL_REG1_G |= 0x03; | |
break; | |
default: // BW_G = 00, bandwidth = LOW (default) | |
break; | |
} | |
_config.gyro.bandwidth = bandwidth; | |
writeByte(LSM9DS1AG_ADDRESS, LSM9DS1AG_CTRL_REG1_G, CTRL_REG1_G); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment