From 7db47cafb2b02087af9b600305c369f5c1373382 Mon Sep 17 00:00:00 2001 From: Andrew Sund Date: Mon, 2 Jun 2025 17:47:28 -0700 Subject: [PATCH 01/26] feat(uart): Add function to invert hardware UART Tx line Simply clone existing Rx functionality for Tx. Allow granular control over both lines. Avoid overloading HardwareSerial::begin() to change the bool invert parameter to a bitmask type. Add an untested implementation for ESP32C6, ESP32H2, ESP32P4 that references the different register naming on those chips. --- cores/esp32/HardwareSerial.cpp | 4 ++++ cores/esp32/HardwareSerial.h | 1 + cores/esp32/esp32-hal-uart.c | 42 ++++++++++++++++++++++++++++++---- cores/esp32/esp32-hal-uart.h | 1 + tests/validation/uart/uart.ino | 8 +++++++ 5 files changed, 52 insertions(+), 4 deletions(-) diff --git a/cores/esp32/HardwareSerial.cpp b/cores/esp32/HardwareSerial.cpp index 6d762da21fb..42acdb742b7 100644 --- a/cores/esp32/HardwareSerial.cpp +++ b/cores/esp32/HardwareSerial.cpp @@ -578,6 +578,10 @@ void HardwareSerial::setRxInvert(bool invert) { uartSetRxInvert(_uart, invert); } +void HardwareSerial::setTxInvert(bool invert) { + uartSetTxInvert(_uart, invert); +} + // negative Pin value will keep it unmodified // can be called after or before begin() bool HardwareSerial::setPins(int8_t rxPin, int8_t txPin, int8_t ctsPin, int8_t rtsPin) { diff --git a/cores/esp32/HardwareSerial.h b/cores/esp32/HardwareSerial.h index e974f112701..c6dc917706d 100644 --- a/cores/esp32/HardwareSerial.h +++ b/cores/esp32/HardwareSerial.h @@ -349,6 +349,7 @@ class HardwareSerial : public Stream { void setDebugOutput(bool); void setRxInvert(bool); + void setTxInvert(bool); // Negative Pin Number will keep it unmodified, thus this function can set individual pins // setPins() can be called after or before begin() diff --git a/cores/esp32/esp32-hal-uart.c b/cores/esp32/esp32-hal-uart.c index 5311aff4f37..5d9c3497651 100644 --- a/cores/esp32/esp32-hal-uart.c +++ b/cores/esp32/esp32-hal-uart.c @@ -827,18 +827,23 @@ void uartSetRxInvert(uart_t *uart, bool invert) { if (uart == NULL) { return; } -#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 // POTENTIAL ISSUE :: original code only set/reset rxd_inv bit // IDF or LL set/reset the whole inv_mask! // if (invert) // ESP_ERROR_CHECK(uart_set_line_inverse(uart->num, UART_SIGNAL_RXD_INV)); // else // ESP_ERROR_CHECK(uart_set_line_inverse(uart->num, UART_SIGNAL_INV_DISABLE)); - log_e("uartSetRxInvert is not supported in ESP32C6, ESP32H2 and ESP32P4"); -#else // this implementation is better over IDF API because it only affects RXD - // this is supported in ESP32, ESP32-S2 and ESP32-C3 uart_dev_t *hw = UART_LL_GET_HW(uart->num); + +#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 + if (invert) { + hw->conf0_sync.rxd_inv = 1; + } else { + hw->conf0_sync.rxd_inv = 0; + } +#else + // this is supported in ESP32, ESP32-S2 and ESP32-C3 if (invert) { hw->conf0.rxd_inv = 1; } else { @@ -847,6 +852,35 @@ void uartSetRxInvert(uart_t *uart, bool invert) { #endif } +void uartSetTxInvert(uart_t *uart, bool invert) { + if (uart == NULL) { + return; + } + // POTENTIAL ISSUE :: original code only set/reset txd_inv bit + // IDF or LL set/reset the whole inv_mask! + // if (invert) + // ESP_ERROR_CHECK(uart_set_line_inverse(uart->num, UART_SIGNAL_TXD_INV)); + // else + // ESP_ERROR_CHECK(uart_set_line_inverse(uart->num, UART_SIGNAL_INV_DISABLE)); + // this implementation is better over IDF API because it only affects TXD + uart_dev_t *hw = UART_LL_GET_HW(uart->num); + +#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 + if (invert) { + hw->conf0_sync.txd_inv = 1; + } else { + hw->conf0_sync.txd_inv = 0; + } +#else + // this is supported in ESP32, ESP32-S2 and ESP32-C3 + if (invert) { + hw->conf0.txd_inv = 1; + } else { + hw->conf0.txd_inv = 0; + } +#endif +} + uint32_t uartAvailable(uart_t *uart) { if (uart == NULL) { diff --git a/cores/esp32/esp32-hal-uart.h b/cores/esp32/esp32-hal-uart.h index 41b005aa151..4f23ab629f5 100644 --- a/cores/esp32/esp32-hal-uart.h +++ b/cores/esp32/esp32-hal-uart.h @@ -62,6 +62,7 @@ bool uartSetBaudRate(uart_t *uart, uint32_t baud_rate); uint32_t uartGetBaudRate(uart_t *uart); void uartSetRxInvert(uart_t *uart, bool invert); +void uartSetTxInvert(uart_t *uart, bool invert); bool uartSetRxTimeout(uart_t *uart, uint8_t numSymbTimeout); bool uartSetRxFIFOFull(uart_t *uart, uint8_t numBytesFIFOFull); void uartSetFastReading(uart_t *uart); diff --git a/tests/validation/uart/uart.ino b/tests/validation/uart/uart.ino index 794fc9affc2..18da797659b 100644 --- a/tests/validation/uart/uart.ino +++ b/tests/validation/uart/uart.ino @@ -276,6 +276,10 @@ void enabled_uart_calls_test(void) { Serial1.setRxInvert(true); Serial1.setRxInvert(false); + log_d("Checking if Serial 1 TX can be inverted while running"); + Serial1.setTxInvert(true); + Serial1.setTxInvert(false); + Serial.println("Enabled UART calls test successful"); } @@ -351,6 +355,10 @@ void disabled_uart_calls_test(void) { Serial1.setRxInvert(true); Serial1.setRxInvert(false); + log_d("Checking if Serial 1 TX can be inverted when stopped"); + Serial1.setTxInvert(true); + Serial1.setTxInvert(false); + Serial.println("Disabled UART calls test successful"); } From 119082f5ce9b1768632ae5683dae9a0edc7da32a Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Mon, 3 Nov 2025 06:04:25 -0300 Subject: [PATCH 02/26] feat(uart): Refactor UART signal inversion handling Refactor UART inversion functions to use a helper for signal inversion. Update UART bus array structure to include inversion mask. --- cores/esp32/esp32-hal-uart.c | 114 +++++++++++++++++------------------ 1 file changed, 54 insertions(+), 60 deletions(-) diff --git a/cores/esp32/esp32-hal-uart.c b/cores/esp32/esp32-hal-uart.c index 5d9c3497651..e74391212e5 100644 --- a/cores/esp32/esp32-hal-uart.c +++ b/cores/esp32/esp32-hal-uart.c @@ -59,6 +59,7 @@ struct uart_struct_t { bool _inverted; // UART inverted signal uint8_t _rxfifo_full_thrhd; // UART RX FIFO full threshold int8_t _uart_clock_source; // UART Clock Source used when it is started using uartBegin() + uint32_t inv_mask; // UART inverse mask used to maintain related pin state }; #if CONFIG_DISABLE_HAL_LOCKS @@ -67,21 +68,21 @@ struct uart_struct_t { #define UART_MUTEX_UNLOCK() static uart_t _uart_bus_array[] = { - {0, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0, -1}, + {0, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0, -1, 0}, #if SOC_UART_NUM > 1 - {1, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0, -1}, + {1, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0, -1, 0}, #endif #if SOC_UART_NUM > 2 - {2, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0, -1}, + {2, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0, -1, 0}, #endif #if SOC_UART_NUM > 3 - {3, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0, -1}, + {3, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0, -1, 0}, #endif #if SOC_UART_NUM > 4 - {4, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0, -1}, + {4, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0, -1, 0}, #endif #if SOC_UART_NUM > 5 - {5, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0, -1}, + {5, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0, -1, 0}, #endif }; @@ -96,21 +97,21 @@ static uart_t _uart_bus_array[] = { xSemaphoreGive(uart->lock) static uart_t _uart_bus_array[] = { - {NULL, 0, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0, -1}, + {NULL, 0, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0, -1, 0}, #if SOC_UART_NUM > 1 - {NULL, 1, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0, -1}, + {NULL, 1, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0, -1, 0}, #endif #if SOC_UART_NUM > 2 - {NULL, 2, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0, -1}, + {NULL, 2, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0, -1, 0}, #endif #if SOC_UART_NUM > 3 - {NULL, 3, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0, -1}, + {NULL, 3, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0, -1, 0}, #endif #if SOC_UART_NUM > 4 - {NULL, 4, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0, -1}, + {NULL, 4, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0, -1, 0}, #endif #if SOC_UART_NUM > 5 - {NULL, 5, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0, -1}, + {NULL, 5, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0, -1, 0}, #endif }; @@ -712,9 +713,15 @@ uart_t *uartBegin( 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); + if (retCode) { + inv_mask |= UART_SIGNAL_TXD_INV | UART_SIGNAL_RXD_INV; + } } else { // disable invert signal for both Rx and Tx retCode &= ESP_OK == uart_set_line_inverse(uart_nr, UART_SIGNAL_INV_DISABLE); + if (retCode) { + inv_mask &= ~(UART_SIGNAL_TXD_INV | UART_SIGNAL_RXD_INV); + } } } // if all fine, set internal parameters @@ -823,62 +830,49 @@ void uartEnd(uint8_t uart_num) { UART_MUTEX_UNLOCK(); } -void uartSetRxInvert(uart_t *uart, bool invert) { +// Helper generic function that takes a uart_sigenl_inv_t mask to be properly applied to the designated uart pin +// invMask can be UART_SIGNAL_RXD_INV, UART_SIGNAL_TXD_INV, UART_SIGNAL_RTS_INV, UART_SIGNAL_CTS_INV +// returns the operation success status +bool _uartPinSignalInversion(uart_t *uart, uint32_t invMask, bool inverted) { if (uart == NULL) { return; } - // POTENTIAL ISSUE :: original code only set/reset rxd_inv bit - // IDF or LL set/reset the whole inv_mask! - // if (invert) - // ESP_ERROR_CHECK(uart_set_line_inverse(uart->num, UART_SIGNAL_RXD_INV)); - // else - // ESP_ERROR_CHECK(uart_set_line_inverse(uart->num, UART_SIGNAL_INV_DISABLE)); - // this implementation is better over IDF API because it only affects RXD - uart_dev_t *hw = UART_LL_GET_HW(uart->num); - -#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 - if (invert) { - hw->conf0_sync.rxd_inv = 1; - } else { - hw->conf0_sync.rxd_inv = 0; - } -#else - // this is supported in ESP32, ESP32-S2 and ESP32-C3 - if (invert) { - hw->conf0.rxd_inv = 1; + bool retCode = true; + uint32_t _inv_mask = inv_mask; + if (inverted) { + _inv_mask |= invMask; + retCode = ESP_OK == uart_set_line_inverse(uart->num, _inv_mask); + if (retCode) { + inv_mask = _inv_mask; + } else { + retCode = false; + } } else { - hw->conf0.rxd_inv = 0; + _inv_mask &= ~invMask; + retCode = ESP_OK == uart_set_line_inverse(uart->num, _inv_mask); + if (retCode) { + inv_mask = _inv_mask; + } else { + retCode = false; + } } -#endif + return retCode; } -void uartSetTxInvert(uart_t *uart, bool invert) { - if (uart == NULL) { - return; - } - // POTENTIAL ISSUE :: original code only set/reset txd_inv bit - // IDF or LL set/reset the whole inv_mask! - // if (invert) - // ESP_ERROR_CHECK(uart_set_line_inverse(uart->num, UART_SIGNAL_TXD_INV)); - // else - // ESP_ERROR_CHECK(uart_set_line_inverse(uart->num, UART_SIGNAL_INV_DISABLE)); - // this implementation is better over IDF API because it only affects TXD - uart_dev_t *hw = UART_LL_GET_HW(uart->num); +bool uartSetRxInvert(uart_t *uart, bool invert) { + return _uartPinSignalInversion(uart, UART_SIGNAL_RXD_INV, invert); +} -#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 - if (invert) { - hw->conf0_sync.txd_inv = 1; - } else { - hw->conf0_sync.txd_inv = 0; - } -#else - // this is supported in ESP32, ESP32-S2 and ESP32-C3 - if (invert) { - hw->conf0.txd_inv = 1; - } else { - hw->conf0.txd_inv = 0; - } -#endif +bool uartSetTxInvert(uart_t *uart, bool invert) { + return _uartPinSignalInversion(uart, UART_SIGNAL_RXD_INV, invert); +} + +bool uartSetCtsInvert(uart_t *uart, bool invert) { + return _uartPinSignalInversion(uart, UART_SIGNAL_CTS_INV, invert); +} + +bool uartSetRtsInvert(uart_t *uart, bool invert) { + return _uartPinSignalInversion(uart, UART_SIGNAL_RTS_INV, invert); } uint32_t uartAvailable(uart_t *uart) { From 268f282f043c984784183c0c884f1559199eef4b Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Mon, 3 Nov 2025 06:07:32 -0300 Subject: [PATCH 03/26] feat(uart): Add UART signal inversion functions Added functions for UART signal inversion and updated existing function signatures. --- cores/esp32/esp32-hal-uart.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cores/esp32/esp32-hal-uart.h b/cores/esp32/esp32-hal-uart.h index 4f23ab629f5..9976f8d2ccc 100644 --- a/cores/esp32/esp32-hal-uart.h +++ b/cores/esp32/esp32-hal-uart.h @@ -61,8 +61,14 @@ void uartFlushTxOnly(uart_t *uart, bool txOnly); bool uartSetBaudRate(uart_t *uart, uint32_t baud_rate); uint32_t uartGetBaudRate(uart_t *uart); -void uartSetRxInvert(uart_t *uart, bool invert); -void uartSetTxInvert(uart_t *uart, bool invert); +// Helper generic function that takes a uart_sigenl_inv_t mask to be properly applied to the designated uart pin +// invMask can be UART_SIGNAL_RXD_INV, UART_SIGNAL_TXD_INV, UART_SIGNAL_RTS_INV, UART_SIGNAL_CTS_INV +// returns the operation success status +bool uartPinSignalInversion(uart_t *uart, uint32_t invMask, bool inverted); +bool uartSetRxInvert(uart_t *uart, bool invert); +bool uartSetTxInvert(uart_t *uart, bool invert); +bool uartSetCtsInvert(uart_t *uart, bool invert); +bool uartSetRtsInvert(uart_t *uart, bool invert); bool uartSetRxTimeout(uart_t *uart, uint8_t numSymbTimeout); bool uartSetRxFIFOFull(uart_t *uart, uint8_t numBytesFIFOFull); void uartSetFastReading(uart_t *uart); From 474edd3213431ad2b55a4ec693846d404beec280 Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Mon, 3 Nov 2025 06:12:06 -0300 Subject: [PATCH 04/26] feat(uart): Refactor UART signal inversion handling --- cores/esp32/esp32-hal-uart.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cores/esp32/esp32-hal-uart.c b/cores/esp32/esp32-hal-uart.c index e74391212e5..93ee8d63c95 100644 --- a/cores/esp32/esp32-hal-uart.c +++ b/cores/esp32/esp32-hal-uart.c @@ -712,15 +712,17 @@ uart_t *uartBegin( 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); + uint32_t _inv_mask = inv_mask; + _inv_mask |= UART_SIGNAL_TXD_INV | UART_SIGNAL_RXD_INV; + retCode &= ESP_OK == uart_set_line_inverse(uart_nr, _inv_mask); if (retCode) { - inv_mask |= UART_SIGNAL_TXD_INV | UART_SIGNAL_RXD_INV; + inv_mask = _inv_mask; } } else { // disable invert signal for both Rx and Tx retCode &= ESP_OK == uart_set_line_inverse(uart_nr, UART_SIGNAL_INV_DISABLE); if (retCode) { - inv_mask &= ~(UART_SIGNAL_TXD_INV | UART_SIGNAL_RXD_INV); + inv_mask = UART_SIGNAL_INV_DISABLE; } } } @@ -833,7 +835,7 @@ void uartEnd(uint8_t uart_num) { // Helper generic function that takes a uart_sigenl_inv_t mask to be properly applied to the designated uart pin // invMask can be UART_SIGNAL_RXD_INV, UART_SIGNAL_TXD_INV, UART_SIGNAL_RTS_INV, UART_SIGNAL_CTS_INV // returns the operation success status -bool _uartPinSignalInversion(uart_t *uart, uint32_t invMask, bool inverted) { +bool uartPinSignalInversion(uart_t *uart, uint32_t invMask, bool inverted) { if (uart == NULL) { return; } From 4e948558517aed1d7a807422baab0194bb6e51a3 Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Mon, 3 Nov 2025 06:18:04 -0300 Subject: [PATCH 05/26] feat(uart): Change setRxInvert and setTxInvert to return bool --- cores/esp32/HardwareSerial.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cores/esp32/HardwareSerial.h b/cores/esp32/HardwareSerial.h index c6dc917706d..3d325eb8374 100644 --- a/cores/esp32/HardwareSerial.h +++ b/cores/esp32/HardwareSerial.h @@ -348,8 +348,10 @@ class HardwareSerial : public Stream { void setDebugOutput(bool); - void setRxInvert(bool); - void setTxInvert(bool); + bool setRxInvert(bool); + bool setTxInvert(bool); + bool setCtsInvert(bool); + bool setRtsInvert(bool); // Negative Pin Number will keep it unmodified, thus this function can set individual pins // setPins() can be called after or before begin() From 2e3ae48a9302ab84141d902e2016d837f766b2b6 Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Mon, 3 Nov 2025 06:20:47 -0300 Subject: [PATCH 06/26] feat(uart) : Refactor serial inversion methods to return bool Changed setRxInvert, setTxInvert to return bool. Added setCtsInvert and setRtsInvert methods. --- cores/esp32/HardwareSerial.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/cores/esp32/HardwareSerial.cpp b/cores/esp32/HardwareSerial.cpp index 42acdb742b7..68d7bb6ef0c 100644 --- a/cores/esp32/HardwareSerial.cpp +++ b/cores/esp32/HardwareSerial.cpp @@ -574,12 +574,20 @@ HardwareSerial::operator bool() const { return uartIsDriverInstalled(_uart); } -void HardwareSerial::setRxInvert(bool invert) { - uartSetRxInvert(_uart, invert); +bool HardwareSerial::setRxInvert(bool invert) { + return uartSetRxInvert(_uart, invert); } -void HardwareSerial::setTxInvert(bool invert) { - uartSetTxInvert(_uart, invert); +bool HardwareSerial::setTxInvert(bool invert) { + return uartSetTxInvert(_uart, invert); +} + +bool HardwareSerial::setCtsInvert(bool invert) { + return uartSetCtsInvert(_uart, invert); +} + +bool HardwareSerial::setRtsInvert(bool invert) { + return uartSetRtsInvert(_uart, invert); } // negative Pin value will keep it unmodified From af3ec5bdfe84a30cce40d5584b490a8cb67ac11b Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Mon, 3 Nov 2025 06:22:19 -0300 Subject: [PATCH 07/26] feat(uart): adds commentatries Added functions for UART pins signal inversion. --- cores/esp32/HardwareSerial.h | 1 + 1 file changed, 1 insertion(+) diff --git a/cores/esp32/HardwareSerial.h b/cores/esp32/HardwareSerial.h index 3d325eb8374..d7f3e6f4673 100644 --- a/cores/esp32/HardwareSerial.h +++ b/cores/esp32/HardwareSerial.h @@ -348,6 +348,7 @@ class HardwareSerial : public Stream { void setDebugOutput(bool); + // fuctions used to enable or disable UART pins signal inversion bool setRxInvert(bool); bool setTxInvert(bool); bool setCtsInvert(bool); From 84da944becda0fce885b89b242242a8a865bd9f3 Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Mon, 3 Nov 2025 06:24:50 -0300 Subject: [PATCH 08/26] feat(uart): add commentaties --- cores/esp32/esp32-hal-uart.h | 1 + 1 file changed, 1 insertion(+) diff --git a/cores/esp32/esp32-hal-uart.h b/cores/esp32/esp32-hal-uart.h index 9976f8d2ccc..2e1240ff3f4 100644 --- a/cores/esp32/esp32-hal-uart.h +++ b/cores/esp32/esp32-hal-uart.h @@ -65,6 +65,7 @@ uint32_t uartGetBaudRate(uart_t *uart); // invMask can be UART_SIGNAL_RXD_INV, UART_SIGNAL_TXD_INV, UART_SIGNAL_RTS_INV, UART_SIGNAL_CTS_INV // returns the operation success status bool uartPinSignalInversion(uart_t *uart, uint32_t invMask, bool inverted); +// functions used to individually enable or disable UART pins inversion bool uartSetRxInvert(uart_t *uart, bool invert); bool uartSetTxInvert(uart_t *uart, bool invert); bool uartSetCtsInvert(uart_t *uart, bool invert); From c2f54ac8463ac00a5b13dc2aa057140d6e068dc0 Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Mon, 3 Nov 2025 06:38:06 -0300 Subject: [PATCH 09/26] feat(uart): Refactor uartPinSignalInversion for mutex locking --- cores/esp32/esp32-hal-uart.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cores/esp32/esp32-hal-uart.c b/cores/esp32/esp32-hal-uart.c index 91f731f1967..c988d0e50f5 100644 --- a/cores/esp32/esp32-hal-uart.c +++ b/cores/esp32/esp32-hal-uart.c @@ -994,18 +994,18 @@ bool uartPinSignalInversion(uart_t *uart, uint32_t invMask, bool inverted) { if (uart == NULL) { return; } - bool retCode = true; + UART_MUTEX_LOCK(); uint32_t _inv_mask = inv_mask; if (inverted) { _inv_mask |= invMask; - retCode = ESP_OK == uart_set_line_inverse(uart->num, _inv_mask); } else { _inv_mask &= ~invMask; - retCode = ESP_OK == uart_set_line_inverse(uart->num, _inv_mask); } + bool retCode = ESP_OK == uart_set_line_inverse(uart->num, _inv_mask); if (retCode) { inv_mask = _inv_mask; } + UART_MUTEX_UNLOCK(); return retCode; } From 3781bef26f1a24ccba74fa717a8814454a07e532 Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Mon, 3 Nov 2025 06:54:44 -0300 Subject: [PATCH 10/26] Refactor UART inversion functions to use new method --- cores/esp32/esp32-hal-uart.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cores/esp32/esp32-hal-uart.c b/cores/esp32/esp32-hal-uart.c index c988d0e50f5..86905e5757b 100644 --- a/cores/esp32/esp32-hal-uart.c +++ b/cores/esp32/esp32-hal-uart.c @@ -1010,19 +1010,19 @@ bool uartPinSignalInversion(uart_t *uart, uint32_t invMask, bool inverted) { } bool uartSetRxInvert(uart_t *uart, bool invert) { - return _uartPinSignalInversion(uart, UART_SIGNAL_RXD_INV, invert); + return uartPinSignalInversion(uart, UART_SIGNAL_RXD_INV, invert); } bool uartSetTxInvert(uart_t *uart, bool invert) { - return _uartPinSignalInversion(uart, UART_SIGNAL_RXD_INV, invert); + return uartPinSignalInversion(uart, UART_SIGNAL_RXD_INV, invert); } bool uartSetCtsInvert(uart_t *uart, bool invert) { - return _uartPinSignalInversion(uart, UART_SIGNAL_CTS_INV, invert); + return uartPinSignalInversion(uart, UART_SIGNAL_CTS_INV, invert); } bool uartSetRtsInvert(uart_t *uart, bool invert) { - return _uartPinSignalInversion(uart, UART_SIGNAL_RTS_INV, invert); + return uartPinSignalInversion(uart, UART_SIGNAL_RTS_INV, invert); } uint32_t uartAvailable(uart_t *uart) { From 9634116d9efac2c2104986e52b9f44f2cb6963eb Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Mon, 3 Nov 2025 07:04:37 -0300 Subject: [PATCH 11/26] fix(uart): missing uart struct usage --- cores/esp32/esp32-hal-uart.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cores/esp32/esp32-hal-uart.c b/cores/esp32/esp32-hal-uart.c index 86905e5757b..ce7f7cbe632 100644 --- a/cores/esp32/esp32-hal-uart.c +++ b/cores/esp32/esp32-hal-uart.c @@ -874,17 +874,17 @@ uart_t *uartBegin( if (retCode) { if (inverted) { // invert signal for both Rx and Tx - uint32_t _inv_mask = inv_mask; + uint32_t _inv_mask = uart->inv_mask; _inv_mask |= UART_SIGNAL_TXD_INV | UART_SIGNAL_RXD_INV; retCode &= ESP_OK == uart_set_line_inverse(uart_nr, _inv_mask); if (retCode) { - inv_mask = _inv_mask; + uart->inv_mask = _inv_mask; } } else { // disable invert signal for both Rx and Tx retCode &= ESP_OK == uart_set_line_inverse(uart_nr, UART_SIGNAL_INV_DISABLE); if (retCode) { - inv_mask = UART_SIGNAL_INV_DISABLE; + uart->inv_mask = UART_SIGNAL_INV_DISABLE; } } } @@ -995,7 +995,7 @@ bool uartPinSignalInversion(uart_t *uart, uint32_t invMask, bool inverted) { return; } UART_MUTEX_LOCK(); - uint32_t _inv_mask = inv_mask; + uint32_t _inv_mask = uart->inv_mask; if (inverted) { _inv_mask |= invMask; } else { @@ -1003,7 +1003,7 @@ bool uartPinSignalInversion(uart_t *uart, uint32_t invMask, bool inverted) { } bool retCode = ESP_OK == uart_set_line_inverse(uart->num, _inv_mask); if (retCode) { - inv_mask = _inv_mask; + uart->inv_mask = _inv_mask; } UART_MUTEX_UNLOCK(); return retCode; From 84f3796a08220fc8057562db203bf822c444d978 Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Mon, 3 Nov 2025 07:09:26 -0300 Subject: [PATCH 12/26] fix(uart): missing function return value --- 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 ce7f7cbe632..16564dad89c 100644 --- a/cores/esp32/esp32-hal-uart.c +++ b/cores/esp32/esp32-hal-uart.c @@ -992,7 +992,7 @@ void uartEnd(uint8_t uart_num) { // returns the operation success status bool uartPinSignalInversion(uart_t *uart, uint32_t invMask, bool inverted) { if (uart == NULL) { - return; + return false; } UART_MUTEX_LOCK(); uint32_t _inv_mask = uart->inv_mask; From 5753a02950aaefb41b06eb601f26a3a4cefa09bf Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Mon, 3 Nov 2025 23:17:51 -0300 Subject: [PATCH 13/26] feat(uart): add commentaties --- cores/esp32/HardwareSerial.h | 1 + 1 file changed, 1 insertion(+) diff --git a/cores/esp32/HardwareSerial.h b/cores/esp32/HardwareSerial.h index 2c2e76ea7bb..2052e12a4e6 100644 --- a/cores/esp32/HardwareSerial.h +++ b/cores/esp32/HardwareSerial.h @@ -357,6 +357,7 @@ class HardwareSerial : public Stream { void setDebugOutput(bool); // fuctions used to enable or disable UART pins signal inversion + // returns the requested operation success status bool setRxInvert(bool); bool setTxInvert(bool); bool setCtsInvert(bool); From 06b2dfa4a2037b02bf6f5f689b08786a7dd60a49 Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Mon, 3 Nov 2025 23:37:23 -0300 Subject: [PATCH 14/26] fix(uart): inverting rx instead of tx --- 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 16564dad89c..5e335c323b9 100644 --- a/cores/esp32/esp32-hal-uart.c +++ b/cores/esp32/esp32-hal-uart.c @@ -1014,7 +1014,7 @@ bool uartSetRxInvert(uart_t *uart, bool invert) { } bool uartSetTxInvert(uart_t *uart, bool invert) { - return uartPinSignalInversion(uart, UART_SIGNAL_RXD_INV, invert); + return uartPinSignalInversion(uart, UART_SIGNAL_TXD_INV, invert); } bool uartSetCtsInvert(uart_t *uart, bool invert) { From c409993c4fbcd5e7250f38258480014d06250ec0 Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Mon, 3 Nov 2025 23:54:48 -0300 Subject: [PATCH 15/26] feat(uart): logging for UART signal inversion Added logging for signal inversion in UART functions. --- cores/esp32/esp32-hal-uart.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/cores/esp32/esp32-hal-uart.c b/cores/esp32/esp32-hal-uart.c index 5e335c323b9..d14ca3e92b7 100644 --- a/cores/esp32/esp32-hal-uart.c +++ b/cores/esp32/esp32-hal-uart.c @@ -879,6 +879,7 @@ uart_t *uartBegin( retCode &= ESP_OK == uart_set_line_inverse(uart_nr, _inv_mask); if (retCode) { uart->inv_mask = _inv_mask; + log_v("Inverted RX and TX signals within UART%d", uart_nr); } } else { // disable invert signal for both Rx and Tx @@ -1010,19 +1011,35 @@ bool uartPinSignalInversion(uart_t *uart, uint32_t invMask, bool inverted) { } bool uartSetRxInvert(uart_t *uart, bool invert) { - return uartPinSignalInversion(uart, UART_SIGNAL_RXD_INV, invert); + if (uartPinSignalInversion(uart, UART_SIGNAL_RXD_INV, invert)) { + log_v("UART%d: RX signal is now inverted", uart->num); + return true; + } + return false; } bool uartSetTxInvert(uart_t *uart, bool invert) { - return uartPinSignalInversion(uart, UART_SIGNAL_TXD_INV, invert); + if (uartPinSignalInversion(uart, UART_SIGNAL_TXD_INV, invert)) { + log_v("UART%d: TX signal is now inverted", uart->num); + return true; + } + return false; } bool uartSetCtsInvert(uart_t *uart, bool invert) { - return uartPinSignalInversion(uart, UART_SIGNAL_CTS_INV, invert); + if (uartPinSignalInversion(uart, UART_SIGNAL_CTS_INV, invert)) { + log_v("UART%d: CTS signal is now inverted", uart->num); + return true; + } + return false; } bool uartSetRtsInvert(uart_t *uart, bool invert) { - return uartPinSignalInversion(uart, UART_SIGNAL_RTS_INV, invert); + if (uartPinSignalInversion(uart, UART_SIGNAL_RTS_INV, invert)) { + log_v("UART%d: RTS signal is now inverted", uart->num); + return true; + } + return false; } uint32_t uartAvailable(uart_t *uart) { From c74f4e962c06d152b7e95ba7c161989623b5c0b3 Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Mon, 3 Nov 2025 23:57:55 -0300 Subject: [PATCH 16/26] feat(uart): standard verbose log message --- 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 d14ca3e92b7..24cfb116a58 100644 --- a/cores/esp32/esp32-hal-uart.c +++ b/cores/esp32/esp32-hal-uart.c @@ -879,7 +879,7 @@ uart_t *uartBegin( retCode &= ESP_OK == uart_set_line_inverse(uart_nr, _inv_mask); if (retCode) { uart->inv_mask = _inv_mask; - log_v("Inverted RX and TX signals within UART%d", uart_nr); + log_v("UART%d: RX and TX signals are set to be inverted.", uart_nr); } } else { // disable invert signal for both Rx and Tx From ffe77697d7e70c228fa0a66b77d615f63bee2128 Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Mon, 3 Nov 2025 23:58:19 -0300 Subject: [PATCH 17/26] feat(uart): add not inverted verbose log message --- cores/esp32/esp32-hal-uart.c | 1 + 1 file changed, 1 insertion(+) diff --git a/cores/esp32/esp32-hal-uart.c b/cores/esp32/esp32-hal-uart.c index 24cfb116a58..391e4140bad 100644 --- a/cores/esp32/esp32-hal-uart.c +++ b/cores/esp32/esp32-hal-uart.c @@ -886,6 +886,7 @@ uart_t *uartBegin( retCode &= ESP_OK == uart_set_line_inverse(uart_nr, UART_SIGNAL_INV_DISABLE); if (retCode) { uart->inv_mask = UART_SIGNAL_INV_DISABLE; + log_v("UART%d: RX and TX signals are set not inverted.", uart_nr); } } } From 6718c907664a42f0692c10fb672ebf93347939ea Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Tue, 4 Nov 2025 00:08:25 -0300 Subject: [PATCH 18/26] fix(uart): misspeling comment Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- cores/esp32/esp32-hal-uart.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/esp32/esp32-hal-uart.h b/cores/esp32/esp32-hal-uart.h index c23260e2856..ab46a3c4f9c 100644 --- a/cores/esp32/esp32-hal-uart.h +++ b/cores/esp32/esp32-hal-uart.h @@ -61,7 +61,7 @@ void uartFlushTxOnly(uart_t *uart, bool txOnly); bool uartSetBaudRate(uart_t *uart, uint32_t baud_rate); uint32_t uartGetBaudRate(uart_t *uart); -// Helper generic function that takes a uart_sigenl_inv_t mask to be properly applied to the designated uart pin +// Helper generic function that takes a uart_signal_inv_t mask to be properly applied to the designated uart pin // invMask can be UART_SIGNAL_RXD_INV, UART_SIGNAL_TXD_INV, UART_SIGNAL_RTS_INV, UART_SIGNAL_CTS_INV // returns the operation success status bool uartPinSignalInversion(uart_t *uart, uint32_t invMask, bool inverted); From 600e13457ffc7abbe092f43e51bf791897ff78e1 Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Tue, 4 Nov 2025 00:09:01 -0300 Subject: [PATCH 19/26] fix(uart): fixes bad code formating Co-authored-by: Copilot <175728472+Copilot@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 391e4140bad..85cd87a1771 100644 --- a/cores/esp32/esp32-hal-uart.c +++ b/cores/esp32/esp32-hal-uart.c @@ -989,7 +989,7 @@ void uartEnd(uint8_t uart_num) { UART_MUTEX_UNLOCK(); } -// Helper generic function that takes a uart_sigenl_inv_t mask to be properly applied to the designated uart pin +// Helper generic function that takes a uart_signal_inv_t mask to be properly applied to the designated uart pin // invMask can be UART_SIGNAL_RXD_INV, UART_SIGNAL_TXD_INV, UART_SIGNAL_RTS_INV, UART_SIGNAL_CTS_INV // returns the operation success status bool uartPinSignalInversion(uart_t *uart, uint32_t invMask, bool inverted) { From 1acfa42934a0fc132c2e1bb709d47fa33af0abc8 Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Tue, 4 Nov 2025 00:09:29 -0300 Subject: [PATCH 20/26] fix(uart): fixes misspeling Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- cores/esp32/HardwareSerial.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/esp32/HardwareSerial.h b/cores/esp32/HardwareSerial.h index 2052e12a4e6..9a4eec5ccb4 100644 --- a/cores/esp32/HardwareSerial.h +++ b/cores/esp32/HardwareSerial.h @@ -356,7 +356,7 @@ class HardwareSerial : public Stream { void setDebugOutput(bool); - // fuctions used to enable or disable UART pins signal inversion + // functions used to enable or disable UART pins signal inversion // returns the requested operation success status bool setRxInvert(bool); bool setTxInvert(bool); From 949b3660ebbf971f067b85e5c7ef1b03a42671f4 Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Tue, 4 Nov 2025 00:09:54 -0300 Subject: [PATCH 21/26] fix(uart): fixes bad code formating Co-authored-by: Copilot <175728472+Copilot@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 85cd87a1771..c0f64e57bf1 100644 --- a/cores/esp32/esp32-hal-uart.c +++ b/cores/esp32/esp32-hal-uart.c @@ -999,7 +999,7 @@ bool uartPinSignalInversion(uart_t *uart, uint32_t invMask, bool inverted) { UART_MUTEX_LOCK(); uint32_t _inv_mask = uart->inv_mask; if (inverted) { - _inv_mask |= invMask; + _inv_mask |= invMask; } else { _inv_mask &= ~invMask; } From f85e5f25de0bf84aba59243470ac9fa5ad642573 Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Tue, 4 Nov 2025 00:10:19 -0300 Subject: [PATCH 22/26] fix(uart): fixes bad code formating Co-authored-by: Copilot <175728472+Copilot@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 c0f64e57bf1..93adb7707a3 100644 --- a/cores/esp32/esp32-hal-uart.c +++ b/cores/esp32/esp32-hal-uart.c @@ -1001,7 +1001,7 @@ bool uartPinSignalInversion(uart_t *uart, uint32_t invMask, bool inverted) { if (inverted) { _inv_mask |= invMask; } else { - _inv_mask &= ~invMask; + _inv_mask &= ~invMask; } bool retCode = ESP_OK == uart_set_line_inverse(uart->num, _inv_mask); if (retCode) { From bfad07c91ce15a7cb930233906408081d385d151 Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Tue, 4 Nov 2025 00:10:36 -0300 Subject: [PATCH 23/26] fix(uart): fixes bad code formating Co-authored-by: Copilot <175728472+Copilot@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 93adb7707a3..4ca9f5a7f99 100644 --- a/cores/esp32/esp32-hal-uart.c +++ b/cores/esp32/esp32-hal-uart.c @@ -1022,7 +1022,7 @@ bool uartSetRxInvert(uart_t *uart, bool invert) { bool uartSetTxInvert(uart_t *uart, bool invert) { if (uartPinSignalInversion(uart, UART_SIGNAL_TXD_INV, invert)) { log_v("UART%d: TX signal is now inverted", uart->num); - return true; + return true; } return false; } From 399255531d59aa6b5c69c5f1a240bf27512072cf Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Tue, 4 Nov 2025 00:11:03 -0300 Subject: [PATCH 24/26] fix(uart): fixes extra spaces Co-authored-by: Copilot <175728472+Copilot@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 4ca9f5a7f99..a6feed7ac82 100644 --- a/cores/esp32/esp32-hal-uart.c +++ b/cores/esp32/esp32-hal-uart.c @@ -1030,7 +1030,7 @@ bool uartSetTxInvert(uart_t *uart, bool invert) { bool uartSetCtsInvert(uart_t *uart, bool invert) { if (uartPinSignalInversion(uart, UART_SIGNAL_CTS_INV, invert)) { log_v("UART%d: CTS signal is now inverted", uart->num); - return true; + return true; } return false; } From 3f6abf9f011152b1816b6d4ca5b8d511b5100aba Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Tue, 4 Nov 2025 00:11:28 -0300 Subject: [PATCH 25/26] fix(uart): extra spacing Co-authored-by: Copilot <175728472+Copilot@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 a6feed7ac82..3fe50effecc 100644 --- a/cores/esp32/esp32-hal-uart.c +++ b/cores/esp32/esp32-hal-uart.c @@ -1038,7 +1038,7 @@ bool uartSetCtsInvert(uart_t *uart, bool invert) { bool uartSetRtsInvert(uart_t *uart, bool invert) { if (uartPinSignalInversion(uart, UART_SIGNAL_RTS_INV, invert)) { log_v("UART%d: RTS signal is now inverted", uart->num); - return true; + return true; } return false; } From e6e09ceed932c786ec1d18bc9cded032c3fdd45d Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Tue, 4 Nov 2025 00:14:15 -0300 Subject: [PATCH 26/26] feat(uart): Improve logging for UART signal inversion --- cores/esp32/esp32-hal-uart.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cores/esp32/esp32-hal-uart.c b/cores/esp32/esp32-hal-uart.c index 3fe50effecc..c9892a4edfc 100644 --- a/cores/esp32/esp32-hal-uart.c +++ b/cores/esp32/esp32-hal-uart.c @@ -1013,7 +1013,7 @@ bool uartPinSignalInversion(uart_t *uart, uint32_t invMask, bool inverted) { bool uartSetRxInvert(uart_t *uart, bool invert) { if (uartPinSignalInversion(uart, UART_SIGNAL_RXD_INV, invert)) { - log_v("UART%d: RX signal is now inverted", uart->num); + log_v("UART%d: RX signal inversion %s", uart->num, invert ? "enabled" : "disabled"); return true; } return false; @@ -1021,7 +1021,7 @@ bool uartSetRxInvert(uart_t *uart, bool invert) { bool uartSetTxInvert(uart_t *uart, bool invert) { if (uartPinSignalInversion(uart, UART_SIGNAL_TXD_INV, invert)) { - log_v("UART%d: TX signal is now inverted", uart->num); + log_v("UART%d: TX signal inversion %s", uart->num, invert ? "enabled" : "disabled"); return true; } return false; @@ -1029,7 +1029,7 @@ bool uartSetTxInvert(uart_t *uart, bool invert) { bool uartSetCtsInvert(uart_t *uart, bool invert) { if (uartPinSignalInversion(uart, UART_SIGNAL_CTS_INV, invert)) { - log_v("UART%d: CTS signal is now inverted", uart->num); + log_v("UART%d: CTS signal inversion %s", uart->num, invert ? "enabled" : "disabled"); return true; } return false; @@ -1037,7 +1037,7 @@ bool uartSetCtsInvert(uart_t *uart, bool invert) { bool uartSetRtsInvert(uart_t *uart, bool invert) { if (uartPinSignalInversion(uart, UART_SIGNAL_RTS_INV, invert)) { - log_v("UART%d: RTS signal is now inverted", uart->num); + log_v("UART%d: RTS signal inversion %s", uart->num, invert ? "enabled" : "disabled"); return true; } return false;