summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoey Castillo <joeycastillo@utexas.edu>2022-02-19 13:11:47 -0500
committerJoey Castillo <joeycastillo@utexas.edu>2022-02-19 13:11:47 -0500
commit3392f73d360c46d2bd79eec2c530a78d9657cf8c (patch)
tree63d0ecfac902386215298e5dde6dd789bf50c1df
parentb1bec8f18740486383ce3c8dfcf1b697f00a67f6 (diff)
downloadSensor-Watch-3392f73d360c46d2bd79eec2c530a78d9657cf8c.tar.gz
Sensor-Watch-3392f73d360c46d2bd79eec2c530a78d9657cf8c.tar.bz2
Sensor-Watch-3392f73d360c46d2bd79eec2c530a78d9657cf8c.zip
lis2dw: add support for high performance mode
-rw-r--r--watch-library/shared/driver/lis2dw.c11
-rw-r--r--watch-library/shared/driver/lis2dw.h4
2 files changed, 15 insertions, 0 deletions
diff --git a/watch-library/shared/driver/lis2dw.c b/watch-library/shared/driver/lis2dw.c
index 1b1ecf11..318ea2e8 100644
--- a/watch-library/shared/driver/lis2dw.c
+++ b/watch-library/shared/driver/lis2dw.c
@@ -139,6 +139,17 @@ lis2dw_bandwidth_filtering_mode_t lis2dw_get_filtering(void) {
return (lis2dw_bandwidth_filtering_mode_t)retval;
}
+void lis2dw_set_mode(lis2dw_mode_t mode) {
+ uint8_t val = watch_i2c_read8(LIS2DW_ADDRESS, LIS2DW_REG_CTRL1) & ~(0b1100);
+ uint8_t bits = (mode << 2) & 0b1100;
+
+ watch_i2c_write8(LIS2DW_ADDRESS, LIS2DW_REG_CTRL1, val | bits);
+}
+
+lis2dw_mode_t lis2dw_get_mode(void) {
+ return (lis2dw_mode_t)(watch_i2c_read8(LIS2DW_ADDRESS, LIS2DW_REG_CTRL1) & 0b1100) >> 2;
+}
+
void lis2dw_set_low_power_mode(lis2dw_low_power_mode_t mode) {
uint8_t val = watch_i2c_read8(LIS2DW_ADDRESS, LIS2DW_REG_CTRL1) & ~(0b11);
uint8_t bits = mode & 0b11;
diff --git a/watch-library/shared/driver/lis2dw.h b/watch-library/shared/driver/lis2dw.h
index 83b0cfb1..ac5de929 100644
--- a/watch-library/shared/driver/lis2dw.h
+++ b/watch-library/shared/driver/lis2dw.h
@@ -291,6 +291,10 @@ void lis2dw_set_bandwidth_filtering(lis2dw_bandwidth_filtering_mode_t bwfilter);
lis2dw_bandwidth_filtering_mode_t lis2dw_get_filtering(void);
+void lis2dw_set_mode(lis2dw_mode_t mode);
+
+lis2dw_mode_t lis2dw_get_mode(void);
+
void lis2dw_set_low_power_mode(lis2dw_low_power_mode_t mode);
lis2dw_low_power_mode_t lis2dw_get_low_power_mode(void);