diff options
author | deadprogram <[email protected]> | 2024-02-21 00:09:34 +0100 |
---|---|---|
committer | Ron Evans <[email protected]> | 2024-02-23 14:00:57 +0100 |
commit | c66836cf3a543d3a41d7bf9510a3c2511c7770c4 (patch) | |
tree | 37adcf0b6180fd486c767af7dd3774b5dca6f11a | |
parent | ca9211b582e9295c167e5ec5cdef2265823861ca (diff) | |
download | tinygo-c66836cf3a543d3a41d7bf9510a3c2511c7770c4.tar.gz tinygo-c66836cf3a543d3a41d7bf9510a3c2511c7770c4.zip |
targets: add support for Thumby
Signed-off-by: deadprogram <[email protected]>
-rw-r--r-- | GNUmakefile | 2 | ||||
-rw-r--r-- | src/machine/board_thumby.go | 94 | ||||
-rw-r--r-- | targets/thumby.json | 14 |
3 files changed, 110 insertions, 0 deletions
diff --git a/GNUmakefile b/GNUmakefile index e2a34a558..760ba6041 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 000000000..dc1f82beb --- /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 000000000..41cbc5e12 --- /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" + ] +} |