Skip to content

Commit

Permalink
[DNM] samples: sensor: lsm6dso: test deferred initialization
Browse files Browse the repository at this point in the history
Show how deferred initialization works.

Signed-off-by: Gerard Marull-Paretas <[email protected]>
  • Loading branch information
gmarull committed Nov 6, 2023
1 parent 8cd00d9 commit bf9825d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
9 changes: 9 additions & 0 deletions samples/sensor/lsm6dso/boards/stm32l562e_dk.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Copyright (c) Nordic Semiconductor ASA
* SPDX-License-Identifier: Apache-2.0
*/

&lsm6dso {
status = "disabled";
zephyr,deferred-init;
};
8 changes: 5 additions & 3 deletions samples/sensor/lsm6dso/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,12 @@ static void test_polling_mode(const struct device *dev)

int main(void)
{
const struct device *const dev = DEVICE_DT_GET_ONE(st_lsm6dso);
int ret;
const struct device *const dev = DEVICE_DT_GET(DT_NODELABEL(lsm6dso));

if (!device_is_ready(dev)) {
printk("%s: device not ready.\n", dev->name);
ret = device_init(dev);
if (ret < 0) {
printk("Could not initialize device %s\n", dev->name);
return 0;
}

Expand Down

0 comments on commit bf9825d

Please sign in to comment.