Add UART line inversion support (#5522)

* feat(machine): add UART line inversion support.

Add InvertTX and InvertRX to UARTConfig to allow enabling hardware
line inversion on supported targets. Added hardware implementation for
RP2 (RP2040, RP2350), STM32 (newer families), SAM (SAMD51, SAME5x),
and ESP (ESP32, ESP32-C3, ESP32-C6).

* refactor(machine): Refactor UART inversion with pin setter helpers.

RP2: Extract setOutOver/setInOver methods on Pin, removing inline
IO control register manipulation from UART configure.

SAM: Switch to SetCTRLA_TXINV/SetCTRLA_RXINV methods, dropping
the unused device/sam import and raw SetBits/ClearBits calls.

---------

Co-authored-by: Konstantin Sharlaimov <ksharlaimov@inavflight.com>
This commit is contained in:
Konstantin Sharlaimov
2026-07-17 10:45:50 +02:00
committed by GitHub
parent 7994d2e912
commit ea003da13f
13 changed files with 109 additions and 4 deletions
+17
View File
@@ -0,0 +1,17 @@
//go:build sam && (atsamd51 || atsame5x)
package machine
// Configure UART TX/RX line inversion using SVD-generated APIs.
func (uart *UART) setInversion(config UARTConfig) {
if config.InvertTX {
uart.Bus.SetCTRLA_TXINV(1)
} else {
uart.Bus.SetCTRLA_TXINV(0)
}
if config.InvertRX {
uart.Bus.SetCTRLA_RXINV(1)
} else {
uart.Bus.SetCTRLA_RXINV(0)
}
}