drivers: serial: nrf_uarte: Reset rx byte counters

Reset rx byte counters when hw timer/counter is disabled.

Fixes issue where disabling and re-enabling async uart rx can produce
"UART_RX_RDY" events with invalid data when power management is used.

Signed-off-by: Audun Korneliussen <audun.korneliussen@nordicsemi.no>
This commit is contained in:
Audun Korneliussen 2020-09-24 11:28:19 +02:00 committed by Ioannis Glaropoulos
commit 1e227d1576

View file

@ -1452,6 +1452,9 @@ static void uarte_nrfx_set_power_state(const struct device *dev,
#ifdef CONFIG_UART_ASYNC_API
if (hw_rx_counting_enabled(get_dev_data(dev))) {
nrfx_timer_disable(&get_dev_config(dev)->timer);
/* Timer/counter value is reset when disabled. */
data->async->rx_total_byte_cnt = 0;
data->async->rx_total_user_byte_cnt = 0;
}
if (get_dev_data(dev)->async) {
nrf_uarte_disable(uarte);