From d0d9d978eb57e2c9ce996d8a7cbab3e8dd1c37d5 Mon Sep 17 00:00:00 2001 From: robert-hh Date: Mon, 22 Sep 2025 18:31:28 +0200 Subject: [PATCH] esp32/machine_uart: Call uart_wait_tx_done() only with driver installed. Otherwise an error message will pop up at the first instatiation of the UART object. Addresses #18122 / #18123. Signed-off-by: robert-hh --- ports/esp32/machine_uart.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ports/esp32/machine_uart.c b/ports/esp32/machine_uart.c index 36b5bcb0ff..ea403f4221 100644 --- a/ports/esp32/machine_uart.c +++ b/ports/esp32/machine_uart.c @@ -253,9 +253,6 @@ static void mp_machine_uart_init_helper(machine_uart_obj_t *self, size_t n_args, mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - // wait for all data to be transmitted before changing settings - uart_wait_tx_done(self->uart_num, pdMS_TO_TICKS(1000)); - // If UART is being freshly initialised then restore object defaults if (!uart_is_driver_installed(self->uart_num)) { self->bits = 8; @@ -299,6 +296,9 @@ static void mp_machine_uart_init_helper(machine_uart_obj_t *self, size_t n_args, case UART_NUM_MAX: assert(0); // Range is checked in mp_machine_uart_make_new, value should be unreachable } + } else { + // wait for all data to be transmitted before changing settings + uart_wait_tx_done(self->uart_num, pdMS_TO_TICKS(1000)); } // Default driver parameters, should correspond to values set above