machine/serial, rp2040: add support for hardware flow control
Signed-off-by: deadprogram <ron@hybridgroup.com>
Этот коммит содержится в:
родитель
534b3b0c0b
коммит
cf21380264
2 изменённых файлов: 18 добавлений и 1 удалений
|
@ -36,10 +36,19 @@ func (uart *UART) Configure(config UARTConfig) error {
|
||||||
uart.SetFormat(8, 1, ParityNone)
|
uart.SetFormat(8, 1, ParityNone)
|
||||||
|
|
||||||
// Enable the UART, both TX and RX
|
// 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_RXE |
|
||||||
rp.UART0_UARTCR_TXE)
|
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
|
// set GPIO mux to UART for the pins
|
||||||
if config.TX != NoPin {
|
if config.TX != NoPin {
|
||||||
config.TX.Configure(PinConfig{Mode: PinUART})
|
config.TX.Configure(PinConfig{Mode: PinUART})
|
||||||
|
@ -47,6 +56,12 @@ func (uart *UART) Configure(config UARTConfig) error {
|
||||||
if config.RX != NoPin {
|
if config.RX != NoPin {
|
||||||
config.RX.Configure(PinConfig{Mode: PinUART})
|
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.
|
// Enable RX IRQ.
|
||||||
uart.Interrupt.SetPriority(0x80)
|
uart.Interrupt.SetPriority(0x80)
|
||||||
|
|
|
@ -11,6 +11,8 @@ type UARTConfig struct {
|
||||||
BaudRate uint32
|
BaudRate uint32
|
||||||
TX Pin
|
TX Pin
|
||||||
RX Pin
|
RX Pin
|
||||||
|
RTS Pin
|
||||||
|
CTS Pin
|
||||||
}
|
}
|
||||||
|
|
||||||
// NullSerial is a serial version of /dev/null (or null router): it drops
|
// NullSerial is a serial version of /dev/null (or null router): it drops
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче