drivers/sensor: lis2dw12: add drdy pulsed/latched config
Add DT option to configure the data ready interrupt mode. Latched is the default; pulsed can be enabled through the drdy-pulsed DT, if desired. Signed-off-by: Maxime Vincent <maxime@veemax.be>
This commit is contained in:
parent
bf1334bafb
commit
307a60e217
4 changed files with 19 additions and 3 deletions
|
@ -503,6 +503,7 @@ static int lis2dw12_init(const struct device *dev)
|
||||||
.low_noise = DT_INST_PROP(inst, low_noise), \
|
.low_noise = DT_INST_PROP(inst, low_noise), \
|
||||||
.hp_filter_path = DT_INST_PROP(inst, hp_filter_path), \
|
.hp_filter_path = DT_INST_PROP(inst, hp_filter_path), \
|
||||||
.hp_ref_mode = DT_INST_PROP(inst, hp_ref_mode), \
|
.hp_ref_mode = DT_INST_PROP(inst, hp_ref_mode), \
|
||||||
|
.drdy_pulsed = DT_INST_PROP(inst, drdy_pulsed), \
|
||||||
LIS2DW12_CONFIG_TAP(inst) \
|
LIS2DW12_CONFIG_TAP(inst) \
|
||||||
COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, irq_gpios), \
|
COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, irq_gpios), \
|
||||||
(LIS2DW12_CFG_IRQ(inst)), ()) \
|
(LIS2DW12_CFG_IRQ(inst)), ()) \
|
||||||
|
@ -531,6 +532,7 @@ static int lis2dw12_init(const struct device *dev)
|
||||||
.low_noise = DT_INST_PROP(inst, low_noise), \
|
.low_noise = DT_INST_PROP(inst, low_noise), \
|
||||||
.hp_filter_path = DT_INST_PROP(inst, hp_filter_path), \
|
.hp_filter_path = DT_INST_PROP(inst, hp_filter_path), \
|
||||||
.hp_ref_mode = DT_INST_PROP(inst, hp_ref_mode), \
|
.hp_ref_mode = DT_INST_PROP(inst, hp_ref_mode), \
|
||||||
|
.drdy_pulsed = DT_INST_PROP(inst, drdy_pulsed), \
|
||||||
LIS2DW12_CONFIG_TAP(inst) \
|
LIS2DW12_CONFIG_TAP(inst) \
|
||||||
COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, irq_gpios), \
|
COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, irq_gpios), \
|
||||||
(LIS2DW12_CFG_IRQ(inst)), ()) \
|
(LIS2DW12_CFG_IRQ(inst)), ()) \
|
||||||
|
|
|
@ -72,6 +72,7 @@ struct lis2dw12_device_config {
|
||||||
bool low_noise;
|
bool low_noise;
|
||||||
bool hp_filter_path;
|
bool hp_filter_path;
|
||||||
bool hp_ref_mode;
|
bool hp_ref_mode;
|
||||||
|
bool drdy_pulsed;
|
||||||
#ifdef CONFIG_LIS2DW12_TRIGGER
|
#ifdef CONFIG_LIS2DW12_TRIGGER
|
||||||
struct gpio_dt_spec gpio_int;
|
struct gpio_dt_spec gpio_int;
|
||||||
uint8_t int_pin;
|
uint8_t int_pin;
|
||||||
|
|
|
@ -422,9 +422,14 @@ int lis2dw12_init_interrupt(const struct device *dev)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* enable interrupt on int1/int2 in pulse mode */
|
/* set interrupt notification mode on int1/int2 */
|
||||||
if (lis2dw12_int_notification_set(ctx, LIS2DW12_INT_PULSED)) {
|
LOG_DBG("drdy_pulsed is %d", (int)cfg->drdy_pulsed);
|
||||||
return -EIO;
|
lis2dw12_lir_t mode = cfg->drdy_pulsed ? LIS2DW12_INT_PULSED : LIS2DW12_INT_LATCHED;
|
||||||
|
|
||||||
|
ret = lis2dw12_int_notification_set(ctx, mode);
|
||||||
|
if (ret < 0) {
|
||||||
|
LOG_ERR("drdy_pulsed config error %d", (int)cfg->drdy_pulsed);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_LIS2DW12_TAP
|
#ifdef CONFIG_LIS2DW12_TAP
|
||||||
|
|
|
@ -187,3 +187,11 @@ properties:
|
||||||
of the LIS2DW12.
|
of the LIS2DW12.
|
||||||
Note that this influences both the OUT_REG / FIFO values,
|
Note that this influences both the OUT_REG / FIFO values,
|
||||||
as well as the Wakeup function.
|
as well as the Wakeup function.
|
||||||
|
|
||||||
|
drdy-pulsed:
|
||||||
|
type: boolean
|
||||||
|
required: false
|
||||||
|
description: |
|
||||||
|
Selects the pulsed mode for data-ready interrupt when enabled,
|
||||||
|
and the latched mode when disabled.
|
||||||
|
Sets the corresponding DRDY_PULSED bit in the CTRL7 register.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue