machine/rp2040: implement UART0/UART1, can be used on all rp2040 boards

Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
deadprogram
2021-06-09 19:11:42 +02:00
committed by Ron Evans
parent b406b81416
commit 87e48c1057
6 changed files with 192 additions and 8 deletions
+33 -1
View File
@@ -4,7 +4,7 @@ package machine
import (
"device/rp"
_ "unsafe"
"runtime/interrupt"
)
const (
@@ -82,3 +82,35 @@ func machineInit() {
func ticks() uint64 {
return timer.timeElapsed()
}
// UART pins
const (
UART_TX_PIN = UART0_TX_PIN
UART_RX_PIN = UART0_RX_PIN
UART0_TX_PIN = GPIO0
UART0_RX_PIN = GPIO1
UART1_TX_PIN = GPIO8
UART1_RX_PIN = GPIO9
)
// UART on the RP2040
var (
UART0 = &_UART0
_UART0 = UART{
Buffer: NewRingBuffer(),
Bus: rp.UART0,
}
UART1 = &_UART1
_UART1 = UART{
Buffer: NewRingBuffer(),
Bus: rp.UART1,
}
)
var Serial = UART0
func init() {
UART0.Interrupt = interrupt.New(rp.IRQ_UART0_IRQ, _UART0.handleInterrupt)
UART1.Interrupt = interrupt.New(rp.IRQ_UART1_IRQ, _UART1.handleInterrupt)
}