From adae99f85c04cdfc083276062d50c99f827ae357 Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Fri, 28 Jun 2024 11:42:00 -0300 Subject: [PATCH 1/3] fix(uart): Set back Pin signal polarity Fixes a problem related to inverting signal polarity back to normal after a previous inversion. This shall set the correct polarity in Serial.begin(). --- cores/esp32/esp32-hal-uart.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cores/esp32/esp32-hal-uart.c b/cores/esp32/esp32-hal-uart.c index 68a600b51c5..d74f4bb8a05 100644 --- a/cores/esp32/esp32-hal-uart.c +++ b/cores/esp32/esp32-hal-uart.c @@ -514,11 +514,16 @@ uart_t *uartBegin( } // Is it right or the idea is to swap rx and tx pins? - if (retCode && inverted) { - // invert signal for both Rx and Tx - retCode &= ESP_OK == uart_set_line_inverse(uart_nr, UART_SIGNAL_TXD_INV | UART_SIGNAL_RXD_INV); + if (retCode) { + if (inverted) { + // invert signal for both Rx and Tx + retCode &= ESP_OK == uart_set_line_inverse(uart_nr, UART_SIGNAL_TXD_INV | UART_SIGNAL_RXD_INV); + } else { + // invert signal for both Rx and Tx + retCode &= ESP_OK == uart_set_line_inverse(uart_nr, UART_SIGNAL_INV_DISABLE); + } } - + // if all fine, set internal parameters if (retCode) { uart->_baudrate = baudrate; uart->_config = config; From 15bab66bec046e1e36658aad4fd28a893386230d Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Fri, 28 Jun 2024 21:34:47 -0300 Subject: [PATCH 2/3] fix(uart): Remove useless commentary Removes a commentary with a question about the inversing polarity function. --- cores/esp32/esp32-hal-uart.c | 1 - 1 file changed, 1 deletion(-) diff --git a/cores/esp32/esp32-hal-uart.c b/cores/esp32/esp32-hal-uart.c index d74f4bb8a05..c40000ebe30 100644 --- a/cores/esp32/esp32-hal-uart.c +++ b/cores/esp32/esp32-hal-uart.c @@ -513,7 +513,6 @@ uart_t *uartBegin( retCode &= ESP_OK == uart_param_config(uart_nr, &uart_config); } - // Is it right or the idea is to swap rx and tx pins? if (retCode) { if (inverted) { // invert signal for both Rx and Tx From f023b27837267d477ac037d0f7b826013fd67634 Mon Sep 17 00:00:00 2001 From: Me No Dev Date: Mon, 1 Jul 2024 11:50:20 +0300 Subject: [PATCH 3/3] fix(uart): Update comment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jan Procházka <90197375+P-R-O-C-H-Y@users.noreply.github.com> --- cores/esp32/esp32-hal-uart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/esp32/esp32-hal-uart.c b/cores/esp32/esp32-hal-uart.c index c40000ebe30..f87775a83ba 100644 --- a/cores/esp32/esp32-hal-uart.c +++ b/cores/esp32/esp32-hal-uart.c @@ -518,7 +518,7 @@ uart_t *uartBegin( // invert signal for both Rx and Tx retCode &= ESP_OK == uart_set_line_inverse(uart_nr, UART_SIGNAL_TXD_INV | UART_SIGNAL_RXD_INV); } else { - // invert signal for both Rx and Tx + // disable invert signal for both Rx and Tx retCode &= ESP_OK == uart_set_line_inverse(uart_nr, UART_SIGNAL_INV_DISABLE); } }