Skip to content

Commit 88c717d

Browse files
authored
Merge pull request #10 from adafruit/rp2350_adalogger
adding rp2350 adalogger
2 parents cc96a13 + 407bdc9 commit 88c717d

File tree

46 files changed

+472
-45
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+472
-45
lines changed

boards.txt

Lines changed: 267 additions & 2 deletions
Large diffs are not rendered by default.

cores/rp2040/Arduino.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,23 @@
2727
#include "RP2040Version.h"
2828
#include "api/ArduinoAPI.h"
2929
#include "api/itoa.h" // ARM toolchain doesn't provide itoa etc, provide them
30+
#include <pico.h>
31+
#undef PICO_RP2350A // Set in the RP2350 SDK boards file, overridden in the variant pins_arduino.h
3032
#include <pins_arduino.h>
3133
#include <hardware/gpio.h> // Required for the port*Register macros
3234
#include "debug_internal.h"
3335

36+
// Chip sanity checking. SDK uses interesting way of separating 2350A from 2350B, see https://github.com/raspberrypi/pico-sdk/issues/2364
37+
#if (!defined(PICO_RP2040) && !defined(PICO_RP2350)) || defined(PICO_RP2040) && defined(PICO_RP2350)
38+
#error Invalid core definition. Either PICO_RP2040 or PICO_RP2350 must be defined.
39+
#endif
40+
#if defined(PICO_RP2350) && !defined(PICO_RP2350A)
41+
#error Invalid RP2350 definition. Need to set PICO_RP2350A=0/1 for A/B variant
42+
#endif
43+
#if defined(PICO_RP2350B)
44+
#error Do not define PICO_RP2350B. Use PICO_RP2350A=0 to indicate RP2350B. See the SDK for more details
45+
#endif
46+
3447
// Try and make the best of the old Arduino abs() macro. When in C++, use
3548
// the sane std::abs() call, but for C code use their macro since stdlib abs()
3649
// is int but their macro "works" for everything (with potential side effects)

cores/rp2040/IPAddress.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
#include "api/IPAddress.h"
2+
using arduino::IPAddress;

cores/rp2040/SerialUART.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ extern void serialEvent1() __attribute__((weak));
3232
extern void serialEvent2() __attribute__((weak));
3333

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

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

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

124124
bool SerialUART::setCTS(pin_size_t pin) {
125-
#ifdef PICO_RP2350B
125+
#if defined(PICO_RP2350) && !PICO_RP2350A // RP2350B
126126
constexpr uint64_t valid[2] = { __bitset({2, 14, 18, 30, 34, 46}) /* UART0 */,
127127
__bitset({6, 10, 22, 26, 38, 42}) /* UART1 */
128128
};
@@ -182,7 +182,7 @@ static void _uart1IRQ();
182182
// Does the selected TX/RX need UART_AUX function (rp2350)
183183
static gpio_function_t __gpioFunction(int pin) {
184184
switch (pin) {
185-
#if defined(PICO_RP2350) || defined(PICO_RP2350B)
185+
#if defined(PICO_RP2350) && !PICO_RP2350A
186186
case 2:
187187
case 3:
188188
case 6:

docs/adc.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ need to be periodically sampled to be read by applications, easily, such as:
1212
* Light dependent resistors (LDR), etc.
1313

1414

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

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

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

3536
bool setBuffers(size_t buffers, size_t bufferWords)
3637
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

docs/contrib.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ For only RP2350A variants (using the compile options, not the onboard ID registe
112112

113113
.. code:: cpp
114114
115-
#if defined(PICO_RP2350) && !defined(PICO_RP2350B)
115+
#if defined(PICO_RP2350A) && PICO_RP2350A
116116
...RP2350A only code...
117117
#endif
118118
@@ -121,7 +121,7 @@ and not the chip ID register):
121121

122122
.. code:: cpp
123123
124-
#if defined(PICO_RP2350B)
124+
#if defined(PICO_RP2350A) && !PICO_RP2350A
125125
...48-GPIO version code here
126126
#endif
127127

libraries/ADCInput/src/ADCInput.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ bool ADCInput::setBuffers(size_t buffers, size_t bufferWords) {
4949

5050
int ADCInput::_mask(pin_size_t p) {
5151
switch (p) {
52-
#if !defined(PICO_RP2350B)
52+
#if defined(PICO_RP2350) && !PICO_RP2350A // RP2350B
5353
case 26: return 1;
5454
case 27: return 2;
5555
case 28: return 4;
@@ -106,7 +106,7 @@ bool ADCInput::begin() {
106106
// Set up the GPIOs to go to ADC
107107
adc_init();
108108
int cnt = 0;
109-
#if !defined(PICO_RP2350B)
109+
#if defined(PICO_RP2350) && !PICO_RP2350A // RP2350B
110110
int startpin = 26;
111111
int maxpin = 29;
112112
#else

libraries/SPI/src/SPI.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ void SPIClassRP2040::abortAsync() {
263263

264264

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

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

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

346346
bool SPIClassRP2040::setTX(pin_size_t pin) {
347-
#ifdef PICO_RP2350B
347+
#if defined(PICO_RP2350) && !PICO_RP2350A // RP2350B
348348
constexpr uint64_t valid[2] = { __bitset({3, 7, 19, 23, 35, 39}) /* SPI0 */,
349349
__bitset({11, 15, 27, 31, 43, 47}) /* SPI1 */
350350
};

libraries/SPI/src/SPIHelper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class SPIHelper {
9898
return (reverseByte(w & 0xff) << 8) | (reverseByte(w >> 8));
9999
}
100100

101-
#ifdef PICO_RP2350B
101+
#if defined(PICO_RP2350) && !PICO_RP2350A // RP2350B
102102
static constexpr int GPIOIRQREGS = 6;
103103
#else
104104
static constexpr int GPIOIRQREGS = 4;

libraries/SPISlave/src/SPISlave.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ inline spi_cpha_t SPISlaveClass::cpha(SPISettings _spis) {
7979
}
8080

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

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

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

162162
bool SPISlaveClass::setTX(pin_size_t pin) {
163-
#ifdef PICO_RP2350B
163+
#if defined(PICO_RP2350) && !PICO_RP2350A // RP2350B
164164
constexpr uint64_t valid[2] = { __bitset({3, 7, 19, 23, 35, 39}) /* SPI0 */,
165165
__bitset({11, 15, 27, 31, 43, 47}) /* SPI1 */
166166
};

0 commit comments

Comments
 (0)