Skip to content

Commit

Permalink
[RP2XXX] build is ready for Pico 2W (RP2350+CY43439)
Browse files Browse the repository at this point in the history
  • Loading branch information
lyusupov committed Nov 26, 2024
1 parent b673cc5 commit 6bae831
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 25 deletions.
14 changes: 8 additions & 6 deletions software/firmware/source/SkyView/Platform_RP2040.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ extern "C"
}
#endif /* ARDUINO_ARCH_MBED */

#if !defined(ARDUINO_RASPBERRY_PI_PICO_2)
#if !defined(ARDUINO_RASPBERRY_PI_PICO_2) && \
!defined(ARDUINO_RASPBERRY_PI_PICO_2W)
#include <pico_sleep.h>
#include <pico_rosc.h>
#endif /* ARDUINO_RASPBERRY_PI_PICO_2 */
#endif /* ARDUINO_RASPBERRY_PI_PICO_2 or 2W */

#if defined(USE_TINYUSB)
#if defined(USE_USB_HOST)
Expand Down Expand Up @@ -134,10 +135,10 @@ static union {
#endif /* USE_EXT_I2S_DAC */
#endif /* EXCLUDE_AUDIO */

#if defined(ARDUINO_RASPBERRY_PI_PICO_W)
#if defined(ARDUINO_RASPBERRY_PI_PICO_W) || defined(ARDUINO_RASPBERRY_PI_PICO_2W)
#include <pico/cyw43_arch.h>
#include <boards/pico_w.h>
#endif /* ARDUINO_RASPBERRY_PI_PICO_W */
#endif /* ARDUINO_RASPBERRY_PI_PICO_W or 2W */

Adafruit_INA219 ina219(INA219_ADDRESS_ALT);

Expand Down Expand Up @@ -527,7 +528,8 @@ static void RP2040_fini()
USBDevice.detach();
#endif /* USE_TINYUSB */

#if !defined(ARDUINO_RASPBERRY_PI_PICO_2)
#if !defined(ARDUINO_RASPBERRY_PI_PICO_2) && \
!defined(ARDUINO_RASPBERRY_PI_PICO_2W)
sleep_run_from_xosc();

#if SOC_GPIO_PIN_KEY1 != SOC_UNUSED_PIN
Expand All @@ -545,7 +547,7 @@ static void RP2040_fini()

// back from dormant state
rosc_enable();
#endif /* ARDUINO_RASPBERRY_PI_PICO_2 */
#endif /* ARDUINO_RASPBERRY_PI_PICO_2 or 2W */

#if PICO_SDK_VERSION_MAJOR < 2
clocks_init();
Expand Down
4 changes: 2 additions & 2 deletions software/firmware/source/SkyView/Platform_RP2040.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#ifndef PLATFORM_RP2040_H
#define PLATFORM_RP2040_H

#if defined(ARDUINO_RASPBERRY_PI_PICO_W)
#if defined(ARDUINO_RASPBERRY_PI_PICO_W) || defined(ARDUINO_RASPBERRY_PI_PICO_2W)
#include <WiFi.h>
#include <WiFiClient.h>
#include <WebServer.h>
Expand All @@ -34,7 +34,7 @@ extern WebServer server;
#include <Arduino.h>
#define EXCLUDE_WIFI
#define EXCLUDE_BLUETOOTH
#endif /* ARDUINO_RASPBERRY_PI_PICO_W */
#endif /* ARDUINO_RASPBERRY_PI_PICO_W or 2W */

/* Maximum of tracked flying objects is now SoC-specific constant */
#define MAX_TRACKING_OBJECTS 8
Expand Down
5 changes: 3 additions & 2 deletions software/firmware/source/SkyWatch/Platform_RP2040.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ extern "C"
}
#endif /* ARDUINO_ARCH_MBED */

#if !defined(ARDUINO_RASPBERRY_PI_PICO_2)
#if !defined(ARDUINO_RASPBERRY_PI_PICO_2) && \
!defined(ARDUINO_RASPBERRY_PI_PICO_2W)
#include <pico_sleep.h>
#endif /* ARDUINO_RASPBERRY_PI_PICO_2 */
#endif /* ARDUINO_RASPBERRY_PI_PICO_2 or 2W */

#if defined(USE_TINYUSB)
#if defined(USE_USB_HOST)
Expand Down
4 changes: 2 additions & 2 deletions software/firmware/source/SkyWatch/Platform_RP2040.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#ifndef PLATFORM_RP2040_H
#define PLATFORM_RP2040_H

#if defined(ARDUINO_RASPBERRY_PI_PICO_W)
#if defined(ARDUINO_RASPBERRY_PI_PICO_W) || defined(ARDUINO_RASPBERRY_PI_PICO_2W)
#include <WiFi.h>
#include <WiFiClient.h>
#include <WebServer.h>
Expand All @@ -34,7 +34,7 @@ extern WebServer server;
#include <Arduino.h>
#define EXCLUDE_WIFI
#define EXCLUDE_BLUETOOTH
#endif /* ARDUINO_RASPBERRY_PI_PICO_W */
#endif /* ARDUINO_RASPBERRY_PI_PICO_W or 2W */

/* Maximum of tracked flying objects is now SoC-specific constant */
#define MAX_TRACKING_OBJECTS 9
Expand Down
31 changes: 23 additions & 8 deletions software/firmware/source/SoftRF/src/platform/RP2XXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ extern "C" {
#include "pico/binary_info.h"
}

#if !defined(ARDUINO_RASPBERRY_PI_PICO_2)
#if !defined(ARDUINO_RASPBERRY_PI_PICO_2) && \
!defined(ARDUINO_RASPBERRY_PI_PICO_2W)
#include <pico_sleep.h>
#endif /* ARDUINO_RASPBERRY_PI_PICO_2 */
#endif /* ARDUINO_RASPBERRY_PI_PICO_2 or 2W */
#else
extern "C"
{
Expand Down Expand Up @@ -308,7 +309,9 @@ static void RP2xxx_setup()
SPI1.setRX(SOC_GPIO_PIN_MISO);
SPI1.setTX(SOC_GPIO_PIN_MOSI);
SPI1.setSCK(SOC_GPIO_PIN_SCK);
#if !defined(ARDUINO_RASPBERRY_PI_PICO) && !defined(ARDUINO_RASPBERRY_PI_PICO_W)
#if !defined(ARDUINO_RASPBERRY_PI_PICO) && \
!defined(ARDUINO_RASPBERRY_PI_PICO_W) && \
!defined(ARDUINO_RASPBERRY_PI_PICO_2W)
SPI1.setCS(SOC_GPIO_PIN_SS);
#endif /* ARDUINO_RASPBERRY_PI_PICO or ARDUINO_RASPBERRY_PI_PICO_W */

Expand Down Expand Up @@ -336,6 +339,8 @@ static void RP2xxx_setup()
#endif /* EXCLUDE_WIFI */
#elif defined(ARDUINO_RASPBERRY_PI_PICO_W)
RP2xxx_board = rp2040.isPicoW() ? RP2040_RPIPICO_W : RP2040_RPIPICO;
#elif defined(ARDUINO_RASPBERRY_PI_PICO_2W)
RP2xxx_board = rp2040.isPicoW() ? RP2040_RPIPICO_2W : RP2040_RPIPICO;
#endif /* ARDUINO_RASPBERRY_PI_PICO */

RP2xxx_board = (SoC->getChipId() == 0xcf516424) ?
Expand Down Expand Up @@ -502,7 +507,7 @@ static void RP2xxx_loop()
#endif /* SOC_GPIO_RADIO_LED_RX */
}

#if defined(ARDUINO_RASPBERRY_PI_PICO_W)
#if defined(ARDUINO_RASPBERRY_PI_PICO_W) || defined(ARDUINO_RASPBERRY_PI_PICO_2W)
#include <pico/cyw43_arch.h>
#include <boards/pico_w.h>
#endif /* ARDUINO_RASPBERRY_PI_PICO_W */
Expand All @@ -511,10 +516,12 @@ static void RP2xxx_fini(int reason)
{
Wire.end();

#if defined(ARDUINO_RASPBERRY_PI_PICO_W)
#if defined(ARDUINO_RASPBERRY_PI_PICO_W) || defined(ARDUINO_RASPBERRY_PI_PICO_2W)
if (RP2xxx_board == RP2040_RPIPICO_W) {
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);
#endif
}
#endif /* ARDUINO_RASPBERRY_PI_PICO_W */

Expand Down Expand Up @@ -550,7 +557,9 @@ static void RP2xxx_fini(int reason)
USBDevice.detach();
#endif /* USE_TINYUSB */

#if !defined(ARDUINO_ARCH_MBED) && !defined(ARDUINO_RASPBERRY_PI_PICO_2)
#if !defined(ARDUINO_ARCH_MBED) && \
!defined(ARDUINO_RASPBERRY_PI_PICO_2) && \
!defined(ARDUINO_RASPBERRY_PI_PICO_2W)
sleep_run_from_xosc();

#if SOC_GPIO_PIN_BUTTON != SOC_UNUSED_PIN
Expand Down Expand Up @@ -993,7 +1002,9 @@ static float RP2xxx_Battery_param(uint8_t param)
pin29_func = gpio_get_function(SOC_GPIO_PIN_BATTERY);
adc_gpio_init(SOC_GPIO_PIN_BATTERY);

#if defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_RASPBERRY_PI_PICO_W)
#if defined(ARDUINO_RASPBERRY_PI_PICO) || \
defined(ARDUINO_RASPBERRY_PI_PICO_W) || \
defined(ARDUINO_RASPBERRY_PI_PICO_2W)
pin25_dir = gpio_get_dir(SOC_GPIO_PIN_CYW43_EN);
pin25_func = gpio_get_function(SOC_GPIO_PIN_CYW43_EN);
pinMode(SOC_GPIO_PIN_CYW43_EN, OUTPUT);
Expand All @@ -1004,7 +1015,9 @@ static float RP2xxx_Battery_param(uint8_t param)
mV = (analogRead(SOC_GPIO_PIN_BATTERY) * 3300UL) >> 12;

if (RP2xxx_board == RP2040_RPIPICO_W) {
#if defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_RASPBERRY_PI_PICO_W)
#if defined(ARDUINO_RASPBERRY_PI_PICO) || \
defined(ARDUINO_RASPBERRY_PI_PICO_W) || \
defined(ARDUINO_RASPBERRY_PI_PICO_2W)
gpio_set_function(SOC_GPIO_PIN_CYW43_EN, pin25_func);
gpio_set_dir(SOC_GPIO_PIN_CYW43_EN, pin25_dir);
#endif /* PICO or PICO W */
Expand Down Expand Up @@ -1354,6 +1367,8 @@ void setup1() {
pio_cfg.pio_rx_num = 0;
pio_cfg.pio_tx_num = 1;
pio_cfg.tx_ch = 9;
#elif defined(ARDUINO_RASPBERRY_PI_PICO_2W)
/* TBD */
#endif /* ARDUINO_RASPBERRY_PI_PICO_W */

USBHost.configure_pio_usb(1, &pio_cfg);
Expand Down
13 changes: 8 additions & 5 deletions software/firmware/source/SoftRF/src/platform/RP2XXX.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ enum RP2xxx_board_id {
RP2040_RPIPICO_W,
RP2040_WEACT,
RP2350_RPIPICO_2,
RP2040_RPIPICO_2W,
};

struct rst_info {
Expand Down Expand Up @@ -154,9 +155,10 @@ struct rst_info {

#define SOC_ADC_VOLTAGE_DIV (5.0 / 3)

#elif defined(ARDUINO_RASPBERRY_PI_PICO) || \
defined(ARDUINO_RASPBERRY_PI_PICO_2) || \
defined(ARDUINO_RASPBERRY_PI_PICO_W) || \
#elif defined(ARDUINO_RASPBERRY_PI_PICO) || \
defined(ARDUINO_RASPBERRY_PI_PICO_2) || \
defined(ARDUINO_RASPBERRY_PI_PICO_W) || \
defined(ARDUINO_RASPBERRY_PI_PICO_2W) || \
defined(ARDUINO_NANO_RP2040_CONNECT)

/* Console I/O */
Expand Down Expand Up @@ -228,7 +230,8 @@ struct rst_info {
#error "This RP2040 build variant is not supported!"
#endif

#if defined(ARDUINO_RASPBERRY_PI_PICO_W)
#if defined(ARDUINO_RASPBERRY_PI_PICO_W) || \
defined(ARDUINO_RASPBERRY_PI_PICO_2W)
#define EXCLUDE_OTA
#define USE_WIFI_NINA false
#define USE_WIFI_CUSTOM true
Expand Down Expand Up @@ -268,7 +271,7 @@ struct rst_info {
#define EXCLUDE_BLUETOOTH
#endif /* ARDUINO_NANO_RP2040_CONNECT */
#endif /* ARDUINO_ARCH_MBED */
#endif /* ARDUINO_RASPBERRY_PI_PICO_W */
#endif /* ARDUINO_RASPBERRY_PI_PICO_W or 2W */

#define EXCLUDE_CC13XX
#define EXCLUDE_TEST_MODE
Expand Down

0 comments on commit 6bae831

Please sign in to comment.