Skip to content

Commit adae99f

Browse files
authored
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().
1 parent 337058a commit adae99f

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

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

+9-4
Original file line numberDiff line numberDiff line change
@@ -514,11 +514,16 @@ uart_t *uartBegin(
514514
}
515515

516516
// Is it right or the idea is to swap rx and tx pins?
517-
if (retCode && inverted) {
518-
// invert signal for both Rx and Tx
519-
retCode &= ESP_OK == uart_set_line_inverse(uart_nr, UART_SIGNAL_TXD_INV | UART_SIGNAL_RXD_INV);
517+
if (retCode) {
518+
if (inverted) {
519+
// invert signal for both Rx and Tx
520+
retCode &= ESP_OK == uart_set_line_inverse(uart_nr, UART_SIGNAL_TXD_INV | UART_SIGNAL_RXD_INV);
521+
} else {
522+
// invert signal for both Rx and Tx
523+
retCode &= ESP_OK == uart_set_line_inverse(uart_nr, UART_SIGNAL_INV_DISABLE);
524+
}
520525
}
521-
526+
// if all fine, set internal parameters
522527
if (retCode) {
523528
uart->_baudrate = baudrate;
524529
uart->_config = config;

0 commit comments

Comments
 (0)