From ee3a05f1de2cfac22eff91d4bc6651ff43bbc320 Mon Sep 17 00:00:00 2001 From: deadprogram Date: Mon, 13 May 2024 18:41:37 +0200 Subject: [PATCH] targets: add support for Badger2040 W Signed-off-by: deadprogram --- GNUmakefile | 2 + src/machine/board_badger2040-w.go | 95 +++++++++++++++++++++++++++++++ src/machine/board_badger2040.go | 8 ++- targets/badger2040-w.json | 13 +++++ 4 files changed, 116 insertions(+), 2 deletions(-) create mode 100644 src/machine/board_badger2040-w.go create mode 100644 targets/badger2040-w.json diff --git a/GNUmakefile b/GNUmakefile index cbc18c14..5454896b 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -659,6 +659,8 @@ endif @$(MD5SUM) test.hex $(TINYGO) build -size short -o test.hex -target=badger2040 examples/blinky1 @$(MD5SUM) test.hex + $(TINYGO) build -size short -o test.hex -target=badger2040-w examples/blinky1 + @$(MD5SUM) test.hex $(TINYGO) build -size short -o test.hex -target=tufty2040 examples/blinky1 @$(MD5SUM) test.hex $(TINYGO) build -size short -o test.hex -target=thingplus-rp2040 examples/blinky1 diff --git a/src/machine/board_badger2040-w.go b/src/machine/board_badger2040-w.go new file mode 100644 index 00000000..d0982653 --- /dev/null +++ b/src/machine/board_badger2040-w.go @@ -0,0 +1,95 @@ +//go:build badger2040_w + +// This contains the pin mappings for the Badger 2040 W board. +// +// For more information, see: https://shop.pimoroni.com/products/badger-2040-w +// Also +// - Badger 2040 W schematic: https://cdn.shopify.com/s/files/1/0174/1800/files/badger_w_schematic.pdf?v=1675859004 +package machine + +const ( + LED Pin = GPIO22 + + BUTTON_A Pin = GPIO12 + BUTTON_B Pin = GPIO13 + BUTTON_C Pin = GPIO14 + BUTTON_UP Pin = GPIO15 + BUTTON_DOWN Pin = GPIO11 + BUTTON_USER Pin = NoPin // Not available on Badger 2040 W + + 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 + VREF_POWER Pin = GPIO27 + VREF_1V24 Pin = GPIO28 + VBAT_SENSE Pin = GPIO29 + ENABLE_3V3 Pin = GPIO10 + + BATTERY = VBAT_SENSE + RTC_ALARM = GPIO8 +) + +// 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 W" + usb_STRING_MANUFACTURER = "Pimoroni" +) + +var ( + usb_VID uint16 = 0x2e8a + usb_PID uint16 = 0x0003 +) + +// UART pins +const ( + UART0_TX_PIN = GPIO0 + UART0_RX_PIN = GPIO1 + UART_TX_PIN = UART0_TX_PIN + UART_RX_PIN = UART0_RX_PIN +) + +var DefaultUART = UART0 diff --git a/src/machine/board_badger2040.go b/src/machine/board_badger2040.go index 049e3cb8..73f802a9 100644 --- a/src/machine/board_badger2040.go +++ b/src/machine/board_badger2040.go @@ -1,6 +1,6 @@ //go:build badger2040 -// This contains the pin mappings for the Badger 2040 Connect board. +// This contains the pin mappings for the Badger 2040 board. // // For more information, see: https://shop.pimoroni.com/products/badger-2040 // Also @@ -25,8 +25,12 @@ const ( EPD_SDO_PIN Pin = GPIO19 VBUS_DETECT Pin = GPIO24 - BATTERY Pin = GPIO29 + VREF_POWER Pin = GPIO27 + VREF_1V24 Pin = GPIO28 + VBAT_SENSE Pin = GPIO29 ENABLE_3V3 Pin = GPIO10 + + BATTERY = VBAT_SENSE ) // I2C pins diff --git a/targets/badger2040-w.json b/targets/badger2040-w.json new file mode 100644 index 00000000..4b29dc85 --- /dev/null +++ b/targets/badger2040-w.json @@ -0,0 +1,13 @@ +{ + "inherits": [ + "rp2040" + ], + "serial-port": ["2e8a:0003"], + "build-tags": ["badger2040_w"], + "ldflags": [ + "--defsym=__flash_size=1020K" + ], + "extra-files": [ + "targets/pico-boot-stage2.S" + ] +}