Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for the Arduino Zero #1365

Merged
merged 5 commits into from
Sep 10, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 40 microcontroller boards are currently supported:
The following 41 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)
Expand All @@ -62,6 +62,7 @@ The following 40 microcontroller boards are currently supported:
* [Arduino Mega 2560](https://store.arduino.cc/arduino-mega-2560-rev3)
* [Arduino Nano](https://store.arduino.cc/arduino-nano)
* [Arduino Nano33 IoT](https://store.arduino.cc/nano-33-iot)
* [Arduino Zero](https://store.arduino.cc/usa/arduino-zero)
* [Arduino Uno](https://store.arduino.cc/arduino-uno-rev3)
* [BBC micro:bit](https://microbit.org/)
* [Digispark](http://digistump.com/products/1)
Expand Down
85 changes: 85 additions & 0 deletions src/machine/board_arduino_zero.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// +build sam,atsamd21,arduino_zero

package machine

// used to reset into bootloader
const RESET_MAGIC_VALUE = 0x07738135

// GPIO Pins
const (
D0 = PA11 // RX
D1 = PA10 // TX
D2 = PA14
D3 = PA09 // PWM available
D4 = PA08 // PWM available
D5 = PA15 // PWM available
D6 = PA20 // PWM available
D7 = PA21
D8 = PA06 // PWM available
D9 = PA07 // PWM available
D10 = PA18 // PWM available
D11 = PA16 // PWM available
D12 = PA19 // PWM available
D13 = PA17 // PWM available
)

// LEDs on the Arduino Zero
const (
LED Pin = D13
LED1 Pin = PA27
LED2 Pin = PB03
)

// ADC on the Arduino
const (
ADC0 Pin = PA02
ADC1 Pin = PB08
ADC2 Pin = PB09
ADC3 Pin = PA04
ADC4 Pin = PA05
ADC5 Pin = PB02
)

// SPI pins
const (
SPI0_SDO_PIN = PA16 // MOSI: SERCOM1/PAD[0]
SPI0_SCK_PIN = PA17 // SCK: SERCOM1/PAD[1]
SPI0_SS_Pin = PA18 // SS: SERCOM1/PAD[2]
SPI0_SDI_PIN = PA19 // MISO: SERCOM1/PAD[3]
)

// I2C pins
const (
SDA_PIN Pin = PA22 // SDA: SERCOM3/PAD[0]
SCL_PIN Pin = PA23 // SCL: SERCOM3/PAD[1]
)

// I2S pins
const (
I2S_SCK_PIN Pin = PA10
I2S_SD_PIN Pin = PA07
I2S_WS_PIN Pin = PA11
)

// UART0 pins - 'promgramming' USB port
const (
UART_TX_PIN Pin = D1
UART_RX_PIN Pin = D0
)

// 'native' USB port pins
const (
USBCDC_DM_PIN Pin = PA25
USBCDC_DP_PIN Pin = PA24
)

// USB CDC identifiers
const (
usb_STRING_PRODUCT = "Arduino Zero"
usb_STRING_MANUFACTURER = "Arduino LLC"
)

var (
usb_VID uint16 = 0x03eb
usb_PID uint16 = 0x2157
jreamy marked this conversation as resolved.
Show resolved Hide resolved
)
6 changes: 6 additions & 0 deletions targets/arduino-zero-native.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"inherits": ["atsamd21g18a"],
"build-tags": ["sam", "atsamd21g18a", "arduino_zero"],
"flash-command": "bossac -i -e -w -v -R -U --port={port} --offset=0x2000 {bin}",
"flash-1200-bps-reset": "true"
}
9 changes: 9 additions & 0 deletions targets/arduino-zero-programming.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"inherits": ["atsamd21g18a"],
"build-tags": ["sam", "atsamd21g18a", "arduino_zero"],

"flash-method":"openocd",
"openocd-transport": "swd",
"openocd-target": "at91samdXX",
"openocd-interface":"cmsis-dap"
}
jreamy marked this conversation as resolved.
Show resolved Hide resolved