From 544f1cae8cba95eb4fdc1c946c184d59f676c439 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Tue, 17 Sep 2024 13:26:39 +0100 Subject: [PATCH] PPP: Add CYW43 wireless. If we're bringing in lwip and networking, this variant might as well support CYW43. --- .github/workflows/micropython.yml | 4 +-- .../{manifest-ppp.py => manifest-wireless.py} | 3 ++ .../board/PIMORONI_PICO_PLUS2/mpconfigboard.h | 34 ++++++++++++++---- .../mpconfigvariant_PPP.cmake | 11 ------ .../mpconfigvariant_PSRAM.cmake | 4 +-- .../mpconfigvariant_WIRELESS.cmake | 36 +++++++++++++++++++ .../board/PIMORONI_PICO_PLUS2/pins.csv | 7 +++- 7 files changed, 76 insertions(+), 23 deletions(-) rename micropython/board/PIMORONI_PICO_PLUS2/{manifest-ppp.py => manifest-wireless.py} (76%) delete mode 100644 micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_PPP.cmake create mode 100644 micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_WIRELESS.cmake diff --git a/.github/workflows/micropython.yml b/.github/workflows/micropython.yml index 338e88e..597a27d 100644 --- a/.github/workflows/micropython.yml +++ b/.github/workflows/micropython.yml @@ -30,9 +30,9 @@ jobs: - name: pico_plus2_rp2350_psram board: PIMORONI_PICO_PLUS2 variant: PSRAM - - name: pico_plus2_rp2350_psram_n_ppp + - name: pico_plus2_rp2350_wireless board: PIMORONI_PICO_PLUS2 - variant: PPP + variant: WIRELESS - name: pico_plus2_rp2350 board: PIMORONI_PICO_PLUS2 diff --git a/micropython/board/PIMORONI_PICO_PLUS2/manifest-ppp.py b/micropython/board/PIMORONI_PICO_PLUS2/manifest-wireless.py similarity index 76% rename from micropython/board/PIMORONI_PICO_PLUS2/manifest-ppp.py rename to micropython/board/PIMORONI_PICO_PLUS2/manifest-wireless.py index f42cb18..b34f473 100644 --- a/micropython/board/PIMORONI_PICO_PLUS2/manifest-ppp.py +++ b/micropython/board/PIMORONI_PICO_PLUS2/manifest-wireless.py @@ -1,5 +1,8 @@ require("bundle-networking") +# Bluetooth +require("aioble") + include("manifest.py") freeze("$(BOARD_DIR)/../../modules_py", "lte.py") \ No newline at end of file diff --git a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigboard.h b/micropython/board/PIMORONI_PICO_PLUS2/mpconfigboard.h index 888f298..3f9dd70 100644 --- a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigboard.h +++ b/micropython/board/PIMORONI_PICO_PLUS2/mpconfigboard.h @@ -7,19 +7,39 @@ #define MICROPY_HW_PSRAM_CS_PIN PIMORONI_PICO_PLUS2_PSRAM_CS_PIN -#ifdef PPP_ENABLE_PPP +// Might be defined in mpconfigvariant_PSRAM.cmake +// or mpconfigvariant_PPP.cmake +#if defined(MICROPY_HW_ENABLE_PSRAM) -// Enable networking. -#define MICROPY_PY_NETWORK 1 -#define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "Pico" +#define MICROPY_GC_SPLIT_HEAP (1) -#define MICROPY_PY_NETWORK_PPP_LWIP 1 +#endif -#define MICROPY_HW_NIC_PPP { MP_ROM_QSTR(MP_QSTR_PINT), MP_ROM_PTR(&mp_network_ppp_lwip_type) }, +// Set up networking. +#define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "PPP2" + +#if defined(MICROPY_PY_NETWORK_CYW43) + +// 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 + +// Might be defined in mpconfigvariant_PPP.cmake +// This is not checked by mpconfigport.h so we must set up networking below +#if defined(MICROPY_PY_NETWORK_PPP_LWIP) + +// TODO: This should be upstreamed to mpconfigport.h +#define MICROPY_HW_NIC_PPP { MP_ROM_QSTR(MP_QSTR_PPP), MP_ROM_PTR(&mp_network_ppp_lwip_type) }, #define MICROPY_BOARD_NETWORK_INTERFACES \ MICROPY_HW_NIC_PPP -#define MICROPY_PY_SOCKET_EXTENDED_STATE 1 +#define MICROPY_PY_SOCKET_EXTENDED_STATE (1) #endif \ No newline at end of file diff --git a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_PPP.cmake b/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_PPP.cmake deleted file mode 100644 index 5df8094..0000000 --- a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_PPP.cmake +++ /dev/null @@ -1,11 +0,0 @@ -# Override the MicroPython board name -list(APPEND MICROPY_DEF_BOARD - "MICROPY_HW_ENABLE_PSRAM=1" - "MICROPY_GC_SPLIT_HEAP=1" - "MICROPY_HW_BOARD_NAME=\"Pimoroni Pico Plus 2 (LTE + PSRAM)\"" - "PPP_ENABLE_PPP=1" -) - -set(MICROPY_PY_LWIP ON) - -set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest-ppp.py) diff --git a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_PSRAM.cmake b/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_PSRAM.cmake index cb27d72..eedd565 100644 --- a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_PSRAM.cmake +++ b/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_PSRAM.cmake @@ -1,6 +1,6 @@ # Override the MicroPython board name +# And set basic options which are expanded upon in mpconfigboard.h list(APPEND MICROPY_DEF_BOARD - "MICROPY_HW_ENABLE_PSRAM=1" - "MICROPY_GC_SPLIT_HEAP=1" "MICROPY_HW_BOARD_NAME=\"Pimoroni Pico Plus 2 (PSRAM)\"" + "MICROPY_HW_ENABLE_PSRAM=1" ) diff --git a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_WIRELESS.cmake b/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_WIRELESS.cmake new file mode 100644 index 0000000..d75423f --- /dev/null +++ b/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_WIRELESS.cmake @@ -0,0 +1,36 @@ +# 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 Pico Plus 2 (Wireless + PSRAM)\"" + "MICROPY_HW_ENABLE_PSRAM=1" + "MICROPY_PY_NETWORK=1" +) + +# 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) + +set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest-wireless.py) diff --git a/micropython/board/PIMORONI_PICO_PLUS2/pins.csv b/micropython/board/PIMORONI_PICO_PLUS2/pins.csv index 9d58ee8..2f11f26 100644 --- a/micropython/board/PIMORONI_PICO_PLUS2/pins.csv +++ b/micropython/board/PIMORONI_PICO_PLUS2/pins.csv @@ -44,4 +44,9 @@ GP44,GPIO44 GP45,GPIO45 GP46,GPIO46 GP47,GPIO47 -LED,GPIO25 \ No newline at end of file +LED,GPIO25 +SPICE_TX,GPIO32 +SPICE_RX,GPIO33 +SPICE_NETLIGHT,GPIO34 +SPICE_RESET,GPIO35 +SPICE_PWRKEY,GPIO36 \ No newline at end of file