diff --git a/src/machine/machine_rp2.go b/src/machine/machine_rp2.go index 3a354c813b..1d01866bd0 100644 --- a/src/machine/machine_rp2.go +++ b/src/machine/machine_rp2.go @@ -4,6 +4,7 @@ package machine import ( "device/rp" + "runtime/interrupt" "runtime/volatile" "unsafe" ) @@ -18,6 +19,26 @@ const ( _PICO_SPINLOCK_ID_IRQ = 9 ) +// UART on the RP2040 +var ( + UART0 = &_UART0 + _UART0 = UART{ + Buffer: NewRingBuffer(), + Bus: rp.UART0, + } + + UART1 = &_UART1 + _UART1 = UART{ + Buffer: NewRingBuffer(), + Bus: rp.UART1, + } +) + +func init() { + UART0.Interrupt = interrupt.New(rp.IRQ_UART0_IRQ, _UART0.handleInterrupt) + UART1.Interrupt = interrupt.New(rp.IRQ_UART1_IRQ, _UART1.handleInterrupt) +} + //go:linkname machineInit runtime.machineInit func machineInit() { // Reset all peripherals to put system into a known state, @@ -96,7 +117,7 @@ const ( ) // DMA channels usable on the RP2040. -var dmaChannels = (*[12]dmaChannel)(unsafe.Pointer(rp.DMA)) +var dmaChannels = (*[12 + 4*rp2350ExtraReg]dmaChannel)(unsafe.Pointer(rp.DMA)) //go:inline func boolToBit(a bool) uint32 { diff --git a/src/machine/machine_rp2040_gpio.go b/src/machine/machine_rp2040_gpio.go deleted file mode 100644 index afcc39331a..0000000000 --- a/src/machine/machine_rp2040_gpio.go +++ /dev/null @@ -1,28 +0,0 @@ -//go:build rp2040 - -package machine - -import ( - "device/rp" - "runtime/interrupt" -) - -// UART on the RP2040 -var ( - UART0 = &_UART0 - _UART0 = UART{ - Buffer: NewRingBuffer(), - Bus: rp.UART0, - } - - UART1 = &_UART1 - _UART1 = UART{ - Buffer: NewRingBuffer(), - Bus: rp.UART1, - } -) - -func init() { - UART0.Interrupt = interrupt.New(rp.IRQ_UART0_IRQ, _UART0.handleInterrupt) - UART1.Interrupt = interrupt.New(rp.IRQ_UART1_IRQ, _UART1.handleInterrupt) -} diff --git a/src/machine/machine_rp2_2350.go b/src/machine/machine_rp2_2350.go index e99809b088..adb75f0090 100644 --- a/src/machine/machine_rp2_2350.go +++ b/src/machine/machine_rp2_2350.go @@ -22,6 +22,16 @@ const ( rp.RESETS_RESET_USBCTRL ) +// UART pins +const ( + UART0_TX_PIN = GPIO0 + UART0_RX_PIN = GPIO1 + UART1_TX_PIN = GPIO8 + UART1_RX_PIN = GPIO9 + UART_TX_PIN = UART0_TX_PIN + UART_RX_PIN = UART0_RX_PIN +) + const ( PinOutput PinMode = iota PinInput diff --git a/src/machine/machine_rp2040_uart.go b/src/machine/machine_rp2_uart.go similarity index 99% rename from src/machine/machine_rp2040_uart.go rename to src/machine/machine_rp2_uart.go index b0b0398772..13cb62bff4 100644 --- a/src/machine/machine_rp2040_uart.go +++ b/src/machine/machine_rp2_uart.go @@ -1,4 +1,4 @@ -//go:build rp2040 +//go:build rp2040 || rp2350 package machine diff --git a/src/machine/uart.go b/src/machine/uart.go index eeeb7d6a0b..32462587b1 100644 --- a/src/machine/uart.go +++ b/src/machine/uart.go @@ -1,4 +1,4 @@ -//go:build atmega || esp || nrf || sam || sifive || stm32 || k210 || nxp || rp2040 +//go:build atmega || esp || nrf || sam || sifive || stm32 || k210 || nxp || rp2040 || rp2350 package machine