Skip to content

Commit

Permalink
targets: add support for Thumby
Browse files Browse the repository at this point in the history
Signed-off-by: deadprogram <ron@hybridgroup.com>
  • Loading branch information
deadprogram committed Feb 23, 2024
1 parent ca9211b commit c66836c
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 0 deletions.
2 changes: 2 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
94 changes: 94 additions & 0 deletions src/machine/board_thumby.go
Original file line number Diff line number Diff line change
@@ -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)
}
14 changes: 14 additions & 0 deletions targets/thumby.json
Original file line number Diff line number Diff line change
@@ -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"
]
}

0 comments on commit c66836c

Please sign in to comment.