From e7849b6c18410e44d8645f30d59e917d39ae9003 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Thu, 19 Sep 2024 20:28:56 +0100 Subject: [PATCH] Plasma2350: Prep wireless-enabled variant. --- .github/workflows/micropython.yml | 3 + .../PIMORONI_PLASMA2350/manifest-wireless.py | 6 + .../board/PIMORONI_PLASMA2350/mpconfigboard.h | 20 ++- .../mpconfigvariant_WIRELESS.cmake | 44 ++++++ .../pimoroni_plasma2350w.h | 137 ++++++++++++++++++ 5 files changed, 209 insertions(+), 1 deletion(-) create mode 100644 micropython/board/PIMORONI_PLASMA2350/manifest-wireless.py create mode 100644 micropython/board/PIMORONI_PLASMA2350/mpconfigvariant_WIRELESS.cmake create mode 100644 micropython/board/PIMORONI_PLASMA2350/pimoroni_plasma2350w.h diff --git a/.github/workflows/micropython.yml b/.github/workflows/micropython.yml index 1261337..59e3e6a 100644 --- a/.github/workflows/micropython.yml +++ b/.github/workflows/micropython.yml @@ -25,6 +25,9 @@ jobs: board: RPI_PICO2B - name: plasma2350 board: PIMORONI_PLASMA2350 + - name: plasma2350-wireless + board: PIMORONI_PLASMA2350 + variant: WIRELESS - name: tiny2350 board: PIMORONI_TINY2350 - name: pico_plus2_rp2350_psram diff --git a/micropython/board/PIMORONI_PLASMA2350/manifest-wireless.py b/micropython/board/PIMORONI_PLASMA2350/manifest-wireless.py new file mode 100644 index 0000000..4efb87f --- /dev/null +++ b/micropython/board/PIMORONI_PLASMA2350/manifest-wireless.py @@ -0,0 +1,6 @@ +require("bundle-networking") + +# Bluetooth +require("aioble") + +include("manifest.py") \ No newline at end of file diff --git a/micropython/board/PIMORONI_PLASMA2350/mpconfigboard.h b/micropython/board/PIMORONI_PLASMA2350/mpconfigboard.h index 9aed816..c474542 100644 --- a/micropython/board/PIMORONI_PLASMA2350/mpconfigboard.h +++ b/micropython/board/PIMORONI_PLASMA2350/mpconfigboard.h @@ -1,7 +1,25 @@ // Board and hardware specific configuration +#ifndef MICROPY_HW_BOARD_NAME #define MICROPY_HW_BOARD_NAME "Pimoroni Plasma 2350" +#endif #define MICROPY_HW_FLASH_STORAGE_BYTES (PICO_FLASH_SIZE_BYTES - (2 * 1024 * 1024)) // I2C0 (non-default) #define MICROPY_HW_I2C0_SCL (PLASMA2350_SDA_PIN) -#define MICROPY_HW_I2C0_SDA (PLASMA2350_SCL_PIN) \ No newline at end of file +#define MICROPY_HW_I2C0_SDA (PLASMA2350_SCL_PIN) + +// Set up networking. + +#if defined(MICROPY_PY_NETWORK_CYW43) + +#define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "Plasma2350" + +// CYW43 driver configuration. +#define CYW43_USE_SPI (1) +#define CYW43_LWIP (1) +#define CYW43_GPIO (1) +#define CYW43_SPI_PIO (1) + +#define MICROPY_HW_PIN_EXT_COUNT CYW43_WL_GPIO_COUNT + +#endif \ No newline at end of file diff --git a/micropython/board/PIMORONI_PLASMA2350/mpconfigvariant_WIRELESS.cmake b/micropython/board/PIMORONI_PLASMA2350/mpconfigvariant_WIRELESS.cmake new file mode 100644 index 0000000..5a5d3fb --- /dev/null +++ b/micropython/board/PIMORONI_PLASMA2350/mpconfigvariant_WIRELESS.cmake @@ -0,0 +1,44 @@ +# Override the MicroPython board name +# And set basic options which are expanded upon in mpconfigboard.h +list(APPEND MICROPY_DEF_BOARD + "MICROPY_HW_BOARD_NAME=\"Pimoroni Plasma 2350 (Wireless)\"" + "MICROPY_PY_NETWORK=1" +) + +# Board and platform +set(PICO_BOARD "pimoroni_plasma2350w") +set(PICO_PLATFORM "rp2350") + +# Links micropy_lib_lwip and sets MICROPY_PY_LWIP = 1 +# Picked up and expanded upon in mpconfigboard.h +set(MICROPY_PY_LWIP ON) + +# Links cyw43-driver and sets: +# MICROPY_PY_NETWORK_CYW43 = 1, +# MICROPY_PY_SOCKET_DEFAULT_TIMEOUT_MS = 30000 +set(MICROPY_PY_NETWORK_CYW43 ON) + +# Adds mpbthciport.c +# And sets: +# MICROPY_PY_BLUETOOTH = 1, +# MICROPY_PY_BLUETOOTH_USE_SYNC_EVENTS = 1, +# MICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE = 1 +set(MICROPY_PY_BLUETOOTH ON) + +# Links pico_btstack_hci_transport_cyw43 +# And sets: +# MICROPY_BLUETOOTH_BTSTACK = 1, +# MICROPY_BLUETOOTH_BTSTACK_CONFIG_FILE = +set(MICROPY_BLUETOOTH_BTSTACK ON) + +# Sets: +# CYW43_ENABLE_BLUETOOTH = 1, +# MICROPY_PY_BLUETOOTH_CYW43 = 1 +set(MICROPY_PY_BLUETOOTH_CYW43 ON) + +# Board specific version of the frozen manifest +set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest-wireless.py) + +set(MICROPY_C_HEAP_SIZE 4096) + +set(PICO_BOARD_HEADER_DIRS ${CMAKE_CURRENT_LIST_DIR}) \ No newline at end of file diff --git a/micropython/board/PIMORONI_PLASMA2350/pimoroni_plasma2350w.h b/micropython/board/PIMORONI_PLASMA2350/pimoroni_plasma2350w.h new file mode 100644 index 0000000..9e4d7a3 --- /dev/null +++ b/micropython/board/PIMORONI_PLASMA2350/pimoroni_plasma2350w.h @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +// ----------------------------------------------------- +// NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO +// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES +// ----------------------------------------------------- + +// This header may be included by other board headers as "boards/pimoroni_plasma2350w.h" + +// pico_cmake_set PICO_PLATFORM=rp2350 + +#ifndef _BOARDS_PIMORONI_PLASMA2350W_H +#define _BOARDS_PIMORONI_PLASMA2350W_H + +// For board detection +#define PIMORONI_PLASMA2350 +#define PIMORONI_PLASMA2350W + +// --- BOARD SPECIFIC --- +#define SPICE_SPI 0 +#define SPICE_TX_MISO_PIN 8 +#define SPICE_RX_CS_PIN 9 +#define SPICE_NETLIGHT_SCK_PIN 10 +#define SPICE_RESET_MOSI_PIN 11 +#define SPICE_PWRKEY_BL_PIN 7 + +#define PLASMA2350_SW_A_PIN 12 + +#define PLASMA2350_CLK_PIN 14 +#define PLASMA2350_DATA_PIN 15 + +#define PLASMA2350_LED_R_PIN 16 +#define PLASMA2350_LED_G_PIN 17 +#define PLASMA2350_LED_B_PIN 18 + +#define PLASMA2350_I2C 0 +#define PLASMA2350_INT_PIN 19 +#define PLASMA2350_SDA_PIN 20 +#define PLASMA2350_SCL_PIN 21 + +#define PLASMA2350_USER_SW_PIN 22 + +#define PLASMA2350_A0_PIN 26 +#define PLASMA2350_A1_PIN 27 +#define PLASMA2350_A2_PIN 28 +#define PLASMA2350_NUM_ADC_PINS 3 + +#define PLASMA2350_CURRENT_SENSE_PIN 29 + +// --- RP2350 VARIANT --- +#define PICO_RP2350A 1 + +// -- CYW43 Wireless -- +#ifndef CYW43_PIN_WL_HOST_WAKE +#define CYW43_PIN_WL_HOST_WAKE 24 +#endif + +#ifndef CYW43_PIN_WL_REG_ON +#define CYW43_PIN_WL_REG_ON 23 +#endif + +#ifndef CYW43_WL_GPIO_COUNT +#define CYW43_WL_GPIO_COUNT 3 +#endif + +#ifndef CYW43_WL_GPIO_LED_PIN +#define CYW43_WL_GPIO_LED_PIN 0 +#endif + +// --- UART --- +// no PICO_DEFAULT_UART +// no PICO_DEFAULT_UART_TX_PIN +// no PICO_DEFAULT_UART_RX_PIN + +// --- LED --- +#ifndef PICO_DEFAULT_LED_PIN +#define PICO_DEFAULT_LED_PIN TINY2350_LED_G_PIN +#endif +// no PICO_DEFAULT_WS2812_PIN + +#ifndef PICO_DEFAULT_LED_PIN_INVERTED +#define PICO_DEFAULT_LED_PIN_INVERTED 1 +#endif + +// --- I2C --- +// routed to Qw/St connector +#ifndef PICO_DEFAULT_I2C +#define PICO_DEFAULT_I2C PLASMA2350_I2C +#endif +#ifndef PICO_DEFAULT_I2C_SDA_PIN +#define PICO_DEFAULT_I2C_SDA_PIN PLASMA2350_SDA_PIN +#endif +#ifndef PICO_DEFAULT_I2C_SCL_PIN +#define PICO_DEFAULT_I2C_SCL_PIN PLASMA2350_SCL_PIN +#endif + +// --- SPI --- +#ifndef PICO_DEFAULT_SPI +#define PICO_DEFAULT_SPI 0 +#endif +#ifndef PICO_DEFAULT_SPI_SCK_PIN +#define PICO_DEFAULT_SPI_SCK_PIN SPICE_NETLIGHT_SCK_PIN +#endif +#ifndef PICO_DEFAULT_SPI_TX_PIN +#define PICO_DEFAULT_SPI_TX_PIN SPICE_RESET_MOSI_PIN +#endif +#ifndef PICO_DEFAULT_SPI_RX_PIN +#define PICO_DEFAULT_SPI_RX_PIN SPICE_TX_MISO_PIN +#endif +#ifndef PICO_DEFAULT_SPI_CSN_PIN +#define PICO_DEFAULT_SPI_CSN_PIN SPICE_RX_CS_PIN +#endif + +// --- FLASH --- +#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1 + +#ifndef PICO_FLASH_SPI_CLKDIV +#define PICO_FLASH_SPI_CLKDIV 2 +#endif + +// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (8 * 1024 * 1024) +#ifndef PICO_FLASH_SIZE_BYTES +#define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024) +#endif + +#ifndef PICO_RP2350_A2_SUPPORTED +#define PICO_RP2350_A2_SUPPORTED 1 +#endif + +// no PICO_VBUS_PIN +// no PICO_VSYS_PIN + +#endif \ No newline at end of file