Skip to content

Add Arduino M0 Pro support #4831

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

Draft
wants to merge 1 commit into
base: release
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
95 changes: 95 additions & 0 deletions src/machine/board_arduino_m0_pro.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
//go:build sam && atsamd21 && arduino_m0_pro

package machine

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

// GPIO Pins - Digital Low
const (
D0 = PA11 // RX
D1 = PA10 // TX
D2 = PA08
D3 = PA09 // PWM available
D4 = PA14 // PWM available
D5 = PA15 // PWM available
D6 = PA20 // PWM available
D7 = PA21
)

// GPIO Pins - Digital High
const (
D8 = PA06 // PWM available
D9 = PA07 // PWM available
D10 = PA18 // PWM available
D11 = PA16 // PWM available
D12 = PA19 // PWM available
D13 = PA17 // PWM available
)

// ADC pins
const (
AREF Pin = PA03
ADC0 Pin = PA02
ADC1 Pin = PB08
ADC2 Pin = PB09
ADC3 Pin = PA04
ADC4 Pin = PA05
ADC5 Pin = PB02
)

// LEDs on the Arduino M0 Pro
const (
LED = LED1
LED1 Pin = D13
LED2 Pin = PA27 // TX LED
LED3 Pin = PB03 // RX LED
)

// SPI pins
const (
SPI0_SDO_PIN Pin = PB10 // MOSI
SPI0_SDI_PIN Pin = PB12 // MISO
SPI0_SCK_PIN Pin = PB11 // SCK
)

// I2C pins
const (
SDA_PIN Pin = PA22 // SDA: Pin 20
SCL_PIN Pin = PA23 // SCL: Pin 21
)

// I2S pins - might not be exposed
const (
I2S_SCK_PIN Pin = PA10
I2S_SDO_PIN Pin = PA07
I2S_SDI_PIN = NoPin
I2S_WS_PIN Pin = PA11
)

// UART pins
const (
UART_RX_PIN Pin = D0
UART_TX_PIN Pin = D1
)

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

// USB CDC identifiers
const (
usb_STRING_PRODUCT = "Arduino M0 Pro"
usb_STRING_MANUFACTURER = "Arduino LLC"

usb_VID uint16 = 0x2A03
usb_PID uint16 = 0x804F
)

// 32.768 KHz Crystal
const (
XIN32 Pin = PA00
XOUT32 Pin = PA01
)
2 changes: 1 addition & 1 deletion src/machine/machine_generic_peripherals.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !baremetal && !arduino_mkr1000 && !arduino_mkrwifi1010 && !arduino_nano33 && !arduino_zero && !circuitplay_express && !feather_m0 && !feather_m4 && !grandcentral_m4 && !itsybitsy_m0 && !itsybitsy_m4 && !matrixportal_m4 && !metro_m4_airlift && !p1am_100 && !pybadge && !pygamer && !pyportal && !qtpy && !trinket_m0 && !wioterminal && !xiao
//go:build !baremetal && !arduino_mkr1000 && !arduino_mkrwifi1010 && !arduino_nano33 && !arduino_zero && !arduino_m0_pro && !circuitplay_express && !feather_m0 && !feather_m4 && !grandcentral_m4 && !itsybitsy_m0 && !itsybitsy_m4 && !matrixportal_m4 && !metro_m4_airlift && !p1am_100 && !pybadge && !pygamer && !pyportal && !qtpy && !trinket_m0 && !wioterminal && !xiao

package machine

Expand Down
7 changes: 7 additions & 0 deletions targets/arduino-m0-pro.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"inherits": ["atsamd21g18au"],
"build-tags": ["arduino_m0_pro"],
"serial-port": ["2A03:004D","2A03:804D","2A03:004F","2A03:804F"],
"flash-command": "avrdude -c stk500v2 -b 57600 -p atmega2560 -P {port} -U flash:w:{hex}:i -v",
"flash-1200-bps-reset": "true"
}
11 changes: 11 additions & 0 deletions targets/atsamd21g18au.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"inherits": ["cortex-m0plus"],
"build-tags": ["atsamd21g18au", "atsamd21g18", "atsamd21", "sam"],
"serial": "usb",
"linkerscript": "targets/atsamd21.ld",
"extra-files": [
"src/device/sam/atsamd21g18au.s"
],
"openocd-transport": "swd",
"openocd-target": "at91samdXX"
}
Loading