Skip to content

Commit

Permalink
fix(uart): Set back Pin signal polarity
Browse files Browse the repository at this point in the history
Fixes a problem related to inverting signal polarity back to normal after a previous inversion.

This shall set the correct polarity in Serial.begin().
  • Loading branch information
SuGlider authored Jun 28, 2024
1 parent b25c1b2 commit 6c6b909
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions cores/esp32/esp32-hal-uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 6c6b909

Please sign in to comment.