drivers: serial: nrf_uarte: Add missing check for async API
uarte_enable function was not supporting a case when async
api was enabled but instance did not use it. Added runtime
check for async instance presence.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
diff --git a/drivers/serial/uart_nrfx_uarte.c b/drivers/serial/uart_nrfx_uarte.c
index 3aeb921..5e358b6 100644
--- a/drivers/serial/uart_nrfx_uarte.c
+++ b/drivers/serial/uart_nrfx_uarte.c
@@ -514,16 +514,19 @@
{
#ifdef CONFIG_UART_ASYNC_API
struct uarte_nrfx_data *data = get_dev_data(dev);
- bool disabled = data->async->low_power_mask == 0;
- data->async->low_power_mask |= mask;
- if (hw_rx_counting_enabled(data) && disabled) {
- const nrfx_timer_t *timer = &get_dev_config(dev)->timer;
+ if (data->async) {
+ bool disabled = data->async->low_power_mask == 0;
- nrfx_timer_enable(timer);
+ data->async->low_power_mask |= mask;
+ if (hw_rx_counting_enabled(data) && disabled) {
+ const nrfx_timer_t *timer = &get_dev_config(dev)->timer;
- for (int i = 0; i < data->async->rx_flush_cnt; i++) {
- nrfx_timer_increment(timer);
+ nrfx_timer_enable(timer);
+
+ for (int i = 0; i < data->async->rx_flush_cnt; i++) {
+ nrfx_timer_increment(timer);
+ }
}
}
#endif