Skip to content

Commit 2721ab1

Browse files
authored
Seeed XIAO support (#1170)
* machine/xiao: add support for Seeedstudio XIAO board
1 parent 81c723d commit 2721ab1

File tree

4 files changed

+137
-1
lines changed

4 files changed

+137
-1
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ smoketest:
296296
$(TINYGO) build -size short -o test.hex -target=wioterminal examples/blinky1
297297
@$(MD5SUM) test.hex
298298
$(TINYGO) build -size short -o test.hex -target=pygamer examples/blinky1
299+
$(TINYGO) build -size short -o test.hex -target=xiao examples/blinky1
299300
@$(MD5SUM) test.hex
300301
ifneq ($(AVR), 0)
301302
$(TINYGO) build -size short -o test.hex -target=atmega1284p examples/serial

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 33 microcontroller boards are currently supported:
46+
The following 34 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)
@@ -73,6 +73,7 @@ The following 33 microcontroller boards are currently supported:
7373
* [Phytec reel board](https://www.phytec.eu/product-eu/internet-of-things/reelboard/)
7474
* [PineTime DevKit](https://www.pine64.org/pinetime/)
7575
* [Seeed Wio Terminal](https://www.seeedstudio.com/Wio-Terminal-p-4509.html)
76+
* [Seeed Seeeduino XIAO](https://www.seeedstudio.com/Seeeduino-XIAO-Arduino-Microcontroller-SAMD21-Cortex-M0+-p-4426.html)
7677
* [SiFIve HiFive1](https://www.sifive.com/boards/hifive1)
7778
* [ST Micro "Nucleo F103RB"](https://www.st.com/en/evaluation-tools/nucleo-f103rb.html)
7879
* [ST Micro STM32F103XX "Bluepill"](http://wiki.stm32duino.com/index.php?title=Blue_Pill)

src/machine/board_xiao.go

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
// +build sam,atsamd21,xiao
2+
3+
package machine
4+
5+
import (
6+
"device/sam"
7+
"runtime/interrupt"
8+
)
9+
10+
// used to reset into bootloader
11+
const RESET_MAGIC_VALUE = 0xf01669ef
12+
13+
// GPIO Pins
14+
const (
15+
D0 = PA02 // can be used for PWM or DAC
16+
D1 = PA04 // PWM available
17+
D2 = PA10 // PWM available
18+
D3 = PA11 // PWM available
19+
D4 = PA08 // can be used for PWM or I2C SDA
20+
D5 = PA09 // can be used for PWM or I2C SCL
21+
D6 = PB08 // can be used for PWM or UART1 TX
22+
D7 = PB09 // can be used for PWM or UART1 RX
23+
D8 = PA07 // can be used for PWM or SPI SCK
24+
D9 = PA05 // can be used for PWM or SPI MISO
25+
D10 = PA06 // can be used for PWM or SPI MOSI
26+
)
27+
28+
// Analog pins
29+
const (
30+
A0 = PA02 // ADC/AIN[0]
31+
A1 = PA04 // ADC/AIN[4]
32+
A2 = PA10 // ADC/AIN[18]
33+
A3 = PA11 // ADC/AIN[19]
34+
A4 = PA08 // ADC/AIN[16]
35+
A5 = PA09 // ADC/AIN[17]
36+
A6 = PB08 // ADC/AIN[2]
37+
A7 = PB09 // ADC/AIN[3]
38+
A8 = PA07 // ADC/AIN[7]
39+
A9 = PA05 // ADC/AIN[6]
40+
A10 = PA06 // ADC/AIN[5]
41+
)
42+
43+
const (
44+
LED = PA17
45+
LED_RXL = PA18
46+
LED_TXL = PA19
47+
LED2 = LED_RXL
48+
LED3 = LED_TXL
49+
)
50+
51+
// UART0 aka USBCDC pins
52+
const (
53+
USBCDC_DM_PIN = PA24
54+
USBCDC_DP_PIN = PA25
55+
)
56+
57+
// UART1 pins
58+
const (
59+
UART_TX_PIN = D6
60+
UART_RX_PIN = D7
61+
)
62+
63+
// UART1 on the Xiao
64+
var (
65+
UART1 = UART{
66+
Buffer: NewRingBuffer(),
67+
Bus: sam.SERCOM4_USART,
68+
SERCOM: 4,
69+
}
70+
)
71+
72+
func init() {
73+
UART1.Interrupt = interrupt.New(sam.IRQ_SERCOM4, UART1.handleInterrupt)
74+
}
75+
76+
// I2C pins
77+
const (
78+
SDA_PIN = PA08 // SDA: SERCOM2/PAD[0]
79+
SCL_PIN = PA09 // SCL: SERCOM2/PAD[1]
80+
)
81+
82+
// I2C on the Xiao
83+
var (
84+
I2C0 = I2C{
85+
Bus: sam.SERCOM2_I2CM,
86+
SERCOM: 2,
87+
}
88+
)
89+
90+
// SPI pins
91+
const (
92+
SPI0_SCK_PIN = PA07 // SCK: SERCOM0/PAD[3]
93+
SPI0_MOSI_PIN = PA06 // MOSI: SERCOM0/PAD[2]
94+
SPI0_MISO_PIN = PA05 // MISO: SERCOM0/PAD[1]
95+
)
96+
97+
// SPI on the Xiao
98+
var (
99+
SPI0 = SPI{
100+
Bus: sam.SERCOM0_SPI,
101+
SERCOM: 0,
102+
}
103+
)
104+
105+
// I2S pins
106+
const (
107+
I2S_SCK_PIN = PA10
108+
I2S_SD_PIN = PA08
109+
I2S_WS_PIN = NoPin // TODO: figure out what this is on Xiao
110+
)
111+
112+
// I2S on the Xiao
113+
var (
114+
I2S0 = I2S{Bus: sam.I2S}
115+
)
116+
117+
// USB CDC identifiers
118+
const (
119+
usb_STRING_PRODUCT = "Seeed XIAO M0"
120+
usb_STRING_MANUFACTURER = "Seeed"
121+
)
122+
123+
var (
124+
usb_VID uint16 = 0x2886
125+
usb_PID uint16 = 0x802F
126+
)

targets/xiao.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"inherits": ["atsamd21g18a"],
3+
"build-tags": ["sam", "atsamd21g18a", "xiao"],
4+
"flash-1200-bps-reset": "true",
5+
"flash-method": "msd",
6+
"msd-volume-name": "Arduino",
7+
"msd-firmware-name": "firmware.uf2"
8+
}

0 commit comments

Comments
 (0)