machine/serial, rp2040: add support for hardware flow control

Signed-off-by: deadprogram <ron@hybridgroup.com>
Этот коммит содержится в:
deadprogram 2023-12-20 18:03:56 +01:00 коммит произвёл BCG
родитель 534b3b0c0b
коммит cf21380264
2 изменённых файлов: 18 добавлений и 1 удалений

Просмотреть файл

@ -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