Skip to content

Commit 47021a6

Browse files
maximevincenashif
authored andcommitted
drivers/sensor: lis2dw12: add bw_filt support
Add bandwidth filter support. (BW_FILT in CTRL6) Value is configurable through DT per instance. Signed-off-by: Maxime Vincent <[email protected]>
1 parent 089f70d commit 47021a6

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

drivers/sensor/lis2dw12/lis2dw12.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,9 @@ static int lis2dw12_init(const struct device *dev)
289289
return ret;
290290
}
291291

292+
LOG_DBG("bandwidth filter is %u", (int)cfg->bw_filt);
293+
lis2dw12_filter_bandwidth_set(ctx, cfg->bw_filt);
294+
292295
#ifdef CONFIG_LIS2DW12_TRIGGER
293296
if (lis2dw12_init_interrupt(dev) < 0) {
294297
LOG_ERR("Failed to initialize interrupts");
@@ -363,6 +366,7 @@ static int lis2dw12_init(const struct device *dev)
363366
}, \
364367
.pm = DT_INST_PROP(inst, power_mode), \
365368
.range = DT_INST_PROP(inst, range), \
369+
.bw_filt = DT_INST_PROP(inst, bw_filt), \
366370
LIS2DW12_CONFIG_TAP(inst) \
367371
COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, irq_gpios), \
368372
(LIS2DW12_CFG_IRQ(inst)), ()) \
@@ -387,6 +391,7 @@ static int lis2dw12_init(const struct device *dev)
387391
}, \
388392
.pm = DT_INST_PROP(inst, power_mode), \
389393
.range = DT_INST_PROP(inst, range), \
394+
.bw_filt = DT_INST_PROP(inst, bw_filt), \
390395
LIS2DW12_CONFIG_TAP(inst) \
391396
COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, irq_gpios), \
392397
(LIS2DW12_CFG_IRQ(inst)), ()) \

drivers/sensor/lis2dw12/lis2dw12.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ struct lis2dw12_device_config {
6868
} stmemsc_cfg;
6969
lis2dw12_mode_t pm;
7070
uint8_t range;
71+
uint8_t bw_filt;
7172
#ifdef CONFIG_LIS2DW12_TRIGGER
7273
struct gpio_dt_spec gpio_int;
7374
uint8_t int_pin;

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,24 @@ properties:
4848
- 4
4949
- 2
5050

51+
bw-filt:
52+
type: int
53+
required: false
54+
default: 0
55+
description: |
56+
Digital filtering cutoff bandwidth. Default is power-up configuration.
57+
58+
3 # ODR/20 (HP/LP)
59+
2 # ODR/10 (HP/LP)
60+
1 # ODR/ 4 (HP/LP)
61+
0 # ODR/ 2 (up to ODR = 800 Hz, 400 Hz when ODR = 1600 Hz)
62+
63+
enum:
64+
- 3
65+
- 2
66+
- 1
67+
- 0
68+
5169
power-mode:
5270
type: int
5371
required: false

0 commit comments

Comments
 (0)