Skip to content

adding rp2350 adalogger #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
269 changes: 267 additions & 2 deletions boards.txt

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions cores/rp2040/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,23 @@
#include "RP2040Version.h"
#include "api/ArduinoAPI.h"
#include "api/itoa.h" // ARM toolchain doesn't provide itoa etc, provide them
#include <pico.h>
#undef PICO_RP2350A // Set in the RP2350 SDK boards file, overridden in the variant pins_arduino.h
#include <pins_arduino.h>
#include <hardware/gpio.h> // Required for the port*Register macros
#include "debug_internal.h"

// Chip sanity checking. SDK uses interesting way of separating 2350A from 2350B, see https://github.com/raspberrypi/pico-sdk/issues/2364
#if (!defined(PICO_RP2040) && !defined(PICO_RP2350)) || defined(PICO_RP2040) && defined(PICO_RP2350)
#error Invalid core definition. Either PICO_RP2040 or PICO_RP2350 must be defined.
#endif
#if defined(PICO_RP2350) && !defined(PICO_RP2350A)
#error Invalid RP2350 definition. Need to set PICO_RP2350A=0/1 for A/B variant
#endif
#if defined(PICO_RP2350B)
#error Do not define PICO_RP2350B. Use PICO_RP2350A=0 to indicate RP2350B. See the SDK for more details
#endif

// Try and make the best of the old Arduino abs() macro. When in C++, use
// the sane std::abs() call, but for C code use their macro since stdlib abs()
// is int but their macro "works" for everything (with potential side effects)
Expand Down
1 change: 1 addition & 0 deletions cores/rp2040/IPAddress.h
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include "api/IPAddress.h"
using arduino::IPAddress;
10 changes: 5 additions & 5 deletions cores/rp2040/SerialUART.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ extern void serialEvent1() __attribute__((weak));
extern void serialEvent2() __attribute__((weak));

bool SerialUART::setRX(pin_size_t pin) {
#if defined(PICO_RP2350B)
#if defined(PICO_RP2350) && !PICO_RP2350A // RP2350B
constexpr uint64_t valid[2] = { __bitset({1, 3, 13, 15, 17, 19, 29, 31, 33, 35, 45, 47}) /* UART0 */,
__bitset({5, 7, 9, 11, 21, 23, 25, 27, 37, 39, 41, 43}) /* UART1 */
};
Expand Down Expand Up @@ -64,7 +64,7 @@ bool SerialUART::setRX(pin_size_t pin) {
}

bool SerialUART::setTX(pin_size_t pin) {
#if defined(PICO_RP2350B)
#if defined(PICO_RP2350) && !PICO_RP2350A // RP2350B
constexpr uint64_t valid[2] = { __bitset({0, 2, 12, 14, 16, 18, 28, 30, 32, 34, 44, 46}) /* UART0 */,
__bitset({4, 6, 8, 10, 20, 22, 24, 26, 36, 38, 40, 42}) /* UART1 */
};
Expand Down Expand Up @@ -95,7 +95,7 @@ bool SerialUART::setTX(pin_size_t pin) {
}

bool SerialUART::setRTS(pin_size_t pin) {
#ifdef PICO_RP2350B
#if defined(PICO_RP2350) && !PICO_RP2350A // RP2350B
constexpr uint64_t valid[2] = { __bitset({3, 15, 19, 31, 35, 47}) /* UART0 */,
__bitset({7, 11, 23, 27, 39, 43}) /* UART1 */
};
Expand All @@ -122,7 +122,7 @@ bool SerialUART::setRTS(pin_size_t pin) {
}

bool SerialUART::setCTS(pin_size_t pin) {
#ifdef PICO_RP2350B
#if defined(PICO_RP2350) && !PICO_RP2350A // RP2350B
constexpr uint64_t valid[2] = { __bitset({2, 14, 18, 30, 34, 46}) /* UART0 */,
__bitset({6, 10, 22, 26, 38, 42}) /* UART1 */
};
Expand Down Expand Up @@ -182,7 +182,7 @@ static void _uart1IRQ();
// Does the selected TX/RX need UART_AUX function (rp2350)
static gpio_function_t __gpioFunction(int pin) {
switch (pin) {
#if defined(PICO_RP2350) || defined(PICO_RP2350B)
#if defined(PICO_RP2350) && !PICO_RP2350A
case 2:
case 3:
case 6:
Expand Down
13 changes: 7 additions & 6 deletions docs/adc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ need to be periodically sampled to be read by applications, easily, such as:
* Light dependent resistors (LDR), etc.


Up to 4 analog samples can be recorded by the hardware (``A0`` ... ``A3``), and all
recording is done at 16-bit levels (but be aware that the ADC in the Pico will only
ever return values between 0...4095).
Up to 4 (or 8 in the case of the RP2350B) analog samples can be recorded by the
hardware (``A0`` ... ``A3``), and all recording is done at 16-bit levels (but be
aware that the ADC in the Pico will only ever return values between 0...4095).

The interface for the ``ADCInput`` device is very similar to the ``I2S`` input
device, and most code can be ported simply by instantiating a ``ADCInput``
Expand All @@ -26,11 +26,12 @@ allowed while in use.
ADC Input API
-------------

ADCInput(pin0 [, pin1, pin2, pin3])
ADCInput(pin0 [, pin1, pin2, pin3[, pin4, pin5, pin6, pin7])
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Creates an ADC input object which will record the pins specified in the code.
Only pins ``A0`` ... ``A3`` can be used, and they must be specified in increasing
order (i.e. ``ADCInput(A0, A1);`` is valid, but ``ADCInput(A1, A0)`` is not.
Only pins ``A0`` ... ``A3`` (``A7`` on RP2350B) can be used, and they must be
specified in increasing order (i.e. ``ADCInput(A0, A1);`` is valid,
but ``ADCInput(A1, A0)`` is not.

bool setBuffers(size_t buffers, size_t bufferWords)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
4 changes: 2 additions & 2 deletions docs/contrib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ For only RP2350A variants (using the compile options, not the onboard ID registe

.. code:: cpp

#if defined(PICO_RP2350) && !defined(PICO_RP2350B)
#if defined(PICO_RP2350A) && PICO_RP2350A
...RP2350A only code...
#endif

Expand All @@ -121,7 +121,7 @@ and not the chip ID register):

.. code:: cpp

#if defined(PICO_RP2350B)
#if defined(PICO_RP2350A) && !PICO_RP2350A
...48-GPIO version code here
#endif

Expand Down
4 changes: 2 additions & 2 deletions libraries/ADCInput/src/ADCInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ bool ADCInput::setBuffers(size_t buffers, size_t bufferWords) {

int ADCInput::_mask(pin_size_t p) {
switch (p) {
#if !defined(PICO_RP2350B)
#if defined(PICO_RP2350) && !PICO_RP2350A // RP2350B
case 26: return 1;
case 27: return 2;
case 28: return 4;
Expand Down Expand Up @@ -106,7 +106,7 @@ bool ADCInput::begin() {
// Set up the GPIOs to go to ADC
adc_init();
int cnt = 0;
#if !defined(PICO_RP2350B)
#if defined(PICO_RP2350) && !PICO_RP2350A // RP2350B
int startpin = 26;
int maxpin = 29;
#else
Expand Down
8 changes: 4 additions & 4 deletions libraries/SPI/src/SPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ void SPIClassRP2040::abortAsync() {


bool SPIClassRP2040::setRX(pin_size_t pin) {
#ifdef PICO_RP2350B
#if defined(PICO_RP2350) && !PICO_RP2350A // RP2350B
constexpr uint64_t valid[2] = { __bitset({0, 4, 16, 20, 32, 26}) /* SPI0 */,
__bitset({8, 12, 24, 28, 40, 44}) /* SPI1 */
};
Expand All @@ -290,7 +290,7 @@ bool SPIClassRP2040::setRX(pin_size_t pin) {
}

bool SPIClassRP2040::setCS(pin_size_t pin) {
#ifdef PICO_RP2350B
#if defined(PICO_RP2350) && !PICO_RP2350A // RP2350B
constexpr uint64_t valid[2] = { __bitset({1, 5, 17, 21, 33, 37}) /* SPI0 */,
__bitset({9, 13, 25, 29, 41, 45}) /* SPI1 */
};
Expand All @@ -317,7 +317,7 @@ bool SPIClassRP2040::setCS(pin_size_t pin) {
}

bool SPIClassRP2040::setSCK(pin_size_t pin) {
#ifdef PICO_RP2350B
#if defined(PICO_RP2350) && !PICO_RP2350A // RP2350B
constexpr uint64_t valid[2] = { __bitset({2, 6, 18, 22, 34, 38}) /* SPI0 */,
__bitset({10, 14, 26, 30, 42, 46}) /* SPI1 */
};
Expand All @@ -344,7 +344,7 @@ bool SPIClassRP2040::setSCK(pin_size_t pin) {
}

bool SPIClassRP2040::setTX(pin_size_t pin) {
#ifdef PICO_RP2350B
#if defined(PICO_RP2350) && !PICO_RP2350A // RP2350B
constexpr uint64_t valid[2] = { __bitset({3, 7, 19, 23, 35, 39}) /* SPI0 */,
__bitset({11, 15, 27, 31, 43, 47}) /* SPI1 */
};
Expand Down
2 changes: 1 addition & 1 deletion libraries/SPI/src/SPIHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class SPIHelper {
return (reverseByte(w & 0xff) << 8) | (reverseByte(w >> 8));
}

#ifdef PICO_RP2350B
#if defined(PICO_RP2350) && !PICO_RP2350A // RP2350B
static constexpr int GPIOIRQREGS = 6;
#else
static constexpr int GPIOIRQREGS = 4;
Expand Down
8 changes: 4 additions & 4 deletions libraries/SPISlave/src/SPISlave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ inline spi_cpha_t SPISlaveClass::cpha(SPISettings _spis) {
}

bool SPISlaveClass::setRX(pin_size_t pin) {
#ifdef PICO_RP2350B
#if defined(PICO_RP2350) && !PICO_RP2350A // RP2350B
constexpr uint64_t valid[2] = { __bitset({0, 4, 16, 20, 32, 26}) /* SPI0 */,
__bitset({8, 12, 24, 28, 40, 44}) /* SPI1 */
};
Expand All @@ -106,7 +106,7 @@ bool SPISlaveClass::setRX(pin_size_t pin) {
}

bool SPISlaveClass::setCS(pin_size_t pin) {
#ifdef PICO_RP2350B
#if defined(PICO_RP2350) && !PICO_RP2350A // RP2350B
constexpr uint64_t valid[2] = { __bitset({1, 5, 17, 21, 33, 37}) /* SPI0 */,
__bitset({9, 13, 25, 29, 41, 45}) /* SPI1 */
};
Expand All @@ -133,7 +133,7 @@ bool SPISlaveClass::setCS(pin_size_t pin) {
}

bool SPISlaveClass::setSCK(pin_size_t pin) {
#ifdef PICO_RP2350B
#if defined(PICO_RP2350) && !PICO_RP2350A // RP2350B
constexpr uint64_t valid[2] = { __bitset({2, 6, 18, 22, 34, 38}) /* SPI0 */,
__bitset({10, 14, 26, 30, 42, 46}) /* SPI1 */
};
Expand All @@ -160,7 +160,7 @@ bool SPISlaveClass::setSCK(pin_size_t pin) {
}

bool SPISlaveClass::setTX(pin_size_t pin) {
#ifdef PICO_RP2350B
#if defined(PICO_RP2350) && !PICO_RP2350A // RP2350B
constexpr uint64_t valid[2] = { __bitset({3, 7, 19, 23, 35, 39}) /* SPI0 */,
__bitset({11, 15, 27, 31, 43, 47}) /* SPI1 */
};
Expand Down
4 changes: 2 additions & 2 deletions libraries/Wire/src/Wire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ TwoWire::TwoWire(i2c_inst_t *i2c, pin_size_t sda, pin_size_t scl) {
}

bool TwoWire::setSDA(pin_size_t pin) {
#ifdef PICO_RP2350B
#if defined(PICO_RP2350) && !PICO_RP2350A // RP2350B
constexpr uint64_t valid[2] = { __bitset({0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44}) /* I2C0 */,
__bitset({2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46}) /* I2C1 */
};
Expand All @@ -76,7 +76,7 @@ bool TwoWire::setSDA(pin_size_t pin) {
}

bool TwoWire::setSCL(pin_size_t pin) {
#ifdef PICO_RP2350B
#if defined(PICO_RP2350) && !PICO_RP2350A // RP2350B
constexpr uint64_t valid[2] = { __bitset({1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45}) /* I2C0 */,
__bitset({3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47}) /* I2C1 */
};
Expand Down
2 changes: 1 addition & 1 deletion libraries/lwIP_Ethernet/src/LwipEthernet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void __removeEthernetPacketHandler(int id) {
}

#define GPIOSTACKSIZE 8
#ifdef PICO_RP2350B
#if defined(PICO_RP2350) && !PICO_RP2350A // RP2350B
#define GPIOIRQREGS 6
#define GPIOIRQREGSINIT 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff
#else
Expand Down
3 changes: 3 additions & 0 deletions package/package_pico_index.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@
{
"name": "Adafruit KB2040"
},
{
"name": "Adafruit Feather RP2350 Adalogger"
},
{
"name": "Adafruit Feather RP2350 HSTX"
},
Expand Down
55 changes: 55 additions & 0 deletions tools/json/adafruit_feather_rp2350_adalogger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"build": {
"arduino": {
"earlephilhower": {
"boot2_source": "none.S",
"usb_vid": "0x239A",
"usb_pid": "0x816D"
}
},
"core": "earlephilhower",
"cpu": "cortex-m33",
"extra_flags": "-DARDUINO_ADAFRUIT_FEATHER_RP2350_ADALOGGER -DARDUINO_ARCH_RP2040 -DUSBD_MAX_POWER_MA=250 ",
"f_cpu": "150000000L",
"hwids": [
[
"0x2E8A",
"0x00C0"
],
[
"0x239A",
"0x816D"
]
],
"mcu": "rp2350",
"variant": "adafruit_feather_rp2350_adalogger"
},
"debug": {
"jlink_device": "RP2350_0",
"openocd_target": "rp2350.cfg",
"svd_path": "rp2350.svd"
},
"frameworks": [
"arduino"
],
"name": "Feather RP2350 Adalogger",
"upload": {
"maximum_ram_size": 524288,
"maximum_size": 8388608,
"require_upload_port": true,
"native_usb": true,
"use_1200bps_touch": true,
"wait_for_upload_port": false,
"protocol": "picotool",
"protocols": [
"blackmagic",
"cmsis-dap",
"jlink",
"raspberrypi-swd",
"picotool",
"picoprobe"
]
},
"url": "https://www.raspberrypi.org/products/raspberry-pi-pico/",
"vendor": "Adafruit"
}
3 changes: 2 additions & 1 deletion tools/makeboards.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def BuildPSRAMFreq(name):
print("%s.menu.psramfreq.freq%d.build.psram_freq=-DRP2350_PSRAM_MAX_SCK_HZ=%d" % (name, s, s * 1000000))

def BuildRP2350Variant(name):
for l in [ ("RP2350A", "-DPICO_RP2350A=1"), ("RP2530B", "-DPICO_RP2350B=1") ]:
for l in [ ("RP2350A", "-D__PICO_RP2350A=1"), ("RP2530B", "-D__PICO_RP2350A=0") ]:
print("%s.menu.variantchip.%s=%s" % (name, l[0], l[0]))
print("%s.menu.variantchip.%s.build.variantdefines=%s" % (name, l[0], l[1]))

Expand Down Expand Up @@ -519,6 +519,7 @@ def MakeBoardJSON(name, chip, vendor_name, product_name, vid, pid, pwr, boarddef
MakeBoard("adafruit_trinkeyrp2040qt", "rp2040", "Adafruit", "Trinkey RP2040 QT", "0x239a", "0x8109", 250, "ADAFRUIT_TRINKEYQT_RP2040", 8, 0, "boot2_w25q080_2_padded_checksum")
MakeBoard("adafruit_macropad2040", "rp2040", "Adafruit", "MacroPad RP2040", "0x239a", "0x8107", 250, "ADAFRUIT_MACROPAD_RP2040", 8, 0, "boot2_w25q080_2_padded_checksum")
MakeBoard("adafruit_kb2040", "rp2040", "Adafruit", "KB2040", "0x239a", "0x8105", 250, "ADAFRUIT_KB2040_RP2040", 8, 0, "boot2_w25q080_2_padded_checksum")
MakeBoard("adafruit_feather_rp2350_adalogger", "rp2350", "Adafruit", "Feather RP2350 Adalogger", "0x239a", "0x816D", 250, "ADAFRUIT_FEATHER_RP2350_ADALOGGER", 8, 0, "none")
MakeBoard("adafruit_feather_rp2350_hstx", "rp2350", "Adafruit", "Feather RP2350 HSTX", "0x239a", "0x814f", 250, "ADAFRUIT_FEATHER_RP2350_HSTX", 8, 0, "none")
MakeBoard("adafruit_floppsy", "rp2040", "Adafruit", "Floppsy", "0x239a", "0x8151", 250, "ADAFRUIT_FLOPPSY_RP2040", 16, 0, "boot2_w25q080_2_padded_checksum")
MakeBoard("adafruit_metro_rp2350", "rp2350", "Adafruit", "Metro RP2350", "0x239a", "0x814d", 250, "ADAFRUIT_METRO_RP2350", 16, 0, "none")
Expand Down
57 changes: 57 additions & 0 deletions variants/adafruit_feather_rp2350_adalogger/pins_arduino.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#pragma once

#define PICO_RP2350A 1

// LEDs
#define PIN_LED (7u)

#define PIN_NEOPIXEL (21u)
#define NUM_NEOPIXEL (1)

// SD Card connector
#define PIN_CARD_DETECT (13u)
#define PIN_SD_CLK (14u)
#define PIN_SD_CMD_MOSI (15u)
#define PIN_SD_DAT0_MISO (16u)
#define PIN_SD_DAT1 (17u)
#define PIN_SD_DAT2 (18u)
#define PIN_SD_DAT3_CS (19u)

// UARTs
#define PIN_SERIAL1_TX (0u)
#define PIN_SERIAL1_RX (1u)
#define PIN_SERIAL2_TX (99u) // not pinned out
#define PIN_SERIAL2_RX (99u)

// SPI
#define PIN_SPI0_MISO (20u)
#define PIN_SPI0_MOSI (23u)
#define PIN_SPI0_SCK (22u)
#define PIN_SPI0_SS (13u)
#define __SPI0_DEVICE spi0

// SPI1 for SD card
#define PIN_SPI1_MISO PIN_SD_DAT0_MISO
#define PIN_SPI1_MOSI PIN_SD_CMD_MOSI
#define PIN_SPI1_SCK PIN_SD_CLK
#define PIN_SPI1_SS PIN_SD_DAT3_CS
#define __SPI1_DEVICE spi1

// Wire
#define __WIRE0_DEVICE i2c0
#define PIN_WIRE0_SDA (2u)
#define PIN_WIRE0_SCL (3u)

#define __WIRE1_DEVICE i2c1
#define PIN_WIRE1_SDA (31u) // not pinned out
#define PIN_WIRE1_SCL (31u)

#define SERIAL_HOWMANY (1u)
#define SPI_HOWMANY (2u)
#define WIRE_HOWMANY (1u)

// PSRAM
#define RP2350_PSRAM_CS (8u)
#define RP2350_PSRAM_MAX_SCK_HZ (109*1000*1000)

#include "../generic/common.h"
2 changes: 2 additions & 0 deletions variants/adafruit_feather_rp2350_hstx/pins_arduino.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#define PICO_RP2350A 1

// LEDs
#define PIN_LED (7u)

Expand Down
Loading