Skip to content

Commit

Permalink
[RP2350] more of SkyView Pico build infra
Browse files Browse the repository at this point in the history
  • Loading branch information
lyusupov committed Jan 21, 2025
1 parent 42b710e commit 5259ffb
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 25 deletions.
33 changes: 22 additions & 11 deletions software/firmware/source/SkyView/Platform_RP2XXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,17 @@ static void RP2xxx_setup()
#endif /* ARDUINO_ARCH_MBED */

#if defined(ARDUINO_RASPBERRY_PI_PICO_W)
RP2xxx_board = rp2040.isPicoW() ? RP2040_RPIPICO_W : RP2xxx_board;
RP2xxx_board = rp2040.isPicoW() ? RP2040_RPIPICO_W : RP2xxx_board;
#elif defined(ARDUINO_RASPBERRY_PI_PICO_2W)
RP2xxx_board = rp2040.isPicoW() ? RP2350_RPIPICO_2W : RP2xxx_board;
#endif /* ARDUINO_RASPBERRY_PI_PICO_W */

RP2xxx_board = (SoC->getChipId() == 0xcf516424) ? RP2040_WEACT : RP2xxx_board;

hw_info.revision = RP2xxx_board == RP2040_RPIPICO_W ? HW_REV_PICO_W : HW_REV_PICO;
hw_info.revision = RP2xxx_board == RP2040_RPIPICO_W ? HW_REV_PICO_W :
RP2xxx_board == RP2350_RPIPICO_2 ? HW_REV_PICO_2 :
RP2xxx_board == RP2350_RPIPICO_2W ? HW_REV_PICO_2W :
HW_REV_PICO;

#if !defined(ARDUINO_ARCH_MBED)
RP2xxx_has_spiflash = SPIFlash->begin(possible_devices,
Expand Down Expand Up @@ -327,7 +332,8 @@ static void RP2xxx_setup()
ina219.setCalibration_16V_400mA();
}

pin_size_t pin_LED = RP2xxx_board == RP2040_RPIPICO_W ?
pin_size_t pin_LED = RP2xxx_board == RP2040_RPIPICO_W ||
RP2xxx_board == RP2350_RPIPICO_2W ?
SOC_GPIO_PIN_LED_W : SOC_GPIO_PIN_LED;
pinMode(pin_LED, OUTPUT);
/* Indicate positive power supply */
Expand All @@ -340,6 +346,7 @@ static void RP2xxx_setup()
pinMode(SOC_GPIO_PIN_VBUS, INPUT);
break;
case RP2040_RPIPICO_W:
case RP2350_RPIPICO_2W:
pinMode(SOC_GPIO_PIN_VBUS_W, INPUT);
break;
case RP2040_WEACT:
Expand Down Expand Up @@ -393,6 +400,7 @@ static void RP2xxx_post_init()
switch (RP2xxx_board)
{
case RP2040_RPIPICO_W : Serial.println(F("Pico W")); break;
case RP2350_RPIPICO_2W : Serial.println(F("Pico 2W")); break;
case RP2040_WEACT : Serial.println(F("WeAct")); break;
case RP2040_RPIPICO :
default : Serial.println(F("Pico")); break;
Expand Down Expand Up @@ -455,7 +463,8 @@ static void RP2xxx_loop()

if (isTimeToToggle()) {
bool vbus_is_on = false;
pin_size_t pin_LED = RP2xxx_board == RP2040_RPIPICO_W ?
pin_size_t pin_LED = RP2xxx_board == RP2040_RPIPICO_W ||
RP2xxx_board == RP2350_RPIPICO_2W ?
SOC_GPIO_PIN_LED_W : SOC_GPIO_PIN_LED;

switch (RP2xxx_board)
Expand All @@ -464,6 +473,7 @@ static void RP2xxx_loop()
vbus_is_on = digitalRead(SOC_GPIO_PIN_VBUS);
break;
case RP2040_RPIPICO_W:
case RP2350_RPIPICO_2W:
if (RP2xxx_board != RP2040_RPIPICO_W || settings->connection != CON_USB) {
vbus_is_on = digitalRead(SOC_GPIO_PIN_VBUS_W);
}
Expand Down Expand Up @@ -499,12 +509,13 @@ static void RP2xxx_fini()
pinMode(SOC_GPIO_PIN_PWM_OUT, INPUT);
#endif /* EXCLUDE_AUDIO */

pin_size_t pin_LED = RP2xxx_board == RP2040_RPIPICO_W ?
pin_size_t pin_LED = RP2xxx_board == RP2040_RPIPICO_W ||
RP2xxx_board == RP2350_RPIPICO_2W ?
SOC_GPIO_PIN_LED_W : SOC_GPIO_PIN_LED;
pinMode(pin_LED, INPUT);

#if defined(ARDUINO_RASPBERRY_PI_PICO_W)
if (RP2xxx_board == RP2040_RPIPICO_W) {
#if defined(ARDUINO_RASPBERRY_PI_PICO_W) || defined(ARDUINO_RASPBERRY_PI_PICO_2W)
if (RP2xxx_board == RP2040_RPIPICO_W || RP2xxx_board == RP2350_RPIPICO_2W) {
if (cyw43_is_initialized(&cyw43_state)) cyw43_arch_deinit();
#if !(ARDUINO_PICO_MAJOR == 4 && ARDUINO_PICO_MINOR == 3 && ARDUINO_PICO_REVISION == 0)
pinMode(CYW43_PIN_WL_REG_ON, INPUT_PULLDOWN);
Expand Down Expand Up @@ -608,7 +619,7 @@ static void RP2xxx_EEPROM_extension(int cmd)
}
}

if (RP2xxx_board != RP2040_RPIPICO_W &&
if (RP2xxx_board != RP2040_RPIPICO_W && RP2xxx_board != RP2350_RPIPICO_2W &&
(settings->connection == CON_BLUETOOTH_SPP ||
settings->connection == CON_BLUETOOTH_LE)) {
settings->connection = CON_USB; /* matches EEPROMHelper.cpp default value */
Expand All @@ -627,7 +638,7 @@ static bool RP2xxx_WiFi_hostname(String aHostname)
{
bool rval = false;
#if !defined(EXCLUDE_WIFI)
if (RP2xxx_board == RP2040_RPIPICO_W) {
if (RP2xxx_board == RP2040_RPIPICO_W || RP2xxx_board == RP2350_RPIPICO_2W) {
WiFi.hostname(aHostname.c_str());
rval = true;
}
Expand Down Expand Up @@ -690,7 +701,7 @@ static float RP2xxx_Battery_voltage()
uint pin25_dir;
uint pin29_dir;

if (RP2xxx_board == RP2040_RPIPICO_W) {
if (RP2xxx_board == RP2040_RPIPICO_W || RP2xxx_board == RP2350_RPIPICO_2W) {
pin29_dir = gpio_get_dir(SOC_GPIO_PIN_BATTERY);
pin29_func = gpio_get_function(SOC_GPIO_PIN_BATTERY);
adc_gpio_init(SOC_GPIO_PIN_BATTERY);
Expand All @@ -703,7 +714,7 @@ static float RP2xxx_Battery_voltage()

mV = (analogRead(SOC_GPIO_PIN_BATTERY) * 3300UL) >> 12;

if (RP2xxx_board == RP2040_RPIPICO_W) {
if (RP2xxx_board == RP2040_RPIPICO_W || RP2xxx_board == RP2350_RPIPICO_2W) {
gpio_set_function(SOC_GPIO_PIN_CYW43_EN, pin25_func);
gpio_set_dir(SOC_GPIO_PIN_CYW43_EN, pin25_dir);
gpio_set_function(SOC_GPIO_PIN_BATTERY, pin29_func);
Expand Down
8 changes: 5 additions & 3 deletions software/firmware/source/SkyView/Platform_RP2XXX.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ enum RP2xxx_board_id {
#define SOC_GPIO_PIN_CYW43_EN (25u) // Pico W
#define SOC_GPIO_PIN_VSYS (29u) // Pico/Pico W
#define SOC_GPIO_PIN_BATTERY SOC_GPIO_PIN_VSYS
#define SOC_GPIO_PIN_LED_W (32u) // Pico W (CYW43 GPIO 0)
#define SOC_GPIO_PIN_SMPS_W (33u) // Pico W (CYW43 GPIO 1)
#define SOC_GPIO_PIN_VBUS_W (34u) // Pico W (CYW43 GPIO 2)
#define SOC_GPIO_PIN_LED_W (64u) // Pico W (CYW43 GPIO 0)
#define SOC_GPIO_PIN_SMPS_W (65u) // Pico W (CYW43 GPIO 1)
#define SOC_GPIO_PIN_VBUS_W (66u) // Pico W (CYW43 GPIO 2)

//#define EXCLUDE_AUDIO

Expand Down Expand Up @@ -144,7 +144,9 @@ enum RP2xxx_board_id {
//#define USE_EXT_I2S_DAC
#endif /* EXCLUDE_AUDIO */
#if defined(USE_TINYUSB) // && !defined(USE_EXT_I2S_DAC)
#if !defined(PICO_RP2350)
#define USE_USB_HOST
#endif /* PICO_RP2350 */
#endif /* USE_TINYUSB */

#endif /* PLATFORM_RP2XXX_H */
Expand Down
2 changes: 2 additions & 0 deletions software/firmware/source/SkyView/SkyView.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ enum
HW_REV_T5_1,
HW_REV_PICO,
HW_REV_PICO_W,
HW_REV_PICO_2,
HW_REV_PICO_2W,
HW_REV_BPI,
};

Expand Down
31 changes: 21 additions & 10 deletions software/firmware/source/SkyView/WebHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ void handleSettings() {
(settings->adapter == ADAPTER_NODEMCU ? "selected" : ""), ADAPTER_NODEMCU,
(settings->adapter == ADAPTER_WAVESHARE_ESP8266 ? "selected" : ""), ADAPTER_WAVESHARE_ESP8266
);
} else if (SoC->id == SOC_RP2040 || SoC->id == SOC_ESP32S3) {
} else if (SoC->id == SOC_RP2040 || SoC->id == SOC_RP2350_ARM ||
SoC->id == SOC_RP2350_RISC || SoC->id == SOC_ESP32S3) {
snprintf_P ( offset, size,
PSTR("\
<tr>\
Expand Down Expand Up @@ -207,7 +208,9 @@ void handleSettings() {
size -= len;

/* SoC specific part 2 */
if (SoC->id != SOC_RP2040 /* || WiFi.getMode() != WIFI_AP */) {
if (SoC->id != SOC_RP2040 &&
SoC->id != SOC_RP2350_RISC &&
SoC->id != SOC_RP2350_ARM /* || WiFi.getMode() != WIFI_AP */) {
snprintf_P ( offset, size, PSTR("<option %s value='%d'>WiFi UDP</option>"),
(settings->connection == CON_WIFI_UDP ? "selected" : ""), CON_WIFI_UDP);
len = strlen(offset);
Expand All @@ -216,7 +219,8 @@ void handleSettings() {
}

/* SoC specific part 3 */
if (SoC->id == SOC_ESP32 || SoC->id == SOC_RP2040) {
if (SoC->id == SOC_ESP32 || SoC->id == SOC_RP2040 ||
SoC->id == SOC_RP2350_RISC || SoC->id == SOC_RP2350_ARM) {
snprintf_P ( offset, size, PSTR("<option %s value='%d'>Bluetooth SPP</option>"),
(settings->connection == CON_BLUETOOTH_SPP ? "selected" : ""), CON_BLUETOOTH_SPP);
len = strlen(offset);
Expand All @@ -225,9 +229,10 @@ void handleSettings() {
}

/* SoC specific part 4 */
if (SoC->id == SOC_ESP32 || SoC->id == SOC_ESP32S3 ||
SoC->id == SOC_ESP32C3 || SoC->id == SOC_ESP32C6 ||
SoC->id == SOC_RP2040) {
if (SoC->id == SOC_ESP32 || SoC->id == SOC_ESP32S3 ||
SoC->id == SOC_ESP32C3 || SoC->id == SOC_ESP32C6 ||
SoC->id == SOC_RP2040 || SoC->id == SOC_RP2350_RISC ||
SoC->id == SOC_RP2350_ARM) {
snprintf_P ( offset, size, PSTR("<option %s value='%d'>Bluetooth LE</option>"),
(settings->connection == CON_BLUETOOTH_LE ? "selected" : ""), CON_BLUETOOTH_LE);
len = strlen(offset);
Expand All @@ -236,7 +241,9 @@ void handleSettings() {
}

/* SoC specific part 5 */
if (SoC->id == SOC_RP2040) {
if (SoC->id == SOC_RP2040 ||
SoC->id == SOC_RP2350_RISC ||
SoC->id == SOC_RP2350_ARM) {
snprintf_P ( offset, size, PSTR("<option %s value='%d'>USB</option>"),
(settings->connection == CON_USB ? "selected" : ""), CON_USB);
len = strlen(offset);
Expand Down Expand Up @@ -284,7 +291,8 @@ void handleSettings() {
/* SoC specific part 6 */
if (SoC->id == SOC_ESP32 || SoC->id == SOC_ESP32S2 ||
SoC->id == SOC_ESP32S3 || SoC->id == SOC_ESP32C3 ||
SoC->id == SOC_ESP32C6 || SoC->id == SOC_RP2040) {
SoC->id == SOC_ESP32C6 || SoC->id == SOC_RP2040 ||
SoC->id == SOC_RP2350_RISC || SoC->id == SOC_RP2350_ARM) {
snprintf_P ( offset, size,
PSTR("\
<option %s value='%d'>115200</option>\
Expand Down Expand Up @@ -462,7 +470,8 @@ void handleSettings() {
len = strlen(offset);
offset += len;
size -= len;
} else if (SoC->id == SOC_ESP32S3 || SoC->id == SOC_RP2040) {
} else if (SoC->id == SOC_ESP32S3 || SoC->id == SOC_RP2040 ||
SoC->id == SOC_RP2350_RISC || SoC->id == SOC_RP2350_ARM) {
snprintf_P ( offset, size,
PSTR("\
<tr>\
Expand Down Expand Up @@ -680,7 +689,9 @@ void handleRoot() {
size -= len;

/* SoC specific part 5 */
if (SoC->id != SOC_RP2040) {
if (SoC->id != SOC_RP2040 &&
SoC->id != SOC_RP2350_RISC &&
SoC->id != SOC_RP2350_ARM) {
snprintf_P ( offset, size, PSTR("\
<td align=right><input type=button onClick=\"location.href='/firmware'\" value='Firmware update'></td>"));
len = strlen(offset);
Expand Down
2 changes: 1 addition & 1 deletion software/firmware/source/SoftRF/src/platform/RP2XXX.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ struct rst_info {
#define SOC_GPIO_PIN_BUTTON (23u) // WeAct
#define SOC_GPIO_PIN_CYW43_EN (25u) // Pico W

#define SOC_GPIO_PIN_STATUS PIN_LED // Pico/WeAct - 25, W - 32 (CYW43 GPIO 0)
#define SOC_GPIO_PIN_STATUS PIN_LED // Pico/WeAct - 25, W - 64 (CYW43 GPIO 0)
#define SOC_GPIO_PIN_BATTERY SOC_GPIO_PIN_VSYS
#define SOC_GPIO_PIN_BUZZER SOC_UNUSED_PIN

Expand Down

0 comments on commit 5259ffb

Please sign in to comment.