Skip to content

Commit e0f06e2

Browse files
aviscontiMaureenHelm
authored andcommitted
drivers/sensor: lis2ds12: Move range Kconfig property into dts
Converts lis2ds12 range options (2g, 4g, 8g, 16g) from Kconfig to Device Tree. Signed-off-by: Armando Visconti <[email protected]>
1 parent 2a48d49 commit e0f06e2

File tree

4 files changed

+19
-15
lines changed

4 files changed

+19
-15
lines changed

drivers/sensor/lis2ds12/Kconfig

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,6 @@ config LIS2DS12_ENABLE_TEMP
5757

5858
menu "Attributes"
5959

60-
config LIS2DS12_FS
61-
int "Accelerometer full-scale range"
62-
default 0
63-
help
64-
Specify the default accelerometer full-scale range.
65-
An X value for the config represents a range of +/- X G. Valid values
66-
are:
67-
0: Full Scale selected at runtime
68-
2: +/- 2g
69-
4: +/- 4g
70-
8: +/- 8g
71-
16: +/- 16g
72-
7360
config LIS2DS12_ODR
7461
int "Accelerometer Output data rate frequency"
7562
range 0 10

drivers/sensor/lis2ds12/lis2ds12.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,10 @@ static int lis2ds12_init(const struct device *dev)
258258
}
259259

260260
/* set sensor default scale */
261-
ret = lis2ds12_set_range(dev, CONFIG_LIS2DS12_FS);
261+
LOG_DBG("%s: range is %d", dev->name, cfg->range);
262+
ret = lis2ds12_set_range(dev, cfg->range);
262263
if (ret < 0) {
263-
LOG_ERR("%s: range init error %d", dev->name, CONFIG_LIS2DS12_FS);
264+
LOG_ERR("%s: range init error %d", dev->name, cfg->range);
264265
return ret;
265266
}
266267

@@ -317,6 +318,7 @@ static int lis2ds12_init(const struct device *dev)
317318
LIS2DS12_SPI_OPERATION, \
318319
0), \
319320
}, \
321+
.range = DT_INST_PROP(inst, range), \
320322
COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, irq_gpios), \
321323
(LIS2DS12_CFG_IRQ(inst)), ()) \
322324
}
@@ -338,6 +340,7 @@ static int lis2ds12_init(const struct device *dev)
338340
.stmemsc_cfg = { \
339341
.i2c = I2C_DT_SPEC_INST_GET(inst), \
340342
}, \
343+
.range = DT_INST_PROP(inst, range), \
341344
COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, irq_gpios), \
342345
(LIS2DS12_CFG_IRQ(inst)), ()) \
343346
}

drivers/sensor/lis2ds12/lis2ds12.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ struct lis2ds12_config {
4040
const struct spi_dt_spec spi;
4141
#endif
4242
} stmemsc_cfg;
43+
uint8_t range;
4344
#ifdef CONFIG_LIS2DS12_TRIGGER
4445
struct gpio_dt_spec gpio_int;
4546
#endif

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,16 @@ properties:
1111
This pin defaults to active high when produced by the sensor.
1212
The property value should ensure the flags properly describe
1313
the signal that is presented to the driver.
14+
15+
range:
16+
type: int
17+
required: false
18+
default: 2
19+
description: |
20+
Range in g. Default is power-up configuration.
21+
22+
enum:
23+
- 16 # 16g (0.488 mg/LSB)
24+
- 8 # 8g (0.244 mg/LSB)
25+
- 4 # 4g (0.122 mg/LSB)
26+
- 2 # 2g (0.061 mg/LSB)

0 commit comments

Comments
 (0)