drivers: nrf: uarte: check if RXSTARTED before issue STOPRX

Only issue STOPRX is RX has started.
This prevents getting stuck in while loop.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
This commit is contained in:
Ryan Erickson 2020-04-15 14:06:17 -05:00 committed by Carles Cufí
commit 6243557e5f

View file

@ -1403,11 +1403,15 @@ static void uarte_nrfx_set_power_state(struct device *dev, u32_t new_state)
return; return;
} }
#endif #endif
nrf_uarte_task_trigger(uarte, NRF_UARTE_TASK_STOPRX); if (nrf_uarte_event_check(uarte, NRF_UARTE_EVENT_RXSTARTED)) {
while (!nrf_uarte_event_check(uarte, NRF_UARTE_EVENT_RXTO)) { nrf_uarte_task_trigger(uarte, NRF_UARTE_TASK_STOPRX);
/* Busy wait for event to register */ while (!nrf_uarte_event_check(uarte,
NRF_UARTE_EVENT_RXTO)) {
/* Busy wait for event to register */
}
nrf_uarte_event_clear(uarte, NRF_UARTE_EVENT_RXSTARTED);
nrf_uarte_event_clear(uarte, NRF_UARTE_EVENT_RXTO);
} }
nrf_uarte_event_clear(uarte, NRF_UARTE_EVENT_RXTO);
nrf_uarte_disable(uarte); nrf_uarte_disable(uarte);
uarte_nrfx_pins_enable(dev, false); uarte_nrfx_pins_enable(dev, false);
} }