From 6c6b909688df61fc39a245174b97bb013df2d1cb Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Fri, 28 Jun 2024 18:00:58 -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 | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cores/esp32/esp32-hal-uart.c b/cores/esp32/esp32-hal-uart.c index 784a97beb7d..e6f554c0c81 100644 --- a/cores/esp32/esp32-hal-uart.c +++ b/cores/esp32/esp32-hal-uart.c @@ -435,11 +435,16 @@ uart_t* uartBegin(uint8_t uart_nr, uint32_t baudrate, uint32_t config, int8_t rx if (retCode) 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 && inverted) { + 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_TXD_INV | UART_SIGNAL_RXD_INV); + 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 05d9ab557dc0a27151295a66e8ada92be55103c1 Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Fri, 28 Jun 2024 21:36:26 -0300 Subject: [PATCH 2/3] fix(uart): Remove 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 e6f554c0c81..765a0621a62 100644 --- a/cores/esp32/esp32-hal-uart.c +++ b/cores/esp32/esp32-hal-uart.c @@ -434,7 +434,6 @@ uart_t* uartBegin(uint8_t uart_nr, uint32_t baudrate, uint32_t config, int8_t rx if (retCode) 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 4f88db2c88aa7765dd6e66556c2ac3ed28f5f141 Mon Sep 17 00:00:00 2001 From: Me No Dev Date: Mon, 1 Jul 2024 11:49:45 +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 765a0621a62..f15eddf8827 100644 --- a/cores/esp32/esp32-hal-uart.c +++ b/cores/esp32/esp32-hal-uart.c @@ -439,7 +439,7 @@ uart_t* uartBegin(uint8_t uart_nr, uint32_t baudrate, uint32_t config, int8_t rx // 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); } }