drivers/sensor: lps22hh: Move odr Kconfig property into dts

Move odr options from Kconfigs to Device Tree.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
This commit is contained in:
Armando Visconti 2021-12-13 18:05:14 +01:00 committed by Maureen Helm
commit 56b435f2bf
4 changed files with 24 additions and 22 deletions

View file

@ -52,24 +52,4 @@ config LPS22HH_THREAD_STACK_SIZE
help help
Stack size of thread used by the driver to handle interrupts. Stack size of thread used by the driver to handle interrupts.
menu "Attributes"
config LPS22HH_SAMPLING_RATE
int "Output data rate"
range 0 7
default 0
help
Sensor output data rate expressed in samples per second.
Data rates supported by the chip are:
0: ODR selected at runtime
1: 1Hz
2: 10Hz
3: 25Hz
4: 50Hz
5: 75Hz
6: 100Hz
7: 200Hz
endmenu
endif # LPS22HH endif # LPS22HH

View file

@ -171,9 +171,11 @@ static int lps22hh_init_chip(const struct device *dev)
LOG_DBG("%s: chip id 0x%x", dev->name, chip_id); LOG_DBG("%s: chip id 0x%x", dev->name, chip_id);
ret = lps22hh_set_odr_raw(dev, CONFIG_LPS22HH_SAMPLING_RATE); /* set sensor default odr */
LOG_DBG("%s: odr: %d", dev->name, cfg->odr);
ret = lps22hh_set_odr_raw(dev, cfg->odr);
if (ret < 0) { if (ret < 0) {
LOG_ERR("%s: Failed to set sampling rate", dev->name); LOG_ERR("%s: Failed to set odr %d", dev->name, cfg->odr);
return ret; return ret;
} }
@ -237,6 +239,7 @@ static int lps22hh_init(const struct device *dev)
LPS22HH_SPI_OPERATION, \ LPS22HH_SPI_OPERATION, \
0), \ 0), \
}, \ }, \
.odr = DT_INST_PROP(inst, odr), \
COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, drdy_gpios), \ COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, drdy_gpios), \
(LPS22HH_CFG_IRQ(inst)), ()) \ (LPS22HH_CFG_IRQ(inst)), ()) \
} }
@ -258,6 +261,7 @@ static int lps22hh_init(const struct device *dev)
.stmemsc_cfg = { \ .stmemsc_cfg = { \
.i2c = I2C_DT_SPEC_INST_GET(inst), \ .i2c = I2C_DT_SPEC_INST_GET(inst), \
}, \ }, \
.odr = DT_INST_PROP(inst, odr), \
COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, drdy_gpios), \ COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, drdy_gpios), \
(LPS22HH_CFG_IRQ(inst)), ()) \ (LPS22HH_CFG_IRQ(inst)), ()) \
} }

View file

@ -33,6 +33,7 @@ struct lps22hh_config {
const struct spi_dt_spec spi; const struct spi_dt_spec spi;
#endif #endif
} stmemsc_cfg; } stmemsc_cfg;
uint8_t odr;
#ifdef CONFIG_LPS22HH_TRIGGER #ifdef CONFIG_LPS22HH_TRIGGER
struct gpio_dt_spec gpio_int; struct gpio_dt_spec gpio_int;
#endif #endif

View file

@ -11,3 +11,20 @@ properties:
This pin defaults to active high when produced by the sensor. This pin defaults to active high when produced by the sensor.
The property value should ensure the flags properly describe The property value should ensure the flags properly describe
the signal that is presented to the driver. the signal that is presented to the driver.
odr:
type: int
required: false
default: 0
description: |
Specify the default output data rate expressed in samples per second (Hz).
Default is power-down mode
enum:
- 0 # Power-Down
- 1 # 1Hz
- 2 # 10Hz
- 3 # 25Hz
- 4 # 50Hz
- 5 # 75Hz
- 6 # 100Hz
- 7 # 200Hz