diff --git a/lib/BlueSCSI_platform_RP2040/BlueSCSI_platform.cpp b/lib/BlueSCSI_platform_RP2040/BlueSCSI_platform.cpp index 2615b491..82a0abfe 100644 --- a/lib/BlueSCSI_platform_RP2040/BlueSCSI_platform.cpp +++ b/lib/BlueSCSI_platform_RP2040/BlueSCSI_platform.cpp @@ -85,6 +85,31 @@ static void gpio_conf(uint gpio, gpio_function_t fn, bool pullup, bool pulldown, } } +# ifndef PICO_RP2040 +/** + * This is a workaround until arduino framework can be updated to handle all 4 variations of + * Pico1/1w/2/2w. In testing this works on all for BlueSCSI. + * Tracking here https://github.com/earlephilhower/arduino-pico/issues/2671 + */ +static void CheckPicoW() { + extern bool __isPicoW; + adc_init(); + auto dir = gpio_get_dir(CYW43_PIN_WL_CLOCK); + auto fnc = gpio_get_function(CYW43_PIN_WL_CLOCK); + adc_gpio_init(CYW43_PIN_WL_CLOCK); + adc_select_input(3); + auto adc29 = adc_read(); + gpio_set_function(CYW43_PIN_WL_CLOCK, fnc); + gpio_set_dir(CYW43_PIN_WL_CLOCK, dir); + debuglog("CheckPicoW adc29: %d", adc29); + if (adc29 < 200) { + __isPicoW = true; // PicoW || Pico2W + } else { + __isPicoW = false; + } +} +#endif + #ifdef ENABLE_AUDIO_OUTPUT // Increases clk_sys and clk_peri to 135.428571MHz at runtime to support // division to audio output rates. Invoke before anything is using clk_peri @@ -220,6 +245,10 @@ void platform_init() gpio_conf(SDIO_D1, GPIO_FUNC_SIO, true, false, false, true, true); gpio_conf(SDIO_D2, GPIO_FUNC_SIO, true, false, false, true, true); +# ifndef PICO_RP2040 + CheckPicoW(); // Override default Wi-Fi check for the Pico2 line. +# endif + if (!platform_network_supported()) { // LED pin gpio_conf(LED_PIN, GPIO_FUNC_SIO, false,false, true, false, false); diff --git a/lib/BlueSCSI_platform_RP2040/BlueSCSI_platform_network.cpp b/lib/BlueSCSI_platform_RP2040/BlueSCSI_platform_network.cpp index 17256787..33edaea3 100644 --- a/lib/BlueSCSI_platform_RP2040/BlueSCSI_platform_network.cpp +++ b/lib/BlueSCSI_platform_RP2040/BlueSCSI_platform_network.cpp @@ -16,7 +16,6 @@ #include "BlueSCSI_platform.h" #include "BlueSCSI_log.h" -#include "BlueSCSI_config.h" #include #include @@ -37,9 +36,8 @@ static bool network_in_use = false; bool __not_in_flash_func(platform_network_supported)() { - // FIXME: This method currently incorrectly returns true on the Pico2 (non-wifi) - // Track here: https://github.com/earlephilhower/arduino-pico/issues/2671 - return rp2040.isPicoW(); + extern bool __isPicoW; + return __isPicoW; } #ifdef BLUESCSI_NETWORK