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 <benjamin.lindqvist@endian.se>
This commit is contained in:
parent
75a3ee5240
commit
55e2014d99
1 changed files with 15 additions and 0 deletions
|
@ -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_SUSPEND_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.
|
||||
*/
|
||||
#ifdef CONFIG_UART_ASYNC_API
|
||||
if (get_dev_data(dev)->async) {
|
||||
nrf_uarte_disable(uarte);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
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);
|
||||
nrf_uarte_disable(uarte);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue