Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/uat-xmas2024'
Browse files Browse the repository at this point in the history
Closes #661
Closes #664
Closes #668
Closes #670
Closes #672
Closes #673
  • Loading branch information
tyeth committed Dec 21, 2024
2 parents 9af3867 + 0923b82 commit 570c166
Show file tree
Hide file tree
Showing 21 changed files with 493 additions and 221 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-clang-doxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ jobs:
strategy:
fail-fast: false
matrix:
arduino-platform: ["picow_rp2040_tinyusb"]
arduino-platform: ["picow_rp2040_tinyusb", "picow_rp2350_tinyusb"]
steps:
- uses: actions/setup-python@v5
with:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions examples/Wippersnapper_demo/.picow_rp2350_tinyusb.generate
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ paragraph=Arduino application for Adafruit.io WipperSnapper
category=Communication
url=https://github.com/adafruit/Adafruit_Wippersnapper_Arduino
architectures=*
depends=Adafruit NeoPixel, Adafruit SPIFlash, ArduinoJson, Adafruit DotStar, Adafruit HDC302x, Adafruit INA219, Adafruit LTR329 and LTR303, Adafruit LTR390 Library, Adafruit MCP3421, Adafruit NAU7802 Library, Adafruit SleepyDog Library, Adafruit TMP117, Adafruit TinyUSB Library, Adafruit AHTX0, Adafruit BME280 Library, Adafruit BMP280 Library, Adafruit BMP3XX Library, Adafruit DPS310, Adafruit DS248x, Adafruit SCD30, Adafruit SGP30 Sensor, Adafruit SGP40 Sensor, Sensirion I2C SCD4x, Sensirion I2C SEN5X, arduino-sht, Adafruit Si7021 Library, Adafruit MQTT Library, Adafruit MS8607, Adafruit MCP9808 Library, Adafruit MCP9600 Library, Adafruit MPL115A2, Adafruit MPRLS Library, Adafruit TSL2591 Library, Adafruit_VL53L0X, Adafruit VL53L1X, STM32duino VL53L4CD, STM32duino VL53L4CX, Adafruit_VL6180X, Adafruit PM25 AQI Sensor, Adafruit VCNL4020 Library, Adafruit VCNL4040, Adafruit VEML7700 Library, Adafruit LC709203F, Adafruit LPS2X, Adafruit LPS35HW, Adafruit seesaw Library, Adafruit BME680 Library, Adafruit MAX1704X, Adafruit ADT7410 Library, Adafruit HTS221, Adafruit HTU21DF Library, Adafruit HTU31D Library, Adafruit PCT2075, hp_BH1750, ENS160 - Adafruit Fork
depends=Adafruit NeoPixel, Adafruit SPIFlash, ArduinoJson, Adafruit DotStar, Adafruit HDC302x, Adafruit INA219, Adafruit LTR329 and LTR303, Adafruit LTR390 Library, Adafruit MCP3421, Adafruit NAU7802 Library, Adafruit SleepyDog Library, Adafruit TMP117, Adafruit TinyUSB Library, Adafruit AHTX0, Adafruit BME280 Library, Adafruit BMP280 Library, Adafruit BMP3XX Library, Adafruit DPS310, Adafruit DS248x, Adafruit SCD30, Adafruit SGP30 Sensor, Adafruit SGP40 Sensor, Sensirion I2C SCD4x, Sensirion I2C SEN5X, arduino-sht, Adafruit Si7021 Library, Adafruit MQTT Library, Adafruit MS8607, Adafruit MCP9808 Library, Adafruit MCP9600 Library, Adafruit MPL115A2, Adafruit MPRLS Library, Adafruit TSL2591 Library, Adafruit_VL53L0X, Adafruit VL53L1X, STM32duino VL53L4CD, STM32duino VL53L4CX, Adafruit_VL6180X, Adafruit PM25 AQI Sensor, Adafruit VCNL4020 Library, Adafruit VCNL4040, Adafruit VCNL4200 Library, Adafruit VEML7700 Library, Adafruit LC709203F, Adafruit LPS2X, Adafruit LPS35HW, Adafruit seesaw Library, Adafruit BME680 Library, Adafruit MAX1704X, Adafruit ADT7410 Library, Adafruit HTS221, Adafruit HTU21DF Library, Adafruit HTU31D Library, Adafruit PCT2075, hp_BH1750, ENS160 - Adafruit Fork
122 changes: 105 additions & 17 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,16 @@ framework = arduino
monitor_speed = 115200
lib_compat_mode = strict
lib_deps =
;;;;;;;;;;; FunHouse / LVGL Boards uncomment these ;;;;;;;;;;;;;;
; https://github.com/adafruit/Adafruit_HX8357_Library.git
; https://github.com/adafruit/Adafruit_ILI9341.git
; https://github.com/adafruit/Adafruit_STMPE610.git
; https://github.com/adafruit/Adafruit-ST7735-Library.git
; https://github.com/adafruit/Adafruit_TouchScreen.git
; https://github.com/brentru/lvgl.git#wippersnapper
; https://github.com/brentru/Adafruit_LvGL_Glue.git#development
;;;;;;;;;;; All Boards need these libraries included ;;;;;;;;;;;;;;
adafruit/Adafruit Zero DMA Library
https://github.com/adafruit/Adafruit_TinyUSB_Arduino.git
adafruit/Adafruit NeoPixel
adafruit/Adafruit SPIFlash
adafruit/Adafruit DotStar
Expand All @@ -43,6 +51,7 @@ lib_deps =
adafruit/Adafruit Si7021 Library
adafruit/Adafruit VCNL4020 Library
adafruit/Adafruit VCNL4040
adafruit/Adafruit VCNL4200 Library
adafruit/Adafruit MCP3421
adafruit/Adafruit MCP9808 Library
adafruit/Adafruit MCP9600 Library
Expand Down Expand Up @@ -78,14 +87,8 @@ lib_deps =
https://github.com/Sensirion/arduino-i2c-sen5x.git
https://github.com/adafruit/WiFiNINA.git
https://github.com/Starmbi/hp_BH1750.git
;;;;;;;;;;; FunHouse / LVGL Boards ;;;;;;;;;;;;;;
https://github.com/adafruit/Adafruit_HX8357_Library.git
https://github.com/adafruit/Adafruit_ILI9341.git
https://github.com/adafruit/Adafruit_STMPE610.git
https://github.com/adafruit/Adafruit-ST7735-Library.git
https://github.com/adafruit/Adafruit_TouchScreen.git
https://github.com/brentru/lvgl.git#wippersnapper
https://github.com/brentru/Adafruit_LvGL_Glue.git#development
https://github.com/adafruit/Adafruit_TinyUSB_Arduino.git



; Common build environment for ESP32 platform
Expand All @@ -107,12 +110,13 @@ platform = atmelsam
platform_packages =
platformio/framework-arduino-samd-adafruit@^1.7.13
platformio/tool-jlink@^1.78811.0
lib_ldf_mode = deep
lib_ldf_mode = chain+
lib_compat_mode = strict
lib_archive = no ; debug timer issues see https://community.platformio.org/t/choose-usb-stack-as-tiny-usb/22451/5
lib_ignore = OneWire
lib_ignore = OneWire, USBHost

[common:rp2040]
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
platform = https://github.com/maxgerhardt/platform-raspberrypi.git#develop
; platform_packages =
; framework-arduinopico @ symlink:///Users/tyeth/Projects/arduino-pico
; framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#master
Expand Down Expand Up @@ -408,7 +412,23 @@ extra_scripts = pre:rename_usb_config.py
[env:huzzah]
extends=common:esp8266
board = huzzah
build_flags = -DARDUINO_ESP8266_ADAFRUIT_HUZZAH
board_build.f_cpu = 80000000L
; Arduino CLI uses this from adafruit_ci#ci-wippersnapper
; esp8266:esp8266:huzzah:xtal=80,vt=flash,exception=disabled,stacksmash=disabled,ssl=all,mmu=3232,non32xfer=fast,eesz=4M2M,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=115200
build_flags =
-Wl,--gc-sections
-Wl,-Map=output.map
-DARDUINO_ESP8266_ADAFRUIT_HUZZAH
-DDEBUG_ESP_PORT=Serial
-DVTABLES_IN_FLASH
-DNO_EXCEPTIONS
-DNO_STACK_SMASH_PROTECTION
-DSSL_ALL
-DMMU_3232
-DNON32XFER_FAST
-DDEBUG_DISABLED
-DDEBUG_LEVEL_NONE
board_build.eesz=4M2M
board_build.filesystem = littlefs
upload_port = /dev/cu.SLAB_USBtoUART

Expand All @@ -418,8 +438,9 @@ upload_port = /dev/cu.SLAB_USBtoUART
[env:adafruit_pyportal_m4]
extends = common:atsamd
board = adafruit_pyportal_m4
build_flags = -DUSE_TINYUSB=1
build_flags = -DUSE_TINYUSB
-DADAFRUIT_PYPORTAL
extra_scripts = pre:rename_usb_config.py

; Adafruit PyPortal M4 Titano
[env:adafruit_pyportal_m4_titano]
Expand Down Expand Up @@ -463,17 +484,24 @@ build_flags = -DUSE_TINYUSB
[env:adafruit_metro_m4_airliftlite]
extends = common:atsamd
board = adafruit_metro_m4_airliftlite
build_flags = -DUSE_TINYUSB=1
build_flags = -DUSE_TINYUSB
-DADAFRUIT_METRO_M4_AIRLIFT_LITE
; extra_scripts = pre:rename_usb_config.py
upload_port = /dev/cu.usbmodem1201


[env:raspberypi_picow]
extends = common:rp2040

[env:raspberypi_picow_debug_port_only]
extends = common:rp2040
build_flags =
-DUSE_TINYUSB
-DDEBUG_RP2040_PORT=Serial

[env:raspberypi_picow_debug]
extends = common:rp2040
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
; platform = https://github.com/maxgerhardt/platform-raspberrypi.git
; platform_packages =
; framework-arduinopico @ symlink:///Users/tyeth/Projects/arduino-pico
; framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#master
Expand All @@ -494,7 +522,7 @@ build_flags =
-DDEBUG_RP2040_CORE
-DDEBUG_RP2040_WIFI
-DNDEBUG
-DLWIP_DEBUG
-DLWIP_DEBUG=1
-DDEBUG_RP2040_PORT=Serial1
-DDEBUG_RP2040_UART_1
-DDEBUG_RP2040_UART=1
Expand All @@ -511,3 +539,63 @@ build_flags =
; ; No USB stack
; build_flags = -DPIO_FRAMEWORK_ARDUINO_NO_USB
; -DPIO_FRAMEWORK_ARDUINO_ENABLE_IPV6


[env:raspberypi_pico2w]
extends = common:rp2040
platform = https://github.com/maxgerhardt/platform-raspberrypi.git#develop
platform_packages =
framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git
board = rpipico2w
build_flags =
-DWIFICC=CYW43_COUNTRY_UK
-DUSE_TINYUSB
; -DARDUINO_ARCH_RP2040
; -DUSBD_MAX_POWER_MA=250
; -DPICO_CYW43_SUPPORTED=1

[env:raspberypi_pico2w_debug]
extends = common:rp2040
platform = https://github.com/maxgerhardt/platform-raspberrypi.git#develop
platform_packages =
framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git
; ; framework-arduinopico @ symlink:///Users/tyeth/Projects/arduino-pico
board = rpipico2w
build_type = debug
framework = arduino
debug_tool = cmsis-dap
upload_protocol = cmsis-dap
; board can use both Arduino cores -- we select Arduino-Pico here
board_build.core = earlephilhower
board_build.filesystem_size = 0.5m
debug_init_break = tbreak runNetFSM
build_flags =
; -UARDUINO
; -DPICO_BUILD
-DARDUINO_ARCH_RP2040
-DUSBD_MAX_POWER_MA=250
-DPICO_CYW43_SUPPORTED=1
-DWIFICC=CYW43_COUNTRY_UK
; -DDEBUG
; -DDEBUG_RP2040_WIRE
; -DDEBUG_RP2040_SPI
; -DDEBUG_RP2040_CORE
; -DDEBUG_RP2040_WIFI
; -DNDEBUG
; -DLWIP_DEBUG
; -DDEBUG_RP2040_PORT=Serial1
; -DDEBUG_RP2040_UART_1
; -DDEBUG_RP2040_UART=1
-Og
; Enable debug stack protection
-fstack-protector
; Enable Exceptions
-DPIO_FRAMEWORK_ARDUINO_ENABLE_EXCEPTIONS
; Enable RTTI
-DPIO_FRAMEWORK_ARDUINO_ENABLE_RTTI
; ; Enable default USB Stack of Pico SDK USB Stack with none of below usb options
; Adafruit TinyUSB
-DUSE_TINYUSB
; ; No USB stack
; build_flags = -DPIO_FRAMEWORK_ARDUINO_NO_USB
; -DPIO_FRAMEWORK_ARDUINO_ENABLE_IPV6
36 changes: 27 additions & 9 deletions src/Wippersnapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2494,14 +2494,27 @@ void Wippersnapper::runNetFSM() {
@brief Prints an error to the serial and halts the hardware until
the WDT bites.
@param error
The desired error to print to serial.
The error to print to serial.
@param ledStatusColor
The desired color to blink.
The color to blink.
@param seconds_until_reboot
The amount of time to wait before rebooting.
*/
/**************************************************************************/
void Wippersnapper::haltError(String error, ws_led_status_t ledStatusColor) {
for (;;) {
WS_DEBUG_PRINT("ERROR [WDT RESET]: ");
void Wippersnapper::haltError(String error, ws_led_status_t ledStatusColor,
uint8_t seconds_until_reboot) {
#ifdef ARDUINO_ARCH_ESP8266
uint8_t wdt_timeout_ms = 3200;
#else
uint8_t wdt_timeout_ms = 5000;
#endif
int seconds_until_wdt_enable =
seconds_until_reboot - (int)(wdt_timeout_ms / 1000);

for (int i = 0;; i++) {
WS_DEBUG_PRINT("ERROR [WDT RESET IN ");
WS_DEBUG_PRINT(seconds_until_reboot - i);
WS_DEBUG_PRINTLN("]: ");
WS_DEBUG_PRINTLN(error);
// let the WDT fail out and reset!
statusLEDSolid(ledStatusColor);
Expand All @@ -2512,6 +2525,12 @@ void Wippersnapper::haltError(String error, ws_led_status_t ledStatusColor) {
// hardware and software watchdog timers, delayMicroseconds does not.
delayMicroseconds(1000000);
#endif
if (i < seconds_until_wdt_enable) {
yield();
WS.feedWDT(); // feed the WDT for the first X-5 seconds
} else if (i == seconds_until_reboot) {
WS.enableWDT(wdt_timeout_ms);
}
}
}

Expand Down Expand Up @@ -2748,9 +2767,6 @@ void Wippersnapper::connect() {
// Dump device info to the serial monitor
printDeviceInfo();

// enable global WDT
WS.enableWDT(WS_WDT_TIMEOUT);

// Generate device identifier
if (!generateDeviceUID()) {
haltError("Unable to generate Device UID");
Expand All @@ -2772,7 +2788,9 @@ void Wippersnapper::connect() {
WS_DEBUG_PRINTLN("Running Network FSM...");
// Run the network fsm
runNetFSM();
WS.feedWDT();

// Enable WDT after wifi connection as wifiMulti doesnt feed WDT
WS.enableWDT(WS_WDT_TIMEOUT);

#ifdef USE_DISPLAY
WS._ui_helper->set_load_bar_icon_complete(loadBarIconCloud);
Expand Down
10 changes: 8 additions & 2 deletions src/Wippersnapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,12 @@ typedef enum {
FSM_NET_ESTABLISH_MQTT,
} fsm_net_t;

#define WS_WDT_TIMEOUT 60000 ///< WDT timeout
#ifdef ARDUINO_ARCH_RP2040
#define WS_WDT_TIMEOUT 8388 ///< RP2040 Max WDT timeout
#else
#define WS_WDT_TIMEOUT 60000 ///< WDT timeout
#endif

#define WS_MAX_ALT_WIFI_NETWORKS 3 ///< Maximum number of alternative networks
/* MQTT Configuration */
#define WS_KEEPALIVE_INTERVAL_MS \
Expand Down Expand Up @@ -306,7 +311,8 @@ class Wippersnapper {

// Error handling helpers
void haltError(String error,
ws_led_status_t ledStatusColor = WS_LED_STATUS_ERROR_RUNTIME);
ws_led_status_t ledStatusColor = WS_LED_STATUS_ERROR_RUNTIME,
uint8_t seconds_until_reboot = 25);
void errorWriteHang(String error);

// MQTT topic callbacks //
Expand Down
7 changes: 6 additions & 1 deletion src/Wippersnapper_Boards.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,12 @@
#define BOARD_ID "rpi-pico-w"
#define USE_TINYUSB
#define USE_STATUS_LED
#define STATUS_LED_PIN 32
#define STATUS_LED_PIN LED_BUILTIN
#elif defined(ARDUINO_RASPBERRY_PI_PICO_2W)
#define BOARD_ID "rpi-pico-2w"
#define USE_TINYUSB
#define USE_STATUS_LED
#define STATUS_LED_PIN LED_BUILTIN
#else
#warning "Board type not identified within Wippersnapper_Boards.h!"
#endif
Expand Down
Loading

0 comments on commit 570c166

Please sign in to comment.