Skip to content

Commit

Permalink
Add SparkFun Thing Plus RP2350
Browse files Browse the repository at this point in the history
  • Loading branch information
sfe-SparkFro committed Nov 13, 2024
1 parent 7a0adfe commit e6e4b80
Show file tree
Hide file tree
Showing 8 changed files with 588 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ Read the [Contributing Guide](https://github.com/earlephilhower/arduino-pico/blo
* SparkFun ProMicro RP2040
* SparkFun ProMicro RP2350
* SparkFun Thing Plus RP2040
* SparkFun Thing Plus RP2350
* uPesy RP2040 DevKit
* VCC-GND YD-RP2040
* Viyalab Mizu RP2040
Expand Down
335 changes: 335 additions & 0 deletions boards.txt

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions package/package_pico_index.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@
{
"name": "SparkFun Thing Plus RP2040"
},
{
"name": "SparkFun Thing Plus RP2350"
},
{
"name": "uPesy RP2040 DevKit"
},
Expand Down
56 changes: 56 additions & 0 deletions tools/json/sparkfun_thingplusrp2350.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"build": {
"arduino": {
"earlephilhower": {
"boot2_source": "none.S",
"usb_vid": "0x1B4F",
"usb_pid": "0x0038"
}
},
"core": "earlephilhower",
"cpu": "cortex-m33",
"extra_flags": "-DARDUINO_SPARKFUN_THINGPLUS_RP2350 -DARDUINO_ARCH_RP2040 -DUSBD_MAX_POWER_MA=250 ",
"f_cpu": "150000000L",
"hwids": [
[
"0x2E8A",
"0x00C0"
],
[
"0x1B4F",
"0x0038"
]
],
"mcu": "rp2350",
"variant": "sparkfun_thingplusrp2350"
},
"debug": {
"jlink_device": "RP2350_0",
"openocd_target": "rp2350.cfg",
"svd_path": "rp2350.svd"
},
"frameworks": [
"arduino"
],
"name": "Thing Plus RP2350",
"upload": {
"maximum_ram_size": 524288,
"maximum_size": 16777216,
"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"
],
"psram_length": 8388608
},
"url": "https://www.raspberrypi.org/products/raspberry-pi-pico/",
"vendor": "SparkFun"
}
1 change: 1 addition & 0 deletions tools/makeboards.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,7 @@ def MakeBoardJSON(name, chip, vendor_name, product_name, vid, pid, pwr, boarddef
MakeBoard("sparkfun_promicrorp2040", "rp2040", "SparkFun", "ProMicro RP2040", "0x1b4f", "0x0026", 250, "SPARKFUN_PROMICRO_RP2040", 16, 0, "boot2_generic_03h_4_padded_checksum")
MakeBoard("sparkfun_promicrorp2350", "rp2350", "SparkFun", "ProMicro RP2350", "0x1b4f", "0x0026", 250, "SPARKFUN_PROMICRO_RP2350", 16, 8, "none")
MakeBoard("sparkfun_thingplusrp2040", "rp2040", "SparkFun", "Thing Plus RP2040", "0x1b4f", "0x0026", 250, "SPARKFUN_THINGPLUS_RP2040", 16, 0, "boot2_w25q080_2_padded_checksum")
MakeBoard("sparkfun_thingplusrp2350", "rp2350", "SparkFun", "Thing Plus RP2350", "0x1b4f", "0x0038", 250, "SPARKFUN_THINGPLUS_RP2350", 16, 8, "none")

# Upesy
MakeBoard("upesy_rp2040_devkit", "rp2040", "uPesy", "RP2040 DevKit", "0x2e8a", "0x1007", 250, "UPESY_RP2040_DEVKIT", 2, 0, "boot2_w25q080_2_padded_checksum")
Expand Down
60 changes: 60 additions & 0 deletions variants/sparkfun_thingplusrp2350/picow_digital.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
pinMode and digitalRead/Write for the Raspberry Pi Pico W RP2040
Copyright (c) 2022 Earle F. Philhower, III <[email protected]>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include "Arduino.h"
#include <pico/cyw43_arch.h>

extern "C" void __pinMode(pin_size_t pin, PinMode mode);
extern "C" void __digitalWrite(pin_size_t pin, PinStatus val);
extern "C" PinStatus __digitalRead(pin_size_t pin);

extern bool __isPicoW;

extern "C" void pinMode(pin_size_t pin, PinMode mode) {
if (!__isPicoW && (pin == PIN_LED)) {
pin = 25; // Silently swap in the Pico's LED
}
if (pin < 32) {
__pinMode(pin, mode);
} else {
// TBD - There is no GPIO direction control in the driver
}
}

extern "C" void digitalWrite(pin_size_t pin, PinStatus val) {
if (!__isPicoW && (pin == PIN_LED)) {
pin = 25; // Silently swap in the Pico's LED
}
if (pin < 32) {
__digitalWrite(pin, val);
} else {
cyw43_arch_gpio_put(pin - 32, val == HIGH ? 1 : 0);
}
}

extern "C" PinStatus digitalRead(pin_size_t pin) {
if (!__isPicoW && (pin == PIN_LED)) {
pin = 25; // Silently swap in the Pico's LED
}
if (pin < 32) {
return __digitalRead(pin);
} else {
return cyw43_arch_gpio_get(pin - 32) ? HIGH : LOW;
}
}
75 changes: 75 additions & 0 deletions variants/sparkfun_thingplusrp2350/picow_init.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
Initialize the Pico W WiFi driver
Copyright (c) 2022 Earle F. Philhower, III <[email protected]>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include <pico/cyw43_arch.h>
#include <pico/lwip_nosys.h>
#include "hardware/resets.h"
#include "hardware/gpio.h"
#include "hardware/adc.h"

#ifndef WIFICC
#define WIFICC CYW43_COUNTRY_WORLDWIDE
#endif

// Taken from https://datasheets.raspberrypi.com/picow/connecting-to-the-internet-with-pico-w.pdf
// also discussion in https://github.com/earlephilhower/arduino-pico/issues/849
static bool CheckPicoW() {
adc_init();
auto dir = gpio_get_dir(29);
auto fnc = gpio_get_function(29);
adc_gpio_init(29);
adc_select_input(3);
auto adc29 = adc_read();
gpio_set_function(29, fnc);
gpio_set_dir(29, dir);

dir = gpio_get_dir(25);
fnc = gpio_get_function(25);
gpio_init(25);
gpio_set_dir(25, GPIO_IN);
auto gp25 = gpio_get(25);
gpio_set_function(25, fnc);
gpio_set_dir(25, dir);

if (gp25) {
return true; // Can't tell, so assume yes
} else if (adc29 < 200) {
return true; // PicoW
} else {
return false;
}
}

bool __isPicoW = true;

extern "C" void initVariant() {
__isPicoW = CheckPicoW();
if (__isPicoW) {
cyw43_arch_init_with_country(WIFICC);
}
}

extern "C" void __lockBluetooth() {
async_context_acquire_lock_blocking(cyw43_arch_async_context());
}

extern "C" void __unlockBluetooth() {
async_context_release_lock(cyw43_arch_async_context());
}
57 changes: 57 additions & 0 deletions variants/sparkfun_thingplusrp2350/pins_arduino.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#pragma once

extern bool __isPicoW;

#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
extern void __lockBluetooth();
extern void __unlockBluetooth();
#ifdef __cplusplus
}; // extern "C"
#endif // __cplusplus

// LEDs
#define PIN_LED (32u)

#define PIN_NEOPIXEL (14)
#define NUM_NEOPIXEL (1)

// Serial
#define PIN_SERIAL1_TX (0u)
#define PIN_SERIAL1_RX (1u)

#define PIN_SERIAL2_TX (31u)
#define PIN_SERIAL2_RX (31u)

// SPI
#define PIN_SPI0_MISO (4u)
#define PIN_SPI0_MOSI (3u)
#define PIN_SPI0_SCK (2u)
#define PIN_SPI0_SS (9u) // CS pin for SD card

#define PIN_SPI1_MISO (31u)
#define PIN_SPI1_MOSI (31u)
#define PIN_SPI1_SCK (31u)
#define PIN_SPI1_SS (31u)

// Wire
#define PIN_WIRE0_SDA (6u)
#define PIN_WIRE0_SCL (7u)

#define PIN_WIRE1_SDA (31u)
#define PIN_WIRE1_SCL (31u)

// Thing Plus uses I2C for Qwiic connector, make that the default
#ifndef __WIRE0_DEVICE
#define __WIRE0_DEVICE i2c1
#endif
#ifndef __WIRE1_DEVICE
#define __WIRE1_DEVICE i2c0
#endif

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

#include "../generic/common.h"

0 comments on commit e6e4b80

Please sign in to comment.