samples: boards: stm32: serial_wakeup: fix device usage issues
Device ready check was wrong (< 0 ?!), so fix it. Also drop static qualifier for the device variable (not needed) and initialize at definition time. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
7fc33f9d47
commit
a11848fc32
1 changed files with 5 additions and 8 deletions
|
@ -11,19 +11,16 @@
|
|||
#include <zephyr/sys/printk.h>
|
||||
#include <zephyr/sys/__assert.h>
|
||||
|
||||
#define DEV_NAME DT_CHOSEN(zephyr_console)
|
||||
|
||||
void main(void)
|
||||
{
|
||||
static const struct device *dev;
|
||||
const struct device *const dev =
|
||||
DEVICE_DT_GET(DT_CHOSEN(zephyr_console));
|
||||
|
||||
dev = DEVICE_DT_GET(DEV_NAME);
|
||||
if (dev < 0) {
|
||||
printk("Failed to get device");
|
||||
if (!device_is_ready(dev)) {
|
||||
printk("Console device not ready");
|
||||
return;
|
||||
}
|
||||
|
||||
printk("Device ready\n");
|
||||
|
||||
#if CONFIG_PM_DEVICE
|
||||
/* In PM_DEVICE modes, enable device as a wakeup source will prevent
|
||||
* system to switch it off (clock off, set pins to sleep configuration, ...)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue