Skip to content

Commit aa13b5d

Browse files
conejoninjadeadprogram
authored andcommitted
Add Pimoroni's Tufty2040 board
1 parent 12d63d9 commit aa13b5d

File tree

5 files changed

+130
-1
lines changed

5 files changed

+130
-1
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,8 @@ endif
589589
@$(MD5SUM) test.hex
590590
$(TINYGO) build -size short -o test.hex -target=badger2040 examples/blinky1
591591
@$(MD5SUM) test.hex
592+
$(TINYGO) build -size short -o test.hex -target=tufty2040 examples/blinky1
593+
@$(MD5SUM) test.hex
592594
$(TINYGO) build -size short -o test.hex -target=thingplus-rp2040 examples/blinky1
593595
@$(MD5SUM) test.hex
594596
$(TINYGO) build -size short -o test.hex -target=xiao-rp2040 examples/blinky1

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ See the [getting started instructions](https://tinygo.org/getting-started/) for
4343

4444
You can compile TinyGo programs for microcontrollers, WebAssembly and Linux.
4545

46-
The following 88 microcontroller boards are currently supported:
46+
The following 89 microcontroller boards are currently supported:
4747

4848
* [Adafruit Circuit Playground Bluefruit](https://www.adafruit.com/product/4333)
4949
* [Adafruit Circuit Playground Express](https://www.adafruit.com/product/3333)
@@ -108,6 +108,7 @@ The following 88 microcontroller boards are currently supported:
108108
* [Particle Xenon](https://docs.particle.io/datasheets/discontinued/xenon-datasheet/)
109109
* [Phytec reel board](https://www.phytec.eu/product-eu/internet-of-things/reelboard/)
110110
* [Pimoroni Badger2040](https://shop.pimoroni.com/products/badger-2040)
111+
* [Pimoroni Tufty2040](https://shop.pimoroni.com/products/tufty-2040)
111112
* [PineTime DevKit](https://www.pine64.org/pinetime/)
112113
* [PJRC Teensy 3.6](https://www.pjrc.com/store/teensy36.html)
113114
* [PJRC Teensy 4.0](https://www.pjrc.com/store/teensy40.html)

src/machine/board_tufty2040.go

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
//go:build tufty2040
2+
// +build tufty2040
3+
4+
// This contains the pin mappings for the Badger 2040 Connect board.
5+
//
6+
// For more information, see: https://shop.pimoroni.com/products/tufty-2040
7+
// Also
8+
// - Tufty 2040 schematic: https://cdn.shopify.com/s/files/1/0174/1800/files/tufty_schematic.pdf?v=1655385675
9+
//
10+
package machine
11+
12+
import (
13+
"device/rp"
14+
"runtime/interrupt"
15+
)
16+
17+
const (
18+
LED Pin = GPIO25
19+
20+
BUTTON_A Pin = GPIO7
21+
BUTTON_B Pin = GPIO8
22+
BUTTON_C Pin = GPIO9
23+
BUTTON_UP Pin = GPIO22
24+
BUTTON_DOWN Pin = GPIO6
25+
BUTTON_USER Pin = GPIO23
26+
27+
LCD_BACKLIGHT Pin = GPIO2
28+
LCD_CS Pin = GPIO10
29+
LCD_DC Pin = GPIO11
30+
LCD_WR Pin = GPIO12
31+
LCD_RD Pin = GPIO13
32+
LCD_DB0 Pin = GPIO14
33+
LCD_DB1 Pin = GPIO15
34+
LCD_DB2 Pin = GPIO16
35+
LCD_DB3 Pin = GPIO17
36+
LCD_DB4 Pin = GPIO18
37+
LCD_DB5 Pin = GPIO19
38+
LCD_DB6 Pin = GPIO20
39+
LCD_DB7 Pin = GPIO21
40+
41+
VBUS_DETECT Pin = GPIO24
42+
BATTERY Pin = GPIO29
43+
USER_LED Pin = GPIO25
44+
LIGHT_SENSE Pin = GPIO26
45+
SENSOR_POWER Pin = GPIO27
46+
)
47+
48+
// I2C pins
49+
const (
50+
I2C0_SDA_PIN Pin = GPIO4
51+
I2C0_SCL_PIN Pin = GPIO5
52+
53+
I2C1_SDA_PIN Pin = NoPin
54+
I2C1_SCL_PIN Pin = NoPin
55+
)
56+
57+
// SPI pins.
58+
const (
59+
SPI0_SCK_PIN Pin = NoPin
60+
SPI0_SDO_PIN Pin = NoPin
61+
SPI0_SDI_PIN Pin = NoPin
62+
63+
SPI1_SCK_PIN Pin = NoPin
64+
SPI1_SDO_PIN Pin = NoPin
65+
SPI1_SDI_PIN Pin = NoPin
66+
)
67+
68+
// Onboard crystal oscillator frequency, in MHz.
69+
const (
70+
xoscFreq = 12 // MHz
71+
)
72+
73+
// USB CDC identifiers
74+
const (
75+
usb_STRING_PRODUCT = "Tufty 2040"
76+
usb_STRING_MANUFACTURER = "Pimoroni"
77+
)
78+
79+
var (
80+
usb_VID uint16 = 0x2e8a
81+
usb_PID uint16 = 0x1002
82+
)
83+
84+
// UART pins
85+
const (
86+
UART0_TX_PIN = GPIO0
87+
UART0_RX_PIN = GPIO1
88+
UART_TX_PIN = UART0_TX_PIN
89+
UART_RX_PIN = UART0_RX_PIN
90+
)
91+
92+
// UART on the RP2040
93+
var (
94+
UART0 = &_UART0
95+
_UART0 = UART{
96+
Buffer: NewRingBuffer(),
97+
Bus: rp.UART0,
98+
}
99+
)
100+
101+
var DefaultUART = UART0
102+
103+
func init() {
104+
UART0.Interrupt = interrupt.New(rp.IRQ_UART0_IRQ, _UART0.handleInterrupt)
105+
}

targets/tufty2040.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"inherits": [
3+
"rp2040"
4+
],
5+
"serial-port": ["acm:2e8a:0003"],
6+
"build-tags": ["tufty2040"],
7+
"linkerscript": "targets/tufty2040.ld",
8+
"extra-files": [
9+
"targets/pico-boot-stage2.S"
10+
]
11+
}

targets/tufty2040.ld

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
MEMORY
3+
{
4+
/* Reserve exactly 256 bytes at start of flash for second stage bootloader */
5+
BOOT2_TEXT (rx) : ORIGIN = 0x10000000, LENGTH = 256
6+
FLASH_TEXT (rx) : ORIGIN = 0x10000000 + 256, LENGTH = 1020K - 256
7+
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 256k
8+
}
9+
10+
INCLUDE "targets/rp2040.ld"

0 commit comments

Comments
 (0)