Skip to content

Commit 33c9552

Browse files
SuGliderme-no-devP-R-O-C-H-Y
authored
[release/2.x] fix(uart): Set back Pin signal polarity (#9952)
* 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(). * fix(uart): Remove commentary Removes a commentary with a question about the inversing polarity function. * fix(uart): Update comment Co-authored-by: Jan Procházka <[email protected]> --------- Co-authored-by: Me No Dev <[email protected]> Co-authored-by: Jan Procházka <[email protected]>
1 parent b25c1b2 commit 33c9552

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Diff for: cores/esp32/esp32-hal-uart.c

+8-4
Original file line numberDiff line numberDiff line change
@@ -434,12 +434,16 @@ uart_t* uartBegin(uint8_t uart_nr, uint32_t baudrate, uint32_t config, int8_t rx
434434

435435
if (retCode) retCode &= ESP_OK == uart_param_config(uart_nr, &uart_config);
436436

437-
// Is it right or the idea is to swap rx and tx pins?
438-
if (retCode && inverted) {
437+
if (retCode) {
438+
if (inverted) {
439439
// invert signal for both Rx and Tx
440-
retCode &= ESP_OK == uart_set_line_inverse(uart_nr, UART_SIGNAL_TXD_INV | UART_SIGNAL_RXD_INV);
440+
retCode &= ESP_OK == uart_set_line_inverse(uart_nr, UART_SIGNAL_TXD_INV | UART_SIGNAL_RXD_INV);
441+
} else {
442+
// disable invert signal for both Rx and Tx
443+
retCode &= ESP_OK == uart_set_line_inverse(uart_nr, UART_SIGNAL_INV_DISABLE);
444+
}
441445
}
442-
446+
// if all fine, set internal parameters
443447
if (retCode) {
444448
uart->_baudrate = baudrate;
445449
uart->_config = config;

0 commit comments

Comments
 (0)