Compare commits

...
42 Commits
Author SHA1 Message Date
Earle F. Philhower, III 4cc8e6d6db Update version 2022-12-17 12:07:51 -08:00
brabl2 fecbac2e25 Modified LowPowerMode functions in WiFiClass.cpp/.h for better connection stability (#1046)
* Modified LowPowerMode functions in WiFiClass.cpp/.h

* Added noLowPowerMode() in the WiFiClass::begin()/beginAP()
2022-12-17 11:49:16 -08:00
Earle F. Philhower, III e2e65fd53b Fix I2s::available() to skip currently playing (#1043)
Fixes #963

The available space calculation didn't account for the fact that one
of the buffers was currently being output, causing ::available() to
be too large and ::write() to block in that case.
2022-12-14 15:41:36 -08:00
Earle F. Philhower, III f22ed52b75 Increase ClientContext write(Stream) to 256b chunk (#1042)
Other parts of the core use temp 256 byte chunks to transmit/move/operate
on data, so do the same here.  Will increase effective WebServer sendFile
speeds.
2022-12-14 09:14:57 -08:00
Earle F. Philhower, III 03dbd6af65 Increase WiFi.begin() default timeout to 15s (#1041)
Fixes #1031, or at least covers the case of slower associations.
2022-12-14 08:59:24 -08:00
Earle F. Philhower, III fca7fb5e0f Add USB drive mode to TinyUSB, SingleFileDisk (#1034)
SingleFileDisk allows for exporting a file from the onboard LittleFS
filesystem to a PC through an emulated FAT drive when connected.  The
PC can open and copy the file, as well as delete it, but the PC has no
access to the main onboard LittleFS and no actual on-flash FAT
structures are used.

This is handy for things like data loggers.  They can run connected to
USB power for some time, and then connected to a PC to dowmload the CSV
log recorded.

It's almost 2023, allow LFN (long file names) on the emulated USB disk.

Reduce the disk buffer size to 64 bytes.  The buffer is statically
allocated so it's always present, even in non-USB disk mode, meaning
all apps will pay the RAM price for it.  64 bytes is slower to read
but works and saves ~1/2KB of heap for all apps.
2022-12-09 13:59:23 -08:00
Earle F. Philhower, III 80d6e2f0ec Throw away UART bytes with errors in reception (#1036)
Fixes #1021

The UART hardware will push characters into the receive FIFO even if there
are parity, framing, or other errors.  These are invalid and shouldn't be
returned to the application, so drop them if errors detected.

This will also avoid the glitch-induced initial garbage character.
2022-12-09 12:30:52 -08:00
Eli Lipsitz d35e938c36 Fix File::readString to work with binary data (#1030)
Previously, File::readString used a C-style string as an intermediate
buffer via the String += operator. This treats a NUL byte as a
terminator, making this function work incorrectly if the File contains
binary data.

This commit switches the function to use String::concat, which doesn't
treat NUL bytes any differently (and is a bit faster, because it doesn't
need to use strlen).
2022-12-04 13:23:16 -08:00
Sebastian Krzyszkowiak 4e16a700c6 pluggable_discovery: Allow the scanner thread to quit (#1029)
When receiving a `QUIT` message, the main thread was trying to tell   
the scanner thread to quit - however, what it was actually doing was
creating a local variable that shadowed the global flag used by the
scanner thread. Fix that by ensuring that the main thread uses the
global variable instead.

Fixes #1028
2022-12-04 11:50:06 -08:00
Earle F. Philhower, III d717b58001 Speed up ClientContext::write(Stream) by chunking (#1017)
Instead of sending a single packet per byte, send out larger chunks to
TCP/IP while doing a ::write(Stream).

Fixes #999
2022-11-29 15:00:47 -08:00
Earle F. Philhower, III 861da4c361 Add Waveshare JSONs for Platform.IO (#1015) 2022-11-28 12:26:23 -08:00
Earle F. Philhower, III f9321b034f Update version 2022-11-28 10:07:41 -08:00
Earle F. Philhower, III 65dd19a158 Allow building w/o USB for normal and picoprobe builds (#1013)
Supersedes #972.  Thanks @kholk
2022-11-28 10:01:35 -08:00
Earle F. Philhower, III be60060941 Fix newline issue w/Waveshare PR (#1012)
Go back to UNIX format endlines.  No functional changes.
2022-11-28 09:43:55 -08:00
Engineer_Will 39ac1d6bfb Add some Waveshare board descriptions (#1004) 2022-11-28 09:35:23 -08:00
Earle F. Philhower, III d94ca66e3e Update Wire per @chrisckc debugging (#1011)
Merge in changes @chrisckc debugged while working at 400khz on his own project.
See https://github.com/earlephilhower/arduino-pico/issues/979#issuecomment-1328237128
2022-11-28 08:50:51 -08:00
brabl2 e47e3c73c2 Fix memcpy to unallocated memory in EEPROM.cpp (#1000)
The memcpy to unallocated memory was done in two cases:
1) The 'size' parameter was not multiple of 256.
2) The begin() was called two times and the 2nd call 'size' was greater than 1st time 'size'. (e.g. 1st size=256, 2nd size=512)
2022-11-24 10:25:48 -08:00
diesel437 f11c22d984 Using PIO_FRAMEWORK_ARDUINO_NO_USB build flag would cause internal rp2040 fifo not being initialized correct. (#1001) 2022-11-24 10:02:25 -08:00
Earle F. Philhower, III bd4a2d232f Update rp2040.rst 2022-11-23 08:19:36 -08:00
Earle F. Philhower, III 158cf3c7b3 Update rp2040.rst 2022-11-23 07:57:59 -08:00
imwoo90 a7cf5cd1ca Fix GPIO interrupt on freeRTOS (#959) 2022-11-22 18:26:19 -08:00
Sylwester 4e6e1d6024 Use PIN_I2S_ defines if they exist in board pin definition. (#991) 2022-11-22 17:42:32 -08:00
Earle F. Philhower, III 0133ecc887 Avoid race conditions in I2C(Wire) callbacks (#995)
Fixes #979

Make sure to read the last byte of I2C data in the case where the IRQ happens
and the STOP signal is also asserted.

Also ensure all branches of the IRQ handler look at the same point in time
value for the IRQ status.
2022-11-22 17:14:44 -08:00
Paint Your Dragonandlady ada 913dfad1ad Add Adafruit Feather RP2040 SCORPIO (#987)
* add rough for scorpio

* Add SCORPIO items from ladyada

* Change PID in makeboards.py instead of boards.txt

* Fix PID in scorpio JSON

* README: Add Feather SCORPIO to supported boards

* Fix PIDs using values from MBAdafruitBoards

Still unsure about pid.[1-7] but let's see what happens

* boards.txt fixed by running makeboards.py

Co-authored-by: lady ada <limor@ladyada.net>
2022-11-22 16:56:48 -08:00
Earle F. Philhower, III 2062f94adc Update README.md 2022-11-21 09:01:30 -08:00
Maximilian Gerhardt f9db547cf3 Do not require USB init variable for TinyUSB (#981) 2022-11-21 09:00:41 -08:00
Maximilian Gerhardt 2782dd1716 Add Waveshare RP2040 Zero (#980) 2022-11-21 08:52:00 -08:00
Sylwester 852219caf5 Add DatanoiseTV PicoADK board (#964) 2022-11-08 16:18:03 -08:00
Earle F. Philhower, III 07fbed06c6 Fix Arduino Nano Connect USB VID:PID tuples (#970)
Fixes #968
2022-11-08 08:59:21 -08:00
Earle F. Philhower, III ea5f8241e3 Remove stdio.h include from CYW43 SDK override (#965) 2022-11-07 08:48:54 -08:00
Earle F. Philhower, III 895ffced8e Fix analogWrite scaling issues (#962)
The PWM internals on the RP2040 are based on 8 slices with independent
clocking.  Make sure that we init the PWM slice being used only once per
change of frequency/range.

Only init the scaling values one time, because we also adjust the input
scale/frequency values when calculating them.  If we ran this twice (i.e.
writing to two slices), it would overwrite the pseudo scale/slow scale
values with 1 causing the wrong PWM values to be set.

Fixes #955
2022-11-07 06:43:14 -08:00
Earle F. Philhower, III 40855c90fb Update version 2022-11-03 08:54:31 -07:00
Earle F. Philhower, III 6570c4856b Fix deadlock in attachInterruptParam (#953)
Thanks to @imwoo90 comment in https://github.com/earlephilhower/arduino-pico/issues/878#issuecomment-1302276196
2022-11-03 08:40:57 -07:00
风飘雨 008c4d62ef Fix SerialPIO bit length, update flyboard2040 pins (#950) 2022-11-03 08:35:40 -07:00
Earle F. Philhower, III 63dfd9ab6b Properly disable Ethernet IRQ, don't drop packets (#951)
Fix #944
2022-11-02 15:27:02 -07:00
Earle F. Philhower, III 9b28fc3e17 Free PIO SM on SerialPIO::end (#949)
Fixes #945
2022-10-31 17:10:59 -07:00
Drzony 6bbaf64daf Async scan + bugfixes (#947)
* Support asynchronous WiFi scan

* Fixed buffer overflow in getChipId

* ESP compatibility fixes

* fixup! ESP compatibility fixes
2022-10-31 17:01:10 -07:00
AngeloGioacchino Del Regno 44eeebbc6f cores/rp2040: _freertos.cpp: Avoid memory leak and unnecessary allocation (#948)
There's a memory leak around the corner: creating the mutex means
that we allocate memory for it, but if we cannot find any free slot in the
FMMap array, we're simply returning a nullptr without ever freeing the
previously allocated memory.

Instead of allocating it out of the free-slot check, do it inside.
While at it, also check if the mutex creation succeeded before assigning
it to a FMMap slot.
2022-10-31 14:29:00 -07:00
Earle F. Philhower, III ec7631096b Update GH actions to non-deprecated versions (#938) 2022-10-27 14:35:52 -07:00
Earle F. Philhower, III 07a1484d72 Add WiFi.channel() reporting (#937)
Also return error conditions when WiFi status is inquired while not
connected.
2022-10-27 13:02:09 -07:00
Earle F. Philhower, III 9503620525 Add WiFi.BSSID() undocumented call (#936)
Using same method as #934 and Infineon wifi-host-driver sources
2022-10-27 09:09:48 -07:00
mecparts e05a3b8ad0 Add a way to return the RSSI value (#934)
See https://forums.raspberrypi.com/viewtopic.php?t=341774
2022-10-27 08:00:59 -07:00
71 changed files with 6636 additions and 194 deletions
+19 -25
View File
@@ -6,6 +6,10 @@ name: Arduino-Pico CI
on:
pull_request:
env:
TRAVIS_BUILD_DIR: ${{ github.workspace }}
TRAVIS_TAG: ${{ github.ref }}
jobs:
@@ -20,7 +24,7 @@ jobs:
- name: Run codespell
uses: codespell-project/actions-codespell@master
with:
skip: ./ArduinoCore-API,./libraries/ESP8266SdFat,./libraries/Adafruit_TinyUSB_Arduino,./libraries/LittleFS/lib,./tools/pyserial,./pico-sdk,./.github,./docs/i2s.rst,./cores/rp2040/api,./libraries/FreeRTOS,./tools/libbearssl/bearssl,./include,./libraries/WiFi/examples/BearSSL_Server,./ota/uzlib,./libraries/http-parser/lib,./libraries/WebServer/examples/HelloServerBearSSL/HelloServerBearSSL.ino,./libraries/HTTPUpdateServer/examples/SecureBearSSLUpdater/SecureBearSSLUpdater.ino
skip: ./ArduinoCore-API,./libraries/ESP8266SdFat,./libraries/Adafruit_TinyUSB_Arduino,./libraries/LittleFS/lib,./tools/pyserial,./pico-sdk,./.github,./docs/i2s.rst,./cores/rp2040/api,./libraries/FreeRTOS,./tools/libbearssl/bearssl,./include,./libraries/WiFi/examples/BearSSL_Server,./ota/uzlib,./libraries/http-parser/lib,./libraries/WebServer/examples/HelloServerBearSSL/HelloServerBearSSL.ino,./libraries/HTTPUpdateServer/examples/SecureBearSSLUpdater/SecureBearSSLUpdater.ino,./.git
ignore_words_list: ser,dout
# Consistent style
@@ -46,10 +50,6 @@ jobs:
./tests/restyle.sh
# If anything changed, GIT should return an error and fail the test
git diff --exit-code
# - name: Check Arduino API copy is clean
# run: |
# git submodule update --init ./ArduinoCore-API
# diff -r ./cores/rp2040/api ./ArduinoCore-API/api
# Build all examples on linux (core and Arduino IDE)
build-linux:
@@ -62,19 +62,17 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Cache Linux toolchain
id: cache-linux
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ./tools/dist
key: ${{ runner.os }}-${{ hashFiles('package/package_pico_index.template.json', 'tests/common.sh') }}
- name: Build Sketches
env:
TRAVIS_BUILD_DIR: ${{ github.workspace }}
TRAVIS_TAG: ${{ github.ref }}
BUILD_PARITY: custom
mod: 6
rem: ${{ matrix.chunk }}
@@ -92,19 +90,17 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Cache Linux toolchain
id: cache-linux
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ./tools/dist
key: ${{ runner.os }}-${{ hashFiles('package/package_pico_index.template.json', 'tests/common.sh') }}
- name: Build Sketches
env:
TRAVIS_BUILD_DIR: ${{ github.workspace }}
TRAVIS_TAG: ${{ github.ref }}
BUILD_PARITY: custom
run: |
cd pico-sdk
@@ -120,19 +116,17 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Cache Windows toolchain
id: cache-windows
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ./tools/dist
key: ${{ runner.os }}-${{ hashFiles('package/package_pico_index.template.json', 'tests/common.sh') }}
- name: Build Sketch
env:
TRAVIS_BUILD_DIR: ${{ github.workspace }}
TRAVIS_TAG: ${{ github.ref }}
WINDOWS: 1
BUILD_PARITY: custom
mod: 500
@@ -150,24 +144,22 @@ jobs:
# Single build under macOS to ensure the Mac toolchain is good.
build-mac:
name: Mac
runs-on: macOS-latest
runs-on: macOS-12
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Cache Mac toolchain
id: cache-mac
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ./tools/dist
key: ${{ runner.os }}-${{ hashFiles('package/package_pico_index.template.json', 'tests/common.sh') }}
- name: Build Sketch
env:
TRAVIS_BUILD_DIR: ${{ github.workspace }}
TRAVIS_TAG: ${{ github.ref }}
MACOSX: 1
BUILD_PARITY: custom
mod: 500
@@ -194,19 +186,21 @@ jobs:
git submodule update --init
cd ../..
- name: Cache pip
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache PlatformIO
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.platformio
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
+4 -4
View File
@@ -9,22 +9,22 @@ jobs:
name: Update master JSON file
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: true
- name: Cache pip
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache PlatformIO
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.platformio
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install PlatformIO
+2 -2
View File
@@ -15,11 +15,11 @@ jobs:
name: Package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0
- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Build package JSON
+7
View File
@@ -13,6 +13,7 @@ See https://arduino-pico.readthedocs.io/en/latest/ along with the examples for m
* Raspberry Pi Pico
* Raspberry Pi Pico W
* Adafruit Feather RP2040
* Adafruit Feather RP2040 SCORPIO
* Adafruit ItsyBitsy RP2040
* Adafruit KB2040
* Adafruit Macropad RP2040
@@ -23,6 +24,7 @@ See https://arduino-pico.readthedocs.io/en/latest/ along with the examples for m
* BridgeTek IDM2040-7A
* Cytron Maker Pi RP2040
* Cytron Maker Nano RP2040
* DatanoiseTV PicoADK+
* Degz Mizu
* DeRuiLab FlyBoard2040 Core
* DFRobot Beetle RP2040
@@ -44,6 +46,11 @@ See https://arduino-pico.readthedocs.io/en/latest/ along with the examples for m
* SparkFun ProMicro RP2040
* SparkFun Thing Plus RP2040
* uPesy RP2040 DevKit
* Waveshare RP2040 Zero
* Waveshare RP2040 One
* Waveshare RP2040 Plus
* Waveshare RP2040 LCD 0.96
* Waveshare RP2040 LCD 1.28
* WIZnet W5100S-EVB-Pico
* WIZnet W5500-EVB-Pico
* WIZnet WizFi360-EVB-Pico
+4543 -21
View File
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,23 @@
// Padded and checksummed version of: generated\Winbond\W25Q16JVxQ\boot2.bin
.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
+13 -4
View File
@@ -24,17 +24,22 @@
#include "Arduino.h"
#include "CoreMutex.h"
CoreMutex::CoreMutex(mutex_t *mutex, bool debugEnable) {
CoreMutex::CoreMutex(mutex_t *mutex, uint8_t option) {
_mutex = mutex;
_acquired = false;
_option = option;
if (__isFreeRTOS) {
auto m = __get_freertos_mutex_for_ptr(mutex);
__freertos_mutex_take(m);
if (_option & FromISR) {
__freertos_mutex_take_from_isr(m);
} else {
__freertos_mutex_take(m);
}
} else {
uint32_t owner;
if (!mutex_try_enter(_mutex, &owner)) {
if (owner == get_core_num()) { // Deadlock!
if (debugEnable) {
if (_option & DebugEnable) {
DEBUGCORE("CoreMutex - Deadlock detected!\n");
}
return;
@@ -49,7 +54,11 @@ CoreMutex::~CoreMutex() {
if (_acquired) {
if (__isFreeRTOS) {
auto m = __get_freertos_mutex_for_ptr(_mutex);
__freertos_mutex_give(m);
if (_option & FromISR) {
__freertos_mutex_give_from_isr(m);
} else {
__freertos_mutex_give(m);
}
} else {
mutex_exit(_mutex);
}
+7 -1
View File
@@ -26,9 +26,14 @@
#include "pico/mutex.h"
#include "_freertos.h"
enum {
DebugEnable = 1,
FromISR = 1 << 1,
};
class CoreMutex {
public:
CoreMutex(mutex_t *mutex, bool debugEnable = true);
CoreMutex(mutex_t *mutex, uint8_t option = DebugEnable);
~CoreMutex();
operator bool() {
@@ -38,4 +43,5 @@ public:
private:
mutex_t *_mutex;
bool _acquired;
u_int8_t _option;
};
+6 -7
View File
@@ -192,13 +192,12 @@ File File::openNextFile() {
String File::readString() {
String ret;
ret.reserve(size() - position());
char temp[256 + 1];
int countRead = readBytes(temp, sizeof(temp) - 1);
while (countRead > 0) {
temp[countRead] = 0;
ret += temp;
countRead = readBytes(temp, sizeof(temp) - 1);
}
uint8_t temp[256];
int countRead;
do {
countRead = read(temp, sizeof(temp));
ret.concat(temp, countRead);
} while (countRead > 0);
return ret;
}
+1 -1
View File
@@ -325,7 +325,7 @@ public:
}
const char *getChipID() {
static char id[PICO_UNIQUE_BOARD_ID_SIZE_BYTES + 1] = { 0 };
static char id[2 * PICO_UNIQUE_BOARD_ID_SIZE_BYTES + 1] = { 0 };
if (!id[0]) {
pico_get_unique_board_id_string(id, sizeof(id));
}
+69 -4
View File
@@ -68,9 +68,11 @@ static int __usb_task_irq;
#define USBD_STR_SERIAL (0x03)
#define USBD_STR_CDC (0x04)
#define EPNUM_HID 0x83
#define USBD_MSC_EPOUT 0x03
#define USBD_MSC_EPIN 0x84
#define USBD_MSC_EPSIZE 64
const uint8_t *tud_descriptor_device_cb(void) {
static tusb_desc_device_t usbd_desc_device = {
@@ -89,7 +91,7 @@ const uint8_t *tud_descriptor_device_cb(void) {
.iSerialNumber = USBD_STR_SERIAL,
.bNumConfigurations = 1
};
if (__USBInstallSerial && !__USBInstallKeyboard && !__USBInstallMouse && !__USBInstallJoystick) {
if (__USBInstallSerial && !__USBInstallKeyboard && !__USBInstallMouse && !__USBInstallJoystick && !__USBInstallMassStorage) {
// Can use as-is, this is the default USB case
return (const uint8_t *)&usbd_desc_device;
}
@@ -103,6 +105,9 @@ const uint8_t *tud_descriptor_device_cb(void) {
if (__USBInstallJoystick) {
usbd_desc_device.idProduct |= 0x0100;
}
if (__USBInstallMassStorage) {
usbd_desc_device.idProduct ^= 0x2000;
}
// Set the device class to 0 to indicate multiple device classes
usbd_desc_device.bDeviceClass = 0;
usbd_desc_device.bDeviceSubClass = 0;
@@ -223,7 +228,7 @@ void __SetupUSBDescriptor() {
if (!usbd_desc_cfg) {
bool hasHID = __USBInstallKeyboard || __USBInstallMouse || __USBInstallJoystick;
uint8_t interface_count = (__USBInstallSerial ? 2 : 0) + (hasHID ? 1 : 0);
uint8_t interface_count = (__USBInstallSerial ? 2 : 0) + (hasHID ? 1 : 0) + (__USBInstallMassStorage ? 1 : 0);
uint8_t cdc_desc[TUD_CDC_DESC_LEN] = {
// Interface number, string index, protocol, report descriptor len, EP In & Out address, size & polling interval
@@ -238,7 +243,12 @@ void __SetupUSBDescriptor() {
TUD_HID_DESCRIPTOR(hid_itf, 0, HID_ITF_PROTOCOL_NONE, hid_report_len, EPNUM_HID, CFG_TUD_HID_EP_BUFSIZE, 10)
};
int usbd_desc_len = TUD_CONFIG_DESC_LEN + (__USBInstallSerial ? sizeof(cdc_desc) : 0) + (hasHID ? sizeof(hid_desc) : 0);
uint8_t msd_itf = interface_count - 1;
uint8_t msd_desc[TUD_MSC_DESC_LEN] = {
TUD_MSC_DESCRIPTOR(msd_itf, 0, USBD_MSC_EPOUT, USBD_MSC_EPIN, USBD_MSC_EPSIZE)
};
int usbd_desc_len = TUD_CONFIG_DESC_LEN + (__USBInstallSerial ? sizeof(cdc_desc) : 0) + (hasHID ? sizeof(hid_desc) : 0) + (__USBInstallMassStorage ? sizeof(msd_desc) : 0);
uint8_t tud_cfg_desc[TUD_CONFIG_DESC_LEN] = {
// Config number, interface count, string index, total length, attribute, power in mA
@@ -260,6 +270,10 @@ void __SetupUSBDescriptor() {
memcpy(ptr, hid_desc, sizeof(hid_desc));
ptr += sizeof(hid_desc);
}
if (__USBInstallMassStorage) {
memcpy(ptr, msd_desc, sizeof(msd_desc));
ptr += sizeof(msd_desc);
}
}
}
}
@@ -367,4 +381,55 @@ extern "C" void tud_hid_set_report_cb(uint8_t instance, uint8_t report_id, hid_r
(void) bufsize;
}
extern "C" int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize) __attribute__((weak));
extern "C" int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize) {
(void) lun;
(void) lba;
(void) offset;
(void) buffer;
(void) bufsize;
return -1;
}
extern "C" bool tud_msc_test_unit_ready_cb(uint8_t lun) __attribute__((weak));
extern "C" bool tud_msc_test_unit_ready_cb(uint8_t lun) {
(void) lun;
return false;
}
extern "C" int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t* buffer, uint32_t bufsize) __attribute__((weak));
extern "C" int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t* buffer, uint32_t bufsize) {
(void) lun;
(void) lba;
(void) offset;
(void) buffer;
(void) bufsize;
return -1;
}
extern "C" int32_t tud_msc_scsi_cb(uint8_t lun, uint8_t const scsi_cmd[16], void* buffer, uint16_t bufsize) __attribute__((weak));
extern "C" int32_t tud_msc_scsi_cb(uint8_t lun, uint8_t const scsi_cmd[16], void* buffer, uint16_t bufsize) {
(void) lun;
(void) scsi_cmd;
(void) buffer;
(void) bufsize;
return 0;
}
extern "C" void tud_msc_capacity_cb(uint8_t lun, uint32_t* block_count, uint16_t* block_size) __attribute__((weak));
extern "C" void tud_msc_capacity_cb(uint8_t lun, uint32_t* block_count, uint16_t* block_size) {
(void) lun;
*block_count = 0;
*block_size = 0;
}
extern "C" void tud_msc_inquiry_cb(uint8_t lun, uint8_t vendor_id[8], uint8_t product_id[16], uint8_t product_rev[4]) __attribute__((weak));
extern "C" void tud_msc_inquiry_cb(uint8_t lun, uint8_t vendor_id[8], uint8_t product_id[16], uint8_t product_rev[4]) {
(void) lun;
vendor_id[0] = 0;
product_id[0] = 0;
product_rev[0] = 0;
}
#endif
+1
View File
@@ -26,6 +26,7 @@ extern void __USBInstallSerial() __attribute__((weak));
extern void __USBInstallKeyboard() __attribute__((weak));
extern void __USBInstallJoystick() __attribute__((weak));
extern void __USBInstallMouse() __attribute__((weak));
extern void __USBInstallMassStorage() __attribute__((weak));
// Big, global USB mutex, shared with all USB devices to make sure we don't
// have multiple cores updating the TUSB state in parallel
+2 -2
View File
@@ -1,5 +1,5 @@
#pragma once
#define ARDUINO_PICO_MAJOR 2
#define ARDUINO_PICO_MINOR 6
#define ARDUINO_PICO_REVISION 2
#define ARDUINO_PICO_VERSION_STR "2.6.2"
#define ARDUINO_PICO_REVISION 5
#define ARDUINO_PICO_VERSION_STR "2.6.5"
+3 -1
View File
@@ -230,7 +230,7 @@ void SerialPIO::begin(unsigned long baud, uint16_t config) {
pio_sm_clear_fifos(_rxPIO, _rxSM); // Remove any existing data
// Put phase divider into OSR w/o using add'l program memory
pio_sm_put_blocking(_rxPIO, _rxSM, clock_get_hz(clk_sys) / (_baud * 2) - 5 /* insns in PIO halfbit loop */);
pio_sm_put_blocking(_rxPIO, _rxSM, clock_get_hz(clk_sys) / (_baud * 2) - 7 /* insns in PIO halfbit loop */);
pio_sm_exec(_rxPIO, _rxSM, pio_encode_pull(false, false));
// Join the TX FIFO to the RX one now that we don't need it
@@ -259,9 +259,11 @@ void SerialPIO::end() {
}
if (_tx != NOPIN) {
pio_sm_set_enabled(_txPIO, _txSM, false);
pio_sm_unclaim(_txPIO, _txSM);
}
if (_rx != NOPIN) {
pio_sm_set_enabled(_rxPIO, _rxSM, false);
pio_sm_unclaim(_rxPIO, _rxSM);
_pioSP[pio_get_index(_rxPIO)][_rxSM] = nullptr;
// If no more active, disable the IRQ
auto pioNum = pio_get_index(_rxPIO);
+6 -1
View File
@@ -390,7 +390,12 @@ void __not_in_flash_func(SerialUART::_handleIRQ)(bool inIRQ) {
// ICR is write-to-clear
uart_get_hw(_uart)->icr = UART_UARTICR_RTIC_BITS | UART_UARTICR_RXIC_BITS;
while (uart_is_readable(_uart)) {
auto val = uart_getc(_uart);
uint32_t raw = uart_get_hw(_uart)->dr;
if (raw & 0x700) {
// Framing, Parity, or Break. Ignore this bad char
continue;
}
uint8_t val = raw & 0xff;
auto next_writer = _writer + 1;
if (next_writer == _fifoSize) {
next_writer = 0;
+7 -2
View File
@@ -38,10 +38,15 @@ extern "C" SemaphoreHandle_t __get_freertos_mutex_for_ptr(mutex_t *m) {
return _map[i].dst;
}
}
// Make a new mutex
auto fm = __freertos_mutex_create();
for (int i = 0; i < 16; i++) {
if (_map[i].src == nullptr) {
// Make a new mutex
SemaphoreHandle_t fm = __freertos_mutex_create();
if (fm == nullptr) {
return nullptr;
}
_map[i].src = m;
_map[i].dst = fm;
return fm;
+2
View File
@@ -41,8 +41,10 @@ extern "C" {
extern SemaphoreHandle_t _freertos_recursive_mutex_create() __attribute__((weak));
extern void __freertos_mutex_take(SemaphoreHandle_t mtx) __attribute__((weak));
extern void __freertos_mutex_take_from_isr(SemaphoreHandle_t mtx) __attribute__((weak));
extern int __freertos_mutex_try_take(SemaphoreHandle_t mtx) __attribute__((weak));
extern void __freertos_mutex_give(SemaphoreHandle_t mtx) __attribute__((weak));
extern void __freertos_mutex_give_from_isr(SemaphoreHandle_t mtx) __attribute__((weak));
extern void __freertos_recursive_mutex_take(SemaphoreHandle_t mtx) __attribute__((weak));
extern int __freertos_recursive_mutex_try_take(SemaphoreHandle_t mtx) __attribute__((weak));
-2
View File
@@ -125,7 +125,6 @@ extern "C" int main() {
}
#endif
#ifndef NO_USB
if (!__isFreeRTOS) {
if (setup1 || loop1) {
rp2040.fifo.begin(2);
@@ -134,7 +133,6 @@ extern "C" int main() {
}
rp2040.fifo.registerCore();
}
#endif
if (!__isFreeRTOS) {
if (setup1 || loop1) {
@@ -6,7 +6,7 @@
// Taken from the Pico-SDK v1.4.0 and hacked by EFP3 to allow overriding the LWIP setup
#include <stdio.h>
//#include <stdio.h>
#include "pico/cyw43_arch.h"
#include "pico/mutex.h"
@@ -145,7 +145,7 @@ static void gpio_irq_handler(void) {
static void low_priority_irq_handler(void) {
assert(cyw43_core_num == get_core_num());
if (recursive_mutex_try_enter(&cyw43_mutex, NULL)) {
if (recursive_mutex_enter_count(&cyw43_mutex) != 1) {
if (__inLWIP || (recursive_mutex_enter_count(&cyw43_mutex) != 1)) {
low_priority_irq_missed = true;
CYW43_STAT_INC(PENDSV_DISABLED_COUNT);
} else {
+8 -2
View File
@@ -29,6 +29,7 @@
static uint32_t analogScale = 255;
static uint32_t analogFreq = 1000;
static uint32_t pwmInitted = 0;
static bool scaleInitted = false;
static bool adcInitted = false;
static uint16_t analogWritePseudoScale = 1;
static uint16_t analogWriteSlowScale = 1;
@@ -49,6 +50,7 @@ extern "C" void analogWriteFreq(uint32_t freq) {
analogFreq = freq;
}
pwmInitted = 0;
scaleInitted = false;
}
extern "C" void analogWriteRange(uint32_t range) {
@@ -58,6 +60,7 @@ extern "C" void analogWriteRange(uint32_t range) {
if ((range >= 3) && (range <= 65535)) {
analogScale = range;
pwmInitted = 0;
scaleInitted = false;
} else {
DEBUGCORE("ERROR: analogWriteRange out of range (%d)\n", range);
}
@@ -78,7 +81,7 @@ extern "C" void analogWrite(pin_size_t pin, int val) {
DEBUGCORE("ERROR: Illegal analogWrite pin (%d)\n", pin);
return;
}
if (!(pwmInitted & (1 << pin))) {
if (!scaleInitted) {
// For low frequencies, we need to scale the output max value up to achieve lower periods
analogWritePseudoScale = 1;
while (((clock_get_hz(clk_sys) / ((float)analogScale * analogFreq)) > 255.0) && (analogScale < 32678)) {
@@ -93,11 +96,14 @@ extern "C" void analogWrite(pin_size_t pin, int val) {
analogScale /= 2;
DEBUGCORE("Adjusting analogWrite values SS=%d, scale=%d\n", analogWriteSlowScale, analogScale);
}
scaleInitted = true;
}
if (!(pwmInitted & (1 << pwm_gpio_to_slice_num(pin)))) {
pwm_config c = pwm_get_default_config();
pwm_config_set_clkdiv(&c, clock_get_hz(clk_sys) / ((float)analogScale * analogFreq));
pwm_config_set_wrap(&c, analogScale - 1);
pwm_init(pwm_gpio_to_slice_num(pin), &c, true);
pwmInitted |= 1 << pin;
pwmInitted |= 1 << pwm_gpio_to_slice_num(pin);
}
val <<= analogWritePseudoScale;
+2 -2
View File
@@ -77,7 +77,7 @@ static std::map<pin_size_t, CBInfo> _map;
void _gpioInterruptDispatcher(uint gpio, uint32_t events) {
(void) events;
// Only need to lock around the std::map check, not the whole IRQ callback
CoreMutex m(&_irqMutex);
CoreMutex m(&_irqMutex, (FromISR | DebugEnable));
if (m) {
auto irq = _map.find(gpio);
if (irq != _map.end()) {
@@ -135,7 +135,7 @@ void attachInterruptParam(pin_size_t pin, voidFuncPtrParam callback, PinStatus m
default: return; // ERROR
}
noInterrupts();
detachInterrupt(pin);
_detachInterruptInternal(pin);
CBInfo cb(callback, param);
_map.insert({pin, cb});
gpio_set_irq_enabled_with_callback(pin, events, true, _gpioInterruptDispatcher);
+2 -2
View File
@@ -54,9 +54,9 @@ author = u'Earle F. Philhower, III'
# built documents.
#
# The short X.Y version.
version = u'2.6.2'
version = u'2.6.5'
# The full version, including alpha/beta/rc tags.
release = u'2.6.2'
release = u'2.6.5'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
+2
View File
@@ -39,6 +39,8 @@ For the latest version, always check https://github.com/earlephilhower/arduino-p
USB (Arduino and Adafruit_TinyUSB) <usb>
Multicore Processing <multicore>
Single File USB Drive <singlefile>
FreeRTOS SMP (multicore) <freertos>
WiFi (Pico-W Support) <wifi>
+2 -2
View File
@@ -38,12 +38,12 @@ void rp2040.reboot()
Forces a hardware reboot of the Pico.
Hardware Watchdog
_________________
-----------------
void rp2040.wdt_begin(uint32_t delay_ms)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enables the hardware watchdog timer with a delay value of delay_ms
microseconds. Note that on the RP2040, once this function has called, the
milliseconds. Note that on the RP2040, once this function has called, the
hardware watchdog can _not_ be disabled.
void rp2040.wdt_reset()
+82
View File
@@ -0,0 +1,82 @@
SingleFileDrive
===============
USB drive mode is supported through the ``SingleFileDrive`` class which
allows the Pico to emulate a FAT-formatted USB stick while preserving the
onboard LittleFS filesystem. A single file can be exported this way without
needing to use FAT as the onboard filesystem (FAT is not appropriate for
flash-based devices without complicated wear leveling because of the update
frequency of the FAT tables).
This emulation is very simple and only allows for the reading of the single
file, and deleting it.
Callbacks, Interrupt Safety, and File Operations
------------------------------------------------
The ``SingleFileDrive`` library allows your application to get a callback
when a PC attempts to mount or unmount the Pico as a drive. Your app can
also get a callback if the user attempts to delete the file (but your
sketch does not actually need to delete the file, it's up to you).
Note that when the USB drive is mounted by a PC it is not safe for your
main sketch to make changes to the LittleFS filesystem or the file being
exported. So, normally, your ``onPlug`` callback will set a flag letting
your application know not to touch the filesystem, with the ``onUnplug``
callback clearing this flag.
Also, because the USB port can be connected at any time, it is important
to disable interrupts using ``noInterrupts()`` before writing to a file
you will be exporting (and restoring them with ``interrupts()`` afterwards).
It is also important to ``close()`` the file after each update, or the
on-flash version the ``SingleFileDrive`` will attempt to export may not be
up to date causing issues later on.
See the included ``DataLoggerUSB`` sketch for an example of working with
these limitations.
Using SingleFileDrive
---------------------
Implementing the drive requires including the header file, starting LittleFS,
defining your callbacks, and telling the library what file to export. No
polling or other calls are required outside of your ``setup()``. (Note that
the callback routines allow for a parameter to be passed to them, but in most
cases this can be safely ignored.)
.. code:: cpp
#include <LittleFS.h>
#include <SingleFileDrive.h>
void myPlugCB(uint32_t data) {
// Tell my app not to write to flash, we're connected
}
void myUnplugCB(uint32_t data) {
// I can start writing to flash again
}
void myDeleteDB(uint32_t data) {
// Maybe LittleFS.remove("myfile.txt")? or do nothing
}
void setup() {
LittleFS.begin();
singleFileDrive.onPlug(myPlugCB);
singleFileDrive.onUnplug(myUnplugCB);
singleFileDrive.onDelete(myDeleteCB);
singleFileDrive.begin("littlefsfile.csv", "Data Recorder.csv");
// ... rest of setup ...
}
void loop() {
// Take some measurements, delay, etc.
if (okay-to-write) {
noInterrupts();
File f = LittleFS.open("littlefsfile.csv", "a");
f.printf("%d,%d,%d\n", data1, data2, data3);
f.close();
interrupts();
}
}
-2
View File
@@ -40,8 +40,6 @@ Please note that WiFi on the Pico W is a work-in-progress and there are some imp
* Combined STA/AP mode is not supported
* Certain WiFi status values (RSSI, BSSID, etc.) are not available.
* Multicore is supported, but only one core may run ``WiFi`` code.
* FreeRTOS is not yet supported due to the requirement for a very different LWIP implementation. PRs always appreciated!
+2 -3
View File
@@ -72,15 +72,14 @@
//------------- CLASS -------------//
#define CFG_TUD_HID (2)
#define CFG_TUD_CDC (1)
#define CFG_TUD_MSC (0)
#define CFG_TUD_MSC (1)
#define CFG_TUD_MIDI (0)
#define CFG_TUD_VENDOR (0)
#define CFG_TUD_CDC_RX_BUFSIZE (256)
#define CFG_TUD_CDC_TX_BUFSIZE (256)
#define CFG_TUD_MIDI_RX_BUFSIZE (64)
#define CFG_TUD_MIDI_TX_BUFSIZE (64)
#define CFG_TUD_MSC_EP_BUFSIZE (64)
// HID buffer size Should be sufficient to hold ID (if any) + Data
#define CFG_TUD_HID_EP_BUFSIZE (64)
Binary file not shown.
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -110,7 +110,7 @@ void ArduinoOTAClass::begin(bool useMDNS) {
_useMDNS = useMDNS;
if (!_hostname.length()) {
char tmp[15];
char tmp[2 * PICO_UNIQUE_BOARD_ID_SIZE_BYTES + 6];
sprintf(tmp, "pico-%s", rp2040.getChipID());
_hostname = tmp;
}
+3 -1
View File
@@ -45,7 +45,7 @@ void EEPROMClass::begin(size_t size) {
size = 4096;
}
_size = (size + 255) & (~255); // Flash writes limited to 256 byte boundaries
size = (size + 255) & (~255); // Flash writes limited to 256 byte boundaries
// In case begin() is called a 2nd+ time, don't reallocate if size is the same
if (_data && size != _size) {
@@ -55,6 +55,8 @@ void EEPROMClass::begin(size_t size) {
_data = new uint8_t[size];
}
_size = size;
memcpy(_data, _sector, _size);
_dirty = false; //make sure dirty is cleared in case begin() is called 2nd+ time
+10 -2
View File
@@ -59,7 +59,7 @@ volatile bool __usbInitted = false;
static void __core0(void *params) {
(void) params;
#ifndef NO_USB
#if !defined(NO_USB) && !defined(USE_TINYUSB)
while (!__usbInitted) {
delay(1);
}
@@ -81,7 +81,7 @@ static void __core0(void *params) {
static void __core1(void *params) {
(void) params;
#ifndef NO_USB
#if !defined(NO_USB) && !defined(USE_TINYUSB)
while (!__usbInitted) {
delay(1);
}
@@ -414,6 +414,10 @@ extern "C" {
xSemaphoreTake(mtx, portMAX_DELAY);
}
void __freertos_mutex_take_from_isr(SemaphoreHandle_t mtx) {
xSemaphoreTakeFromISR(mtx, NULL);
}
int __freertos_mutex_try_take(SemaphoreHandle_t mtx) {
return xSemaphoreTake(mtx, 0);
}
@@ -422,6 +426,10 @@ extern "C" {
xSemaphoreGive(mtx);
}
void __freertos_mutex_give_from_isr(SemaphoreHandle_t mtx) {
xSemaphoreGiveFromISR(mtx, NULL);
}
void __freertos_recursive_mutex_take(SemaphoreHandle_t mtx) {
xSemaphoreTakeRecursive(mtx, portMAX_DELAY);
}
+4 -1
View File
@@ -215,7 +215,10 @@ int AudioRingBuffer::available() {
}
int avail;
avail = _wordsPerBuffer - _userOff;
avail += ((_bufferCount + _curBuffer - _userBuffer) % _bufferCount) * _wordsPerBuffer;
avail += ((_bufferCount + _curBuffer - _userBuffer) % _bufferCount) * _wordsPerBuffer /* total other buffers */ - _wordsPerBuffer /* minus the one currently being output */;
if (avail < 0) {
avail = 0; // Should never hit
}
return avail;
}
+16 -1
View File
@@ -27,11 +27,26 @@ I2S::I2S(PinMode direction) {
_running = false;
_bps = 16;
_writtenHalf = false;
_isOutput = direction == OUTPUT;
_pinBCLK = 26;
_pinDOUT = 28;
#ifdef PIN_I2S_BCLK
_pinBCLK = PIN_I2S_BCLK;
#endif
#ifdef PIN_I2S_DOUT
if (_isOutput) {
_pinDOUT = PIN_I2S_DOUT;
}
#endif
#ifdef PIN_I2S_DIN
if (!_isOutput) {
_pinDOUT = PIN_I2S_DIN;
}
#endif
_freq = 48000;
_arb = nullptr;
_isOutput = direction == OUTPUT;
_cb = nullptr;
_buffers = 8;
_bufferWords = 16;
+1 -1
View File
@@ -5,6 +5,6 @@ maintainer=Earle F. Philhower, III <earlephilhower@yahoo.com>
sentence=Configures requests for OTA bootloader
paragraph=Example repository for Ethernet drivers
category=Device Control
url=https://github.com/earlephilhower.arduino-pico
url=https://github.com/earlephilhower/arduino-pico
architectures=rp2040
dot_a_linkage=true
@@ -0,0 +1,92 @@
// Simple logger with USB upload to PC
// Uses SingleFileDrive to export an onboard LittleFS file to the computer
// The PC can open/copy the file, and then the user can delete it to restart
// Released to the public domain, 2022 - Earle F. Philhower, III
#include <SingleFileDrive.h>
#include <LittleFS.h>
uint32_t cnt = 0;
bool okayToWrite = true;
// Make the CSV file and give it a simple header
void headerCSV() {
File f = LittleFS.open("data.csv", "w");
f.printf("sample,millis,temp,rand\n");
f.close();
cnt = 0;
}
// Called when the USB stick connected to a PC and the drive opened
// Note this is from a USB IRQ so no printing to SerialUSB/etc.
void plug(uint32_t i) {
(void) i;
okayToWrite = false;
}
// Called when the USB is ejected or removed from a PC
// Note this is from a USB IRQ so no printing to SerialUSB/etc.
void unplug(uint32_t i) {
(void) i;
okayToWrite = true;
}
// Called when the PC tries to delete the single file
// Note this is from a USB IRQ so no printing to SerialUSB/etc.
void deleteCSV(uint32_t i) {
(void) i;
LittleFS.remove("data.csv");
headerCSV();
}
void setup() {
Serial.begin();
delay(5000);
LittleFS.begin();
// Set up the USB disk share
singleFileDrive.onDelete(deleteCSV);
singleFileDrive.onPlug(plug);
singleFileDrive.onUnplug(unplug);
singleFileDrive.begin("data.csv", "Recorded data from the Raspberry Pi Pico.csv");
// Find the last written data
File f = LittleFS.open("data.csv", "r");
if (!f || !f.size()) {
cnt = 1;
headerCSV();
} else {
if (f.size() > 2048) {
f.seek(f.size() - 1024);
}
do {
String s = f.readStringUntil('\n');
sscanf(s.c_str(), "%lu,", &cnt);
} while (f.available());
f.close();
cnt++;
}
Serial.printf("Starting acquisition at %d\n", cnt);
}
void loop() {
float temp = analogReadTemp();
uint32_t hwrand = rp2040.hwrand32();
// Make sure the USB connect doesn't happen while we're writing!
noInterrupts();
if (okayToWrite) {
Serial.printf("Sampling...%lu\n", cnt);
// Don't want the USB to connect during an update!
File f = LittleFS.open("data.csv", "a");
if (f) {
f.printf("%lu,%lu,%f,%lu\n", cnt++, millis(), temp, hwrand);
f.close();
}
}
interrupts();
delay(10000);
}
+22
View File
@@ -0,0 +1,22 @@
#######################################
# Syntax Coloring Map
#######################################
#######################################
# Datatypes (KEYWORD1)
#######################################
SingleFileDrive KEYWORD1
#######################################
# Methods and Functions (KEYWORD2)
#######################################
singleFileDrive KEYWORD1
onDelete KEYWORD1
onPlug KEYWORD1
onUnplug KEYWORD1
#######################################
# Constants (LITERAL1)
#######################################
@@ -0,0 +1,10 @@
name=SingleFileDrive
version=1.0.0
author=Earle F. Philhower, III <earlephilhower@yahoo.com>
maintainer=Earle F. Philhower, III <earlephilhower@yahoo.com>
sentence=Allows using USB MSC (USB stick) to transfer an onboard flash file to a PC
paragraph=Emulates a USB stick and presents a single file for users to copy over/erase
category=Device Control
url=https://github.com/earlephilhower/arduino-pico
architectures=rp2040
dot_a_linkage=true
@@ -0,0 +1,396 @@
/*
SingleFileDrive - Emulates a USB stick for easy data transfer
Copyright (c) 2022 Earle F. Philhower, III. All rights reserved.
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 <SingleFileDrive.h>
#include <LittleFS.h>
#include <class/msc/msc.h>
SingleFileDrive singleFileDrive;
static const uint32_t _hddsize = (256 * 1024 * 1024); // 256MB
static const uint32_t _hddsects = _hddsize / 512;
// Ensure we are logged in to the USB framework
void __USBInstallMassStorage() {
/* dummy */
}
SingleFileDrive::SingleFileDrive() {
}
SingleFileDrive::~SingleFileDrive() {
end();
}
void SingleFileDrive::onDelete(void (*cb)(uint32_t), uint32_t cbData) {
_cbDelete = cb;
_cbDeleteData = cbData;
}
void SingleFileDrive::onPlug(void (*cb)(uint32_t), uint32_t cbData) {
_cbPlug = cb;
_cbPlugData = cbData;
}
void SingleFileDrive::onUnplug(void (*cb)(uint32_t), uint32_t cbData) {
_cbUnplug = cb;
_cbUnplugData = cbData;
}
bool SingleFileDrive::begin(const char *localFile, const char *dosFile) {
if (_started) {
return false;
}
_localFile = strdup(localFile);
_dosFile = strdup(dosFile);
_started = true;
return true;
}
void SingleFileDrive::end() {
_started = false;
free(_localFile);
free(_dosFile);
_localFile = nullptr;
_dosFile = nullptr;
}
void SingleFileDrive::bootSector(char buff[512]) {
// 256MB FAT16 stolen from mkfs.fat
// dd if=/dev/zero of=/tmp/fat.bin bs=1M seek=255 count=1
// mkfs.fat -F 16 -r 16 -n PICODISK -i 12345678 -s 128 -m ':(' /tmp/fat.bin
const uint8_t hdr[] = {
0xeb, 0x3c, 0x90, 0x6d, 0x6b, 0x66, 0x73, 0x2e, 0x66, 0x61, 0x74, 0x00,
0x02, 0x80, 0x80, 0x00, 0x02, 0x00, 0x08, 0x00, 0x00, 0xf8, 0x80, 0x00,
0x20, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00,
0x80, 0x00, 0x29, 0x78, 0x56, 0x34, 0x12, 0x50, 0x49, 0x43, 0x4f, 0x44,
0x49, 0x53, 0x4b, 0x20, 0x20, 0x20, 0x46, 0x41, 0x54, 0x31, 0x36, 0x20,
0x20, 0x20, 0x0e, 0x1f, 0xbe, 0x5b, 0x7c, 0xac, 0x22, 0xc0, 0x74, 0x0b,
0x56, 0xb4, 0x0e, 0xbb, 0x07, 0x00, 0xcd, 0x10, 0x5e, 0xeb, 0xf0, 0x32,
0xe4, 0xcd, 0x16, 0xcd, 0x19, 0xeb, 0xfe, 0x3a, 0x28, 0x0d, 0x0a, 0x00
};
memset(buff, 0, 512);
memcpy(buff, hdr, sizeof(hdr));
buff[0x1fe] = 0x55;
buff[0x1ff] = 0xff;
}
static char _toLegalFATChar(char c) {
const char *odds = "!#$%&'()-@^_`{}~";
c = toupper(c);
if (((c >= '0') && (c <= '9')) || ((c >= 'A') && (c <= 'Z')) || strchr(odds, c)) {
return c;
} else {
return '~';
}
}
void SingleFileDrive::directorySector(char buff[512]) {
const uint8_t lbl[] = {
0x50, 0x49, 0x43, 0x4f, 0x44, 0x49, 0x53, 0x4b, 0x20, 0x20, 0x20, 0x08, 0x00, 0x00, 0xac, 0x56,
0x82, 0x55, 0x82, 0x55, 0x00, 0x00, 0xac, 0x56, 0x82, 0x55
}; //, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
memset(buff, 0, 512);
memcpy(buff, lbl, sizeof(lbl));
buff += 32; // Skip the just-set label
// Create a legal 11-char UPPERCASE FILENAME WITH 0x20 PAD
char SFN[11];
memset(SFN, ' ', 11);
for (int i = 0; (i < 8) && _dosFile[i] && (_dosFile[i] != '.'); i++) {
SFN[i] = _toLegalFATChar(_dosFile[i]);
}
char *dot = _dosFile + strlen(_dosFile) - 1;
while ((dot >= _dosFile) && (*dot != '.')) {
dot--;
}
if (*dot == '.') {
dot++;
for (int i = 0; (i < 3) && dot[i]; i++) {
SFN[8 + i] = _toLegalFATChar(dot[i]);
}
}
uint8_t chksum = 0; // for LFN
for (int i = 0; i < 11; i++) {
chksum = (chksum >> 1) + (chksum << 7) + SFN[i];
}
// Create LFN structure
int entries = (strlen(_dosFile) + 12) / 13; // round up
for (int i = 0; i < entries; i++) {
*buff++ = (entries - i) | (i == 0 ? 0x40 : 0);
const char *partname = _dosFile + 13 * (entries - i - 1);
for (int j = 0; j < 13; j++) {
uint16_t u;
if (j > (int)strlen(partname)) {
u = 0xffff;
} else {
u = partname[j] & 0xff;
}
*buff++ = u & 0xff;
*buff++ = (u >> 8) & 0xff;
if (j == 4) {
*buff++ = 0x0f; // LFN ATTR
*buff++ = 0;
*buff++ = chksum;
} else if (j == 10) {
*buff++ = 0;
*buff++ = 0;
}
}
}
// Create SFN
memset(buff, 0, 32);
for (int i = 0; i < 11; i++) {
buff[i] = SFN[i];
}
buff[0x0b] = 0x20; // ATTR = Archive
// Ignore creation data/time, etc.
buff[0x1a] = 0x03; // Starting cluster 3
File f = LittleFS.open(_localFile, "r");
int size = f.size();
f.close();
buff[0x1c] = size & 255;
buff[0x1d] = (size >> 8) & 255;
buff[0x1e] = (size >> 16) & 255; // 16MB or smaller
}
void SingleFileDrive::fatSector(char fat[512]) {
memset(fat, 0, 512);
fat[0x00] = 0xff;
fat[0x01] = 0xf8;
fat[0x02] = 0xff;
fat[0x03] = 0xff;
int cluster = 3;
File f = LittleFS.open(_localFile, "r");
int size = f.size();
f.close();
while (size > 65536) {
fat[cluster * 2] = (cluster + 1) & 0xff;
fat[cluster * 2 + 1] = ((cluster + 1) >> 8) & 0xff;
cluster++;
size -= 65536;
}
fat[cluster * 2] = 0xff;
fat[cluster * 2 + 1] = 0xff;
}
// Invoked to determine max LUN
extern "C" uint8_t tud_msc_get_maxlun_cb(void) {
return 1;
}
// Invoked when received SCSI_CMD_INQUIRY
// Application fill vendor id, product id and revision with string up to 8, 16, 4 characters respectively
extern "C" void tud_msc_inquiry_cb(uint8_t lun, uint8_t vendor_id[8], uint8_t product_id[16], uint8_t product_rev[4]) {
(void) lun;
const char vid[] = "PicoDisk";
const char pid[] = "Mass Storage";
const char rev[] = "1.0";
memcpy(vendor_id, vid, strlen(vid));
memcpy(product_id, pid, strlen(pid));
memcpy(product_rev, rev, strlen(rev));
}
bool SingleFileDrive::testUnitReady() {
return _started;
}
// Invoked when received Test Unit Ready command.
// return true allowing host to read/write this LUN e.g SD card inserted
extern "C" bool tud_msc_test_unit_ready_cb(uint8_t lun) {
(void) lun;
return singleFileDrive.testUnitReady();
}
// Invoked when received SCSI_CMD_READ_CAPACITY_10 and SCSI_CMD_READ_FORMAT_CAPACITY to determine the disk size
// Application update block count and block size
extern "C" void tud_msc_capacity_cb(uint8_t lun, uint32_t* block_count, uint16_t* block_size) {
(void) lun;
*block_count = _hddsects;
*block_size = 512;
}
// Callback invoked when received READ10 command.
// Copy disk's data to buffer (up to bufsize) and return number of copied bytes.
extern "C" int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize) {
(void) lun;
return singleFileDrive.read10(lba, offset, buffer, bufsize);
}
int32_t SingleFileDrive::read10(uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize) {
if (!_started || (lba >= _hddsects)) {
return -1;
}
uint32_t toread = bufsize;
char buff[512];
uint8_t *curbuff = (uint8_t *)buffer;
while (bufsize > 0) {
if (lba == 0) {
bootSector(buff);
} else if ((lba == 128) || (lba == 256)) {
fatSector(buff);
} else if (lba == 384) {
directorySector(buff);
} else if (lba >= 640) {
File f = LittleFS.open(_localFile, "r");
f.seek((lba - 640) * 512);
f.read((uint8_t*)buff, 512);
f.close();
} else {
memset(buff, 0, sizeof(buff));
}
uint32_t cplen = 512 - offset;
if (bufsize < cplen) {
cplen = bufsize;
}
memcpy(curbuff, buff + offset, cplen);
curbuff += cplen;
offset = 0;
lba++;
bufsize -= cplen;
}
return toread;
}
extern "C" bool tud_msc_is_writable_cb(uint8_t lun) {
(void) lun;
return true;
}
// Callback invoked when received WRITE10 command.
// Process data in buffer to disk's storage and return number of written bytes
extern "C" int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t* buffer, uint32_t bufsize) {
(void) lun;
return singleFileDrive.write10(lba, offset, buffer, bufsize);
}
int32_t SingleFileDrive::write10(uint32_t lba, uint32_t offset, uint8_t* buffer, uint32_t bufsize) {
if (!_started || (lba >= _hddsects)) {
return -1;
}
uint32_t addr = lba * 512 + offset;
uint32_t hotspot = 384 * 512 + 0x20;
if ((addr > hotspot) || (addr + bufsize < hotspot)) {
// Did not try and erase the file entry, ignore
return bufsize;
}
int off = hotspot - addr;
uint8_t *ptr = (uint8_t *)buffer;
ptr += off;
if (*ptr == 0xe5) {
if (_cbDelete) {
_cbDelete(_cbDeleteData);
}
}
return bufsize;
}
extern "C" bool tud_msc_set_sense(uint8_t lun, uint8_t sense_key, uint8_t add_sense_code, uint8_t add_sense_qualifier);
// Callback invoked when received an SCSI command not in built-in list below
// - READ_CAPACITY10, READ_FORMAT_CAPACITY, INQUIRY, MODE_SENSE6, REQUEST_SENSE
// - READ10 and WRITE10 has their own callbacks
extern "C" int32_t tud_msc_scsi_cb(uint8_t lun, uint8_t const scsi_cmd[16], void* buffer, uint16_t bufsize) {
const int SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL = 0x1E;
const int SCSI_CMD_START_STOP_UNIT = 0x1B;
const int SCSI_SENSE_ILLEGAL_REQUEST = 0x05;
void const* response = NULL;
int32_t resplen = 0;
// most scsi handled is input
bool in_xfer = true;
scsi_start_stop_unit_t const * start_stop = (scsi_start_stop_unit_t const *) scsi_cmd;
switch (scsi_cmd[0]) {
case SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL:
// Host is about to read/write etc ... better not to disconnect disk
if (scsi_cmd[4] & 1) {
singleFileDrive.plug();
}
resplen = 0;
break;
case SCSI_CMD_START_STOP_UNIT:
// Host try to eject/safe remove/poweroff us. We could safely disconnect with disk storage, or go into lower power
if (!start_stop->start && start_stop->load_eject) {
singleFileDrive.unplug();
} else if (start_stop->start && start_stop->load_eject) {
singleFileDrive.plug();
}
resplen = 0;
break;
default:
// Set Sense = Invalid Command Operation
tud_msc_set_sense(lun, SCSI_SENSE_ILLEGAL_REQUEST, 0x20, 0x00);
// negative means error -> tinyusb could stall and/or response with failed status
resplen = -1;
break;
}
// return resplen must not larger than bufsize
if (resplen > bufsize) {
resplen = bufsize;
}
if (response && (resplen > 0)) {
if (in_xfer) {
memcpy(buffer, response, resplen);
} else {
// SCSI output
}
}
return resplen;
}
void SingleFileDrive::plug() {
if (_started && _cbPlug) {
_cbPlug(_cbPlugData);
}
}
void SingleFileDrive::unplug() {
if (_started && _cbUnplug) {
_cbUnplug(_cbUnplugData);
}
}
// Callback invoked on start/stop
extern "C" bool tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, bool load_eject) {
(void) lun;
(void) power_condition;
if (start && load_eject) {
singleFileDrive.plug();
} else if (!start && load_eject) {
singleFileDrive.unplug();
}
return true;
}
@@ -0,0 +1,63 @@
/*
SingleFileDrive - Emulates a USB stick for easy data transfer
Copyright (c) 2022 Earle F. Philhower, III. All rights reserved.
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>
class SingleFileDrive {
public:
SingleFileDrive();
~SingleFileDrive();
bool begin(const char *localFile, const char *dosFile);
void end();
void onDelete(void (*cb)(uint32_t), uint32_t cbData = 0);
void onPlug(void (*cb)(uint32_t), uint32_t cbData = 0);
void onUnplug(void (*cb)(uint32_t), uint32_t cbData = 0);
// Only for internal TinyUSB callback use
bool testUnitReady();
int32_t read10(uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize);
int32_t write10(uint32_t lba, uint32_t offset, uint8_t* buffer, uint32_t bufsize);
void plug();;
void unplug();
private:
void bootSector(char buff[512]);
void directorySector(char buff[512]);
void fatSector(char buff[512]);
private:
bool _started = false;
char *_localFile = nullptr;
char *_dosFile = nullptr;
void (*_cbDelete)(uint32_t) = nullptr;
uint32_t _cbDeleteData = 0;
void (*_cbPlug)(uint32_t) = nullptr;
uint32_t _cbPlugData = 0;
void (*_cbUnplug)(uint32_t) = nullptr;
uint32_t _cbUnplugData = 0;
};
extern SingleFileDrive singleFileDrive;
+3 -1
View File
@@ -42,6 +42,7 @@ gatewayIP KEYWORD2
SSID KEYWORD2
BSSID KEYWORD2
RSSI KEYWORD2
channel KEYWORD2
encryptionType KEYWORD2
beginPacket KEYWORD2
endPacket KEYWORD2
@@ -56,7 +57,8 @@ beginEnterprise KEYWORD2
setHostname KEYWORD2
end KEYWORD2
getTime KEYWORD2
lowPowerMode KEYWORD2
aggressiveLowPowerMode KEYWORD2
defaultLowPowerMode KEYWORD2
noLowPowerMode KEYWORD2
ping KEYWORD2
beginMulticast KEYWORD2
+78 -21
View File
@@ -44,17 +44,20 @@ const char* WiFiClass::firmwareVersion() {
return PICO_SDK_VERSION_STRING;
}
void WiFiClass::mode(_wifiModeESP m) {
void WiFiClass::mode(WiFiMode_t m) {
_calledESP = true;
switch (m) {
case WIFI_OFF:
case WiFiMode_t::WIFI_OFF:
end();
break;
case WIFI_AP:
_modeESP = WIFI_AP;
case WiFiMode_t::WIFI_AP:
_modeESP = WiFiMode_t::WIFI_AP;
break;
case WIFI_STA:
_modeESP = WIFI_STA;
case WiFiMode_t::WIFI_STA:
_modeESP = WiFiMode_t::WIFI_STA;
break;
case WiFiMode_t::WIFI_AP_STA:
_modeESP = WiFiMode_t::WIFI_STA;
break;
}
}
@@ -86,7 +89,7 @@ int WiFiClass::begin(const char* ssid, const char *passphrase) {
_ssid = ssid;
_password = passphrase;
_wifi.setSSID(ssid);
_wifi.setSSID(_ssid.c_str());
_wifi.setPassword(passphrase);
_wifi.setTimeout(_timeout);
_wifi.setSTA();
@@ -96,6 +99,7 @@ int WiFiClass::begin(const char* ssid, const char *passphrase) {
if (!_wifi.begin()) {
return WL_IDLE_STATUS;
}
noLowPowerMode();
// Enable CYW43 event debugging (make sure Debug Port is set)
//cyw43_state.trace_flags = 0xffff;
while (!_calledESP && ((millis() - start < (uint32_t)2 * _timeout)) && !connected()) {
@@ -123,7 +127,7 @@ uint8_t WiFiClass::beginAP(const char *ssid, const char* passphrase) {
_ssid = ssid;
_password = passphrase;
_wifi.setSSID(ssid);
_wifi.setSSID(_ssid.c_str());
_wifi.setPassword(passphrase);
_wifi.setTimeout(_timeout);
_wifi.setAP();
@@ -131,6 +135,7 @@ uint8_t WiFiClass::beginAP(const char *ssid, const char* passphrase) {
if (!_wifi.begin()) {
return WL_IDLE_STATUS;
}
noLowPowerMode();
IPAddress gw = _wifi.gatewayIP();
if (!gw.isSet()) {
gw = IPAddress(192, 168, 42, 1);
@@ -234,7 +239,7 @@ const char *WiFiClass::getHostname() {
return: one value of wl_status_t enum
*/
int WiFiClass::disconnect(void) {
int WiFiClass::disconnect(bool wifi_off __unused) {
if (_dhcpServer) {
dhcp_server_deinit(_dhcpServer);
free(_dhcpServer);
@@ -300,7 +305,7 @@ IPAddress WiFiClass::gatewayIP() {
return: ssid string
*/
const char* WiFiClass::SSID() {
const String &WiFiClass::SSID() {
return _ssid;
}
@@ -311,11 +316,33 @@ const char* WiFiClass::SSID() {
return: pointer to uint8_t array with length WL_MAC_ADDR_LENGTH
*/
uint8_t* WiFiClass::BSSID(uint8_t* bssid) {
// TODO - driver does not return this?!
memset(bssid, 0xee, WL_MAC_ADDR_LENGTH);
#ifndef CYW43_IOCTL_GET_BSSID
#define CYW43_IOCTL_GET_BSSID ( (uint32_t)23 * 2 )
#endif
if (_wifi.connected()) {
cyw43_ioctl(&cyw43_state, CYW43_IOCTL_GET_BSSID, WL_MAC_ADDR_LENGTH, bssid, CYW43_ITF_STA);
} else {
memset(bssid, 0, WL_MAC_ADDR_LENGTH);
}
return bssid;
}
int WiFiClass::channel() {
#ifndef CYW43_IOCTL_GET_CHANNEL
#define CYW43_IOCTL_GET_CHANNEL 0x3a
#endif
int32_t channel;
if (_wifi.connected()) {
cyw43_ioctl(&cyw43_state, CYW43_IOCTL_GET_CHANNEL, sizeof channel, (uint8_t *)&channel, CYW43_ITF_STA);
} else {
channel = -1;
}
return channel;
}
/*
Return the current RSSI /Received Signal Strength in dBm)
associated with the network
@@ -323,8 +350,17 @@ uint8_t* WiFiClass::BSSID(uint8_t* bssid) {
return: signed value
*/
int32_t WiFiClass::RSSI() {
// TODO - driver does not return this?!
return 0;
#ifndef CYW43_IOCTL_GET_RSSI
#define CYW43_IOCTL_GET_RSSI 0xFE
#endif
int32_t rssi;
if (_wifi.connected()) {
cyw43_ioctl(&cyw43_state, CYW43_IOCTL_GET_RSSI, sizeof rssi, (uint8_t *)&rssi, CYW43_ITF_STA);
} else {
rssi = -255;
}
return rssi;
}
/*
@@ -365,7 +401,7 @@ int WiFiClass::_scanCB(void *env, const cyw43_ev_scan_result_t *result) {
return: Number of discovered networks
*/
int8_t WiFiClass::scanNetworks() {
int8_t WiFiClass::scanNetworks(bool async) {
cyw43_wifi_scan_options_t scan_options;
memset(&scan_options, 0, sizeof(scan_options));
_scan.clear();
@@ -378,11 +414,27 @@ int8_t WiFiClass::scanNetworks() {
if (err) {
return 0;
}
uint32_t now = millis();
while (cyw43_wifi_scan_active(&cyw43_state) && (millis() - now < 10000)) {
delay(10);
if (!async) {
uint32_t now = millis();
while (cyw43_wifi_scan_active(&cyw43_state) && (millis() - now < 10000)) {
delay(10);
}
return _scan.size();
} else {
return -1;
}
return _scan.size();
}
int8_t WiFiClass::scanComplete() {
if (cyw43_wifi_scan_active(&cyw43_state)) {
return -1;
} else {
return _scan.size();
}
}
void WiFiClass::scanDelete() {
_scan.clear();
}
/*
@@ -515,14 +567,19 @@ unsigned long WiFiClass::getTime() {
return millis();
}
void WiFiClass::lowPowerMode() {
void WiFiClass::aggressiveLowPowerMode() {
cyw43_wifi_pm(&cyw43_state, CYW43_AGGRESSIVE_PM);
}
void WiFiClass::noLowPowerMode() {
void WiFiClass::defaultLowPowerMode() {
cyw43_wifi_pm(&cyw43_state, CYW43_DEFAULT_PM);
}
// The difference between the default CYW43_DEFAULT_PM (0xA11142) and not low power (0xA11140) is that it changed from "Powersave mode on specified interface with High throughput" to "No Powersave mode". All other parameters stayed the same.
void WiFiClass::noLowPowerMode() {
cyw43_wifi_pm(&cyw43_state, 0xA11140);
}
int WiFiClass::ping(const char* hostname, uint8_t ttl) {
IPAddress ip;
if (!hostByName(hostname, ip)) {
+41 -11
View File
@@ -35,7 +35,7 @@
typedef void(*FeedHostProcessorWatchdogFuncPointer)();
typedef enum { WIFI_STA, WIFI_AP, WIFI_OFF } _wifiModeESP; // For ESP8266 compatibility
typedef enum { WIFI_OFF = 0, WIFI_STA = 1, WIFI_AP = 2, WIFI_AP_STA = 3 } WiFiMode_t; // For ESP8266 compatibility
class WiFiClass {
public:
@@ -46,7 +46,18 @@ public:
*/
static const char* firmwareVersion();
void mode(_wifiModeESP m); // For ESP8266 compatibility
void mode(WiFiMode_t m); // For ESP8266 compatibility
WiFiMode_t getMode() {
if (_wifiHWInitted) {
if (_apMode) {
return WiFiMode_t::WIFI_AP;
} else {
return WiFiMode_t::WIFI_STA;
}
}
return WiFiMode_t::WIFI_OFF;
};
/* Start WiFi connection for OPEN networks
@@ -138,7 +149,7 @@ public:
}
String softAPSSID() {
return String(SSID());
return SSID();
}
@@ -205,7 +216,7 @@ public:
return: one value of wl_status_t enum
*/
int disconnect(void);
int disconnect(bool wifi_off = false);
void end(void);
@@ -249,7 +260,7 @@ public:
return: ssid string
*/
const char* SSID();
const String &SSID();
/*
Return the current BSSID associated with the network.
@@ -267,6 +278,10 @@ public:
*/
int32_t RSSI();
/* Return the current network channel */
int channel();
/*
Return the Encryption Type associated with the network
@@ -277,9 +292,23 @@ public:
/*
Start scan WiFi networks available
param async: whether to perform asynchronous scan
return: Number of discovered networks
*/
int8_t scanNetworks();
int8_t scanNetworks(bool async = false);
/*
Return number of scanned WiFi networks
return: Number of discovered networks
*/
int8_t scanComplete();
/*
Delete scan results
*/
void scanDelete();
/*
Return the SSID discovered during the network scan.
@@ -339,7 +368,8 @@ public:
unsigned long getTime();
void lowPowerMode();
void aggressiveLowPowerMode();
void defaultLowPowerMode();
void noLowPowerMode();
int ping(const char* hostname, uint8_t ttl = 128);
@@ -352,9 +382,9 @@ public:
void feedWatchdog();
private:
int _timeout = 10000;
const char * _ssid = nullptr;
const char * _password = nullptr;
int _timeout = 15000;
String _ssid;
String _password;
bool _wifiHWInitted = false;
bool _apMode = false;
@@ -367,7 +397,7 @@ private:
// ESP compat
bool _calledESP = false; // Should we behave like the ESP8266 for connect?
_wifiModeESP _modeESP = WIFI_STA;
WiFiMode_t _modeESP = WIFI_STA;
};
extern WiFiClass WiFi;
+14 -4
View File
@@ -374,12 +374,22 @@ public:
return 0;
}
size_t sent = 0;
uint8_t buff[256];
while (stream.available()) {
char b;
b = stream.read();
if (write(&b, 1)) {
sent ++;
// Stream only lets you read 1 byte at a time, so buffer in local copy
size_t i;
for (i = 0; (i < sizeof(buff)) && stream.available(); i++) {
buff[i] = stream.read();
}
if (i) {
// Send as a single packet
int len = write((const char *)buff, i);
sent += len;
if (len != (int)i) {
break; // Write error...
}
} else {
// Out of data...
break;
}
}
+42 -31
View File
@@ -140,23 +140,52 @@ void TwoWire::begin(uint8_t addr) {
_running = true;
}
// See: https://github.com/earlephilhower/arduino-pico/issues/979#issuecomment-1328237128
#pragma GCC push_options
#pragma GCC optimize ("O0")
void TwoWire::onIRQ() {
if (_i2c->hw->intr_stat & (1 << 12)) {
if (_onReceiveCallback && _buffLen) {
_onReceiveCallback(_buffLen);
}
_buffLen = 0;
_buffOff = 0;
_slaveStartDet = false;
_i2c->hw->clr_restart_det;
// Make a local copy of the IRQ status up front. If it changes while we're
// running the IRQ callback will fire again after returning. Avoids potential
// race conditions
uint32_t irqstat = _i2c->hw->intr_stat;
if (irqstat == 0) {
return;
}
if (_i2c->hw->intr_stat & (1 << 10)) {
_buffLen = 0;
_buffOff = 0;
// First, pull off any data available
if (irqstat & (1 << 2)) {
// RX_FULL
if (_buffLen < (int)sizeof(_buff)) {
_buff[_buffLen++] = _i2c->hw->data_cmd & 0xff;
} else {
_i2c->hw->data_cmd;
}
}
// RD_REQ
if (irqstat & (1 << 5)) {
if (_onRequestCallback) {
_onRequestCallback();
}
_i2c->hw->clr_rd_req;
}
// TX_ABRT
if (irqstat & (1 << 6)) {
_i2c->hw->clr_tx_abrt;
}
// START_DET
if (irqstat & (1 << 10)) {
_slaveStartDet = true;
_i2c->hw->clr_start_det;
}
if (_i2c->hw->intr_stat & (1 << 9)) {
// RESTART_DET
if (irqstat & (1 << 12)) {
if (_onReceiveCallback && _buffLen) {
_onReceiveCallback(_buffLen);
}
_i2c->hw->clr_restart_det;
}
// STOP_DET
if (irqstat & (1 << 9)) {
if (_onReceiveCallback && _buffLen) {
_onReceiveCallback(_buffLen);
}
@@ -165,26 +194,8 @@ void TwoWire::onIRQ() {
_slaveStartDet = false;
_i2c->hw->clr_stop_det;
}
if (_i2c->hw->intr_stat & (1 << 6)) {
// TX_ABRT
_i2c->hw->clr_tx_abrt;
}
if (_i2c->hw->intr_stat & (1 << 5)) {
// RD_REQ
if (_onRequestCallback) {
_onRequestCallback();
}
_i2c->hw->clr_rd_req;
}
if (_i2c->hw->intr_stat & (1 << 2)) {
// RX_FULL
if (_slaveStartDet && (_buffLen < (int)sizeof(_buff))) {
_buff[_buffLen++] = _i2c->hw->data_cmd & 0xff;
} else {
_i2c->hw->data_cmd;
}
}
}
#pragma GCC pop_options
void TwoWire::end() {
if (!_running) {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "framework-arduinopico",
"version": "1.20602.0",
"version": "1.20605.0",
"description": "Arduino Wiring-based Framework (RPi Pico RP2040)",
"keywords": [
"framework",
+24
View File
@@ -26,6 +26,9 @@
{
"name": "Adafruit Feather RP2040"
},
{
"name": "Adafruit Feather RP2040 SCORPIO"
},
{
"name": "Adafruit ItsyBitsy RP2040"
},
@@ -56,6 +59,9 @@
{
"name": "Cytron Maker Pi RP2040"
},
{
"name": "DatanoiseTV PicoADK"
},
{
"name": "Degz Mizu"
},
@@ -122,6 +128,24 @@
{
"name": "Seeed XIAO RP2040"
},
{
"name": "Waveshare RP2040 Zero"
},
{
"name": "Waveshare RP2040 One"
},
{
"name": "Waveshare RP2040 Plus 4MB"
},
{
"name": "Waveshare RP2040 Plus 16MB"
},
{
"name": "Waveshare RP2040 LCD 0.96"
},
{
"name": "Waveshare RP2040 LCD 1.28"
},
{
"name": "WIZnet W5100S-EVB-Pico"
},
+1 -1
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.6.2
version=2.6.5
runtime.tools.pqt-gcc.path={runtime.platform.path}/system/arm-none-eabi
runtime.tools.pqt-python3.path={runtime.platform.path}/system/python3
+1 -1
View File
@@ -1,6 +1,6 @@
#!/bin/bash
for dir in ./cores/rp2040 ./libraries/EEPROM ./libraries/I2S \
for dir in ./cores/rp2040 ./libraries/EEPROM ./libraries/I2S ./libraries/SingleFileDrive \
./libraries/LittleFS/src ./libraries/LittleFS/examples \
./libraries/rp2040 ./libraries/SD ./libraries/ESP8266SdFat \
./libraries/Servo ./libraries/SPI ./libraries/Wire ./libraries/PDM \
+54
View File
@@ -0,0 +1,54 @@
{
"build": {
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_w25q080_2_padded_checksum.S",
"usb_vid": "0x239A",
"usb_pid": "0x8121"
}
},
"core": "earlephilhower",
"cpu": "cortex-m0plus",
"extra_flags": "-D ARDUINO_ADAFRUIT_FEATHER_RP2040_SCORPIO -DARDUINO_ARCH_RP2040 -DUSBD_MAX_POWER_MA=250",
"f_cpu": "133000000L",
"hwids": [
[
"0x2E8A",
"0x00C0"
],
[
"0x239A",
"0x8121"
]
],
"mcu": "rp2040",
"variant": "adafruit_feather_scorpio"
},
"debug": {
"jlink_device": "RP2040_M0_0",
"openocd_target": "rp2040.cfg",
"svd_path": "rp2040.svd"
},
"frameworks": [
"arduino"
],
"name": "Feather RP2040 SCORPIO",
"upload": {
"maximum_ram_size": 270336,
"maximum_size": 8388608,
"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": "Adafruit"
}
+2 -2
View File
@@ -4,7 +4,7 @@
"earlephilhower": {
"boot2_source": "boot2_w25q080_2_padded_checksum.S",
"usb_vid": "0x2341",
"usb_pid": "0x0058"
"usb_pid": "0x005E"
}
},
"core": "earlephilhower",
@@ -18,7 +18,7 @@
],
[
"0x2341",
"0x0058"
"0x005E"
]
],
"mcu": "rp2040",
+54
View File
@@ -0,0 +1,54 @@
{
"build": {
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_w25q080_2_padded_checksum.S",
"usb_vid": "0x2E8A",
"usb_pid": "0x000A"
}
},
"core": "earlephilhower",
"cpu": "cortex-m0plus",
"extra_flags": "-D ARDUINO_DATANOISETV_PICOADK -DARDUINO_ARCH_RP2040 -DUSBD_MAX_POWER_MA=250",
"f_cpu": "133000000L",
"hwids": [
[
"0x2E8A",
"0x00C0"
],
[
"0x2E8A",
"0x000A"
]
],
"mcu": "rp2040",
"variant": "datanoisetv_picoadk"
},
"debug": {
"jlink_device": "RP2040_M0_0",
"openocd_target": "rp2040.cfg",
"svd_path": "rp2040.svd"
},
"frameworks": [
"arduino"
],
"name": "PicoADK",
"upload": {
"maximum_ram_size": 270336,
"maximum_size": 2097152,
"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": "DatanoiseTV"
}
+1 -1
View File
@@ -2,7 +2,7 @@
"build": {
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_generic_03h_4_padded_checksum.S",
"boot2_source": "boot2_w25q080_2_padded_checksum.S",
"usb_vid": "0x2E8A",
"usb_pid": "0x008A"
}
+54
View File
@@ -0,0 +1,54 @@
{
"build": {
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_w25q16jvxq_4_padded_checksum.S",
"usb_vid": "0x2E8A",
"usb_pid": "0x1021"
}
},
"core": "earlephilhower",
"cpu": "cortex-m0plus",
"extra_flags": "-D ARDUINO_WAVESHARE_RP2040_LCD_0_96 -DARDUINO_ARCH_RP2040 -DUSBD_MAX_POWER_MA=500",
"f_cpu": "133000000L",
"hwids": [
[
"0x2E8A",
"0x00C0"
],
[
"0x2E8A",
"0x1021"
]
],
"mcu": "rp2040",
"variant": "waveshare_rp2040_lcd_0_96"
},
"debug": {
"jlink_device": "RP2040_M0_0",
"openocd_target": "rp2040.cfg",
"svd_path": "rp2040.svd"
},
"frameworks": [
"arduino"
],
"name": "RP2040 LCD 0.96",
"upload": {
"maximum_ram_size": 270336,
"maximum_size": 2097152,
"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": "Waveshare"
}
+54
View File
@@ -0,0 +1,54 @@
{
"build": {
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_w25q16jvxq_4_padded_checksum.S",
"usb_vid": "0x2E8A",
"usb_pid": "0x1039"
}
},
"core": "earlephilhower",
"cpu": "cortex-m0plus",
"extra_flags": "-D ARDUINO_WAVESHARE_RP2040_LCD_1_28 -DARDUINO_ARCH_RP2040 -DUSBD_MAX_POWER_MA=500",
"f_cpu": "133000000L",
"hwids": [
[
"0x2E8A",
"0x00C0"
],
[
"0x2E8A",
"0x1039"
]
],
"mcu": "rp2040",
"variant": "waveshare_rp2040_lcd_1_28"
},
"debug": {
"jlink_device": "RP2040_M0_0",
"openocd_target": "rp2040.cfg",
"svd_path": "rp2040.svd"
},
"frameworks": [
"arduino"
],
"name": "RP2040 LCD 1.28",
"upload": {
"maximum_ram_size": 270336,
"maximum_size": 2097152,
"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": "Waveshare"
}
+54
View File
@@ -0,0 +1,54 @@
{
"build": {
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_w25q16jvxq_4_padded_checksum.S",
"usb_vid": "0x2E8A",
"usb_pid": "0x103A"
}
},
"core": "earlephilhower",
"cpu": "cortex-m0plus",
"extra_flags": "-D ARDUINO_WAVESHARE_RP2040_ONE -DARDUINO_ARCH_RP2040 -DUSBD_MAX_POWER_MA=500",
"f_cpu": "133000000L",
"hwids": [
[
"0x2E8A",
"0x00C0"
],
[
"0x2E8A",
"0x103A"
]
],
"mcu": "rp2040",
"variant": "waveshare_rp2040_one"
},
"debug": {
"jlink_device": "RP2040_M0_0",
"openocd_target": "rp2040.cfg",
"svd_path": "rp2040.svd"
},
"frameworks": [
"arduino"
],
"name": "RP2040 One",
"upload": {
"maximum_ram_size": 270336,
"maximum_size": 4194304,
"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": "Waveshare"
}
@@ -0,0 +1,54 @@
{
"build": {
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_w25q080_2_padded_checksum.S",
"usb_vid": "0x2E8A",
"usb_pid": "0x1020"
}
},
"core": "earlephilhower",
"cpu": "cortex-m0plus",
"extra_flags": "-D ARDUINO_WAVESHARE_RP2040_PLUS -DARDUINO_ARCH_RP2040 -DUSBD_MAX_POWER_MA=500",
"f_cpu": "133000000L",
"hwids": [
[
"0x2E8A",
"0x00C0"
],
[
"0x2E8A",
"0x1020"
]
],
"mcu": "rp2040",
"variant": "waveshare_rp2040_plus_16mb"
},
"debug": {
"jlink_device": "RP2040_M0_0",
"openocd_target": "rp2040.cfg",
"svd_path": "rp2040.svd"
},
"frameworks": [
"arduino"
],
"name": "RP2040 Plus 16MB",
"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": "Waveshare"
}
+54
View File
@@ -0,0 +1,54 @@
{
"build": {
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_w25q080_2_padded_checksum.S",
"usb_vid": "0x2E8A",
"usb_pid": "0x1020"
}
},
"core": "earlephilhower",
"cpu": "cortex-m0plus",
"extra_flags": "-D ARDUINO_WAVESHARE_RP2040_PLUS -DARDUINO_ARCH_RP2040 -DUSBD_MAX_POWER_MA=500",
"f_cpu": "133000000L",
"hwids": [
[
"0x2E8A",
"0x00C0"
],
[
"0x2E8A",
"0x1020"
]
],
"mcu": "rp2040",
"variant": "waveshare_rp2040_plus_4mb"
},
"debug": {
"jlink_device": "RP2040_M0_0",
"openocd_target": "rp2040.cfg",
"svd_path": "rp2040.svd"
},
"frameworks": [
"arduino"
],
"name": "RP2040 Plus 4MB",
"upload": {
"maximum_ram_size": 270336,
"maximum_size": 4194304,
"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": "Waveshare"
}
+54
View File
@@ -0,0 +1,54 @@
{
"build": {
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_w25q16jvxq_4_padded_checksum.S",
"usb_vid": "0x2E8A",
"usb_pid": "0x0003"
}
},
"core": "earlephilhower",
"cpu": "cortex-m0plus",
"extra_flags": "-D ARDUINO_WAVESHARE_RP2040_ZERO -DARDUINO_ARCH_RP2040 -DUSBD_MAX_POWER_MA=500",
"f_cpu": "133000000L",
"hwids": [
[
"0x2E8A",
"0x00C0"
],
[
"0x2E8A",
"0x0003"
]
],
"mcu": "rp2040",
"variant": "waveshare_rp2040_zero"
},
"debug": {
"jlink_device": "RP2040_M0_0",
"openocd_target": "rp2040.cfg",
"svd_path": "rp2040.svd"
},
"frameworks": [
"arduino"
],
"name": "RP2040 Zero",
"upload": {
"maximum_ram_size": 270336,
"maximum_size": 2097152,
"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": "Waveshare"
}
+2 -3
View File
@@ -72,15 +72,14 @@
//------------- CLASS -------------//
#define CFG_TUD_HID (2)
#define CFG_TUD_CDC (1)
#define CFG_TUD_MSC (0)
#define CFG_TUD_MSC (1)
#define CFG_TUD_MIDI (0)
#define CFG_TUD_VENDOR (0)
#define CFG_TUD_CDC_RX_BUFSIZE (256)
#define CFG_TUD_CDC_TX_BUFSIZE (256)
#define CFG_TUD_MIDI_RX_BUFSIZE (64)
#define CFG_TUD_MIDI_TX_BUFSIZE (64)
#define CFG_TUD_MSC_EP_BUFSIZE (64)
// HID buffer size Should be sufficient to hold ID (if any) + Data
#define CFG_TUD_HID_EP_BUFSIZE (64)
+40 -16
View File
@@ -70,7 +70,7 @@ def BuildBoot(name):
("IS25LP080 QSPI /2", "boot2_is25lp080_2_padded_checksum"), ("IS25LP080 QSPI /4", "boot2_is25lp080_4_padded_checksum"),
("W25Q080 QSPI /2", "boot2_w25q080_2_padded_checksum"), ("W25Q080 QSPI /4", "boot2_w25q080_4_padded_checksum"),
("W25X10CL QSPI /2", "boot2_w25x10cl_2_padded_checksum"), ("W25X10CL QSPI /4", "boot2_w25x10cl_4_padded_checksum"),
("W25Q64JV QSPI /4", "boot2_w25q64jv_4_padded_checksum") ]:
("W25Q64JV QSPI /4", "boot2_w25q64jv_4_padded_checksum"), ("W25Q16JVxQ QSPI /4", "boot2_w25q16jvxq_4_padded_checksum") ]:
print("%s.menu.boot2.%s=%s" % (name, l[1], l[0]))
print("%s.menu.boot2.%s.build.boot2=%s" % (name, l[1], l[1]))
@@ -110,15 +110,24 @@ def BuildHeader(name, vendor_name, product_name, vidtouse, pidtouse, vid, pid, p
print("# %s" % (prettyname))
print("# -----------------------------------")
print("%s.name=%s" % (name, prettyname))
usb = 0;
for kb in [ "0", "0x8000" ]:
for ms in [ "0", "0x4000" ]:
for jy in [ "0", "0x0100" ]:
thispid = int(pidtouse, 16) | int(kb, 16) | int(ms, 16) | int(jy, 16)
print("%s.vid.%d=%s" % (name, usb, vidtouse))
print("%s.pid.%d=0x%04x" % (name, usb, thispid))
usb = usb + 1
print("%s.build.usbpid=-DSERIALUSB_PID=%s" % (name, pid))
usb = 0
if type(pidtouse) == list:
for tp in pid:
print("%s.vid.%d=%s" % (name, usb, vidtouse))
print("%s.pid.%d=0x%04x" % (name, usb, int(tp, 16)))
usb = usb + 1
else:
for kb in [ "0", "0x8000" ]:
for ms in [ "0", "0x4000" ]:
for jy in [ "0", "0x0100" ]:
thispid = int(pidtouse, 16) | int(kb, 16) | int(ms, 16) | int(jy, 16)
print("%s.vid.%d=%s" % (name, usb, vidtouse))
print("%s.pid.%d=0x%04x" % (name, usb, thispid))
usb = usb + 1
if type(pid) == list:
print("%s.build.usbpid=-DSERIALUSB_PID=%s" % (name, pid[0]))
else:
print("%s.build.usbpid=-DSERIALUSB_PID=%s" % (name, pid))
print("%s.build.usbpwr=-DUSBD_MAX_POWER_MA=%s" % (name, pwr))
print("%s.build.board=%s" % (name, boarddefine))
print("%s.build.mcu=cortex-m0plus" % (name))
@@ -141,7 +150,10 @@ def BuildHeader(name, vendor_name, product_name, vidtouse, pidtouse, vid, pid, p
print("%s.build.debugscript=%s" % (name, dbg))
print("%s.build.boot2=%s" % (name, boot2))
print("%s.build.vid=%s" % (name, vid))
print("%s.build.pid=%s" % (name, pid))
if type(pid) == list:
print("%s.build.pid=%s" % (name, pid[0]))
else:
print("%s.build.pid=%s" % (name, pid))
print('%s.build.usb_manufacturer="%s"' % (name, vendor_name))
print('%s.build.usb_product="%s"' % (name, product_name))
if extra != None:
@@ -205,10 +217,9 @@ def MakeBoard(name, vendor_name, product_name, vid, pid, pwr, boarddefine, flash
BuildExceptions(n)
BuildDebugPort(n)
BuildDebugLevel(n)
if a == "picodebug":
BuildWithoutUSBStack(n)
else:
if a != "picodebug":
BuildUSBStack(n)
BuildWithoutUSBStack(n)
if name == "rpipicow":
BuildCountry(n)
BuildIPStack(n)
@@ -221,6 +232,8 @@ def MakeBoard(name, vendor_name, product_name, vid, pid, pwr, boarddefine, flash
pkgjson['packages'][0]['platforms'][0]['boards'].append(thisbrd)
def MakeBoardJSON(name, vendor_name, product_name, vid, pid, pwr, boarddefine, flashsizemb, boot2, extra):
if type(pid) == list:
pid = pid[0]
if extra != None:
m_extra = ' '
for m_item in extra:
@@ -313,6 +326,7 @@ MakeBoard("rpipicow", "Raspberry Pi", "Pico W", "0x2e8a", "0xf00a", 250, "RASPBE
# Adafruit
MakeBoard("adafruit_feather", "Adafruit", "Feather RP2040", "0x239a", "0x80f1", 250, "ADAFRUIT_FEATHER_RP2040", 8, "boot2_w25x10cl_4_padded_checksum")
MakeBoard("adafruit_feather_scorpio", "Adafruit", "Feather RP2040 SCORPIO", "0x239a", "0x8121", 250, "ADAFRUIT_FEATHER_RP2040_SCORPIO", 8, "boot2_w25q080_2_padded_checksum")
MakeBoard("adafruit_itsybitsy", "Adafruit", "ItsyBitsy RP2040", "0x239a", "0x80fd", 250, "ADAFRUIT_ITSYBITSY_RP2040", 8, "boot2_w25q080_2_padded_checksum")
MakeBoard("adafruit_qtpy", "Adafruit", "QT Py RP2040", "0x239a", "0x80f7", 250, "ADAFRUIT_QTPY_RP2040", 8, "boot2_w25q080_2_padded_checksum")
MakeBoard("adafruit_stemmafriend", "Adafruit", "STEMMA Friend RP2040", "0x239a", "0x80e3", 250, "ADAFRUIT_STEMMAFRIEND_RP2040", 8, "boot2_w25q080_2_padded_checksum")
@@ -321,7 +335,7 @@ MakeBoard("adafruit_macropad2040", "Adafruit", "MacroPad RP2040", "0x239a", "0x8
MakeBoard("adafruit_kb2040", "Adafruit", "KB2040", "0x239a", "0x8105", 250, "ADAFRUIT_KB2040_RP2040", 8, "boot2_w25q080_2_padded_checksum")
# Arduino
MakeBoard("arduino_nano_connect", "Arduino", "Nano RP2040 Connect", "0x2341", "0x0058", 250, "NANO_RP2040_CONNECT", 16, "boot2_w25q080_2_padded_checksum")
MakeBoard("arduino_nano_connect", "Arduino", "Nano RP2040 Connect", "0x2341", ["0x005e", "0x805e", "0x015e", "0x025e"] , 250, "NANO_RP2040_CONNECT", 16, "boot2_w25q080_2_padded_checksum")
# BridgeTek
MakeBoard("bridgetek_idm2040-7a", "BridgeTek", "IDM2040-7A", "0x2e8a", "0x1041", 250, "BRIDGETEK_IDM2040-7A", 8, "boot2_w25q080_2_padded_checksum", ["FT8XX_TYPE=BT817", "DISPLAY_RES=WVGA", "PLATFORM_RP2040"])
@@ -330,11 +344,14 @@ MakeBoard("bridgetek_idm2040-7a", "BridgeTek", "IDM2040-7A", "0x2e8a", "0x1041",
MakeBoard("cytron_maker_nano_rp2040", "Cytron", "Maker Nano RP2040", "0x2e8a", "0x100f", 250, "CYTRON_MAKER_NANO_RP2040", 2, "boot2_w25q080_2_padded_checksum")
MakeBoard("cytron_maker_pi_rp2040", "Cytron", "Maker Pi RP2040", "0x2e8a", "0x1000", 250, "CYTRON_MAKER_PI_RP2040", 2, "boot2_w25q080_2_padded_checksum")
# DatanoiseTV
MakeBoard("datanoisetv_picoadk", "DatanoiseTV", "PicoADK", "0x2e8a", "0x000a", 250, "DATANOISETV_PICOADK", 2, "boot2_w25q080_2_padded_checksum")
# Degz
MakeBoard("degz_mizu", "Degz", "Mizu", "0x2e8a", "0x000a", 250, "DEGZ_MIZU", 8, "boot2_generic_03h_4_padded_checksum")
# DeRuiLab
MakeBoard("flyboard2040_core", "DeRuiLab", "FlyBoard2040Core", "0x2e8a", "0x008a", 500, "FLYBOARD2040_CORE", 4, "boot2_generic_03h_4_padded_checksum")
MakeBoard("flyboard2040_core", "DeRuiLab", "FlyBoard2040Core", "0x2e8a", "0x008a", 500, "FLYBOARD2040_CORE", 4, "boot2_w25q080_2_padded_checksum")
# DFRobot
MakeBoard("dfrobot_beetle_rp2040", "DFRobot", "Beetle RP2040", "0x3343", "0x4253", 250, "DFROBOT_BEETLE_RP2040", 2, "boot2_w25q080_2_padded_checksum")
@@ -376,6 +393,13 @@ MakeBoard("upesy_rp2040_devkit", "uPesy", "RP2040 DevKit", "0x2e8a", "0x1007", 2
# Seeed
MakeBoard("seeed_xiao_rp2040", "Seeed", "XIAO RP2040", "0x2e8a", "0x000a", 250, "SEEED_XIAO_RP2040", 2, "boot2_w25q080_2_padded_checksum")
# Waveshare
MakeBoard("waveshare_rp2040_zero", "Waveshare", "RP2040 Zero", "0x2e8a", "0x0003", 500, "WAVESHARE_RP2040_ZERO", 2, "boot2_w25q16jvxq_4_padded_checksum")
MakeBoard("waveshare_rp2040_one", "Waveshare", "RP2040 One", "0x2e8a", "0x103a", 500, "WAVESHARE_RP2040_ONE", 4, "boot2_w25q16jvxq_4_padded_checksum")
MakeBoard("waveshare_rp2040_plus_4mb", "Waveshare", "RP2040 Plus 4MB", "0x2e8a", "0x1020", 500, "WAVESHARE_RP2040_PLUS", 4, "boot2_w25q080_2_padded_checksum")
MakeBoard("waveshare_rp2040_plus_16mb", "Waveshare", "RP2040 Plus 16MB", "0x2e8a", "0x1020", 500, "WAVESHARE_RP2040_PLUS", 16, "boot2_w25q080_2_padded_checksum")
MakeBoard("waveshare_rp2040_lcd_0_96", "Waveshare", "RP2040 LCD 0.96", "0x2e8a", "0x1021", 500, "WAVESHARE_RP2040_LCD_0_96", 2, "boot2_w25q16jvxq_4_padded_checksum")
MakeBoard("waveshare_rp2040_lcd_1_28", "Waveshare", "RP2040 LCD 1.28", "0x2e8a", "0x1039", 500, "WAVESHARE_RP2040_LCD_1_28", 2, "boot2_w25q16jvxq_4_padded_checksum")
# WIZnet
MakeBoard("wiznet_5100s_evb_pico", "WIZnet", "W5100S-EVB-Pico", "0x2e8a", "0x1027", 250, "WIZNET_5100S_EVB_PICO", 2, "boot2_w25q080_2_padded_checksum")
MakeBoard("wiznet_wizfi360_evb_pico", "WIZnet", "WizFi360-EVB-Pico", "0x2e8a", "0x1028", 250, "WIZNET_WIZFI360_EVB_PICO", 2, "boot2_w25q080_2_padded_checksum")
+1
View File
@@ -54,6 +54,7 @@ def scanner():
scannerGo = True
def main():
global scannerGo
while True:
cmdline = input()
cmd = cmdline.split()[0]
@@ -0,0 +1,42 @@
#pragma once
// Pin definitions taken from:
// https://learn.adafruit.com/assets/100337
// LEDs
#define PIN_LED (13u)
// NeoPixel
#define PIN_NEOPIXEL (4u)
// Serial
#define PIN_SERIAL1_TX (0u)
#define PIN_SERIAL1_RX (1u)
// Not pinned out
#define PIN_SERIAL2_TX (31u)
#define PIN_SERIAL2_RX (31u)
// SPI
#define PIN_SPI0_MISO (8u)
#define PIN_SPI0_MOSI (15u)
#define PIN_SPI0_SCK (14u)
#define PIN_SPI0_SS (13u)
// Not pinned out
#define PIN_SPI1_MISO (31u)
#define PIN_SPI1_MOSI (31u)
#define PIN_SPI1_SCK (31u)
#define PIN_SPI1_SS (31u)
// Wire
#define PIN_WIRE0_SDA (2u)
#define PIN_WIRE0_SCL (3u)
#define PIN_WIRE1_SDA (31u)
#define PIN_WIRE1_SCL (31u)
#define SERIAL_HOWMANY (2u)
#define SPI_HOWMANY (1u)
#define WIRE_HOWMANY (1u)
#include "../generic/common.h"
@@ -0,0 +1,51 @@
#pragma once
// DatanoiseTV PicoADK+ - Audio Development Kit
// Pin definitions taken from:
// https://github.com/DatanoiseTV/PicoDSP-Hardware
// LEDs
#define PIN_LED (15u)
// Debug LEDs near the USB connector
#define PIN_LED0 (2u)
#define PIN_LED1 (3u)
#define PIN_LED2 (4u)
#define PIN_LED3 (5u)
// Serial
#define PIN_SERIAL1_TX (0u)
#define PIN_SERIAL1_RX (1u)
#define PIN_SERIAL2_TX (8u)
#define PIN_SERIAL2_RX (9u)
// SPI0
#define PIN_SPI0_MISO (16u)
#define PIN_SPI0_MOSI (19u)
#define PIN_SPI0_SCK (18u)
#define PIN_SPI0_SS (17u)
// SPI1
#define PIN_SPI1_MISO (12u)
#define PIN_SPI1_MOSI (11u)
#define PIN_SPI1_SCK (10u)
#define PIN_SPI1_SS (13u)
// Wire
#define PIN_WIRE0_SDA (8u)
#define PIN_WIRE0_SCL (9u)
#define PIN_WIRE1_SDA (6u)
#define PIN_WIRE1_SCL (7u)
// I2S
#define PIN_I2S_BCLK (17u)
#define PIN_I2S_LRCLK (18u)
#define PIN_I2S_DOUT (16u)
#define SERIAL_HOWMANY (3u)
#define SPI_HOWMANY (2u)
#define WIRE_HOWMANY (2u)
#include "../generic/common.h"
+2 -2
View File
@@ -27,8 +27,8 @@
#define PIN_SPI1_SS (13u)
// Wire
#define PIN_WIRE0_SDA (6u)
#define PIN_WIRE0_SCL (7u)
#define PIN_WIRE0_SDA (16u)
#define PIN_WIRE0_SCL (17u)
#define PIN_WIRE1_SDA (14u)
#define PIN_WIRE1_SCL (15u)
@@ -0,0 +1,78 @@
#pragma once
// Waveshare RP2040 lcd 0.96
// https://www.waveshare.com/wiki/RP2040-LCD-0.96
// https://www.waveshare.com/w/upload/0/01/RP2040-LCD-0.96.pdf
// https://www.waveshare.com/img/devkit/RP2040-LCD-0.96/RP2040-LCD-0.96-details-7.jpg
//
/*
Pin# Pin#
___(_____)___
GPIO0 1 | *USB C* | 40 VBUS
GPIO1 2 | | 39 VSYS
GND 3 | | 38 GND
GPIO2 4 | | 37 3V3_EN
GPIO3 5 | | 36 3V3(OUT)
GPIO4 6 | | 35 ADC_VREF
GPIO5 7 | | 34 GPIO28
GND 8 | | 33 GND
GPIO6 9 | | 32 GPIO27
GPIO7 10 | | 31 GPIO26
GPIO8 11 | | 30 RUN
GPIO9 12 | | 29 GPIO22
GND 13 | | 28 GND
GPIO10 14 | | 27 GPIO21
GPIO11 15 | | 25 GPIO20
GPIO12 16 | | 25 GPIO19
GPIO13 17 | | 24 GPIO18
GND 18 | | 23 GND
GPIO14 19 | | 22 GPIO17
GPIO15 20 |____|_|_|____| 21 GPIO16
S G S
W N W
C D D
L I
K N
*/
// LCD
#define LDC_SPI (1u)
#define PIN_LCD_DC (8u)
#define PIN_LCD_CS (9u)
#define PIN_LCD_SCLK (10u)
#define PIN_LCD_MOSI (11u)
#define PIN_LCD_RST (12u)
#define PIN_LCD_BL (25u)
// Serial
#define PIN_SERIAL1_TX (0u)
#define PIN_SERIAL1_RX (1u)
#define PIN_SERIAL2_TX (8u)
#define PIN_SERIAL2_RX (9u)
// SPI
#define PIN_SPI0_MISO (16u)
#define PIN_SPI0_MOSI (19u)
#define PIN_SPI0_SCK (18u)
#define PIN_SPI0_SS (17u)
#define PIN_SPI1_MISO (12u)
#define PIN_SPI1_MOSI (15u)
#define PIN_SPI1_SCK (14u)
#define PIN_SPI1_SS (13u)
// Wire
#define PIN_WIRE0_SDA (8u)
#define PIN_WIRE0_SCL (9u)
#define PIN_WIRE1_SDA (6u)
#define PIN_WIRE1_SCL (7u)
#define SERIAL_HOWMANY (3u)
#define SPI_HOWMANY (2u)
#define WIRE_HOWMANY (2u)
#include "../generic/common.h"
@@ -0,0 +1,70 @@
#pragma once
// Waveshare RP2040 LCD 1.28
// https://www.waveshare.com/wiki/RP2040-LCD-1.28
// https://www.waveshare.com/w/upload/6/60/RP2040-LCD-1.28-sch.pdf
// https://www.waveshare.com/img/devkit/RP2040-LCD-1.28/RP2040-LCD-1.28-details-3.jpg
//
/*
H1 H2
Pin# Pin# Pin# Pin#
GPIO8 1 2 GPIO0 GND 1 2 GND
GPIO9 3 4 GPIO1 VSYS 3 4 ADC_AVDD
GPIO10 5 6 GPIO2 GPIO23 5 6 BOOT
GPIO11 7 8 GPIO3 GPIO22 7 8 RUM
GPIO12 9 10 GPIO4 GPIO21 9 10 GPIO29
GPIO13 11 12 GPIO5 GPIO20 11 12 GPIO28
GPIO14 13 14 GPIO6 GPIO19 13 14 GPIO27
GPIO15 15 16 GPIO7 GPIO18 15 16 GPIO26
SWCLK 17 18 VSYS GPIO17 17 18 GPIO25
SWDIP 19 20 GND GPIO16 19 20 GPIO24
*/
// LCD
#define LDC_SPI (1u)
#define PIN_LCD_DC (8u)
#define PIN_LCD_CS (9u)
#define PIN_LCD_SCLK (10u)
#define PIN_LCD_MOSI (11u)
#define PIN_LCD_RST (12u)
#define PIN_LCD_BL (25u)
// BAT_ADC
#define PIN_BAT_ADC (25u)
// IMU
#define PIN_IMU_SDA (6u)
#define PIN_IMU_SCL (7u)
#define PIN_IMU_INT1 (23u)
#define PIN_IMU_INT2 (24u)
// Serial
#define PIN_SERIAL1_TX (0u)
#define PIN_SERIAL1_RX (1u)
#define PIN_SERIAL2_TX (8u)
#define PIN_SERIAL2_RX (9u)
// SPI
#define PIN_SPI0_MISO (16u)
#define PIN_SPI0_MOSI (19u)
#define PIN_SPI0_SCK (18u)
#define PIN_SPI0_SS (17u)
#define PIN_SPI1_MISO (12u)
#define PIN_SPI1_MOSI (15u)
#define PIN_SPI1_SCK (14u)
#define PIN_SPI1_SS (13u)
// Wire
#define PIN_WIRE0_SDA (8u)
#define PIN_WIRE0_SCL (9u)
#define PIN_WIRE1_SDA (6u)
#define PIN_WIRE1_SCL (7u)
#define SERIAL_HOWMANY (3u)
#define SPI_HOWMANY (2u)
#define WIRE_HOWMANY (2u)
#include "../generic/common.h"
@@ -0,0 +1,65 @@
#pragma once
// Waveshare RP2040 One
// https://www.waveshare.com/wiki/RP2040-One
// https://www.waveshare.com/w/upload/9/90/RP2040-One.pdf
// https://www.waveshare.com/img/devkit/RP2040-One/RP2040-One-details-9.jpg
/*
Pin# Pin#
_____
|USB A|
___| |___
5v 1 | | 23 GPIO0
GND 2 | | 22 GPIO1
3.3v 3 | | 21 GPIO2
GPIO29 4 | | 20 GPIO3
GPIO28 5 | | 19 GPIO4
GPIO27 6 | | 18 GPIO5
GPIO26 7 | | 17 GPIO6
GPIO15 8 | | 16 GPIO7
GPIO14 9 |__|_|_|_|_|__| 15 GPIO8
1 1 1 1 1
0 1 2 3 4
Pin10 = GPIO13
Pin11 = GPIO12
Pin12 = GPIO11
Pin13 = GPIO10
Pin14 = GPIO9
*/
// NeoPixel
#define PIN_NEOPIXEL (16u)
//#define LED_BUILTIN PIN_NEOPIXEL
// Serial1
#define PIN_SERIAL1_TX (0u)
#define PIN_SERIAL1_RX (1u)
#define PIN_SERIAL2_TX (8u)
#define PIN_SERIAL2_RX (9u)
// SPI
#define PIN_SPI0_MISO (4u)
#define PIN_SPI0_MOSI (3u)
#define PIN_SPI0_SCK (2u)
#define PIN_SPI0_SS (5u)
#define PIN_SPI1_MISO (12u)
#define PIN_SPI1_MOSI (15u)
#define PIN_SPI1_SCK (14u)
#define PIN_SPI1_SS (13u)
// Wire
#define PIN_WIRE0_SDA (4u)
#define PIN_WIRE0_SCL (5u)
#define PIN_WIRE1_SDA (26u)
#define PIN_WIRE1_SCL (27u)
#define SERIAL_HOWMANY (2u)
#define SPI_HOWMANY (2u)
#define WIRE_HOWMANY (2u)
#include "../generic/common.h"
@@ -0,0 +1,72 @@
#pragma once
// Waveshare RP2040 Plus
// https://www.waveshare.com/wiki/RP2040-Plus
// https://www.waveshare.com/w/upload/d/d1/RP2040_Plus.pdf
// https://www.waveshare.com/img/devkit/RP2040-Plus/RP2040-Plus-details-7.jpg
//
/*
Pin# Pin#
___(_____)___
GPIO0 1 | *USB C* | 40 VBUS
GPIO1 2 | | 39 VSYS
GND 3 | | 38 GND
GPIO2 4 | | 37 3V3_EN
GPIO3 5 | | 36 3V3(OUT)
GPIO4 6 | | 35 ADC_VREF
GPIO5 7 | | 34 GPIO28
GND 8 | | 33 GND
GPIO6 9 | | 32 GPIO27
GPIO7 10 | | 31 GPIO26
GPIO8 11 | | 30 RUN
GPIO9 12 | | 29 GPIO22
GND 13 | | 28 GND
GPIO10 14 | | 27 GPIO21
GPIO11 15 | | 25 GPIO20
GPIO12 16 | | 25 GPIO19
GPIO13 17 | | 24 GPIO18
GND 18 | | 23 GND
GPIO14 19 | | 22 GPIO17
GPIO15 20 |____|_|_|____| 21 GPIO16
S G S
W N W
C D D
L I
K N
*/
// LEDs
#define PIN_LED (25u)
// Serial
#define PIN_SERIAL1_TX (0u)
#define PIN_SERIAL1_RX (1u)
#define PIN_SERIAL2_TX (8u)
#define PIN_SERIAL2_RX (9u)
// SPI
#define PIN_SPI0_MISO (16u)
#define PIN_SPI0_MOSI (19u)
#define PIN_SPI0_SCK (18u)
#define PIN_SPI0_SS (17u)
#define PIN_SPI1_MISO (12u)
#define PIN_SPI1_MOSI (15u)
#define PIN_SPI1_SCK (14u)
#define PIN_SPI1_SS (13u)
// Wire
#define PIN_WIRE0_SDA (8u)
#define PIN_WIRE0_SCL (9u)
#define PIN_WIRE1_SDA (6u)
#define PIN_WIRE1_SCL (7u)
#define SERIAL_HOWMANY (3u)
#define SPI_HOWMANY (2u)
#define WIRE_HOWMANY (2u)
#include "../generic/common.h"
@@ -0,0 +1,72 @@
#pragma once
// Waveshare RP2040 Plus
// https://www.waveshare.com/wiki/RP2040-Plus
// https://www.waveshare.com/w/upload/d/d1/RP2040_Plus.pdf
// https://www.waveshare.com/img/devkit/RP2040-Plus/RP2040-Plus-details-7.jpg
//
/*
Pin# Pin#
___(_____)___
GPIO0 1 | *USB C* | 40 VBUS
GPIO1 2 | | 39 VSYS
GND 3 | | 38 GND
GPIO2 4 | | 37 3V3_EN
GPIO3 5 | | 36 3V3(OUT)
GPIO4 6 | | 35 ADC_VREF
GPIO5 7 | | 34 GPIO28
GND 8 | | 33 GND
GPIO6 9 | | 32 GPIO27
GPIO7 10 | | 31 GPIO26
GPIO8 11 | | 30 RUN
GPIO9 12 | | 29 GPIO22
GND 13 | | 28 GND
GPIO10 14 | | 27 GPIO21
GPIO11 15 | | 25 GPIO20
GPIO12 16 | | 25 GPIO19
GPIO13 17 | | 24 GPIO18
GND 18 | | 23 GND
GPIO14 19 | | 22 GPIO17
GPIO15 20 |____|_|_|____| 21 GPIO16
S G S
W N W
C D D
L I
K N
*/
// LEDs
#define PIN_LED (25u)
// Serial
#define PIN_SERIAL1_TX (0u)
#define PIN_SERIAL1_RX (1u)
#define PIN_SERIAL2_TX (8u)
#define PIN_SERIAL2_RX (9u)
// SPI
#define PIN_SPI0_MISO (16u)
#define PIN_SPI0_MOSI (19u)
#define PIN_SPI0_SCK (18u)
#define PIN_SPI0_SS (17u)
#define PIN_SPI1_MISO (12u)
#define PIN_SPI1_MOSI (15u)
#define PIN_SPI1_SCK (14u)
#define PIN_SPI1_SS (13u)
// Wire
#define PIN_WIRE0_SDA (8u)
#define PIN_WIRE0_SCL (9u)
#define PIN_WIRE1_SDA (6u)
#define PIN_WIRE1_SCL (7u)
#define SERIAL_HOWMANY (3u)
#define SPI_HOWMANY (2u)
#define WIRE_HOWMANY (2u)
#include "../generic/common.h"
@@ -0,0 +1,66 @@
#pragma once
// Waveshare RP2040 Zero
// https://www.waveshare.com/wiki/RP2040-Zero
// https://www.waveshare.com/w/upload/4/4c/RP2040_Zero.pdf
// https://www.waveshare.com/img/devkit/RP2040-Zero/RP2040-Zero-details-7.jpg
//
// https://www.mischianti.org/2022/09/19/waveshare-rp2040-zero-high-resolution-pinout-and-specs/
// https://www.mischianti.org/wp-content/uploads/2022/09/Waveshare-rp2040-zero-Raspberry-Pi-Pico-alternative-pinout.jpg
/*
Pin# Pin#
___(_____)___
5v 1 | *USB C* | 23 GPIO0
GND 2 | | 22 GPIO1
3.3v 3 | | 21 GPIO2
GPIO29 4 | | 20 GPIO3
GPIO28 5 | | 19 GPIO4
GPIO27 6 | | 18 GPIO5
GPIO26 7 | | 17 GPIO6
GPIO15 8 | | 16 GPIO7
GPIO14 9 |__|_|_|_|_|__| 15 GPIO8
1 1 1 1 1
0 1 2 3 4
Pin10 = GPIO13
Pin11 = GPIO12
Pin12 = GPIO11
Pin13 = GPIO10
Pin14 = GPIO9
*/
// NeoPixel
#define PIN_NEOPIXEL (16u)
//#define LED_BUILTIN PIN_NEOPIXEL
// Serial1
#define PIN_SERIAL1_TX (0u)
#define PIN_SERIAL1_RX (1u)
#define PIN_SERIAL2_TX (8u)
#define PIN_SERIAL2_RX (9u)
// SPI
#define PIN_SPI0_MISO (4u)
#define PIN_SPI0_MOSI (3u)
#define PIN_SPI0_SCK (2u)
#define PIN_SPI0_SS (5u)
#define PIN_SPI1_MISO (12u)
#define PIN_SPI1_MOSI (15u)
#define PIN_SPI1_SCK (14u)
#define PIN_SPI1_SS (13u)
// Wire
#define PIN_WIRE0_SDA (4u)
#define PIN_WIRE0_SCL (5u)
#define PIN_WIRE1_SDA (26u)
#define PIN_WIRE1_SCL (27u)
#define SERIAL_HOWMANY (2u)
#define SPI_HOWMANY (2u)
#define WIRE_HOWMANY (2u)
#include "../generic/common.h"