aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorsago35 <[email protected]>2020-06-22 16:01:13 +0900
committerGitHub <[email protected]>2020-06-22 09:01:13 +0200
commit2721ab146ffe1ef0924a5eea47b4fcd61f0f124c (patch)
treed318a685ebcd49cf472832c0171ef25b10ca8a39
parent81c723db1a768aae5671162631c2abd0e1ed6211 (diff)
downloadtinygo-2721ab146ffe1ef0924a5eea47b4fcd61f0f124c.tar.gz
tinygo-2721ab146ffe1ef0924a5eea47b4fcd61f0f124c.zip
Seeed XIAO support (#1170)
* machine/xiao: add support for Seeedstudio XIAO board
-rw-r--r--Makefile1
-rw-r--r--README.md3
-rw-r--r--src/machine/board_xiao.go126
-rw-r--r--targets/xiao.json8
4 files changed, 137 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 743f0736d..7dfdb13ac 100644
--- a/Makefile
+++ b/Makefile
@@ -296,6 +296,7 @@ smoketest:
$(TINYGO) build -size short -o test.hex -target=wioterminal examples/blinky1
@$(MD5SUM) test.hex
$(TINYGO) build -size short -o test.hex -target=pygamer examples/blinky1
+ $(TINYGO) build -size short -o test.hex -target=xiao examples/blinky1
@$(MD5SUM) test.hex
ifneq ($(AVR), 0)
$(TINYGO) build -size short -o test.hex -target=atmega1284p examples/serial
diff --git a/README.md b/README.md
index 06002839e..f7bf6fd0a 100644
--- a/README.md
+++ b/README.md
@@ -43,7 +43,7 @@ See the [getting started instructions](https://tinygo.org/getting-started/) for
You can compile TinyGo programs for microcontrollers, WebAssembly and Linux.
-The following 33 microcontroller boards are currently supported:
+The following 34 microcontroller boards are currently supported:
* [Adafruit Circuit Playground Bluefruit](https://www.adafruit.com/product/4333)
* [Adafruit Circuit Playground Express](https://www.adafruit.com/product/3333)
@@ -73,6 +73,7 @@ The following 33 microcontroller boards are currently supported:
* [Phytec reel board](https://www.phytec.eu/product-eu/internet-of-things/reelboard/)
* [PineTime DevKit](https://www.pine64.org/pinetime/)
* [Seeed Wio Terminal](https://www.seeedstudio.com/Wio-Terminal-p-4509.html)
+* [Seeed Seeeduino XIAO](https://www.seeedstudio.com/Seeeduino-XIAO-Arduino-Microcontroller-SAMD21-Cortex-M0+-p-4426.html)
* [SiFIve HiFive1](https://www.sifive.com/boards/hifive1)
* [ST Micro "Nucleo F103RB"](https://www.st.com/en/evaluation-tools/nucleo-f103rb.html)
* [ST Micro STM32F103XX "Bluepill"](http://wiki.stm32duino.com/index.php?title=Blue_Pill)
diff --git a/src/machine/board_xiao.go b/src/machine/board_xiao.go
new file mode 100644
index 000000000..34a88106b
--- /dev/null
+++ b/src/machine/board_xiao.go
@@ -0,0 +1,126 @@
+// +build sam,atsamd21,xiao
+
+package machine
+
+import (
+ "device/sam"
+ "runtime/interrupt"
+)
+
+// used to reset into bootloader
+const RESET_MAGIC_VALUE = 0xf01669ef
+
+// GPIO Pins
+const (
+ D0 = PA02 // can be used for PWM or DAC
+ D1 = PA04 // PWM available
+ D2 = PA10 // PWM available
+ D3 = PA11 // PWM available
+ D4 = PA08 // can be used for PWM or I2C SDA
+ D5 = PA09 // can be used for PWM or I2C SCL
+ D6 = PB08 // can be used for PWM or UART1 TX
+ D7 = PB09 // can be used for PWM or UART1 RX
+ D8 = PA07 // can be used for PWM or SPI SCK
+ D9 = PA05 // can be used for PWM or SPI MISO
+ D10 = PA06 // can be used for PWM or SPI MOSI
+)
+
+// Analog pins
+const (
+ A0 = PA02 // ADC/AIN[0]
+ A1 = PA04 // ADC/AIN[4]
+ A2 = PA10 // ADC/AIN[18]
+ A3 = PA11 // ADC/AIN[19]
+ A4 = PA08 // ADC/AIN[16]
+ A5 = PA09 // ADC/AIN[17]
+ A6 = PB08 // ADC/AIN[2]
+ A7 = PB09 // ADC/AIN[3]
+ A8 = PA07 // ADC/AIN[7]
+ A9 = PA05 // ADC/AIN[6]
+ A10 = PA06 // ADC/AIN[5]
+)
+
+const (
+ LED = PA17
+ LED_RXL = PA18
+ LED_TXL = PA19
+ LED2 = LED_RXL
+ LED3 = LED_TXL
+)
+
+// UART0 aka USBCDC pins
+const (
+ USBCDC_DM_PIN = PA24
+ USBCDC_DP_PIN = PA25
+)
+
+// UART1 pins
+const (
+ UART_TX_PIN = D6
+ UART_RX_PIN = D7
+)
+
+// UART1 on the Xiao
+var (
+ UART1 = UART{
+ Buffer: NewRingBuffer(),
+ Bus: sam.SERCOM4_USART,
+ SERCOM: 4,
+ }
+)
+
+func init() {
+ UART1.Interrupt = interrupt.New(sam.IRQ_SERCOM4, UART1.handleInterrupt)
+}
+
+// I2C pins
+const (
+ SDA_PIN = PA08 // SDA: SERCOM2/PAD[0]
+ SCL_PIN = PA09 // SCL: SERCOM2/PAD[1]
+)
+
+// I2C on the Xiao
+var (
+ I2C0 = I2C{
+ Bus: sam.SERCOM2_I2CM,
+ SERCOM: 2,
+ }
+)
+
+// SPI pins
+const (
+ SPI0_SCK_PIN = PA07 // SCK: SERCOM0/PAD[3]
+ SPI0_MOSI_PIN = PA06 // MOSI: SERCOM0/PAD[2]
+ SPI0_MISO_PIN = PA05 // MISO: SERCOM0/PAD[1]
+)
+
+// SPI on the Xiao
+var (
+ SPI0 = SPI{
+ Bus: sam.SERCOM0_SPI,
+ SERCOM: 0,
+ }
+)
+
+// I2S pins
+const (
+ I2S_SCK_PIN = PA10
+ I2S_SD_PIN = PA08
+ I2S_WS_PIN = NoPin // TODO: figure out what this is on Xiao
+)
+
+// I2S on the Xiao
+var (
+ I2S0 = I2S{Bus: sam.I2S}
+)
+
+// USB CDC identifiers
+const (
+ usb_STRING_PRODUCT = "Seeed XIAO M0"
+ usb_STRING_MANUFACTURER = "Seeed"
+)
+
+var (
+ usb_VID uint16 = 0x2886
+ usb_PID uint16 = 0x802F
+)
diff --git a/targets/xiao.json b/targets/xiao.json
new file mode 100644
index 000000000..10b413005
--- /dev/null
+++ b/targets/xiao.json
@@ -0,0 +1,8 @@
+{
+ "inherits": ["atsamd21g18a"],
+ "build-tags": ["sam", "atsamd21g18a", "xiao"],
+ "flash-1200-bps-reset": "true",
+ "flash-method": "msd",
+ "msd-volume-name": "Arduino",
+ "msd-firmware-name": "firmware.uf2"
+}