This is an automated email from the ASF dual-hosted git repository. vipulrahane pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
The following commit(s) were added to refs/heads/master by this push: new 3ca7d75 LIS2DW12: Added mapping of int2 to int1. (#1007) 3ca7d75 is described below commit 3ca7d7589e47041c6838b561b8f28a6ad1eda64d Author: brolan-juul <33846322+brolan-j...@users.noreply.github.com> AuthorDate: Tue Apr 10 15:40:43 2018 -0700 LIS2DW12: Added mapping of int2 to int1. (#1007) --- .../sensors/lis2dw12/include/lis2dw12/lis2dw12.h | 21 +++++++- hw/drivers/sensors/lis2dw12/src/lis2dw12.c | 57 +++++++++++++++++++++- 2 files changed, 75 insertions(+), 3 deletions(-) diff --git a/hw/drivers/sensors/lis2dw12/include/lis2dw12/lis2dw12.h b/hw/drivers/sensors/lis2dw12/include/lis2dw12/lis2dw12.h index 6d6362f..d6241f8 100644 --- a/hw/drivers/sensors/lis2dw12/include/lis2dw12/lis2dw12.h +++ b/hw/drivers/sensors/lis2dw12/include/lis2dw12/lis2dw12.h @@ -185,6 +185,7 @@ struct lis2dw12_cfg { uint8_t int1_pin_cfg; uint8_t int2_pin_cfg; + bool map_int2_to_int1; uint8_t int_enable; enum lis2dw12_fifo_mode fifo_mode; @@ -654,7 +655,25 @@ int lis2dw12_set_stationary_en(struct sensor_itf *itf, uint8_t en); * @return 0 on success, non-zero on failure */ int lis2dw12_get_stationary_en(struct sensor_itf *itf, uint8_t *en); - + +/** + * Set whether interrupts are enabled + * + * @param the sensor interface + * @param value to set (0 = disabled, 1 = enabled) + * @return 0 on success, non-zero on failure + */ +int lis2dw12_set_int1_on_int2_map(struct sensor_itf *itf, bool enable); + +/** + * Get whether interrupt 1 signals is mapped onto interrupt 2 pin + * + * @param the sensor interface + * @param value to set (0 = disabled, 1 = enabled) + * @return 0 on success, non-zero on failure + */ +int lis2dw12_get_int1_on_int2_map(struct sensor_itf *itf, uint8_t *val); + /** * Run Self test on sensor * diff --git a/hw/drivers/sensors/lis2dw12/src/lis2dw12.c b/hw/drivers/sensors/lis2dw12/src/lis2dw12.c index 41f4824..85d253c 100644 --- a/hw/drivers/sensors/lis2dw12/src/lis2dw12.c +++ b/hw/drivers/sensors/lis2dw12/src/lis2dw12.c @@ -1457,6 +1457,53 @@ int lis2dw12_set_int_enable(struct sensor_itf *itf, uint8_t enabled) } /** + * Set whether interrupt 1 signals is mapped onto interrupt 2 pin + * + * @param the sensor interface + * @param value to set (false = disabled, true = enabled) + * @return 0 on success, non-zero on failure + */ +int lis2dw12_set_int1_on_int2_map(struct sensor_itf *itf, bool enable) +{ + uint8_t reg; + int rc; + + rc = lis2dw12_read8(itf, LIS2DW12_REG_CTRL_REG7, ®); + if (rc) { + return rc; + } + + if (enable) { + reg |= LIS2DW12_CTRL_REG7_INT2_ON_INT1; + } else { + reg &= ~LIS2DW12_CTRL_REG7_INT2_ON_INT1; + } + + return lis2dw12_write8(itf, LIS2DW12_REG_CTRL_REG7, reg); +} + +/** + * Get whether interrupt 1 signals is mapped onto interrupt 2 pin + * + * @param the sensor interface + * @param value to set (0 = disabled, 1 = enabled) + * @return 0 on success, non-zero on failure + */ +int lis2dw12_get_int1_on_int2_map(struct sensor_itf *itf, uint8_t *val) +{ + uint8_t reg; + int rc; + + rc = lis2dw12_read8(itf, LIS2DW12_REG_CTRL_REG7, ®); + if (rc) { + return rc; + } + + *val = (reg & LIS2DW12_CTRL_REG7_INT2_ON_INT1) >> 5; + return 0; +} + +/** * Run Self test on sensor * * @param the sensor interface @@ -1608,7 +1655,7 @@ lis2dw12_int_irq_handler(void *arg) if(lis2dw12->pdd.interrupt) { wake_interrupt(lis2dw12->pdd.interrupt); } - + sensor_mgr_put_interrupt_evt(sensor); } @@ -2418,7 +2465,13 @@ lis2dw12_config(struct lis2dw12 *lis2dw12, struct lis2dw12_cfg *cfg) goto err; } lis2dw12->cfg.tap_cfg = cfg->tap_cfg; - + + rc = lis2dw12_set_int1_on_int2_map(itf, cfg->map_int2_to_int1); + if(rc) { + goto err; + } + lis2dw12->cfg.map_int2_to_int1 = cfg->map_int2_to_int1; + rc = sensor_set_type_mask(&(lis2dw12->sensor), cfg->mask); if (rc) { goto err; -- To stop receiving notification emails like this one, please contact vipulrah...@apache.org.