samples: lsm6dso: Convert to use DEVICE_DT_GET_ONE
Move to use DEVICE_DT_GET_ONE instead of device_get_binding as we work on phasing out use of DTS 'label' property. Also, Removed 'lsm6dso' from board & sample yaml's and move to just filtering based on devicetree compat. Signed-off-by: Kumar Gala <galak@kernel.org>
This commit is contained in:
parent
0cc2b37d04
commit
c96f8f9c29
|
@ -8,7 +8,6 @@ toolchain:
|
||||||
supported:
|
supported:
|
||||||
- gpio
|
- gpio
|
||||||
- i2c
|
- i2c
|
||||||
- lsm6dso
|
|
||||||
- lptim
|
- lptim
|
||||||
- pwm
|
- pwm
|
||||||
- watchdog
|
- watchdog
|
||||||
|
|
|
@ -8,7 +8,6 @@ toolchain:
|
||||||
supported:
|
supported:
|
||||||
- gpio
|
- gpio
|
||||||
- i2c
|
- i2c
|
||||||
- lsm6dso
|
|
||||||
- lptim
|
- lptim
|
||||||
- dac
|
- dac
|
||||||
- spi
|
- spi
|
||||||
|
|
|
@ -4,8 +4,8 @@ tests:
|
||||||
sample.sensor.lsm6dso:
|
sample.sensor.lsm6dso:
|
||||||
harness: console
|
harness: console
|
||||||
tags: sensors
|
tags: sensors
|
||||||
depends_on: lsm6dso
|
|
||||||
timeout: 15
|
timeout: 15
|
||||||
|
filter: dt_compat_enabled("st,lsm6dso")
|
||||||
harness_config:
|
harness_config:
|
||||||
type: multi_line
|
type: multi_line
|
||||||
ordered: true
|
ordered: true
|
||||||
|
|
|
@ -9,15 +9,6 @@
|
||||||
#include <zephyr/device.h>
|
#include <zephyr/device.h>
|
||||||
#include <zephyr/drivers/sensor.h>
|
#include <zephyr/drivers/sensor.h>
|
||||||
|
|
||||||
#define LSM6DSO DT_INST(0, st_lsm6dso)
|
|
||||||
|
|
||||||
#if DT_NODE_HAS_STATUS(LSM6DSO, okay)
|
|
||||||
#define LSM6DSO_LABEL DT_LABEL(LSM6DSO)
|
|
||||||
#else
|
|
||||||
#error Your devicetree has no enabled nodes with compatible "st,lsm6dso"
|
|
||||||
#define LSM6DSO_LABEL "<none>"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static inline float out_ev(struct sensor_value *val)
|
static inline float out_ev(struct sensor_value *val)
|
||||||
{
|
{
|
||||||
return (val->val1 + (float)val->val2 / 1000000);
|
return (val->val1 + (float)val->val2 / 1000000);
|
||||||
|
@ -116,10 +107,10 @@ static void test_polling_mode(const struct device *dev)
|
||||||
|
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
const struct device *dev = device_get_binding(LSM6DSO_LABEL);
|
const struct device *dev = DEVICE_DT_GET_ONE(st_lsm6dso);
|
||||||
|
|
||||||
if (dev == NULL) {
|
if (!device_is_ready(dev)) {
|
||||||
printf("No device \"%s\" found.\n", LSM6DSO_LABEL);
|
printk("%s: device not ready.\n", dev->name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue