rp2040: move UART0 and UART1 to common file

This is makes it easier to use these in simulation, plus it avoids
duplication. The only downside I see is that more UARTs get defined than
a board supports, but no existing code should break (no UARTs get
renamed for example).
This commit is contained in:
Ayke van Laethem
2024-03-30 13:24:55 +01:00
committed by Ron Evans
parent 2733e376bd
commit c55ac9f28e
16 changed files with 22 additions and 327 deletions
@@ -7,11 +7,6 @@
// - https://www.waveshare.com/wiki/RP2040-Zero
package machine
import (
"device/rp"
"runtime/interrupt"
)
// Digital Pins
const (
D0 Pin = GPIO0
@@ -94,27 +89,8 @@ const (
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 DefaultUART = UART0
func init() {
UART0.Interrupt = interrupt.New(rp.IRQ_UART0_IRQ, _UART0.handleInterrupt)
UART1.Interrupt = interrupt.New(rp.IRQ_UART1_IRQ, _UART1.handleInterrupt)
}
// USB CDC identifiers
const (
usb_STRING_PRODUCT = "RP2040-Zero"