diff options
author | Joey Castillo <joeycastillo@utexas.edu> | 2021-11-30 20:02:41 -0500 |
---|---|---|
committer | Joey Castillo <joeycastillo@utexas.edu> | 2021-11-30 20:02:41 -0500 |
commit | 45282f2ef40a54e337b1596af45009c609981130 (patch) | |
tree | ee6f9f2f6edcfcf046046e5d508ebd9c69173c5d /watch-library/driver | |
parent | 4ae46f907b2c6f54f87c350920d7f297967764fe (diff) | |
download | Sensor-Watch-45282f2ef40a54e337b1596af45009c609981130.tar.gz Sensor-Watch-45282f2ef40a54e337b1596af45009c609981130.tar.bz2 Sensor-Watch-45282f2ef40a54e337b1596af45009c609981130.zip |
lis2dh driver: add support for int2 pin
Diffstat (limited to 'watch-library/driver')
-rw-r--r-- | watch-library/driver/lis2dh.c | 12 | ||||
-rw-r--r-- | watch-library/driver/lis2dh.h | 8 |
2 files changed, 20 insertions, 0 deletions
diff --git a/watch-library/driver/lis2dh.c b/watch-library/driver/lis2dh.c index 2ebf53fb..8266905f 100644 --- a/watch-library/driver/lis2dh.c +++ b/watch-library/driver/lis2dh.c @@ -125,3 +125,15 @@ void lis2dh_configure_aoi_int1(lis2dh_interrupt_configuration configuration, uin lis2dh_interrupt_state lis2dh_get_int1_state() { return (lis2dh_interrupt_state) watch_i2c_read8(LIS2DH_ADDRESS, LIS2DH_REG_INT1_SRC); } + +void lis2dh_configure_aoi_int2(lis2dh_interrupt_configuration configuration, uint8_t threshold, uint8_t duration) { + watch_i2c_write8(LIS2DH_ADDRESS, LIS2DH_REG_CTRL6, LIS2DH_CTRL6_VAL_I2_INT2); + watch_i2c_write8(LIS2DH_ADDRESS, LIS2DH_REG_INT2_CFG, configuration); + watch_i2c_write8(LIS2DH_ADDRESS, LIS2DH_REG_INT2_THS, threshold); + watch_i2c_write8(LIS2DH_ADDRESS, LIS2DH_REG_INT2_DUR, duration); +} + +lis2dh_interrupt_state lis2dh_get_int2_state() { + return (lis2dh_interrupt_state) watch_i2c_read8(LIS2DH_ADDRESS, LIS2DH_REG_INT2_SRC); +} + diff --git a/watch-library/driver/lis2dh.h b/watch-library/driver/lis2dh.h index b8162a4c..f3e7ec84 100644 --- a/watch-library/driver/lis2dh.h +++ b/watch-library/driver/lis2dh.h @@ -106,6 +106,10 @@ void lis2dh_configure_aoi_int1(lis2dh_interrupt_configuration configuration, uin lis2dh_interrupt_state lis2dh_get_int1_state(); +void lis2dh_configure_aoi_int2(lis2dh_interrupt_configuration configuration, uint8_t threshold, uint8_t duration); + +lis2dh_interrupt_state lis2dh_get_int2_state(); + // Assumes SA0 is high; if low, its 0x18 #define LIS2DH_ADDRESS (0x19) @@ -204,6 +208,10 @@ lis2dh_interrupt_state lis2dh_get_int1_state(); #define LIS2DH_REG_INT1_SRC 0x31 #define LIS2DH_REG_INT1_THS 0x32 #define LIS2DH_REG_INT1_DUR 0x33 +#define LIS2DH_REG_INT2_CFG 0x34 +#define LIS2DH_REG_INT2_SRC 0x35 +#define LIS2DH_REG_INT2_THS 0x36 +#define LIS2DH_REG_INT2_DUR 0x37 #define LIS2DH_REG_CLICK_CFG 0x38 #define LIS2DH_REG_CLICK_SRC 0x39 #define LIS2DH_REG_CLICK_THS 0x3A |