Skip to content

Commit c66836c

Browse files
committed
targets: add support for Thumby
Signed-off-by: deadprogram <[email protected]>
1 parent ca9211b commit c66836c

File tree

3 files changed

+110
-0
lines changed

3 files changed

+110
-0
lines changed

GNUmakefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,8 @@ endif
670670
@$(MD5SUM) test.hex
671671
$(TINYGO) build -size short -o test.hex -target=ae-rp2040 examples/echo
672672
@$(MD5SUM) test.hex
673+
$(TINYGO) build -size short -o test.hex -target=thumby examples/echo
674+
@$(MD5SUM) test.hex
673675
# test pwm
674676
$(TINYGO) build -size short -o test.hex -target=itsybitsy-m0 examples/pwm
675677
@$(MD5SUM) test.hex

src/machine/board_thumby.go

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
//go:build thumby
2+
3+
// This contains the pin mappings for the Thumby.
4+
//
5+
// https://thumby.us/
6+
package machine
7+
8+
import (
9+
"device/rp"
10+
"runtime/interrupt"
11+
)
12+
13+
const (
14+
THUMBY_SCK_PIN = I2C1_SDA_PIN
15+
THUMBY_SDA_PIN = I2C1_SCL_PIN
16+
17+
THUMBY_CS_PIN = GPIO16
18+
THUMBY_DC_PIN = GPIO17
19+
THUMBY_RESET_PIN = GPIO20
20+
21+
THUMBY_LINK_TX_PIN = UART0_TX_PIN
22+
THUMBY_LINK_RX_PIN = UART0_RX_PIN
23+
THUMBY_LINK_PU_PIN = GPIO2
24+
25+
THUMBY_BTN_LDPAD_PIN = GPIO3
26+
THUMBY_BTN_RDPAD_PIN = GPIO5
27+
THUMBY_BTN_UDPAD_PIN = GPIO4
28+
THUMBY_BTN_DDPAD_PIN = GPIO6
29+
THUMBY_BTN_B_PIN = GPIO24
30+
THUMBY_BTN_A_PIN = GPIO27
31+
32+
THUMBY_AUDIO_PIN = GPIO28
33+
34+
THUMBY_SCREEN_RESET_PIN = GPIO20
35+
)
36+
37+
// I2C pins
38+
const (
39+
I2C0_SDA_PIN Pin = NoPin
40+
I2C0_SCL_PIN Pin = NoPin
41+
42+
I2C1_SDA_PIN Pin = GPIO18
43+
I2C1_SCL_PIN Pin = GPIO19
44+
)
45+
46+
// SPI pins
47+
const (
48+
SPI0_SCK_PIN = GPIO18
49+
SPI0_SDO_PIN = GPIO19
50+
SPI0_SDI_PIN = GPIO16
51+
52+
SPI1_SCK_PIN = NoPin
53+
SPI1_SDO_PIN = NoPin
54+
SPI1_SDI_PIN = NoPin
55+
)
56+
57+
// Onboard crystal oscillator frequency, in MHz.
58+
const (
59+
xoscFreq = 12 // MHz
60+
)
61+
62+
// USB CDC identifiers
63+
const (
64+
usb_STRING_PRODUCT = "Thumby"
65+
usb_STRING_MANUFACTURER = "TinyCircuits"
66+
)
67+
68+
var (
69+
usb_VID uint16 = 0x2E8A
70+
usb_PID uint16 = 0x0005
71+
)
72+
73+
// UART pins
74+
const (
75+
UART0_TX_PIN = GPIO0
76+
UART0_RX_PIN = GPIO1
77+
UART_TX_PIN = UART0_TX_PIN
78+
UART_RX_PIN = UART0_RX_PIN
79+
)
80+
81+
// UART on the Thumby
82+
var (
83+
UART0 = &_UART0
84+
_UART0 = UART{
85+
Buffer: NewRingBuffer(),
86+
Bus: rp.UART0,
87+
}
88+
)
89+
90+
var DefaultUART = UART0
91+
92+
func init() {
93+
UART0.Interrupt = interrupt.New(rp.IRQ_UART0_IRQ, _UART0.handleInterrupt)
94+
}

targets/thumby.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"inherits": [
3+
"rp2040"
4+
],
5+
"serial-port": ["2e8a:0005"],
6+
"build-tags": ["thumby"],
7+
"default-stack-size": 8192,
8+
"ldflags": [
9+
"--defsym=__flash_size=2048K"
10+
],
11+
"extra-files": [
12+
"targets/pico-boot-stage2.S"
13+
]
14+
}

0 commit comments

Comments
 (0)