Suspending uart with Zephyr console

NCS 3.02 54L10

I am using uart0 in async mode for printk and user input (my own callback not zephyr CLI). I need to be able to put the uart into suspend after an inactivity timeout to reduce current consumption.

Based on advice from ticket 344896 I am using rc = pm_device_action_run(uart_dev, PM_DEVICE_ACTION_SUSPEND) gets me an error -88 Not Implemented.

These are my config options:

CONFIG_SERIAL=y
CONFIG_PM_DEVICE=y
CONFIG_UART_ASYNC_API=y
CONFIG_UART_ASYNC_ADAPTER=y
CONFIG_UART_CONSOLE=y
CONFIG_PM_DEVICE=y
CONFIG_PM_DEVICE_RUNTIME=y
CONFIG_CONSOLE=y

I get a feeling this might be because the console is using the driver? In any case, how can I force a shutdown of the uart? It doesn't matter if there is no way of restarting it outside of a reboot.

  • Thanks, this works OK for me.

    Back to my project, it seems it is because I am using Async. After a bit of hacking around this is the offending code in my uart_init, culled from your peripheral_uart example:

    		/* Implement API adapter */
    		uart_async_adapter_init(async_adapter, uart);
    		uart = async_adapter;

    Removing it my CLI no longer works of course, but uart suspend/resume now does. (Note the CLI is my own using a uart callback rather than Zephyr's, because the Zephyr CLI doesn't support the format required for this app)

    Given this, any ideas how to suspend the uart?

  • Why is an adapter used instead of native async support in the UART driver? Our R&D thinks the adapter was mainly added to emulate the UART async API on devices that do not support it (primarily for USB CDC ACM). When using UART0, I would not use the adapter at all.

Related