aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDaniel Esteban <[email protected]>2023-03-22 07:45:10 +0100
committerRon Evans <[email protected]>2023-03-22 16:17:12 +0100
commit4b0e56cbec91a2b4e26b362493bc552e72803da6 (patch)
tree598396d8d42d4cf58ccba7e0519747c5103303d8
parent62e1c3ebb7ae87fbc4ed53cb2f0572d72b284e77 (diff)
downloadtinygo-4b0e56cbec91a2b4e26b362493bc552e72803da6.tar.gz
tinygo-4b0e56cbec91a2b4e26b362493bc552e72803da6.zip
Added Gopher Badge support
-rw-r--r--Makefile2
-rw-r--r--src/machine/board_gopher-badge.go108
-rw-r--r--targets/gopher-badge.json11
-rw-r--r--targets/gopher-badge.ld10
4 files changed, 131 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 4a2010527..9517cab9f 100644
--- a/Makefile
+++ b/Makefile
@@ -638,6 +638,8 @@ endif
@$(MD5SUM) test.hex
$(TINYGO) build -size short -o test.hex -target=trinkey-qt2040 examples/temp
@$(MD5SUM) test.hex
+ $(TINYGO) build -size short -o test.hex -target=gopher-badge examples/blinky1
+ @$(MD5SUM) test.hex
# test pwm
$(TINYGO) build -size short -o test.hex -target=itsybitsy-m0 examples/pwm
@$(MD5SUM) test.hex
diff --git a/src/machine/board_gopher-badge.go b/src/machine/board_gopher-badge.go
new file mode 100644
index 000000000..59c17beb2
--- /dev/null
+++ b/src/machine/board_gopher-badge.go
@@ -0,0 +1,108 @@
+//go:build gopher_badge
+
+// This contains the pin mappings for the Gopher Badge.
+//
+// For more information, see: https://gopherbadge.com/
+package machine
+
+import (
+ "device/rp"
+ "runtime/interrupt"
+)
+
+const (
+ /*ADC0 Pin = GPIO26
+ ADC1 Pin = GPIO27
+ ADC2 Pin = GPIO28
+ GPIO4 Pin = GPIO4
+ GPIO5 Pin = GPIO5
+ GPIO6 Pin = GPIO6
+ GPIO7 Pin = GPIO7
+ GPIO8 Pin = GPIO8
+ GPIO9 Pin = GPIO9*/
+
+ PENIRQ Pin = GPIO13
+
+ LED Pin = GPIO2
+ NEOPIXELS Pin = GPIO15
+ WS2812 Pin = GPIO15
+
+ BUTTON_A Pin = GPIO10
+ BUTTON_B Pin = GPIO11
+ BUTTON_LEFT Pin = GPIO25
+ BUTTON_UP Pin = GPIO24
+ BUTTON_RIGHT Pin = GPIO22
+ BUTTON_DOWN Pin = GPIO23
+
+ TFT_RST Pin = GPIO21
+ TFT_SDI Pin = GPIO19
+ TFT_SDO Pin = GPIO16
+ TFT_CS Pin = GPIO17
+ TFT_SCL Pin = GPIO18
+ TFT_WRX Pin = GPIO20
+ TFT_BACKLIGHT Pin = GPIO12
+
+ SPEAKER Pin = GPIO14
+ SPEAKER_ENABLE Pin = GPIO3
+)
+
+// I2C pins
+const (
+ I2C0_SDA_PIN Pin = GPIO0
+ I2C0_SCL_PIN Pin = GPIO1
+
+ I2C1_SDA_PIN Pin = NoPin
+ I2C1_SCL_PIN Pin = NoPin
+)
+
+// SPI pins.
+const (
+ SPI0_SCK_PIN Pin = GPIO18
+ SPI0_SDO_PIN Pin = GPIO19
+ SPI0_SDI_PIN Pin = GPIO16
+
+ SPI1_SCK_PIN Pin = NoPin
+ SPI1_SDO_PIN Pin = NoPin
+ SPI1_SDI_PIN Pin = NoPin
+)
+
+// Onboard crystal oscillator frequency, in MHz.
+const (
+ xoscFreq = 12 // MHz
+)
+
+// USB CDC identifiers
+const (
+ usb_STRING_PRODUCT = "Gopher Badger"
+ usb_STRING_MANUFACTURER = "TinyGo"
+)
+
+var (
+ usb_VID uint16 = 0x2e8a
+ usb_PID uint16 = 0x0003
+)
+
+// UART pins
+const (
+ UART0_TX_PIN = GPIO0
+ UART0_RX_PIN = GPIO1
+ UART1_TX_PIN = GPIO4
+ UART1_RX_PIN = GPIO5
+ UART_TX_PIN = UART0_TX_PIN
+ 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/targets/gopher-badge.json b/targets/gopher-badge.json
new file mode 100644
index 000000000..8bf4f0c92
--- /dev/null
+++ b/targets/gopher-badge.json
@@ -0,0 +1,11 @@
+{
+ "inherits": [
+ "rp2040"
+ ],
+ "serial-port": ["2e8a:0003"],
+ "build-tags": ["gopher_badge"],
+ "linkerscript": "targets/gopher-badge.ld",
+ "extra-files": [
+ "targets/pico-boot-stage2.S"
+ ]
+}
diff --git a/targets/gopher-badge.ld b/targets/gopher-badge.ld
new file mode 100644
index 000000000..7e06d7a0a
--- /dev/null
+++ b/targets/gopher-badge.ld
@@ -0,0 +1,10 @@
+
+MEMORY
+{
+ /* Reserve exactly 256 bytes at start of flash for second stage bootloader */
+ BOOT2_TEXT (rx) : ORIGIN = 0x10000000, LENGTH = 256
+ FLASH_TEXT (rx) : ORIGIN = 0x10000000 + 256, LENGTH = 1020K - 256
+ RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 256k
+}
+
+INCLUDE "targets/rp2040.ld"