From f308d7d28ca8d1d06a9cdca928f06086dfd4e26c Mon Sep 17 00:00:00 2001 From: deadprogram Date: Fri, 20 May 2022 10:56:40 +0200 Subject: [PATCH] machine/badger2040: support for Badger 2040 Signed-off-by: deadprogram --- src/machine/board_badger2040.go | 81 +++++++++++++++++++++++++++++++++ targets/badger2040.json | 11 +++++ targets/badger2040.ld | 10 ++++ 3 files changed, 102 insertions(+) create mode 100644 src/machine/board_badger2040.go create mode 100644 targets/badger2040.json create mode 100644 targets/badger2040.ld diff --git a/src/machine/board_badger2040.go b/src/machine/board_badger2040.go new file mode 100644 index 00000000..d2b41122 --- /dev/null +++ b/src/machine/board_badger2040.go @@ -0,0 +1,81 @@ +//go:build badger2040 +// +build badger2040 + +// This contains the pin mappings for the Badger 2040 Connect board. +// +// For more information, see: https://shop.pimoroni.com/products/badger-2040 +// Also +// - Badger 2040 schematic: https://cdn.shopify.com/s/files/1/0174/1800/files/badger_2040_schematic.pdf?v=1645702148 +// +package machine + +const ( + LED Pin = GPIO25 + + BUTTON_A Pin = GPIO12 + BUTTON_B Pin = GPIO13 + BUTTON_C Pin = GPIO14 + BUTTON_UP Pin = GPIO15 + BUTTON_DOWN Pin = GPIO11 + BUTTON_USER Pin = GPIO23 + + EPD_BUSY_PIN Pin = GPIO26 + EPD_RESET_PIN Pin = GPIO21 + EPD_DC_PIN Pin = GPIO20 + EPD_CS_PIN Pin = GPIO17 + EPD_SCK_PIN Pin = GPIO18 + EPD_SDO_PIN Pin = GPIO19 + + VBUS_DETECT Pin = GPIO24 + BATTERY Pin = GPIO29 + ENABLE_3V3 Pin = GPIO10 +) + +// I2C pins +const ( + I2C0_SDA_PIN Pin = GPIO4 + I2C0_SCL_PIN Pin = GPIO5 + + I2C1_SDA_PIN Pin = NoPin + I2C1_SCL_PIN Pin = NoPin +) + +// SPI pins. +const ( + SPI0_SCK_PIN Pin = GPIO18 + SPI0_SDO_PIN Pin = GPIO19 + SPI0_SDI_PIN Pin = GPIO16 + + SPI1_SCK_PIN Pin = NoPin + SPI1_SDO_PIN Pin = NoPin + SPI1_SDI_PIN Pin = NoPin +) + +// QSPI pins¿? +const ( +/* TODO +SPI0_SD0_PIN Pin = QSPI_SD0 +SPI0_SD1_PIN Pin = QSPI_SD1 +SPI0_SD2_PIN Pin = QSPI_SD2 +SPI0_SD3_PIN Pin = QSPI_SD3 +SPI0_SCK_PIN Pin = QSPI_SCLKGPIO6 +SPI0_CS_PIN Pin = QSPI_CS + +*/ +) + +// Onboard crystal oscillator frequency, in MHz. +const ( + xoscFreq = 12 // MHz +) + +// USB CDC identifiers +const ( + usb_STRING_PRODUCT = "Badger 2040" + usb_STRING_MANUFACTURER = "Pimoroni" +) + +var ( + usb_VID uint16 = 0x2e8a + usb_PID uint16 = 0x0003 +) diff --git a/targets/badger2040.json b/targets/badger2040.json new file mode 100644 index 00000000..340a8b5b --- /dev/null +++ b/targets/badger2040.json @@ -0,0 +1,11 @@ +{ + "inherits": [ + "rp2040" + ], + "serial": "uart", + "build-tags": ["badger2040"], + "linkerscript": "targets/badger2040.ld", + "extra-files": [ + "targets/pico-boot-stage2.S" + ] +} diff --git a/targets/badger2040.ld b/targets/badger2040.ld new file mode 100644 index 00000000..7e06d7a0 --- /dev/null +++ b/targets/badger2040.ld @@ -0,0 +1,10 @@ + +MEMORY +{ + /* Reserve exactly 256 bytes at start of flash for second stage bootloader */ + BOOT2_TEXT (rx) : ORIGIN = 0x10000000, LENGTH = 256 + FLASH_TEXT (rx) : ORIGIN = 0x10000000 + 256, LENGTH = 1020K - 256 + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 256k +} + +INCLUDE "targets/rp2040.ld"