Skip to content

Commit e6e4b80

Browse files
committed
Add SparkFun Thing Plus RP2350
1 parent 7a0adfe commit e6e4b80

File tree

8 files changed

+588
-0
lines changed

8 files changed

+588
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ Read the [Contributing Guide](https://github.com/earlephilhower/arduino-pico/blo
9191
* SparkFun ProMicro RP2040
9292
* SparkFun ProMicro RP2350
9393
* SparkFun Thing Plus RP2040
94+
* SparkFun Thing Plus RP2350
9495
* uPesy RP2040 DevKit
9596
* VCC-GND YD-RP2040
9697
* Viyalab Mizu RP2040

boards.txt

Lines changed: 335 additions & 0 deletions
Large diffs are not rendered by default.

package/package_pico_index.template.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,9 @@
281281
{
282282
"name": "SparkFun Thing Plus RP2040"
283283
},
284+
{
285+
"name": "SparkFun Thing Plus RP2350"
286+
},
284287
{
285288
"name": "uPesy RP2040 DevKit"
286289
},
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"build": {
3+
"arduino": {
4+
"earlephilhower": {
5+
"boot2_source": "none.S",
6+
"usb_vid": "0x1B4F",
7+
"usb_pid": "0x0038"
8+
}
9+
},
10+
"core": "earlephilhower",
11+
"cpu": "cortex-m33",
12+
"extra_flags": "-DARDUINO_SPARKFUN_THINGPLUS_RP2350 -DARDUINO_ARCH_RP2040 -DUSBD_MAX_POWER_MA=250 ",
13+
"f_cpu": "150000000L",
14+
"hwids": [
15+
[
16+
"0x2E8A",
17+
"0x00C0"
18+
],
19+
[
20+
"0x1B4F",
21+
"0x0038"
22+
]
23+
],
24+
"mcu": "rp2350",
25+
"variant": "sparkfun_thingplusrp2350"
26+
},
27+
"debug": {
28+
"jlink_device": "RP2350_0",
29+
"openocd_target": "rp2350.cfg",
30+
"svd_path": "rp2350.svd"
31+
},
32+
"frameworks": [
33+
"arduino"
34+
],
35+
"name": "Thing Plus RP2350",
36+
"upload": {
37+
"maximum_ram_size": 524288,
38+
"maximum_size": 16777216,
39+
"require_upload_port": true,
40+
"native_usb": true,
41+
"use_1200bps_touch": true,
42+
"wait_for_upload_port": false,
43+
"protocol": "picotool",
44+
"protocols": [
45+
"blackmagic",
46+
"cmsis-dap",
47+
"jlink",
48+
"raspberrypi-swd",
49+
"picotool",
50+
"picoprobe"
51+
],
52+
"psram_length": 8388608
53+
},
54+
"url": "https://www.raspberrypi.org/products/raspberry-pi-pico/",
55+
"vendor": "SparkFun"
56+
}

tools/makeboards.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,7 @@ def MakeBoardJSON(name, chip, vendor_name, product_name, vid, pid, pwr, boarddef
630630
MakeBoard("sparkfun_promicrorp2040", "rp2040", "SparkFun", "ProMicro RP2040", "0x1b4f", "0x0026", 250, "SPARKFUN_PROMICRO_RP2040", 16, 0, "boot2_generic_03h_4_padded_checksum")
631631
MakeBoard("sparkfun_promicrorp2350", "rp2350", "SparkFun", "ProMicro RP2350", "0x1b4f", "0x0026", 250, "SPARKFUN_PROMICRO_RP2350", 16, 8, "none")
632632
MakeBoard("sparkfun_thingplusrp2040", "rp2040", "SparkFun", "Thing Plus RP2040", "0x1b4f", "0x0026", 250, "SPARKFUN_THINGPLUS_RP2040", 16, 0, "boot2_w25q080_2_padded_checksum")
633+
MakeBoard("sparkfun_thingplusrp2350", "rp2350", "SparkFun", "Thing Plus RP2350", "0x1b4f", "0x0038", 250, "SPARKFUN_THINGPLUS_RP2350", 16, 8, "none")
633634

634635
# Upesy
635636
MakeBoard("upesy_rp2040_devkit", "rp2040", "uPesy", "RP2040 DevKit", "0x2e8a", "0x1007", 250, "UPESY_RP2040_DEVKIT", 2, 0, "boot2_w25q080_2_padded_checksum")
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
pinMode and digitalRead/Write for the Raspberry Pi Pico W RP2040
3+
Copyright (c) 2022 Earle F. Philhower, III <[email protected]>
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
20+
#include "Arduino.h"
21+
#include <pico/cyw43_arch.h>
22+
23+
extern "C" void __pinMode(pin_size_t pin, PinMode mode);
24+
extern "C" void __digitalWrite(pin_size_t pin, PinStatus val);
25+
extern "C" PinStatus __digitalRead(pin_size_t pin);
26+
27+
extern bool __isPicoW;
28+
29+
extern "C" void pinMode(pin_size_t pin, PinMode mode) {
30+
if (!__isPicoW && (pin == PIN_LED)) {
31+
pin = 25; // Silently swap in the Pico's LED
32+
}
33+
if (pin < 32) {
34+
__pinMode(pin, mode);
35+
} else {
36+
// TBD - There is no GPIO direction control in the driver
37+
}
38+
}
39+
40+
extern "C" void digitalWrite(pin_size_t pin, PinStatus val) {
41+
if (!__isPicoW && (pin == PIN_LED)) {
42+
pin = 25; // Silently swap in the Pico's LED
43+
}
44+
if (pin < 32) {
45+
__digitalWrite(pin, val);
46+
} else {
47+
cyw43_arch_gpio_put(pin - 32, val == HIGH ? 1 : 0);
48+
}
49+
}
50+
51+
extern "C" PinStatus digitalRead(pin_size_t pin) {
52+
if (!__isPicoW && (pin == PIN_LED)) {
53+
pin = 25; // Silently swap in the Pico's LED
54+
}
55+
if (pin < 32) {
56+
return __digitalRead(pin);
57+
} else {
58+
return cyw43_arch_gpio_get(pin - 32) ? HIGH : LOW;
59+
}
60+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
Initialize the Pico W WiFi driver
3+
4+
Copyright (c) 2022 Earle F. Philhower, III <[email protected]>
5+
6+
This library is free software; you can redistribute it and/or
7+
modify it under the terms of the GNU Lesser General Public
8+
License as published by the Free Software Foundation; either
9+
version 2.1 of the License, or (at your option) any later version.
10+
11+
This library is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
Lesser General Public License for more details.
15+
16+
You should have received a copy of the GNU Lesser General Public
17+
License along with this library; if not, write to the Free Software
18+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19+
*/
20+
21+
#include <pico/cyw43_arch.h>
22+
#include <pico/lwip_nosys.h>
23+
#include "hardware/resets.h"
24+
#include "hardware/gpio.h"
25+
#include "hardware/adc.h"
26+
27+
#ifndef WIFICC
28+
#define WIFICC CYW43_COUNTRY_WORLDWIDE
29+
#endif
30+
31+
// Taken from https://datasheets.raspberrypi.com/picow/connecting-to-the-internet-with-pico-w.pdf
32+
// also discussion in https://github.com/earlephilhower/arduino-pico/issues/849
33+
static bool CheckPicoW() {
34+
adc_init();
35+
auto dir = gpio_get_dir(29);
36+
auto fnc = gpio_get_function(29);
37+
adc_gpio_init(29);
38+
adc_select_input(3);
39+
auto adc29 = adc_read();
40+
gpio_set_function(29, fnc);
41+
gpio_set_dir(29, dir);
42+
43+
dir = gpio_get_dir(25);
44+
fnc = gpio_get_function(25);
45+
gpio_init(25);
46+
gpio_set_dir(25, GPIO_IN);
47+
auto gp25 = gpio_get(25);
48+
gpio_set_function(25, fnc);
49+
gpio_set_dir(25, dir);
50+
51+
if (gp25) {
52+
return true; // Can't tell, so assume yes
53+
} else if (adc29 < 200) {
54+
return true; // PicoW
55+
} else {
56+
return false;
57+
}
58+
}
59+
60+
bool __isPicoW = true;
61+
62+
extern "C" void initVariant() {
63+
__isPicoW = CheckPicoW();
64+
if (__isPicoW) {
65+
cyw43_arch_init_with_country(WIFICC);
66+
}
67+
}
68+
69+
extern "C" void __lockBluetooth() {
70+
async_context_acquire_lock_blocking(cyw43_arch_async_context());
71+
}
72+
73+
extern "C" void __unlockBluetooth() {
74+
async_context_release_lock(cyw43_arch_async_context());
75+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#pragma once
2+
3+
extern bool __isPicoW;
4+
5+
#ifdef __cplusplus
6+
extern "C" {
7+
#endif // __cplusplus
8+
extern void __lockBluetooth();
9+
extern void __unlockBluetooth();
10+
#ifdef __cplusplus
11+
}; // extern "C"
12+
#endif // __cplusplus
13+
14+
// LEDs
15+
#define PIN_LED (32u)
16+
17+
#define PIN_NEOPIXEL (14)
18+
#define NUM_NEOPIXEL (1)
19+
20+
// Serial
21+
#define PIN_SERIAL1_TX (0u)
22+
#define PIN_SERIAL1_RX (1u)
23+
24+
#define PIN_SERIAL2_TX (31u)
25+
#define PIN_SERIAL2_RX (31u)
26+
27+
// SPI
28+
#define PIN_SPI0_MISO (4u)
29+
#define PIN_SPI0_MOSI (3u)
30+
#define PIN_SPI0_SCK (2u)
31+
#define PIN_SPI0_SS (9u) // CS pin for SD card
32+
33+
#define PIN_SPI1_MISO (31u)
34+
#define PIN_SPI1_MOSI (31u)
35+
#define PIN_SPI1_SCK (31u)
36+
#define PIN_SPI1_SS (31u)
37+
38+
// Wire
39+
#define PIN_WIRE0_SDA (6u)
40+
#define PIN_WIRE0_SCL (7u)
41+
42+
#define PIN_WIRE1_SDA (31u)
43+
#define PIN_WIRE1_SCL (31u)
44+
45+
// Thing Plus uses I2C for Qwiic connector, make that the default
46+
#ifndef __WIRE0_DEVICE
47+
#define __WIRE0_DEVICE i2c1
48+
#endif
49+
#ifndef __WIRE1_DEVICE
50+
#define __WIRE1_DEVICE i2c0
51+
#endif
52+
53+
#define SERIAL_HOWMANY (3u)
54+
#define SPI_HOWMANY (1u)
55+
#define WIRE_HOWMANY (1u)
56+
57+
#include "../generic/common.h"

0 commit comments

Comments
 (0)