Skip to content
Browse files

drivers: nrf: Trigger STOP RX event and wait before disabling UARTE

Without first triggering TASKS_STOP{RX,TX}, I observed that the UARTE
was never disabled when using device_set_power_state which resulted in
the HFCLK never being shut down and several hundred microamps in
unnecessary current consumption when idle. This seems to fix the issue.

Also added special treatment of uarte if CONFIG_UART_ASYNC_API is
selected. Note that the #ifdef isn't enough, since it's possible that
the option is set, but only one of the UARTs uses it.

Signed-off-by: Benjamin Lindqvist <>
  • Loading branch information...
endian-benjamin authored and carlescufi committed Apr 29, 2019
1 parent 75a3ee5 commit 55e2014d995a4a6b73cc1d967bdd4fd452ceb03e
Showing with 15 additions and 0 deletions.
  1. +15 −0 drivers/serial/uart_nrfx_uarte.c
@@ -1189,6 +1189,21 @@ static void uarte_nrfx_set_power_state(struct device *dev, u32_t new_state)
assert(new_state == DEVICE_PM_LOW_POWER_STATE ||
new_state == DEVICE_PM_OFF_STATE);

/* Disabling UART requires stopping RX, but stop RX event is
* only sent after each RX if async UART API is used.
if (get_dev_data(dev)->async) {
nrf_uarte_task_trigger(uarte, NRF_UARTE_TASK_STOPRX);
while (!nrf_uarte_event_check(uarte, NRF_UARTE_EVENT_RXTO)) {
/* Busy wait for event to register */
nrf_uarte_event_clear(uarte, NRF_UARTE_EVENT_RXTO);

0 comments on commit 55e2014

Please sign in to comment.
You can’t perform that action at this time.