summaryrefslogtreecommitdiffstats
path: root/watch-library/driver
diff options
context:
space:
mode:
authorJoey Castillo <joeycastillo@utexas.edu>2022-01-09 12:12:41 -0500
committerJoey Castillo <joeycastillo@utexas.edu>2022-01-09 12:12:41 -0500
commita10267552260466d0dd50432faffbdbceec94eb6 (patch)
tree8bb3f0097f547f120b95e127e27c9b6bcd941b55 /watch-library/driver
parent54762248a33e3a26701966d403ada6eb5bba86a5 (diff)
downloadSensor-Watch-a10267552260466d0dd50432faffbdbceec94eb6.tar.gz
Sensor-Watch-a10267552260466d0dd50432faffbdbceec94eb6.tar.bz2
Sensor-Watch-a10267552260466d0dd50432faffbdbceec94eb6.zip
set correct registers for range and rate
Diffstat (limited to 'watch-library/driver')
-rw-r--r--watch-library/driver/lis2dw.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/watch-library/driver/lis2dw.c b/watch-library/driver/lis2dw.c
index 4e0cc473..4e506a6d 100644
--- a/watch-library/driver/lis2dw.c
+++ b/watch-library/driver/lis2dw.c
@@ -92,21 +92,21 @@ lis2dw_reading lis2dw_get_raw_reading(void) {
}
void lis2dw_set_range(lis2dw_range_t range) {
- uint8_t val = watch_i2c_read8(LIS2DW_ADDRESS, LIS2DW_REG_CTRL4) & 0xCF;
+ uint8_t val = watch_i2c_read8(LIS2DW_ADDRESS, LIS2DW_REG_CTRL6) & ~(LIS2DW_RANGE_16_G << 4);
uint8_t bits = range << 4;
- watch_i2c_write8(LIS2DW_ADDRESS, LIS2DW_REG_CTRL4, val | bits);
+ watch_i2c_write8(LIS2DW_ADDRESS, LIS2DW_REG_CTRL6, val | bits);
}
lis2dw_range_t lis2dw_get_range(void) {
- uint8_t retval = watch_i2c_read8(LIS2DW_ADDRESS, LIS2DW_REG_CTRL4) & 0x30;
+ uint8_t retval = watch_i2c_read8(LIS2DW_ADDRESS, LIS2DW_REG_CTRL6) & (LIS2DW_RANGE_16_G << 4);
retval >>= 4;
return (lis2dw_range_t)retval;
}
void lis2dw_set_data_rate(lis2dw_data_rate_t dataRate) {
- uint8_t val = watch_i2c_read8(LIS2DW_ADDRESS, LIS2DW_REG_CTRL1) & 0x0F;
+ uint8_t val = watch_i2c_read8(LIS2DW_ADDRESS, LIS2DW_REG_CTRL1) & ~(0b1111 << 4);
uint8_t bits = dataRate << 4;
watch_i2c_write8(LIS2DW_ADDRESS, LIS2DW_REG_CTRL1, val | bits);