samples: sensor: lsm303dlhc_magn: Convert sample 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. Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
This commit is contained in:
parent
45b70fc8cf
commit
97275659ac
1 changed files with 6 additions and 10 deletions
|
@ -38,20 +38,16 @@ end:
|
|||
|
||||
void main(void)
|
||||
{
|
||||
const struct device *accelerometer = device_get_binding(
|
||||
DT_LABEL(DT_INST(0, st_lis2dh)));
|
||||
const struct device *magnetometer = device_get_binding(
|
||||
DT_LABEL(DT_INST(0, st_lsm303dlhc_magn)));
|
||||
const struct device *accelerometer = DEVICE_DT_GET_ONE(st_lis2dh);
|
||||
const struct device *magnetometer = DEVICE_DT_GET_ONE(st_lsm303dlhc_magn);
|
||||
|
||||
if (accelerometer == NULL) {
|
||||
printf("Could not get %s device\n",
|
||||
DT_LABEL(DT_INST(0, st_lis2dh)));
|
||||
if (!device_is_ready(accelerometer)) {
|
||||
printf("Device %s is not ready\n", accelerometer->name);
|
||||
return;
|
||||
}
|
||||
|
||||
if (magnetometer == NULL) {
|
||||
printf("Could not get %s device\n",
|
||||
DT_LABEL(DT_INST(0, st_lsm303dlhc_magn)));
|
||||
if (!device_is_ready(magnetometer)) {
|
||||
printf("Device %s is not ready\n", magnetometer->name);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue