Skip to content

Commit 4922aa6

Browse files
Munsiotorntrousers
authored andcommitted
[Board] Adafruit Trinket (tinygo-org#333)
* Add support for Adafruit Trinket-M0 board
1 parent 3bd4bdf commit 4922aa6

File tree

10 files changed

+1103
-612
lines changed

10 files changed

+1103
-612
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ commands:
7979
- run: tinygo build -size short -o test.elf -target=pca10056 examples/blinky1
8080
- run: tinygo build -size short -o test.elf -target=pca10056 examples/blinky2
8181
- run: tinygo build -size short -o test.elf -target=itsybitsy-m0 examples/blinky1
82+
- run: tinygo build -size short -o test.elf -target=trinket-m0 examples/blinky1
8283
- run: tinygo build -size short -o test.elf -target=circuitplay-express examples/blinky1
8384
- run: tinygo build -size short -o test.elf -target=stm32f4disco examples/blinky1
8485
- run: tinygo build -size short -o test.elf -target=stm32f4disco examples/blinky2

src/machine/board_trinket.go

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// +build sam,atsamd21,trinket_m0
2+
3+
package machine
4+
5+
import "device/sam"
6+
7+
// GPIO Pins
8+
const (
9+
D0 = PA08 // PWM available
10+
D1 = PA02
11+
D2 = PA09 // PWM available
12+
D3 = PA07 // PWM available / UART0 RX
13+
D4 = PA06 // PWM available / UART0 TX
14+
D13 = PA10 // LED
15+
)
16+
17+
// Analog pins
18+
const (
19+
A0 = D1
20+
A1 = D2
21+
A2 = D0
22+
A3 = D3
23+
A4 = D4
24+
)
25+
26+
const (
27+
LED = D13
28+
)
29+
30+
// UART0 aka USBCDC pins
31+
const (
32+
USBCDC_DM_PIN = PA24
33+
USBCDC_DP_PIN = PA25
34+
)
35+
36+
// UART1 pins
37+
const (
38+
UART_TX_PIN = D4
39+
UART_RX_PIN = D3
40+
)
41+
42+
// SPI pins
43+
const (
44+
SPI0_SCK_PIN = D3
45+
SPI0_MOSI_PIN = D4
46+
SPI0_MISO_PIN = D2
47+
)
48+
49+
// SPI on the Trinket M0.
50+
var (
51+
SPI0 = SPI{Bus: sam.SERCOM0_SPI}
52+
)
53+
54+
// I2C pins
55+
const (
56+
SDA_PIN = D0 // SDA
57+
SCL_PIN = D2 // SCL
58+
)
59+
60+
// I2C on the Trinket M0.
61+
var (
62+
I2C0 = I2C{Bus: sam.SERCOM2_I2CM,
63+
SDA: SDA_PIN,
64+
SCL: SCL_PIN,
65+
PinMode: GPIO_SERCOM_ALT}
66+
)
67+
68+
// I2S pins
69+
const (
70+
I2S_SCK_PIN = PA10
71+
I2S_SD_PIN = PA08
72+
I2S_WS_PIN = 0xff // TODO: figure out what this is on Trinket M0.
73+
)

0 commit comments

Comments
 (0)