From c66836cf3a543d3a41d7bf9510a3c2511c7770c4 Mon Sep 17 00:00:00 2001 From: deadprogram Date: Wed, 21 Feb 2024 00:09:34 +0100 Subject: [PATCH] targets: add support for Thumby Signed-off-by: deadprogram --- GNUmakefile | 2 + src/machine/board_thumby.go | 94 +++++++++++++++++++++++++++++++++++++ targets/thumby.json | 14 ++++++ 3 files changed, 110 insertions(+) create mode 100644 src/machine/board_thumby.go create mode 100644 targets/thumby.json diff --git a/GNUmakefile b/GNUmakefile index e2a34a558f..760ba60413 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -670,6 +670,8 @@ endif @$(MD5SUM) test.hex $(TINYGO) build -size short -o test.hex -target=ae-rp2040 examples/echo @$(MD5SUM) test.hex + $(TINYGO) build -size short -o test.hex -target=thumby examples/echo + @$(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_thumby.go b/src/machine/board_thumby.go new file mode 100644 index 0000000000..dc1f82beb3 --- /dev/null +++ b/src/machine/board_thumby.go @@ -0,0 +1,94 @@ +//go:build thumby + +// This contains the pin mappings for the Thumby. +// +// https://thumby.us/ +package machine + +import ( + "device/rp" + "runtime/interrupt" +) + +const ( + THUMBY_SCK_PIN = I2C1_SDA_PIN + THUMBY_SDA_PIN = I2C1_SCL_PIN + + THUMBY_CS_PIN = GPIO16 + THUMBY_DC_PIN = GPIO17 + THUMBY_RESET_PIN = GPIO20 + + THUMBY_LINK_TX_PIN = UART0_TX_PIN + THUMBY_LINK_RX_PIN = UART0_RX_PIN + THUMBY_LINK_PU_PIN = GPIO2 + + THUMBY_BTN_LDPAD_PIN = GPIO3 + THUMBY_BTN_RDPAD_PIN = GPIO5 + THUMBY_BTN_UDPAD_PIN = GPIO4 + THUMBY_BTN_DDPAD_PIN = GPIO6 + THUMBY_BTN_B_PIN = GPIO24 + THUMBY_BTN_A_PIN = GPIO27 + + THUMBY_AUDIO_PIN = GPIO28 + + THUMBY_SCREEN_RESET_PIN = GPIO20 +) + +// I2C pins +const ( + I2C0_SDA_PIN Pin = NoPin + I2C0_SCL_PIN Pin = NoPin + + I2C1_SDA_PIN Pin = GPIO18 + I2C1_SCL_PIN Pin = GPIO19 +) + +// SPI pins +const ( + SPI0_SCK_PIN = GPIO18 + SPI0_SDO_PIN = GPIO19 + SPI0_SDI_PIN = GPIO16 + + SPI1_SCK_PIN = NoPin + SPI1_SDO_PIN = NoPin + SPI1_SDI_PIN = NoPin +) + +// Onboard crystal oscillator frequency, in MHz. +const ( + xoscFreq = 12 // MHz +) + +// USB CDC identifiers +const ( + usb_STRING_PRODUCT = "Thumby" + usb_STRING_MANUFACTURER = "TinyCircuits" +) + +var ( + usb_VID uint16 = 0x2E8A + usb_PID uint16 = 0x0005 +) + +// UART pins +const ( + UART0_TX_PIN = GPIO0 + UART0_RX_PIN = GPIO1 + UART_TX_PIN = UART0_TX_PIN + 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/targets/thumby.json b/targets/thumby.json new file mode 100644 index 0000000000..41cbc5e127 --- /dev/null +++ b/targets/thumby.json @@ -0,0 +1,14 @@ +{ + "inherits": [ + "rp2040" + ], + "serial-port": ["2e8a:0005"], + "build-tags": ["thumby"], + "default-stack-size": 8192, + "ldflags": [ + "--defsym=__flash_size=2048K" + ], + "extra-files": [ + "targets/pico-boot-stage2.S" + ] +}