Skip to content

Commit 307a60e

Browse files
maximevincenashif
authored andcommitted
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 <[email protected]>
1 parent bf1334b commit 307a60e

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

drivers/sensor/lis2dw12/lis2dw12.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,7 @@ static int lis2dw12_init(const struct device *dev)
503503
.low_noise = DT_INST_PROP(inst, low_noise), \
504504
.hp_filter_path = DT_INST_PROP(inst, hp_filter_path), \
505505
.hp_ref_mode = DT_INST_PROP(inst, hp_ref_mode), \
506+
.drdy_pulsed = DT_INST_PROP(inst, drdy_pulsed), \
506507
LIS2DW12_CONFIG_TAP(inst) \
507508
COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, irq_gpios), \
508509
(LIS2DW12_CFG_IRQ(inst)), ()) \
@@ -531,6 +532,7 @@ static int lis2dw12_init(const struct device *dev)
531532
.low_noise = DT_INST_PROP(inst, low_noise), \
532533
.hp_filter_path = DT_INST_PROP(inst, hp_filter_path), \
533534
.hp_ref_mode = DT_INST_PROP(inst, hp_ref_mode), \
535+
.drdy_pulsed = DT_INST_PROP(inst, drdy_pulsed), \
534536
LIS2DW12_CONFIG_TAP(inst) \
535537
COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, irq_gpios), \
536538
(LIS2DW12_CFG_IRQ(inst)), ()) \

drivers/sensor/lis2dw12/lis2dw12.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ struct lis2dw12_device_config {
7272
bool low_noise;
7373
bool hp_filter_path;
7474
bool hp_ref_mode;
75+
bool drdy_pulsed;
7576
#ifdef CONFIG_LIS2DW12_TRIGGER
7677
struct gpio_dt_spec gpio_int;
7778
uint8_t int_pin;

drivers/sensor/lis2dw12/lis2dw12_trigger.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,9 +422,14 @@ int lis2dw12_init_interrupt(const struct device *dev)
422422
return -EIO;
423423
}
424424

425-
/* enable interrupt on int1/int2 in pulse mode */
426-
if (lis2dw12_int_notification_set(ctx, LIS2DW12_INT_PULSED)) {
427-
return -EIO;
425+
/* set interrupt notification mode on int1/int2 */
426+
LOG_DBG("drdy_pulsed is %d", (int)cfg->drdy_pulsed);
427+
lis2dw12_lir_t mode = cfg->drdy_pulsed ? LIS2DW12_INT_PULSED : LIS2DW12_INT_LATCHED;
428+
429+
ret = lis2dw12_int_notification_set(ctx, mode);
430+
if (ret < 0) {
431+
LOG_ERR("drdy_pulsed config error %d", (int)cfg->drdy_pulsed);
432+
return ret;
428433
}
429434

430435
#ifdef CONFIG_LIS2DW12_TAP

dts/bindings/sensor/st,lis2dw12-common.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,3 +187,11 @@ properties:
187187
of the LIS2DW12.
188188
Note that this influences both the OUT_REG / FIFO values,
189189
as well as the Wakeup function.
190+
191+
drdy-pulsed:
192+
type: boolean
193+
required: false
194+
description: |
195+
Selects the pulsed mode for data-ready interrupt when enabled,
196+
and the latched mode when disabled.
197+
Sets the corresponding DRDY_PULSED bit in the CTRL7 register.

0 commit comments

Comments
 (0)