Skip to content

Commit

Permalink
Added Adafruit's pybadge target (tinygo-org#795)
Browse files Browse the repository at this point in the history
* machine/pybadge: add support for Adafruit PyBadge board
  • Loading branch information
conejoninja authored and deadprogram committed Dec 22, 2019
1 parent d41f01f commit c2481b1
Show file tree
Hide file tree
Showing 4 changed files with 161 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ smoketest:
@$(MD5SUM) test.hex
$(TINYGO) build -size short -o test.hex -target=feather-m4 examples/blinky1
@$(MD5SUM) test.hex
$(TINYGO) build -size short -o test.hex -target=pybadge examples/blinky1
@$(MD5SUM) test.hex
$(TINYGO) build -size short -o test.hex -target=metro-m4-airlift examples/blinky1
@$(MD5SUM) test.hex
$(TINYGO) build -size short -o test.hex -target=nucleo-f103rb examples/blinky1
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ The following 22 microcontroller boards are currently supported:
* [Adafruit ItsyBitsy M0](https://www.adafruit.com/product/3727)
* [Adafruit ItsyBitsy M4](https://www.adafruit.com/product/3800)
* [Adafruit Metro M4 Express Airlift](https://www.adafruit.com/product/4000)
* [Adafruit PyBadge](https://www.adafruit.com/product/4200)
* [Adafruit Trinket M0](https://www.adafruit.com/product/3500)
* [Arduino Nano33 IoT](https://store.arduino.cc/nano-33-iot)
* [Arduino Uno](https://store.arduino.cc/arduino-uno-rev3)
Expand Down
150 changes: 150 additions & 0 deletions src/machine/board_pybadge.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
// +build sam,atsamd51,pybadge

package machine

import "device/sam"

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

// GPIO Pins
const (
D0 = PB17 // UART0 RX/PWM available
D1 = PB16 // UART0 TX/PWM available
D2 = PB03
D3 = PB02
D4 = PA14 // PWM available
D5 = PA16 // PWM available
D6 = PA18 // PWM available
D7 = PB14
D8 = PA15 // built-in neopixel
D9 = PA19 // PWM available
D10 = PA20 // can be used for PWM or UART1 TX
D11 = PA21 // can be used for PWM or UART1 RX
D12 = PA22 // PWM available
D13 = PA23 // PWM available
)

// Analog pins
const (
A0 = PA02 // ADC/AIN[0]
A1 = PA05 // ADC/AIN[2]
A2 = PB08 // ADC/AIN[3]
A3 = PB09 // ADC/AIN[4]
A4 = PA04 // ADC/AIN[5]
A5 = PA06 // ADC/AIN[6]
A6 = PB01 // ADC/AIN[12]/VMEAS
A7 = PB04 // ADC/AIN[6]/LIGHT
A8 = D2 // ADC/AIN[14]
A9 = D3 // ADC/AIN[15]
)

const (
LED = D13
NEOPIXELS = D8

LIGHTSENSOR = A7

BUTTON_LATCH = PB00
BUTTON_OUT = PB30
BUTTON_CLK = PB31

TFT_DC = PB05
TFT_CS = PB07
TFT_RST = PA00
TFT_LITE = PA01

SPEAKER_ENABLE = PA27

QSPI_SCK = PB10
QSPI_CS = PB11
QSPI_DATA_1 = PA08
QSPI_DATA_2 = PA09
QSPI_DATA_3 = PA10
QSPI_DATA_4 = PA11
)

const (
BUTTON_LEFT_MASK = 1
BUTTON_UP_MASK = 2
BUTTON_DOWN_MASK = 4
BUTTON_RIGHT_MASK = 8
BUTTON_SELECT_MASK = 16
BUTTON_START_MASK = 32
BUTTON_A_MASK = 64
BUTTON_B_MASK = 128
)

// UART0 aka USBCDC pins
const (
USBCDC_DM_PIN = PA24
USBCDC_DP_PIN = PA25
)

// UART1 pins
const (
UART_TX_PIN = D1
UART_RX_PIN = D0
)

// UART1 var is on SERCOM3, defined in atsamd51.go

// UART2 pins
const (
UART2_TX_PIN = A4
UART2_RX_PIN = A5
)

// UART2 var is on SERCOM0, defined in atsamd51.go

// I2C pins
const (
SDA_PIN = PA12 // SDA: SERCOM2/PAD[0]
SCL_PIN = PA13 // SCL: SERCOM2/PAD[1]
)

// I2C on the ItsyBitsy M4.
var (
I2C0 = I2C{Bus: sam.SERCOM2_I2CM,
SDA: SDA_PIN,
SCL: SCL_PIN,
PinMode: PinSERCOM}
)

// SPI pins
const (
SPI0_SCK_PIN = PA17 // SCK: SERCOM1/PAD[1]
SPI0_MOSI_PIN = PB23 // MOSI: SERCOM1/PAD[3]
SPI0_MISO_PIN = PB22 // MISO: SERCOM1/PAD[2]
)

// SPI on the PyBadge.
var (
SPI0 = SPI{Bus: sam.SERCOM1_SPIM,
SCK: SPI0_SCK_PIN,
MOSI: SPI0_MOSI_PIN,
MISO: SPI0_MISO_PIN,
DOpad: spiTXPad3SCK1,
DIpad: sercomRXPad2,
MISOPinMode: PinSERCOM,
MOSIPinMode: PinSERCOM,
SCKPinMode: PinSERCOM,
}
)

// TFT SPI pins
const (
SPI1_SCK_PIN = PB13 // SCK: SERCOM4/PAD[1]
SPI1_MOSI_PIN = PB15 // MOSI: SERCOM4/PAD[3]
)

// TFT SPI on the PyBadge.
var (
SPI1 = SPI{Bus: sam.SERCOM4_SPIM,
SCK: SPI1_SCK_PIN,
MOSI: SPI1_MOSI_PIN,
DOpad: spiTXPad3SCK1,
MOSIPinMode: PinSERCOM,
SCKPinMode: PinSERCOM,
}
)
8 changes: 8 additions & 0 deletions targets/pybadge.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"inherits": ["atsamd51j19a"],
"build-tags": ["sam", "atsamd51j19a", "pybadge"],
"flash-1200-bps-reset": "true",
"flash-method": "msd",
"msd-volume-name": "PYBADGEBOOT",
"msd-firmware-name": "arcade.uf2"
}

0 comments on commit c2481b1

Please sign in to comment.