diff options
author | BCG <[email protected]> | 2022-02-14 00:13:00 -0500 |
---|---|---|
committer | Ron Evans <[email protected]> | 2022-02-19 11:52:24 +0100 |
commit | 52ffd6aa98ed54ef93e7fd281c38f4c90a798140 (patch) | |
tree | fbe78514dea8f5b55e610d5d17a4c15fbf58b95f | |
parent | 644356c220ed88f110d01300f671a170cd36eb04 (diff) | |
download | tinygo-52ffd6aa98ed54ef93e7fd281c38f4c90a798140.tar.gz tinygo-52ffd6aa98ed54ef93e7fd281c38f4c90a798140.zip |
board: Adafruit MacroPad RP2040
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | src/machine/board_macropad-rp2040.go | 66 | ||||
-rw-r--r-- | src/machine/machine_rp2040_gpio.go | 8 | ||||
-rw-r--r-- | targets/macropad-rp2040.json | 11 |
5 files changed, 89 insertions, 1 deletions
@@ -465,6 +465,8 @@ endif @$(MD5SUM) test.hex $(TINYGO) build -size short -o test.hex -target=feather-rp2040 examples/blinky1 @$(MD5SUM) test.hex + $(TINYGO) build -size short -o test.hex -target=macropad-rp2040 examples/blinky1 + @$(MD5SUM) test.hex # test pwm $(TINYGO) build -size short -o test.hex -target=itsybitsy-m0 examples/pwm @$(MD5SUM) test.hex @@ -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 81 microcontroller boards are currently supported: +The following 82 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) @@ -59,6 +59,7 @@ The following 81 microcontroller boards are currently supported: * [Adafruit ItsyBitsy M0](https://www.adafruit.com/product/3727) * [Adafruit ItsyBitsy M4](https://www.adafruit.com/product/3800) * [Adafruit ItsyBitsy nRF52840](https://www.adafruit.com/product/4481) +* [Adafruit MacroPad RP2040](https://www.adafruit.com/product/5100) * [Adafruit Matrix Portal M4](https://www.adafruit.com/product/4745) * [Adafruit Metro M4 Express Airlift](https://www.adafruit.com/product/4000) * [Adafruit PyBadge](https://www.adafruit.com/product/4200) diff --git a/src/machine/board_macropad-rp2040.go b/src/machine/board_macropad-rp2040.go new file mode 100644 index 000000000..356641eba --- /dev/null +++ b/src/machine/board_macropad-rp2040.go @@ -0,0 +1,66 @@ +//go:build macropad_rp2040 +// +build macropad_rp2040 + +package machine + +const ( + NeopixelCount = 12 + + // Onboard crystal oscillator frequency, in MHz. + xoscFreq = 12 // MHz +) + +const ( + SWITCH = GPIO0 + + KEY1 = GPIO1 + KEY2 = GPIO2 + KEY3 = GPIO3 + KEY4 = GPIO4 + KEY5 = GPIO5 + KEY6 = GPIO6 + KEY7 = GPIO7 + KEY8 = GPIO8 + KEY9 = GPIO9 + KEY10 = GPIO10 + KEY11 = GPIO11 + KEY12 = GPIO12 + + LED = GPIO13 + + SPEAKER_ENABLE = GPIO14 + SPEAKER = GPIO16 + + ROT_A = GPIO18 + ROT_B = GPIO17 + + OLED_CS = GPIO22 + OLED_RST = GPIO23 + OLED_DC = GPIO24 + + NEOPIXEL = GPIO19 + WS2812 = NEOPIXEL +) + +// I2C Default pins on Raspberry Pico. +const ( + I2C0_SDA_PIN = GPIO20 + I2C0_SCL_PIN = GPIO21 + + I2C1_SDA_PIN = 31 // not pinned out + I2C1_SCL_PIN = 31 // not pinned out +) + +// SPI default pins +const ( + // Default Serial Clock Bus 1 for SPI communications + SPI1_SCK_PIN = GPIO26 + // Default Serial Out Bus 1 for SPI communications + SPI1_SDO_PIN = GPIO27 // Tx + // Default Serial In Bus 1 for SPI communications + SPI1_SDI_PIN = GPIO28 // Rx + + SPI0_SCK_PIN = 31 // not pinned out + SPI0_SDO_PIN = 31 // not pinned out + SPI0_SDI_PIN = 31 // not pinned out +) diff --git a/src/machine/machine_rp2040_gpio.go b/src/machine/machine_rp2040_gpio.go index e20a84c69..29909ae76 100644 --- a/src/machine/machine_rp2040_gpio.go +++ b/src/machine/machine_rp2040_gpio.go @@ -88,12 +88,20 @@ const ( PinSPI ) +func (p Pin) PortMaskSet() (*volatile.Register32, uint32) { + return &rp.SIO.GPIO_OUT_SET, 1 << p +} + // set drives the pin high func (p Pin) set() { mask := uint32(1) << p rp.SIO.GPIO_OUT_SET.Set(mask) } +func (p Pin) PortMaskClear() (*volatile.Register32, uint32) { + return &rp.SIO.GPIO_OUT_CLR, 1 << p +} + // clr drives the pin low func (p Pin) clr() { mask := uint32(1) << p diff --git a/targets/macropad-rp2040.json b/targets/macropad-rp2040.json new file mode 100644 index 000000000..556a19c98 --- /dev/null +++ b/targets/macropad-rp2040.json @@ -0,0 +1,11 @@ +{ + "inherits": [ + "rp2040" + ], + "build-tags": ["macropad_rp2040"], + "serial": "none", + "linkerscript": "targets/pico.ld", + "extra-files": [ + "targets/pico-boot-stage2.S" + ] +} |