mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-11 06:23:39 +00:00
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:
committed by
GitHub
parent
7994d2e912
commit
ea003da13f
@@ -332,10 +332,20 @@ func (uart *UART) Configure(config UARTConfig) {
|
||||
|
||||
if config.RX != NoPin {
|
||||
config.RX.configure(PinConfig{Mode: PinInputPullup}, uart.TXRXSignal)
|
||||
if config.InvertRX {
|
||||
inFunc(uart.TXRXSignal).Set(esp.GPIO_FUNC_IN_SEL_CFG_SEL | uint32(config.RX)<<esp.GPIO_FUNC_IN_SEL_CFG_IN_SEL_Pos | esp.GPIO_FUNC_IN_SEL_CFG_IN_INV_SEL)
|
||||
} else {
|
||||
inFunc(uart.TXRXSignal).Set(esp.GPIO_FUNC_IN_SEL_CFG_SEL | uint32(config.RX)<<esp.GPIO_FUNC_IN_SEL_CFG_IN_SEL_Pos)
|
||||
}
|
||||
}
|
||||
|
||||
if config.TX != NoPin {
|
||||
config.TX.configure(PinConfig{Mode: PinOutput}, uart.TXRXSignal)
|
||||
if config.InvertTX {
|
||||
config.TX.outFunc().Set(uart.TXRXSignal | esp.GPIO_FUNC_OUT_SEL_CFG_INV_SEL)
|
||||
} else {
|
||||
config.TX.outFunc().Set(uart.TXRXSignal)
|
||||
}
|
||||
}
|
||||
|
||||
if config.RTS != NoPin {
|
||||
|
||||
Reference in New Issue
Block a user