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), \
|
||||
.hp_filter_path = DT_INST_PROP(inst, hp_filter_path), \
|
||||
.hp_ref_mode = DT_INST_PROP(inst, hp_ref_mode), \
|
||||
.drdy_pulsed = DT_INST_PROP(inst, drdy_pulsed), \
|
||||
LIS2DW12_CONFIG_TAP(inst) \
|
||||
COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, irq_gpios), \
|
||||
(LIS2DW12_CFG_IRQ(inst)), ()) \
|
||||
|
@ -531,6 +532,7 @@ static int lis2dw12_init(const struct device *dev)
|
|||
.low_noise = DT_INST_PROP(inst, low_noise), \
|
||||
.hp_filter_path = DT_INST_PROP(inst, hp_filter_path), \
|
||||
.hp_ref_mode = DT_INST_PROP(inst, hp_ref_mode), \
|
||||
.drdy_pulsed = DT_INST_PROP(inst, drdy_pulsed), \
|
||||
LIS2DW12_CONFIG_TAP(inst) \
|
||||
COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, irq_gpios), \
|
||||
(LIS2DW12_CFG_IRQ(inst)), ()) \
|
||||
|
|
|
@ -72,6 +72,7 @@ struct lis2dw12_device_config {
|
|||
bool low_noise;
|
||||
bool hp_filter_path;
|
||||
bool hp_ref_mode;
|
||||
bool drdy_pulsed;
|
||||
#ifdef CONFIG_LIS2DW12_TRIGGER
|
||||
struct gpio_dt_spec gpio_int;
|
||||
uint8_t int_pin;
|
||||
|
|
|
@ -422,9 +422,14 @@ int lis2dw12_init_interrupt(const struct device *dev)
|
|||
return -EIO;
|
||||
}
|
||||
|
||||
/* enable interrupt on int1/int2 in pulse mode */
|
||||
if (lis2dw12_int_notification_set(ctx, LIS2DW12_INT_PULSED)) {
|
||||
return -EIO;
|
||||
/* set interrupt notification mode on int1/int2 */
|
||||
LOG_DBG("drdy_pulsed is %d", (int)cfg->drdy_pulsed);
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue