mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-03 02:27:48 +00:00
machine/serial, rp2040: add support for hardware flow control
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
@@ -36,10 +36,19 @@ func (uart *UART) Configure(config UARTConfig) error {
|
||||
uart.SetFormat(8, 1, ParityNone)
|
||||
|
||||
// Enable the UART, both TX and RX
|
||||
uart.Bus.UARTCR.SetBits(rp.UART0_UARTCR_UARTEN |
|
||||
settings := uint32(rp.UART0_UARTCR_UARTEN |
|
||||
rp.UART0_UARTCR_RXE |
|
||||
rp.UART0_UARTCR_TXE)
|
||||
|
||||
if config.RTS != 0 {
|
||||
settings |= rp.UART0_UARTCR_RTSEN
|
||||
}
|
||||
if config.CTS != 0 {
|
||||
settings |= rp.UART0_UARTCR_CTSEN
|
||||
}
|
||||
|
||||
uart.Bus.UARTCR.SetBits(settings)
|
||||
|
||||
// set GPIO mux to UART for the pins
|
||||
if config.TX != NoPin {
|
||||
config.TX.Configure(PinConfig{Mode: PinUART})
|
||||
@@ -47,6 +56,12 @@ func (uart *UART) Configure(config UARTConfig) error {
|
||||
if config.RX != NoPin {
|
||||
config.RX.Configure(PinConfig{Mode: PinUART})
|
||||
}
|
||||
if config.RTS != 0 {
|
||||
config.RTS.Configure(PinConfig{Mode: PinOutput})
|
||||
}
|
||||
if config.CTS != 0 {
|
||||
config.CTS.Configure(PinConfig{Mode: PinInput})
|
||||
}
|
||||
|
||||
// Enable RX IRQ.
|
||||
uart.Interrupt.SetPriority(0x80)
|
||||
|
||||
@@ -11,6 +11,8 @@ type UARTConfig struct {
|
||||
BaudRate uint32
|
||||
TX Pin
|
||||
RX Pin
|
||||
RTS Pin
|
||||
CTS Pin
|
||||
}
|
||||
|
||||
// NullSerial is a serial version of /dev/null (or null router): it drops
|
||||
|
||||
Reference in New Issue
Block a user