diff --git a/src/machine/board_ae_rp2040.go b/src/machine/board_ae_rp2040.go index 91432e4b4..716cf72b3 100644 --- a/src/machine/board_ae_rp2040.go +++ b/src/machine/board_ae_rp2040.go @@ -2,11 +2,6 @@ package machine -import ( - "device/rp" - "runtime/interrupt" -) - // GPIO pins const ( GP0 Pin = GPIO0 @@ -77,28 +72,8 @@ const ( UART_RX_PIN = UART0_RX_PIN ) -// 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 identifiers const ( usb_STRING_PRODUCT = "AE-RP2040" diff --git a/src/machine/board_badger2040.go b/src/machine/board_badger2040.go index d1b29f4c6..049e3cb89 100644 --- a/src/machine/board_badger2040.go +++ b/src/machine/board_badger2040.go @@ -7,11 +7,6 @@ // - Badger 2040 schematic: https://cdn.shopify.com/s/files/1/0174/1800/files/badger_2040_schematic.pdf?v=1645702148 package machine -import ( - "device/rp" - "runtime/interrupt" -) - const ( LED Pin = GPIO25 @@ -92,17 +87,4 @@ const ( UART_RX_PIN = UART0_RX_PIN ) -// UART on the RP2040 -var ( - UART0 = &_UART0 - _UART0 = UART{ - Buffer: NewRingBuffer(), - Bus: rp.UART0, - } -) - var DefaultUART = UART0 - -func init() { - UART0.Interrupt = interrupt.New(rp.IRQ_UART0_IRQ, _UART0.handleInterrupt) -} diff --git a/src/machine/board_challenger_rp2040.go b/src/machine/board_challenger_rp2040.go index b67b3245d..9a85aa0ae 100644 --- a/src/machine/board_challenger_rp2040.go +++ b/src/machine/board_challenger_rp2040.go @@ -2,11 +2,6 @@ package machine -import ( - "device/rp" - "runtime/interrupt" -) - const ( LED = GPIO24 @@ -84,28 +79,8 @@ const ( UART_RX_PIN = UART0_RX_PIN ) -// 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 identifiers const ( usb_STRING_PRODUCT = "Challenger 2040 LoRa" diff --git a/src/machine/board_feather_rp2040.go b/src/machine/board_feather_rp2040.go index f121a1e83..44091e56e 100644 --- a/src/machine/board_feather_rp2040.go +++ b/src/machine/board_feather_rp2040.go @@ -2,11 +2,6 @@ package machine -import ( - "device/rp" - "runtime/interrupt" -) - // Onboard crystal oscillator frequency, in MHz. const xoscFreq = 12 // MHz @@ -73,28 +68,8 @@ const ( UART_RX_PIN = UART0_RX_PIN ) -// 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 identifiers const ( usb_STRING_PRODUCT = "Feather RP2040" diff --git a/src/machine/board_gopher-badge.go b/src/machine/board_gopher-badge.go index e7eff25f8..7af27118b 100644 --- a/src/machine/board_gopher-badge.go +++ b/src/machine/board_gopher-badge.go @@ -5,11 +5,6 @@ // For more information, see: https://gopherbadge.com/ package machine -import ( - "device/rp" - "runtime/interrupt" -) - const ( /*ADC0 Pin = GPIO26 ADC1 Pin = GPIO27 @@ -92,17 +87,4 @@ const ( UART_RX_PIN = UART0_RX_PIN ) -// UART on the RP2040 -var ( - UART1 = &_UART1 - _UART1 = UART{ - Buffer: NewRingBuffer(), - Bus: rp.UART1, - } -) - var DefaultUART = UART1 - -func init() { - UART1.Interrupt = interrupt.New(rp.IRQ_UART1_IRQ, _UART1.handleInterrupt) -} diff --git a/src/machine/board_kb2040.go b/src/machine/board_kb2040.go index 288f1ddf3..1a6f35362 100644 --- a/src/machine/board_kb2040.go +++ b/src/machine/board_kb2040.go @@ -2,11 +2,6 @@ package machine -import ( - "device/rp" - "runtime/interrupt" -) - // Onboard crystal oscillator frequency, in MHz. const xoscFreq = 12 // MHz @@ -75,28 +70,8 @@ const ( UART_RX_PIN = UART0_RX_PIN ) -// 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 identifiers const ( usb_STRING_PRODUCT = "KB2040" diff --git a/src/machine/board_macropad-rp2040.go b/src/machine/board_macropad-rp2040.go index eca20f797..78bd2b749 100644 --- a/src/machine/board_macropad-rp2040.go +++ b/src/machine/board_macropad-rp2040.go @@ -2,11 +2,6 @@ package machine -import ( - "device/rp" - "runtime/interrupt" -) - const ( NeopixelCount = 12 @@ -78,21 +73,8 @@ const ( UART_RX_PIN = UART0_RX_PIN ) -// UART on the RP2040 -var ( - UART0 = &_UART0 - _UART0 = UART{ - Buffer: NewRingBuffer(), - Bus: rp.UART0, - } -) - var DefaultUART = UART0 -func init() { - UART0.Interrupt = interrupt.New(rp.IRQ_UART0_IRQ, _UART0.handleInterrupt) -} - // USB identifiers const ( usb_STRING_PRODUCT = "MacroPad RP2040" diff --git a/src/machine/board_nano-rp2040.go b/src/machine/board_nano-rp2040.go index 4f5757e86..815552313 100644 --- a/src/machine/board_nano-rp2040.go +++ b/src/machine/board_nano-rp2040.go @@ -11,11 +11,6 @@ // - Nano RP2040 Connect technical reference: https://docs.arduino.cc/tutorials/nano-rp2040-connect/rp2040-01-technical-reference package machine -import ( - "device/rp" - "runtime/interrupt" -) - // Digital Pins const ( D2 Pin = GPIO25 @@ -125,27 +120,7 @@ const ( UART_RX_PIN = UART0_RX_PIN ) -// UART on the RP2040 -var ( - UART0 = &_UART0 - _UART0 = UART{ - Buffer: NewRingBuffer(), - Bus: rp.UART0, - } - - UART1 = &_UART1 - _UART1 = UART{ - Buffer: NewRingBuffer(), - Bus: rp.UART1, - } - - // UART_NINA on the Arduino Nano RP2040 connects to the NINA HCI. - UART_NINA = UART1 -) +// UART_NINA on the Arduino Nano RP2040 connects to the NINA HCI. +var UART_NINA = 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) -} diff --git a/src/machine/board_pico.go b/src/machine/board_pico.go index 41109af03..efbd6ef7d 100644 --- a/src/machine/board_pico.go +++ b/src/machine/board_pico.go @@ -2,11 +2,6 @@ package machine -import ( - "device/rp" - "runtime/interrupt" -) - // GPIO pins const ( GP0 Pin = GPIO0 @@ -79,28 +74,8 @@ const ( UART_RX_PIN = UART0_RX_PIN ) -// 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 identifiers const ( usb_STRING_PRODUCT = "Pico" diff --git a/src/machine/board_qtpy_rp2040.go b/src/machine/board_qtpy_rp2040.go index 3f37023f8..3eabf0c9b 100644 --- a/src/machine/board_qtpy_rp2040.go +++ b/src/machine/board_qtpy_rp2040.go @@ -2,11 +2,6 @@ package machine -import ( - "device/rp" - "runtime/interrupt" -) - // Onboard crystal oscillator frequency, in MHz. const xoscFreq = 12 // MHz @@ -84,28 +79,8 @@ const ( UART_RX_PIN = UART0_RX_PIN ) -// 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 identifiers const ( usb_STRING_PRODUCT = "QT Py RP2040" diff --git a/src/machine/board_thingplus_rp2040.go b/src/machine/board_thingplus_rp2040.go index ac40ee4a4..7f005412f 100644 --- a/src/machine/board_thingplus_rp2040.go +++ b/src/machine/board_thingplus_rp2040.go @@ -2,11 +2,6 @@ package machine -import ( - "device/rp" - "runtime/interrupt" -) - // Onboard crystal oscillator frequency, in MHz. const xoscFreq = 12 // MHz @@ -90,21 +85,8 @@ const ( UART_RX_PIN = UART0_RX_PIN ) -// UART on the RP2040 -var ( - UART0 = &_UART0 - _UART0 = UART{ - Buffer: NewRingBuffer(), - Bus: rp.UART0, - } -) - var DefaultUART = UART0 -func init() { - UART0.Interrupt = interrupt.New(rp.IRQ_UART0_IRQ, _UART0.handleInterrupt) -} - // USB identifiers const ( usb_STRING_PRODUCT = "Thing Plus RP2040" diff --git a/src/machine/board_thumby.go b/src/machine/board_thumby.go index dc1f82beb..f89a8b705 100644 --- a/src/machine/board_thumby.go +++ b/src/machine/board_thumby.go @@ -5,11 +5,6 @@ // https://thumby.us/ package machine -import ( - "device/rp" - "runtime/interrupt" -) - const ( THUMBY_SCK_PIN = I2C1_SDA_PIN THUMBY_SDA_PIN = I2C1_SCL_PIN @@ -78,17 +73,4 @@ const ( UART_RX_PIN = UART0_RX_PIN ) -// UART on the Thumby -var ( - UART0 = &_UART0 - _UART0 = UART{ - Buffer: NewRingBuffer(), - Bus: rp.UART0, - } -) - var DefaultUART = UART0 - -func init() { - UART0.Interrupt = interrupt.New(rp.IRQ_UART0_IRQ, _UART0.handleInterrupt) -} diff --git a/src/machine/board_tufty2040.go b/src/machine/board_tufty2040.go index d82cb9951..57d244f28 100644 --- a/src/machine/board_tufty2040.go +++ b/src/machine/board_tufty2040.go @@ -7,11 +7,6 @@ // - Tufty 2040 schematic: https://cdn.shopify.com/s/files/1/0174/1800/files/tufty_schematic.pdf?v=1655385675 package machine -import ( - "device/rp" - "runtime/interrupt" -) - const ( LED Pin = GPIO25 @@ -87,17 +82,4 @@ const ( UART_RX_PIN = UART0_RX_PIN ) -// UART on the RP2040 -var ( - UART0 = &_UART0 - _UART0 = UART{ - Buffer: NewRingBuffer(), - Bus: rp.UART0, - } -) - var DefaultUART = UART0 - -func init() { - UART0.Interrupt = interrupt.New(rp.IRQ_UART0_IRQ, _UART0.handleInterrupt) -} diff --git a/src/machine/board_waveshare-rp2040-zero.go b/src/machine/board_waveshare-rp2040-zero.go index 65e7a9481..ea9223c15 100644 --- a/src/machine/board_waveshare-rp2040-zero.go +++ b/src/machine/board_waveshare-rp2040-zero.go @@ -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" diff --git a/src/machine/board_xiao-rp2040.go b/src/machine/board_xiao-rp2040.go index 272fcc599..b01031455 100644 --- a/src/machine/board_xiao-rp2040.go +++ b/src/machine/board_xiao-rp2040.go @@ -7,11 +7,6 @@ // - https://wiki.seeedstudio.com/XIAO-RP2040/ package machine -import ( - "device/rp" - "runtime/interrupt" -) - // Digital Pins const ( D0 Pin = GPIO26 @@ -81,21 +76,8 @@ const ( UART_RX_PIN = UART0_RX_PIN ) -// UART on the RP2040 -var ( - UART0 = &_UART0 - _UART0 = UART{ - Buffer: NewRingBuffer(), - Bus: rp.UART0, - } -) - var DefaultUART = UART0 -func init() { - UART0.Interrupt = interrupt.New(rp.IRQ_UART0_IRQ, _UART0.handleInterrupt) -} - // USB CDC identifiers const ( usb_STRING_PRODUCT = "XIAO RP2040" diff --git a/src/machine/machine_rp2040_gpio.go b/src/machine/machine_rp2040_gpio.go index 86cb09eb9..89c5f40b1 100644 --- a/src/machine/machine_rp2040_gpio.go +++ b/src/machine/machine_rp2040_gpio.go @@ -331,3 +331,23 @@ func (p Pin) ioIntBit(change PinChange) uint32 { func getIntChange(p Pin, status uint32) PinChange { return PinChange(status>>(4*(p%8))) & 0xf } + +// 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) +}