Skip to content

Commit 5f663e7

Browse files
SuGliderme-no-devP-R-O-C-H-Y
authored
fix(uart): Set back Pin signal polarity (espressif#9950)
* 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 useless 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 88ad677 commit 5f663e7

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

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

+9-5
Original file line numberDiff line numberDiff line change
@@ -513,12 +513,16 @@ uart_t *uartBegin(
513513
retCode &= ESP_OK == uart_param_config(uart_nr, &uart_config);
514514
}
515515

516-
// 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);
516+
if (retCode) {
517+
if (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);
520+
} else {
521+
// disable invert signal for both Rx and Tx
522+
retCode &= ESP_OK == uart_set_line_inverse(uart_nr, UART_SIGNAL_INV_DISABLE);
523+
}
520524
}
521-
525+
// if all fine, set internal parameters
522526
if (retCode) {
523527
uart->_baudrate = baudrate;
524528
uart->_config = config;

0 commit comments

Comments
 (0)