/*
 * Copyright (c) 2012-2014 Wind River Systems, Inc.
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#include <stdio.h>

#include <zephyr/device.h>
#include <zephyr/kernel.h>
#include <zephyr/pm/device.h>

#define UART_DEVICE_NODE DT_CHOSEN(zephyr_console)

static const struct device *const uart_dev = DEVICE_DT_GET(UART_DEVICE_NODE);

int main(void)
{
	int err;

	printf("Hello World! %s\n", CONFIG_BOARD_TARGET);
	if (device_is_ready(uart_dev))
    {
		printk("Put the peripheral into suspended state.\n");
		err = pm_device_action_run(uart_dev, PM_DEVICE_ACTION_SUSPEND);
		if (err) {
			printk("UART suspend failed. (err %d)\n", err);
		}
	
		k_sleep(K_MSEC(1000));
	
		err = pm_device_action_run(uart_dev, PM_DEVICE_ACTION_RESUME);
		if (err) {
			printk("UART resume failed. (err %d)\n", err);
		} else {
			printk("Resume the peripheral from the suspended state.\n");
		}
	} else {
		printk("UART device not ready.\n");
	}

	return 0;
}
