Skip to content

Commit

Permalink
pico2: work around for not being able to detect wifi version of Pico2…
Browse files Browse the repository at this point in the history
… at runtime
  • Loading branch information
erichelgeson committed Dec 5, 2024
1 parent 30b42b9 commit bfffd38
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
29 changes: 29 additions & 0 deletions lib/BlueSCSI_platform_RP2040/BlueSCSI_platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 2 additions & 4 deletions lib/BlueSCSI_platform_RP2040/BlueSCSI_platform_network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#include "BlueSCSI_platform.h"
#include "BlueSCSI_log.h"
#include "BlueSCSI_config.h"
#include <scsi.h>
#include <network.h>

Expand All @@ -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
Expand Down

0 comments on commit bfffd38

Please sign in to comment.