-
Notifications
You must be signed in to change notification settings - Fork 431
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7a0adfe
commit e6e4b80
Showing
8 changed files
with
588 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |