Compare commits

..
61 Commits
Author SHA1 Message Date
Earle F. Philhower, III 11ac5ed33e Update version 2023-02-18 13:04:53 -08:00
Earle F. Philhower, III b7912f182b Add isPicoW call to RP2040 object (#1204)
Use the RPi code to get a best-guess as to whether the board is a Pico or
PicoW.

Fixes #849
2023-02-18 13:00:02 -08:00
Earle F. Philhower, III 6db0ac8471 Add release package fixups for picoprobe-cmsis-dap (#1205) 2023-02-18 12:14:23 -08:00
Ha Thach 060aa52c89 Add picoprobe CMSIS-DAP support (#1198) 2023-02-18 12:09:02 -08:00
Carter Nelson ba413bb7ad Remove extra SPI byte flip (#1202)
Fixes #1201
2023-02-17 12:42:31 -08:00
Earle F. Philhower, III 97e787e48a Reduce unintialized_ram overhead to 0 in most cases (#1200)
Use GNU LD MAX() to ensure the uninitialized RAM portions are after the
OTA region.  For most apps this already happens, so there will be no
overhead added.
2023-02-16 18:23:15 -08:00
Earle F. Philhower, III b473139758 Enable use of uninitialized_ram() macro (#1199)
The uninitted RAM macro would fail because the OTA code would clear out the
first 50KB or so of RAM to copy its code and global values.

Move all global values to the end of RAM in OTA, and then align any uninitted
vars to a 16KB unit to ensure it won't appear in the 1st part of RAM that is
still needed to copy the OTA executable.

In the normal case, without any uninit_ram vars, no additional space is used.
When uninit_ram is used, up to 16KB of space may be lost to get that alignment,
but it will work properly.

Fixes #1188
2023-02-16 17:59:15 -08:00
Earle F. Philhower, III 7afcec8edc Update picotool refs in JSON (#1197) 2023-02-15 18:49:40 -08:00
Earle F. Philhower, III d1a3009447 Upgrade to toolchain 1.5.0-b (#1196)
Includes fixes for ::printf/etc. using stdout/stderr
Fixes #1181
2023-02-15 18:20:18 -08:00
Earle F. Philhower, III 651d596246 Allow FreeRTOS to ::printf (#1195)
The stdin/stdout FILEs have an internal mutex which needs to be initted
to a FreeRTOS one, or any sketch with ::printf will hang.  Automatically
create and acquire/release the shadowed mutex.

Requires new build of pico-quick-toolchain to function properly.  Tested
on preliminary local build.
2023-02-15 15:58:45 -08:00
Earle F. Philhower, III 75bab41e39 Make uf2conf.py flush STDOUT for real-time updates (#1194)
Without flushing STDOUT, the upload script's output aften are buffered
and not displayed until it completes.  Add in flush commands to allow
the IDE to display status as it changes.
2023-02-15 12:13:55 -08:00
Earle F. Philhower, III 36e0b4a908 Unbreak FreeRTOS (#1193)
USB changes caused FreeRTOS to not be able to swap tasks when the Serial port
was connected.  Clear the "stop PendSV" flag after checking for reset signal.
2023-02-15 12:10:52 -08:00
Earle F. Philhower, III 974301eaaf Add rp2040.cpuid() call to get running core (#1190)
Per question received via email.
2023-02-14 16:22:04 -08:00
Earle F. Philhower, III 2acc161ad2 Update contrib.rst 2023-02-14 13:24:02 -08:00
Earle F. Philhower, III 7322bad830 Add docs on adding a new board to the core, too 2023-02-14 08:46:24 -08:00
Earle F. Philhower, III 6afd3260ef Update README.md 2023-02-13 14:56:46 -08:00
Earle F. Philhower, III 76e7cca821 Add contributing docs (#1183) 2023-02-13 14:54:52 -08:00
Earle F. Philhower, III 84206eb237 Fix SD.H FILE_WRITE mapping (#1178)
O_RDWR != O_READ|O_WRITE.  Posix is weird.  Thanks @mcspr
2023-02-12 17:46:50 -08:00
Earle F. Philhower, III 5e576c1a08 Update SD examples with working SPI configs (#1175)
Fixes #1172
2023-02-12 11:01:01 -08:00
Earle F. Philhower, III fc180041aa Implement WiFi::softAPgetStationNum (#1174) 2023-02-12 10:38:37 -08:00
Earle F. Philhower, III 1bfd07c19a Update version 2023-02-11 12:34:40 -08:00
Andrew KrollandEarle F. Philhower, III 5dafbf57e9 Optimize and improve upload experience (#1136)
Stop the IDE from reporting large "Serial port not fount"-type errors after
every upload by delaying a bit before the uploader exits to give the OS/Pico
time to renegotiate.

Fixes flashing problems on certain Linux distros by checking all possible mount
locations instead of only the first one to be found.

Make 1200bps reset tickle more robust

Co-authored-by: Earle F. Philhower, III <earlephilhower@yahoo.com>
2023-02-11 12:33:44 -08:00
Earle F. Philhower, III 09db2e6c37 Apply SD.h fix from ESP8266 (#1171)
Pull in the portion of the change correcting the flag setting from
https://github.com/esp8266/Arduino/pull/8833
2023-02-11 11:57:27 -08:00
Earle F. Philhower, III b6cb2e7edc Avoid race condition in I2S/PWMAudio delete (#1163)
Fixes #1162

Disable DMA interrupts while we're tearing down an AudioBufferManager
and explicitly clear any potential leftover IRQs to avoid hangs.
2023-02-09 13:29:45 -08:00
Earle F. Philhower, III bedcbf57c6 Add ESP8266/32 WiFi.isConnected wrapper (#1166)
Fixes #1165
2023-02-09 08:39:35 -08:00
TomKong666 7df080ee92 PDM library re-port (#1160)
See #1156
2023-02-07 08:10:24 -08:00
Earle F. Philhower, III b400897ca2 Avoid initial glitch on Serial1/2 when RX high (#1154)
Fixes #1153

Set up the GPIO redirects before the UART is pulled from reset to avoid
a possible bad byte at `Serial1/2.begin()`.
2023-02-01 19:15:58 -08:00
uPesy Electronics 7573500e59 Add uPesy Tutorials using Arduino Pico port. (#1151) 2023-02-01 06:52:25 -08:00
Vishnu Mohanan 8a1e03739a Fix SPI transfer16 return value (#1148)
The SPI transfer16() function returned wrongly oriented bytes. Replaced reverseByte() with reverse16Bit().

Fixes #1146
2023-01-31 08:09:53 -08:00
Earle F. Philhower, III a1af9698ac Fix USB VID/PID setting, rationalize boards.txt (#1144)
The USB VID was always being set to the Raspberry Pi foundation code,
causing other brand boards to show up incorrectly.

Remove redundant values from the boards.txt and define a consistent
USB VID/PID and use it in the setup code.

See #1129 for more info
2023-01-28 11:10:39 -08:00
Earle F. Philhower, III af01c3cc77 Add boot2_w25q128jv to generic Pico flash menu (#1142)
Add-on to #1126
2023-01-26 16:35:16 -08:00
Earle F. Philhower, III 4c8bdc2bfc Print useful uf2conv error if executable not found (#1141)
Fixes #1140

````
Converting to uf2, output size: 134144, start address: 0x2000
ERROR: Unable to execute powershell or wmic commands, can't continue.
ERROR: Please make sure either PowerShell or WMIC is installed and in
       your %PATH%.
````
2023-01-26 11:02:07 -08:00
Conor Burns c58f94a9ba Add correct boot source to helios (#1126) 2023-01-25 14:45:51 -08:00
Earle F. Philhower, III ecaa2bd778 Fix SerialUART::overflow reporting race condition (#1133)
Fixes #1132
2023-01-21 01:38:15 -08:00
Earle F. Philhower, III d619bf0bc1 More minor ESP8266 compatibility tweaks (#1131) 2023-01-20 17:06:40 -08:00
Gavin Hurlbut 9a241b0e43 Add Serial UART break reporting (#1130)
Added SerialUART::getBreakReceived()
2023-01-20 16:54:31 -08:00
Earle F. Philhower, III e3f2f87e2d Add more ESP8266 WiFi compatibility wrappers (#1128) 2023-01-19 12:44:05 -08:00
Earle F. Philhower, III a8238cb0d4 Add the YD-RP2040 support files
Oops!
2023-01-19 07:57:26 -08:00
Earle F. Philhower, III f212720484 Update version 2023-01-14 14:34:45 -08:00
Earle F. Philhower, III 1328f78099 Add VCC-GND YD-RP2040 board (#1120)
Fixes #1109
2023-01-14 14:33:52 -08:00
Earle F. Philhower, III 4c234310fd Add hook support to WebServer (#1119)
Implement the method used in the ESP8266 Web Server to allow user apps to hook into
the HTTP server (to support hooked WebSockets, etc._)

Add example of hook usage
2023-01-14 13:35:33 -08:00
Conor Burns f7ee4a868a Add 0xCB Helios (#1117) 2023-01-14 12:19:27 -08:00
Earle F. Philhower, III ae386d4308 Redo boards menu, separate out upload method, add picotool upload (#1112)
Instead of listing each board three times (normal upload, picoprobe,
and pico-debug uploads), list each board once and use a menu to select
the actual upload method.

Also add in picotool as an upload method for those folks who have trouble
with automounting.

Fix #1111
2023-01-13 13:04:24 -08:00
Earle F. Philhower, III ff9f5d3809 Update README.md 2023-01-09 09:55:27 -08:00
Earle F. Philhower, III ce17a6200b Update install.rst 2023-01-09 08:08:57 -08:00
AnachronisticPenguin 8289bbd27b Add additional instructions for Linux Flatpak users (#1105)
Provide instructions for users to override filesystem access restrictions imposed by Flatpak on some installations of the Arduino IDE
2023-01-09 08:03:30 -08:00
Earle F. Philhower, III aeb41f3e70 Handle slave mode I2C restarts (#1104)
Fixes #1100
2023-01-06 12:23:53 -08:00
Earle F. Philhower, III cefea28539 Stop the I2S PIO when I2S::end called (#1103) 2023-01-06 12:23:26 -08:00
Earle F. Philhower, III da26016edf DMA-based ADC input (microphone, analog sensor) (#1101)
Mimics the I2S/PWMAudio/Stream interface for ease of use.

* Fix non-32b DMA size transfer calculation in ABM
* Rename wasHolding to isHolding in the I2S/PWM
  It is the **current** number of bits left, not the past number.
* Add commented microphone example
* Add docs
2023-01-05 16:00:34 -08:00
Earle F. Philhower, III 6bef238772 Update to LittleFS 2.5.1 (only minor updates) (#1099) 2023-01-03 18:51:28 -08:00
Earle F. Philhower, III 02465b48b3 Allow on-the-fly changes to PWMAudio when possible (#1098)
Also fix crash on PWMAudio::end()
2023-01-03 16:02:43 -08:00
Earle F. Philhower, III 94abf9d19f Move analogReadTemp() to C++-only (#1097)
Now that we have a default parameter, need to only allow it in C++ since
default values are not part of C spec.  Should not affect any users since
only legacy code is in C.
2023-01-03 13:30:11 -08:00
Thomas Combriat 7a4244180b Set Right and Left correctly for lsbj format (#1096) 2023-01-03 13:15:08 -08:00
Earle F. Philhower, III 6fe6c474f7 Add LSBJ format support for I2S (#1095)
Fixes #1094
2023-01-03 11:47:55 -08:00
Earle F. Philhower, III be34ed1385 Reduce stack usage of several components (#1093)
Only 4K total stack, so allocating 400 bytes for a local C string
or 600 bytes for a DHCP response is dangerous.  Use static allocations
instead on the heap.
2023-01-02 11:40:51 -08:00
Earle F. Philhower, III 444bb24464 Remove debug printout warnings (#1091)
Exposed by #1090, remove ugly printf format warnings while in debug mode
2023-01-02 10:51:04 -08:00
NuclearPhoenix 0e6ca28316 Update wiring_analog.cpp (#1092) 2023-01-02 10:44:49 -08:00
Earle F. Philhower, III d718b143d2 Warn when Serial.printf() format is wrong (#1090)
Let GCC check the format string to Print::printf().  Will catch when
sketches use incorrect parameters to `Serial::printf()`.
2023-01-01 15:26:15 -08:00
Axotron 1e2f1a19ff Adding sei() and cli() as aliases for interrupts() and noInterrupts(). (#1089) 2023-01-01 14:18:06 -08:00
Earle F. Philhower, III 1228251bc3 Add stereo support, docs for PWM playback (#1084)
Limited to consecutive pins (i.e. GPIOs on the same PWM slice).
"For free" with PWM since no add'l DMA, buffers, or IRQs are needed.
2023-01-01 11:27:49 -08:00
Earle F. Philhower, III a781ec2fdd Add WString.h include redirect for broader compat (#1083)
See #1079
2022-12-31 11:03:28 -08:00
106 changed files with 19908 additions and 34460 deletions
+11
View File
@@ -9,9 +9,13 @@ This is a port of the RP2040 (Raspberry Pi Pico processor) to the Arduino ecosys
# Documentation
See https://arduino-pico.readthedocs.io/en/latest/ along with the examples for more detailed usage information.
# Contributing
Read the [Contributing Guide](https://github.com/earlephilhower/arduino-pico/blob/master/docs/contrib.rst) for more information on submitting pull requests and porting libraries or sketches to this core.
# Supported Boards
* Raspberry Pi Pico
* Raspberry Pi Pico W
* 0xCB Helios
* Adafruit Feather RP2040
* Adafruit Feather RP2040 SCORPIO
* Adafruit ItsyBitsy RP2040
@@ -46,6 +50,7 @@ See https://arduino-pico.readthedocs.io/en/latest/ along with the examples for m
* SparkFun ProMicro RP2040
* SparkFun Thing Plus RP2040
* uPesy RP2040 DevKit
* VCC-GND YD-RP2040
* Viyalab Mizu RP2040
* Waveshare RP2040 Zero
* Waveshare RP2040 One
@@ -168,6 +173,9 @@ The installed tools include a version of OpenOCD (in the pqt-openocd directory)
* FreeRTOS SMP support
* Overclocking and underclocking from the menus
* digitalWrite/Read, shiftIn/Out, tone, analogWrite(PWM)/Read, temperature
* Analog stereo audio in using DMA and the built-in ADC
* Analog stereo audio out using PWM hardware
* USB drive mode for data loggers (SingleFileDrive)
* Peripherals: SPI master, Wire(I2C) master/slave, dual UART, emulated EEPROM, I2S audio input, I2S audio output, Servo
* printf (i.e. debug) output over USB serial
@@ -186,6 +194,9 @@ Here are some links to coverage and additional tutorials for using `arduino-pico
* Adafruit Feather RP2040 running LCD + TMP117 - https://www.youtube.com/watch?v=fKDeqZiIwHg
* Demonstration of Servos and I2C in Korean - https://cafe.naver.com/arduinoshield/1201
* Home Assistant Pico W integration starter project using Arduino - https://github.com/daniloc/PicoW_HomeAssistant_Starter
* Tutorials for the Raspberry Pi Pico / uPesy RP2040 DevKit board
- English version: https://www.upesy.com/blogs/tutorials/best-tutorials-for-rpi-pi-pico-with-arduino-code
- French version: https://www.upesy.fr/blogs/tutorials/best-tutorials-for-rpi-pi-pico-with-arduino-code
# Contributing
If you want to contribute or have bugfixes, drop me a note at <earlephilhower@yahoo.com> or open an issue/PR here.
+2229 -18874
View File
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,23 @@
// Padded and checksummed version of: generated\Winbond\W25Q128JVxQ\boot2.bin by @maxgerhardt
.cpu cortex-m0plus
.thumb
.section .boot2, "ax"
.byte 0xf7, 0xb5, 0x73, 0x46, 0x21, 0x22, 0x02, 0x26, 0x01, 0x93, 0x29, 0x4b, 0xc0, 0x24, 0x5a, 0x60
.byte 0x9a, 0x68, 0x00, 0x27, 0xb2, 0x43, 0xda, 0x60, 0x9a, 0x60, 0x1a, 0x61, 0x5a, 0x61, 0x04, 0x23
.byte 0x01, 0x25, 0x64, 0x05, 0xa7, 0x60, 0x63, 0x61, 0x22, 0x4b, 0x30, 0x00, 0x1d, 0x60, 0xe0, 0x23
.byte 0xdb, 0x02, 0x23, 0x60, 0x35, 0x23, 0xa5, 0x60, 0x23, 0x66, 0x23, 0x66, 0x00, 0xf0, 0x4a, 0xf8
.byte 0xc0, 0xb2, 0xb0, 0x42, 0x12, 0xd0, 0x06, 0x23, 0x28, 0x00, 0x23, 0x66, 0x00, 0xf0, 0x42, 0xf8
.byte 0x25, 0x66, 0x03, 0x20, 0x27, 0x66, 0x26, 0x66, 0x00, 0xf0, 0x3c, 0xf8, 0x03, 0x36, 0x26, 0x66
.byte 0x02, 0x20, 0x26, 0x66, 0x00, 0xf0, 0x36, 0xf8, 0x28, 0x42, 0xf8, 0xd1, 0x00, 0x25, 0x12, 0x4b
.byte 0xa5, 0x60, 0x12, 0x4f, 0x23, 0x60, 0x12, 0x4b, 0x65, 0x60, 0x01, 0x26, 0x3b, 0x60, 0xeb, 0x23
.byte 0xa6, 0x60, 0x23, 0x66, 0x4b, 0x3b, 0x23, 0x66, 0x02, 0x20, 0x00, 0xf0, 0x23, 0xf8, 0x0d, 0x4b
.byte 0xa5, 0x60, 0x3b, 0x60, 0xa6, 0x60, 0x01, 0x9b, 0xab, 0x42, 0x08, 0xd1, 0x0a, 0x4b, 0x0b, 0x4a
.byte 0x13, 0x60, 0x1b, 0x68, 0x83, 0xf3, 0x08, 0x88, 0x09, 0x4b, 0x1b, 0x68, 0x18, 0x47, 0xf7, 0xbd
.byte 0x00, 0x00, 0x02, 0x40, 0xf0, 0x00, 0x00, 0x18, 0x00, 0x03, 0x5f, 0x00, 0xf4, 0x00, 0x00, 0x18
.byte 0x21, 0x22, 0x00, 0x00, 0x22, 0x20, 0x00, 0xa0, 0x00, 0x01, 0x00, 0x10, 0x08, 0xed, 0x00, 0xe0
.byte 0x04, 0x01, 0x00, 0x10, 0xc0, 0x22, 0x03, 0x00, 0x04, 0x21, 0x52, 0x05, 0x90, 0x6a, 0x08, 0x42
.byte 0xfc, 0xd0, 0x01, 0x21, 0x90, 0x6a, 0x08, 0x42, 0xfc, 0xd1, 0x01, 0x3b, 0xdb, 0xb2, 0x10, 0x6e
.byte 0x00, 0x2b, 0xfa, 0xd1, 0x70, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, 0xa0, 0xf0, 0x2f
+7
View File
@@ -70,10 +70,14 @@ void noInterrupts();
#define portModeRegister(port) ((volatile uint32_t*) sio_hw->gpio_oe)
#define digitalWriteFast(pin, val) (val ? sio_hw->gpio_set = (1 << pin) : sio_hw->gpio_clr = (1 << pin))
#define digitalReadFast(pin) ((1 << pin) & sio_hw->gpio_in)
#define sei() interrupts()
#define cli() noInterrupts()
// ADC RP2040-specific calls
void analogReadResolution(int bits);
#ifdef __cplusplus
float analogReadTemp(float vref = 3.3); // Returns core temp in Centigrade
#endif
// PWM RP2040-specific calls
void analogWriteFreq(uint32_t freq);
@@ -103,6 +107,9 @@ extern bool __isFreeRTOS;
#ifdef __cplusplus
// emptyString is an ESP-ism, a constant string with ""
extern const String emptyString;
#ifdef USE_TINYUSB
// Needed for declaring Serial
#include "Adafruit_USBD_CDC.h"
+15
View File
@@ -246,6 +246,11 @@ public:
return clock_get_hz(clk_sys);
}
// Get current CPU core number
static int cpuid() {
return sio_hw->cpuid;
}
// Get CPU cycle count. Needs to do magic to extens 24b HW to something longer
volatile uint64_t _epoch = 0;
inline uint32_t getCycleCount() {
@@ -358,6 +363,16 @@ public:
return (uint32_t)rr;
}
bool isPicoW() {
#if !defined(ARDUINO_RASPBERRY_PI_PICO_W)
return false;
#else
extern bool __isPicoW;
return __isPicoW;
#endif
}
private:
static void _SystickHandler() {
rp2040._epoch += 1LL << 24;
+108 -4
View File
@@ -33,6 +33,10 @@
#include "hardware/irq.h"
#include "pico/mutex.h"
#include "pico/unique_id.h"
#include "pico/usb_reset_interface.h"
#include "hardware/watchdog.h"
#include "pico/bootrom.h"
#include <device/usbd_pvt.h>
// Big, global USB mutex, shared with all USB devices to make sure we don't
// have multiple cores updating the TUSB state in parallel
@@ -42,12 +46,11 @@ mutex_t __usb_mutex;
#define USB_TASK_INTERVAL 1000
static int __usb_task_irq;
// USB VID/PID (note that PID can change depending on the add'l interfaces)
#ifndef USBD_VID
#define USBD_VID (0x2E8A) // Raspberry Pi
#endif
#ifdef SERIALUSB_PID
#define USBD_PID (SERIALUSB_PID)
#else
#ifndef USBD_PID
#define USBD_PID (0x000a) // Raspberry Pi Pico SDK CDC
#endif
@@ -67,6 +70,7 @@ static int __usb_task_irq;
#define USBD_STR_PRODUCT (0x02)
#define USBD_STR_SERIAL (0x03)
#define USBD_STR_CDC (0x04)
#define USBD_STR_RPI_RESET (0x05)
#define EPNUM_HID 0x83
@@ -74,6 +78,11 @@ static int __usb_task_irq;
#define USBD_MSC_EPIN 0x84
#define USBD_MSC_EPSIZE 64
#define TUD_RPI_RESET_DESCRIPTOR(_itfnum, _stridx) \
/* Interface */\
9, TUSB_DESC_INTERFACE, _itfnum, 0, 0, TUSB_CLASS_VENDOR_SPECIFIC, RESET_INTERFACE_SUBCLASS, RESET_INTERFACE_PROTOCOL, _stridx,
const uint8_t *tud_descriptor_device_cb(void) {
static tusb_desc_device_t usbd_desc_device = {
.bLength = sizeof(tusb_desc_device_t),
@@ -250,6 +259,14 @@ void __SetupUSBDescriptor() {
int usbd_desc_len = TUD_CONFIG_DESC_LEN + (__USBInstallSerial ? sizeof(cdc_desc) : 0) + (hasHID ? sizeof(hid_desc) : 0) + (__USBInstallMassStorage ? sizeof(msd_desc) : 0);
#ifdef ENABLE_PICOTOOL_USB
uint8_t picotool_itf = interface_count++;
uint8_t picotool_desc[] = {
TUD_RPI_RESET_DESCRIPTOR(picotool_itf, USBD_STR_RPI_RESET)
};
usbd_desc_len += sizeof(picotool_desc);
#endif
uint8_t tud_cfg_desc[TUD_CONFIG_DESC_LEN] = {
// Config number, interface count, string index, total length, attribute, power in mA
TUD_CONFIG_DESCRIPTOR(1, interface_count, USBD_STR_0, usbd_desc_len, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, USBD_MAX_POWER_MA)
@@ -274,6 +291,10 @@ void __SetupUSBDescriptor() {
memcpy(ptr, msd_desc, sizeof(msd_desc));
ptr += sizeof(msd_desc);
}
#ifdef ENABLE_PICOTOOL_USB
memcpy(ptr, picotool_desc, sizeof(picotool_desc));
ptr += sizeof(picotool_desc);
#endif
}
}
}
@@ -291,6 +312,9 @@ const uint16_t *tud_descriptor_string_cb(uint8_t index, uint16_t langid) {
[USBD_STR_PRODUCT] = "PicoArduino",
[USBD_STR_SERIAL] = idString,
[USBD_STR_CDC] = "Board CDC",
#ifdef ENABLE_PICOTOOL_USB
[USBD_STR_RPI_RESET] = "Reset",
#endif
};
if (!idString[0]) {
@@ -432,4 +456,84 @@ extern "C" void tud_msc_inquiry_cb(uint8_t lun, uint8_t vendor_id[8], uint8_t pr
}
#ifdef ENABLE_PICOTOOL_USB
static uint8_t _picotool_itf_num;
static void resetd_init() {
}
static void resetd_reset(uint8_t rhport) {
(void) rhport;
_picotool_itf_num = 0;
}
static uint16_t resetd_open(uint8_t rhport,
tusb_desc_interface_t const *itf_desc, uint16_t max_len) {
(void) rhport;
TU_VERIFY(TUSB_CLASS_VENDOR_SPECIFIC == itf_desc->bInterfaceClass &&
RESET_INTERFACE_SUBCLASS == itf_desc->bInterfaceSubClass &&
RESET_INTERFACE_PROTOCOL == itf_desc->bInterfaceProtocol, 0);
uint16_t const drv_len = sizeof(tusb_desc_interface_t);
TU_VERIFY(max_len >= drv_len, 0);
_picotool_itf_num = itf_desc->bInterfaceNumber;
return drv_len;
}
// Support for parameterized reset via vendor interface control request
static bool resetd_control_xfer_cb(uint8_t rhport, uint8_t stage,
tusb_control_request_t const *request) {
(void) rhport;
// nothing to do with DATA & ACK stage
if (stage != CONTROL_STAGE_SETUP) {
return true;
}
if (request->wIndex == _picotool_itf_num) {
if (request->bRequest == RESET_REQUEST_BOOTSEL) {
reset_usb_boot(0, (request->wValue & 0x7f));
// does not return, otherwise we'd return true
}
if (request->bRequest == RESET_REQUEST_FLASH) {
watchdog_reboot(0, 0, 100);
return true;
}
}
return false;
}
static bool resetd_xfer_cb(uint8_t rhport, uint8_t ep_addr,
xfer_result_t result, uint32_t xferred_bytes) {
(void) rhport;
(void) ep_addr;
(void) result;
(void) xferred_bytes;
return true;
}
static usbd_class_driver_t const _resetd_driver = {
#if CFG_TUSB_DEBUG >= 2
.name = "RESET",
#endif
.init = resetd_init,
.reset = resetd_reset,
.open = resetd_open,
.control_xfer_cb = resetd_control_xfer_cb,
.xfer_cb = resetd_xfer_cb,
.sof = NULL
};
// Implement callback to add our custom driver
usbd_class_driver_t const *usbd_app_driver_get_cb(uint8_t *driver_count) {
*driver_count = 1;
return &_resetd_driver;
}
#endif
#endif
+2 -2
View File
@@ -1,5 +1,5 @@
#pragma once
#define ARDUINO_PICO_MAJOR 2
#define ARDUINO_PICO_MINOR 7
#define ARDUINO_PICO_REVISION 0
#define ARDUINO_PICO_VERSION_STR "2.7.0"
#define ARDUINO_PICO_REVISION 3
#define ARDUINO_PICO_VERSION_STR "2.7.3"
+53 -18
View File
@@ -134,6 +134,20 @@ void SerialUART::begin(unsigned long baud, uint16_t config) {
_overflow = false;
_queue = new uint8_t[_fifoSize];
_baud = baud;
_fcnTx = gpio_get_function(_tx);
_fcnRx = gpio_get_function(_rx);
gpio_set_function(_tx, GPIO_FUNC_UART);
gpio_set_function(_rx, GPIO_FUNC_UART);
if (_rts != UART_PIN_NOT_DEFINED) {
_fcnRts = gpio_get_function(_rts);
gpio_set_function(_rts, GPIO_FUNC_UART);
}
if (_cts != UART_PIN_NOT_DEFINED) {
_fcnCts = gpio_get_function(_cts);
gpio_set_function(_cts, GPIO_FUNC_UART);
}
uart_init(_uart, baud);
int bits, stop;
uart_parity_t parity;
@@ -171,18 +185,6 @@ void SerialUART::begin(unsigned long baud, uint16_t config) {
break;
}
uart_set_format(_uart, bits, stop, parity);
_fcnTx = gpio_get_function(_tx);
_fcnRx = gpio_get_function(_rx);
gpio_set_function(_tx, GPIO_FUNC_UART);
gpio_set_function(_rx, GPIO_FUNC_UART);
if (_rts != UART_PIN_NOT_DEFINED) {
_fcnRts = gpio_get_function(_rts);
gpio_set_function(_rts, GPIO_FUNC_UART);
}
if (_cts != UART_PIN_NOT_DEFINED) {
_fcnCts = gpio_get_function(_cts);
gpio_set_function(_cts, GPIO_FUNC_UART);
}
uart_set_hw_flow(_uart, _rts != UART_PIN_NOT_DEFINED, _cts != UART_PIN_NOT_DEFINED);
_writer = 0;
_reader = 0;
@@ -200,6 +202,7 @@ void SerialUART::begin(unsigned long baud, uint16_t config) {
} else {
// Polling mode has no IRQs used
}
_break = false;
_running = true;
}
@@ -288,13 +291,22 @@ int SerialUART::read() {
}
bool SerialUART::overflow() {
CoreMutex m(&_mutex);
if (!_running || !m) {
if (!_running) {
return false;
}
bool hold = _overflow;
if (_polling) {
_handleIRQ(false);
} else {
_pumpFIFO();
}
mutex_enter_blocking(&_fifoMutex);
bool ovf = _overflow;
_overflow = false;
return hold;
mutex_exit(&_fifoMutex);
return ovf;
}
int SerialUART::available() {
@@ -365,6 +377,25 @@ SerialUART::operator bool() {
return _running;
}
bool SerialUART::getBreakReceived() {
if (!_running) {
return false;
}
if (_polling) {
_handleIRQ(false);
} else {
_pumpFIFO();
}
mutex_enter_blocking(&_fifoMutex);
bool break_received = _break;
_break = false;
mutex_exit(&_fifoMutex);
return break_received;
}
void arduino::serialEvent1Run(void) {
if (serialEvent1 && Serial1.available()) {
serialEvent1();
@@ -391,8 +422,12 @@ void __not_in_flash_func(SerialUART::_handleIRQ)(bool inIRQ) {
uart_get_hw(_uart)->icr = UART_UARTICR_RTIC_BITS | UART_UARTICR_RXIC_BITS;
while (uart_is_readable(_uart)) {
uint32_t raw = uart_get_hw(_uart)->dr;
if (raw & 0x700) {
// Framing, Parity, or Break. Ignore this bad char
if (raw & 0x400) {
// break!
_break = true;
continue;
} else if (raw & 0x300) {
// Framing, Parity Error. Ignore this bad char
continue;
}
uint8_t val = raw & 0xff;
+10
View File
@@ -63,9 +63,18 @@ public:
bool overflow();
operator bool() override;
// ESP8266 compat
void setDebugOutput(bool unused) {
(void) unused;
}
// Not to be called by users, only from the IRQ handler. In public so that the C-language IQR callback can access it
void _handleIRQ(bool inIRQ = true);
// Allows the user to sleep until a break is received (self-clears the flag
// on read)
bool getBreakReceived();
private:
bool _running = false;
uart_inst_t *_uart;
@@ -76,6 +85,7 @@ private:
mutex_t _mutex;
bool _polling = false;
bool _overflow;
bool _break;
// Lockless, IRQ-handled circular queue
uint32_t _writer;
+13 -1
View File
@@ -33,6 +33,7 @@
#include "pico/mutex.h"
#include "hardware/watchdog.h"
#include "pico/unique_id.h"
#include "hardware/resets.h"
#ifndef DISABLE_USB_SERIAL
// Ensure we are installed in the USB chain
@@ -174,11 +175,22 @@ SerialUSB::operator bool() {
static bool _dtr = false;
static bool _rts = false;
static int _bps = 115200;
static bool _rebooting = false;
static void CheckSerialReset() {
if ((_bps == 1200) && (!_dtr)) {
__holdUpPendSV = 1; // Ensure we don't get swapped out by FreeRTOS
if (!_rebooting && (_bps == 1200) && (!_dtr)) {
_rebooting = true;
// Disable NVIC IRQ, so that we don't get bothered anymore
irq_set_enabled(USBCTRL_IRQ, false);
// Reset the whole USB hardware block
reset_block(RESETS_RESET_USBCTRL_BITS);
unreset_block(RESETS_RESET_USBCTRL_BITS);
// Delay a bit, so the PC can figure out that we have disconnected.
sleep_ms(3);
reset_usb_boot(0, 0);
while (1); // WDT will fire here
}
__holdUpPendSV = 0;
}
extern "C" void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts) {
+5
View File
@@ -44,6 +44,11 @@ public:
using Print::write;
operator bool() override;
// ESP8266 compat
void setDebugOutput(bool unused) {
(void) unused;
}
private:
bool _running = false;
};
+1 -1
View File
@@ -109,7 +109,7 @@ void tone(uint8_t pin, unsigned int frequency, unsigned long duration) {
if (ret > 0) {
newTone->alarm = ret;
} else {
DEBUGCORE("ERROR: Unable to allocate timer for tone(%d, %d, %d)\n",
DEBUGCORE("ERROR: Unable to allocate timer for tone(%d, %d, %lu)\n",
pin, frequency, duration);
}
}
+1
View File
@@ -0,0 +1 @@
#include "api/String.h"
+7 -2
View File
@@ -28,7 +28,7 @@ typedef struct {
} FMMap;
static FMMap *_map = nullptr;
extern "C" SemaphoreHandle_t __get_freertos_mutex_for_ptr(mutex_t *m) {
SemaphoreHandle_t __get_freertos_mutex_for_ptr(mutex_t *m, bool recursive) {
if (!_map) {
_map = (FMMap *)calloc(sizeof(FMMap), 16);
}
@@ -42,7 +42,12 @@ extern "C" SemaphoreHandle_t __get_freertos_mutex_for_ptr(mutex_t *m) {
for (int i = 0; i < 16; i++) {
if (_map[i].src == nullptr) {
// Make a new mutex
SemaphoreHandle_t fm = __freertos_mutex_create();
SemaphoreHandle_t fm;
if (recursive) {
fm = _freertos_recursive_mutex_create();
} else {
fm = __freertos_mutex_create();
}
if (fm == nullptr) {
return nullptr;
}
+1 -1
View File
@@ -59,8 +59,8 @@ extern "C" {
extern void vTaskPreemptionEnable(TaskHandle_t p) __attribute__((weak));
#endif
extern SemaphoreHandle_t __get_freertos_mutex_for_ptr(mutex_t *m);
}
extern SemaphoreHandle_t __get_freertos_mutex_for_ptr(mutex_t *m, bool recursive = false);
// Halt the FreeRTOS PendSV task switching magic
extern "C" int __holdUpPendSV;
+6
View File
@@ -18,6 +18,8 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#pragma once
#if !defined(DEBUG_RP2040_PORT)
#define DEBUGV(...) do { } while(0)
#define DEBUGCORE(...) do { } while(0)
@@ -44,3 +46,7 @@
#define DEBUGSPI(...) do { } while(0)
#endif
#endif
#ifdef __cplusplus
extern void hexdump(const void* mem, uint32_t len, uint8_t cols = 16);
#endif
+16 -4
View File
@@ -80,7 +80,7 @@ static SemaphoreHandle_t __getFreeRTOSMutex(_LOCK_T lock) {
} else if (l == &__lock___arc4random_mutex) {
return __lock___arc4random_mutex_freertos;
}
return nullptr;
return __get_freertos_mutex_for_ptr(l, false);
}
static SemaphoreHandle_t __getFreeRTOSRecursiveMutex(_LOCK_T lock) {
@@ -96,12 +96,18 @@ static SemaphoreHandle_t __getFreeRTOSRecursiveMutex(_LOCK_T lock) {
} else if (l == &__lock___env_recursive_mutex) {
return __lock___env_recursive_mutex_freertos;
}
return nullptr;
return __get_freertos_mutex_for_ptr((mutex_t *)l, true);
}
void __retarget_lock_init(_LOCK_T *lock) {
if (__freeRTOSinitted) {
/* Already done in initFreeRTOSMutexes() */
mutex_t *l = (mutex_t *)lock;
if ((l == &__lock___at_quick_exit_mutex) || (l == &__lock___tz_mutex) || (l == &__lock___dd_hash_mutex) || (l == &__lock___arc4random_mutex)) {
/* Already done in initFreeRTOSMutexes() */
} else {
// Will init the mutex as well
__get_freertos_mutex_for_ptr(l, false);
}
} else {
mutex_init((mutex_t*) lock);
}
@@ -109,7 +115,13 @@ void __retarget_lock_init(_LOCK_T *lock) {
void __retarget_lock_init_recursive(_LOCK_T *lock) {
if (__freeRTOSinitted) {
/* Already done in initFreeRTOSMutexes() */
recursive_mutex_t *l = (recursive_mutex_t *)lock;
if ((l == &__lock___sinit_recursive_mutex) || (l == &__lock___sfp_recursive_mutex) || (l == &__lock___atexit_recursive_mutex) || (l == &__lock___malloc_recursive_mutex) || (l == &__lock___env_recursive_mutex)) {
/* Already done in initFreeRTOSMutexes() */
} else {
// Will init the mutex as well
__get_freertos_mutex_for_ptr((mutex_t *)l, true);
}
} else {
recursive_mutex_init((recursive_mutex_t*) lock);
}
+27
View File
@@ -170,3 +170,30 @@ extern "C" struct _reent *__wrap___getreent() {
return _impure_ptr1;
}
}
// ESP8266 internal debug routine
extern void hexdump(const void* mem, uint32_t len, uint8_t cols) __attribute__((weak));
void hexdump(const void* mem, uint32_t len, uint8_t cols) {
const char* src = (const char*)mem;
printf("\n[HEXDUMP] Address: %p len: 0x%lX (%ld)", src, len, len);
while (len > 0) {
uint32_t linesize = cols > len ? len : cols;
printf("\n[%p] 0x%04x: ", src, (int)(src - (const char*)mem));
for (uint32_t i = 0; i < linesize; i++) {
printf("%02x ", *(src + i));
}
printf(" ");
for (uint32_t i = linesize; i < cols; i++) {
printf(" ");
}
for (uint32_t i = 0; i < linesize; i++) {
unsigned char c = *(src + i);
putc(isprint(c) ? c : '.', stdout);
}
src += linesize;
len -= linesize;
}
printf("\n");
}
const String emptyString = "";
+6 -6
View File
@@ -43,10 +43,10 @@ extern "C" void analogWriteFreq(uint32_t freq) {
return;
}
if (freq < 100) {
DEBUGCORE("ERROR: analogWriteFreq too low (%d)\n", freq);
DEBUGCORE("ERROR: analogWriteFreq too low (%lu)\n", freq);
analogFreq = 100;
} else if (freq > 10'000'000) {
DEBUGCORE("ERROR: analogWriteFreq too high (%d)\n", freq);
DEBUGCORE("ERROR: analogWriteFreq too high (%lu)\n", freq);
analogFreq = 10'000'000;
} else {
analogFreq = freq;
@@ -64,7 +64,7 @@ extern "C" void analogWriteRange(uint32_t range) {
pwmInitted = 0;
scaleInitted = false;
} else {
DEBUGCORE("ERROR: analogWriteRange out of range (%d)\n", range);
DEBUGCORE("ERROR: analogWriteRange out of range (%lu)\n", range);
}
}
@@ -90,14 +90,14 @@ extern "C" void analogWrite(pin_size_t pin, int val) {
while (((clock_get_hz(clk_sys) / ((float)analogScale * analogFreq)) > 255.0) && (analogScale < 32678)) {
analogWritePseudoScale++;
analogScale *= 2;
DEBUGCORE("Adjusting analogWrite values PS=%d, scale=%d\n", analogWritePseudoScale, analogScale);
DEBUGCORE("Adjusting analogWrite values PS=%d, scale=%lu\n", analogWritePseudoScale, analogScale);
}
// For high frequencies, we need to scale the output max value down to actually hit the frequency target
analogWriteSlowScale = 1;
while (((clock_get_hz(clk_sys) / ((float)analogScale * analogFreq)) < 1.0) && (analogScale >= 6)) {
analogWriteSlowScale++;
analogScale /= 2;
DEBUGCORE("Adjusting analogWrite values SS=%d, scale=%d\n", analogWriteSlowScale, analogScale);
DEBUGCORE("Adjusting analogWrite values SS=%d, scale=%lu\n", analogWriteSlowScale, analogScale);
}
scaleInitted = true;
}
@@ -172,7 +172,7 @@ extern "C" float analogReadTemp(float vref) {
adc_select_input(4); // Temperature sensor
int v = adc_read();
adc_set_temp_sensor_enabled(false);
float t = 27.0f - ((v * vref / pow(2, _readBits)) - 0.706f) / 0.001721f; // From the datasheet
float t = 27.0f - ((v * vref / 4096.0f) - 0.706f) / 0.001721f; // From the datasheet
return t;
}
+87
View File
@@ -0,0 +1,87 @@
ADC Input Library
=================
The ADC pins can be sampled and recorded by an application using the same
interface as the I2S or PWM Audio libraries. This allows analog devices which
need to be periodically sampled to be read by applications, easily, such as:
* Analog electret microphones
* Potentiometers
* Light dependent resistors (LDR), etc.
Up to 4 analog samples can be recorded by the hardware (``A0`` ... ``A4``), 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``
object in lieu of an ``I2S`` input object and choosing the pins to record.
Since this uses the ADC hardware, no ``analogRead`` or ``analogReadTemp`` calls are
allowed while in use.
ADC Input API
-------------
ADCInput(pin0 [, pin1, pin2, pin3])
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Creates an ADC input object which will record the pins specified in the code.
Only pins ``A0`` ... ``A4`` 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)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Set the number of DMA buffers and their size in 32-bit words. Call before
``ADCInput::begin()``.
When running at high sample rates, it is recommended to increase the
``bufferWords`` to 32 or higher (i.e. ``adcinput.setBuffers(4, 32);`` ).
bool setPins(pin_size_t pin [, pin1, pin2, pin3])
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Adjusts the pin to record. Only legal before ``ADCInput::begin()``.
bool setFrequency(long sampleRate)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sets the ADC sampling frequency, but does not start recording (however if the
device was already running, it will wontinue to run at the new frequency). Note
that every pin requested will be sampled at this frequency, one after the other.
That is, if you have code like this:
.. code:: cpp
ADCInput adc(A0, A1);
adc.setFrequency(1000);
``A0`` will be sampled at 0ms, 1ms, 2ms, etc. and ``A1`` will be sampled at 0.5ms
1.5ms, 2.5ms, etc. Each input is sampled at the proper frequency but offset in time
since there is only one active ADC at a time.
bool begin()/begin(long sampleRate)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Start the ADC input up with the given sample rate, or with the value set
using the prior ``setFrequency`` call.
void end()
~~~~~~~~~~
Stops the ADC Input device.
int read()
~~~~~~~~~~
Reads a single sample of recorded ADC data, as a 16-bit value. When multiple pins are
recorded the first read will be pin 0, the second will be pin 1, etc. Applications need
to keep track of which pin is being returned (normally by always reading out all pins
at once). Will not return until data is available.
int available()
~~~~~~~~~~~~~~~
Returns the number of samples that can be read without potentially blocking.
void onReceive(void (\*fn)(void))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sets a callback to be called when a ADC input DMA buffer is fully filled.
Will be in an interrupt context so the specified function must operate
quickly and not use blocking calls like delay().
+2 -2
View File
@@ -14,12 +14,12 @@ Returns a value from 0...4095 correspionding to the ADC reading
of the specific pin.
void analogReadResolution(int bits)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Determines the resolution (in bits) of the value returned by the analogRead() function.
Default resolution is 10bit.
float analogReadTemp(float vref = 3.3f)
~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Returns the temperature, in Celsius, of the onboard thermal sensor.
If you have a custom Vref for the ADC on your RP2040 board, you can pass it in as a parameter. Calling with no parameters assumes the normal, 3.3V Vref.
This reading is not exceedingly accurate and of relatively low
+2 -2
View File
@@ -54,9 +54,9 @@ author = u'Earle F. Philhower, III'
# built documents.
#
# The short X.Y version.
version = u'2.7.0'
version = u'2.7.3'
# The full version, including alpha/beta/rc tags.
release = u'2.7.0'
release = u'2.7.3'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
+99
View File
@@ -0,0 +1,99 @@
Contributing and Porting to the Core
====================================
First of all, thank you for contributing to the project. It's a lot of work
keeping up with all the different uses of the RP2040, so the more people
working on the code, the better. Your assistance can help the project
succeed.
Contributing to the Core (Pull Requests)
----------------------------------------
We use the standard GitHub Pull Request model. If you're unfamiliar with it,
this `guide <https://www.freecodecamp.org/news/how-to-make-your-first-pull-request-on-github-3/>` gives a simple overview of the process.
All pull requests have to pass a set of Continuous Integration (CI) checks
which help make sure the code compiles under different configurations and has
no spelling or style errors.
Tips for a Good Pull Request (PR)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All code in the core and libraries, except for INO sketches, uses a 4-space
indent with cuddled brackets. When in doubt, copy your formatting from the
surrounding code. You should install ``astyle`` and run ``tests/restyle.sh``
on your machine before committing and pushing any pull requests to ensure
the formatting is correct.
Describe the change you're proposing and why it's important in your
``git commit`` message. If it fixes an open issue, place ``Fixes #xxxx``
(where xxxx is the issue number) in the message to link the two.
Try and only change one thing per pull request. That makes it easier to
review and prioritize. Opening up a separate PR per change also helps keep
track of them when release messages are generated.
Adding a New Board
------------------
Adding a new board requires:
* Updated ``tools/makeboards.py`` script
* Updated ``boards.txt`` file, generated by ``makeboard.py``
* Updated ``package_pico_index.template.json`` file, generated by ``makeboard.py``
* New ``tools/json/BOARD_NAME.json`` board file for Platform.IO
* New ``variants/BOARD_NAME/pins_arduino.h`` header defining the I/O pins
To add a new RP2040 board you will need to update the ``tools/makeboards.py``
script. Do *NOT* manually edit ``boards.txt``, that file is machine generated.
You will need to add a ``MakeBoard`` call at the end of the file. Please be sure
to add your board so that it sorts alphabetically, starting with the company name
and then the board name. Otherwise it is hard to find a specific board in the menu.
Run ``python3 tools/makeboards.py`` to update the ``boards.txt`` file and generate
a Platform.IO JSON file in the ``tools/json`` directory.
Create a folder called ``variants/BOARD_NAME`` and place in a ``pins_arduino.h``
file in it that contains your default pin name mapping (i.e. SPI0/1 pins, UART
pins, LED_DEFAULT, etc.). Copying one of the existing ones as a template can
make this task much simpler.
In your ``git commit`` be sure to add the newly generated ``tools/json/XXX.json``
file as well as the modified ``makeboards`` script and ``boards.txt``, the new
``pins_arduino.h`` header you generated, and the Arduino packaging JSON
``package/package_pico_index.template.json``. You should also add a note in
the ``README.md`` file listing your new board.
Submit the updated commit as a PR and, if all goes well, your board will be in
on the next core release.
Porting Libraries and Applications to the Core
----------------------------------------------
We try and follow Arduino standards so, with luck, porting to this core should
be relatively straightforward. The ``WiFi`` library and associates support
libraries like ``WebServer`` are modeled after the ESP32 and ESP8266 versions
of those libraries, combined with the "standard" Arduino ``WiFi`` one.
Compiler Defines for Porting
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you are adding RP2040 support to an existing library and need to isolate
code that only runs on this core, use the following define.
.. code:: cpp
#if defined(ARDUINO_ARCH_RP2040)
~~~ your changes ~~~
#endif
Library Architectures
~~~~~~~~~~~~~~~~~~~~~
After adding support in the code, libraries need their ``library.properties``
and ``library.json`` files updated to indicate support, or the IDE will
not know your new code is compatible here.
Add ``rp2040`` to ``architectures`` (in ``library.properties``) and
``"rp2040"`` to ``platforms[]`` (in ``library.json``) to let the tools know.
+2 -2
View File
@@ -1,5 +1,5 @@
Getting Help and Contributing
=============================
Getting Help
============
This is a community supported project and has multiple ways to get assistance.
Posting complete details, in a polite and organized way will get the best
+6
View File
@@ -58,6 +58,12 @@ Sets the word clock frequency, but does not start the I2S device if not
already running. May be called after ``I2S::begin()`` to change the
sample rate on-the-fly.
bool setLSBJFormat()
~~~~~~~~~~~~~~~~~~~~
Enables LSB-J format for I2S output. In this mode the MSB comes out at the
same time as the LRCLK changes, and not the normal 1-cycle delay. Useful for
DAC chips like the PT8211.
bool begin()/begin(long sampleRate)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Start the I2S device up with the given sample rate, or with the value set
+5 -1
View File
@@ -16,7 +16,9 @@ For the latest version, always check https://github.com/earlephilhower/arduino-p
:maxdepth: 2
:caption: Contents:
Getting Help and Contributing <help>
Getting Help <help>
Contributing <contrib>
Installation <install>
IDE Menus <ide>
@@ -30,6 +32,8 @@ For the latest version, always check https://github.com/earlephilhower/arduino-p
Digital I/O <digital>
EEPROM <eeprom>
I2S Audio <i2s>
PWM Audio <pwm>
Microphone (and Analog Sensor) Input <adc>
Serial USB and UARTs <serial>
"Software Serial" PIO UART <piouart>
Servo <servo>
+34 -8
View File
@@ -9,14 +9,6 @@ installation.
Installing via Arduino Boards Manager
-------------------------------------
**Note for Windows Users**: Please do not use the Windows Store version of
the actual Arduino application because it has issues detecting attached Pico
boards. Use the "Windows ZIP" or plain "Windows" executable (EXE) download
direct from https://arduino.cc. and allow it to install any device drivers
it suggests. Otherwise the Pico board may not be detected. Also, if trying
out the 2.0 beta Arduino please install the release 1.8 version beforehand
to ensure needed device drivers are present.
1. Open up the Arduino IDE and go to File->Preferences.
2. In the dialog that pops up, enter the following URL in the "Additional Boards Manager URLs" field: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
@@ -28,6 +20,24 @@ to ensure needed device drivers are present.
.. image:: images/install2.png
Arduino IDE Installation Warning
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**Note for Windows Users**: Please do not use the Windows Store version of
the actual Arduino application because it has issues detecting attached Pico
boards. Use the "Windows ZIP" or plain "Windows" executable (EXE) download
direct from https://arduino.cc. and allow it to install any device drivers
it suggests. Otherwise the Pico board may not be detected. Also, if trying
out the 2.0 beta Arduino please install the release 1.8 version beforehand
to ensure needed device drivers are present.
**Note for Linux Users**: If you installed the Arduino IDE using Flatpak, which
is common in Pop!_OS, Fedora, and Mint, among others, you may need to configure
Flatpak to allow the IDE access to files outside your home folder. The RP2040
device is sometimes mounted as a folder in /opt or /media, which Flatpak will
prevent the Arduino IDE from accessing. For Arduino IDE V2, override the filesystem
restriction using ``flatpak override --user --filesystem=host cc.arduino.IDE2`` . For
For Arduino IDE < V2, use ``flatpak override --user --filesystem=host cc.arduino.arduinoide``.
Installing via GIT
------------------
To install via GIT (for latest and greatest versions):
@@ -125,6 +135,22 @@ For detailed usage information, please check the repo documentation available at
* https://arduino-pico.readthedocs.io/en/latest/fs.html
Uploading Sketches with Picotool
--------------------------------
Because the Picotool uses a custom device driver in the Pico to handle upload, when using the ``Upload Method->Picotool`` mode custom code needs to be run on the Pico which is not included by default for compatibility and code savings.
So for the first sketch you will need to rebuild (with the ``Upload Method->Picotool`` selected in them menus) and then manually hold down BOOTSEL and insert the Pico USB cable to enter the ROM bootloader.
After the initial upload, as long as the running binary was built using the ``Picotool`` upload method, then the normal upload process should work.
Note that for Ubuntu and other Linux operating systems you may need to add the following lines to a new `udev` config file(``99-picotool.rules``) to allow normal users to access the special USB device the Pico exports:
.. code::
echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="0003", MODE="660", GROUP="plugdev"' | sudo tee -a /etc/udev/rules.d/98-Picotool.rules
echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="000a", MODE="660", GROUP="plugdev"' | sudo tee -a /etc/udev/rules.d/98-Picotool.rules
sudo udevadm control --reload
Uploading Sketches with Picoprobe
---------------------------------
If you have built a Raspberry Pi Picoprobe, you can use OpenOCD to handle your sketch uploads and for debugging with GDB.
+97
View File
@@ -0,0 +1,97 @@
PWM Audio Library
=================
Relatively good quality analog audio out can be generated by using the
RP2040 onboard PWM hardware. It can drive an amplifier for speaker output,
or be decoupled using a capacitor to drive a headphone-level signal. Mono
and stereo signals can be generated.
All samples are sent to the ``PWMAudio`` library as **signed 16 bits per sample**.
Due to frequency limitations of the PWM hardware, at higher bit rates
these 16-bits will automatically be reduced to the maximum the hardware
can handle.
Multiple ``PWMAudio`` devices are supported, depending on availability of
DMA channels.
The interface for the ``PWMAudio`` device is very similar to the ``I2S``
device, and most code can be ported simply by instantiating a ``PWMAudio``
object in lieu of an ``I2S`` object.
PWM Class API
-------------
PWMAudio(pin)
~~~~~~~~~~~~~
Creates a mono PWM output port. Any pin can be used, but no ``analogWrite``
calls are allowed to any other pins using that pin's PWM slice hardware.
See the RP2040 datasheet for more details about PWM slices.
PWMAudio(pin, true)
~~~~~~~~~~~~~~~~~~~
Creates a stereo PWM output port. Only even pins (left signal) can be used, the next odd
pin will automatically be assigned to the right channel (i.e. ``PWMAudio pwm(0, true);``
will make GP0 as the left channel, GP1 as the right channel). The same restriction as
in mono mode applies.
bool setBuffers(size_t buffers, size_t bufferWords)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Set the number of DMA buffers and their size in 32-bit words.
Call before ``PWMAudio::begin()``.
When running at high sample rates, it is recommended to increase the
``bufferWords`` to 32 or higher (i.e. ``pwm.setBuffers(4, 32);`` ).
bool setPin(pin_size_t pin)
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Adjusts the pin to connect to the PWM audio output. Only legal before
``PWMAudio::begin()``.
bool setStereo(bool stereo)
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Adjusts the mono/stereo setting of the PWM audio output. Only legal before
``PWMAudio::begin()``.
bool setFrequency(long sampleRate)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sets the sample frequency, but does not start the PWM device (however if the
device was already running, it will wontinue to run at the new frequency).
bool begin()/begin(long sampleRate)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Start the PWM Audio device up with the given sample rate, or with the value set
using the prior ``setFrequency`` call.
void end()
~~~~~~~~~~
Stops the PWMAudio device.
void flush()
~~~~~~~~~~~~
Waits until all the PWM Audio buffers have been output.
size_t write(int16_t sample, bool sync = true)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Writes a single 16-bit sample to the buffer. It is up to the user to keep track
of left/right channels when in stereo mode. In mono mode, one sample is written
per timestep while in stereo mode two ``write()`` calls are required.
This call will block (wait) until space is available to actually write
the data if ``sync`` is not specified or set to ``true``.
size_t write(const uint8_t \*buffer, size_t size)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Transfers number of bytes from an application buffer to the PWM Audio output buffer.
Be aware that ``size`` is in *bytes** and not samples. Size must be a multiple
of **4 bytes**. Will not block, so check the return value to find out how
many bytes were actually written.
int availableForWrite()
~~~~~~~~~~~~~~~~~~~~~~~
Returns the number of samples that can be written without potentially blocking.
void onTransmit(void (\*fn)(void))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sets a callback to be called when a PWM Audio DMA buffer is fully transmitted.
Will be in an interrupt context so the specified function must operate
quickly and not use blocking calls like delay() or write to the PWM Audio.
+15 -2
View File
@@ -13,6 +13,10 @@ Returns the current frequency of the core clock. This is read at runtime,
versus the constant ``F_CPU`` macro that is also available. This is useful
in cases where your code changes the core clock (i.e. low power modes, etc.)
int rp2040.cpuid()
~~~~~~~~~~~~~~~~~~
Returns the current core ID (0 or 1) of the executing task.
uint32_t rp2040.getCycleCount()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Returns a 32-bit cycle count from then the core started running. Because it
@@ -41,13 +45,13 @@ Hardware Watchdog
-----------------
void rp2040.wdt_begin(uint32_t delay_ms)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enables the hardware watchdog timer with a delay value of delay_ms
milliseconds. Note that on the RP2040, once this function has called, the
hardware watchdog can _not_ be disabled.
void rp2040.wdt_reset()
~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~
Reloads the watchdog's counter with the amount of time set by wdt_begin.
@@ -71,6 +75,15 @@ Returns the total heap that was available to this program at compile time (i.e.
the Pico RAM size minus things like the ``.data`` and ``.bss`` sections and other
overhead).
Hardware Identification
-----------------------
bool isPicoW()
~~~~~~~~~~~~~~
Returns the core's best guess if this code is running on a Raspberry Pi Pico W.
This would let you, possibly, use the same UF2 for Pico and PicoW by simply not
doing any WiFi calls.
Bootloader
----------
+2
View File
@@ -44,6 +44,8 @@ restartCore1 KEYWORD2
reboot KEYWORD2
restart KEYWORD2
isPicoW KEYWORD2
getChipID KEYWORD2
hwrand32 KEYWORD2
+10 -6
View File
@@ -191,11 +191,6 @@ SECTIONS
__data_end__ = .;
} > RAM AT> FLASH
.uninitialized_data (COPY): {
. = ALIGN(4);
*(.uninitialized_data*)
} > RAM
/* Start and end symbols must be word-aligned */
.scratch_x : {
__scratch_x_start__ = .;
@@ -213,7 +208,7 @@ SECTIONS
} > SCRATCH_Y AT > FLASH
__scratch_y_source__ = LOADADDR(.scratch_y);
.bss : {
.bss : {
. = ALIGN(4);
__bss_start__ = .;
*(SORT_BY_ALIGNMENT(SORT_BY_NAME(.bss*)))
@@ -222,6 +217,15 @@ SECTIONS
__bss_end__ = .;
} > RAM
/* At most one of the following two will be engaged, depending on the SDK version */
.uninitialized_ram MAX(0x20003000, .) (NOLOAD) : {
*(.uninitialized_ram*)
} > RAM
.uninitialized_data MAX(0x20003000, .) (NOLOAD) : {
*(.uninitialized_data*)
} > RAM
.heap (COPY):
{
__end__ = .;
BIN
View File
Binary file not shown.
+2
View File
@@ -0,0 +1,2 @@
source [find interface/cmsis-dap.cfg]
source [find target/rp2040.cfg]
+1
View File
@@ -9,6 +9,7 @@
-iwithprefixbefore/pico-sdk/src/common/pico_stdlib/include
-iwithprefixbefore/pico-sdk/src/common/pico_sync/include
-iwithprefixbefore/pico-sdk/src/common/pico_time/include
-iwithprefixbefore/pico-sdk/src/common/pico_usb_reset_interface/include
-iwithprefixbefore/pico-sdk/src/common/pico_util/include
-iwithprefixbefore/pico-sdk/src/rp2040/hardware_regs/include
-iwithprefixbefore/pico-sdk/src/rp2040/hardware_structs/include
@@ -0,0 +1,30 @@
/*
Mono analog microphone example using electret mike on A0
Run using the Arduino Serial Plotter to see waveform.
Released to the Public Domain by Earle F. Philhower, III
Wire the mike's VCC to 3.3V on the Pico, connect the mike's
GND to a convenient Pico GND, and then connect mike OUT to A0
*/
#include <ADCInput.h>
ADCInput mike(A0);
// For stereo/dual mikes, could use this line instead
// ADCInput(A0, A1);
void setup() {
Serial.begin(115200);
mike.begin(8000);
while (1) {
Serial.printf("%d\n", mike.read());
// For stereo/dual mikes, use this line instead
// Serial.printf("%d %d\n", mike.read(), mike.read());
}
}
void loop() {
/* Nothing here */
}
+25
View File
@@ -0,0 +1,25 @@
#######################################
# Syntax Coloring Map
#######################################
#######################################
# Datatypes (KEYWORD1)
#######################################
ADCInput KEYWORD1
#######################################
# Methods and Functions (KEYWORD2)
#######################################
begin KEYWORD2
end KEYWORD2
setPins KEYWORD2
setFrequency KEYWORD2
setBuffers KEYWORD2
onReceive KEYWORD2
#######################################
# Constants (LITERAL1)
#######################################
+10
View File
@@ -0,0 +1,10 @@
name=ADCInput
version=1.0
author=Earle F. Philhower, III <earlephilhower@yahoo.com>
maintainer=Earle F. Philhower, III <earlephilhower@yahoo.com>
sentence=Records ADC values (i.e. microphone, sensors) and presents an I2S-like callback/immediate read interface
paragraph=Records ADC values (i.e. microphone, sensors) and presents an I2S-like callback/immediate read interface
category=Communication
url=http://github.com/earlephilhower/arduino-pico
architectures=rp2040
dot_a_linkage=true
+172
View File
@@ -0,0 +1,172 @@
/*
ADCInput
Records ADC values (i.e. microphone, sensors) and presents an I2S-like
callback/immediate read interface
Copyright (c) 2023 Earle F. Philhower, III <earlephilhower@yahoo.com>
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 "ADCInput.h"
#include <hardware/adc.h>
ADCInput::ADCInput(pin_size_t p0, pin_size_t p1, pin_size_t p2, pin_size_t p3) {
_running = false;
setPins(p0, p1, p2, p3);
_freq = 48000;
_arb = nullptr;
_cb = nullptr;
_buffers = 8;
_bufferWords = 0;
}
ADCInput::~ADCInput() {
end();
}
bool ADCInput::setBuffers(size_t buffers, size_t bufferWords) {
if (_running || (buffers < 3) || (bufferWords < 8)) {
return false;
}
_buffers = buffers;
_bufferWords = bufferWords;
return true;
}
int ADCInput::_mask(pin_size_t p) {
switch (p) {
case 26: return 1;
case 27: return 2;
case 28: return 4;
case 29: return 8;
default: return 0;
}
}
bool ADCInput::setPins(pin_size_t pin0, pin_size_t pin1, pin_size_t pin2, pin_size_t pin3) {
if (_running) {
return false;
}
_pinMask = _mask(pin0) | _mask(pin1) | _mask(pin2) | _mask(pin3);
return true;
}
bool ADCInput::setFrequency(int newFreq) {
_freq = newFreq * __builtin_popcount(_pinMask); // Want to sample all channels at given frequency
adc_set_clkdiv(48000000.0f / _freq - 1.0f);
return true;
}
void ADCInput::onReceive(void(*fn)(void)) {
_cb = fn;
if (_running) {
_arb->setCallback(_cb);
}
}
bool ADCInput::begin() {
_running = true;
_isHolding = 0;
if (!_bufferWords) {
_bufferWords = 16;
}
// Set up the GPIOs to go to ADC
adc_init();
int cnt = 0;
for (int mask = 1, pin = 26; pin <= 29; mask <<= 1, pin++) {
if (_pinMask & mask) {
if (!cnt) {
adc_select_input(pin - 26);
}
cnt++;
adc_gpio_init(pin);
}
}
adc_set_round_robin(_pinMask);
adc_fifo_setup(true, true, 1, false, false);
setFrequency(_freq);
_arb = new AudioBufferManager(_buffers, _bufferWords, 0, INPUT, DMA_SIZE_16);
_arb->begin(DREQ_ADC, (volatile void*)&adc_hw->fifo);
_arb->setCallback(_cb);
adc_fifo_drain();
adc_run(true);
return true;
}
void ADCInput::end() {
if (_running) {
_running = false;
delete _arb;
_arb = nullptr;
}
adc_run(false);
adc_fifo_drain();
}
int ADCInput::available() {
if (!_running) {
return 0;
} else {
return _arb->available();
}
}
int ADCInput::read() {
if (!_running) {
return -1;
}
if (_hasPeeked) {
_hasPeeked = false;
return _peekSaved;
}
if (_isHolding <= 0) {
_arb->read(&_holdWord, true);
_isHolding = 32;
}
int ret = _holdWord & 0x0fff;
_holdWord >>= 16;
_isHolding -= 16;
return ret;
}
int ADCInput::peek() {
if (!_running) {
return -1;
}
if (!_hasPeeked) {
_peekSaved = read();
_hasPeeked = true;
}
return _peekSaved;
}
void ADCInput::flush() {
if (_running) {
_arb->flush();
}
}
+87
View File
@@ -0,0 +1,87 @@
/*
ADCInput
Records ADC values (i.e. microphone, sensors) and presents an I2S-like
callback/immediate read interface
Copyright (c) 2023 Earle F. Philhower, III <earlephilhower@yahoo.com>
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
*/
#pragma once
#include <Arduino.h>
#include "AudioBufferManager.h"
class ADCInput : public Stream {
public:
ADCInput(pin_size_t pin0, pin_size_t pin1 = 255, pin_size_t pin2 = 255, pin_size_t pin3 = 255);
virtual ~ADCInput();
bool setBuffers(size_t buffers, size_t bufferWords);
bool setFrequency(int newFreq);
bool setPins(pin_size_t pin0, pin_size_t pin1 = 255, pin_size_t pin2 = 255, pin_size_t pin3 = 255);
bool begin(long sampleRate) {
setFrequency(sampleRate);
return begin();
}
bool begin();
void end();
// from Stream
virtual int available() override;
virtual int read() override;
virtual int peek() override;
virtual void flush() override;
// from Print, not supported
virtual size_t write(const uint8_t *buffer, size_t size) override {
(void) buffer;
(void) size;
return -1;
}
virtual size_t write(uint8_t x) override {
(void) x;
return -1;
}
virtual int availableForWrite() override {
return 0;
}
// Note that these callback are called from **INTERRUPT CONTEXT** and hence
// should be in RAM, not FLASH, and should be quick to execute.
void onReceive(void(*)(void));
private:
uint32_t _pinMask;
int _freq;
size_t _buffers;
size_t _bufferWords;
bool _running;
void (*_cb)();
bool _hasPeeked;
uint32_t _peekSaved;
uint32_t _holdWord = 0;
int _isHolding = 0;
int _mask(pin_size_t pin);
AudioBufferManager *_arb;
};
@@ -59,6 +59,7 @@ AudioBufferManager::AudioBufferManager(size_t bufferCount, size_t bufferWords, i
for (size_t i = 0; i < bufferCount; i++) {
auto ab = new AudioBuffer;
ab->buff = new uint32_t[_wordsPerBuffer];
bzero(ab->buff, _wordsPerBuffer * 4);
ab->next = nullptr;
_addToList(&_empty, ab);
}
@@ -68,11 +69,15 @@ AudioBufferManager::AudioBufferManager(size_t bufferCount, size_t bufferWords, i
}
AudioBufferManager::~AudioBufferManager() {
noInterrupts();
if (_running) {
_running = false;
for (auto i = 0; i < 2; i++) {
dma_channel_set_irq0_enabled(_channelDMA[i], false);
dma_channel_unclaim(_channelDMA[i]);
__channelMap[_channelDMA[i]] = nullptr;
dma_channel_abort(_channelDMA[i]);
dma_channel_unclaim(_channelDMA[i]);
dma_channel_acknowledge_irq0(_channelDMA[i]);
}
__channelCount--;
if (!__channelCount) {
@@ -81,6 +86,7 @@ AudioBufferManager::~AudioBufferManager() {
irq_remove_handler(DMA_IRQ_0, _irq);
}
}
interrupts();
for (int i = 0; i < 2; i++) {
if (_active[i] != _silence) {
_deleteAudioBuffer(_active[i]);
@@ -133,10 +139,10 @@ bool AudioBufferManager::begin(int dreq, volatile void *pioFIFOAddr) {
channel_config_set_irq_quiet(&c, false); // Need IRQs
if (_isOutput) {
dma_channel_configure(_channelDMA[i], &c, pioFIFOAddr, _silence->buff, _wordsPerBuffer, false);
dma_channel_configure(_channelDMA[i], &c, pioFIFOAddr, _silence->buff, _wordsPerBuffer * (_dmaSize == DMA_SIZE_16 ? 2 : 1), false);
} else {
_active[i] = _takeFromList(&_empty);
dma_channel_configure(_channelDMA[i], &c, _active[i]->buff, pioFIFOAddr, _wordsPerBuffer, false);
dma_channel_configure(_channelDMA[i], &c, _active[i]->buff, pioFIFOAddr, _wordsPerBuffer * (_dmaSize == DMA_SIZE_16 ? 2 : 1), false);
}
dma_channel_set_irq0_enabled(_channelDMA[i], true);
__channelMap[_channelDMA[i]] = this;
@@ -237,6 +243,9 @@ void AudioBufferManager::flush() {
}
void __not_in_flash_func(AudioBufferManager::_dmaIRQ)(int channel) {
if (!_running) {
return;
}
if (_isOutput) {
if (_active[0] != _silence) {
_addToList(&_empty, _active[0]);
@@ -259,7 +268,7 @@ void __not_in_flash_func(AudioBufferManager::_dmaIRQ)(int channel) {
}
dma_channel_set_write_addr(channel, _active[0]->buff, false);
}
dma_channel_set_trans_count(channel, _wordsPerBuffer, false);
dma_channel_set_trans_count(channel, _wordsPerBuffer * (_dmaSize == DMA_SIZE_16 ? 2 : 1), false);
dma_channel_acknowledge_irq0(channel);
if (_callback) {
_callback();
@@ -30,7 +30,7 @@ void ps() {
Serial.printf("# Tasks: %d\n", tasks);
Serial.println("ID, NAME, STATE, PRIO, CYCLES");
for (int i=0; i < tasks; i++) {
Serial.printf("%d: %-16s %-10s %d %lu\n", i, pxTaskStatusArray[i].pcTaskName, eTaskStateName[pxTaskStatusArray[i].eCurrentState], pxTaskStatusArray[i].uxCurrentPriority, pxTaskStatusArray[i].ulRunTimeCounter);
Serial.printf("%d: %-16s %-10s %d %lu\n", i, pxTaskStatusArray[i].pcTaskName, eTaskStateName[pxTaskStatusArray[i].eCurrentState], (int)pxTaskStatusArray[i].uxCurrentPriority, pxTaskStatusArray[i].ulRunTimeCounter);
}
delete[] pxTaskStatusArray;
}
+29
View File
@@ -0,0 +1,29 @@
/**
simple demo to show sha1 calculation
*/
#include <Arduino.h>
#include <Hash.h>
void setup() {
Serial.begin(115200);
}
void loop() {
// usage as String
// SHA1:a9993e364706816aba3e25717850c26c9cd0d89d
Serial.print("SHA1:");
Serial.println(sha1("abc"));
// usage as ptr
// SHA1:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3
uint8_t hash[20];
sha1("test", &hash[0]);
Serial.print("SHA1:");
for (uint16_t i = 0; i < 20; i++) { Serial.printf("%02x", hash[i]); }
Serial.println();
delay(1000);
}
+23
View File
@@ -0,0 +1,23 @@
#######################################
# Syntax Coloring Map For Hash
#######################################
#######################################
# Library (KEYWORD3)
#######################################
Hash KEYWORD3 RESERVED_WORD
#######################################
# Datatypes (KEYWORD1)
#######################################
#######################################
# Methods and Functions (KEYWORD2)
#######################################
sha1 KEYWORD2
#######################################
# Constants (LITERAL1)
#######################################
+10
View File
@@ -0,0 +1,10 @@
name=Hash
version=1.0
author=Markus Sattler
maintainer=Markus Sattler
sentence=Generate Hash from data
paragraph=
category=Data Processing
url=
architectures=rp2040
dot_a_linkage=true
+96
View File
@@ -0,0 +1,96 @@
/**
* @file Hash.cpp
* @date 20.05.2015
* @author Markus Sattler
*
* Copyright (c) 2015 Markus Sattler. All rights reserved.
* This file is part of the esp8266 core for Arduino environment.
*
* 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 <bearssl/bearssl_hash.h>
#include "Hash.h"
/**
* create a sha1 hash from data
* @param data uint8_t *
* @param size uint32_t
* @param hash uint8_t[20]
*/
void sha1(const uint8_t* data, uint32_t size, uint8_t hash[20]) {
br_sha1_context ctx;
#ifdef DEBUG_SHA1
os_printf("DATA:");
for(uint16_t i = 0; i < size; i++) {
os_printf("%02X", data[i]);
}
os_printf("\n");
os_printf("DATA:");
for(uint16_t i = 0; i < size; i++) {
os_printf("%c", data[i]);
}
os_printf("\n");
#endif
br_sha1_init(&ctx);
br_sha1_update(&ctx, data, size);
br_sha1_out(&ctx, hash);
#ifdef DEBUG_SHA1
os_printf("SHA1:");
for(uint16_t i = 0; i < 20; i++) {
os_printf("%02X", hash[i]);
}
os_printf("\n\n");
#endif
}
void sha1(const char* data, uint32_t size, uint8_t hash[20]) {
sha1((const uint8_t *) data, size, hash);
}
void sha1(const String& data, uint8_t hash[20]) {
sha1(data.c_str(), data.length(), hash);
}
String sha1(const uint8_t* data, uint32_t size) {
uint8_t hash[20];
String hashStr((const char*)nullptr);
hashStr.reserve(20 * 2 + 1);
sha1(&data[0], size, &hash[0]);
for(uint16_t i = 0; i < 20; i++) {
char hex[3];
snprintf(hex, sizeof(hex), "%02x", hash[i]);
hashStr += hex;
}
return hashStr;
}
String sha1(const char* data, uint32_t size) {
return sha1((const uint8_t*) data, size);
}
String sha1(const String& data) {
return sha1(data.c_str(), data.length());
}
+38
View File
@@ -0,0 +1,38 @@
/**
* @file Hash.h
* @date 20.05.2015
* @author Markus Sattler
*
* Copyright (c) 2015 Markus Sattler. All rights reserved.
* This file is part of the esp8266 core for Arduino environment.
*
* 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
*
*/
#ifndef HASH_H_
#define HASH_H_
//#define DEBUG_SHA1
void sha1(const uint8_t* data, uint32_t size, uint8_t hash[20]);
void sha1(const char* data, uint32_t size, uint8_t hash[20]);
void sha1(const String& data, uint8_t hash[20]);
String sha1(const uint8_t* data, uint32_t size);
String sha1(const char* data, uint32_t size);
String sha1(const String& data);
#endif /* HASH_H_ */
+1
View File
@@ -19,6 +19,7 @@ setDATA KEYWORD2
setBitsPerSample KEYWORD2
setFrequency KEYWORD2
setBuffers KEYWORD2
setLSBJFormat KEYWORD2
read8 KEYWORD2
read16 KEYWORD2
+37 -21
View File
@@ -51,6 +51,7 @@ I2S::I2S(PinMode direction) {
_buffers = 8;
_bufferWords = 0;
_silenceSample = 0;
_isLSBJ = false;
}
I2S::~I2S() {
@@ -99,6 +100,14 @@ bool I2S::setFrequency(int newFreq) {
return true;
}
bool I2S::setLSBJFormat() {
if (_running || !_isOutput) {
return false;
}
_isLSBJ = true;
return true;
}
void I2S::onTransmit(void(*fn)(void)) {
if (_isOutput) {
_cb = fn;
@@ -121,10 +130,14 @@ bool I2S::begin() {
_running = true;
_hasPeeked = false;
int off = 0;
_i2s = new PIOProgram(_isOutput ? &pio_i2s_out_program : &pio_i2s_in_program);
_i2s = new PIOProgram(_isOutput ? (_isLSBJ ? &pio_lsbj_out_program : &pio_i2s_out_program) : &pio_i2s_in_program);
_i2s->prepare(&_pio, &_sm, &off);
if (_isOutput) {
pio_i2s_out_program_init(_pio, _sm, off, _pinDOUT, _pinBCLK, _bps);
if (_isLSBJ) {
pio_lsbj_out_program_init(_pio, _sm, off, _pinDOUT, _pinBCLK, _bps);
} else {
pio_i2s_out_program_init(_pio, _sm, off, _pinDOUT, _pinBCLK, _bps);
}
} else {
pio_i2s_in_program_init(_pio, _sm, off, _pinDOUT, _pinBCLK, _bps);
}
@@ -148,11 +161,14 @@ bool I2S::begin() {
}
void I2S::end() {
_running = false;
delete _arb;
_arb = nullptr;
delete _i2s;
_i2s = nullptr;
if (_running) {
pio_sm_set_enabled(_pio, _sm, false);
_running = false;
delete _arb;
_arb = nullptr;
delete _i2s;
_i2s = nullptr;
}
}
int I2S::available() {
@@ -175,9 +191,9 @@ int I2S::read() {
return _peekSaved;
}
if (_wasHolding <= 0) {
if (_isHolding <= 0) {
read(&_holdWord, true);
_wasHolding = 32;
_isHolding = 32;
}
int ret;
@@ -185,18 +201,18 @@ int I2S::read() {
case 8:
ret = _holdWord >> 24;
_holdWord <<= 8;
_wasHolding -= 8;
_isHolding -= 8;
return ret;
case 16:
ret = _holdWord >> 16;
_holdWord <<= 16;
_wasHolding -= 32;
_isHolding -= 32;
return ret;
case 24:
case 32:
default:
ret = _holdWord;
_wasHolding = 0;
_isHolding = 0;
return ret;
}
}
@@ -225,26 +241,26 @@ size_t I2S::_writeNatural(int32_t s) {
switch (_bps) {
case 8:
_holdWord |= s & 0xff;
if (_wasHolding >= 24) {
if (_isHolding >= 24) {
auto ret = write(_holdWord, true);
_holdWord = 0;
_wasHolding = 0;
_isHolding = 0;
return ret;
} else {
_holdWord <<= 8;
_wasHolding += 8;
_isHolding += 8;
return 1;
}
case 16:
_holdWord |= s & 0xffff;
if (_wasHolding) {
if (_isHolding) {
auto ret = write(_holdWord, true);
_holdWord = 0;
_wasHolding = 0;
_isHolding = 0;
return ret;
} else {
_holdWord <<= 16;
_wasHolding = 16;
_isHolding = 16;
return 1;
}
case 24:
@@ -301,13 +317,13 @@ bool I2S::read8(int8_t *l, int8_t *r) {
if (!_running || _isOutput) {
return false;
}
if (_wasHolding) {
if (_isHolding) {
*l = (_holdWord >> 8) & 0xff;
*r = (_holdWord >> 0) & 0xff;
_wasHolding = 0;
_isHolding = 0;
} else {
read(&_holdWord, true);
_wasHolding = 16;
_isHolding = 16;
*l = (_holdWord >> 24) & 0xff;
*r = (_holdWord >> 16) & 0xff;
}
+3 -1
View File
@@ -33,6 +33,7 @@ public:
bool setBitsPerSample(int bps);
bool setBuffers(size_t buffers, size_t bufferWords, int32_t silenceSample = 0);
bool setFrequency(int newFreq);
bool setLSBJFormat();
bool begin(long sampleRate) {
setFrequency(sampleRate);
@@ -104,6 +105,7 @@ private:
size_t _buffers;
size_t _bufferWords;
int32_t _silenceSample;
bool _isLSBJ;
bool _isOutput;
bool _running;
@@ -116,7 +118,7 @@ private:
bool _writtenHalf;
int32_t _holdWord = 0;
int _wasHolding = 0;
int _isHolding = 0;
void (*_cb)();
+45 -1
View File
@@ -41,6 +41,29 @@ right:
out pins, 1 side 0b00 ; Last bit of right also has WCLK change
; Loop back to beginning...
.program pio_lsbj_out
.side_set 2 ; 0 = bclk, 1=wclk
; The C code should place (number of bits/sample - 2) in Y and
; also update the SHIFTCTRL to be 24 or 32 as appropriate
; +----- WCLK
; |+---- BCLK
mov x, y side 0b01
left:
out pins, 1 side 0b10
jmp x--, left side 0b11
out pins, 1 side 0b10
mov x, y side 0b11
right:
out pins, 1 side 0b00
jmp x--, right side 0b01
out pins, 1 side 0b00
; Loop back to beginning...
.program pio_i2s_in ; Note this is the same as _out, just "in" and not "out"
.side_set 2 ; 0 = bclk, 1=wclk
@@ -73,7 +96,28 @@ static inline void pio_i2s_out_program_init(PIO pio, uint sm, uint offset, uint
pio_gpio_init(pio, clock_pin_base + 1);
pio_sm_config sm_config = pio_i2s_out_program_get_default_config(offset);
sm_config_set_out_pins(&sm_config, data_pin, 1);
sm_config_set_sideset_pins(&sm_config, clock_pin_base);
sm_config_set_out_shift(&sm_config, false, true, (bits <= 16) ? 2 * bits : bits);
sm_config_set_fifo_join(&sm_config, PIO_FIFO_JOIN_TX);
pio_sm_init(pio, sm, offset, &sm_config);
uint pin_mask = (1u << data_pin) | (3u << clock_pin_base);
pio_sm_set_pindirs_with_mask(pio, sm, pin_mask, pin_mask);
pio_sm_set_pins(pio, sm, 0); // clear pins
pio_sm_exec(pio, sm, pio_encode_set(pio_y, bits - 2));
}
static inline void pio_lsbj_out_program_init(PIO pio, uint sm, uint offset, uint data_pin, uint clock_pin_base, uint bits) {
pio_gpio_init(pio, data_pin);
pio_gpio_init(pio, clock_pin_base);
pio_gpio_init(pio, clock_pin_base + 1);
pio_sm_config sm_config = pio_lsbj_out_program_get_default_config(offset);
sm_config_set_out_pins(&sm_config, data_pin, 1);
sm_config_set_sideset_pins(&sm_config, clock_pin_base);
sm_config_set_out_shift(&sm_config, false, true, (bits <= 16) ? 2 * bits : bits);
+50 -1
View File
@@ -43,6 +43,41 @@ static inline pio_sm_config pio_i2s_out_program_get_default_config(uint offset)
}
#endif
// ------------ //
// pio_lsbj_out //
// ------------ //
#define pio_lsbj_out_wrap_target 0
#define pio_lsbj_out_wrap 7
static const uint16_t pio_lsbj_out_program_instructions[] = {
// .wrap_target
0xa822, // 0: mov x, y side 1
0x7001, // 1: out pins, 1 side 2
0x1841, // 2: jmp x--, 1 side 3
0x7001, // 3: out pins, 1 side 2
0xb822, // 4: mov x, y side 3
0x6001, // 5: out pins, 1 side 0
0x0845, // 6: jmp x--, 5 side 1
0x6001, // 7: out pins, 1 side 0
// .wrap
};
#if !PICO_NO_HARDWARE
static const struct pio_program pio_lsbj_out_program = {
.instructions = pio_lsbj_out_program_instructions,
.length = 8,
.origin = -1,
};
static inline pio_sm_config pio_lsbj_out_program_get_default_config(uint offset) {
pio_sm_config c = pio_get_default_sm_config();
sm_config_set_wrap(&c, offset + pio_lsbj_out_wrap_target, offset + pio_lsbj_out_wrap);
sm_config_set_sideset(&c, 2, false, false);
return c;
}
#endif
// ---------- //
// pio_i2s_in //
// ---------- //
@@ -92,6 +127,21 @@ static inline void pio_i2s_out_program_init(PIO pio, uint sm, uint offset, uint
pio_sm_set_pins(pio, sm, 0); // clear pins
pio_sm_exec(pio, sm, pio_encode_set(pio_y, bits - 2));
}
static inline void pio_lsbj_out_program_init(PIO pio, uint sm, uint offset, uint data_pin, uint clock_pin_base, uint bits) {
pio_gpio_init(pio, data_pin);
pio_gpio_init(pio, clock_pin_base);
pio_gpio_init(pio, clock_pin_base + 1);
pio_sm_config sm_config = pio_lsbj_out_program_get_default_config(offset);
sm_config_set_out_pins(&sm_config, data_pin, 1);
sm_config_set_sideset_pins(&sm_config, clock_pin_base);
sm_config_set_out_shift(&sm_config, false, true, (bits <= 16) ? 2 * bits : bits);
sm_config_set_fifo_join(&sm_config, PIO_FIFO_JOIN_TX);
pio_sm_init(pio, sm, offset, &sm_config);
uint pin_mask = (1u << data_pin) | (3u << clock_pin_base);
pio_sm_set_pindirs_with_mask(pio, sm, pin_mask, pin_mask);
pio_sm_set_pins(pio, sm, 0); // clear pins
pio_sm_exec(pio, sm, pio_encode_set(pio_y, bits - 2));
}
static inline void pio_i2s_in_program_init(PIO pio, uint sm, uint offset, uint data_pin, uint clock_pin_base, uint bits) {
pio_gpio_init(pio, data_pin);
pio_gpio_init(pio, clock_pin_base);
@@ -109,4 +159,3 @@ static inline void pio_i2s_in_program_init(PIO pio, uint sm, uint offset, uint d
}
#endif
+2 -2
View File
@@ -457,14 +457,14 @@ public:
if (_creation) {
int rc = lfs_setattr(_fs->getFS(), _name.get(), 'c', (const void *)&_creation, sizeof(_creation));
if (rc < 0) {
DEBUGV("Unable to set creation time on '%s' to %d\n", _name.get(), _creation);
DEBUGV("Unable to set creation time on '%s' to %lld\n", _name.get(), _creation);
}
}
// Add metadata with last write time
time_t now = _timeCallback();
int rc = lfs_setattr(_fs->getFS(), _name.get(), 't', (const void *)&now, sizeof(now));
if (rc < 0) {
DEBUGV("Unable to set last write time on '%s' to %d\n", _name.get(), now);
DEBUGV("Unable to set last write time on '%s' to %lld\n", _name.get(), now);
}
}
}
+3
View File
@@ -38,6 +38,7 @@ public:
//PORTENTA_H7 min -12 max 51
//NANO 33 BLE SENSe min 0 max 80
//NICLA_VISION min 0 max 8
void setGain(int gain);
void setBufferSize(int bufferSize);
size_t getBufferSize();
@@ -56,6 +57,8 @@ private:
int _gain;
int _init;
int _cutSamples;
// Hardware peripherals used
uint _dmaChannel;
PIO _pio;
+54 -19
View File
@@ -20,7 +20,7 @@ uint8_t rawBuffer1[RAW_BUFFER_SIZE];
uint8_t* rawBuffer[2] = {rawBuffer0, rawBuffer1};
volatile int rawBufferIndex = 0;
int decimation = 64;
int decimation = 128;
// final buffer is the one to be filled with PCM data
int16_t* volatile finalBuffer;
@@ -45,6 +45,7 @@ PDMClass::PDMClass(int dinPin, int clkPin, int pwrPin) :
_channels(-1),
_samplerate(-1),
_init(-1),
_cutSamples(100),
_dmaChannel(0),
_pio(nullptr),
_smIdx(-1),
@@ -55,6 +56,12 @@ PDMClass::~PDMClass() {
}
int PDMClass::begin(int channels, int sampleRate) {
if (_init == 1) {
//ERROR: please call end first
return 0;
}
//_channels = channels; // only one channel available
// clear the final buffers
@@ -63,6 +70,18 @@ int PDMClass::begin(int channels, int sampleRate) {
int finalBufferLength = _doubleBuffer.availableForWrite() / sizeof(int16_t);
_doubleBuffer.swap(0);
// The mic accepts an input clock from 1.2 to 3.25 Mhz
// Setup the decimation factor accordingly
if ((sampleRate * decimation * 2) > 3250000) {
decimation = 64;
}
// Sanity check, abort if still over 3.25Mhz
if ((sampleRate * decimation * 2) > 3250000) {
//ERROR: Sample rate too high, the mic would glitch
return -1;
}
int rawBufferLength = RAW_BUFFER_SIZE / (decimation / 8);
// Saturate number of samples. Remaining bytes are dropped.
if (rawBufferLength > finalBufferLength) {
@@ -71,6 +90,7 @@ int PDMClass::begin(int channels, int sampleRate) {
/* Initialize Open PDM library */
filter.Fs = sampleRate;
filter.MaxVolume = 1;
filter.nSamples = rawBufferLength;
filter.LP_HZ = sampleRate / 2;
filter.HP_HZ = 10;
@@ -88,7 +108,7 @@ int PDMClass::begin(int channels, int sampleRate) {
if (!_pdmPgm.prepare(&_pio, &_smIdx, &_pgmOffset)) {
// ERROR, no free slots
return -1;
return 0;
}
pdm_pio_program_init(_pio, _smIdx, _pgmOffset, _clkPin, _dinPin, clkDiv);
@@ -118,14 +138,29 @@ int PDMClass::begin(int channels, int sampleRate) {
true // Start immediately
);
_cutSamples = 100;
_init = 1;
return 1;
}
void PDMClass::end() {
if (_init != 1) {
return;
}
dma_channel_set_irq0_enabled(_dmaChannel, false);
dma_channel_abort(_dmaChannel);
dma_channel_unclaim(_dmaChannel);
irq_remove_handler(DMA_IRQ_0, dmaHandler);
pio_sm_unclaim(_pio, _smIdx);
pinMode(_clkPin, INPUT);
rawBufferIndex = 0;
_pgmOffset = -1;
_init = 0;
}
int PDMClass::available() {
@@ -163,7 +198,6 @@ void PDMClass::setBufferSize(int bufferSize) {
}
void PDMClass::IrqHandler(bool halftranfer) {
static int cutSamples = 100;
// Clear the interrupt request.
dma_hw->ints0 = 1u << _dmaChannel;
@@ -171,24 +205,25 @@ void PDMClass::IrqHandler(bool halftranfer) {
int shadowIndex = rawBufferIndex ^ 1;
dma_channel_set_write_addr(_dmaChannel, rawBuffer[shadowIndex], true);
if (_doubleBuffer.available()) {
// buffer overflow, stop
return end();
if (!_doubleBuffer.available()) {
// fill final buffer with PCM samples
if (filter.Decimation == 128) {
Open_PDM_Filter_128(rawBuffer[rawBufferIndex], finalBuffer, 1, &filter);
} else {
Open_PDM_Filter_64(rawBuffer[rawBufferIndex], finalBuffer, 1, &filter);
}
if (_cutSamples) {
memset(finalBuffer, 0, _cutSamples);
_cutSamples = 0;
}
// swap final buffer and raw buffers' indexes
finalBuffer = (int16_t*)_doubleBuffer.data();
_doubleBuffer.swap(filter.nSamples * sizeof(int16_t));
rawBufferIndex = shadowIndex;
}
// fill final buffer with PCM samples
Open_PDM_Filter_64(rawBuffer[rawBufferIndex], finalBuffer, 1, &filter);
if (cutSamples) {
memset(finalBuffer, 0, cutSamples);
cutSamples = 0;
}
// swap final buffer and raw buffers' indexes
finalBuffer = (int16_t*)_doubleBuffer.data();
_doubleBuffer.swap(filter.nSamples * sizeof(int16_t));
rawBufferIndex = shadowIndex;
if (_onReceive) {
_onReceive();
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,68 @@
/*
This example plays a tune that alternates between left and right channels using a simple sine wave.
Released to the public domain by Earle F. Philhower, III <earlephilhower@yahoo.com>
*/
#include <PWMAudio.h>
PWMAudio pwm(0, true); // GP0 = left, GP1 = right
const int freq = 48000; // Output frequency for PWM
int16_t al = 0;
int16_t ar = 0;
const int notes[] = { 784, 880, 698, 349, 523 };
const int dly[] = { 400, 500, 700, 500, 1000 };
const int noteCnt = sizeof(notes) / sizeof(notes[0]);
int freqL = 1;
int freqR = 1;
double sineTable[128]; // Precompute sine wave in 128 steps
unsigned int cnt = 0;
void cb() {
while (pwm.availableForWrite()) {
double now = ((double)cnt) / (double)freq;
int fl = freqL << 7; // Prescale by 128 to avoid FP math later on
int fr = freqR << 7; // Prescale by 128 to avoid FP math later on
pwm.write((uint16_t)(al * sineTable[(int)(now * fl) & 127]));
pwm.write((uint16_t)(ar * sineTable[(int)(now * fr) & 127]));
cnt++;
}
}
void setup() {
// Set up sine table for waveform generation
for (int i = 0; i < 128; i++) {
sineTable[i] = sin(i * 2.0 * 3.14159 / 128.0);
}
pwm.setBuffers(4, 32); // Give larger buffers since we're are 48khz sample rate
pwm.onTransmit(cb);
pwm.begin(freq);
}
void loop() {
delay(1000);
// Send it out on the LHS
ar = 0;
for (int i = 0; i < noteCnt; i++) {
freqL = notes[i];
al = 5000;
delay(dly[i]);
}
al = 0;
delay(1000);
// Hear reply on RHS
for (int i = 0; i < noteCnt; i++) {
freqR = notes[i] / 4;
ar = 15000;
delay(dly[i]);
}
ar = 0;
delay(3000);
}
+1
View File
@@ -17,6 +17,7 @@ end KEYWORD2
setPin KEYWORD2
setFrequency KEYWORD2
setBuffers KEYWORD2
setStereo KEYWORD2
onTransmit KEYWORD2
+77 -27
View File
@@ -23,7 +23,7 @@
#include <hardware/pwm.h>
PWMAudio::PWMAudio(pin_size_t pin) {
PWMAudio::PWMAudio(pin_size_t pin, bool stereo) {
_running = false;
_pin = pin;
_freq = 48000;
@@ -31,9 +31,11 @@ PWMAudio::PWMAudio(pin_size_t pin) {
_cb = nullptr;
_buffers = 8;
_bufferWords = 0;
_stereo = stereo;
}
PWMAudio::~PWMAudio() {
end();
}
bool PWMAudio::setBuffers(size_t buffers, size_t bufferWords) {
@@ -45,11 +47,48 @@ bool PWMAudio::setBuffers(size_t buffers, size_t bufferWords) {
return true;
}
bool PWMAudio::setFrequency(int newFreq) {
bool PWMAudio::setPin(pin_size_t pin) {
if (_running) {
return false;
}
_pin = pin;
return true;
}
bool PWMAudio::setStereo(bool stereo) {
if (_running) {
return false;
}
_stereo = stereo;
return true;
}
bool PWMAudio::setFrequency(int newFreq) {
_freq = newFreq;
// Figure out the scale factor for PWM values
float fPWM = 65535.0 * _freq; // ideal
if (fPWM > clock_get_hz(clk_sys)) {
// Need to downscale the range to hit the frequency target
float pwmMax = (float) clock_get_hz(clk_sys) / (float) _freq;
_pwmScale = pwmMax;
fPWM = clock_get_hz(clk_sys);
} else {
_pwmScale = 1 << 16;
}
pwm_config c = pwm_get_default_config();
pwm_config_set_clkdiv(&c, clock_get_hz(clk_sys) / fPWM);
pwm_config_set_wrap(&c, _pwmScale);
pwm_init(pwm_gpio_to_slice_num(_pin), &c, _running);
gpio_set_function(_pin, GPIO_FUNC_PWM);
pwm_set_gpio_level(_pin, (0x8000 * _pwmScale) >> 16);
if (_stereo) {
gpio_set_function(_pin + 1, GPIO_FUNC_PWM);
pwm_set_gpio_level(_pin + 1, (0x8000 * _pwmScale) >> 16);
}
return true;
}
@@ -61,30 +100,20 @@ void PWMAudio::onTransmit(void(*fn)(void)) {
}
bool PWMAudio::begin() {
if (_stereo && (_pin & 1)) {
// Illegal, need to have consecutive pins on the same PWM slice
Serial.printf("ERROR: PWMAudio stereo mode requires pin be even\n");
return false;
}
_running = true;
_wasHolding = false;
if (!_bufferWords) {
_bufferWords = 16;
}
// Figure out the scale factor for PWM values
float fPWM = 65535.0 * _freq; // ideal
if (fPWM > clock_get_hz(clk_sys)) {
// Need to downscale the range to hit the frequency target
float pwmMax = (float) clock_get_hz(clk_sys) /(float) _freq;
_pwmScale = pwmMax;
fPWM = clock_get_hz(clk_sys);
} else {
_pwmScale = 1 << 16;
}
pwm_config c = pwm_get_default_config();
pwm_config_set_clkdiv(&c, clock_get_hz(clk_sys) / fPWM);
pwm_config_set_wrap(&c, _pwmScale);
pwm_init(pwm_gpio_to_slice_num(_pin), &c, true);
gpio_set_function(_pin, GPIO_FUNC_PWM);
pwm_set_gpio_level(_pin, (0x8000 * _pwmScale) >> 16);
setFrequency(_freq);
uint32_t ccAddr = PWM_BASE + PWM_CH0_CC_OFFSET + pwm_gpio_to_slice_num(_pin) * 20;
@@ -96,9 +125,15 @@ bool PWMAudio::begin() {
}
void PWMAudio::end() {
_running = false;
delete _arb;
_arb = nullptr;
if (_running) {
_running = false;
pinMode(_pin, OUTPUT);
if (_stereo) {
pinMode(_pin + 1, OUTPUT);
}
delete _arb;
_arb = nullptr;
}
}
int PWMAudio::available() {
@@ -131,13 +166,28 @@ size_t PWMAudio::write(int16_t val, bool sync) {
return 0;
}
// Go from signed -32K...32K to unsigned 0...64K
uint32_t sample = (uint32_t) (val + 0x8000);
uint32_t sample = (uint32_t)(val + 0x8000);
// Adjust to the real range
sample *= _pwmScale;
sample >>= 16;
// Duplicate sample since we don't care which PWM channel
sample = (sample & 0xffff) | (sample << 16);
return _arb->write(sample, sync);
if (!_stereo) {
// Duplicate sample since we don't care which PWM channel
sample = (sample & 0xffff) | (sample << 16);
return _arb->write(sample, sync);
} else {
if (_wasHolding) {
_holdWord = (_holdWord & 0xffff) | (sample << 16);
auto ret = _arb->write(_holdWord, sync);
if (ret) {
_wasHolding = false;
}
return ret;
} else {
_holdWord = sample;
_wasHolding = true;
return true;
}
}
}
size_t PWMAudio::write(const uint8_t *buffer, size_t size) {
+8 -1
View File
@@ -25,11 +25,13 @@
class PWMAudio : public Stream {
public:
PWMAudio(pin_size_t pin);
PWMAudio(pin_size_t pin = 0, bool stereo = false);
virtual ~PWMAudio();
bool setBuffers(size_t buffers, size_t bufferWords);
bool setFrequency(int newFreq);
bool setPin(pin_size_t pin);
bool setStereo(bool stereo = true);
bool begin(long sampleRate) {
setFrequency(sampleRate);
@@ -65,6 +67,8 @@ public:
private:
pin_size_t _pin;
bool _stereo;
int _freq;
size_t _buffers;
@@ -74,6 +78,9 @@ private:
bool _running;
bool _wasHolding;
uint32_t _holdWord;
void (*_cb)();
AudioBufferManager *_arb;
@@ -7,10 +7,10 @@
The circuit:
analog sensors on analog ins 0, 1, and 2
SD card attached to SPI bus as follows (Raspberry Pi Pico):
** MISO - pin 0
** MOSI - pin 3
** CS - pin 1
** SCK - pin 2
** MISO - pin 4
** MOSI - pin 7
** CS - pin 5
** SCK - pin 6
created 24 Nov 2010
modified 9 Apr 2012
@@ -20,19 +20,32 @@
*/
// This are GP pins for SPI0 on the Raspberry Pi Pico board, and connect
// to different *board* level pinouts. Check the PCB while wiring.
// Only certain pins can be used by the SPI hardware, so if you change
// these be sure they are legal or the program will crash.
// See: https://datasheets.raspberrypi.com/picow/PicoW-A4-Pinout.pdf
const int _MISO = 4;
const int _MOSI = 7;
const int _CS = 5;
const int _SCK = 6;
#include <SPI.h>
#include <SD.h>
const int chipSelect = 4;
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(115200);
Serial.print("Initializing SD card...");
// Ensure the SPI pinout the SD card is connected to is configured properly
SPI.setRX(_MISO);
SPI.setTX(_MOSI);
SPI.setSCK(_SCK);
// see if the card is present and can be initialized:
if (!SD.begin(chipSelect)) {
if (!SD.begin(_CS)) {
Serial.println("Card failed, or not present");
// don't do anything more:
return;
+20 -7
View File
@@ -6,10 +6,10 @@
The circuit:
SD card attached to SPI bus as follows:
** MISO - pin 0
** MOSI - pin 3
** CS - pin 1
** SCK - pin 2
** MISO - pin 4
** MOSI - pin 7
** CS - pin 5
** SCK - pin 6
created 22 December 2010
by Limor Fried
@@ -20,19 +20,32 @@
*/
// This are GP pins for SPI0 on the Raspberry Pi Pico board, and connect
// to different *board* level pinouts. Check the PCB while wiring.
// Only certain pins can be used by the SPI hardware, so if you change
// these be sure they are legal or the program will crash.
// See: https://datasheets.raspberrypi.com/picow/PicoW-A4-Pinout.pdf
const int _MISO = 4;
const int _MOSI = 7;
const int _CS = 5;
const int _SCK = 6;
#include <SPI.h>
#include <SD.h>
const int chipSelect = 4;
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(115200);
Serial.print("Initializing SD card...");
// Ensure the SPI pinout the SD card is connected to is configured properly
SPI.setRX(_MISO);
SPI.setTX(_MOSI);
SPI.setSCK(_SCK);
// see if the card is present and can be initialized:
if (!SD.begin(chipSelect)) {
if (!SD.begin(_CS)) {
Serial.println("Card failed, or not present");
// don't do anything more:
return;
+21 -5
View File
@@ -4,10 +4,10 @@
This example shows how to create and destroy an SD card file
The circuit:
SD card attached to SPI bus as follows:
** MISO - pin 0
** MOSI - pin 3
** CS - pin 1
** SCK - pin 2
** MISO - pin 4
** MOSI - pin 7
** CS - pin 5
** SCK - pin 6
created Nov 2010
by David A. Mellis
@@ -17,6 +17,17 @@
This example code is in the public domain.
*/
// This are GP pins for SPI0 on the Raspberry Pi Pico board, and connect
// to different *board* level pinouts. Check the PCB while wiring.
// Only certain pins can be used by the SPI hardware, so if you change
// these be sure they are legal or the program will crash.
// See: https://datasheets.raspberrypi.com/picow/PicoW-A4-Pinout.pdf
const int _MISO = 4;
const int _MOSI = 7;
const int _CS = 5;
const int _SCK = 6;
#include <SPI.h>
#include <SD.h>
@@ -28,7 +39,12 @@ void setup() {
Serial.print("Initializing SD card...");
if (!SD.begin(4)) {
// Ensure the SPI pinout the SD card is connected to is configured properly
SPI.setRX(_MISO);
SPI.setTX(_MOSI);
SPI.setSCK(_SCK);
if (!SD.begin(_CS)) {
Serial.println("initialization failed!");
return;
}
+20 -5
View File
@@ -4,10 +4,10 @@
This example shows how to read and write data to and from an SD card file
The circuit:
SD card attached to SPI bus as follows:
** MISO - pin 0
** MOSI - pin 3
** CS - pin 1
** SCK - pin 2
** MISO - pin 4
** MOSI - pin 7
** CS - pin 5
** SCK - pin 6
created Nov 2010
by David A. Mellis
@@ -18,6 +18,16 @@
*/
// This are GP pins for SPI0 on the Raspberry Pi Pico board, and connect
// to different *board* level pinouts. Check the PCB while wiring.
// Only certain pins can be used by the SPI hardware, so if you change
// these be sure they are legal or the program will crash.
// See: https://datasheets.raspberrypi.com/picow/PicoW-A4-Pinout.pdf
const int _MISO = 4;
const int _MOSI = 7;
const int _CS = 5;
const int _SCK = 6;
#include <SPI.h>
#include <SD.h>
@@ -29,7 +39,12 @@ void setup() {
Serial.print("Initializing SD card...");
if (!SD.begin(4)) {
// Ensure the SPI pinout the SD card is connected to is configured properly
SPI.setRX(_MISO);
SPI.setTX(_MOSI);
SPI.setSCK(_SCK);
if (!SD.begin(_CS)) {
Serial.println("initialization failed!");
return;
}
+21 -5
View File
@@ -6,10 +6,10 @@
The circuit:
SD card attached to SPI bus as follows:
** MISO - pin 0
** MOSI - pin 3
** CS - pin 1
** SCK - pin 2
** MISO - pin 4
** MOSI - pin 7
** CS - pin 5
** SCK - pin 6
created Nov 2010
by David A. Mellis
@@ -21,6 +21,17 @@
This example code is in the public domain.
*/
// This are GP pins for SPI0 on the Raspberry Pi Pico board, and connect
// to different *board* level pinouts. Check the PCB while wiring.
// Only certain pins can be used by the SPI hardware, so if you change
// these be sure they are legal or the program will crash.
// See: https://datasheets.raspberrypi.com/picow/PicoW-A4-Pinout.pdf
const int _MISO = 4;
const int _MOSI = 7;
const int _CS = 5;
const int _SCK = 6;
#include <SPI.h>
#include <SD.h>
@@ -32,7 +43,12 @@ void setup() {
Serial.print("Initializing SD card...");
if (!SD.begin(SS)) {
// Ensure the SPI pinout the SD card is connected to is configured properly
SPI.setRX(_MISO);
SPI.setTX(_MOSI);
SPI.setSCK(_SCK);
if (!SD.begin(_CS)) {
Serial.println("initialization failed!");
return;
}
+18 -4
View File
@@ -26,7 +26,7 @@
#undef FILE_READ
#define FILE_READ O_READ
#undef FILE_WRITE
#define FILE_WRITE (O_READ | O_WRITE | O_CREAT | O_APPEND)
#define FILE_WRITE (O_RDWR | O_CREAT | O_APPEND)
class SDClass {
@@ -162,9 +162,23 @@ public:
private:
const char *getMode(uint8_t mode) {
bool read = (mode & O_READ) ? true : false;
bool write = (mode & O_WRITE) ? true : false;
bool append = (mode & O_APPEND) ? true : false;
bool read = false;
bool write = false;
switch (mode & O_ACCMODE) {
case O_RDONLY:
read = true;
break;
case O_WRONLY:
write = true;
break;
case O_RDWR:
read = true;
write = true;
break;
}
const bool append = (mode & O_APPEND) > 0;
if (read & !write) {
return "r";
} else if (!read & write & !append) {
+2 -3
View File
@@ -125,7 +125,7 @@ uint16_t SPIClassRP2040::transfer16(uint16_t data) {
spi_set_format(_spi, 16, cpol(), cpha(), SPI_MSB_FIRST);
DEBUGSPI("SPI::transfer16(%04x), cpol=%d, cpha=%d\n", data, cpol(), cpha());
spi_write16_read16_blocking(_spi, &data, &ret, 1);
ret = (_spis.getBitOrder() == MSBFIRST) ? ret : reverseByte(ret);
ret = (_spis.getBitOrder() == MSBFIRST) ? ret : reverse16Bit(ret);
DEBUGSPI("SPI: read back %02x\n", ret);
return ret;
}
@@ -135,7 +135,6 @@ void SPIClassRP2040::transfer(void *buf, size_t count) {
uint8_t *buff = reinterpret_cast<uint8_t *>(buf);
for (size_t i = 0; i < count; i++) {
*buff = transfer(*buff);
*buff = (_spis.getBitOrder() == MSBFIRST) ? *buff : reverseByte(*buff);
buff++;
}
DEBUGSPI("SPI::transfer completed\n");
@@ -178,7 +177,7 @@ void SPIClassRP2040::transfer(const void *txbuf, void *rxbuf, size_t count) {
}
void SPIClassRP2040::beginTransaction(SPISettings settings) {
DEBUGSPI("SPI::beginTransaction(clk=%d, bo=%s\n", _spis.getClockFreq(), (_spis.getBitOrder() == MSBFIRST) ? "MSB" : "LSB");
DEBUGSPI("SPI::beginTransaction(clk=%lu, bo=%s\n", _spis.getClockFreq(), (_spis.getBitOrder() == MSBFIRST) ? "MSB" : "LSB");
if (_initted && settings == _spis) {
DEBUGSPI("SPI: Reusing existing initted SPI\n");
} else {
@@ -69,7 +69,7 @@ void setup() {
cnt++;
}
Serial.printf("Starting acquisition at %d\n", cnt);
Serial.printf("Starting acquisition at %lu\n", cnt);
}
void loop() {
@@ -245,30 +245,29 @@ int32_t SingleFileDrive::read10(uint32_t lba, uint32_t offset, void* buffer, uin
}
uint32_t toread = bufsize;
char buff[512];
uint8_t *curbuff = (uint8_t *)buffer;
while (bufsize > 0) {
if (lba == 0) {
bootSector(buff);
bootSector(_sectBuff);
} else if ((lba == 128) || (lba == 256)) {
fatSector(buff);
fatSector(_sectBuff);
} else if (lba == 384) {
directorySector(buff);
directorySector(_sectBuff);
} else if (lba >= 640) {
File f = LittleFS.open(_localFile, "r");
f.seek((lba - 640) * 512);
f.read((uint8_t*)buff, 512);
f.read((uint8_t*)_sectBuff, 512);
f.close();
} else {
memset(buff, 0, sizeof(buff));
memset(_sectBuff, 0, sizeof(_sectBuff));
}
uint32_t cplen = 512 - offset;
if (bufsize < cplen) {
cplen = bufsize;
}
memcpy(curbuff, buff + offset, cplen);
memcpy(curbuff, _sectBuff + offset, cplen);
curbuff += cplen;
offset = 0;
lba++;
@@ -50,6 +50,8 @@ private:
char *_localFile = nullptr;
char *_dosFile = nullptr;
char _sectBuff[512]; // Read sector region
void (*_cbDelete)(uint32_t) = nullptr;
uint32_t _cbDeleteData = 0;
+3 -3
View File
@@ -129,7 +129,7 @@ bool UpdaterClass::begin(size_t size, int command) {
_command = command;
#ifdef DEBUG_UPDATER
DEBUG_UPDATER.printf_P(PSTR("[begin] _startAddress: 0x%08X (%d)\n"), _startAddress, _startAddress);
DEBUG_UPDATER.printf_P(PSTR("[begin] _startAddress: 0x%08lX (%lu)\n"), _startAddress, _startAddress);
DEBUG_UPDATER.printf_P(PSTR("[begin] _size: 0x%08zX (%zd)\n"), _size, _size);
#endif
@@ -188,7 +188,7 @@ bool UpdaterClass::end(bool evenIfRemaining) {
_fp.read((uint8_t *)&sigLen, sizeof(uint32_t));
}
#ifdef DEBUG_UPDATER
DEBUG_UPDATER.printf_P(PSTR("[Updater] sigLen: %d\n"), sigLen);
DEBUG_UPDATER.printf_P(PSTR("[Updater] sigLen: %lu\n"), sigLen);
#endif
if (sigLen != expectedSigLen) {
_setError(UPDATE_ERROR_SIGN);
@@ -276,7 +276,7 @@ bool UpdaterClass::end(bool evenIfRemaining) {
picoOTA.addFile("firmware.bin");
picoOTA.commit();
#ifdef DEBUG_UPDATER
DEBUG_UPDATER.printf_P(PSTR("Staged: address:0x%08X, size:0x%08zX\n"), _startAddress, _size);
DEBUG_UPDATER.printf_P(PSTR("Staged: address:0x%08lX, size:0x%08zX\n"), _startAddress, _size);
#endif
}
@@ -32,6 +32,7 @@
#include <WiFiClient.h>
#include <WebServer.h>
#include <LEAmDNS.h>
#include <StreamString.h>
#ifndef STASSID
#define STASSID "your-ssid"
@@ -48,14 +49,13 @@ const int led = LED_BUILTIN;
void handleRoot() {
static int cnt = 0;
digitalWrite(led, 1);
char temp[400];
int sec = millis() / 1000;
int min = sec / 60;
int hr = min / 60;
snprintf(temp, 400,
"<html>\
StreamString temp;
temp.reserve(500); // Preallocate a large chunk to avoid memory fragmentation
temp.printf("<html>\
<head>\
<meta http-equiv='refresh' content='5'/>\
<title>Pico-W Demo</title>\
@@ -70,9 +70,7 @@ void handleRoot() {
<p>Page Count: %d</p>\
<img src=\"/test.svg\" />\
</body>\
</html>",
hr, min % 60, sec % 60, rp2040.getFreeHeap(), ++cnt);
</html>", hr, min % 60, sec % 60, rp2040.getFreeHeap(), ++cnt);
server.send(200, "text/html", temp);
digitalWrite(led, 0);
}
@@ -0,0 +1,149 @@
#include <WiFi.h>
#include <WiFiClient.h>
#include <WebServer.h>
#include <LEAmDNS.h>
#ifndef STASSID
#define STASSID "your-ssid"
#define STAPSK "your-password"
#endif
const char* ssid = STASSID;
const char* password = STAPSK;
WebServer server(80);
const int led = LED_BUILTIN;
void handleRoot() {
digitalWrite(led, 1);
server.send(200, "text/plain", "hello from pico w!\r\n");
digitalWrite(led, 0);
}
void handleNotFound() {
digitalWrite(led, 1);
String message = "File Not Found\n\n";
message += "URI: ";
message += server.uri();
message += "\nMethod: ";
message += (server.method() == HTTP_GET) ? "GET" : "POST";
message += "\nArguments: ";
message += server.args();
message += "\n";
for (uint8_t i = 0; i < server.args(); i++) {
message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
}
server.send(404, "text/plain", message);
digitalWrite(led, 0);
}
void setup(void) {
pinMode(led, OUTPUT);
digitalWrite(led, 0);
Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
Serial.println("");
// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
if (MDNS.begin("picow")) {
Serial.println("MDNS responder started");
}
server.on("/", handleRoot);
server.on("/inline", []() {
server.send(200, "text/plain", "this works as well");
});
server.on("/gif", []() {
static const uint8_t gif[] = {
0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x10, 0x00, 0x10, 0x00, 0x80, 0x01,
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x2c, 0x00, 0x00, 0x00, 0x00,
0x10, 0x00, 0x10, 0x00, 0x00, 0x02, 0x19, 0x8c, 0x8f, 0xa9, 0xcb, 0x9d,
0x00, 0x5f, 0x74, 0xb4, 0x56, 0xb0, 0xb0, 0xd2, 0xf2, 0x35, 0x1e, 0x4c,
0x0c, 0x24, 0x5a, 0xe6, 0x89, 0xa6, 0x4d, 0x01, 0x00, 0x3b
};
char gif_colored[sizeof(gif)];
memcpy_P(gif_colored, gif, sizeof(gif));
// Set the background to a random set of colors
gif_colored[16] = millis() % 256;
gif_colored[17] = millis() % 256;
gif_colored[18] = millis() % 256;
server.send(200, "image/gif", gif_colored, sizeof(gif_colored));
});
server.onNotFound(handleNotFound);
/////////////////////////////////////////////////////////
// Hook examples
server.addHook([](const String & method, const String & url, WiFiClient * client, WebServer::ContentTypeFunction contentType) {
(void)method; // GET, PUT, ...
(void)url; // example: /root/myfile.html
(void)client; // the webserver tcp client connection
(void)contentType; // contentType(".html") => "text/html"
Serial.printf("A useless web hook has passed\n");
return WebServer::CLIENT_REQUEST_CAN_CONTINUE;
});
server.addHook([](const String&, const String & url, WiFiClient*, WebServer::ContentTypeFunction) {
if (url.startsWith("/fail")) {
Serial.printf("An always failing web hook has been triggered\n");
return WebServer::CLIENT_MUST_STOP;
}
return WebServer::CLIENT_REQUEST_CAN_CONTINUE;
});
server.addHook([](const String&, const String & url, WiFiClient * client, WebServer::ContentTypeFunction) {
if (url.startsWith("/dump")) {
Serial.printf("The dumper web hook is on the run\n");
// Here the request is not interpreted, so we cannot for sure
// swallow the exact amount matching the full request+content,
// hence the tcp connection cannot be handled anymore by the
auto last = millis();
while ((millis() - last) < 500) {
char buf[32];
size_t len = client->read((uint8_t*)buf, sizeof(buf));
if (len > 0) {
Serial.printf("(<%d> chars)", (int)len);
Serial.write(buf, len);
last = millis();
}
}
// Two choices: return MUST STOP and webserver will close it
// (we already have the example with '/fail' hook)
// or IS GIVEN and webserver will forget it
// trying with IS GIVEN and storing it on a dumb WiFiClient.
// check the client connection: it should not immediately be closed
// (make another '/dump' one to close the first)
Serial.printf("\nTelling server to forget this connection\n");
static WiFiClient forgetme = *client; // stop previous one if present and transfer client refcounter
return WebServer::CLIENT_IS_GIVEN;
}
return WebServer::CLIENT_REQUEST_CAN_CONTINUE;
});
// Hook examples
/////////////////////////////////////////////////////////
server.begin();
Serial.println("HTTP server started");
}
void loop(void) {
server.handleClient();
MDNS.update();
}
@@ -0,0 +1,4 @@
// Since things may just work, we'll redirect for now
#include "WebServer.h"
using ESP8266WebServer = WebServer;
+23 -11
View File
@@ -249,20 +249,32 @@ void HTTPServer::httpHandleClient() {
case HC_WAIT_READ:
// Wait for data from client to become available
if (_currentClient->available()) {
if (_parseRequest(_currentClient)) {
// because HTTP_MAX_SEND_WAIT is expressed in milliseconds,
// it must be divided by 1000
switch (_parseRequest(_currentClient)) {
case CLIENT_REQUEST_CAN_CONTINUE:
// Because HTTP_MAX_SEND_WAIT is expressed in milliseconds, it must be divided by 1000
_currentClient->setTimeout(HTTP_MAX_SEND_WAIT / 1000);
_contentLength = CONTENT_LENGTH_NOT_SET;
_handleRequest();
// Fix for issue with Chrome based browsers: https://github.com/espressif/arduino-esp32/issues/3652
// if (_currentClient->connected()) {
// _currentStatus = HC_WAIT_CLOSE;
// _statusChange = millis();
// keepCurrentClient = true;
// }
}
/* fallthrough */
case CLIENT_REQUEST_IS_HANDLED:
if (_currentClient->connected() || _currentClient->available()) {
_currentStatus = HC_WAIT_CLOSE;
_statusChange = millis();
keepCurrentClient = true;
} else {
log_v("webserver: peer has closed after served\n");
}
break;
case CLIENT_MUST_STOP:
log_v("Close client\n");
_currentClient->stop();
break;
case CLIENT_IS_GIVEN:
// client must not be stopped but must not be handled here anymore
// (example: tcp connection given to websocket)
log_v("Give client\n");
break;
} // switch _parseRequest()
} else { // !_currentClient->available()
if (millis() - _statusChange <= HTTP_MAX_DATA_WAIT) {
keepCurrentClient = true;
+24 -1
View File
@@ -48,6 +48,8 @@ enum HTTPAuthMethod { BASIC_AUTH, DIGEST_AUTH };
#define CONTENT_LENGTH_UNKNOWN ((size_t) -1)
#define CONTENT_LENGTH_NOT_SET ((size_t) -2)
#define WEBSERVER_HAS_HOOK 1
class HTTPServer;
typedef struct {
@@ -183,6 +185,25 @@ public:
return _currentClient->write(file);
}
// Hook
enum ClientFuture { CLIENT_REQUEST_CAN_CONTINUE, CLIENT_REQUEST_IS_HANDLED, CLIENT_MUST_STOP, CLIENT_IS_GIVEN };
typedef String(*ContentTypeFunction)(const String&);
using HookFunction = std::function<ClientFuture(const String& method, const String& url, WiFiClient* client, ContentTypeFunction contentType)>;
void addHook(HookFunction hook) {
if (_hook) {
auto previousHook = _hook;
_hook = [previousHook, hook](const String & method, const String & url, WiFiClient * client, ContentTypeFunction contentType) {
auto whatNow = previousHook(method, url, client, contentType);
if (whatNow == CLIENT_REQUEST_CAN_CONTINUE) {
return hook(method, url, client, contentType);
}
return whatNow;
};
} else {
_hook = hook;
}
}
protected:
virtual size_t _currentClientWrite(const char* b, size_t l) {
return _currentClient->write(b, l);
@@ -193,7 +214,7 @@ protected:
void _addRequestHandler(RequestHandler* handler);
void _handleRequest();
void _finalizeResponse();
bool _parseRequest(WiFiClient* client);
ClientFuture _parseRequest(WiFiClient* client);
void _parseArguments(String data);
static String _responseCodeToString(int code);
bool _parseForm(WiFiClient* client, String boundary, uint32_t len);
@@ -249,4 +270,6 @@ protected:
String _snonce; // Store noance and opaque for future comparison
String _sopaque;
String _srealm; // Store the Auth realm between Calls
HookFunction _hook;
};
+13 -6
View File
@@ -78,7 +78,7 @@ static char* readBytesWithTimeout(WiFiClient* client, size_t maxLength, size_t&
return buf;
}
bool HTTPServer::_parseRequest(WiFiClient* client) {
HTTPServer::ClientFuture HTTPServer::_parseRequest(WiFiClient* client) {
// Read the first line of HTTP request
String req = client->readStringUntil('\r');
client->readStringUntil('\n');
@@ -93,7 +93,7 @@ bool HTTPServer::_parseRequest(WiFiClient* client) {
int addr_end = req.indexOf(' ', addr_start + 1);
if (addr_start == -1 || addr_end == -1) {
log_e("Invalid request: %s", req.c_str());
return false;
return CLIENT_MUST_STOP;
}
String methodStr = req.substring(0, addr_start);
@@ -110,6 +110,13 @@ bool HTTPServer::_parseRequest(WiFiClient* client) {
_chunked = false;
_clientContentLength = 0; // not known yet, or invalid
if (_hook) {
auto whatNow = _hook(methodStr, url, client, mime::getContentType);
if (whatNow != CLIENT_REQUEST_CAN_CONTINUE) {
return whatNow;
}
}
HTTPMethod method = HTTP_ANY;
size_t num_methods = sizeof(_http_method_str) / sizeof(const char *);
for (size_t i = 0; i < num_methods; i++) {
@@ -120,7 +127,7 @@ bool HTTPServer::_parseRequest(WiFiClient* client) {
}
if (method == HTTP_ANY) {
log_e("Unknown HTTP Method: %s", methodStr.c_str());
return false;
return CLIENT_MUST_STOP;
}
_currentMethod = method;
@@ -186,7 +193,7 @@ bool HTTPServer::_parseRequest(WiFiClient* client) {
char* plainBuf = readBytesWithTimeout(client, _clientContentLength, plainLength, HTTP_MAX_POST_WAIT);
if ((int)plainLength < (int)_clientContentLength) {
free(plainBuf);
return false;
return CLIENT_MUST_STOP;
}
if (_clientContentLength > 0) {
if (isEncoded) {
@@ -214,7 +221,7 @@ bool HTTPServer::_parseRequest(WiFiClient* client) {
// it IS a form
_parseArguments(searchStr);
if (!_parseForm(client, boundaryStr, _clientContentLength)) {
return false;
return CLIENT_MUST_STOP;
}
}
} else {
@@ -249,7 +256,7 @@ bool HTTPServer::_parseRequest(WiFiClient* client) {
log_v("Request: %s", url.c_str());
log_v(" Arguments: %s", searchStr.c_str());
return true;
return CLIENT_REQUEST_CAN_CONTINUE;
}
bool HTTPServer::_collectHeader(const char* headerName, const char* headerValue) {
@@ -113,7 +113,7 @@ void loop() {
client.setTrustAnchors(&cert);
fetchURL(&client, host, port, path);
finish = millis();
Serial.printf("Total time: %dms\n", finish - start);
Serial.printf("Total time: %lums\n", finish - start);
BearSSL::Session session;
client.setSession(&session);
@@ -122,21 +122,21 @@ void loop() {
client.setTrustAnchors(&cert);
fetchURL(&client, host, port, path);
finish = millis();
Serial.printf("Total time: %dms\n", finish - start);
Serial.printf("Total time: %lums\n", finish - start);
Serial.printf("Connecting with the just initialized session...");
start = millis();
client.setTrustAnchors(&cert);
fetchURL(&client, host, port, path);
finish = millis();
Serial.printf("Total time: %dms\n", finish - start);
Serial.printf("Total time: %lums\n", finish - start);
Serial.printf("Connecting again with the initialized session...");
start = millis();
client.setTrustAnchors(&cert);
fetchURL(&client, host, port, path);
finish = millis();
Serial.printf("Total time: %dms\n", finish - start);
Serial.printf("Total time: %lums\n", finish - start);
delay(10000); // Avoid DDOSing github
}
@@ -76,7 +76,7 @@ void fetchURL(BearSSL::WiFiClientSecure *client, const char *host, const uint16_
} while (millis() < to);
}
client->stop();
Serial.printf("BSSL stack used: %d\n-------\n\n", stack_thunk_get_max_usage());
Serial.printf("BSSL stack used: %lu\n-------\n\n", stack_thunk_get_max_usage());
}
void fetchNoConfig() {
@@ -24,7 +24,7 @@ const char *encToString(uint8_t enc) {
void loop() {
delay(5000);
Serial.printf("Beginning scan at %d\n", millis());
Serial.printf("Beginning scan at %lu\n", millis());
auto cnt = WiFi.scanNetworks();
if (!cnt) {
Serial.printf("No networks found\n");
@@ -34,7 +34,7 @@ void loop() {
for (auto i = 0; i < cnt; i++) {
uint8_t bssid[6];
WiFi.BSSID(i, bssid);
Serial.printf("%32s %5s %17s %2d %4d\n", WiFi.SSID(i), encToString(WiFi.encryptionType(i)), macToString(bssid), WiFi.channel(i), WiFi.RSSI(i));
Serial.printf("%32s %5s %17s %2d %4ld\n", WiFi.SSID(i), encToString(WiFi.encryptionType(i)), macToString(bssid), WiFi.channel(i), WiFi.RSSI(i));
}
}
Serial.printf("\n--- Sleeping ---\n\n\n");
+4
View File
@@ -0,0 +1,4 @@
// Since things may just work, we'll redirect for now
#include "WiFiMulti.h"
using ESP8266WiFiMulti = WiFiMulti;
+16
View File
@@ -158,6 +158,22 @@ uint8_t WiFiClass::beginAP(const char *ssid, const char* passphrase) {
}
#endif
uint8_t WiFiClass::softAPgetStationNum() {
if (!_apMode || !_wifiHWInitted) {
return 0;
}
int m;
cyw43_wifi_ap_get_max_stas(&cyw43_state, &m);
uint8_t *macs = (uint8_t*)malloc(m * 6);
if (!macs) {
return 0;
}
cyw43_wifi_ap_get_stas(&cyw43_state, &m, macs);
free(macs);
return m;
}
bool WiFiClass::connected() {
return (_apMode && _wifiHWInitted) || (_wifi.connected() && localIP().isSet() && (cyw43_wifi_link_status(&cyw43_state, _apMode ? 1 : 0) == CYW43_LINK_JOIN));
}
+12
View File
@@ -86,6 +86,9 @@ public:
int begin(const char* ssid, const char *passphrase);
bool connected();
bool isConnected() {
return connected();
}
int8_t waitForConnectResult(unsigned long timeoutLength = 60000) {
uint32_t now = millis();
while (millis() - now < timeoutLength) {
@@ -381,6 +384,15 @@ public:
void setFeedWatchdogFunc(FeedHostProcessorWatchdogFuncPointer func);
void feedWatchdog();
// ESP8266 compatibility
void persistent(bool unused) {
(void) unused;
}
void hostname(const char *name) {
setHostname(name);
}
private:
int _timeout = 15000;
String _ssid;
+1 -1
View File
@@ -78,7 +78,7 @@ uint8_t WiFiMulti::run(uint32_t to) {
for (int i = 0; i < cnt; i++) {
if (WiFi.RSSI(i) > maxRSSID) {
for (auto j = _list.begin(); j != _list.end(); j++) {
DEBUGV("[WIFIMULTI] Checking for '%s' at %d\n", WiFi.SSID(i), WiFi.RSSI(i));
DEBUGV("[WIFIMULTI] Checking for '%s' at %ld\n", WiFi.SSID(i), WiFi.RSSI(i));
if (!strcmp(j->ssid, WiFi.SSID(i))) {
hit = j;
maxRSSID = WiFi.RSSI(i);
+2 -2
View File
@@ -184,8 +184,8 @@ static void dhcp_server_process(void *arg, struct udp_pcb *upcb, struct pbuf *p,
(void)src_addr;
(void)src_port;
// This is around 548 bytes
dhcp_msg_t dhcp_msg;
// This is around 548 bytes, so make static so it will live in the heap, not the stack (too large)
static dhcp_msg_t dhcp_msg;
#define DHCP_MIN_SIZE (240 + 3)
if (p->tot_len < DHCP_MIN_SIZE) {
+1 -1
View File
@@ -651,7 +651,7 @@ protected:
void _error(err_t err) {
(void) err;
DEBUGV(":er %d 0x%08x\r\n", (int) err, (uint32_t) _datasource);
DEBUGV(":er %d 0x%08lx\r\n", (int) err, (uint32_t) _datasource);
tcp_arg(_pcb, nullptr);
tcp_sent(_pcb, nullptr);
tcp_recv(_pcb, nullptr);
+3
View File
@@ -182,6 +182,9 @@ void TwoWire::onIRQ() {
if (_onReceiveCallback && _buffLen) {
_onReceiveCallback(_buffLen);
}
_buffLen = 0;
_buffOff = 0;
_slaveStartDet = false;
_i2c->hw->clr_restart_det;
}
// STOP_DET
@@ -6,7 +6,7 @@ void setup() {
uint32_t a = rp2040.getCycleCount();
delay(1000);
uint32_t b = rp2040.getCycleCount();
Serial.printf("There are %d cycles in one second.\n\n\n", b - a);
Serial.printf("There are %lu cycles in one second.\n\n\n", b - a);
delay(3000);
@@ -16,6 +16,6 @@ void setup() {
}
void loop() {
Serial.printf("%15u - %15llu\n", rp2040.getCycleCount(), rp2040.getCycleCount64());
Serial.printf("%15lu - %15llu\n", rp2040.getCycleCount(), rp2040.getCycleCount64());
delay(1500);
}
+2
View File
@@ -50,6 +50,8 @@ target_compile_definitions(ota PUBLIC
target_compile_options(ota PUBLIC
-fno-exceptions
-Os
-Wall
-Werror
$<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>
)
+17 -15
View File
@@ -23,21 +23,28 @@
MEMORY
{
FLASH(rx) : ORIGIN = 0x10000100, LENGTH = 16384k
RAM(rwx) : ORIGIN = 0x20000000, LENGTH = 256k
FLASH(rx) : ORIGIN = 0x10000100, LENGTH = 16384k
RAM(rwx) : ORIGIN = 0x20000000, LENGTH = 212k
/* We split RAM into main (where the flash->ram code will be copied) and GLOBALS which has all large arrays */
/* By placing those arrays at the end of RAM we can avoid overwriting uninitialize_ram from the main app as */
/* long as those vars are stored after 12K by using an alignment value in the main app linker file. */
GLOBALS(rwx) : ORIGIN = 0x20035000, LENGTH = 44k
SCRATCH_X(rwx) : ORIGIN = 0x20040000, LENGTH = 4k
SCRATCH_Y(rwx) : ORIGIN = 0x20041000, LENGTH = 4k
}
ENTRY(_entry_point)
SECTIONS
{
SECTIONS {
/* Second stage bootloader is prepended to the image. It must be 256 bytes big
and checksummed. It is usually built by the boot_stage2 target
in the Raspberry Pi Pico SDK
*/
/* Make sure the globals are not copied/etc. They're empty RAM we will init ourselves */
.globals (NOLOAD) : {
} > GLOBALS
.flash_begin : {
__flash_binary_start = .;
} > FLASH
@@ -72,14 +79,12 @@ SECTIONS
. = ALIGN(4);
} > FLASH
.ARM.extab :
{
.ARM.extab : {
*(.ARM.extab* .gnu.linkonce.armextab.*)
} > FLASH
__exidx_start = .;
.ARM.exidx :
{
.ARM.exidx : {
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
} > FLASH
__exidx_end = .;
@@ -188,7 +193,7 @@ SECTIONS
} > SCRATCH_Y AT > FLASH
__scratch_y_source__ = LOADADDR(.scratch_y);
.bss : {
.bss : {
. = ALIGN(4);
__bss_start__ = .;
*(SORT_BY_ALIGNMENT(SORT_BY_NAME(.bss*)))
@@ -197,8 +202,7 @@ SECTIONS
__bss_end__ = .;
} > RAM
.heap (COPY):
{
.heap (COPY): {
__end__ = .;
end = __end__;
*(.heap*)
@@ -214,12 +218,10 @@ SECTIONS
/* by default we put core 0 stack at the end of scratch Y, so that if core 1
* stack is not used then all of SCRATCH_X is free.
*/
.stack1_dummy (COPY):
{
.stack1_dummy (COPY): {
*(.stack1*)
} > SCRATCH_X
.stack_dummy (COPY):
{
.stack_dummy (COPY): {
*(.stack*)
} > SCRATCH_Y
+3 -4
View File
@@ -53,8 +53,7 @@ void dumphex(uint32_t x) {
#endif
}
static OTACmdPage _ota_cmd;
extern OTACmdPage _ota_cmd;
void do_ota() {
if (*__FS_START__ == *__FS_END__) {
return;
@@ -165,7 +164,7 @@ void do_ota() {
#pragma GCC push_options
#pragma GCC optimize("O0")
int main(int a, unsigned char **b) {
int main(int a, char **b) {
(void) a;
(void) b;
@@ -190,7 +189,7 @@ int main(int a, unsigned char **b) {
fcn();
// Should never get here!
return 0;
return *sp;
}
#pragma GCC pop_options
+13 -11
View File
@@ -26,6 +26,8 @@
#include "../libraries/LittleFS/lib/littlefs/lfs_util.h"
#include "./uzlib/src/uzlib.h"
OTACmdPage __attribute__((section (".globals"))) _ota_cmd;
static lfs_t _lfs;
static struct lfs_config _lfs_cfg;
@@ -70,9 +72,9 @@ static int lfs_flash_sync(const struct lfs_config *c) {
return 0;
}
uint8_t _read_buffer[256];
uint8_t _prog_buffer[256];
uint8_t _lookahead_buffer[256];
uint8_t __attribute__((section (".globals"))) _read_buffer[256];
uint8_t __attribute__((section (".globals"))) _prog_buffer[256];
uint8_t __attribute__((section (".globals"))) _lookahead_buffer[256];
bool lfsMount(uint8_t *start, uint32_t blockSize, uint32_t size) {
_start = start;
_blockSize = blockSize;
@@ -104,16 +106,16 @@ bool lfsMount(uint8_t *start, uint32_t blockSize, uint32_t size) {
static bool _gzip = false;
static lfs_file_t _file;
static unsigned char __attribute__((aligned(4))) uzlib_read_buff[4096];
static unsigned char gzip_dict[32768];
static uint8_t _flash_buff[4096]; // no room for this on the stack
static struct uzlib_uncomp m_uncomp;
unsigned char __attribute__((section (".globals"))) uzlib_read_buff[4096];
unsigned char __attribute__((section (".globals"))) gzip_dict[32768];
uint8_t __attribute__((section (".globals")))_flash_buff[4096]; // no room for this on the stack
struct uzlib_uncomp __attribute__((section (".globals"))) m_uncomp;
static uint8_t _ota_buff[256];
static struct lfs_file_config _ota_cfg = { (void *)_ota_buff, NULL, 0 };
uint8_t __attribute__((section (".globals")))_ota_buff[256];
struct lfs_file_config _ota_cfg = { (void *)_ota_buff, NULL, 0 };
static uint8_t _file_buff[256];
static struct lfs_file_config _file_cfg = { (void *)_file_buff, NULL, 0 };
uint8_t __attribute__((section (".globals")))_file_buff[256];
struct lfs_file_config _file_cfg = { (void *)_file_buff, NULL, 0 };
bool lfsReadOTA(OTACmdPage *ota, uint32_t *blockToErase) {
lfs_file_t f;
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "framework-arduinopico",
"version": "1.20700.0",
"version": "1.20703.0",
"description": "Arduino Wiring-based Framework (RPi Pico RP2040)",
"keywords": [
"framework",
+4
View File
@@ -111,6 +111,10 @@ sed 's/^tools.uf2conv.network_cmd=.*//g' | \
sed 's/^#tools.uf2conv.network_cmd=/tools.uf2conv.network_cmd=/g' | \
sed 's/^tools.picoprobe.cmd=.*//g' | \
sed 's/^#tools.picoprobe.cmd=/tools.picoprobe.cmd=/g' | \
sed 's/^tools.picoprobe_cmsis_dap.cmd=.*//g' | \
sed 's/^#tools.picoprobe_cmsis_dap.cmd=/tools.picoprobe_cmsis_dap.cmd=/g' | \
sed 's/^tools.picotool.cmd=.*//g' | \
sed 's/^#tools.picotool.cmd=/tools.picotool.cmd=/g' | \
sed 's/^tools.picodebug.cmd=.*//g' | \
sed 's/^#tools.picodebug.cmd=/tools.picodebug.cmd=/g' | \
sed 's/^discovery.rp2040.pattern=.*//g' | \
+215 -149
View File
@@ -23,6 +23,9 @@
{
"name": "Raspberry Pi Pico W"
},
{
"name": "0xCB Helios"
},
{
"name": "Adafruit Feather RP2040"
},
@@ -128,6 +131,9 @@
{
"name": "Seeed XIAO RP2040"
},
{
"name": "VCC-GND YD RP2040"
},
{
"name": "Viyalab Mizu RP2040"
},
@@ -165,22 +171,22 @@
"toolsDependencies": [
{
"packager": "rp2040",
"version": "1.5.0-a-5007782",
"version": "1.5.0-b-c7bab52",
"name": "pqt-gcc"
},
{
"packager": "rp2040",
"version": "1.5.0-a-5007782",
"version": "1.5.0-b-c7bab52",
"name": "pqt-mklittlefs"
},
{
"packager": "rp2040",
"version": "1.5.0-a-5007782",
"version": "1.5.0-b-c7bab52",
"name": "pqt-elf2uf2"
},
{
"packager": "rp2040",
"version": "1.5.0-a-5007782",
"version": "1.5.0-b-c7bab52",
"name": "pqt-pioasm"
},
{
@@ -190,8 +196,13 @@
},
{
"packager": "rp2040",
"version": "1.5.0-a-5007782",
"version": "1.5.0-b-c7bab52",
"name": "pqt-openocd"
},
{
"packager": "rp2040",
"version": "1.5.0-b-03f2812",
"name": "pqt-picotool"
}
],
"help": {
@@ -201,56 +212,111 @@
],
"tools": [
{
"version": "1.5.0-a-5007782",
"version": "1.5.0-b-03f2812",
"name": "pqt-picotool",
"systems": [
{
"host": "aarch64-linux-gnu",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/aarch64-linux-gnu.picotool-03f2812.230216.tar.gz",
"archiveFileName": "aarch64-linux-gnu.picotool-03f2812.230216.tar.gz",
"checksum": "SHA-256:5efe9c4ccc08d9d28cc87a0cfaf563b6fc1caa5d3967c963814225fd252756c7",
"size": "171877"
},
{
"host": "arm-linux-gnueabihf",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/arm-linux-gnueabihf.picotool-03f2812.230216.tar.gz",
"archiveFileName": "arm-linux-gnueabihf.picotool-03f2812.230216.tar.gz",
"checksum": "SHA-256:38f3f0925be5e053866ad33e8a535ac9d08f58af837a53b65dfe45f2ccbe9c5b",
"size": "152925"
},
{
"host": "i686-pc-linux-gnu",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/i686-linux-gnu.picotool-03f2812.230216.tar.gz",
"archiveFileName": "i686-linux-gnu.picotool-03f2812.230216.tar.gz",
"checksum": "SHA-256:485c09be49850d2e05c32e20fcc899b58e649e2863b300c7e89110d36094dce1",
"size": "183644"
},
{
"host": "i686-mingw32",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/i686-w64-mingw32.picotool-03f2812.230216.zip",
"archiveFileName": "i686-w64-mingw32.picotool-03f2812.230216.zip",
"checksum": "SHA-256:9d7516313c1e9b341fe8ce05b786348def60692dc88f17bdee5bc25b6baf6871",
"size": "352766"
},
{
"host": "x86_64-apple-darwin",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/x86_64-apple-darwin14.picotool-03f2812.230216.tar.gz",
"archiveFileName": "x86_64-apple-darwin14.picotool-03f2812.230216.tar.gz",
"checksum": "SHA-256:8b48c395f871dac7cbe396e4518649d40582d5a78948f0e792d0569db5069226",
"size": "852423"
},
{
"host": "x86_64-pc-linux-gnu",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/x86_64-linux-gnu.picotool-03f2812.230216.tar.gz",
"archiveFileName": "x86_64-linux-gnu.picotool-03f2812.230216.tar.gz",
"checksum": "SHA-256:507d7d01d63caebb2c3f33e99a8545a3719699c5645c423175bf0b7bfd685a48",
"size": "131605"
},
{
"host": "x86_64-mingw32",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/x86_64-w64-mingw32.picotool-03f2812.230216.zip",
"archiveFileName": "x86_64-w64-mingw32.picotool-03f2812.230216.zip",
"checksum": "SHA-256:ca62fe7dd783fc38080d834e413e1632086c6bc24660e6f5eaad931465ca87e3",
"size": "337119"
}
]
},
{
"version": "1.5.0-b-c7bab52",
"name": "pqt-openocd",
"systems": [
{
"host": "aarch64-linux-gnu",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-a/aarch64-linux-gnu.openocd-228ede43d.221223.tar.gz",
"archiveFileName": "aarch64-linux-gnu.openocd-228ede43d.221223.tar.gz",
"checksum": "SHA-256:aa3f7a24af6afca5bacd9172f943f59d1f7ca9a3525e7e9c445dba9f8c6c8b68",
"size": "5807317"
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/aarch64-linux-gnu.openocd-8e3c38f78.230216.tar.gz",
"archiveFileName": "aarch64-linux-gnu.openocd-8e3c38f78.230216.tar.gz",
"checksum": "SHA-256:6875c0c2e7faa320882d00f33f415499e1028d3bd0bac7d672d4342968c28eaf",
"size": "5812640"
},
{
"host": "arm-linux-gnueabihf",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-a/arm-linux-gnueabihf.openocd-228ede43d.221223.tar.gz",
"archiveFileName": "arm-linux-gnueabihf.openocd-228ede43d.221223.tar.gz",
"checksum": "SHA-256:40a623e198eccafaec210e3f1b425369e6fe79cef0d94b7a910d63223c37cc50",
"size": "5538300"
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/arm-linux-gnueabihf.openocd-8e3c38f78.230216.tar.gz",
"archiveFileName": "arm-linux-gnueabihf.openocd-8e3c38f78.230216.tar.gz",
"checksum": "SHA-256:fa35b2c6ca10b332718db8217c7bb57cc1e15bafc526dd05c0d6a890b05dec50",
"size": "5543967"
},
{
"host": "i686-pc-linux-gnu",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-a/i686-linux-gnu.openocd-228ede43d.221223.tar.gz",
"archiveFileName": "i686-linux-gnu.openocd-228ede43d.221223.tar.gz",
"checksum": "SHA-256:b80eb819e302130bde5ed303f23645e615bc2440303223d924742ee89dc6d477",
"size": "5341706"
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/i686-linux-gnu.openocd-8e3c38f78.230216.tar.gz",
"archiveFileName": "i686-linux-gnu.openocd-8e3c38f78.230216.tar.gz",
"checksum": "SHA-256:0f27f4a7be0411db032b8fc0aa8f55b559d03909830b38dc6610301a9a79050c",
"size": "5347247"
},
{
"host": "i686-mingw32",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-a/i686-w64-mingw32.openocd-228ede43d.221223.zip",
"archiveFileName": "i686-w64-mingw32.openocd-228ede43d.221223.zip",
"checksum": "SHA-256:02d9fba9d4e66de31cd99af0ade3a6150d258d034aa5f85f7f4601c849b8bc80",
"size": "2207879"
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/i686-w64-mingw32.openocd-8e3c38f78.230216.zip",
"archiveFileName": "i686-w64-mingw32.openocd-8e3c38f78.230216.zip",
"checksum": "SHA-256:a53ee67b63893d2dc432df293f494443921301021ec0828a044813528880d16a",
"size": "2207880"
},
{
"host": "x86_64-apple-darwin",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-a/x86_64-apple-darwin14.openocd-228ede43d.221223.tar.gz",
"archiveFileName": "x86_64-apple-darwin14.openocd-228ede43d.221223.tar.gz",
"checksum": "SHA-256:f92b87bd2ec81260c4c76e9e74ede41888d943ac0a97c11ec5f579d450ba72b1",
"size": "2599689"
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/x86_64-apple-darwin14.openocd-8e3c38f78.230216.tar.gz",
"archiveFileName": "x86_64-apple-darwin14.openocd-8e3c38f78.230216.tar.gz",
"checksum": "SHA-256:8f68f93ee51973926cb94c24164013d35d4dd42a636e4c15af5d3bb3884e6daf",
"size": "2599703"
},
{
"host": "x86_64-pc-linux-gnu",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-a/x86_64-linux-gnu.openocd-228ede43d.221223.tar.gz",
"archiveFileName": "x86_64-linux-gnu.openocd-228ede43d.221223.tar.gz",
"checksum": "SHA-256:cf4c30151c9f4583964579f11ffbc66229508b21d83d2f1d7c87eb28d1f0cca9",
"size": "5727971"
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/x86_64-linux-gnu.openocd-8e3c38f78.230216.tar.gz",
"archiveFileName": "x86_64-linux-gnu.openocd-8e3c38f78.230216.tar.gz",
"checksum": "SHA-256:50fe784a938922ffb0c12076245cedbc467f5f51b6030da776b6f95305308492",
"size": "5732546"
},
{
"host": "x86_64-mingw32",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-a/x86_64-w64-mingw32.openocd-228ede43d.221223.zip",
"archiveFileName": "x86_64-w64-mingw32.openocd-228ede43d.221223.zip",
"checksum": "SHA-256:5f0c4f67f0bba6cf3b9968ba27796fe98ef8787e56f0a160dede8d05d578586c",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/x86_64-w64-mingw32.openocd-8e3c38f78.230216.zip",
"archiveFileName": "x86_64-w64-mingw32.openocd-8e3c38f78.230216.zip",
"checksum": "SHA-256:d36a25b7e40771bcc286a51bfa4803668037662651bce5a40a36608babbc3f5f",
"size": "2168940"
}
]
@@ -318,222 +384,222 @@
]
},
{
"version": "1.5.0-a-5007782",
"version": "1.5.0-b-c7bab52",
"name": "pqt-gcc",
"systems": [
{
"host": "aarch64-linux-gnu",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-a/aarch64-linux-gnu.arm-none-eabi-5007782.221223.tar.gz",
"archiveFileName": "aarch64-linux-gnu.arm-none-eabi-5007782.221223.tar.gz",
"checksum": "SHA-256:baff843fce38393565babf81ecfddfab17df8046d901faad3c5f93ee072d395b",
"size": "81474410"
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/aarch64-linux-gnu.arm-none-eabi-c7bab52.230216.tar.gz",
"archiveFileName": "aarch64-linux-gnu.arm-none-eabi-c7bab52.230216.tar.gz",
"checksum": "SHA-256:2b3ec7c790bab21e08347205b8dec03a39747d0ef99266ce26a04e8e55bd7db8",
"size": "81474732"
},
{
"host": "arm-linux-gnueabihf",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-a/arm-linux-gnueabihf.arm-none-eabi-5007782.221223.tar.gz",
"archiveFileName": "arm-linux-gnueabihf.arm-none-eabi-5007782.221223.tar.gz",
"checksum": "SHA-256:35144f4aded62ab45ab7ddabf63c189af70b57534438cf00281c11b5ef90d316",
"size": "76138344"
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/arm-linux-gnueabihf.arm-none-eabi-c7bab52.230216.tar.gz",
"archiveFileName": "arm-linux-gnueabihf.arm-none-eabi-c7bab52.230216.tar.gz",
"checksum": "SHA-256:9ec76a79f045d6f634a21e2b1e814b39bf85bb294c53a076b9c8ac2640ad3acc",
"size": "76133046"
},
{
"host": "i686-pc-linux-gnu",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-a/i686-linux-gnu.arm-none-eabi-5007782.221223.tar.gz",
"archiveFileName": "i686-linux-gnu.arm-none-eabi-5007782.221223.tar.gz",
"checksum": "SHA-256:d1d5121c4a5e4fa42047daf58c112a90beeb3533d1f133f4928db4b337030351",
"size": "83712710"
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/i686-linux-gnu.arm-none-eabi-c7bab52.230216.tar.gz",
"archiveFileName": "i686-linux-gnu.arm-none-eabi-c7bab52.230216.tar.gz",
"checksum": "SHA-256:dea62b8d66c323a07e366625049a17b2d1d8a8a7882b4d2b3aa6247456614867",
"size": "83713275"
},
{
"host": "i686-mingw32",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-a/i686-w64-mingw32.arm-none-eabi-5007782.221223.zip",
"archiveFileName": "i686-w64-mingw32.arm-none-eabi-5007782.221223.zip",
"checksum": "SHA-256:71e0858689b644e5b0aaa07ec5257919ab292ff9404bfc9c52dc31593828f391",
"size": "85628083"
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/i686-w64-mingw32.arm-none-eabi-c7bab52.230216.zip",
"archiveFileName": "i686-w64-mingw32.arm-none-eabi-c7bab52.230216.zip",
"checksum": "SHA-256:0b76a320398ce6f0457edf98033742afd85ea3f143dec034a3fec7d3a21c52bf",
"size": "85634400"
},
{
"host": "x86_64-apple-darwin",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-a/x86_64-apple-darwin14.arm-none-eabi-5007782.221223.tar.gz",
"archiveFileName": "x86_64-apple-darwin14.arm-none-eabi-5007782.221223.tar.gz",
"checksum": "SHA-256:ad984927785d17ddd34cfc7bc76d4d1371d6f6905d8708d3535a261b244b32d9",
"size": "84968911"
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/x86_64-apple-darwin14.arm-none-eabi-c7bab52.230216.tar.gz",
"archiveFileName": "x86_64-apple-darwin14.arm-none-eabi-c7bab52.230216.tar.gz",
"checksum": "SHA-256:f83f143d424077322f7ea3971b88ac558c7b211f4a27776f6ba7c012a7c19938",
"size": "84979864"
},
{
"host": "x86_64-pc-linux-gnu",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-a/x86_64-linux-gnu.arm-none-eabi-5007782.221223.tar.gz",
"archiveFileName": "x86_64-linux-gnu.arm-none-eabi-5007782.221223.tar.gz",
"checksum": "SHA-256:591af0c27b08b31d11b3135a56bbd3c447cd9e6cac2987cdb3ab25a86d7eb3e3",
"size": "83660106"
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/x86_64-linux-gnu.arm-none-eabi-c7bab52.230216.tar.gz",
"archiveFileName": "x86_64-linux-gnu.arm-none-eabi-c7bab52.230216.tar.gz",
"checksum": "SHA-256:bf197bde7ee76d26a8c142b2308e46269252b19403df5617aa1bd90ea4618427",
"size": "83669292"
},
{
"host": "x86_64-mingw32",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-a/x86_64-w64-mingw32.arm-none-eabi-5007782.221223.zip",
"archiveFileName": "x86_64-w64-mingw32.arm-none-eabi-5007782.221223.zip",
"checksum": "SHA-256:f2cf872ce5bd07efa2cfa044de28458034be9466f5ccae4e7e9cd229aabefa11",
"size": "88351413"
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/x86_64-w64-mingw32.arm-none-eabi-c7bab52.230216.zip",
"archiveFileName": "x86_64-w64-mingw32.arm-none-eabi-c7bab52.230216.zip",
"checksum": "SHA-256:ed1a7103c9d55ad3d44eeb399a308789d1d1094a73c78b554e2693eb8140b9c5",
"size": "88352385"
}
]
},
{
"version": "1.5.0-a-5007782",
"version": "1.5.0-b-c7bab52",
"name": "pqt-elf2uf2",
"systems": [
{
"host": "aarch64-linux-gnu",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-a/aarch64-linux-gnu.elf2uf2-2e6142b.221223.tar.gz",
"archiveFileName": "aarch64-linux-gnu.elf2uf2-2e6142b.221223.tar.gz",
"checksum": "SHA-256:266151dc2523ec707b88256e7220a5e89c819ad1e134a7f492cf9fbe07ccf8a1",
"size": "82684"
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/aarch64-linux-gnu.elf2uf2-2e6142b.230216.tar.gz",
"archiveFileName": "aarch64-linux-gnu.elf2uf2-2e6142b.230216.tar.gz",
"checksum": "SHA-256:00adc6949c467c75181364e9e5bf6378e50483caf4f04b0fc5e4c1d105f780ee",
"size": "82856"
},
{
"host": "arm-linux-gnueabihf",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-a/arm-linux-gnueabihf.elf2uf2-2e6142b.221223.tar.gz",
"archiveFileName": "arm-linux-gnueabihf.elf2uf2-2e6142b.221223.tar.gz",
"checksum": "SHA-256:e30f1243259361a635a21d69e81bf2d913e194882159eba8c652d5b45cf2591b",
"size": "55998"
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/arm-linux-gnueabihf.elf2uf2-2e6142b.230216.tar.gz",
"archiveFileName": "arm-linux-gnueabihf.elf2uf2-2e6142b.230216.tar.gz",
"checksum": "SHA-256:de9991519727ecbb3a157e672de2572c843558018515d7c680a3aa5a0d700056",
"size": "56175"
},
{
"host": "i686-pc-linux-gnu",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-a/i686-linux-gnu.elf2uf2-2e6142b.221223.tar.gz",
"archiveFileName": "i686-linux-gnu.elf2uf2-2e6142b.221223.tar.gz",
"checksum": "SHA-256:17ebb211916bc74a9cd3263f6d5e9721bb91d54a836c4369c1e01e9147e4f477",
"size": "91387"
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/i686-linux-gnu.elf2uf2-2e6142b.230216.tar.gz",
"archiveFileName": "i686-linux-gnu.elf2uf2-2e6142b.230216.tar.gz",
"checksum": "SHA-256:12c4d4566a61c15104e26b10a1330a2dc12ecf63e054966e2d6cea13cef8f92b",
"size": "91559"
},
{
"host": "i686-mingw32",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-a/i686-w64-mingw32.elf2uf2-2e6142b.221223.zip",
"archiveFileName": "i686-w64-mingw32.elf2uf2-2e6142b.221223.zip",
"checksum": "SHA-256:80f740ffdb0a1812212f631598060216361b1a8e55d2092e729afee3b3b1ad95",
"size": "71949"
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/i686-w64-mingw32.elf2uf2-2e6142b.230216.zip",
"archiveFileName": "i686-w64-mingw32.elf2uf2-2e6142b.230216.zip",
"checksum": "SHA-256:6537879c71359b916dd604dc4833aeaab6ff7571ad9e498f1f2aa8085670548c",
"size": "72230"
},
{
"host": "x86_64-apple-darwin",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-a/x86_64-apple-darwin14.elf2uf2-2e6142b.221223.tar.gz",
"archiveFileName": "x86_64-apple-darwin14.elf2uf2-2e6142b.221223.tar.gz",
"checksum": "SHA-256:bebf3f984c59b36cfdc1a5b41bc3368c674c03eea54586419872c0ce2ad71430",
"size": "86604"
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/x86_64-apple-darwin14.elf2uf2-2e6142b.230216.tar.gz",
"archiveFileName": "x86_64-apple-darwin14.elf2uf2-2e6142b.230216.tar.gz",
"checksum": "SHA-256:5b8fb8fc2dec9819ca018fa53d84b824dd2136fdcde713d98ef2cea9e5a1ce3f",
"size": "86779"
},
{
"host": "x86_64-pc-linux-gnu",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-a/x86_64-linux-gnu.elf2uf2-2e6142b.221223.tar.gz",
"archiveFileName": "x86_64-linux-gnu.elf2uf2-2e6142b.221223.tar.gz",
"checksum": "SHA-256:d7d0e77a8b4c5cf879bb92d20bbfb213d568fec86fb96fc08c60bd9a3fb38712",
"size": "82339"
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/x86_64-linux-gnu.elf2uf2-2e6142b.230216.tar.gz",
"archiveFileName": "x86_64-linux-gnu.elf2uf2-2e6142b.230216.tar.gz",
"checksum": "SHA-256:784b76139053cd5fd3cac25ec00ac75d1612dc512c0cd5f7a69b5867df8ec7ba",
"size": "82555"
},
{
"host": "x86_64-mingw32",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-a/x86_64-w64-mingw32.elf2uf2-2e6142b.221223.zip",
"archiveFileName": "x86_64-w64-mingw32.elf2uf2-2e6142b.221223.zip",
"checksum": "SHA-256:25840973640fd28817a37a4213dfbad81da91a7b75a1ecb14cdee56c2bd1a8ee",
"size": "80399"
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/x86_64-w64-mingw32.elf2uf2-2e6142b.230216.zip",
"archiveFileName": "x86_64-w64-mingw32.elf2uf2-2e6142b.230216.zip",
"checksum": "SHA-256:7ab9d08f6f3cd472c7fc005def31c87d9ce9ea57923ef7a6a81fe4f86a75b12a",
"size": "80680"
}
]
},
{
"version": "1.5.0-a-5007782",
"version": "1.5.0-b-c7bab52",
"name": "pqt-pioasm",
"systems": [
{
"host": "aarch64-linux-gnu",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-a/aarch64-linux-gnu.pioasm-2e6142b.221223.tar.gz",
"archiveFileName": "aarch64-linux-gnu.pioasm-2e6142b.221223.tar.gz",
"checksum": "SHA-256:38ae80646805781c1df2264ae6b8ff41cc0dbfcefd4dfaae9f5e355bce4890c7",
"size": "453442"
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/aarch64-linux-gnu.pioasm-2e6142b.230216.tar.gz",
"archiveFileName": "aarch64-linux-gnu.pioasm-2e6142b.230216.tar.gz",
"checksum": "SHA-256:6b60c57530bb3bd07f85a95808209f158b7b45b2808544794307701d8d468dd8",
"size": "453460"
},
{
"host": "arm-linux-gnueabihf",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-a/arm-linux-gnueabihf.pioasm-2e6142b.221223.tar.gz",
"archiveFileName": "arm-linux-gnueabihf.pioasm-2e6142b.221223.tar.gz",
"checksum": "SHA-256:3ab67c8b0f40806e8e2a53fe22b274f3b79ccc12189ab80dc2db3b4e80e34de2",
"size": "360686"
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/arm-linux-gnueabihf.pioasm-2e6142b.230216.tar.gz",
"archiveFileName": "arm-linux-gnueabihf.pioasm-2e6142b.230216.tar.gz",
"checksum": "SHA-256:079dc194321751d70e76496f0bcffdec58b73eb9976670a170f65ec06f110450",
"size": "360828"
},
{
"host": "i686-pc-linux-gnu",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-a/i686-linux-gnu.pioasm-2e6142b.221223.tar.gz",
"archiveFileName": "i686-linux-gnu.pioasm-2e6142b.221223.tar.gz",
"checksum": "SHA-256:ed5d190b3726caa58a63b08785aff17f6f412810cc7bef21405a6342717e6c6b",
"size": "511442"
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/i686-linux-gnu.pioasm-2e6142b.230216.tar.gz",
"archiveFileName": "i686-linux-gnu.pioasm-2e6142b.230216.tar.gz",
"checksum": "SHA-256:8926f848f80c29d6e52595e54e9021c4955f053f8cf157b88275408a0047d08f",
"size": "511533"
},
{
"host": "i686-mingw32",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-a/i686-w64-mingw32.pioasm-2e6142b.221223.zip",
"archiveFileName": "i686-w64-mingw32.pioasm-2e6142b.221223.zip",
"checksum": "SHA-256:713be116f8fbdd7a77ae294f2b8a72fcfcb0bd43f013124bde6e569dd284ad43",
"size": "385882"
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/i686-w64-mingw32.pioasm-2e6142b.230216.zip",
"archiveFileName": "i686-w64-mingw32.pioasm-2e6142b.230216.zip",
"checksum": "SHA-256:55a887da459e46b62b4e2eb6d62556e27a879e8bbf241c719f4d85b495d1caab",
"size": "386161"
},
{
"host": "x86_64-apple-darwin",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-a/x86_64-apple-darwin14.pioasm-2e6142b.221223.tar.gz",
"archiveFileName": "x86_64-apple-darwin14.pioasm-2e6142b.221223.tar.gz",
"checksum": "SHA-256:16feb332e66b8ed7f911eceb153484565d1947a87eb7c9db774bd38a9a7b0043",
"size": "480539"
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/x86_64-apple-darwin14.pioasm-2e6142b.230216.tar.gz",
"archiveFileName": "x86_64-apple-darwin14.pioasm-2e6142b.230216.tar.gz",
"checksum": "SHA-256:2818ab1de24bad4e421315ac497b20373beaa16dd09b876bc6d00e2bba1f3d15",
"size": "480566"
},
{
"host": "x86_64-pc-linux-gnu",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-a/x86_64-linux-gnu.pioasm-2e6142b.221223.tar.gz",
"archiveFileName": "x86_64-linux-gnu.pioasm-2e6142b.221223.tar.gz",
"checksum": "SHA-256:367b14d59bb5394c068bacd1ab3dfd77116208ad28213af01372d5a93bb0ead3",
"size": "458693"
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/x86_64-linux-gnu.pioasm-2e6142b.230216.tar.gz",
"archiveFileName": "x86_64-linux-gnu.pioasm-2e6142b.230216.tar.gz",
"checksum": "SHA-256:c79400b056594268aab8ae1baf18abc8cf3170c6edb1f8104579738d78cd22ad",
"size": "458858"
},
{
"host": "x86_64-mingw32",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-a/x86_64-w64-mingw32.pioasm-2e6142b.221223.zip",
"archiveFileName": "x86_64-w64-mingw32.pioasm-2e6142b.221223.zip",
"checksum": "SHA-256:c18d5499308c4938b1c2230724f3adb2de8071583b9185b77705747555c9a50f",
"size": "409100"
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/x86_64-w64-mingw32.pioasm-2e6142b.230216.zip",
"archiveFileName": "x86_64-w64-mingw32.pioasm-2e6142b.230216.zip",
"checksum": "SHA-256:8c06fa68fe5d51fd54e9e9db11608e0e893d3b90e0437a6507eaef972e95b891",
"size": "409379"
}
]
},
{
"version": "1.5.0-a-5007782",
"version": "1.5.0-b-c7bab52",
"name": "pqt-mklittlefs",
"systems": [
{
"host": "aarch64-linux-gnu",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-a/aarch64-linux-gnu.mklittlefs-30b7fc1.221223.tar.gz",
"archiveFileName": "aarch64-linux-gnu.mklittlefs-30b7fc1.221223.tar.gz",
"checksum": "SHA-256:6e20ef3f0c8f4eedd18377cd8e7626a724b3c11ce914e66e23fe021493b519b6",
"size": "60993"
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/aarch64-linux-gnu.mklittlefs-4aca452.230216.tar.gz",
"archiveFileName": "aarch64-linux-gnu.mklittlefs-4aca452.230216.tar.gz",
"checksum": "SHA-256:07d1baa8f0e8c3eb38db8751eb647e0f3ff465c5d7973642c8f9011a2c05dba2",
"size": "63222"
},
{
"host": "arm-linux-gnueabihf",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-a/arm-linux-gnueabihf.mklittlefs-30b7fc1.221223.tar.gz",
"archiveFileName": "arm-linux-gnueabihf.mklittlefs-30b7fc1.221223.tar.gz",
"checksum": "SHA-256:092501f939d78625f876644a5c1d3264f2310e1798ea6d12a2845274a50a0b54",
"size": "51573"
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/arm-linux-gnueabihf.mklittlefs-4aca452.230216.tar.gz",
"archiveFileName": "arm-linux-gnueabihf.mklittlefs-4aca452.230216.tar.gz",
"checksum": "SHA-256:e7ce6a71ea02cae9d149ee1e078702a4af50d7a930452237666a2b402c3f1181",
"size": "53461"
},
{
"host": "i686-pc-linux-gnu",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-a/i686-linux-gnu.mklittlefs-30b7fc1.221223.tar.gz",
"archiveFileName": "i686-linux-gnu.mklittlefs-30b7fc1.221223.tar.gz",
"checksum": "SHA-256:c2d8b5d8c903b024ae88bd5a97d9759049fbc1e7ab84ea19ea6ea2546f0aa496",
"size": "67720"
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/i686-linux-gnu.mklittlefs-4aca452.230216.tar.gz",
"archiveFileName": "i686-linux-gnu.mklittlefs-4aca452.230216.tar.gz",
"checksum": "SHA-256:8c41373fb26bcdc15590b2924f23672a46464877702c583d9a7c30ac3a1ea942",
"size": "69995"
},
{
"host": "i686-mingw32",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-a/i686-w64-mingw32.mklittlefs-30b7fc1.221223.zip",
"archiveFileName": "i686-w64-mingw32.mklittlefs-30b7fc1.221223.zip",
"checksum": "SHA-256:9f66d5b6bdfce13b1c246ae2d8abfcab623828337a16a1f2571eeed1b71096b9",
"size": "345497"
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/i686-w64-mingw32.mklittlefs-4aca452.230216.zip",
"archiveFileName": "i686-w64-mingw32.mklittlefs-4aca452.230216.zip",
"checksum": "SHA-256:9a4460c0e2e46847c2bd1ab934544f88fbd611237a12445ae69dbc6086f05c4f",
"size": "347619"
},
{
"host": "x86_64-apple-darwin",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-a/x86_64-apple-darwin14.mklittlefs-30b7fc1.221223.tar.gz",
"archiveFileName": "x86_64-apple-darwin14.mklittlefs-30b7fc1.221223.tar.gz",
"checksum": "SHA-256:1f7e675700ff4b5de21d1ea37a0969683ad54685d94bf0b42de13c26aa42f13f",
"size": "377123"
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/x86_64-apple-darwin14.mklittlefs-4aca452.230216.tar.gz",
"archiveFileName": "x86_64-apple-darwin14.mklittlefs-4aca452.230216.tar.gz",
"checksum": "SHA-256:3575877065d206083c3dc4715bee983a1e7145969457d1fca752943aa67eb655",
"size": "378957"
},
{
"host": "x86_64-pc-linux-gnu",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-a/x86_64-linux-gnu.mklittlefs-30b7fc1.221223.tar.gz",
"archiveFileName": "x86_64-linux-gnu.mklittlefs-30b7fc1.221223.tar.gz",
"checksum": "SHA-256:2773b0e7a5af33052b84959893cd9e7f3223236730f2109546399ec52d6a7a70",
"size": "62741"
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/x86_64-linux-gnu.mklittlefs-4aca452.230216.tar.gz",
"archiveFileName": "x86_64-linux-gnu.mklittlefs-4aca452.230216.tar.gz",
"checksum": "SHA-256:af472f914ba46b6a7466049cb989804ce56d5808334b1af09403dedfdf6e1ff2",
"size": "64931"
},
{
"host": "x86_64-mingw32",
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-a/x86_64-w64-mingw32.mklittlefs-30b7fc1.221223.zip",
"archiveFileName": "x86_64-w64-mingw32.mklittlefs-30b7fc1.221223.zip",
"checksum": "SHA-256:ee9a6caad229cd9530465926c755a4dc68a89bd5a6ff642c060dfa05f0c01a2a",
"size": "357313"
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.5.0-b/x86_64-w64-mingw32.mklittlefs-4aca452.230216.zip",
"archiveFileName": "x86_64-w64-mingw32.mklittlefs-4aca452.230216.zip",
"checksum": "SHA-256:fd3dbfd224708f05f14d1c3f715d90473d462ba2fa06683fc523e13d2bb716f2",
"size": "359304"
}
]
}
+22 -7
View File
@@ -20,7 +20,7 @@
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification
name=Raspberry Pi RP2040 Boards
version=2.7.0
version=2.7.3
runtime.tools.pqt-gcc.path={runtime.platform.path}/system/arm-none-eabi
runtime.tools.pqt-python3.path={runtime.platform.path}/system/python3
@@ -28,6 +28,7 @@ runtime.tools.pqt-mklittlefs.path={runtime.platform.path}/system/mklittlefs
runtime.tools.pqt-pioasm.path={runtime.platform.path}/system/pioasm
runtime.tools.pqt-elf2uf2.path={runtime.platform.path}/system/elf2uf2
runtime.tools.pqt-openocd.path={runtime.platform.path}/system/openocd
runtime.tools.pqt-picotool.path={runtime.platform.path}/system/picotool
compiler.path={runtime.tools.pqt-gcc.path}/bin/
compiler.libraries.ldflags=
@@ -42,9 +43,9 @@ compiler.warning_flags.more=-Wall -Werror=return-type -Wno-ignored-qualifiers
compiler.warning_flags.all=-Wall -Wextra -Werror=return-type -Wno-ignored-qualifiers
compiler.netdefines=-DPICO_CYW43_ARCH_THREADSAFE_BACKGROUND=1 -DCYW43_LWIP=0 {build.lwipdefs} -DLWIP_IGMP=1 -DLWIP_CHECKSUM_CTRL_PER_NETIF=1
compiler.defines={build.led} {build.usbstack_flags} -DCFG_TUSB_MCU=OPT_MCU_RP2040 -DUSB_VID={build.vid} -DUSB_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {compiler.netdefines} -DARDUINO_VARIANT="{build.variant}" -DTARGET_RP2040
compiler.defines={build.led} {build.usbstack_flags} -DCFG_TUSB_MCU=OPT_MCU_RP2040 {build.usbpid} {build.usbvid} {build.usbpwr} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {compiler.netdefines} -DARDUINO_VARIANT="{build.variant}" -DTARGET_RP2040
compiler.includes="-iprefix{runtime.platform.path}/" "@{runtime.platform.path}/lib/platform_inc.txt" "-I{runtime.platform.path}/include"
compiler.flags=-march=armv6-m -mcpu=cortex-m0plus -mthumb -ffunction-sections -fdata-sections {build.flags.exceptions} {build.flags.stackprotect} {build.flags.cmsis}
compiler.flags=-march=armv6-m -mcpu=cortex-m0plus -mthumb -ffunction-sections -fdata-sections {build.flags.exceptions} {build.flags.stackprotect} {build.flags.cmsis} {build.picodebugflags}
compiler.wrap="@{runtime.platform.path}/lib/platform_wrap.txt"
compiler.libbearssl="{runtime.platform.path}/lib/libbearssl.a"
@@ -97,6 +98,7 @@ build.boot2=boot2_generic_03h_4_padded_checksum
build.lwipdefs=-DLWIP_IPV6=0 -DLWIP_IPV4=1
build.wificc=-DWIFICC=CYW43_COUNTRY_WORLDWIDE
build.debugscript=picoprobe.tcl
build.picodebugflags=
# Allow Pico boards do be auto-discovered by the IDE
#discovery.rp2040.pattern={runtime.tools.pqt-python3.path}/python3 -I "{runtime.platform.path}/tools/pluggable_discovery.py"
@@ -112,13 +114,13 @@ pluggable_discovery.rp2040.pattern="{runtime.platform.path}/system/python3/pytho
recipe.hooks.sketch.prebuild.pattern="{runtime.tools.pqt-python3.path}/python3" -I "{runtime.platform.path}/tools/signing.py" --mode header --publickey "{build.source.path}/public.key" --out "{build.path}/core/Updater_Signing.h"
## Compile c files
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} {build.usbpid} {build.usbpwr} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.debug_port} {build.debug_level} {build.flags.optimize} {includes} "{source_file}" -o "{object_file}"
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.debug_port} {build.debug_level} {build.flags.optimize} {includes} "{source_file}" -o "{object_file}"
## Compile c++ files
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" -I "{build.path}/core" {compiler.cpp.flags} {build.usbpid} {build.usbpwr} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {build.debug_port} {build.debug_level} {build.flags.optimize} {build.wificc} {includes} "{source_file}" -o "{object_file}"
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" -I "{build.path}/core" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {build.debug_port} {build.debug_level} {build.flags.optimize} {build.wificc} {includes} "{source_file}" -o "{object_file}"
## Compile S files
recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} {build.usbpid} {build.usbpwr} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.debug_port} {build.debug_level} {includes} "{source_file}" -o "{object_file}"
recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.debug_port} {build.debug_level} {includes} "{source_file}" -o "{object_file}"
## Create archives
# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value
@@ -151,7 +153,7 @@ recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_ou
## Compute size
recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"
recipe.size.regex=^(?:\.boot2|\.text|\.rodata|\.ARM\.extab|\.ARM\.exidx)\s+([0-9]+).*
recipe.size.regex.data=^(?:\.data|\.bss|\.ram_vector_table|\.uninitialized_data)\s+([0-9]+).*
recipe.size.regex.data=^(?:\.data|\.bss|\.ram_vector_table|\.uninitialized_ram|\.uninitialized_data)\s+([0-9]+).*
# Debugging
@@ -187,6 +189,12 @@ tools.uf2conv-network.upload.params.verbose=
tools.uf2conv-network.upload.params.quiet=
tools.uf2conv-network.upload.pattern="{cmd}" -I "{runtime.platform.path}/tools/espota.py" -i "{upload.port.address}" -p "{upload.port.properties.port}" "--auth={upload.field.password}" -f "{build.path}/{build.project_name}.bin"
#tools.picotool.cmd={runtime.tools.pqt-picotool.path}
tools.picotool.cmd={runtime.platform.path}/system/picotool
tools.picotool.upload.protocol=picotool
tools.picotool.upload.params.verbose=
tools.picotool.upload.params.quiet=
tools.picotool.upload.pattern="{cmd}/picotool" load "{build.path}/{build.project_name}.uf2" -f
#tools.picoprobe.cmd={runtime.tools.pqt-openocd.path}
tools.picoprobe.cmd={runtime.platform.path}/system/openocd
@@ -195,6 +203,13 @@ tools.picoprobe.upload.params.verbose=
tools.picoprobe.upload.params.quiet=
tools.picoprobe.upload.pattern="{cmd}/bin/openocd" -f "interface/picoprobe.cfg" -f "target/rp2040.cfg" -s "{cmd}/share/openocd/scripts" -c "program {{build.path}/{build.project_name}.elf} verify reset exit"
#tools.picoprobe_cmsis_dap.cmd={runtime.tools.pqt-openocd.path}
tools.picoprobe_cmsis_dap.cmd={runtime.platform.path}/system/openocd
tools.picoprobe_cmsis_dap.upload.protocol=picoprobe_cmsis_dap
tools.picoprobe_cmsis_dap.upload.params.verbose=
tools.picoprobe_cmsis_dap.upload.params.quiet=
tools.picoprobe_cmsis_dap.upload.pattern="{cmd}/bin/openocd" -f "interface/cmsis-dap.cfg" -f "target/rp2040.cfg" -s "{cmd}/share/openocd/scripts" -c "adapter speed 5000" -c "program {{build.path}/{build.project_name}.elf} verify reset exit"
#tools.picodebug.cmd={runtime.tools.pqt-openocd.path}
tools.picodebug.cmd={runtime.platform.path}/system/openocd
tools.picodebug.upload.protocol=pico-debug
+2 -2
View File
@@ -1,8 +1,8 @@
#!/bin/bash
for dir in ./cores/rp2040 ./libraries/EEPROM ./libraries/I2S ./libraries/SingleFileDrive \
./libraries/LittleFS/src ./libraries/LittleFS/examples \
./libraries/rp2040 ./libraries/SD ./libraries/ESP8266SdFat \
./libraries/LittleFS/src ./libraries/LittleFS/examples ./libraries/PWMAudio \
./libraries/rp2040 ./libraries/SD ./libraries/ESP8266SdFat ./libraries/ADCInput \
./libraries/Servo ./libraries/SPI ./libraries/Wire ./libraries/PDM \
./libraries/WiFi ./libraries/lwIP_Ethernet ./libraries/lwIP_CYW43 \
./libraries/FreeRTOS/src ./libraries/LEAmDNS ./libraries/MD5Builder \
+54
View File
@@ -0,0 +1,54 @@
{
"build": {
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_w25q128jvxq_4_padded_checksum.S",
"usb_vid": "0x1209",
"usb_pid": "0xCB74"
}
},
"core": "earlephilhower",
"cpu": "cortex-m0plus",
"extra_flags": "-D ARDUINO_0XCB_HELIOS -DARDUINO_ARCH_RP2040 -DUSBD_MAX_POWER_MA=500",
"f_cpu": "133000000L",
"hwids": [
[
"0x2E8A",
"0x00C0"
],
[
"0x1209",
"0xCB74"
]
],
"mcu": "rp2040",
"variant": "0xcb_helios"
},
"debug": {
"jlink_device": "RP2040_M0_0",
"openocd_target": "rp2040.cfg",
"svd_path": "rp2040.svd"
},
"frameworks": [
"arduino"
],
"name": "Helios",
"upload": {
"maximum_ram_size": 270336,
"maximum_size": 16777216,
"require_upload_port": true,
"native_usb": true,
"use_1200bps_touch": true,
"wait_for_upload_port": false,
"protocol": "picotool",
"protocols": [
"cmsis-dap",
"jlink",
"raspberrypi-swd",
"picotool",
"picoprobe"
]
},
"url": "https://www.raspberrypi.org/products/raspberry-pi-pico/",
"vendor": "0xCB"
}
+54
View File
@@ -0,0 +1,54 @@
{
"build": {
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_generic_03h_4_padded_checksum.S",
"usb_vid": "0x2E8A",
"usb_pid": "0x800A"
}
},
"core": "earlephilhower",
"cpu": "cortex-m0plus",
"extra_flags": "-D ARDUINO_YD_RP2040 -DARDUINO_ARCH_RP2040 -DUSBD_MAX_POWER_MA=500",
"f_cpu": "133000000L",
"hwids": [
[
"0x2E8A",
"0x00C0"
],
[
"0x2E8A",
"0x800A"
]
],
"mcu": "rp2040",
"variant": "vccgnd_yd_rp2040"
},
"debug": {
"jlink_device": "RP2040_M0_0",
"openocd_target": "rp2040.cfg",
"svd_path": "rp2040.svd"
},
"frameworks": [
"arduino"
],
"name": "YD RP2040",
"upload": {
"maximum_ram_size": 270336,
"maximum_size": 16777216,
"require_upload_port": true,
"native_usb": true,
"use_1200bps_touch": true,
"wait_for_upload_port": false,
"protocol": "picotool",
"protocols": [
"cmsis-dap",
"jlink",
"raspberrypi-swd",
"picotool",
"picoprobe"
]
},
"url": "https://www.raspberrypi.org/products/raspberry-pi-pico/",
"vendor": "VCC-GND"
}

Some files were not shown because too many files have changed in this diff Show More