Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
edccf66ec4 | ||
|
|
5ca62f6cc4 | ||
|
|
1d4ffe1374 | ||
|
|
bfcb181cdf | ||
|
|
6c6a839903 | ||
|
|
bddaf2af3b | ||
|
|
07b896d425 | ||
|
|
667af8be45 | ||
|
|
4ad2b20fd0 | ||
|
|
7b2f6e92ad | ||
|
|
77a97cf590 | ||
|
|
a5abc5bbfe | ||
|
|
4c2416715b | ||
|
|
af97500976 | ||
|
|
e0d5daee47 | ||
|
|
a9107a5ca8 | ||
|
|
c29c98b2b1 | ||
|
|
544f1cae8c | ||
|
|
fd7621fdcb | ||
|
|
e5515981ea | ||
|
|
ac34474435 |
15
.github/workflows/micropython.yml
vendored
15
.github/workflows/micropython.yml
vendored
@ -7,9 +7,9 @@ on:
|
||||
types: [created]
|
||||
|
||||
env:
|
||||
MICROPYTHON_VERSION: feature/psram
|
||||
MICROPYTHON_VERSION: feature/psram-and-wifi
|
||||
MICROPYTHON_FLAVOUR: pimoroni
|
||||
PIMORONI_PICO_VERSION: feature/sdk-2.0.0
|
||||
PIMORONI_PICO_VERSION: main
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@ -21,15 +21,24 @@ jobs:
|
||||
include:
|
||||
- name: pico2_rp2350
|
||||
board: RPI_PICO2
|
||||
- name: pico2_rp2350_wireless
|
||||
board: RPI_PICO2
|
||||
variant: WIRELESS
|
||||
- name: pico2b_rp2350
|
||||
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
|
||||
board: PIMORONI_PICO_PLUS2
|
||||
variant: PSRAM
|
||||
- name: pico_plus2_rp2350_wireless
|
||||
board: PIMORONI_PICO_PLUS2
|
||||
variant: WIRELESS
|
||||
- name: pico_plus2_rp2350
|
||||
board: PIMORONI_PICO_PLUS2
|
||||
|
||||
@ -70,7 +79,7 @@ jobs:
|
||||
- name: Install Arm GNU Toolchain (arm-none-eabi-gcc)
|
||||
uses: carlosperate/arm-none-eabi-gcc-action@v1
|
||||
with:
|
||||
release: '9-2020-q2'
|
||||
release: '13.3.Rel1'
|
||||
|
||||
- name: Install CCache
|
||||
run: |
|
||||
|
||||
@ -0,0 +1,8 @@
|
||||
require("bundle-networking")
|
||||
|
||||
# Bluetooth
|
||||
require("aioble")
|
||||
|
||||
include("manifest.py")
|
||||
|
||||
freeze("$(BOARD_DIR)/../../modules_py", "lte.py")
|
||||
@ -1,8 +1,79 @@
|
||||
// Board and hardware specific configuration
|
||||
#ifndef MICROPY_HW_BOARD_NAME
|
||||
// Might be defined by mpconfigvariant.cmake
|
||||
#define MICROPY_HW_BOARD_NAME "Pimoroni Pico Plus 2"
|
||||
#endif
|
||||
#define MICROPY_HW_FLASH_STORAGE_BYTES (PICO_FLASH_SIZE_BYTES - (2 * 1024 * 1024))
|
||||
|
||||
#define MICROPY_HW_PSRAM_CS_PIN PIMORONI_PICO_PLUS2_PSRAM_CS_PIN
|
||||
|
||||
#ifndef CYW43_WL_GPIO_COUNT
|
||||
// Effecively remaps LEDW,EXT_GPIO0 to GPIO25 on non-W builds
|
||||
#define pin_EXT_GPIO0 pin_GPIO25
|
||||
// Shim the EXT GPIOs because we can't specify a variant pins.csv
|
||||
#define pin_EXT_GPIO1 pin_GPIO1
|
||||
#define pin_EXT_GPIO2 pin_GPIO2
|
||||
#endif
|
||||
|
||||
// Might be defined in mpconfigvariant_PSRAM.cmake
|
||||
// or mpconfigvariant_WIRELESS.cmake
|
||||
#if defined(MICROPY_HW_ENABLE_PSRAM)
|
||||
|
||||
#define MICROPY_GC_SPLIT_HEAP (1)
|
||||
|
||||
#endif
|
||||
|
||||
// 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
|
||||
|
||||
#if defined(CYW43_PIN_WL_DYNAMIC)
|
||||
|
||||
#define CYW43_PIO_CLOCK_DIV_DYNAMIC (1)
|
||||
|
||||
// Defined by pimoroni_pico_plus2w_rp2350.h
|
||||
//#define CYW43_DEFAULT_PIN_WL_HOST_WAKE SPICE_RESET_MOSI_PIN
|
||||
//#define CYW43_DEFAULT_PIN_WL_REG_ON SPICE_TX_MISO_PIN
|
||||
#define CYW43_DEFAULT_PIN_WL_DATA_OUT CYW43_DEFAULT_PIN_WL_HOST_WAKE
|
||||
#define CYW43_DEFAULT_PIN_WL_DATA_IN CYW43_DEFAULT_PIN_WL_HOST_WAKE
|
||||
#define CYW43_DEFAULT_PIN_WL_CLOCK 29u
|
||||
#define CYW43_DEFAULT_PIN_WL_CS 25u
|
||||
|
||||
/* SPICE alternative
|
||||
#define CYW43_DEFAULT_PIN_WL_HOST_WAKE SPICE_RESET_MOSI_PIN
|
||||
#define CYW43_DEFAULT_PIN_WL_REG_ON SPICE_TX_MISO_PIN
|
||||
#define CYW43_DEFAULT_PIN_WL_DATA_OUT SPICE_RESET_MOSI_PIN
|
||||
#define CYW43_DEFAULT_PIN_WL_DATA_IN SPICE_RESET_MOSI_PIN
|
||||
#define CYW43_DEFAULT_PIN_WL_CLOCK SPICE_NETLIGHT_SCK_PIN
|
||||
#define CYW43_DEFAULT_PIN_WL_CS SPICE_RX_CS_PIN
|
||||
*/
|
||||
|
||||
// Slow down the wireless clock, since we'll be running
|
||||
// comms through wiring spaghetti!
|
||||
#define CYW43_PIO_CLOCK_DIV_INT 50
|
||||
#define CYW43_PIO_CLOCK_DIV_FRAC 0
|
||||
#define CYW43_SPI_PROGRAM_NAME spi_gap0_sample1
|
||||
|
||||
#endif
|
||||
|
||||
#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)
|
||||
|
||||
// Nothing to do here?
|
||||
|
||||
#endif
|
||||
|
||||
// If a variant is not used, define a fallback board name
|
||||
#ifndef MICROPY_HW_BOARD_NAME
|
||||
|
||||
#define MICROPY_HW_BOARD_NAME "Pimoroni Pico Plus 2"
|
||||
|
||||
#endif
|
||||
@ -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"
|
||||
)
|
||||
|
||||
@ -0,0 +1,41 @@
|
||||
# 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"
|
||||
"CYW43_PIN_WL_DYNAMIC=1"
|
||||
"MICROPY_PY_NETWORK_PPP_LWIP=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)
|
||||
|
||||
set(PICO_BOARD "pimoroni_pico_plus2w_rp2350")
|
||||
set(PICO_BOARD_HEADER_DIRS ${CMAKE_CURRENT_LIST_DIR})
|
||||
@ -0,0 +1,136 @@
|
||||
/*
|
||||
* 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_pico_plus2w_rp2350.h"
|
||||
|
||||
// pico_cmake_set PICO_PLATFORM=rp2350
|
||||
|
||||
#ifndef _BOARDS_PIMORONI_PICO_PLUS2W_RP2350_H
|
||||
#define _BOARDS_PIMORONI_PICO_PLUS2W_RP2350_H
|
||||
|
||||
// For board detection
|
||||
#define PIMORONI_PICO_PLUS2_RP2350
|
||||
#define PIMORONI_PICO_PLUS2W_RP2350
|
||||
|
||||
// --- BOARD SPECIFIC ---
|
||||
#define SPICE_SPI 0
|
||||
#define SPICE_TX_MISO_PIN 32
|
||||
#define SPICE_RX_CS_PIN 33
|
||||
#define SPICE_NETLIGHT_SCK_PIN 34
|
||||
#define SPICE_RESET_MOSI_PIN 35
|
||||
#define SPICE_PWRKEY_BL_PIN 36
|
||||
|
||||
#define PIMORONI_PICO_PLUS2_USER_SW_PIN 45
|
||||
#define PIMORONI_PICO_PLUS2_PSRAM_CS_PIN 47
|
||||
|
||||
// -- CYW43 Wireless --
|
||||
#ifndef CYW43_DEFAULT_PIN_WL_HOST_WAKE
|
||||
#define CYW43_DEFAULT_PIN_WL_HOST_WAKE 24
|
||||
#endif
|
||||
|
||||
#ifndef CYW43_DEFAULT_PIN_WL_REG_ON
|
||||
#define CYW43_DEFAULT_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
|
||||
|
||||
// If CYW43_WL_GPIO_VBUS_PIN is defined then a CYW43 GPIO has to be used to read VBUS.
|
||||
// This can be passed to cyw43_arch_gpio_get to determine if the device is battery powered.
|
||||
// PICO_VBUS_PIN and CYW43_WL_GPIO_VBUS_PIN should not both be defined.
|
||||
|
||||
// no CYW43_WL_GPIO_VBUS_PIN
|
||||
|
||||
// If CYW43_USES_VSYS_PIN is defined then CYW43 uses the VSYS GPIO (defined by PICO_VSYS_PIN) for other purposes.
|
||||
// If this is the case, to use the VSYS GPIO it's necessary to ensure CYW43 is not using it.
|
||||
// This can be achieved by wrapping the use of the VSYS GPIO in cyw43_thread_enter / cyw43_thread_exit.
|
||||
|
||||
// no CYW43_USES_VSYS_PIN
|
||||
|
||||
// --- UART ---
|
||||
#ifndef PICO_DEFAULT_UART
|
||||
#define PICO_DEFAULT_UART 0
|
||||
#endif
|
||||
#ifndef PICO_DEFAULT_UART_TX_PIN
|
||||
#define PICO_DEFAULT_UART_TX_PIN 0
|
||||
#endif
|
||||
#ifndef PICO_DEFAULT_UART_RX_PIN
|
||||
#define PICO_DEFAULT_UART_RX_PIN 1
|
||||
#endif
|
||||
|
||||
// --- LED ---
|
||||
#ifndef PICO_DEFAULT_LED_PIN
|
||||
#define PICO_DEFAULT_LED_PIN 25
|
||||
#endif
|
||||
// no PICO_DEFAULT_WS2812_PIN
|
||||
|
||||
// --- I2C ---
|
||||
#ifndef PICO_DEFAULT_I2C
|
||||
#define PICO_DEFAULT_I2C 0
|
||||
#endif
|
||||
#ifndef PICO_DEFAULT_I2C_SDA_PIN
|
||||
#define PICO_DEFAULT_I2C_SDA_PIN 4
|
||||
#endif
|
||||
#ifndef PICO_DEFAULT_I2C_SCL_PIN
|
||||
#define PICO_DEFAULT_I2C_SCL_PIN 5
|
||||
#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 = (16 * 1024 * 1024)
|
||||
#ifndef PICO_FLASH_SIZE_BYTES
|
||||
#define PICO_FLASH_SIZE_BYTES (16 * 1024 * 1024)
|
||||
#endif
|
||||
|
||||
// The GPIO Pin used to read VBUS to determine if the device is battery powered.
|
||||
#ifndef PICO_VBUS_PIN
|
||||
#define PICO_VBUS_PIN 24
|
||||
#endif
|
||||
|
||||
// The GPIO Pin used to monitor VSYS. Typically you would use this with ADC.
|
||||
// There is an example in adc/read_vsys in pico-examples.
|
||||
#ifndef PICO_VSYS_PIN
|
||||
#define PICO_VSYS_PIN 43
|
||||
#endif
|
||||
|
||||
#ifndef PICO_RP2350_A2_SUPPORTED
|
||||
#define PICO_RP2350_A2_SUPPORTED 1
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@ -45,3 +45,12 @@ GP45,GPIO45
|
||||
GP46,GPIO46
|
||||
GP47,GPIO47
|
||||
LED,GPIO25
|
||||
LEDW,EXT_GPIO0
|
||||
WL_GPIO0,EXT_GPIO0
|
||||
WL_GPIO1,EXT_GPIO1
|
||||
WL_GPIO2,EXT_GPIO2
|
||||
SPICE_TX,GPIO32
|
||||
SPICE_RX,GPIO33
|
||||
SPICE_NETLIGHT,GPIO34
|
||||
SPICE_RESET,GPIO35
|
||||
SPICE_PWRKEY,GPIO36
|
||||
|
@ -0,0 +1,8 @@
|
||||
require("bundle-networking")
|
||||
|
||||
# Bluetooth
|
||||
require("aioble")
|
||||
|
||||
include("manifest.py")
|
||||
|
||||
freeze("$(BOARD_DIR)/../../modules_py", "lte.py")
|
||||
@ -6,3 +6,6 @@ set(PICO_PLATFORM "rp2350")
|
||||
set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py)
|
||||
|
||||
set(MICROPY_C_HEAP_SIZE 4096)
|
||||
|
||||
set(PICO_BOARD "pimoroni_plasma2350")
|
||||
set(PICO_BOARD_HEADER_DIRS ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
@ -1,7 +1,73 @@
|
||||
// Board and hardware specific configuration
|
||||
#define MICROPY_HW_BOARD_NAME "Pimoroni Plasma 2350"
|
||||
#define MICROPY_HW_FLASH_STORAGE_BYTES (PICO_FLASH_SIZE_BYTES - (2 * 1024 * 1024))
|
||||
|
||||
#ifndef CYW43_WL_GPIO_COUNT
|
||||
// Shim the EXT GPIOs because we can't specify a variant pins.csv
|
||||
// Remap them to LED R, G and B respectively on non-W builds
|
||||
#define pin_EXT_GPIO0 pin_GPIO16
|
||||
#define pin_EXT_GPIO1 pin_GPIO17
|
||||
#define pin_EXT_GPIO2 pin_GPIO18
|
||||
#endif
|
||||
|
||||
// I2C0 (non-default)
|
||||
#define MICROPY_HW_I2C0_SCL (PLASMA2350_SDA_PIN)
|
||||
#define MICROPY_HW_I2C0_SDA (PLASMA2350_SCL_PIN)
|
||||
|
||||
// Set up networking.
|
||||
#define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "PLASMA2350"
|
||||
|
||||
#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
|
||||
|
||||
#if defined(CYW43_PIN_WL_DYNAMIC)
|
||||
|
||||
#define CYW43_PIO_CLOCK_DIV_DYNAMIC (1)
|
||||
|
||||
// Defined by pimoroni_pico_plus2w_rp2350.h
|
||||
//#define CYW43_DEFAULT_PIN_WL_HOST_WAKE SPICE_RESET_MOSI_PIN
|
||||
//#define CYW43_DEFAULT_PIN_WL_REG_ON SPICE_TX_MISO_PIN
|
||||
#define CYW43_DEFAULT_PIN_WL_DATA_OUT CYW43_DEFAULT_PIN_WL_HOST_WAKE
|
||||
#define CYW43_DEFAULT_PIN_WL_DATA_IN CYW43_DEFAULT_PIN_WL_HOST_WAKE
|
||||
#define CYW43_DEFAULT_PIN_WL_CLOCK 29u
|
||||
#define CYW43_DEFAULT_PIN_WL_CS 25u
|
||||
|
||||
/* SPICE alternative
|
||||
#define CYW43_DEFAULT_PIN_WL_HOST_WAKE SPICE_RESET_MOSI_PIN
|
||||
#define CYW43_DEFAULT_PIN_WL_REG_ON SPICE_TX_MISO_PIN
|
||||
#define CYW43_DEFAULT_PIN_WL_DATA_OUT SPICE_RESET_MOSI_PIN
|
||||
#define CYW43_DEFAULT_PIN_WL_DATA_IN SPICE_RESET_MOSI_PIN
|
||||
#define CYW43_DEFAULT_PIN_WL_CLOCK SPICE_NETLIGHT_SCK_PIN
|
||||
#define CYW43_DEFAULT_PIN_WL_CS SPICE_RX_CS_PIN
|
||||
*/
|
||||
|
||||
// Slow down the wireless clock, since we'll be running
|
||||
// comms through wiring spaghetti!
|
||||
#define CYW43_PIO_CLOCK_DIV_INT 50
|
||||
#define CYW43_PIO_CLOCK_DIV_FRAC 0
|
||||
#define CYW43_SPI_PROGRAM_NAME spi_gap0_sample1
|
||||
|
||||
#endif
|
||||
|
||||
#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)
|
||||
|
||||
// Nothing to do here?
|
||||
|
||||
#endif
|
||||
|
||||
// If a variant is not used, define a fallback board name
|
||||
#ifndef MICROPY_HW_BOARD_NAME
|
||||
|
||||
#define MICROPY_HW_BOARD_NAME "Pimoroni Plasma 2350"
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,40 @@
|
||||
# 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 (LTE + WiFi)\""
|
||||
"MICROPY_PY_NETWORK=1"
|
||||
"CYW43_PIN_WL_DYNAMIC=1"
|
||||
"MICROPY_PY_NETWORK_PPP_LWIP=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)
|
||||
|
||||
set(PICO_BOARD "pimoroni_plasma2350w")
|
||||
set(PICO_BOARD_HEADER_DIRS ${CMAKE_CURRENT_LIST_DIR})
|
||||
119
micropython/board/PIMORONI_PLASMA2350/pimoroni_plasma2350.h
Normal file
119
micropython/board/PIMORONI_PLASMA2350/pimoroni_plasma2350.h
Normal file
@ -0,0 +1,119 @@
|
||||
/*
|
||||
* 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_plasma2350.h"
|
||||
|
||||
// pico_cmake_set PICO_PLATFORM=rp2350
|
||||
|
||||
#ifndef _BOARDS_PIMORONI_PLASMA2350_H
|
||||
#define _BOARDS_PIMORONI_PLASMA2350_H
|
||||
|
||||
// For board detection
|
||||
#define PIMORONI_PLASMA2350
|
||||
|
||||
// --- 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
|
||||
|
||||
// --- 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 = (4 * 1024 * 1024)
|
||||
#ifndef PICO_FLASH_SIZE_BYTES
|
||||
#define PICO_FLASH_SIZE_BYTES (4 * 1024 * 1024)
|
||||
#endif
|
||||
|
||||
#ifndef PICO_RP2350_A2_SUPPORTED
|
||||
#define PICO_RP2350_A2_SUPPORTED 1
|
||||
#endif
|
||||
|
||||
// no PICO_VBUS_PIN
|
||||
// no PICO_VSYS_PIN
|
||||
|
||||
#endif
|
||||
137
micropython/board/PIMORONI_PLASMA2350/pimoroni_plasma2350w.h
Normal file
137
micropython/board/PIMORONI_PLASMA2350/pimoroni_plasma2350w.h
Normal file
@ -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_plasma2350.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
|
||||
|
||||
// -- CYW43 Wireless --
|
||||
#ifndef CYW43_DEFAULT_PIN_WL_HOST_WAKE
|
||||
#define CYW43_DEFAULT_PIN_WL_HOST_WAKE 24
|
||||
#endif
|
||||
|
||||
#ifndef CYW43_DEFAULT_PIN_WL_REG_ON
|
||||
#define CYW43_DEFAULT_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
|
||||
|
||||
// --- RP2350 VARIANT ---
|
||||
#define PICO_RP2350A 1
|
||||
|
||||
// --- 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 = (4 * 1024 * 1024)
|
||||
#ifndef PICO_FLASH_SIZE_BYTES
|
||||
#define PICO_FLASH_SIZE_BYTES (4 * 1024 * 1024)
|
||||
#endif
|
||||
|
||||
#ifndef PICO_RP2350_A2_SUPPORTED
|
||||
#define PICO_RP2350_A2_SUPPORTED 1
|
||||
#endif
|
||||
|
||||
// no PICO_VBUS_PIN
|
||||
// no PICO_VSYS_PIN
|
||||
|
||||
#endif
|
||||
@ -31,3 +31,6 @@ LED_R,GPIO16
|
||||
LED_G,GPIO17
|
||||
LED_B,GPIO18
|
||||
USER_SW,GPIO22
|
||||
WL_GPIO0,EXT_GPIO0
|
||||
WL_GPIO1,EXT_GPIO1
|
||||
WL_GPIO2,EXT_GPIO2
|
||||
|
8
micropython/board/RPI_PICO2/manifest-wireless.py
Normal file
8
micropython/board/RPI_PICO2/manifest-wireless.py
Normal file
@ -0,0 +1,8 @@
|
||||
require("bundle-networking")
|
||||
|
||||
# Bluetooth
|
||||
require("aioble")
|
||||
|
||||
include("manifest.py")
|
||||
|
||||
freeze("$(BOARD_DIR)/../../modules_py", "lte.py")
|
||||
@ -1,3 +1,52 @@
|
||||
// Board and hardware specific configuration
|
||||
#define MICROPY_HW_BOARD_NAME "Raspberry Pi Pico"
|
||||
#define MICROPY_HW_FLASH_STORAGE_BYTES (PICO_FLASH_SIZE_BYTES - 1024 * 1024)
|
||||
#define MICROPY_HW_FLASH_STORAGE_BYTES (PICO_FLASH_SIZE_BYTES - (2 * 1024 * 1024))
|
||||
|
||||
// Set up networking.
|
||||
#define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "Pico2"
|
||||
|
||||
#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
|
||||
|
||||
#if defined(CYW43_PIN_WL_DYNAMIC)
|
||||
|
||||
#define CYW43_PIO_CLOCK_DIV_DYNAMIC (1)
|
||||
|
||||
// CYW43 default pin configuration
|
||||
#define CYW43_DEFAULT_PIN_WL_HOST_WAKE 24u
|
||||
#define CYW43_DEFAULT_PIN_WL_REG_ON 23u
|
||||
#define CYW43_DEFAULT_PIN_WL_DATA_OUT CYW43_DEFAULT_PIN_WL_HOST_WAKE
|
||||
#define CYW43_DEFAULT_PIN_WL_DATA_IN CYW43_DEFAULT_PIN_WL_HOST_WAKE
|
||||
#define CYW43_DEFAULT_PIN_WL_CLOCK 29u
|
||||
#define CYW43_DEFAULT_PIN_WL_CS 25u
|
||||
|
||||
// Slow down the wireless clock, since we'll be running
|
||||
// comms through wiring spaghetti!
|
||||
#define CYW43_PIO_CLOCK_DIV_INT 50
|
||||
#define CYW43_PIO_CLOCK_DIV_FRAC 0
|
||||
#define CYW43_SPI_PROGRAM_NAME spi_gap0_sample1
|
||||
|
||||
#endif
|
||||
|
||||
#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)
|
||||
|
||||
// Nothing to do here?
|
||||
|
||||
#endif
|
||||
|
||||
// If a variant is not used, define a fallback board name
|
||||
#ifndef MICROPY_HW_BOARD_NAME
|
||||
|
||||
#define MICROPY_HW_BOARD_NAME "Raspberry Pi Pico 2"
|
||||
|
||||
#endif
|
||||
40
micropython/board/RPI_PICO2/mpconfigvariant_WIRELESS.cmake
Normal file
40
micropython/board/RPI_PICO2/mpconfigvariant_WIRELESS.cmake
Normal file
@ -0,0 +1,40 @@
|
||||
# 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=\"Raspberry Pi Pico 2 (LTE + WiFi)\""
|
||||
"MICROPY_PY_NETWORK=1"
|
||||
"CYW43_PIN_WL_DYNAMIC=1"
|
||||
"MICROPY_PY_NETWORK_PPP_LWIP=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)
|
||||
|
||||
set(PICO_BOARD "pico2_w")
|
||||
set(PICO_BOARD_HEADER_DIRS ${CMAKE_CURRENT_LIST_DIR})
|
||||
116
micropython/board/RPI_PICO2/pico2_w.h
Normal file
116
micropython/board/RPI_PICO2/pico2_w.h
Normal file
@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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/pico2_w.h"
|
||||
|
||||
// pico_cmake_set PICO_PLATFORM=rp2350
|
||||
// pico_cmake_set PICO_CYW43_SUPPORTED = 1
|
||||
|
||||
#ifndef _BOARDS_PICO2_W_H
|
||||
#define _BOARDS_PICO2_W_H
|
||||
|
||||
// For board detection
|
||||
#define RASPBERRYPI_PICO2_W
|
||||
|
||||
// --- RP2350 VARIANT ---
|
||||
#define PICO_RP2350A 1
|
||||
|
||||
// --- UART ---
|
||||
#ifndef PICO_DEFAULT_UART
|
||||
#define PICO_DEFAULT_UART 0
|
||||
#endif
|
||||
#ifndef PICO_DEFAULT_UART_TX_PIN
|
||||
#define PICO_DEFAULT_UART_TX_PIN 0
|
||||
#endif
|
||||
#ifndef PICO_DEFAULT_UART_RX_PIN
|
||||
#define PICO_DEFAULT_UART_RX_PIN 1
|
||||
#endif
|
||||
|
||||
// --- LED ---
|
||||
// no PICO_DEFAULT_LED_PIN - LED is on Wireless chip
|
||||
// no PICO_DEFAULT_WS2812_PIN
|
||||
|
||||
// --- I2C ---
|
||||
#ifndef PICO_DEFAULT_I2C
|
||||
#define PICO_DEFAULT_I2C 0
|
||||
#endif
|
||||
#ifndef PICO_DEFAULT_I2C_SDA_PIN
|
||||
#define PICO_DEFAULT_I2C_SDA_PIN 4
|
||||
#endif
|
||||
#ifndef PICO_DEFAULT_I2C_SCL_PIN
|
||||
#define PICO_DEFAULT_I2C_SCL_PIN 5
|
||||
#endif
|
||||
|
||||
// --- SPI ---
|
||||
#ifndef PICO_DEFAULT_SPI
|
||||
#define PICO_DEFAULT_SPI 0
|
||||
#endif
|
||||
#ifndef PICO_DEFAULT_SPI_SCK_PIN
|
||||
#define PICO_DEFAULT_SPI_SCK_PIN 18
|
||||
#endif
|
||||
#ifndef PICO_DEFAULT_SPI_TX_PIN
|
||||
#define PICO_DEFAULT_SPI_TX_PIN 19
|
||||
#endif
|
||||
#ifndef PICO_DEFAULT_SPI_RX_PIN
|
||||
#define PICO_DEFAULT_SPI_RX_PIN 16
|
||||
#endif
|
||||
#ifndef PICO_DEFAULT_SPI_CSN_PIN
|
||||
#define PICO_DEFAULT_SPI_CSN_PIN 17
|
||||
#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 = (4 * 1024 * 1024)
|
||||
#ifndef PICO_FLASH_SIZE_BYTES
|
||||
#define PICO_FLASH_SIZE_BYTES (4 * 1024 * 1024)
|
||||
#endif
|
||||
// Drive high to force power supply into PWM mode (lower ripple on 3V3 at light loads)
|
||||
// note the SMSP mode pin is on WL_GPIO1
|
||||
|
||||
#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
|
||||
|
||||
// If CYW43_WL_GPIO_VBUS_PIN is defined then a CYW43 GPIO has to be used to read VBUS.
|
||||
// This can be passed to cyw43_arch_gpio_get to determine if the device is battery powered.
|
||||
// PICO_VBUS_PIN and CYW43_WL_GPIO_VBUS_PIN should not both be defined.
|
||||
#ifndef CYW43_WL_GPIO_VBUS_PIN
|
||||
#define CYW43_WL_GPIO_VBUS_PIN 2
|
||||
#endif
|
||||
|
||||
// If CYW43_USES_VSYS_PIN is defined then CYW43 uses the VSYS GPIO (defined by PICO_VSYS_PIN) for other purposes.
|
||||
// If this is the case, to use the VSYS GPIO it's necessary to ensure CYW43 is not using it.
|
||||
// This can be achieved by wrapping the use of the VSYS GPIO in cyw43_thread_enter / cyw43_thread_exit.
|
||||
#ifndef CYW43_USES_VSYS_PIN
|
||||
#define CYW43_USES_VSYS_PIN 1
|
||||
#endif
|
||||
|
||||
// The GPIO Pin used to monitor VSYS. Typically you would use this with ADC.
|
||||
// There is an example in adc/read_vsys in pico-examples.
|
||||
#ifndef PICO_VSYS_PIN
|
||||
#define PICO_VSYS_PIN 29
|
||||
#endif
|
||||
|
||||
#ifndef PICO_RP2350_A2_SUPPORTED
|
||||
#define PICO_RP2350_A2_SUPPORTED 1
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@ -1,5 +1,8 @@
|
||||
MODULES_PY = "../../../pimoroni-pico/micropython/modules_py"
|
||||
|
||||
# SD Card
|
||||
require("sdcard")
|
||||
|
||||
freeze(MODULES_PY, "gfx_pack.py")
|
||||
|
||||
freeze(MODULES_PY, "pimoroni.py")
|
||||
|
||||
38
micropython/examples/pico_plus_2/breakouts/lte-breakout.py
Normal file
38
micropython/examples/pico_plus_2/breakouts/lte-breakout.py
Normal file
@ -0,0 +1,38 @@
|
||||
import lte
|
||||
import time
|
||||
import requests
|
||||
from machine import Pin, PWM
|
||||
|
||||
|
||||
MOBILE_APN = "Your APN Here"
|
||||
|
||||
# Setting this to True will attempt to resume an existing connection
|
||||
RESUME = False
|
||||
|
||||
# Fix the eye-searing brightness of the onboard LED with PWM
|
||||
class Netlight:
|
||||
def __init__(self):
|
||||
self.pin = PWM(Pin("LED", Pin.OUT), freq=1000)
|
||||
|
||||
def value(self, value):
|
||||
self.pin.duty_u16(value * 2000)
|
||||
|
||||
|
||||
con = lte.LTE(MOBILE_APN, netlight_led=Netlight(), skip_reset=RESUME)
|
||||
con.start_ppp(connect=not RESUME)
|
||||
|
||||
# Do some requests! Internet stuff should just work now.
|
||||
try:
|
||||
t_start = time.time()
|
||||
for x in range(2):
|
||||
req = requests.get("https://shop.pimoroni.com/robots.txt")
|
||||
print(req)
|
||||
|
||||
finally:
|
||||
t_end = time.time()
|
||||
|
||||
print(f"Took: {t_end - t_start} seconds")
|
||||
|
||||
print("Disconnecting...")
|
||||
con.stop_ppp()
|
||||
print("Done!")
|
||||
220
micropython/modules_py/lte.py
Normal file
220
micropython/modules_py/lte.py
Normal file
@ -0,0 +1,220 @@
|
||||
from machine import UART, Pin
|
||||
from network import PPP
|
||||
from micropython import const
|
||||
import time
|
||||
|
||||
|
||||
DEFAULT_PIN_RST = 35
|
||||
DEFAULT_PIN_NETLIGHT = 34
|
||||
DEFAULT_PIN_RX = 33
|
||||
DEFAULT_PIN_TX = 32
|
||||
DEFAULT_UART_ID = 0
|
||||
|
||||
DEFAULT_UART_TIMEOUT = const(1)
|
||||
DEFAULT_UART_TIMEOUT_CHAR = const(1)
|
||||
DEFAULT_UART_RXBUF = const(1024)
|
||||
DEFAULT_UART_STARTUP_BAUD = const(115200)
|
||||
DEFAULT_UART_BAUD = const(460800)
|
||||
|
||||
|
||||
class CellularError(Exception):
|
||||
def __init__(self, message=None):
|
||||
self.message = f"CellularError: {message}"
|
||||
|
||||
|
||||
class LTE():
|
||||
def __init__(self, apn, uart=None, reset_pin=None, netlight_pin=None, netlight_led=None, skip_reset=False):
|
||||
self._apn = apn
|
||||
self._reset = reset_pin or Pin(DEFAULT_PIN_RST, Pin.OUT)
|
||||
self._uart = uart or UART(
|
||||
DEFAULT_UART_ID,
|
||||
tx=Pin(DEFAULT_PIN_TX, Pin.OUT),
|
||||
rx=Pin(DEFAULT_PIN_RX, Pin.OUT))
|
||||
|
||||
# Set PPP timeouts and rxbuf
|
||||
self._uart.init(
|
||||
timeout=DEFAULT_UART_TIMEOUT,
|
||||
timeout_char=DEFAULT_UART_TIMEOUT_CHAR,
|
||||
rxbuf=DEFAULT_UART_RXBUF)
|
||||
|
||||
if not skip_reset:
|
||||
self._reset.value(0)
|
||||
time.sleep(1.0)
|
||||
self._reset.value(1)
|
||||
|
||||
if netlight_led:
|
||||
self._led = netlight_led
|
||||
self._netlight = netlight_pin or Pin(DEFAULT_PIN_NETLIGHT, Pin.IN)
|
||||
self._netlight.irq(self._netlight_irq)
|
||||
|
||||
def _netlight_irq(self, pin):
|
||||
self._led.value(pin.value())
|
||||
|
||||
def ipconfig(self, *args, **kwargs):
|
||||
if len(args):
|
||||
return self._ppp.ipconfig(*args)
|
||||
else:
|
||||
return self._ppp.ipconfig(**kwargs)
|
||||
|
||||
def iccid(self):
|
||||
try:
|
||||
return self._send_at_command("AT+CICCID", 1)
|
||||
except CellularError:
|
||||
return None
|
||||
|
||||
def status(self):
|
||||
lte_status = self._send_at_command("AT+CEREG?", 1)
|
||||
gsm_status = self._send_at_command("AT+CGREG?", 1)
|
||||
return lte_status, gsm_status
|
||||
|
||||
def signal_quality(self):
|
||||
try:
|
||||
response = self._send_at_command("AT+CSQ", 1)
|
||||
quality = int(response.split(":")[1].split(",")[0])
|
||||
db = -113 + (2 * quality) # conversion as per AT command set datasheet
|
||||
return db
|
||||
except CellularError:
|
||||
pass
|
||||
return None
|
||||
|
||||
def stop_ppp(self):
|
||||
self._ppp.disconnect()
|
||||
self._send_at_command(f"AT+IPR={DEFAULT_UART_STARTUP_BAUD}")
|
||||
self._flush_uart()
|
||||
|
||||
def start_ppp(self, baudrate=DEFAULT_UART_BAUD, connect=True):
|
||||
self._wait_ready(poll_time=1.0, timeout=30)
|
||||
|
||||
# Switch to a faster baudrate
|
||||
self._send_at_command(f"AT+IPR={baudrate}")
|
||||
self._flush_uart()
|
||||
self._uart.init(
|
||||
baudrate=baudrate,
|
||||
timeout=DEFAULT_UART_TIMEOUT,
|
||||
timeout_char=DEFAULT_UART_TIMEOUT_CHAR,
|
||||
rxbuf=DEFAULT_UART_RXBUF)
|
||||
self._wait_ready(poll_time=1.0)
|
||||
|
||||
# Connect!
|
||||
if connect:
|
||||
self.connect()
|
||||
|
||||
# This will just always time out!?
|
||||
# try:
|
||||
# self._send_at_command("ATD*99#", timeout=300)
|
||||
# except CellularError as e:
|
||||
# print(e)
|
||||
|
||||
# Force PPP to use modem's default settings...
|
||||
self._flush_uart()
|
||||
self._uart.write("ATD*99#\r")
|
||||
self._uart.flush()
|
||||
|
||||
self._ppp = PPP(self._uart)
|
||||
self._ppp.connect()
|
||||
while self._ppp.status() != 4:
|
||||
time.sleep(1.0)
|
||||
|
||||
return self._ppp.ifconfig()
|
||||
|
||||
def connect(self, timeout=60):
|
||||
print(" - setting up cellular uart")
|
||||
# connect to and flush the uart
|
||||
# consume any unsolicited messages first, we don't need those
|
||||
self._flush_uart()
|
||||
|
||||
print(" - waiting for cellular module to be ready")
|
||||
|
||||
# wait for the cellular module to respond to AT commands
|
||||
self._wait_ready()
|
||||
|
||||
self._send_at_command("ATE0") # disable local echo
|
||||
self._send_at_command(f"AT+CGDCONT=1,\"IP\",\"{self._apn}\"") # set apn and activate pdp context
|
||||
|
||||
# wait for roaming lte connection to be established
|
||||
giveup = time.time() + timeout
|
||||
status = None
|
||||
while status != "+CEREG: 0,5" and status != "+CEREG: 0,1":
|
||||
status = self._send_at_command("AT+CEREG?", 1)
|
||||
time.sleep(0.25)
|
||||
if time.time() > giveup:
|
||||
raise CellularError("timed out getting network registration")
|
||||
|
||||
# disable server and client certification validation
|
||||
self._send_at_command("AT+CSSLCFG=\"authmode\",0,0")
|
||||
self._send_at_command("AT+CSSLCFG=\"enableSNI\",0,1")
|
||||
|
||||
print(f" - SIM ICCID is {self.iccid()}")
|
||||
|
||||
def _wait_ready(self, poll_time=0.25, timeout=10):
|
||||
giveup = time.time() + timeout
|
||||
while time.time() <= giveup:
|
||||
try:
|
||||
# if __send_at_command doesn't throw an exception then we're good!
|
||||
self._send_at_command("AT")
|
||||
return
|
||||
except CellularError as e:
|
||||
print(e)
|
||||
time.sleep(poll_time)
|
||||
|
||||
raise CellularError("timed out waiting for AT response")
|
||||
|
||||
def _flush_uart(self):
|
||||
self._uart.flush()
|
||||
time.sleep(0.25)
|
||||
while self._uart.any():
|
||||
self._uart.read(self._uart.any())
|
||||
time.sleep(0.25)
|
||||
|
||||
def _send_at_command(self, command, result_lines=0, timeout=5.0):
|
||||
# consume any unsolicited messages first, we don't need those
|
||||
self._flush_uart()
|
||||
|
||||
self._uart.write(command + "\r")
|
||||
self._uart.flush()
|
||||
status, data = self._read_result(result_lines, timeout=timeout)
|
||||
|
||||
print(" -", command, status, data)
|
||||
|
||||
if status not in ["OK", "DOWNLOAD"]:
|
||||
raise CellularError(f"non 'OK' or 'DOWNLOAD' result for command {command}")
|
||||
|
||||
if result_lines == 1:
|
||||
return data[0]
|
||||
if result_lines > 1:
|
||||
return data
|
||||
return None
|
||||
|
||||
def _read_result(self, result_lines, timeout=1.0):
|
||||
status = None
|
||||
result = []
|
||||
start = time.ticks_ms()
|
||||
timeout *= 1000
|
||||
while len(result) < result_lines or status is None:
|
||||
if (time.ticks_ms() - start) > timeout:
|
||||
raise CellularError("cellular module timed out")
|
||||
|
||||
line = self._uart.readline()
|
||||
|
||||
if line:
|
||||
line = line.strip()
|
||||
if line in [b"OK", b"ERROR", b"DOWNLOAD"]:
|
||||
status = line.decode("ascii")
|
||||
elif line != b"":
|
||||
result.append(str(line, "ascii"))
|
||||
start = time.ticks_ms()
|
||||
|
||||
return status, result
|
||||
|
||||
def send_text_message(self, recipient, body, timeout=5.0):
|
||||
self._uart.write("AT+CMGS=\"")
|
||||
self._uart.write(recipient.encode("ascii"))
|
||||
self._uart.write(b"\"\r")
|
||||
time.sleep(0.5)
|
||||
self._uart.write(body.encode("ascii"))
|
||||
self._uart.write(b"\x1a\r")
|
||||
self._uart.flush()
|
||||
|
||||
status, _ = self._read_result(1, timeout=timeout)
|
||||
|
||||
return status == "OK"
|
||||
Loading…
Reference in New Issue
Block a user