From 2b6aabd1ea4476650c08e5080ddaee2ee03ae38b Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Wed, 15 Dec 2021 02:22:59 -0300 Subject: [PATCH] Forces UART Flush() to wait until all bits are sent --- cores/esp32/esp32-hal-uart.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cores/esp32/esp32-hal-uart.c b/cores/esp32/esp32-hal-uart.c index c3f2df37207..b76d02f18f8 100644 --- a/cores/esp32/esp32-hal-uart.c +++ b/cores/esp32/esp32-hal-uart.c @@ -140,6 +140,9 @@ uart_t* uartBegin(uint8_t uart_nr, uint32_t baudrate, uint32_t config, int8_t rx ESP_ERROR_CHECK(uart_set_line_inverse(uart_nr, UART_SIGNAL_TXD_INV | UART_SIGNAL_RXD_INV)); } + // Set RS485 half duplex mode on UART. This shall force flush to wait up to sending all bits out + ESP_ERROR_CHECK(uart_set_mode(uart_nr, UART_MODE_RS485_HALF_DUPLEX)); + UART_MUTEX_UNLOCK(); uartFlush(uart);