Compare commits
@@ -18,13 +18,13 @@ jobs:
|
||||
name: Check spelling
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
- 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,./.git
|
||||
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,./libraries/FatFS/lib/fatfs,./libraries/FatFS/src/diskio.h,./libraries/FatFS/src/ff.cpp,./libraries/FatFS/src/ffconf.h,./libraries/FatFS/src/ffsystem.cpp,./libraries/FatFS/src/ff.h
|
||||
ignore_words_list: ser,dout
|
||||
|
||||
# Consistent style
|
||||
@@ -32,7 +32,7 @@ jobs:
|
||||
name: Style, Boards, Package
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: false
|
||||
- name: Check package references
|
||||
@@ -59,15 +59,15 @@ jobs:
|
||||
matrix:
|
||||
chunk: [0, 1, 2, 3, 4, 5]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
- uses: actions/setup-python@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- name: Cache Linux toolchain
|
||||
id: cache-linux
|
||||
uses: actions/cache@v3
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ./tools/dist
|
||||
key: ${{ runner.os }}-${{ hashFiles('package/package_pico_index.template.json', 'tests/common.sh') }}
|
||||
@@ -87,15 +87,15 @@ jobs:
|
||||
name: Build TinyUSB Examples
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
- uses: actions/setup-python@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- name: Cache Linux toolchain
|
||||
id: cache-linux
|
||||
uses: actions/cache@v3
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ./tools/dist
|
||||
key: ${{ runner.os }}-${{ hashFiles('package/package_pico_index.template.json', 'tests/common.sh') }}
|
||||
@@ -113,15 +113,15 @@ jobs:
|
||||
name: Windows
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
- uses: actions/setup-python@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- name: Cache Windows toolchain
|
||||
id: cache-windows
|
||||
uses: actions/cache@v3
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ./tools/dist
|
||||
key: ${{ runner.os }}-${{ hashFiles('package/package_pico_index.template.json', 'tests/common.sh') }}
|
||||
@@ -144,17 +144,20 @@ jobs:
|
||||
# Single build under macOS to ensure the Mac toolchain is good.
|
||||
build-mac:
|
||||
name: Mac
|
||||
runs-on: macOS-12
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macOS-12, macOS-14]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
- uses: actions/setup-python@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- name: Cache Mac toolchain
|
||||
id: cache-mac
|
||||
uses: actions/cache@v3
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ./tools/dist
|
||||
key: ${{ runner.os }}-${{ hashFiles('package/package_pico_index.template.json', 'tests/common.sh') }}
|
||||
@@ -165,6 +168,7 @@ jobs:
|
||||
mod: 500
|
||||
rem: 1
|
||||
run: |
|
||||
uname -a
|
||||
cd pico-sdk
|
||||
git submodule update --init
|
||||
cd ..
|
||||
@@ -175,7 +179,7 @@ jobs:
|
||||
name: Build PlatformIO Examples
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: 'true'
|
||||
- name: Initialize needed submodules
|
||||
@@ -186,19 +190,19 @@ jobs:
|
||||
git submodule update --init
|
||||
cd ../..
|
||||
- name: Cache pip
|
||||
uses: actions/cache@v3
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cache/pip
|
||||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pip-
|
||||
- name: Cache PlatformIO
|
||||
uses: actions/cache@v3
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.platformio
|
||||
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v4
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- name: Install PlatformIO
|
||||
|
||||
@@ -9,21 +9,21 @@ jobs:
|
||||
name: Update master JSON file
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
- name: Cache pip
|
||||
uses: actions/cache@v3
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cache/pip
|
||||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pip-
|
||||
- uses: actions/setup-python@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.x'
|
||||
# - name: Cache PlatformIO
|
||||
# uses: actions/cache@v3
|
||||
# uses: actions/cache@v4
|
||||
# with:
|
||||
# path: ~/.platformio
|
||||
# key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
|
||||
|
||||
@@ -15,11 +15,11 @@ jobs:
|
||||
name: Package
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
fetch-depth: 0
|
||||
- uses: actions/setup-python@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- name: Build package JSON
|
||||
|
||||
@@ -37,3 +37,6 @@
|
||||
[submodule "libraries/http_parser/lib/http-parser"]
|
||||
path = libraries/http-parser/lib/http-parser
|
||||
url = https://github.com/nodejs/http-parser.git
|
||||
[submodule "libraries/FatFS/lib/SPIFTL"]
|
||||
path = libraries/FatFS/lib/SPIFTL
|
||||
url = https://github.com/earlephilhower/SPIFTL.git
|
||||
|
||||
@@ -30,6 +30,7 @@ Read the [Contributing Guide](https://github.com/earlephilhower/arduino-pico/blo
|
||||
* BridgeTek IDM2040-7A
|
||||
* Cytron Maker Pi RP2040
|
||||
* Cytron Maker Nano RP2040
|
||||
* Cytron Maker Uno RP2040
|
||||
* DatanoiseTV PicoADK+
|
||||
* Degz Suibo RP2040
|
||||
* DeRuiLab FlyBoard2040 Core
|
||||
@@ -76,6 +77,34 @@ Read the [Contributing Guide](https://github.com/earlephilhower/arduino-pico/blo
|
||||
* WIZnet WizFi360-EVB-Pico
|
||||
* Generic (configurable flash, I/O pins)
|
||||
|
||||
# Features
|
||||
* Adafruit TinyUSB Arduino (USB mouse, keyboard, flash drive, generic HID, CDC Serial, MIDI, WebUSB, others)
|
||||
* Bluetooth on the PicoW (Classic and BLE) with Keyboard, Mouse, Joystick, and Virtual Serial
|
||||
* Generic Arduino USB Serial, Keyboard, Joystick, and Mouse emulation
|
||||
* WiFi (Pico W)
|
||||
* Ethernet (Wired W5500, W5100, ENC28J60)
|
||||
* HTTP client and server (WebServer)
|
||||
* SSL/TLS/HTTPS
|
||||
* Over-the-Air (OTA) upgrades
|
||||
* Filesystems (LittleFS and SD/SDFS)
|
||||
* Multicore support (setup1() and loop1())
|
||||
* FreeRTOS SMP support
|
||||
* Overclocking and underclocking from the menus
|
||||
* digitalWrite/Read, shiftIn/Out, tone, analogWrite(PWM)/Read, temperature
|
||||
* Analog stereo audio in using DMA and the built-in ADC
|
||||
* Analog stereo audio out using PWM hardware
|
||||
* USB drive mode for data loggers (SingleFileDrive)
|
||||
* Peripherals: SPI master/slave, Wire(I2C) master/slave, dual UART, emulated EEPROM, I2S audio input/output, Servo
|
||||
* printf (i.e. debug) output over USB serial
|
||||
|
||||
The RP2040 PIO state machines (SMs) are used to generate jitter-free:
|
||||
* Servos
|
||||
* Tones
|
||||
* I2S Input
|
||||
* I2S Output
|
||||
* Software UARTs (Serial ports)
|
||||
|
||||
|
||||
# Installing via Arduino Boards Manager
|
||||
## Windows-specific Notes
|
||||
Please do not use the Windows Store version of the actual Arduino application
|
||||
@@ -173,11 +202,14 @@ Under Windows a local admin user should be able to access the Picoprobe port aut
|
||||
|
||||
To set up user-level access to Picoprobes on Ubuntu (and other OSes which use `udev`):
|
||||
````
|
||||
echo 'SUBSYSTEMS=="usb", ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="0004", GROUP="users", MODE="0666"' | sudo tee -a /etc/udev/rules.d/98-PicoProbe.rules
|
||||
echo 'SUBSYSTEMS=="usb", ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="0004", MODE="0666"' | sudo tee -a /etc/udev/rules.d/98-PicoProbe.rules
|
||||
sudo udevadm control --reload
|
||||
sudo udevadm trigger -w -s usb
|
||||
````
|
||||
|
||||
The first line creates a file with the USB vendor and ID of the Picoprobe and tells UDEV to give users full access to it. The second causes `udev` to load this new rule. Note that you will need to unplug and re-plug in your device the first time you create this file, to allow udev to make the device node properly.
|
||||
The first line creates a device file in `/dev` matching the USB vendor and product ID of the Picoprobe, and it enables global read+write permissions. The second line causes `udev` to load this new rule. The third line requests the kernel generate "device change" events that will cause our new `udev` rule to run.
|
||||
|
||||
If for some reason the device file does not appear, manually unplug and re-plug the USB connection and check again. The output from `dmesg` can reveal useful diagnostics if the device file remains absent.
|
||||
|
||||
Once Picoprobe permissions are set up properly, then select the board "Raspberry Pi Pico (Picoprobe)" in the Tools menu and upload as normal.
|
||||
|
||||
@@ -186,13 +218,16 @@ Once Picoprobe permissions are set up properly, then select the board "Raspberry
|
||||
|
||||
Under Windows and macOS, any user should be able to access pico-debug automatically, but under Linux `udev` must be told about the device and to allow normal users access.
|
||||
|
||||
To set up user-level access to all CMSIS-DAP adapters on Ubuntu (and other OSes which use `udev`):
|
||||
To set up group-level access to all CMSIS-DAP adapters on Ubuntu (and other OSes which use `udev`):
|
||||
````
|
||||
echo 'ATTRS{product}=="*CMSIS-DAP*", MODE="664", GROUP="plugdev"' | sudo tee -a /etc/udev/rules.d/98-CMSIS-DAP.rules
|
||||
sudo udevadm control --reload
|
||||
sudo udevadm trigger -w -s usb
|
||||
````
|
||||
|
||||
The first line creates a file that recognizes all CMSIS-DAP adapters and tells UDEV to give users full access to it. The second causes `udev` to load this new rule. Note that you will need to unplug and re-plug in your device the first time you create this file, to allow udev to make the device node properly.
|
||||
The first line creates a device file in `/dev` that matches all CMSIS-DAP adapters, and it enables read+write permissions for members of the `plugdev` group. The second line causes `udev` to load this new rule. The third line requests the kernel generate "device change" events that will cause our new `udev` rule to run.
|
||||
|
||||
If for some reason the device file does not appear, manually unplug and re-plug the USB connection and check again. The output from `dmesg` can reveal useful diagnostics if the device file remains absent.
|
||||
|
||||
Once CMSIS-DAP permissions are set up properly, then select the board "Raspberry Pi Pico (pico-debug)" in the Tools menu.
|
||||
|
||||
@@ -201,48 +236,6 @@ When first connecting the USB port to your PC, you must copy [pico-debug-gimmeca
|
||||
# Debugging with Picoprobe/pico-debug, OpenOCD, and GDB
|
||||
The installed tools include a version of OpenOCD (in the pqt-openocd directory) and GDB (in the pqt-gcc directory). These may be used to run GDB in an interactive window as documented in the Pico Getting Started manuals from the Raspberry Pi Foundation. For [pico-debug](https://github.com/majbthrd/pico-debug/), replace the raspberrypi-swd and picoprobe example OpenOCD arguments of "-f interface/raspberrypi-swd.cfg -f target/rp2040.cfg" or "-f interface/picoprobe.cfg -f target/rp2040.cfg" respectively in the Pico Getting Started manual with "-f board/pico-debug.cfg".
|
||||
|
||||
# Features
|
||||
* Adafruit TinyUSB Arduino (USB mouse, keyboard, flash drive, generic HID, CDC Serial, MIDI, WebUSB, others)
|
||||
* Bluetooth on the PicoW (Classic and BLE) with Keyboard, Mouse, Joystick, and Virtual Serial
|
||||
* Generic Arduino USB Serial, Keyboard, Joystick, and Mouse emulation
|
||||
* WiFi (Pico W)
|
||||
* Ethernet (Wired W5500, W5100, ENC28J60)
|
||||
* HTTP client and server (WebServer)
|
||||
* SSL/TLS/HTTPS
|
||||
* Over-the-Air (OTA) upgrades
|
||||
* Filesystems (LittleFS and SD/SDFS)
|
||||
* Multicore support (setup1() and loop1())
|
||||
* FreeRTOS SMP support
|
||||
* Overclocking and underclocking from the menus
|
||||
* digitalWrite/Read, shiftIn/Out, tone, analogWrite(PWM)/Read, temperature
|
||||
* Analog stereo audio in using DMA and the built-in ADC
|
||||
* Analog stereo audio out using PWM hardware
|
||||
* USB drive mode for data loggers (SingleFileDrive)
|
||||
* Peripherals: SPI master/slave, Wire(I2C) master/slave, dual UART, emulated EEPROM, I2S audio input/output, Servo
|
||||
* printf (i.e. debug) output over USB serial
|
||||
|
||||
The RP2040 PIO state machines (SMs) are used to generate jitter-free:
|
||||
* Servos
|
||||
* Tones
|
||||
* I2S Input
|
||||
* I2S Output
|
||||
* Software UARTs (Serial ports)
|
||||
|
||||
# Tutorials from Across the Web
|
||||
Here are some links to coverage and additional tutorials for using `arduino-pico`
|
||||
* The File:: class is taken from the ESP8266. See https://arduino-esp8266.readthedocs.io/en/latest/filesystem.html
|
||||
* Arduino Support for the Pi Pico available! And how fast is the Pico? - https://youtu.be/-XHh17cuH5E
|
||||
* Pre-release Adafruit QT Py RP2040 - https://www.youtube.com/watch?v=sfC1msqXX0I
|
||||
* Adafruit Feather RP2040 running LCD + TMP117 - https://www.youtube.com/watch?v=fKDeqZiIwHg
|
||||
* Demonstration of Servos and I2C in Korean - https://cafe.naver.com/arduinoshield/1201
|
||||
* Home Assistant Pico W integration starter project using Arduino - https://github.com/daniloc/PicoW_HomeAssistant_Starter
|
||||
* Tutorials for the Raspberry Pi Pico / uPesy RP2040 DevKit board
|
||||
- English version: https://www.upesy.com/blogs/tutorials/best-tutorials-for-rpi-pi-pico-with-arduino-code
|
||||
- French version: https://www.upesy.fr/blogs/tutorials/best-tutorials-for-rpi-pi-pico-with-arduino-code
|
||||
|
||||
# Contributing
|
||||
If you want to contribute or have bugfixes, drop me a note at <earlephilhower@yahoo.com> or open an issue/PR here.
|
||||
|
||||
# Licensing and Credits
|
||||
* The [Arduino IDE and ArduinoCore-API](https://arduino.cc) are developed and maintained by the Arduino team. The IDE is licensed under GPL.
|
||||
* The [RP2040 GCC-based toolchain](https://github.com/earlephilhower/pico-quick-toolchain) is licensed under under the GPL.
|
||||
@@ -260,6 +253,8 @@ If you want to contribute or have bugfixes, drop me a note at <earlephilhower@ya
|
||||
* [http-parser](https://github.com/nodejs/http-parser) is copyright Joyent, Inc. and other Node contributors.
|
||||
* WebServer code modified from the [ESP32 WebServer](https://github.com/espressif/arduino-esp32/tree/master/libraries/WebServer) and is copyright (c) 2015 Ivan Grokhotkov and others.
|
||||
* [Xoshiro-cpp](https://github.com/Reputeless/Xoshiro-cpp) is copyright (c) 2020 Ryo Suzuki and distributed under the MIT license.
|
||||
* [FatFS low-level filesystem](http://elm-chan.org/fsw/ff/) code is Copyright (C) 2024, ChaN, all rights reserved.
|
||||
|
||||
|
||||
-Earle F. Philhower, III
|
||||
earlephilhower@yahoo.com
|
||||
|
||||
+1996
-74
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#define ARDUINO_PICO_MAJOR 3
|
||||
#define ARDUINO_PICO_MINOR 6
|
||||
#define ARDUINO_PICO_REVISION 3
|
||||
#define ARDUINO_PICO_VERSION_STR "3.6.3"
|
||||
#define ARDUINO_PICO_MINOR 8
|
||||
#define ARDUINO_PICO_REVISION 0
|
||||
#define ARDUINO_PICO_VERSION_STR "3.8.0"
|
||||
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
using Print::write;
|
||||
operator bool() override;
|
||||
|
||||
// Not to be called by users, only from the IRQ handler. In public so that the C-language IQR callback can access it
|
||||
// Not to be called by users, only from the IRQ handler. In public so that the C-language IRQ callback can access it
|
||||
void _handleIRQ();
|
||||
|
||||
protected:
|
||||
|
||||
@@ -201,7 +201,7 @@ void SerialUART::begin(unsigned long baud, uint16_t config) {
|
||||
break;
|
||||
}
|
||||
uart_set_format(_uart, bits, stop, parity);
|
||||
uart_set_hw_flow(_uart, _rts != UART_PIN_NOT_DEFINED, _cts != UART_PIN_NOT_DEFINED);
|
||||
uart_set_hw_flow(_uart, _cts != UART_PIN_NOT_DEFINED, _rts != UART_PIN_NOT_DEFINED);
|
||||
_writer = 0;
|
||||
_reader = 0;
|
||||
|
||||
|
||||
@@ -0,0 +1,474 @@
|
||||
|
||||
// autogenerated from https://raw.githubusercontent.com/nayarsystems/posix_tz_db/master/zones.csv
|
||||
// by script <rp2040 arduino core>/tools/tzupdate.sh
|
||||
// Sat 20 Jan 2024 08:54:45 PM UTC
|
||||
//
|
||||
// This database is autogenerated from IANA timezone database
|
||||
// https://raw.githubusercontent.com/nayarsystems/posix_tz_db/master/zones.csv
|
||||
// (using https://www.iana.org/time-zones)
|
||||
// and can be updated on demand in this repository
|
||||
// or by yourself using the above script
|
||||
|
||||
#pragma once
|
||||
|
||||
#define TZ_Africa_Abidjan ("GMT0")
|
||||
#define TZ_Africa_Accra ("GMT0")
|
||||
#define TZ_Africa_Addis_Ababa ("EAT-3")
|
||||
#define TZ_Africa_Algiers ("CET-1")
|
||||
#define TZ_Africa_Asmara ("EAT-3")
|
||||
#define TZ_Africa_Bamako ("GMT0")
|
||||
#define TZ_Africa_Bangui ("WAT-1")
|
||||
#define TZ_Africa_Banjul ("GMT0")
|
||||
#define TZ_Africa_Bissau ("GMT0")
|
||||
#define TZ_Africa_Blantyre ("CAT-2")
|
||||
#define TZ_Africa_Brazzaville ("WAT-1")
|
||||
#define TZ_Africa_Bujumbura ("CAT-2")
|
||||
#define TZ_Africa_Cairo ("EET-2EEST,M4.5.5/0,M10.5.4/24")
|
||||
#define TZ_Africa_Casablanca ("<+01>-1")
|
||||
#define TZ_Africa_Ceuta ("CET-1CEST,M3.5.0,M10.5.0/3")
|
||||
#define TZ_Africa_Conakry ("GMT0")
|
||||
#define TZ_Africa_Dakar ("GMT0")
|
||||
#define TZ_Africa_Dar_es_Salaam ("EAT-3")
|
||||
#define TZ_Africa_Djibouti ("EAT-3")
|
||||
#define TZ_Africa_Douala ("WAT-1")
|
||||
#define TZ_Africa_El_Aaiun ("<+01>-1")
|
||||
#define TZ_Africa_Freetown ("GMT0")
|
||||
#define TZ_Africa_Gaborone ("CAT-2")
|
||||
#define TZ_Africa_Harare ("CAT-2")
|
||||
#define TZ_Africa_Johannesburg ("SAST-2")
|
||||
#define TZ_Africa_Juba ("CAT-2")
|
||||
#define TZ_Africa_Kampala ("EAT-3")
|
||||
#define TZ_Africa_Khartoum ("CAT-2")
|
||||
#define TZ_Africa_Kigali ("CAT-2")
|
||||
#define TZ_Africa_Kinshasa ("WAT-1")
|
||||
#define TZ_Africa_Lagos ("WAT-1")
|
||||
#define TZ_Africa_Libreville ("WAT-1")
|
||||
#define TZ_Africa_Lome ("GMT0")
|
||||
#define TZ_Africa_Luanda ("WAT-1")
|
||||
#define TZ_Africa_Lubumbashi ("CAT-2")
|
||||
#define TZ_Africa_Lusaka ("CAT-2")
|
||||
#define TZ_Africa_Malabo ("WAT-1")
|
||||
#define TZ_Africa_Maputo ("CAT-2")
|
||||
#define TZ_Africa_Maseru ("SAST-2")
|
||||
#define TZ_Africa_Mbabane ("SAST-2")
|
||||
#define TZ_Africa_Mogadishu ("EAT-3")
|
||||
#define TZ_Africa_Monrovia ("GMT0")
|
||||
#define TZ_Africa_Nairobi ("EAT-3")
|
||||
#define TZ_Africa_Ndjamena ("WAT-1")
|
||||
#define TZ_Africa_Niamey ("WAT-1")
|
||||
#define TZ_Africa_Nouakchott ("GMT0")
|
||||
#define TZ_Africa_Ouagadougou ("GMT0")
|
||||
#define TZ_Africa_PortomNovo ("WAT-1")
|
||||
#define TZ_Africa_Sao_Tome ("GMT0")
|
||||
#define TZ_Africa_Tripoli ("EET-2")
|
||||
#define TZ_Africa_Tunis ("CET-1")
|
||||
#define TZ_Africa_Windhoek ("CAT-2")
|
||||
#define TZ_America_Adak ("HST10HDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Anchorage ("AKST9AKDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Anguilla ("AST4")
|
||||
#define TZ_America_Antigua ("AST4")
|
||||
#define TZ_America_Araguaina ("<-03>3")
|
||||
#define TZ_America_Argentina_Buenos_Aires ("<-03>3")
|
||||
#define TZ_America_Argentina_Catamarca ("<-03>3")
|
||||
#define TZ_America_Argentina_Cordoba ("<-03>3")
|
||||
#define TZ_America_Argentina_Jujuy ("<-03>3")
|
||||
#define TZ_America_Argentina_La_Rioja ("<-03>3")
|
||||
#define TZ_America_Argentina_Mendoza ("<-03>3")
|
||||
#define TZ_America_Argentina_Rio_Gallegos ("<-03>3")
|
||||
#define TZ_America_Argentina_Salta ("<-03>3")
|
||||
#define TZ_America_Argentina_San_Juan ("<-03>3")
|
||||
#define TZ_America_Argentina_San_Luis ("<-03>3")
|
||||
#define TZ_America_Argentina_Tucuman ("<-03>3")
|
||||
#define TZ_America_Argentina_Ushuaia ("<-03>3")
|
||||
#define TZ_America_Aruba ("AST4")
|
||||
#define TZ_America_Asuncion ("<-04>4<-03>,M10.1.0/0,M3.4.0/0")
|
||||
#define TZ_America_Atikokan ("EST5")
|
||||
#define TZ_America_Bahia ("<-03>3")
|
||||
#define TZ_America_Bahia_Banderas ("CST6")
|
||||
#define TZ_America_Barbados ("AST4")
|
||||
#define TZ_America_Belem ("<-03>3")
|
||||
#define TZ_America_Belize ("CST6")
|
||||
#define TZ_America_BlancmSablon ("AST4")
|
||||
#define TZ_America_Boa_Vista ("<-04>4")
|
||||
#define TZ_America_Bogota ("<-05>5")
|
||||
#define TZ_America_Boise ("MST7MDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Cambridge_Bay ("MST7MDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Campo_Grande ("<-04>4")
|
||||
#define TZ_America_Cancun ("EST5")
|
||||
#define TZ_America_Caracas ("<-04>4")
|
||||
#define TZ_America_Cayenne ("<-03>3")
|
||||
#define TZ_America_Cayman ("EST5")
|
||||
#define TZ_America_Chicago ("CST6CDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Chihuahua ("CST6")
|
||||
#define TZ_America_Costa_Rica ("CST6")
|
||||
#define TZ_America_Creston ("MST7")
|
||||
#define TZ_America_Cuiaba ("<-04>4")
|
||||
#define TZ_America_Curacao ("AST4")
|
||||
#define TZ_America_Danmarkshavn ("GMT0")
|
||||
#define TZ_America_Dawson ("MST7")
|
||||
#define TZ_America_Dawson_Creek ("MST7")
|
||||
#define TZ_America_Denver ("MST7MDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Detroit ("EST5EDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Dominica ("AST4")
|
||||
#define TZ_America_Edmonton ("MST7MDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Eirunepe ("<-05>5")
|
||||
#define TZ_America_El_Salvador ("CST6")
|
||||
#define TZ_America_Fortaleza ("<-03>3")
|
||||
#define TZ_America_Fort_Nelson ("MST7")
|
||||
#define TZ_America_Glace_Bay ("AST4ADT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Godthab ("<-02>2<-01>,M3.5.0/-1,M10.5.0/0")
|
||||
#define TZ_America_Goose_Bay ("AST4ADT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Grand_Turk ("EST5EDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Grenada ("AST4")
|
||||
#define TZ_America_Guadeloupe ("AST4")
|
||||
#define TZ_America_Guatemala ("CST6")
|
||||
#define TZ_America_Guayaquil ("<-05>5")
|
||||
#define TZ_America_Guyana ("<-04>4")
|
||||
#define TZ_America_Halifax ("AST4ADT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Havana ("CST5CDT,M3.2.0/0,M11.1.0/1")
|
||||
#define TZ_America_Hermosillo ("MST7")
|
||||
#define TZ_America_Indiana_Indianapolis ("EST5EDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Indiana_Knox ("CST6CDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Indiana_Marengo ("EST5EDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Indiana_Petersburg ("EST5EDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Indiana_Tell_City ("CST6CDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Indiana_Vevay ("EST5EDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Indiana_Vincennes ("EST5EDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Indiana_Winamac ("EST5EDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Inuvik ("MST7MDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Iqaluit ("EST5EDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Jamaica ("EST5")
|
||||
#define TZ_America_Juneau ("AKST9AKDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Kentucky_Louisville ("EST5EDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Kentucky_Monticello ("EST5EDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Kralendijk ("AST4")
|
||||
#define TZ_America_La_Paz ("<-04>4")
|
||||
#define TZ_America_Lima ("<-05>5")
|
||||
#define TZ_America_Los_Angeles ("PST8PDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Lower_Princes ("AST4")
|
||||
#define TZ_America_Maceio ("<-03>3")
|
||||
#define TZ_America_Managua ("CST6")
|
||||
#define TZ_America_Manaus ("<-04>4")
|
||||
#define TZ_America_Marigot ("AST4")
|
||||
#define TZ_America_Martinique ("AST4")
|
||||
#define TZ_America_Matamoros ("CST6CDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Mazatlan ("MST7")
|
||||
#define TZ_America_Menominee ("CST6CDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Merida ("CST6")
|
||||
#define TZ_America_Metlakatla ("AKST9AKDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Mexico_City ("CST6")
|
||||
#define TZ_America_Miquelon ("<-03>3<-02>,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Moncton ("AST4ADT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Monterrey ("CST6")
|
||||
#define TZ_America_Montevideo ("<-03>3")
|
||||
#define TZ_America_Montreal ("EST5EDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Montserrat ("AST4")
|
||||
#define TZ_America_Nassau ("EST5EDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_New_York ("EST5EDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Nipigon ("EST5EDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Nome ("AKST9AKDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Noronha ("<-02>2")
|
||||
#define TZ_America_North_Dakota_Beulah ("CST6CDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_North_Dakota_Center ("CST6CDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_North_Dakota_New_Salem ("CST6CDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Nuuk ("<-02>2<-01>,M3.5.0/-1,M10.5.0/0")
|
||||
#define TZ_America_Ojinaga ("CST6CDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Panama ("EST5")
|
||||
#define TZ_America_Pangnirtung ("EST5EDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Paramaribo ("<-03>3")
|
||||
#define TZ_America_Phoenix ("MST7")
|
||||
#define TZ_America_PortmaumPrince ("EST5EDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Port_of_Spain ("AST4")
|
||||
#define TZ_America_Porto_Velho ("<-04>4")
|
||||
#define TZ_America_Puerto_Rico ("AST4")
|
||||
#define TZ_America_Punta_Arenas ("<-03>3")
|
||||
#define TZ_America_Rainy_River ("CST6CDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Rankin_Inlet ("CST6CDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Recife ("<-03>3")
|
||||
#define TZ_America_Regina ("CST6")
|
||||
#define TZ_America_Resolute ("CST6CDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Rio_Branco ("<-05>5")
|
||||
#define TZ_America_Santarem ("<-03>3")
|
||||
#define TZ_America_Santiago ("<-04>4<-03>,M9.1.6/24,M4.1.6/24")
|
||||
#define TZ_America_Santo_Domingo ("AST4")
|
||||
#define TZ_America_Sao_Paulo ("<-03>3")
|
||||
#define TZ_America_Scoresbysund ("<-01>1<+00>,M3.5.0/0,M10.5.0/1")
|
||||
#define TZ_America_Sitka ("AKST9AKDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_St_Barthelemy ("AST4")
|
||||
#define TZ_America_St_Johns ("NST3:30NDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_St_Kitts ("AST4")
|
||||
#define TZ_America_St_Lucia ("AST4")
|
||||
#define TZ_America_St_Thomas ("AST4")
|
||||
#define TZ_America_St_Vincent ("AST4")
|
||||
#define TZ_America_Swift_Current ("CST6")
|
||||
#define TZ_America_Tegucigalpa ("CST6")
|
||||
#define TZ_America_Thule ("AST4ADT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Thunder_Bay ("EST5EDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Tijuana ("PST8PDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Toronto ("EST5EDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Tortola ("AST4")
|
||||
#define TZ_America_Vancouver ("PST8PDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Whitehorse ("MST7")
|
||||
#define TZ_America_Winnipeg ("CST6CDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Yakutat ("AKST9AKDT,M3.2.0,M11.1.0")
|
||||
#define TZ_America_Yellowknife ("MST7MDT,M3.2.0,M11.1.0")
|
||||
#define TZ_Antarctica_Casey ("<+11>-11")
|
||||
#define TZ_Antarctica_Davis ("<+07>-7")
|
||||
#define TZ_Antarctica_DumontDUrville ("<+10>-10")
|
||||
#define TZ_Antarctica_Macquarie ("AEST-10AEDT,M10.1.0,M4.1.0/3")
|
||||
#define TZ_Antarctica_Mawson ("<+05>-5")
|
||||
#define TZ_Antarctica_McMurdo ("NZST-12NZDT,M9.5.0,M4.1.0/3")
|
||||
#define TZ_Antarctica_Palmer ("<-03>3")
|
||||
#define TZ_Antarctica_Rothera ("<-03>3")
|
||||
#define TZ_Antarctica_Syowa ("<+03>-3")
|
||||
#define TZ_Antarctica_Troll ("<+00>0<+02>-2,M3.5.0/1,M10.5.0/3")
|
||||
#define TZ_Antarctica_Vostok ("<+06>-6")
|
||||
#define TZ_Arctic_Longyearbyen ("CET-1CEST,M3.5.0,M10.5.0/3")
|
||||
#define TZ_Asia_Aden ("<+03>-3")
|
||||
#define TZ_Asia_Almaty ("<+06>-6")
|
||||
#define TZ_Asia_Amman ("<+03>-3")
|
||||
#define TZ_Asia_Anadyr ("<+12>-12")
|
||||
#define TZ_Asia_Aqtau ("<+05>-5")
|
||||
#define TZ_Asia_Aqtobe ("<+05>-5")
|
||||
#define TZ_Asia_Ashgabat ("<+05>-5")
|
||||
#define TZ_Asia_Atyrau ("<+05>-5")
|
||||
#define TZ_Asia_Baghdad ("<+03>-3")
|
||||
#define TZ_Asia_Bahrain ("<+03>-3")
|
||||
#define TZ_Asia_Baku ("<+04>-4")
|
||||
#define TZ_Asia_Bangkok ("<+07>-7")
|
||||
#define TZ_Asia_Barnaul ("<+07>-7")
|
||||
#define TZ_Asia_Beirut ("EET-2EEST,M3.5.0/0,M10.5.0/0")
|
||||
#define TZ_Asia_Bishkek ("<+06>-6")
|
||||
#define TZ_Asia_Brunei ("<+08>-8")
|
||||
#define TZ_Asia_Chita ("<+09>-9")
|
||||
#define TZ_Asia_Choibalsan ("<+08>-8")
|
||||
#define TZ_Asia_Colombo ("<+0530>-5:30")
|
||||
#define TZ_Asia_Damascus ("<+03>-3")
|
||||
#define TZ_Asia_Dhaka ("<+06>-6")
|
||||
#define TZ_Asia_Dili ("<+09>-9")
|
||||
#define TZ_Asia_Dubai ("<+04>-4")
|
||||
#define TZ_Asia_Dushanbe ("<+05>-5")
|
||||
#define TZ_Asia_Famagusta ("EET-2EEST,M3.5.0/3,M10.5.0/4")
|
||||
#define TZ_Asia_Gaza ("EET-2EEST,M3.4.4/50,M10.4.4/50")
|
||||
#define TZ_Asia_Hebron ("EET-2EEST,M3.4.4/50,M10.4.4/50")
|
||||
#define TZ_Asia_Ho_Chi_Minh ("<+07>-7")
|
||||
#define TZ_Asia_Hong_Kong ("HKT-8")
|
||||
#define TZ_Asia_Hovd ("<+07>-7")
|
||||
#define TZ_Asia_Irkutsk ("<+08>-8")
|
||||
#define TZ_Asia_Jakarta ("WIB-7")
|
||||
#define TZ_Asia_Jayapura ("WIT-9")
|
||||
#define TZ_Asia_Jerusalem ("IST-2IDT,M3.4.4/26,M10.5.0")
|
||||
#define TZ_Asia_Kabul ("<+0430>-4:30")
|
||||
#define TZ_Asia_Kamchatka ("<+12>-12")
|
||||
#define TZ_Asia_Karachi ("PKT-5")
|
||||
#define TZ_Asia_Kathmandu ("<+0545>-5:45")
|
||||
#define TZ_Asia_Khandyga ("<+09>-9")
|
||||
#define TZ_Asia_Kolkata ("IST-5:30")
|
||||
#define TZ_Asia_Krasnoyarsk ("<+07>-7")
|
||||
#define TZ_Asia_Kuala_Lumpur ("<+08>-8")
|
||||
#define TZ_Asia_Kuching ("<+08>-8")
|
||||
#define TZ_Asia_Kuwait ("<+03>-3")
|
||||
#define TZ_Asia_Macau ("CST-8")
|
||||
#define TZ_Asia_Magadan ("<+11>-11")
|
||||
#define TZ_Asia_Makassar ("WITA-8")
|
||||
#define TZ_Asia_Manila ("PST-8")
|
||||
#define TZ_Asia_Muscat ("<+04>-4")
|
||||
#define TZ_Asia_Nicosia ("EET-2EEST,M3.5.0/3,M10.5.0/4")
|
||||
#define TZ_Asia_Novokuznetsk ("<+07>-7")
|
||||
#define TZ_Asia_Novosibirsk ("<+07>-7")
|
||||
#define TZ_Asia_Omsk ("<+06>-6")
|
||||
#define TZ_Asia_Oral ("<+05>-5")
|
||||
#define TZ_Asia_Phnom_Penh ("<+07>-7")
|
||||
#define TZ_Asia_Pontianak ("WIB-7")
|
||||
#define TZ_Asia_Pyongyang ("KST-9")
|
||||
#define TZ_Asia_Qatar ("<+03>-3")
|
||||
#define TZ_Asia_Qyzylorda ("<+05>-5")
|
||||
#define TZ_Asia_Riyadh ("<+03>-3")
|
||||
#define TZ_Asia_Sakhalin ("<+11>-11")
|
||||
#define TZ_Asia_Samarkand ("<+05>-5")
|
||||
#define TZ_Asia_Seoul ("KST-9")
|
||||
#define TZ_Asia_Shanghai ("CST-8")
|
||||
#define TZ_Asia_Singapore ("<+08>-8")
|
||||
#define TZ_Asia_Srednekolymsk ("<+11>-11")
|
||||
#define TZ_Asia_Taipei ("CST-8")
|
||||
#define TZ_Asia_Tashkent ("<+05>-5")
|
||||
#define TZ_Asia_Tbilisi ("<+04>-4")
|
||||
#define TZ_Asia_Tehran ("<+0330>-3:30")
|
||||
#define TZ_Asia_Thimphu ("<+06>-6")
|
||||
#define TZ_Asia_Tokyo ("JST-9")
|
||||
#define TZ_Asia_Tomsk ("<+07>-7")
|
||||
#define TZ_Asia_Ulaanbaatar ("<+08>-8")
|
||||
#define TZ_Asia_Urumqi ("<+06>-6")
|
||||
#define TZ_Asia_UstmNera ("<+10>-10")
|
||||
#define TZ_Asia_Vientiane ("<+07>-7")
|
||||
#define TZ_Asia_Vladivostok ("<+10>-10")
|
||||
#define TZ_Asia_Yakutsk ("<+09>-9")
|
||||
#define TZ_Asia_Yangon ("<+0630>-6:30")
|
||||
#define TZ_Asia_Yekaterinburg ("<+05>-5")
|
||||
#define TZ_Asia_Yerevan ("<+04>-4")
|
||||
#define TZ_Atlantic_Azores ("<-01>1<+00>,M3.5.0/0,M10.5.0/1")
|
||||
#define TZ_Atlantic_Bermuda ("AST4ADT,M3.2.0,M11.1.0")
|
||||
#define TZ_Atlantic_Canary ("WET0WEST,M3.5.0/1,M10.5.0")
|
||||
#define TZ_Atlantic_Cape_Verde ("<-01>1")
|
||||
#define TZ_Atlantic_Faroe ("WET0WEST,M3.5.0/1,M10.5.0")
|
||||
#define TZ_Atlantic_Madeira ("WET0WEST,M3.5.0/1,M10.5.0")
|
||||
#define TZ_Atlantic_Reykjavik ("GMT0")
|
||||
#define TZ_Atlantic_South_Georgia ("<-02>2")
|
||||
#define TZ_Atlantic_Stanley ("<-03>3")
|
||||
#define TZ_Atlantic_St_Helena ("GMT0")
|
||||
#define TZ_Australia_Adelaide ("ACST-9:30ACDT,M10.1.0,M4.1.0/3")
|
||||
#define TZ_Australia_Brisbane ("AEST-10")
|
||||
#define TZ_Australia_Broken_Hill ("ACST-9:30ACDT,M10.1.0,M4.1.0/3")
|
||||
#define TZ_Australia_Currie ("AEST-10AEDT,M10.1.0,M4.1.0/3")
|
||||
#define TZ_Australia_Darwin ("ACST-9:30")
|
||||
#define TZ_Australia_Eucla ("<+0845>-8:45")
|
||||
#define TZ_Australia_Hobart ("AEST-10AEDT,M10.1.0,M4.1.0/3")
|
||||
#define TZ_Australia_Lindeman ("AEST-10")
|
||||
#define TZ_Australia_Lord_Howe ("<+1030>-10:30<+11>-11,M10.1.0,M4.1.0")
|
||||
#define TZ_Australia_Melbourne ("AEST-10AEDT,M10.1.0,M4.1.0/3")
|
||||
#define TZ_Australia_Perth ("AWST-8")
|
||||
#define TZ_Australia_Sydney ("AEST-10AEDT,M10.1.0,M4.1.0/3")
|
||||
#define TZ_Europe_Amsterdam ("CET-1CEST,M3.5.0,M10.5.0/3")
|
||||
#define TZ_Europe_Andorra ("CET-1CEST,M3.5.0,M10.5.0/3")
|
||||
#define TZ_Europe_Astrakhan ("<+04>-4")
|
||||
#define TZ_Europe_Athens ("EET-2EEST,M3.5.0/3,M10.5.0/4")
|
||||
#define TZ_Europe_Belgrade ("CET-1CEST,M3.5.0,M10.5.0/3")
|
||||
#define TZ_Europe_Berlin ("CET-1CEST,M3.5.0,M10.5.0/3")
|
||||
#define TZ_Europe_Bratislava ("CET-1CEST,M3.5.0,M10.5.0/3")
|
||||
#define TZ_Europe_Brussels ("CET-1CEST,M3.5.0,M10.5.0/3")
|
||||
#define TZ_Europe_Bucharest ("EET-2EEST,M3.5.0/3,M10.5.0/4")
|
||||
#define TZ_Europe_Budapest ("CET-1CEST,M3.5.0,M10.5.0/3")
|
||||
#define TZ_Europe_Busingen ("CET-1CEST,M3.5.0,M10.5.0/3")
|
||||
#define TZ_Europe_Chisinau ("EET-2EEST,M3.5.0,M10.5.0/3")
|
||||
#define TZ_Europe_Copenhagen ("CET-1CEST,M3.5.0,M10.5.0/3")
|
||||
#define TZ_Europe_Dublin ("IST-1GMT0,M10.5.0,M3.5.0/1")
|
||||
#define TZ_Europe_Gibraltar ("CET-1CEST,M3.5.0,M10.5.0/3")
|
||||
#define TZ_Europe_Guernsey ("GMT0BST,M3.5.0/1,M10.5.0")
|
||||
#define TZ_Europe_Helsinki ("EET-2EEST,M3.5.0/3,M10.5.0/4")
|
||||
#define TZ_Europe_Isle_of_Man ("GMT0BST,M3.5.0/1,M10.5.0")
|
||||
#define TZ_Europe_Istanbul ("<+03>-3")
|
||||
#define TZ_Europe_Jersey ("GMT0BST,M3.5.0/1,M10.5.0")
|
||||
#define TZ_Europe_Kaliningrad ("EET-2")
|
||||
#define TZ_Europe_Kiev ("EET-2EEST,M3.5.0/3,M10.5.0/4")
|
||||
#define TZ_Europe_Kirov ("MSK-3")
|
||||
#define TZ_Europe_Lisbon ("WET0WEST,M3.5.0/1,M10.5.0")
|
||||
#define TZ_Europe_Ljubljana ("CET-1CEST,M3.5.0,M10.5.0/3")
|
||||
#define TZ_Europe_London ("GMT0BST,M3.5.0/1,M10.5.0")
|
||||
#define TZ_Europe_Luxembourg ("CET-1CEST,M3.5.0,M10.5.0/3")
|
||||
#define TZ_Europe_Madrid ("CET-1CEST,M3.5.0,M10.5.0/3")
|
||||
#define TZ_Europe_Malta ("CET-1CEST,M3.5.0,M10.5.0/3")
|
||||
#define TZ_Europe_Mariehamn ("EET-2EEST,M3.5.0/3,M10.5.0/4")
|
||||
#define TZ_Europe_Minsk ("<+03>-3")
|
||||
#define TZ_Europe_Monaco ("CET-1CEST,M3.5.0,M10.5.0/3")
|
||||
#define TZ_Europe_Moscow ("MSK-3")
|
||||
#define TZ_Europe_Oslo ("CET-1CEST,M3.5.0,M10.5.0/3")
|
||||
#define TZ_Europe_Paris ("CET-1CEST,M3.5.0,M10.5.0/3")
|
||||
#define TZ_Europe_Podgorica ("CET-1CEST,M3.5.0,M10.5.0/3")
|
||||
#define TZ_Europe_Prague ("CET-1CEST,M3.5.0,M10.5.0/3")
|
||||
#define TZ_Europe_Riga ("EET-2EEST,M3.5.0/3,M10.5.0/4")
|
||||
#define TZ_Europe_Rome ("CET-1CEST,M3.5.0,M10.5.0/3")
|
||||
#define TZ_Europe_Samara ("<+04>-4")
|
||||
#define TZ_Europe_San_Marino ("CET-1CEST,M3.5.0,M10.5.0/3")
|
||||
#define TZ_Europe_Sarajevo ("CET-1CEST,M3.5.0,M10.5.0/3")
|
||||
#define TZ_Europe_Saratov ("<+04>-4")
|
||||
#define TZ_Europe_Simferopol ("MSK-3")
|
||||
#define TZ_Europe_Skopje ("CET-1CEST,M3.5.0,M10.5.0/3")
|
||||
#define TZ_Europe_Sofia ("EET-2EEST,M3.5.0/3,M10.5.0/4")
|
||||
#define TZ_Europe_Stockholm ("CET-1CEST,M3.5.0,M10.5.0/3")
|
||||
#define TZ_Europe_Tallinn ("EET-2EEST,M3.5.0/3,M10.5.0/4")
|
||||
#define TZ_Europe_Tirane ("CET-1CEST,M3.5.0,M10.5.0/3")
|
||||
#define TZ_Europe_Ulyanovsk ("<+04>-4")
|
||||
#define TZ_Europe_Uzhgorod ("EET-2EEST,M3.5.0/3,M10.5.0/4")
|
||||
#define TZ_Europe_Vaduz ("CET-1CEST,M3.5.0,M10.5.0/3")
|
||||
#define TZ_Europe_Vatican ("CET-1CEST,M3.5.0,M10.5.0/3")
|
||||
#define TZ_Europe_Vienna ("CET-1CEST,M3.5.0,M10.5.0/3")
|
||||
#define TZ_Europe_Vilnius ("EET-2EEST,M3.5.0/3,M10.5.0/4")
|
||||
#define TZ_Europe_Volgograd ("MSK-3")
|
||||
#define TZ_Europe_Warsaw ("CET-1CEST,M3.5.0,M10.5.0/3")
|
||||
#define TZ_Europe_Zagreb ("CET-1CEST,M3.5.0,M10.5.0/3")
|
||||
#define TZ_Europe_Zaporozhye ("EET-2EEST,M3.5.0/3,M10.5.0/4")
|
||||
#define TZ_Europe_Zurich ("CET-1CEST,M3.5.0,M10.5.0/3")
|
||||
#define TZ_Indian_Antananarivo ("EAT-3")
|
||||
#define TZ_Indian_Chagos ("<+06>-6")
|
||||
#define TZ_Indian_Christmas ("<+07>-7")
|
||||
#define TZ_Indian_Cocos ("<+0630>-6:30")
|
||||
#define TZ_Indian_Comoro ("EAT-3")
|
||||
#define TZ_Indian_Kerguelen ("<+05>-5")
|
||||
#define TZ_Indian_Mahe ("<+04>-4")
|
||||
#define TZ_Indian_Maldives ("<+05>-5")
|
||||
#define TZ_Indian_Mauritius ("<+04>-4")
|
||||
#define TZ_Indian_Mayotte ("EAT-3")
|
||||
#define TZ_Indian_Reunion ("<+04>-4")
|
||||
#define TZ_Pacific_Apia ("<+13>-13")
|
||||
#define TZ_Pacific_Auckland ("NZST-12NZDT,M9.5.0,M4.1.0/3")
|
||||
#define TZ_Pacific_Bougainville ("<+11>-11")
|
||||
#define TZ_Pacific_Chatham ("<+1245>-12:45<+1345>,M9.5.0/2:45,M4.1.0/3:45")
|
||||
#define TZ_Pacific_Chuuk ("<+10>-10")
|
||||
#define TZ_Pacific_Easter ("<-06>6<-05>,M9.1.6/22,M4.1.6/22")
|
||||
#define TZ_Pacific_Efate ("<+11>-11")
|
||||
#define TZ_Pacific_Enderbury ("<+13>-13")
|
||||
#define TZ_Pacific_Fakaofo ("<+13>-13")
|
||||
#define TZ_Pacific_Fiji ("<+12>-12")
|
||||
#define TZ_Pacific_Funafuti ("<+12>-12")
|
||||
#define TZ_Pacific_Galapagos ("<-06>6")
|
||||
#define TZ_Pacific_Gambier ("<-09>9")
|
||||
#define TZ_Pacific_Guadalcanal ("<+11>-11")
|
||||
#define TZ_Pacific_Guam ("ChST-10")
|
||||
#define TZ_Pacific_Honolulu ("HST10")
|
||||
#define TZ_Pacific_Kiritimati ("<+14>-14")
|
||||
#define TZ_Pacific_Kosrae ("<+11>-11")
|
||||
#define TZ_Pacific_Kwajalein ("<+12>-12")
|
||||
#define TZ_Pacific_Majuro ("<+12>-12")
|
||||
#define TZ_Pacific_Marquesas ("<-0930>9:30")
|
||||
#define TZ_Pacific_Midway ("SST11")
|
||||
#define TZ_Pacific_Nauru ("<+12>-12")
|
||||
#define TZ_Pacific_Niue ("<-11>11")
|
||||
#define TZ_Pacific_Norfolk ("<+11>-11<+12>,M10.1.0,M4.1.0/3")
|
||||
#define TZ_Pacific_Noumea ("<+11>-11")
|
||||
#define TZ_Pacific_Pago_Pago ("SST11")
|
||||
#define TZ_Pacific_Palau ("<+09>-9")
|
||||
#define TZ_Pacific_Pitcairn ("<-08>8")
|
||||
#define TZ_Pacific_Pohnpei ("<+11>-11")
|
||||
#define TZ_Pacific_Port_Moresby ("<+10>-10")
|
||||
#define TZ_Pacific_Rarotonga ("<-10>10")
|
||||
#define TZ_Pacific_Saipan ("ChST-10")
|
||||
#define TZ_Pacific_Tahiti ("<-10>10")
|
||||
#define TZ_Pacific_Tarawa ("<+12>-12")
|
||||
#define TZ_Pacific_Tongatapu ("<+13>-13")
|
||||
#define TZ_Pacific_Wake ("<+12>-12")
|
||||
#define TZ_Pacific_Wallis ("<+12>-12")
|
||||
#define TZ_Etc_GMT ("GMT0")
|
||||
#define TZ_Etc_GMTm0 ("GMT0")
|
||||
#define TZ_Etc_GMTm1 ("<+01>-1")
|
||||
#define TZ_Etc_GMTm2 ("<+02>-2")
|
||||
#define TZ_Etc_GMTm3 ("<+03>-3")
|
||||
#define TZ_Etc_GMTm4 ("<+04>-4")
|
||||
#define TZ_Etc_GMTm5 ("<+05>-5")
|
||||
#define TZ_Etc_GMTm6 ("<+06>-6")
|
||||
#define TZ_Etc_GMTm7 ("<+07>-7")
|
||||
#define TZ_Etc_GMTm8 ("<+08>-8")
|
||||
#define TZ_Etc_GMTm9 ("<+09>-9")
|
||||
#define TZ_Etc_GMTm10 ("<+10>-10")
|
||||
#define TZ_Etc_GMTm11 ("<+11>-11")
|
||||
#define TZ_Etc_GMTm12 ("<+12>-12")
|
||||
#define TZ_Etc_GMTm13 ("<+13>-13")
|
||||
#define TZ_Etc_GMTm14 ("<+14>-14")
|
||||
#define TZ_Etc_GMT0 ("GMT0")
|
||||
#define TZ_Etc_GMTp0 ("GMT0")
|
||||
#define TZ_Etc_GMTp1 ("<-01>1")
|
||||
#define TZ_Etc_GMTp2 ("<-02>2")
|
||||
#define TZ_Etc_GMTp3 ("<-03>3")
|
||||
#define TZ_Etc_GMTp4 ("<-04>4")
|
||||
#define TZ_Etc_GMTp5 ("<-05>5")
|
||||
#define TZ_Etc_GMTp6 ("<-06>6")
|
||||
#define TZ_Etc_GMTp7 ("<-07>7")
|
||||
#define TZ_Etc_GMTp8 ("<-08>8")
|
||||
#define TZ_Etc_GMTp9 ("<-09>9")
|
||||
#define TZ_Etc_GMTp10 ("<-10>10")
|
||||
#define TZ_Etc_GMTp11 ("<-11>11")
|
||||
#define TZ_Etc_GMTp12 ("<-12>12")
|
||||
#define TZ_Etc_UCT ("UTC0")
|
||||
#define TZ_Etc_UTC ("UTC0")
|
||||
#define TZ_Etc_Greenwich ("GMT0")
|
||||
#define TZ_Etc_Universal ("UTC0")
|
||||
#define TZ_Etc_Zulu ("UTC0")
|
||||
@@ -33,12 +33,17 @@
|
||||
|
||||
extern void ethernet_arch_lwip_begin() __attribute__((weak));
|
||||
extern void ethernet_arch_lwip_end() __attribute__((weak));
|
||||
extern void ethernet_arch_lwip_gpio_mask() __attribute__((weak));
|
||||
extern void ethernet_arch_lwip_gpio_unmask() __attribute__((weak));
|
||||
|
||||
auto_init_recursive_mutex(__lwipMutex); // Only for case with no Ethernet or PicoW, but still doing LWIP (PPP?)
|
||||
|
||||
class LWIPMutex {
|
||||
public:
|
||||
LWIPMutex() {
|
||||
if (ethernet_arch_lwip_gpio_mask) {
|
||||
ethernet_arch_lwip_gpio_mask();
|
||||
}
|
||||
#if defined(ARDUINO_RASPBERRY_PI_PICO_W)
|
||||
if (rp2040.isPicoW()) {
|
||||
cyw43_arch_lwip_begin();
|
||||
@@ -56,13 +61,18 @@ public:
|
||||
#if defined(ARDUINO_RASPBERRY_PI_PICO_W)
|
||||
if (rp2040.isPicoW()) {
|
||||
cyw43_arch_lwip_end();
|
||||
return;
|
||||
} else {
|
||||
#endif
|
||||
if (ethernet_arch_lwip_end) {
|
||||
ethernet_arch_lwip_end();
|
||||
} else {
|
||||
recursive_mutex_exit(&__lwipMutex);
|
||||
}
|
||||
#if defined(ARDUINO_RASPBERRY_PI_PICO_W)
|
||||
}
|
||||
#endif
|
||||
if (ethernet_arch_lwip_end) {
|
||||
ethernet_arch_lwip_end();
|
||||
} else {
|
||||
recursive_mutex_exit(&__lwipMutex);
|
||||
if (ethernet_arch_lwip_gpio_unmask) {
|
||||
ethernet_arch_lwip_gpio_unmask();
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -79,7 +89,7 @@ extern "C" {
|
||||
extern void __real_lwip_init();
|
||||
void __wrap_lwip_init() {
|
||||
if (!_lwip_rng) {
|
||||
_lwip_rng = new XoshiroCpp::Xoshiro256PlusPlus(get_rand_64());
|
||||
_lwip_rng = new XoshiroCpp::Xoshiro256PlusPlus(micros() * rp2040.getCycleCount());
|
||||
__real_lwip_init();
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -54,9 +54,9 @@ author = u'Earle F. Philhower, III'
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = u'3.6.3'
|
||||
version = u'3.8.0'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = u'3.6.3'
|
||||
release = u'3.8.0'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
|
||||
+15
-2
@@ -86,6 +86,19 @@ Pico may not have enough time to service the Ethernet port before the timer fire
|
||||
leading to a lock up and hang.
|
||||
|
||||
|
||||
Using Interrupt-Driven Handling
|
||||
-------------------------------
|
||||
|
||||
The WizNet and ENC28J60 devices support generating an interrupt when a packet is received,
|
||||
removing the need for polling and decreasing latency. Simply specify the SPI object to use and the
|
||||
interrupt pin when instantiating the Ethernet object:
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
#include <W5100lwIP.h>
|
||||
Wiznet5100lwIP eth(SS /* Chip Select*/, SPI /* SPI interface */, 17 /* Interrupt GPIO */ );
|
||||
|
||||
|
||||
Adjusting SPI Speed
|
||||
-------------------
|
||||
|
||||
@@ -114,12 +127,12 @@ For example, to set the W5500 to use a 30MHZ clock:
|
||||
Using the WIZnet W5100S-EVB-Pico
|
||||
--------------------------------
|
||||
|
||||
You can use the onboard Ethernet chip with these drivers by utilizing the following options:
|
||||
You can use the onboard Ethernet chip with these drivers, in interrupt mode, by utilizing the following options:
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
#include <W5100lwIP.h>
|
||||
Wiznet5100lwIP eth(17); // Note chip select is **17**
|
||||
Wiznet5100lwIP eth(17, SPI, 21); // Note chip select is **17**
|
||||
|
||||
void setup() {
|
||||
// Set SPI to the onboard Wiznet chip
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
FatFSUSB
|
||||
========
|
||||
|
||||
When the onboard flash memory is used as a ``FatFS`` filesystem, the
|
||||
``FatFSUSB`` can be used to allow exporting it to a PC as a standard
|
||||
memory stick. The PC can then access, add, and remove files as if the
|
||||
Pico was a USB memory stick, and upon ejection the Pico can access
|
||||
any new files just as if it made them itself.
|
||||
|
||||
(Note, if you are using LittleFS then you need to use ``SingleFileDrive``
|
||||
to export a single file, not this class, because the PC does not
|
||||
understand the LittleFS disk format.)
|
||||
|
||||
Callbacks, Interrupt Safety, and File Operations
|
||||
------------------------------------------------
|
||||
|
||||
The ``FatFSUSB`` library allows your application to get a callback
|
||||
when a PC attempts to mount or unmount the Pico as a FAT drive.
|
||||
|
||||
When the drive is being used by the Pico (i.e. any ``File`` is open for
|
||||
read or write, the ``FatFS`` is not ``end()`` -ed and still mounted,
|
||||
etc.) the host may not access it. Conversely, while the host PC is
|
||||
connected to the drive no ``FatFS`` access by the Pico is allowed.
|
||||
|
||||
Your ``driveReady`` callback will be called when the PC attempts to mount
|
||||
the drive. If you have any files open, then this callback can report back
|
||||
that the drive is not yet ready. When you complete file processing, the PC
|
||||
can re-attempt to mount the drive and your callback can return ``true`` .
|
||||
|
||||
The ``onPlug`` callback will generally ``FatFS.end()`` and set a
|
||||
global flag letting your application know not to touch the filesystem until
|
||||
the flag is cleared by the ``onUnplug`` callback (which will also do a
|
||||
``FatFS.begin()`` call).
|
||||
|
||||
Failing to close all files **and** ``FatFS.end()`` before granting the
|
||||
PC access to flash memory will result in corruption. FAT does not allow multiple
|
||||
writers to access the same drive. Even mounting and only reading files from
|
||||
the PC may cause hidden writes (things like access time, etc.) which would
|
||||
also cause corruption.
|
||||
|
||||
See the included ``Listfiles-USB`` sketch for an example of working with
|
||||
these limitations.
|
||||
+49
-5
@@ -33,6 +33,7 @@ following include to the sketch:
|
||||
#include "LittleFS.h" // LittleFS is declared
|
||||
// #include <SDFS.h>
|
||||
// #include <SD.h>
|
||||
// #include <FatFS.h>
|
||||
|
||||
|
||||
Compatible Filesystem APIs
|
||||
@@ -48,10 +49,45 @@ SD card reader.
|
||||
SD is the Arduino-supported, somewhat old and limited SD card filesystem.
|
||||
It is recommended to use SDFS for new applications instead of SD.
|
||||
|
||||
All three of these filesystems can open and manipulate ``File`` and ``Dir``
|
||||
FatFS implements a wear-leveled, FTL-backed FAT filesystem in the onboard
|
||||
flash which can be easily accessed over USB as a standard memory stick
|
||||
via FatFSUSB.
|
||||
|
||||
All of these filesystems can open and manipulate ``File`` and ``Dir``
|
||||
objects with the same code because the implement a common end-user
|
||||
filesystem API.
|
||||
|
||||
FatFS File System Caveats and Warnings
|
||||
--------------------------------------
|
||||
|
||||
The FAT filesystem is ubiquitous, but it is also around 50 years old and ill
|
||||
suited to SPI flash memory due to having "hot spots" like the FAT copies that
|
||||
are rewritten many times over. SPI flash allows a high, but limited, number
|
||||
of writes before losing the ability to write safely. Applications like
|
||||
data loggers where many writes occur could end up wearing out the SPI flash
|
||||
sector that holds the FAT **years** before coming close to the write limits of
|
||||
the data sectors.
|
||||
|
||||
To circumvent this issue, the FatFS implementation here uses a flash translation
|
||||
layer (FTL) developed for SPI flash on embedded systems. This allows for the
|
||||
same LBA to be written over and over by the FAT filesystem, but use different
|
||||
flash locations. For more information see
|
||||
[SPIFTL](https://github.com/earlephilhower/SPIFTL). In this mode the Pico
|
||||
flash appears as a normal, 512-byte sector drive to the FAT.
|
||||
|
||||
What this means, practically, is that about 5KB of RAM per megabyte of flash
|
||||
is required for housekeeping. Writes can also become very slow if most of the
|
||||
flash LBA range is used (i.e. if the FAT drive is 99% full) due to the need
|
||||
for garbage collection processes to move data around and preserve the flash
|
||||
lifetime.
|
||||
|
||||
Alternatively, if an FTL is not desired or memory is tight, FatFS can use the
|
||||
raw flash directly. In this mode sectors are 4K in size and flash is mapped
|
||||
1:1 to sectors, so things like the FAT table updates will all use the same
|
||||
physical flash bits. For low-utilization operations this may be fine, but if
|
||||
significant writes are done (from the Pico or the PC host) this may wear out
|
||||
portions of flash very quickly , rendering it unusable.
|
||||
|
||||
LittleFS File System Limitations
|
||||
--------------------------------
|
||||
|
||||
@@ -115,8 +151,8 @@ second SPI port, ``SPI1``. Just use the following call in place of
|
||||
SD.begin(cspin, SPI1);
|
||||
|
||||
|
||||
File system object (LittleFS/SD/SDFS)
|
||||
-------------------------------------
|
||||
File system object (LittleFS/SD/SDFS/FatFS)
|
||||
-------------------------------------------
|
||||
|
||||
setConfig
|
||||
~~~~~~~~~
|
||||
@@ -131,14 +167,22 @@ setConfig
|
||||
c2.setCSPin(12);
|
||||
SDFS.setConfig(c2);
|
||||
|
||||
FatFSConfig c3;
|
||||
c3.setUseFTL(false); // Directly access flash memory
|
||||
c3.setDirEntries(256); // We need 256 root directory entries on a format()
|
||||
c3.setFATCopies(1); // Only 1 FAT to save 4K of space and extra writes
|
||||
FatFS.setConfig(c3);
|
||||
FatFS.format(); // Format using these settings, erasing everything
|
||||
|
||||
This method allows you to configure the parameters of a filesystem
|
||||
before mounting. All filesystems have their own ``*Config`` (i.e.
|
||||
``SDFSConfig`` or ``LittleFSConfig`` with their custom set of options.
|
||||
All filesystems allow explicitly enabling/disabling formatting when
|
||||
mounts fail. If you do not call this ``setConfig`` method before
|
||||
perforing ``begin()``, you will get the filesystem's default
|
||||
behavior and configuration. By default, LittleFS will autoformat the
|
||||
filesystem if it cannot mount it, while SDFS will not.
|
||||
behavior and configuration. By default, LittleFS and FatFS will autoformat the
|
||||
filesystem if it cannot mount it, while SDFS will not. FatFS will also use
|
||||
the built-in FTL to support 512 byte sectors and higher write lifetime.
|
||||
|
||||
begin
|
||||
~~~~~
|
||||
|
||||
+3
-7
@@ -1,15 +1,11 @@
|
||||
IDE Menus
|
||||
=========
|
||||
|
||||
Model
|
||||
Board
|
||||
-----
|
||||
Use the boards menu to select your model of RP2040 board. There will be two
|
||||
options: `Boardname` and `Boardname (Picoprobe)`. If you want to use a
|
||||
Picoprobe to upload your sketches and not the default automatic UF2 upload,
|
||||
use the `(Picoprobe)` option, otherwise use the normal name. No functional
|
||||
or code changes are done because of this.
|
||||
Use the boards menu to select your model of RP2040 board.
|
||||
|
||||
There is also a `Generic` board which allows you to individually select
|
||||
There is also a `Generic RP2040` board which allows you to individually select
|
||||
things such as flash size or boot2 flash type. Use this if your board isn't
|
||||
yet fully supported and isn't working with the normal `Raspberry Pi Pico`
|
||||
option.
|
||||
|
||||
+12
-2
@@ -37,6 +37,11 @@ Pausing Cores
|
||||
|
||||
Sometimes an application needs to pause the other core on chip (i.e. it is
|
||||
writing to flash or needs to stop processing while some other event occurs).
|
||||
In most cases, however, these calls are **SHOULD NOT BE USED**. To synchronize
|
||||
cross-core operations use normal multiprocessor methods such as circular buffers,
|
||||
global ``volatile`` flags, mutexes, and the like. Stopping a core has massive
|
||||
implications and can kill networking and USB communications if done too long or
|
||||
too frequently.
|
||||
|
||||
void rp2040.idleOtherCore()
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@@ -69,7 +74,12 @@ Communicating Between Cores
|
||||
The RP2040 provides a hardware FIFO for communicating between cores, but it
|
||||
is used exclusively for the idle/resume calls described above. Instead, please
|
||||
use the following functions to access a software-managed, multicore safe
|
||||
FIFO.
|
||||
FIFO. There are two FIFOs, one written to by core 0 and read by core 1, and
|
||||
the other written to by core 1 and read by core 0.
|
||||
|
||||
You can (and probably should) use shared memory (such as ``volatile`` globals)
|
||||
or other normal multiprocessor communication algorithms to transfer data or
|
||||
work between cores, but for simple tasks these FIFO routines can suffice.
|
||||
|
||||
void rp2040.fifo.push(uint32_t)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@@ -96,4 +106,4 @@ Reads a value from this core's FIFO and places it in dest. Will return
|
||||
int rp2040.fifo.available()
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Returns the number of values available in this core's FIFO.
|
||||
Returns the number of values available to read in this core's FIFO.
|
||||
|
||||
+4
-4
@@ -12,7 +12,7 @@ OTA may be done using:
|
||||
- `Arduino IDE <#arduino-ide>`__
|
||||
- `Web Browser <#web-browser>`__
|
||||
- `HTTP Server <#http-server>`__
|
||||
- Any other method (ZModen receive over a UART port, etc.) by using the ``Updater`` object in your sketch
|
||||
- Any other method (ZModem receive over a UART port, etc.) by using the ``Updater`` object in your sketch
|
||||
|
||||
The Arduino IDE option is intended primarily for the software development phase. The other two options would be more useful after deployment, to provide the module with application updates either manually with a web browser, or automatically using an HTTP server.
|
||||
|
||||
@@ -189,7 +189,7 @@ Uploading modules wirelessly from Arduino IDE is intended for the following typi
|
||||
|
||||
To upload wirelessly from the IDE:
|
||||
|
||||
1. Build a sketch starts ``WiFi`` and includes the appropriate calls to ``ArduinoOTA`` (see the examples for reference). These include the ``ArduinoOTA.begin()`` call in ``setup()`` and periodically calling ``ArduinoOTA.handle();`` from the ``loop()``
|
||||
1. Build a sketch that starts ``WiFi`` and includes the appropriate calls to ``ArduinoOTA`` (see the examples for reference). These include the ``ArduinoOTA.begin()`` call in ``setup()`` and periodically calling ``ArduinoOTA.handle();`` from the ``loop()``
|
||||
|
||||
2. Upload using standard USB connection the first time.
|
||||
|
||||
@@ -212,9 +212,9 @@ Before implementing it in your sketch, it is a good idea to check how it works u
|
||||
|
||||
Enter the password and upload should be initiated as usual with the only difference being ``Authenticating...OK`` message visible in the upload log.
|
||||
|
||||
You will not be prompted for a reentering the same password next time. Arduino IDE will remember it for you. You will see a prompt for password only after reopening IDE, or if you change it in your sketch, upload the sketch and then try to upload it again.
|
||||
You will not be prompted for a reentering the same password next time. Arduino IDE will remember it for you. You will see a prompt for password only after reopening the IDE, or if you change it in your sketch, upload the sketch and then try to upload it again.
|
||||
|
||||
Please note, it is possible to reveal password entered previously in Arduino IDE, if IDE has not been closed since last upload. This can be done by enabling *Show verbose output during: upload* in *File > Preferences* and attempting to upload the module.
|
||||
Please note, it is possible to reveal password entered previously in Arduino IDE, if the IDE has not been closed since last upload. This can be done by enabling *Show verbose output during: upload* in *File > Preferences* and attempting to upload the module.
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ To instantiate only a serial transmit or receive unit, pass in
|
||||
``SerialPIO::NOPIN`` as the ``txpin`` or ``rxpin``.
|
||||
|
||||
For example, to make a transmit-only port on GP16
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
SerialPIO transmitter( 16, SerialPIO::NOPIN );
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ diagram for your board, or it won't work.
|
||||
Other than that, the API is compatible with the Arduino standard.
|
||||
Both master and slave operation are supported.
|
||||
|
||||
Master transmissions are buffered (up to 128 bytes) and only performed
|
||||
Master transmissions are buffered (up to 256 bytes) and only performed
|
||||
on ``endTransmission``, as is standard with modern Arduino Wire implementations.
|
||||
|
||||
For more detailed information, check the `Arduino Wire documentation <https://www.arduino.cc/en/reference/wire>`_ .
|
||||
|
||||
@@ -8,10 +8,19 @@ Arduino KEYWORD3 RESERVED_WORD
|
||||
# Datatypes (KEYWORD1)
|
||||
#######################################
|
||||
|
||||
Dir KEYWORD1
|
||||
File KEYWORD1
|
||||
timeval KEYWORD1
|
||||
time_t KEYWORD1
|
||||
|
||||
#######################################
|
||||
# Methods and Functions (KEYWORD2)
|
||||
#######################################
|
||||
|
||||
openDir KEYWORD2
|
||||
setConfig KEYWORD2
|
||||
fileCreationTime KEYWORD2
|
||||
|
||||
setup1 KEYWORD2
|
||||
loop1 KEYWORD2
|
||||
|
||||
@@ -61,6 +70,21 @@ digitalReadFast KEYWORD2
|
||||
|
||||
enableDoubleResetBootloader KEYWORD2
|
||||
|
||||
openDir KEYWORD2
|
||||
next KEYWORD2
|
||||
getLastWrite KEYWORD2
|
||||
getCreationTime KEYWORD2
|
||||
fileTime KEYWORD2
|
||||
fileCreationTime KEYWORD2
|
||||
check KEYWORD2
|
||||
setTimeCallback KEYWORD2
|
||||
settimeofday KEYWORD2
|
||||
|
||||
sprintf_P KEYWORD2
|
||||
strcpy_P KEYWORD2
|
||||
snprintf_P KEYWORD2
|
||||
strncpy_P KEYWORD2
|
||||
|
||||
OUTPUT_2MA LITERAL1
|
||||
OUTPUT_4MA LITERAL1
|
||||
OUTPUT_8MA LITERAL1
|
||||
|
||||
Submodule libraries/Adafruit_TinyUSB_Arduino updated: e291865233...d629476752
+1
-1
Submodule libraries/ESP8266SdFat updated: 255180be14...16ba999e1d
@@ -0,0 +1,24 @@
|
||||
#######################################
|
||||
# Syntax Coloring Map
|
||||
#######################################
|
||||
|
||||
#######################################
|
||||
# Datatypes (KEYWORD1)
|
||||
#######################################
|
||||
|
||||
FatFS KEYWORD1
|
||||
|
||||
#######################################
|
||||
# Methods and Functions (KEYWORD2)
|
||||
#######################################
|
||||
|
||||
format KEYWORD2
|
||||
FatFSConfig KEYWORD2
|
||||
setUseFTL KEYWORD2
|
||||
setDirEntries KEYWORD2
|
||||
setFATCopies KEYWORD2
|
||||
|
||||
#######################################
|
||||
# Constants (LITERAL1)
|
||||
#######################################
|
||||
|
||||
Submodule
+1
Submodule libraries/FatFS/lib/SPIFTL added at 3016627c3f
@@ -0,0 +1,24 @@
|
||||
FatFs License
|
||||
|
||||
FatFs has being developped as a personal project of the author, ChaN. It is free from the code anyone else wrote at current release. Following code block shows a copy of the FatFs license document that heading the source files.
|
||||
|
||||
/*----------------------------------------------------------------------------/
|
||||
/ FatFs - Generic FAT Filesystem Module Rx.xx /
|
||||
/-----------------------------------------------------------------------------/
|
||||
/
|
||||
/ Copyright (C) 20xx, ChaN, all right reserved.
|
||||
/
|
||||
/ FatFs module is an open source software. Redistribution and use of FatFs in
|
||||
/ source and binary forms, with or without modification, are permitted provided
|
||||
/ that the following condition is met:
|
||||
/
|
||||
/ 1. Redistributions of source code must retain the above copyright notice,
|
||||
/ this condition and the following disclaimer.
|
||||
/
|
||||
/ This software is provided by the copyright holder and contributors "AS IS"
|
||||
/ and any warranties related to this software are DISCLAIMED.
|
||||
/ The copyright owner or contributors be NOT LIABLE for any damages caused
|
||||
/ by use of this software.
|
||||
/----------------------------------------------------------------------------*/
|
||||
|
||||
Therefore FatFs license is one of the BSD-style licenses, but there is a significant feature. FatFs is mainly intended for embedded systems. In order to extend the usability for commercial products, the redistributions of FatFs in binary form, such as embedded code, binary library and any forms without source code, do not need to include about FatFs in the documentations. This is equivalent to the 1-clause BSD license. Of course FatFs is compatible with the most of open source software licenses include GNU GPL. When you redistribute the FatFs source code with changes or create a fork, the license can also be changed to GNU GPL, BSD-style license or any open source software license that not conflict with FatFs license.
|
||||
@@ -0,0 +1 @@
|
||||
FatFS home at http://elm-chan.org/fsw/ff/
|
||||
@@ -0,0 +1,10 @@
|
||||
name=FatFS
|
||||
version=0.15.0
|
||||
author=Earle F. Philhower, III <earlephilhower@yahoo.com>
|
||||
maintainer=Earle F. Philhower, III <earlephilhower@yahoo.com>
|
||||
sentence=FS filesystem for use on flash using ChaN's FatFS code
|
||||
paragraph=FS filesystem for use on flash using ChaN's FatFS code
|
||||
category=Data Storage
|
||||
url=https://github.com/earlephilhower/arduino-pico
|
||||
architectures=rp2040
|
||||
dot_a_linkage=true
|
||||
@@ -0,0 +1,310 @@
|
||||
/*
|
||||
FatFS.cpp - file system wrapper for FatFS
|
||||
Copyright (c) 2024 Earle F. Philhower, III. All rights reserved.
|
||||
|
||||
Based on spiffs_api.cpp which is:
|
||||
| Copyright (c) 2015 Ivan Grokhotkov. All rights reserved.
|
||||
|
||||
This code was influenced by NodeMCU and Sming libraries, and first version of
|
||||
Arduino wrapper written by Hristo Gochkov.
|
||||
|
||||
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 "FatFS.h"
|
||||
#include <FS.h>
|
||||
//#define FTL_DEBUG 1
|
||||
#include "../lib/SPIFTL/FlashInterfaceRP2040.h"
|
||||
#include "../lib/SPIFTL/SPIFTL.h"
|
||||
|
||||
using namespace fs;
|
||||
|
||||
|
||||
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_FATFS)
|
||||
extern uint8_t _FS_start;
|
||||
extern uint8_t _FS_end;
|
||||
|
||||
FS FatFS = FS(FSImplPtr(new fatfs::FatFSImpl()));
|
||||
static FlashInterfaceRP2040 *_fi = new FlashInterfaceRP2040(&_FS_start, &_FS_end);
|
||||
static SPIFTL *_ftl = nullptr;
|
||||
uint16_t _sectorSize = 512;
|
||||
#endif
|
||||
|
||||
namespace fatfs {
|
||||
|
||||
|
||||
bool FatFSImpl::begin() {
|
||||
if (_mounted) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_cfg._useFTL) {
|
||||
if (!_ftl) {
|
||||
_ftl = new SPIFTL(_fi);
|
||||
}
|
||||
_sectorSize = 512;
|
||||
} else {
|
||||
_sectorSize = 4096;
|
||||
if (_ftl) {
|
||||
delete _ftl;
|
||||
_ftl = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
_mounted = (FR_OK == f_mount(&_fatfs, "", 1));
|
||||
if (!_mounted && _cfg._autoFormat) {
|
||||
format();
|
||||
_mounted = (FR_OK == f_mount(&_fatfs, "", 1));
|
||||
}
|
||||
//FsDateTime::setCallback(dateTimeCB); TODO = callback
|
||||
return _mounted;
|
||||
}
|
||||
|
||||
void FatFSImpl::end() {
|
||||
if (_mounted) {
|
||||
f_unmount("");
|
||||
}
|
||||
sync();
|
||||
_mounted = false;
|
||||
}
|
||||
|
||||
|
||||
// Required to be global because SDFAT doesn't allow a this pointer in it's own time call
|
||||
time_t (*__fatfs_timeCallback)(void) = nullptr;
|
||||
|
||||
FileImplPtr FatFSImpl::open(const char* path, OpenMode openMode, AccessMode accessMode) {
|
||||
if (!_mounted) {
|
||||
DEBUGV("FatFSImpl::open() called on unmounted FS\n");
|
||||
return FileImplPtr();
|
||||
}
|
||||
if (!path || !path[0]) {
|
||||
DEBUGV("FatFSImpl::open() called with invalid filename\n");
|
||||
return FileImplPtr();
|
||||
}
|
||||
BYTE flags = _getFlags(openMode, accessMode);
|
||||
if ((openMode && OM_CREATE) && strchr(path, '/')) {
|
||||
// For file creation, silently make subdirs as needed. If any fail,
|
||||
// it will be caught by the real file open later on
|
||||
char *pathStr = strdup(path);
|
||||
if (pathStr) {
|
||||
// Make dirs up to the final fnamepart
|
||||
char *ptr = strrchr(pathStr, '/');
|
||||
if (ptr && ptr != pathStr) { // Don't try to make root dir!
|
||||
*ptr = 0;
|
||||
f_mkdir(pathStr);
|
||||
}
|
||||
}
|
||||
free(pathStr);
|
||||
}
|
||||
auto sharedFd = std::make_shared<FIL>();
|
||||
if (FR_OK == f_open(sharedFd.get(), path, flags)) {
|
||||
return std::make_shared<FatFSFileImpl>(this, sharedFd, path, FA_WRITE & flags ? true : false);
|
||||
}
|
||||
sharedFd = nullptr;
|
||||
DEBUGV("FatFSImpl::openFile: path=`%s` openMode=%d accessMode=%d FAILED", path, openMode, accessMode);
|
||||
return FileImplPtr();
|
||||
}
|
||||
|
||||
DirImplPtr FatFSImpl::openDir(const char* path) {
|
||||
if (!_mounted) {
|
||||
return DirImplPtr();
|
||||
}
|
||||
char *pathStr = strdup(path); // Allow edits on our scratch copy
|
||||
if (!pathStr) {
|
||||
// OOM
|
||||
return DirImplPtr();
|
||||
}
|
||||
// Get rid of any trailing slashes
|
||||
while (strlen(pathStr) && (pathStr[strlen(pathStr) - 1] == '/')) {
|
||||
pathStr[strlen(pathStr) - 1] = 0;
|
||||
}
|
||||
// At this point we have a name of "/blah/blah/blah" or "blah" or ""
|
||||
// If that references a directory, just open it and we're done.
|
||||
DIR dirFile;
|
||||
FILINFO fno;
|
||||
const char *filter = "";
|
||||
if (!pathStr[0]) {
|
||||
// openDir("") === openDir("/")
|
||||
f_opendir(&dirFile, "/");
|
||||
filter = "";
|
||||
} else if (FR_OK == f_stat(pathStr, &fno)) {
|
||||
if (fno.fattrib & AM_DIR) {
|
||||
// Easy peasy, path specifies an existing dir!
|
||||
f_opendir(&dirFile, pathStr);
|
||||
filter = "";
|
||||
} else {
|
||||
// This is a file, so open the containing dir
|
||||
char *ptr = strrchr(pathStr, '/');
|
||||
if (!ptr) {
|
||||
// No slashes, open the root dir
|
||||
f_opendir(&dirFile, "/");
|
||||
filter = pathStr;
|
||||
} else {
|
||||
// We've got slashes, open the dir one up
|
||||
*ptr = 0; // Remove slash, truncare string
|
||||
f_opendir(&dirFile, pathStr);
|
||||
filter = ptr + 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Name doesn't exist, so use the parent dir of whatever was sent in
|
||||
// This is a file, so open the containing dir
|
||||
char *ptr = strrchr(pathStr, '/');
|
||||
if (!ptr) {
|
||||
// No slashes, open the root dir
|
||||
f_opendir(&dirFile, "/");
|
||||
filter = pathStr;
|
||||
} else {
|
||||
// We've got slashes, open the dir one up
|
||||
*ptr = 0; // Remove slash, truncare string
|
||||
f_opendir(&dirFile, pathStr);
|
||||
filter = ptr + 1;
|
||||
}
|
||||
}
|
||||
// TODO -can this ever happen?
|
||||
// if (!dirFile) {
|
||||
// DEBUGV("FatFSImpl::openDir: path=`%s`\n", path);
|
||||
// return DirImplPtr();
|
||||
// }
|
||||
auto sharedDir = std::make_shared<DIR>(dirFile);
|
||||
auto ret = std::make_shared<FatFSDirImpl>(filter, this, sharedDir, pathStr);
|
||||
free(pathStr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool FatFSImpl::format() {
|
||||
if (_mounted) {
|
||||
return false;
|
||||
}
|
||||
BYTE *work = new BYTE[4096]; /* Work area (larger is better for processing time) */
|
||||
MKFS_PARM opt = { FM_FAT | FM_SFD, _cfg._fatCopies, 1, _sectorSize, _cfg._dirEntries};
|
||||
auto ret = f_mkfs("", &opt, work, 4096);
|
||||
delete[] work;
|
||||
|
||||
return ret == FR_OK;
|
||||
}
|
||||
|
||||
DSTATUS disk_status(BYTE p) {
|
||||
(void) p;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool started = false;
|
||||
|
||||
void disk_format() {
|
||||
if (!started && _ftl) {
|
||||
_ftl->format();
|
||||
}
|
||||
}
|
||||
|
||||
DSTATUS disk_initialize(BYTE p) {
|
||||
(void) p;
|
||||
if (!started) {
|
||||
if (_ftl) {
|
||||
_ftl->start();
|
||||
}
|
||||
started = true;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
DRESULT disk_read(BYTE p, BYTE *buff, LBA_t sect, UINT count) {
|
||||
(void) p;
|
||||
for (unsigned int i = 0; i < count; i++) {
|
||||
if (_ftl) {
|
||||
_ftl->read(sect + i, buff + i * _sectorSize);
|
||||
} else {
|
||||
_fi->read(sect + i, 0, buff, _sectorSize);
|
||||
}
|
||||
}
|
||||
return RES_OK;
|
||||
}
|
||||
|
||||
DRESULT disk_write(BYTE pdrv, const BYTE* buff, LBA_t sector, UINT count) {
|
||||
(void) pdrv;
|
||||
for (unsigned int i = 0; i < count; i++) {
|
||||
if (_ftl) {
|
||||
_ftl->write(sector + i, buff + i * _sectorSize);
|
||||
} else {
|
||||
_fi->eraseBlock(sector + i);
|
||||
_fi->program(sector + i, 0, buff + i * _sectorSize, _sectorSize);
|
||||
}
|
||||
}
|
||||
return RES_OK;
|
||||
}
|
||||
|
||||
DRESULT disk_ioctl(BYTE pdrv, BYTE cmd, void* buff) {
|
||||
(void) pdrv;
|
||||
switch (cmd) {
|
||||
case CTRL_SYNC:
|
||||
if (_ftl) {
|
||||
_ftl->persist();
|
||||
}
|
||||
return RES_OK;
|
||||
case GET_SECTOR_COUNT: {
|
||||
LBA_t *p = (LBA_t *)buff;
|
||||
if (_ftl) {
|
||||
*p = _ftl->lbaCount();
|
||||
} else {
|
||||
*p = _fi->size() / 4096;
|
||||
}
|
||||
return RES_OK;
|
||||
}
|
||||
case GET_SECTOR_SIZE: {
|
||||
WORD *w = (WORD *)buff;
|
||||
*w = _sectorSize;
|
||||
return RES_OK;
|
||||
}
|
||||
case GET_BLOCK_SIZE: {
|
||||
DWORD *dw = (DWORD *)buff;
|
||||
*dw = _sectorSize;
|
||||
return RES_OK;
|
||||
}
|
||||
case CTRL_TRIM: {
|
||||
LBA_t *lba = (LBA_t *)buff;
|
||||
for (unsigned int i = lba[0]; i < lba[1]; i++) {
|
||||
if (_ftl) {
|
||||
_ftl->trim(i);
|
||||
} else {
|
||||
_fi->eraseBlock(i);
|
||||
}
|
||||
}
|
||||
return RES_OK;
|
||||
}
|
||||
default:
|
||||
return RES_PARERR;
|
||||
}
|
||||
}
|
||||
|
||||
DWORD get_fattime() {
|
||||
time_t now;
|
||||
if (fatfs::__fatfs_timeCallback) {
|
||||
now = fatfs::__fatfs_timeCallback();
|
||||
} else {
|
||||
now = time(nullptr);
|
||||
}
|
||||
struct tm *stm = localtime(&now);
|
||||
if (stm->tm_year < 80) {
|
||||
// FAT can't report years before 1980
|
||||
stm->tm_year = 80;
|
||||
}
|
||||
return (DWORD)(stm->tm_year - 80) << 25 |
|
||||
(DWORD)(stm->tm_mon + 1) << 21 |
|
||||
(DWORD)stm->tm_mday << 16 |
|
||||
(DWORD)stm->tm_hour << 11 |
|
||||
(DWORD)stm->tm_min << 5 |
|
||||
(DWORD)stm->tm_sec >> 1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,470 @@
|
||||
/*
|
||||
FatFS.h - File system wrapper for FatFS
|
||||
Copyright (c) 2024 Earle F. Philhower, III. All rights reserved.
|
||||
|
||||
Based on spiffs_api.h, which is:
|
||||
| Copyright (c) 2015 Ivan Grokhotkov. All rights reserved.
|
||||
|
||||
This code was influenced by NodeMCU and Sming libraries, and first version of
|
||||
Arduino wrapper written by Hristo Gochkov.
|
||||
|
||||
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 <limits>
|
||||
#include <assert.h>
|
||||
#include "FS.h"
|
||||
#include "FSImpl.h"
|
||||
#include "./ff.h"
|
||||
#include "./diskio.h"
|
||||
#include <FS.h>
|
||||
|
||||
using namespace fs;
|
||||
|
||||
namespace fatfs {
|
||||
|
||||
class FatFSFileImpl;
|
||||
class FatFSDirImpl;
|
||||
class FatFSConfig : public FSConfig {
|
||||
public:
|
||||
static constexpr uint32_t FSId = 0x46617446;
|
||||
|
||||
FatFSConfig(bool autoFormat = true, bool useFTL = true, int dirEntries = 128, int fatCopies = 1) : FSConfig(FSId, autoFormat), _useFTL(useFTL), _dirEntries(dirEntries), _fatCopies(fatCopies) { }
|
||||
|
||||
FatFSConfig setUseFTL(bool val = true) {
|
||||
_useFTL = val;
|
||||
return *this;
|
||||
}
|
||||
|
||||
FatFSConfig setDirEntries(int entries) {
|
||||
_dirEntries = entries;
|
||||
return *this;
|
||||
}
|
||||
|
||||
FatFSConfig setFATCopies(int copies) {
|
||||
_fatCopies = copies;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool _useFTL;
|
||||
uint16_t _dirEntries;
|
||||
uint8_t _fatCopies;
|
||||
};
|
||||
|
||||
class FatFSImpl : public FSImpl {
|
||||
public:
|
||||
FatFSImpl() : _mounted(false) {
|
||||
}
|
||||
|
||||
FileImplPtr open(const char* path, OpenMode openMode, AccessMode accessMode) override;
|
||||
|
||||
bool exists(const char* path) override {
|
||||
if (_mounted) {
|
||||
FILINFO fi;
|
||||
if (FR_OK == f_stat(path, &fi)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
DirImplPtr openDir(const char* path) override;
|
||||
|
||||
bool rename(const char* pathFrom, const char* pathTo) override {
|
||||
return _mounted ? (FR_OK == f_rename(pathFrom, pathTo)) : false;
|
||||
}
|
||||
|
||||
bool info64(FSInfo64& info) override {
|
||||
if (!_mounted) {
|
||||
DEBUGV("FatFS::info: FS not mounted\n");
|
||||
return false;
|
||||
}
|
||||
FATFS *fs = nullptr;
|
||||
DWORD fre_clust = 0;
|
||||
f_getfree("", &fre_clust, &fs);
|
||||
info.maxOpenFiles = 999; // TODO - not valid
|
||||
info.blockSize = 512 * fs->csize;
|
||||
info.pageSize = 0; // TODO ?
|
||||
info.maxPathLength = 255; // TODO ?
|
||||
info.totalBytes = (uint64_t)(fs->n_fatent - 2) * (uint64_t)fs->csize * 512;
|
||||
info.usedBytes = info.totalBytes - (uint64_t)fre_clust * fs->csize * 512;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool info(FSInfo& info) override {
|
||||
FSInfo64 i;
|
||||
if (!info64(i)) {
|
||||
return false;
|
||||
}
|
||||
info.blockSize = i.blockSize;
|
||||
info.pageSize = i.pageSize;
|
||||
info.maxOpenFiles = i.maxOpenFiles;
|
||||
info.maxPathLength = i.maxPathLength;
|
||||
info.totalBytes = (size_t)i.totalBytes;
|
||||
info.usedBytes = (size_t)i.usedBytes;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool remove(const char* path) override {
|
||||
return _mounted ? (FR_OK == f_unlink(path)) : false;
|
||||
}
|
||||
|
||||
bool mkdir(const char* path) override {
|
||||
return _mounted ? (FR_OK == f_mkdir(path)) : false;
|
||||
}
|
||||
|
||||
bool rmdir(const char* path) override {
|
||||
return _mounted ? (FR_OK == f_unlink(path)) : false;
|
||||
}
|
||||
|
||||
bool setConfig(const FSConfig &cfg) override {
|
||||
if ((cfg._type != FatFSConfig::FSId) || _mounted) {
|
||||
DEBUGV("FatFS::setConfig: invalid config or already mounted\n");
|
||||
return false;
|
||||
}
|
||||
_cfg = *static_cast<const FatFSConfig *>(&cfg);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool begin() override;
|
||||
void end() override;
|
||||
bool format() override;
|
||||
|
||||
// Helper function, takes FAT and makes standard time_t
|
||||
static time_t FatToTimeT(uint16_t d, uint16_t t) {
|
||||
struct tm tiempo;
|
||||
memset(&tiempo, 0, sizeof(tiempo));
|
||||
tiempo.tm_sec = (((int)t) << 1) & 0x3e;
|
||||
tiempo.tm_min = (((int)t) >> 5) & 0x3f;
|
||||
tiempo.tm_hour = (((int)t) >> 11) & 0x1f;
|
||||
tiempo.tm_mday = (int)(d & 0x1f);
|
||||
tiempo.tm_mon = ((int)(d >> 5) & 0x0f) - 1;
|
||||
tiempo.tm_year = ((int)(d >> 9) & 0x7f) + 80;
|
||||
tiempo.tm_isdst = -1;
|
||||
return mktime(&tiempo);
|
||||
}
|
||||
|
||||
virtual void setTimeCallback(time_t (*cb)(void)) override {
|
||||
extern time_t (*__fatfs_timeCallback)(void);
|
||||
__fatfs_timeCallback = cb;
|
||||
}
|
||||
|
||||
void sync() {
|
||||
disk_ioctl(0, CTRL_SYNC, nullptr);
|
||||
}
|
||||
|
||||
protected:
|
||||
friend class FatFileImpl;
|
||||
friend class FatFSDirImpl;
|
||||
|
||||
FATFS* getFs() {
|
||||
return &_fatfs;
|
||||
}
|
||||
|
||||
static int _getFlags(OpenMode openMode, AccessMode accessMode) {
|
||||
int mode = 0;
|
||||
if (openMode & OM_CREATE) {
|
||||
mode |= FA_CREATE_ALWAYS;
|
||||
}
|
||||
if (openMode & OM_APPEND) {
|
||||
mode |= FA_OPEN_APPEND;
|
||||
}
|
||||
if (openMode & OM_TRUNCATE) {
|
||||
mode |= 0; // TODO - no truncate?
|
||||
}
|
||||
if ((accessMode & (AM_READ | AM_WRITE)) == (AM_READ | AM_WRITE)) {
|
||||
mode |= FA_READ | FA_WRITE;
|
||||
} else if (accessMode & AM_READ) {
|
||||
mode |= FA_READ;
|
||||
} else if (accessMode & AM_WRITE) {
|
||||
mode |= FA_WRITE;
|
||||
}
|
||||
return mode;
|
||||
}
|
||||
|
||||
FATFS _fatfs;
|
||||
FatFSConfig _cfg;
|
||||
bool _mounted;
|
||||
};
|
||||
|
||||
|
||||
class FatFSFileImpl : public FileImpl {
|
||||
public:
|
||||
FatFSFileImpl(FatFSImpl *fs, std::shared_ptr<FIL> fd, const char *name, bool writable)
|
||||
: _fs(fs), _fd(fd), _opened(true), _writable(writable) {
|
||||
_name = std::shared_ptr<char>(new char[strlen(name) + 1], std::default_delete<char[]>());
|
||||
strcpy(_name.get(), name);
|
||||
}
|
||||
|
||||
~FatFSFileImpl() override {
|
||||
flush();
|
||||
close();
|
||||
}
|
||||
|
||||
int availableForWrite() override {
|
||||
return 1; // TODO - not implemented? _opened ? _fd->availableSpaceForWrite() : 0;
|
||||
}
|
||||
|
||||
size_t write(const uint8_t *buf, size_t size) override {
|
||||
if (_opened) {
|
||||
UINT bw;
|
||||
if (FR_OK == f_write(_fd.get(), buf, size, &bw)) {
|
||||
return bw;
|
||||
}
|
||||
}
|
||||
return -1; // some kind of error
|
||||
}
|
||||
|
||||
int read(uint8_t* buf, size_t size) override {
|
||||
if (_opened) {
|
||||
UINT bw;
|
||||
if (FR_OK == f_read(_fd.get(), buf, size, &bw)) {
|
||||
return bw;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void flush() override {
|
||||
if (_opened) {
|
||||
f_sync(_fd.get());
|
||||
if (_writable) {
|
||||
_fs->sync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool seek(uint32_t pos, SeekMode mode) override {
|
||||
if (!_opened) {
|
||||
return false;
|
||||
}
|
||||
switch (mode) {
|
||||
case SeekSet:
|
||||
return FR_OK == f_lseek(_fd.get(), pos);
|
||||
case SeekEnd:
|
||||
return FR_OK == f_lseek(_fd.get(), f_size(_fd.get()) - pos); // TODO again, odd from POSIX
|
||||
case SeekCur:
|
||||
return FR_OK == f_lseek(_fd.get(), f_tell(_fd.get()) + pos);
|
||||
default:
|
||||
// Should not be hit, we've got an invalid seek mode
|
||||
DEBUGV("FatFSFileImpl::seek: invalid seek mode %d\n", mode);
|
||||
assert((mode == SeekSet) || (mode == SeekEnd) || (mode == SeekCur)); // Will fail and give meaningful assert message
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
size_t position() const override {
|
||||
return _opened ? f_tell(_fd.get()) : 0;
|
||||
}
|
||||
|
||||
size_t size() const override {
|
||||
return _opened ? f_size(_fd.get()) : 0;
|
||||
}
|
||||
|
||||
bool truncate(uint32_t size) override {
|
||||
if (!_opened) {
|
||||
DEBUGV("FatFSFileImpl::truncate: file not opened\n");
|
||||
return false;
|
||||
}
|
||||
if (FR_OK == f_lseek(_fd.get(), size)) {
|
||||
return FR_OK == f_truncate(_fd.get());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void close() override {
|
||||
if (_opened) {
|
||||
f_close(_fd.get());
|
||||
// f_close does a disk_sync
|
||||
_opened = false;
|
||||
}
|
||||
}
|
||||
|
||||
const char* name() const override {
|
||||
if (!_opened) {
|
||||
DEBUGV("FatFSFileImpl::name: file not opened\n");
|
||||
return nullptr;
|
||||
} else {
|
||||
const char *p = _name.get();
|
||||
const char *slash = strrchr(p, '/');
|
||||
// For names w/o any path elements, return directly
|
||||
// If there are slashes, return name after the last slash
|
||||
// (note that strrchr will return the address of the slash,
|
||||
// so need to increment to ckip it)
|
||||
return (slash && slash[1]) ? slash + 1 : p;
|
||||
}
|
||||
}
|
||||
|
||||
const char* fullName() const override {
|
||||
return _opened ? _name.get() : nullptr;
|
||||
}
|
||||
|
||||
bool isFile() const override {
|
||||
if (_opened) {
|
||||
FILINFO fno;
|
||||
if (FR_OK == f_stat(_name.get(), &fno)) {
|
||||
return (fno.fattrib & AM_DIR) ? false : true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isDirectory() const override {
|
||||
if (_opened) {
|
||||
FILINFO fno;
|
||||
if (FR_OK == f_stat(_name.get(), &fno)) {
|
||||
return (fno.fattrib & AM_DIR) ? true : false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
time_t getLastWrite() override {
|
||||
return getCreationTime(); // TODO - FatFS doesn't seem to report both filetimes
|
||||
}
|
||||
|
||||
time_t getCreationTime() override {
|
||||
time_t ftime = 0;
|
||||
if (_opened && _fd) {
|
||||
FILINFO fno;
|
||||
if (FR_OK == f_stat(_name.get(), &fno)) {
|
||||
ftime = FatFSImpl::FatToTimeT(fno.fdate, fno.ftime);
|
||||
}
|
||||
}
|
||||
return ftime;
|
||||
}
|
||||
|
||||
protected:
|
||||
FatFSImpl* _fs;
|
||||
std::shared_ptr<FIL> _fd;
|
||||
std::shared_ptr<char> _name;
|
||||
bool _opened;
|
||||
bool _writable;
|
||||
};
|
||||
|
||||
class FatFSDirImpl : public DirImpl {
|
||||
public:
|
||||
FatFSDirImpl(const String& pattern, FatFSImpl* fs, std::shared_ptr<DIR> dir, const char *dirPath = nullptr)
|
||||
: _pattern(pattern), _fs(fs), _dir(dir), _valid(false), _dirPath(nullptr) {
|
||||
if (dirPath) {
|
||||
_dirPath = std::shared_ptr<char>(new char[strlen(dirPath) + 1], std::default_delete<char[]>());
|
||||
strcpy(_dirPath.get(), dirPath);
|
||||
}
|
||||
f_opendir(dir.get(), dirPath);
|
||||
}
|
||||
|
||||
~FatFSDirImpl() override {
|
||||
if (_dir) {
|
||||
f_closedir(_dir.get());
|
||||
}
|
||||
}
|
||||
|
||||
FileImplPtr openFile(OpenMode openMode, AccessMode accessMode) override {
|
||||
if (!_valid) {
|
||||
return FileImplPtr();
|
||||
}
|
||||
// MAX_PATH on FAT32 is potentially 260 bytes per most implementations
|
||||
char tmpName[260];
|
||||
snprintf(tmpName, sizeof(tmpName), "%s%s%s", _dirPath.get() ? _dirPath.get() : "", _dirPath.get() && _dirPath.get()[0] ? "/" : "", _lfn);
|
||||
return _fs->open((const char *)tmpName, openMode, accessMode);
|
||||
}
|
||||
|
||||
const char* fileName() override {
|
||||
if (!_valid) {
|
||||
DEBUGV("FatFSDirImpl::fileName: directory not valid\n");
|
||||
return nullptr;
|
||||
}
|
||||
return (const char*) _lfn; //_dirent.name;
|
||||
}
|
||||
|
||||
size_t fileSize() override {
|
||||
if (!_valid) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return _size;
|
||||
}
|
||||
|
||||
time_t fileTime() override {
|
||||
if (!_valid) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return _time;
|
||||
}
|
||||
|
||||
time_t fileCreationTime() override {
|
||||
if (!_valid) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return _creation;
|
||||
}
|
||||
|
||||
bool isFile() const override {
|
||||
return _valid ? _isFile : false;
|
||||
}
|
||||
|
||||
bool isDirectory() const override {
|
||||
return _valid ? _isDirectory : false;
|
||||
}
|
||||
|
||||
bool next() override {
|
||||
const int n = _pattern.length();
|
||||
do {
|
||||
FILINFO fno;
|
||||
if (FR_OK == f_readdir(_dir.get(), &fno) && fno.fname[0]) {
|
||||
_valid = true;
|
||||
_size = fno.fsize;
|
||||
_isFile = fno.fattrib & AM_DIR ? false : true;
|
||||
_isDirectory = !_isFile;
|
||||
_time = FatFSImpl::FatToTimeT(fno.fdate, fno.ftime);
|
||||
_creation = _time;
|
||||
strncpy(_lfn, fno.fname, sizeof(_lfn));
|
||||
} else {
|
||||
_valid = false;
|
||||
}
|
||||
} while (_valid && strncmp((const char*) _lfn, _pattern.c_str(), n) != 0);
|
||||
return _valid;
|
||||
}
|
||||
|
||||
bool rewind() override {
|
||||
_valid = false;
|
||||
return FR_OK == f_rewinddir(_dir.get());
|
||||
return false;
|
||||
}
|
||||
|
||||
protected:
|
||||
String _pattern;
|
||||
FatFSImpl* _fs;
|
||||
std::shared_ptr<DIR> _dir;
|
||||
bool _valid;
|
||||
char _lfn[64];
|
||||
time_t _time;
|
||||
time_t _creation;
|
||||
std::shared_ptr<char> _dirPath;
|
||||
uint32_t _size;
|
||||
bool _isFile;
|
||||
bool _isDirectory;
|
||||
};
|
||||
|
||||
}; // namespace sdfs
|
||||
|
||||
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_FATFS)
|
||||
extern FS FatFS;
|
||||
using fatfs::FatFSConfig;
|
||||
#endif
|
||||
@@ -0,0 +1,81 @@
|
||||
/* -----------------------------------------------------------------------/
|
||||
/ Low level disk interface modlue include file (C)ChaN, 2019 /
|
||||
/-----------------------------------------------------------------------*/
|
||||
|
||||
#ifndef _DISKIO_DEFINED
|
||||
#define _DISKIO_DEFINED
|
||||
|
||||
//#ifdef __cplusplus
|
||||
//extern "C" {
|
||||
//#endif
|
||||
|
||||
namespace fatfs {
|
||||
|
||||
/* Status of Disk Functions */
|
||||
typedef BYTE DSTATUS;
|
||||
|
||||
/* Results of Disk Functions */
|
||||
typedef enum {
|
||||
RES_OK = 0, /* 0: Successful */
|
||||
RES_ERROR, /* 1: R/W Error */
|
||||
RES_WRPRT, /* 2: Write Protected */
|
||||
RES_NOTRDY, /* 3: Not Ready */
|
||||
RES_PARERR /* 4: Invalid Parameter */
|
||||
} DRESULT;
|
||||
|
||||
|
||||
/*---------------------------------------*/
|
||||
/* Prototypes for disk control functions */
|
||||
|
||||
|
||||
DSTATUS disk_initialize(BYTE pdrv);
|
||||
DSTATUS disk_status(BYTE pdrv);
|
||||
DRESULT disk_read(BYTE pdrv, BYTE* buff, LBA_t sector, UINT count);
|
||||
DRESULT disk_write(BYTE pdrv, const BYTE* buff, LBA_t sector, UINT count);
|
||||
DRESULT disk_ioctl(BYTE pdrv, BYTE cmd, void* buff);
|
||||
|
||||
|
||||
/* Disk Status Bits (DSTATUS) */
|
||||
|
||||
#define STA_NOINIT 0x01 /* Drive not initialized */
|
||||
#define STA_NODISK 0x02 /* No medium in the drive */
|
||||
#define STA_PROTECT 0x04 /* Write protected */
|
||||
|
||||
|
||||
/* Command code for disk_ioctrl fucntion */
|
||||
|
||||
/* Generic command (Used by FatFs) */
|
||||
#define CTRL_SYNC 0 /* Complete pending write process (needed at FF_FS_READONLY == 0) */
|
||||
#define GET_SECTOR_COUNT 1 /* Get media size (needed at FF_USE_MKFS == 1) */
|
||||
#define GET_SECTOR_SIZE 2 /* Get sector size (needed at FF_MAX_SS != FF_MIN_SS) */
|
||||
#define GET_BLOCK_SIZE 3 /* Get erase block size (needed at FF_USE_MKFS == 1) */
|
||||
#define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at FF_USE_TRIM == 1) */
|
||||
|
||||
/* Generic command (Not used by FatFs) */
|
||||
#define CTRL_POWER 5 /* Get/Set power status */
|
||||
#define CTRL_LOCK 6 /* Lock/Unlock media removal */
|
||||
#define CTRL_EJECT 7 /* Eject media */
|
||||
#define CTRL_FORMAT 8 /* Create physical format on the media */
|
||||
|
||||
/* MMC/SDC specific ioctl command */
|
||||
#define MMC_GET_TYPE 10 /* Get card type */
|
||||
#define MMC_GET_CSD 11 /* Get CSD */
|
||||
#define MMC_GET_CID 12 /* Get CID */
|
||||
#define MMC_GET_OCR 13 /* Get OCR */
|
||||
#define MMC_GET_SDSTAT 14 /* Get SD status */
|
||||
#define ISDIO_READ 55 /* Read data form SD iSDIO register */
|
||||
#define ISDIO_WRITE 56 /* Write data to SD iSDIO register */
|
||||
#define ISDIO_MRITE 57 /* Masked write data to SD iSDIO register */
|
||||
|
||||
/* ATA/CF specific ioctl command */
|
||||
#define ATA_GET_REV 20 /* Get F/W revision */
|
||||
#define ATA_GET_MODEL 21 /* Get model name */
|
||||
#define ATA_GET_SN 22 /* Get serial number */
|
||||
|
||||
};
|
||||
|
||||
//#ifdef __cplusplus
|
||||
//}
|
||||
//#endif
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,431 @@
|
||||
/* ----------------------------------------------------------------------------/
|
||||
/ FatFs - Generic FAT Filesystem module R0.15 /
|
||||
/-----------------------------------------------------------------------------/
|
||||
/
|
||||
/ Copyright (C) 2022, ChaN, all right reserved.
|
||||
/
|
||||
/ FatFs module is an open source software. Redistribution and use of FatFs in
|
||||
/ source and binary forms, with or without modification, are permitted provided
|
||||
/ that the following condition is met:
|
||||
|
||||
/ 1. Redistributions of source code must retain the above copyright notice,
|
||||
/ this condition and the following disclaimer.
|
||||
/
|
||||
/ This software is provided by the copyright holder and contributors "AS IS"
|
||||
/ and any warranties related to this software are DISCLAIMED.
|
||||
/ The copyright owner or contributors be NOT LIABLE for any damages caused
|
||||
/ by use of this software.
|
||||
/
|
||||
/----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef FF_DEFINED
|
||||
#define FF_DEFINED 80286 /* Revision ID */
|
||||
|
||||
//#ifdef __cplusplus
|
||||
//extern "C" {
|
||||
//#endif
|
||||
|
||||
#include "ffconf.h" /* FatFs configuration options */
|
||||
|
||||
#if FF_DEFINED != FFCONF_DEF
|
||||
#error Wrong configuration file (ffconf.h).
|
||||
#endif
|
||||
|
||||
|
||||
/* Integer types used for FatFs API */
|
||||
|
||||
#if defined(_WIN32) /* Windows VC++ (for development only) */
|
||||
#define FF_INTDEF 2
|
||||
#include <windows.h>
|
||||
typedef unsigned __int64 QWORD;
|
||||
#include <float.h>
|
||||
#define isnan(v) _isnan(v)
|
||||
#define isinf(v) (!_finite(v))
|
||||
|
||||
#elif (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__cplusplus) /* C99 or later */
|
||||
#define FF_INTDEF 2
|
||||
#include <stdint.h>
|
||||
namespace fatfs {
|
||||
typedef unsigned int UINT; /* int must be 16-bit or 32-bit */
|
||||
typedef unsigned char BYTE; /* char must be 8-bit */
|
||||
typedef uint16_t WORD; /* 16-bit unsigned integer */
|
||||
typedef uint32_t DWORD; /* 32-bit unsigned integer */
|
||||
typedef uint64_t QWORD; /* 64-bit unsigned integer */
|
||||
typedef WORD WCHAR; /* UTF-16 character type */
|
||||
};
|
||||
#else /* Earlier than C99 */
|
||||
#define FF_INTDEF 1
|
||||
typedef unsigned int UINT; /* int must be 16-bit or 32-bit */
|
||||
typedef unsigned char BYTE; /* char must be 8-bit */
|
||||
typedef unsigned short WORD; /* 16-bit unsigned integer */
|
||||
typedef unsigned long DWORD; /* 32-bit unsigned integer */
|
||||
typedef WORD WCHAR; /* UTF-16 character type */
|
||||
#endif
|
||||
|
||||
namespace fatfs {
|
||||
/* Type of file size and LBA variables */
|
||||
|
||||
#if FF_FS_EXFAT
|
||||
#if FF_INTDEF != 2
|
||||
#error exFAT feature wants C99 or later
|
||||
#endif
|
||||
typedef QWORD FSIZE_t;
|
||||
#if FF_LBA64
|
||||
typedef QWORD LBA_t;
|
||||
#else
|
||||
typedef DWORD LBA_t;
|
||||
#endif
|
||||
#else
|
||||
#if FF_LBA64
|
||||
#error exFAT needs to be enabled when enable 64-bit LBA
|
||||
#endif
|
||||
typedef DWORD FSIZE_t;
|
||||
typedef DWORD LBA_t;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Type of path name strings on FatFs API (TCHAR) */
|
||||
|
||||
#if FF_USE_LFN && FF_LFN_UNICODE == 1 /* Unicode in UTF-16 encoding */
|
||||
typedef WCHAR TCHAR;
|
||||
#define _T(x) L ## x
|
||||
#define _TEXT(x) L ## x
|
||||
#elif FF_USE_LFN && FF_LFN_UNICODE == 2 /* Unicode in UTF-8 encoding */
|
||||
typedef char TCHAR;
|
||||
#define _T(x) u8 ## x
|
||||
#define _TEXT(x) u8 ## x
|
||||
#elif FF_USE_LFN && FF_LFN_UNICODE == 3 /* Unicode in UTF-32 encoding */
|
||||
typedef DWORD TCHAR;
|
||||
#define _T(x) U ## x
|
||||
#define _TEXT(x) U ## x
|
||||
#elif FF_USE_LFN && (FF_LFN_UNICODE < 0 || FF_LFN_UNICODE > 3)
|
||||
#error Wrong FF_LFN_UNICODE setting
|
||||
#else /* ANSI/OEM code in SBCS/DBCS */
|
||||
typedef char TCHAR;
|
||||
#define _T(x) x
|
||||
#define _TEXT(x) x
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Definitions of volume management */
|
||||
|
||||
#if FF_MULTI_PARTITION /* Multiple partition configuration */
|
||||
typedef struct {
|
||||
BYTE pd; /* Physical drive number */
|
||||
BYTE pt; /* Partition: 0:Auto detect, 1-4:Forced partition) */
|
||||
} PARTITION;
|
||||
extern PARTITION VolToPart[]; /* Volume - Partition mapping table */
|
||||
#endif
|
||||
|
||||
#if FF_STR_VOLUME_ID
|
||||
#ifndef FF_VOLUME_STRS
|
||||
extern const char* VolumeStr[FF_VOLUMES]; /* User defied volume ID */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Filesystem object structure (FATFS) */
|
||||
|
||||
typedef struct {
|
||||
BYTE fs_type; /* Filesystem type (0:not mounted) */
|
||||
BYTE pdrv; /* Volume hosting physical drive */
|
||||
BYTE ldrv; /* Logical drive number (used only when FF_FS_REENTRANT) */
|
||||
BYTE n_fats; /* Number of FATs (1 or 2) */
|
||||
BYTE wflag; /* win[] status (b0:dirty) */
|
||||
BYTE fsi_flag; /* FSINFO status (b7:disabled, b0:dirty) */
|
||||
WORD id; /* Volume mount ID */
|
||||
WORD n_rootdir; /* Number of root directory entries (FAT12/16) */
|
||||
WORD csize; /* Cluster size [sectors] */
|
||||
#if FF_MAX_SS != FF_MIN_SS
|
||||
WORD ssize; /* Sector size (512, 1024, 2048 or 4096) */
|
||||
#endif
|
||||
#if FF_USE_LFN
|
||||
WCHAR* lfnbuf; /* LFN working buffer */
|
||||
#endif
|
||||
#if FF_FS_EXFAT
|
||||
BYTE* dirbuf; /* Directory entry block scratchpad buffer for exFAT */
|
||||
#endif
|
||||
#if !FF_FS_READONLY
|
||||
DWORD last_clst; /* Last allocated cluster */
|
||||
DWORD free_clst; /* Number of free clusters */
|
||||
#endif
|
||||
#if FF_FS_RPATH
|
||||
DWORD cdir; /* Current directory start cluster (0:root) */
|
||||
#if FF_FS_EXFAT
|
||||
DWORD cdc_scl; /* Containing directory start cluster (invalid when cdir is 0) */
|
||||
DWORD cdc_size; /* b31-b8:Size of containing directory, b7-b0: Chain status */
|
||||
DWORD cdc_ofs; /* Offset in the containing directory (invalid when cdir is 0) */
|
||||
#endif
|
||||
#endif
|
||||
DWORD n_fatent; /* Number of FAT entries (number of clusters + 2) */
|
||||
DWORD fsize; /* Number of sectors per FAT */
|
||||
LBA_t volbase; /* Volume base sector */
|
||||
LBA_t fatbase; /* FAT base sector */
|
||||
LBA_t dirbase; /* Root directory base sector (FAT12/16) or cluster (FAT32/exFAT) */
|
||||
LBA_t database; /* Data base sector */
|
||||
#if FF_FS_EXFAT
|
||||
LBA_t bitbase; /* Allocation bitmap base sector */
|
||||
#endif
|
||||
LBA_t winsect; /* Current sector appearing in the win[] */
|
||||
BYTE win[FF_MAX_SS]; /* Disk access window for Directory, FAT (and file data at tiny cfg) */
|
||||
} FATFS;
|
||||
|
||||
|
||||
|
||||
/* Object ID and allocation information (FFOBJID) */
|
||||
|
||||
typedef struct {
|
||||
FATFS* fs; /* Pointer to the hosting volume of this object */
|
||||
WORD id; /* Hosting volume's mount ID */
|
||||
BYTE attr; /* Object attribute */
|
||||
BYTE stat; /* Object chain status (b1-0: =0:not contiguous, =2:contiguous, =3:fragmented in this session, b2:sub-directory stretched) */
|
||||
DWORD sclust; /* Object data start cluster (0:no cluster or root directory) */
|
||||
FSIZE_t objsize; /* Object size (valid when sclust != 0) */
|
||||
#if FF_FS_EXFAT
|
||||
DWORD n_cont; /* Size of first fragment - 1 (valid when stat == 3) */
|
||||
DWORD n_frag; /* Size of last fragment needs to be written to FAT (valid when not zero) */
|
||||
DWORD c_scl; /* Containing directory start cluster (valid when sclust != 0) */
|
||||
DWORD c_size; /* b31-b8:Size of containing directory, b7-b0: Chain status (valid when c_scl != 0) */
|
||||
DWORD c_ofs; /* Offset in the containing directory (valid when file object and sclust != 0) */
|
||||
#endif
|
||||
#if FF_FS_LOCK
|
||||
UINT lockid; /* File lock ID origin from 1 (index of file semaphore table Files[]) */
|
||||
#endif
|
||||
} FFOBJID;
|
||||
|
||||
|
||||
|
||||
/* File object structure (FIL) */
|
||||
|
||||
typedef struct {
|
||||
FFOBJID obj; /* Object identifier (must be the 1st member to detect invalid object pointer) */
|
||||
BYTE flag; /* File status flags */
|
||||
BYTE err; /* Abort flag (error code) */
|
||||
FSIZE_t fptr; /* File read/write pointer (Zeroed on file open) */
|
||||
DWORD clust; /* Current cluster of fpter (invalid when fptr is 0) */
|
||||
LBA_t sect; /* Sector number appearing in buf[] (0:invalid) */
|
||||
#if !FF_FS_READONLY
|
||||
LBA_t dir_sect; /* Sector number containing the directory entry (not used at exFAT) */
|
||||
BYTE* dir_ptr; /* Pointer to the directory entry in the win[] (not used at exFAT) */
|
||||
#endif
|
||||
#if FF_USE_FASTSEEK
|
||||
DWORD* cltbl; /* Pointer to the cluster link map table (nulled on open, set by application) */
|
||||
#endif
|
||||
#if !FF_FS_TINY
|
||||
BYTE buf[FF_MAX_SS]; /* File private data read/write window */
|
||||
#endif
|
||||
} FIL;
|
||||
|
||||
|
||||
|
||||
/* Directory object structure (DIR) */
|
||||
|
||||
typedef struct {
|
||||
FFOBJID obj; /* Object identifier */
|
||||
DWORD dptr; /* Current read/write offset */
|
||||
DWORD clust; /* Current cluster */
|
||||
LBA_t sect; /* Current sector (0:Read operation has terminated) */
|
||||
BYTE* dir; /* Pointer to the directory item in the win[] */
|
||||
BYTE fn[12]; /* SFN (in/out) {body[8],ext[3],status[1]} */
|
||||
#if FF_USE_LFN
|
||||
DWORD blk_ofs; /* Offset of current entry block being processed (0xFFFFFFFF:Invalid) */
|
||||
#endif
|
||||
#if FF_USE_FIND
|
||||
const TCHAR* pat; /* Pointer to the name matching pattern */
|
||||
#endif
|
||||
} DIR;
|
||||
|
||||
|
||||
|
||||
/* File information structure (FILINFO) */
|
||||
|
||||
typedef struct {
|
||||
FSIZE_t fsize; /* File size */
|
||||
WORD fdate; /* Modified date */
|
||||
WORD ftime; /* Modified time */
|
||||
BYTE fattrib; /* File attribute */
|
||||
#if FF_USE_LFN
|
||||
TCHAR altname[FF_SFN_BUF + 1];/* Alternative file name */
|
||||
TCHAR fname[FF_LFN_BUF + 1]; /* Primary file name */
|
||||
#else
|
||||
TCHAR fname[12 + 1]; /* File name */
|
||||
#endif
|
||||
} FILINFO;
|
||||
|
||||
|
||||
|
||||
/* Format parameter structure (MKFS_PARM) */
|
||||
|
||||
typedef struct {
|
||||
BYTE fmt; /* Format option (FM_FAT, FM_FAT32, FM_EXFAT and FM_SFD) */
|
||||
BYTE n_fat; /* Number of FATs */
|
||||
UINT align; /* Data area alignment (sector) */
|
||||
UINT n_root; /* Number of root directory entries */
|
||||
DWORD au_size; /* Cluster size (byte) */
|
||||
} MKFS_PARM;
|
||||
|
||||
|
||||
|
||||
/* File function return code (FRESULT) */
|
||||
|
||||
typedef enum {
|
||||
FR_OK = 0, /* (0) Succeeded */
|
||||
FR_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */
|
||||
FR_INT_ERR, /* (2) Assertion failed */
|
||||
FR_NOT_READY, /* (3) The physical drive cannot work */
|
||||
FR_NO_FILE, /* (4) Could not find the file */
|
||||
FR_NO_PATH, /* (5) Could not find the path */
|
||||
FR_INVALID_NAME, /* (6) The path name format is invalid */
|
||||
FR_DENIED, /* (7) Access denied due to prohibited access or directory full */
|
||||
FR_EXIST, /* (8) Access denied due to prohibited access */
|
||||
FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */
|
||||
FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */
|
||||
FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */
|
||||
FR_NOT_ENABLED, /* (12) The volume has no work area */
|
||||
FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */
|
||||
FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any problem */
|
||||
FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */
|
||||
FR_LOCKED, /* (16) The operation is rejected according to the file sharing policy */
|
||||
FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */
|
||||
FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > FF_FS_LOCK */
|
||||
FR_INVALID_PARAMETER /* (19) Given parameter is invalid */
|
||||
} FRESULT;
|
||||
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
/* FatFs Module Application Interface */
|
||||
/*--------------------------------------------------------------*/
|
||||
|
||||
FRESULT f_open(FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */
|
||||
FRESULT f_close(FIL* fp); /* Close an open file object */
|
||||
FRESULT f_read(FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from the file */
|
||||
FRESULT f_write(FIL* fp, const void* buff, UINT btw, UINT* bw); /* Write data to the file */
|
||||
FRESULT f_lseek(FIL* fp, FSIZE_t ofs); /* Move file pointer of the file object */
|
||||
FRESULT f_truncate(FIL* fp); /* Truncate the file */
|
||||
FRESULT f_sync(FIL* fp); /* Flush cached data of the writing file */
|
||||
FRESULT f_opendir(DIR* dp, const TCHAR* path); /* Open a directory */
|
||||
FRESULT f_closedir(DIR* dp); /* Close an open directory */
|
||||
FRESULT f_readdir(DIR* dp, FILINFO* fno); /* Read a directory item */
|
||||
FRESULT f_findfirst(DIR* dp, FILINFO* fno, const TCHAR* path, const TCHAR* pattern); /* Find first file */
|
||||
FRESULT f_findnext(DIR* dp, FILINFO* fno); /* Find next file */
|
||||
FRESULT f_mkdir(const TCHAR* path); /* Create a sub directory */
|
||||
FRESULT f_unlink(const TCHAR* path); /* Delete an existing file or directory */
|
||||
FRESULT f_rename(const TCHAR* path_old, const TCHAR* path_new); /* Rename/Move a file or directory */
|
||||
FRESULT f_stat(const TCHAR* path, FILINFO* fno); /* Get file status */
|
||||
FRESULT f_chmod(const TCHAR* path, BYTE attr, BYTE mask); /* Change attribute of a file/dir */
|
||||
FRESULT f_utime(const TCHAR* path, const FILINFO* fno); /* Change timestamp of a file/dir */
|
||||
FRESULT f_chdir(const TCHAR* path); /* Change current directory */
|
||||
FRESULT f_chdrive(const TCHAR* path); /* Change current drive */
|
||||
FRESULT f_getcwd(TCHAR* buff, UINT len); /* Get current directory */
|
||||
FRESULT f_getfree(const TCHAR* path, DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */
|
||||
FRESULT f_getlabel(const TCHAR* path, TCHAR* label, DWORD* vsn); /* Get volume label */
|
||||
FRESULT f_setlabel(const TCHAR* label); /* Set volume label */
|
||||
FRESULT f_forward(FIL* fp, UINT(*func)(const BYTE*, UINT), UINT btf, UINT* bf); /* Forward data to the stream */
|
||||
FRESULT f_expand(FIL* fp, FSIZE_t fsz, BYTE opt); /* Allocate a contiguous block to the file */
|
||||
FRESULT f_mount(FATFS* fs, const TCHAR* path, BYTE opt); /* Mount/Unmount a logical drive */
|
||||
FRESULT f_mkfs(const TCHAR* path, const MKFS_PARM* opt, void* work, UINT len); /* Create a FAT volume */
|
||||
FRESULT f_fdisk(BYTE pdrv, const LBA_t ptbl[], void* work); /* Divide a physical drive into some partitions */
|
||||
FRESULT f_setcp(WORD cp); /* Set current code page */
|
||||
int f_putc(TCHAR c, FIL* fp); /* Put a character to the file */
|
||||
int f_puts(const TCHAR* str, FIL* cp); /* Put a string to the file */
|
||||
int f_printf(FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */
|
||||
TCHAR* f_gets(TCHAR* buff, int len, FIL* fp); /* Get a string from the file */
|
||||
|
||||
/* Some API fucntions are implemented as macro */
|
||||
|
||||
#define f_eof(fp) ((int)((fp)->fptr == (fp)->obj.objsize))
|
||||
#define f_error(fp) ((fp)->err)
|
||||
#define f_tell(fp) ((fp)->fptr)
|
||||
#define f_size(fp) ((fp)->obj.objsize)
|
||||
#define f_rewind(fp) f_lseek((fp), 0)
|
||||
#define f_rewinddir(dp) f_readdir((dp), 0)
|
||||
#define f_rmdir(path) f_unlink(path)
|
||||
#define f_unmount(path) f_mount(0, path, 0)
|
||||
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
/* Additional Functions */
|
||||
/*--------------------------------------------------------------*/
|
||||
|
||||
/* RTC function (provided by user) */
|
||||
#if !FF_FS_READONLY && !FF_FS_NORTC
|
||||
DWORD get_fattime(void); /* Get current time */
|
||||
#endif
|
||||
|
||||
|
||||
/* LFN support functions (defined in ffunicode.c) */
|
||||
|
||||
#if FF_USE_LFN >= 1
|
||||
WCHAR ff_oem2uni(WCHAR oem, WORD cp); /* OEM code to Unicode conversion */
|
||||
WCHAR ff_uni2oem(DWORD uni, WORD cp); /* Unicode to OEM code conversion */
|
||||
DWORD ff_wtoupper(DWORD uni); /* Unicode upper-case conversion */
|
||||
#endif
|
||||
|
||||
|
||||
/* O/S dependent functions (samples available in ffsystem.c) */
|
||||
|
||||
#if FF_USE_LFN == 3 /* Dynamic memory allocation */
|
||||
void* ff_memalloc(UINT msize); /* Allocate memory block */
|
||||
void ff_memfree(void* mblock); /* Free memory block */
|
||||
#endif
|
||||
#if FF_FS_REENTRANT /* Sync functions */
|
||||
int ff_mutex_create(int vol); /* Create a sync object */
|
||||
void ff_mutex_delete(int vol); /* Delete a sync object */
|
||||
int ff_mutex_take(int vol); /* Lock sync object */
|
||||
void ff_mutex_give(int vol); /* Unlock sync object */
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
/* Flags and Offset Address */
|
||||
/*--------------------------------------------------------------*/
|
||||
|
||||
/* File access mode and open method flags (3rd argument of f_open) */
|
||||
#define FA_READ 0x01
|
||||
#define FA_WRITE 0x02
|
||||
#define FA_OPEN_EXISTING 0x00
|
||||
#define FA_CREATE_NEW 0x04
|
||||
#define FA_CREATE_ALWAYS 0x08
|
||||
#define FA_OPEN_ALWAYS 0x10
|
||||
#define FA_OPEN_APPEND 0x30
|
||||
|
||||
/* Fast seek controls (2nd argument of f_lseek) */
|
||||
#define CREATE_LINKMAP ((FSIZE_t)0 - 1)
|
||||
|
||||
/* Format options (2nd argument of f_mkfs) */
|
||||
#define FM_FAT 0x01
|
||||
#define FM_FAT32 0x02
|
||||
#define FM_EXFAT 0x04
|
||||
#define FM_ANY 0x07
|
||||
#define FM_SFD 0x08
|
||||
|
||||
/* Filesystem type (FATFS.fs_type) */
|
||||
#define FS_FAT12 1
|
||||
#define FS_FAT16 2
|
||||
#define FS_FAT32 3
|
||||
#define FS_EXFAT 4
|
||||
|
||||
/* File attribute bits for directory entry (FILINFO.fattrib) */
|
||||
#define AM_RDO 0x01 /* Read only */
|
||||
#define AM_HID 0x02 /* Hidden */
|
||||
#define AM_SYS 0x04 /* System */
|
||||
#define AM_DIR 0x10 /* Directory */
|
||||
#define AM_ARC 0x20 /* Archive */
|
||||
|
||||
};
|
||||
|
||||
//#ifdef __cplusplus
|
||||
//}
|
||||
//#endif
|
||||
|
||||
#endif /* FF_DEFINED */
|
||||
@@ -0,0 +1,296 @@
|
||||
/* ---------------------------------------------------------------------------/
|
||||
/ Configurations of FatFs Module
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define FFCONF_DEF 80286 /* Revision ID */
|
||||
|
||||
/* ---------------------------------------------------------------------------/
|
||||
/ Function Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define FF_FS_READONLY 0
|
||||
/* This option switches read-only configuration. (0:Read/Write or 1:Read-only)
|
||||
/ Read-only configuration removes writing API functions, f_write(), f_sync(),
|
||||
/ f_unlink(), f_mkdir(), f_chmod(), f_rename(), f_truncate(), f_getfree()
|
||||
/ and optional writing functions as well. */
|
||||
|
||||
|
||||
#define FF_FS_MINIMIZE 0
|
||||
/* This option defines minimization level to remove some basic API functions.
|
||||
/
|
||||
/ 0: Basic functions are fully enabled.
|
||||
/ 1: f_stat(), f_getfree(), f_unlink(), f_mkdir(), f_truncate() and f_rename()
|
||||
/ are removed.
|
||||
/ 2: f_opendir(), f_readdir() and f_closedir() are removed in addition to 1.
|
||||
/ 3: f_lseek() function is removed in addition to 2. */
|
||||
|
||||
|
||||
#define FF_USE_FIND 1
|
||||
/* This option switches filtered directory read functions, f_findfirst() and
|
||||
/ f_findnext(). (0:Disable, 1:Enable 2:Enable with matching altname[] too) */
|
||||
|
||||
|
||||
#define FF_USE_MKFS 1
|
||||
/* This option switches f_mkfs() function. (0:Disable or 1:Enable) */
|
||||
|
||||
|
||||
#define FF_USE_FASTSEEK 1
|
||||
/* This option switches fast seek function. (0:Disable or 1:Enable) */
|
||||
|
||||
|
||||
#define FF_USE_EXPAND 0
|
||||
/* This option switches f_expand function. (0:Disable or 1:Enable) */
|
||||
|
||||
|
||||
#define FF_USE_CHMOD 1
|
||||
/* This option switches attribute manipulation functions, f_chmod() and f_utime().
|
||||
/ (0:Disable or 1:Enable) Also FF_FS_READONLY needs to be 0 to enable this option. */
|
||||
|
||||
|
||||
#define FF_USE_LABEL 1
|
||||
/* This option switches volume label functions, f_getlabel() and f_setlabel().
|
||||
/ (0:Disable or 1:Enable) */
|
||||
|
||||
|
||||
#define FF_USE_FORWARD 0
|
||||
/* This option switches f_forward() function. (0:Disable or 1:Enable) */
|
||||
|
||||
|
||||
#define FF_USE_STRFUNC 0
|
||||
#define FF_PRINT_LLI 1
|
||||
#define FF_PRINT_FLOAT 1
|
||||
#define FF_STRF_ENCODE 3
|
||||
/* FF_USE_STRFUNC switches string functions, f_gets(), f_putc(), f_puts() and
|
||||
/ f_printf().
|
||||
/
|
||||
/ 0: Disable. FF_PRINT_LLI, FF_PRINT_FLOAT and FF_STRF_ENCODE have no effect.
|
||||
/ 1: Enable without LF-CRLF conversion.
|
||||
/ 2: Enable with LF-CRLF conversion.
|
||||
/
|
||||
/ FF_PRINT_LLI = 1 makes f_printf() support long long argument and FF_PRINT_FLOAT = 1/2
|
||||
/ makes f_printf() support floating point argument. These features want C99 or later.
|
||||
/ When FF_LFN_UNICODE >= 1 with LFN enabled, string functions convert the character
|
||||
/ encoding in it. FF_STRF_ENCODE selects assumption of character encoding ON THE FILE
|
||||
/ to be read/written via those functions.
|
||||
/
|
||||
/ 0: ANSI/OEM in current CP
|
||||
/ 1: Unicode in UTF-16LE
|
||||
/ 2: Unicode in UTF-16BE
|
||||
/ 3: Unicode in UTF-8
|
||||
*/
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------/
|
||||
/ Locale and Namespace Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define FF_CODE_PAGE 437
|
||||
/* This option specifies the OEM code page to be used on the target system.
|
||||
/ Incorrect code page setting can cause a file open failure.
|
||||
/
|
||||
/ 437 - U.S.
|
||||
/ 720 - Arabic
|
||||
/ 737 - Greek
|
||||
/ 771 - KBL
|
||||
/ 775 - Baltic
|
||||
/ 850 - Latin 1
|
||||
/ 852 - Latin 2
|
||||
/ 855 - Cyrillic
|
||||
/ 857 - Turkish
|
||||
/ 860 - Portuguese
|
||||
/ 861 - Icelandic
|
||||
/ 862 - Hebrew
|
||||
/ 863 - Canadian French
|
||||
/ 864 - Arabic
|
||||
/ 865 - Nordic
|
||||
/ 866 - Russian
|
||||
/ 869 - Greek 2
|
||||
/ 932 - Japanese (DBCS)
|
||||
/ 936 - Simplified Chinese (DBCS)
|
||||
/ 949 - Korean (DBCS)
|
||||
/ 950 - Traditional Chinese (DBCS)
|
||||
/ 0 - Include all code pages above and configured by f_setcp()
|
||||
*/
|
||||
|
||||
|
||||
#define FF_USE_LFN 1
|
||||
#define FF_MAX_LFN 64
|
||||
/* The FF_USE_LFN switches the support for LFN (long file name).
|
||||
/
|
||||
/ 0: Disable LFN. FF_MAX_LFN has no effect.
|
||||
/ 1: Enable LFN with static working buffer on the BSS. Always NOT thread-safe.
|
||||
/ 2: Enable LFN with dynamic working buffer on the STACK.
|
||||
/ 3: Enable LFN with dynamic working buffer on the HEAP.
|
||||
/
|
||||
/ To enable the LFN, ffunicode.c needs to be added to the project. The LFN function
|
||||
/ requiers certain internal working buffer occupies (FF_MAX_LFN + 1) * 2 bytes and
|
||||
/ additional (FF_MAX_LFN + 44) / 15 * 32 bytes when exFAT is enabled.
|
||||
/ The FF_MAX_LFN defines size of the working buffer in UTF-16 code unit and it can
|
||||
/ be in range of 12 to 255. It is recommended to be set it 255 to fully support LFN
|
||||
/ specification.
|
||||
/ When use stack for the working buffer, take care on stack overflow. When use heap
|
||||
/ memory for the working buffer, memory management functions, ff_memalloc() and
|
||||
/ ff_memfree() exemplified in ffsystem.c, need to be added to the project. */
|
||||
|
||||
|
||||
#define FF_LFN_UNICODE 0
|
||||
/* This option switches the character encoding on the API when LFN is enabled.
|
||||
/
|
||||
/ 0: ANSI/OEM in current CP (TCHAR = char)
|
||||
/ 1: Unicode in UTF-16 (TCHAR = WCHAR)
|
||||
/ 2: Unicode in UTF-8 (TCHAR = char)
|
||||
/ 3: Unicode in UTF-32 (TCHAR = DWORD)
|
||||
/
|
||||
/ Also behavior of string I/O functions will be affected by this option.
|
||||
/ When LFN is not enabled, this option has no effect. */
|
||||
|
||||
|
||||
#define FF_LFN_BUF 64
|
||||
#define FF_SFN_BUF 12
|
||||
/* This set of options defines size of file name members in the FILINFO structure
|
||||
/ which is used to read out directory items. These values should be suffcient for
|
||||
/ the file names to read. The maximum possible length of the read file name depends
|
||||
/ on character encoding. When LFN is not enabled, these options have no effect. */
|
||||
|
||||
|
||||
#define FF_FS_RPATH 0
|
||||
/* This option configures support for relative path.
|
||||
/
|
||||
/ 0: Disable relative path and remove related functions.
|
||||
/ 1: Enable relative path. f_chdir() and f_chdrive() are available.
|
||||
/ 2: f_getcwd() function is available in addition to 1.
|
||||
*/
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------/
|
||||
/ Drive/Volume Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define FF_VOLUMES 1
|
||||
/* Number of volumes (logical drives) to be used. (1-10) */
|
||||
|
||||
|
||||
#define FF_STR_VOLUME_ID 0
|
||||
#define FF_VOLUME_STRS "FLASH"
|
||||
/* FF_STR_VOLUME_ID switches support for volume ID in arbitrary strings.
|
||||
/ When FF_STR_VOLUME_ID is set to 1 or 2, arbitrary strings can be used as drive
|
||||
/ number in the path name. FF_VOLUME_STRS defines the volume ID strings for each
|
||||
/ logical drives. Number of items must not be less than FF_VOLUMES. Valid
|
||||
/ characters for the volume ID strings are A-Z, a-z and 0-9, however, they are
|
||||
/ compared in case-insensitive. If FF_STR_VOLUME_ID >= 1 and FF_VOLUME_STRS is
|
||||
/ not defined, a user defined volume string table is needed as:
|
||||
/
|
||||
/ const char* VolumeStr[FF_VOLUMES] = {"ram","flash","sd","usb",...
|
||||
*/
|
||||
|
||||
|
||||
#define FF_MULTI_PARTITION 0
|
||||
/* This option switches support for multiple volumes on the physical drive.
|
||||
/ By default (0), each logical drive number is bound to the same physical drive
|
||||
/ number and only an FAT volume found on the physical drive will be mounted.
|
||||
/ When this function is enabled (1), each logical drive number can be bound to
|
||||
/ arbitrary physical drive and partition listed in the VolToPart[]. Also f_fdisk()
|
||||
/ function will be available. */
|
||||
|
||||
|
||||
#define FF_MIN_SS 512
|
||||
#define FF_MAX_SS 4096
|
||||
/* This set of options configures the range of sector size to be supported. (512,
|
||||
/ 1024, 2048 or 4096) Always set both 512 for most systems, generic memory card and
|
||||
/ harddisk, but a larger value may be required for on-board flash memory and some
|
||||
/ type of optical media. When FF_MAX_SS is larger than FF_MIN_SS, FatFs is configured
|
||||
/ for variable sector size mode and disk_ioctl() function needs to implement
|
||||
/ GET_SECTOR_SIZE command. */
|
||||
|
||||
|
||||
#define FF_LBA64 0
|
||||
/* This option switches support for 64-bit LBA. (0:Disable or 1:Enable)
|
||||
/ To enable the 64-bit LBA, also exFAT needs to be enabled. (FF_FS_EXFAT == 1) */
|
||||
|
||||
|
||||
#define FF_MIN_GPT 0x10000000
|
||||
/* Minimum number of sectors to switch GPT as partitioning format in f_mkfs and
|
||||
/ f_fdisk function. 0x100000000 max. This option has no effect when FF_LBA64 == 0. */
|
||||
|
||||
|
||||
#define FF_USE_TRIM 1
|
||||
/* This option switches support for ATA-TRIM. (0:Disable or 1:Enable)
|
||||
/ To enable Trim function, also CTRL_TRIM command should be implemented to the
|
||||
/ disk_ioctl() function. */
|
||||
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------/
|
||||
/ System Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define FF_FS_TINY 0
|
||||
/* This option switches tiny buffer configuration. (0:Normal or 1:Tiny)
|
||||
/ At the tiny configuration, size of file object (FIL) is shrinked FF_MAX_SS bytes.
|
||||
/ Instead of private sector buffer eliminated from the file object, common sector
|
||||
/ buffer in the filesystem object (FATFS) is used for the file data transfer. */
|
||||
|
||||
|
||||
#define FF_FS_EXFAT 0
|
||||
/* This option switches support for exFAT filesystem. (0:Disable or 1:Enable)
|
||||
/ To enable exFAT, also LFN needs to be enabled. (FF_USE_LFN >= 1)
|
||||
/ Note that enabling exFAT discards ANSI C (C89) compatibility. */
|
||||
|
||||
|
||||
#define FF_FS_NORTC 0
|
||||
#define FF_NORTC_MON 1
|
||||
#define FF_NORTC_MDAY 1
|
||||
#define FF_NORTC_YEAR 2022
|
||||
/* The option FF_FS_NORTC switches timestamp feature. If the system does not have
|
||||
/ an RTC or valid timestamp is not needed, set FF_FS_NORTC = 1 to disable the
|
||||
/ timestamp feature. Every object modified by FatFs will have a fixed timestamp
|
||||
/ defined by FF_NORTC_MON, FF_NORTC_MDAY and FF_NORTC_YEAR in local time.
|
||||
/ To enable timestamp function (FF_FS_NORTC = 0), get_fattime() function need to be
|
||||
/ added to the project to read current time form real-time clock. FF_NORTC_MON,
|
||||
/ FF_NORTC_MDAY and FF_NORTC_YEAR have no effect.
|
||||
/ These options have no effect in read-only configuration (FF_FS_READONLY = 1). */
|
||||
|
||||
|
||||
#define FF_FS_NOFSINFO 0
|
||||
/* If you need to know correct free space on the FAT32 volume, set bit 0 of this
|
||||
/ option, and f_getfree() function at the first time after volume mount will force
|
||||
/ a full FAT scan. Bit 1 controls the use of last allocated cluster number.
|
||||
/
|
||||
/ bit0=0: Use free cluster count in the FSINFO if available.
|
||||
/ bit0=1: Do not trust free cluster count in the FSINFO.
|
||||
/ bit1=0: Use last allocated cluster number in the FSINFO if available.
|
||||
/ bit1=1: Do not trust last allocated cluster number in the FSINFO.
|
||||
*/
|
||||
|
||||
|
||||
#define FF_FS_LOCK 0
|
||||
/* The option FF_FS_LOCK switches file lock function to control duplicated file open
|
||||
/ and illegal operation to open objects. This option must be 0 when FF_FS_READONLY
|
||||
/ is 1.
|
||||
/
|
||||
/ 0: Disable file lock function. To avoid volume corruption, application program
|
||||
/ should avoid illegal open, remove and rename to the open objects.
|
||||
/ >0: Enable file lock function. The value defines how many files/sub-directories
|
||||
/ can be opened simultaneously under file lock control. Note that the file
|
||||
/ lock control is independent of re-entrancy. */
|
||||
|
||||
|
||||
#define FF_FS_REENTRANT 0
|
||||
#define FF_FS_TIMEOUT 1000
|
||||
/* The option FF_FS_REENTRANT switches the re-entrancy (thread safe) of the FatFs
|
||||
/ module itself. Note that regardless of this option, file access to different
|
||||
/ volume is always re-entrant and volume control functions, f_mount(), f_mkfs()
|
||||
/ and f_fdisk() function, are always not re-entrant. Only file/directory access
|
||||
/ to the same volume is under control of this featuer.
|
||||
/
|
||||
/ 0: Disable re-entrancy. FF_FS_TIMEOUT have no effect.
|
||||
/ 1: Enable re-entrancy. Also user provided synchronization handlers,
|
||||
/ ff_mutex_create(), ff_mutex_delete(), ff_mutex_take() and ff_mutex_give()
|
||||
/ function, must be added to the project. Samples are available in ffsystem.c.
|
||||
/
|
||||
/ The FF_FS_TIMEOUT defines timeout period in unit of O/S time tick.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*--- End of configuration options ---*/
|
||||
@@ -0,0 +1,202 @@
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* A Sample Code of User Provided OS Dependent Functions for FatFs */
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
#include "ff.h"
|
||||
|
||||
|
||||
#if FF_USE_LFN == 3 /* Use dynamic memory allocation */
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Allocate/Free a Memory Block */
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
#include <stdlib.h> /* with POSIX API */
|
||||
|
||||
|
||||
void* ff_memalloc( /* Returns pointer to the allocated memory block (null if not enough core) */
|
||||
UINT msize /* Number of bytes to allocate */
|
||||
) {
|
||||
return malloc((size_t)msize); /* Allocate a new memory block */
|
||||
}
|
||||
|
||||
|
||||
void ff_memfree(
|
||||
void* mblock /* Pointer to the memory block to free (no effect if null) */
|
||||
) {
|
||||
free(mblock); /* Free the memory block */
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#if FF_FS_REENTRANT /* Mutal exclusion */
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Definitions of Mutex */
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
#define OS_TYPE 0 /* 0:Win32, 1:uITRON4.0, 2:uC/OS-II, 3:FreeRTOS, 4:CMSIS-RTOS */
|
||||
|
||||
|
||||
#if OS_TYPE == 0 /* Win32 */
|
||||
#include <windows.h>
|
||||
static HANDLE Mutex[FF_VOLUMES + 1]; /* Table of mutex handle */
|
||||
|
||||
#elif OS_TYPE == 1 /* uITRON */
|
||||
#include "itron.h"
|
||||
#include "kernel.h"
|
||||
static mtxid Mutex[FF_VOLUMES + 1]; /* Table of mutex ID */
|
||||
|
||||
#elif OS_TYPE == 2 /* uc/OS-II */
|
||||
#include "includes.h"
|
||||
static OS_EVENT *Mutex[FF_VOLUMES + 1]; /* Table of mutex pinter */
|
||||
|
||||
#elif OS_TYPE == 3 /* FreeRTOS */
|
||||
#include "FreeRTOS.h"
|
||||
#include "semphr.h"
|
||||
static SemaphoreHandle_t Mutex[FF_VOLUMES + 1]; /* Table of mutex handle */
|
||||
|
||||
#elif OS_TYPE == 4 /* CMSIS-RTOS */
|
||||
#include "cmsis_os.h"
|
||||
static osMutexId Mutex[FF_VOLUMES + 1]; /* Table of mutex ID */
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Create a Mutex */
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* This function is called in f_mount function to create a new mutex
|
||||
/ or semaphore for the volume. When a 0 is returned, the f_mount function
|
||||
/ fails with FR_INT_ERR.
|
||||
*/
|
||||
|
||||
int ff_mutex_create( /* Returns 1:Function succeeded or 0:Could not create the mutex */
|
||||
int vol /* Mutex ID: Volume mutex (0 to FF_VOLUMES - 1) or system mutex (FF_VOLUMES) */
|
||||
) {
|
||||
#if OS_TYPE == 0 /* Win32 */
|
||||
Mutex[vol] = CreateMutex(NULL, FALSE, NULL);
|
||||
return (int)(Mutex[vol] != INVALID_HANDLE_VALUE);
|
||||
|
||||
#elif OS_TYPE == 1 /* uITRON */
|
||||
T_CMTX cmtx = {TA_TPRI, 1};
|
||||
|
||||
Mutex[vol] = acre_mtx(&cmtx);
|
||||
return (int)(Mutex[vol] > 0);
|
||||
|
||||
#elif OS_TYPE == 2 /* uC/OS-II */
|
||||
OS_ERR err;
|
||||
|
||||
Mutex[vol] = OSMutexCreate(0, &err);
|
||||
return (int)(err == OS_NO_ERR);
|
||||
|
||||
#elif OS_TYPE == 3 /* FreeRTOS */
|
||||
Mutex[vol] = xSemaphoreCreateMutex();
|
||||
return (int)(Mutex[vol] != NULL);
|
||||
|
||||
#elif OS_TYPE == 4 /* CMSIS-RTOS */
|
||||
osMutexDef(cmsis_os_mutex);
|
||||
|
||||
Mutex[vol] = osMutexCreate(osMutex(cmsis_os_mutex));
|
||||
return (int)(Mutex[vol] != NULL);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Delete a Mutex */
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* This function is called in f_mount function to delete a mutex or
|
||||
/ semaphore of the volume created with ff_mutex_create function.
|
||||
*/
|
||||
|
||||
void ff_mutex_delete( /* Returns 1:Function succeeded or 0:Could not delete due to an error */
|
||||
int vol /* Mutex ID: Volume mutex (0 to FF_VOLUMES - 1) or system mutex (FF_VOLUMES) */
|
||||
) {
|
||||
#if OS_TYPE == 0 /* Win32 */
|
||||
CloseHandle(Mutex[vol]);
|
||||
|
||||
#elif OS_TYPE == 1 /* uITRON */
|
||||
del_mtx(Mutex[vol]);
|
||||
|
||||
#elif OS_TYPE == 2 /* uC/OS-II */
|
||||
OS_ERR err;
|
||||
|
||||
OSMutexDel(Mutex[vol], OS_DEL_ALWAYS, &err);
|
||||
|
||||
#elif OS_TYPE == 3 /* FreeRTOS */
|
||||
vSemaphoreDelete(Mutex[vol]);
|
||||
|
||||
#elif OS_TYPE == 4 /* CMSIS-RTOS */
|
||||
osMutexDelete(Mutex[vol]);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Request a Grant to Access the Volume */
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* This function is called on enter file functions to lock the volume.
|
||||
/ When a 0 is returned, the file function fails with FR_TIMEOUT.
|
||||
*/
|
||||
|
||||
int ff_mutex_take( /* Returns 1:Succeeded or 0:Timeout */
|
||||
int vol /* Mutex ID: Volume mutex (0 to FF_VOLUMES - 1) or system mutex (FF_VOLUMES) */
|
||||
) {
|
||||
#if OS_TYPE == 0 /* Win32 */
|
||||
return (int)(WaitForSingleObject(Mutex[vol], FF_FS_TIMEOUT) == WAIT_OBJECT_0);
|
||||
|
||||
#elif OS_TYPE == 1 /* uITRON */
|
||||
return (int)(tloc_mtx(Mutex[vol], FF_FS_TIMEOUT) == E_OK);
|
||||
|
||||
#elif OS_TYPE == 2 /* uC/OS-II */
|
||||
OS_ERR err;
|
||||
|
||||
OSMutexPend(Mutex[vol], FF_FS_TIMEOUT, &err));
|
||||
return (int)(err == OS_NO_ERR);
|
||||
|
||||
#elif OS_TYPE == 3 /* FreeRTOS */
|
||||
return (int)(xSemaphoreTake(Mutex[vol], FF_FS_TIMEOUT) == pdTRUE);
|
||||
|
||||
#elif OS_TYPE == 4 /* CMSIS-RTOS */
|
||||
return (int)(osMutexWait(Mutex[vol], FF_FS_TIMEOUT) == osOK);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Release a Grant to Access the Volume */
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* This function is called on leave file functions to unlock the volume.
|
||||
*/
|
||||
|
||||
void ff_mutex_give(
|
||||
int vol /* Mutex ID: Volume mutex (0 to FF_VOLUMES - 1) or system mutex (FF_VOLUMES) */
|
||||
) {
|
||||
#if OS_TYPE == 0 /* Win32 */
|
||||
ReleaseMutex(Mutex[vol]);
|
||||
|
||||
#elif OS_TYPE == 1 /* uITRON */
|
||||
unl_mtx(Mutex[vol]);
|
||||
|
||||
#elif OS_TYPE == 2 /* uC/OS-II */
|
||||
OSMutexPost(Mutex[vol]);
|
||||
|
||||
#elif OS_TYPE == 3 /* FreeRTOS */
|
||||
xSemaphoreGive(Mutex[vol]);
|
||||
|
||||
#elif OS_TYPE == 4 /* CMSIS-RTOS */
|
||||
osMutexRelease(Mutex[vol]);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* FF_FS_REENTRANT */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,95 @@
|
||||
// FatFS + FatFSUSB listFiles example
|
||||
|
||||
#include <FatFS.h>
|
||||
#include <FatFSUSB.h>
|
||||
|
||||
volatile bool updated = false;
|
||||
volatile bool driveConnected = false;
|
||||
volatile bool inPrinting = false;
|
||||
|
||||
// Called by FatFSUSB when the drive is released. We note this, restart FatFS, and tell the main loop to rescan.
|
||||
void unplug(uint32_t i) {
|
||||
(void) i;
|
||||
driveConnected = false;
|
||||
updated = true;
|
||||
FatFS.begin();
|
||||
}
|
||||
|
||||
// Called by FatFSUSB when the drive is mounted by the PC. Have to stop FatFS, since the drive data can change, note it, and continue.
|
||||
void plug(uint32_t i) {
|
||||
(void) i;
|
||||
driveConnected = true;
|
||||
FatFS.end();
|
||||
}
|
||||
|
||||
// Called by FatFSUSB to determine if it is safe to let the PC mount the USB drive. If we're accessing the FS in any way, have any Files open, etc. then it's not safe to let the PC mount the drive.
|
||||
bool mountable(uint32_t i) {
|
||||
(void) i;
|
||||
return !inPrinting;
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
while (!Serial) {
|
||||
delay(1);
|
||||
}
|
||||
delay(5000);
|
||||
|
||||
if (!FatFS.begin()) {
|
||||
Serial.println("FatFS initialization failed!");
|
||||
while (1) {
|
||||
delay(1);
|
||||
}
|
||||
}
|
||||
Serial.println("FatFS initialization done.");
|
||||
|
||||
inPrinting = true;
|
||||
printDirectory("/", 0);
|
||||
inPrinting = false;
|
||||
|
||||
// Set up callbacks
|
||||
FatFSUSB.onUnplug(unplug);
|
||||
FatFSUSB.onPlug(plug);
|
||||
FatFSUSB.driveReady(mountable);
|
||||
// Start FatFS USB drive mode
|
||||
FatFSUSB.begin();
|
||||
Serial.println("FatFSUSB started.");
|
||||
Serial.println("Connect drive via USB to upload/erase files and re-display");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (updated && !driveConnected) {
|
||||
inPrinting = true;
|
||||
Serial.println("\n\nDisconnected, new file listing:");
|
||||
printDirectory("/", 0);
|
||||
updated = false;
|
||||
inPrinting = false;
|
||||
}
|
||||
}
|
||||
|
||||
void printDirectory(String dirName, int numTabs) {
|
||||
Dir dir = FatFS.openDir(dirName);
|
||||
|
||||
while (true) {
|
||||
|
||||
if (!dir.next()) {
|
||||
// no more files
|
||||
break;
|
||||
}
|
||||
for (uint8_t i = 0; i < numTabs; i++) {
|
||||
Serial.print('\t');
|
||||
}
|
||||
Serial.print(dir.fileName());
|
||||
if (dir.isDirectory()) {
|
||||
Serial.println("/");
|
||||
printDirectory(dirName + "/" + dir.fileName(), numTabs + 1);
|
||||
} else {
|
||||
// files have sizes, directories do not
|
||||
Serial.print("\t\t");
|
||||
Serial.print(dir.fileSize(), DEC);
|
||||
time_t cr = dir.fileCreationTime();
|
||||
struct tm* tmstruct = localtime(&cr);
|
||||
Serial.printf("\t%d-%02d-%02d %02d:%02d:%02d\n", (tmstruct->tm_year) + 1900, (tmstruct->tm_mon) + 1, tmstruct->tm_mday, tmstruct->tm_hour, tmstruct->tm_min, tmstruct->tm_sec);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#######################################
|
||||
# Syntax Coloring Map
|
||||
#######################################
|
||||
|
||||
#######################################
|
||||
# Datatypes (KEYWORD1)
|
||||
#######################################
|
||||
|
||||
FatFSUSB KEYWORD1
|
||||
|
||||
#######################################
|
||||
# Methods and Functions (KEYWORD2)
|
||||
#######################################
|
||||
|
||||
driveReady KEYWORD1
|
||||
onPlug KEYWORD1
|
||||
onUnplug KEYWORD1
|
||||
|
||||
#######################################
|
||||
# Constants (LITERAL1)
|
||||
#######################################
|
||||
@@ -0,0 +1,11 @@
|
||||
name=FatFSUSB
|
||||
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
|
||||
depends=FatFS
|
||||
@@ -0,0 +1,284 @@
|
||||
/*
|
||||
FatFSUSB - Export onboard FatFS/FTL to host for data movement
|
||||
Copyright (c) 2024 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 "FatFSUSB.h"
|
||||
#include <FatFS.h>
|
||||
#include <class/msc/msc.h>
|
||||
|
||||
FatFSUSBClass FatFSUSB;
|
||||
|
||||
// Ensure we are logged in to the USB framework
|
||||
void __USBInstallMassStorage() {
|
||||
/* dummy */
|
||||
}
|
||||
|
||||
FatFSUSBClass::FatFSUSBClass() {
|
||||
}
|
||||
|
||||
FatFSUSBClass::~FatFSUSBClass() {
|
||||
end();
|
||||
}
|
||||
|
||||
void FatFSUSBClass::onPlug(void (*cb)(uint32_t), uint32_t cbData) {
|
||||
_cbPlug = cb;
|
||||
_cbPlugData = cbData;
|
||||
}
|
||||
|
||||
void FatFSUSBClass::onUnplug(void (*cb)(uint32_t), uint32_t cbData) {
|
||||
_cbUnplug = cb;
|
||||
_cbUnplugData = cbData;
|
||||
}
|
||||
|
||||
void FatFSUSBClass::driveReady(bool (*cb)(uint32_t), uint32_t cbData) {
|
||||
_driveReady = cb;
|
||||
_driveReadyData = cbData;
|
||||
}
|
||||
|
||||
bool FatFSUSBClass::begin() {
|
||||
if (_started) {
|
||||
return false;
|
||||
}
|
||||
_started = true;
|
||||
fatfs::disk_initialize(0);
|
||||
fatfs::WORD ss;
|
||||
fatfs::disk_ioctl(0, GET_SECTOR_SIZE, &ss);
|
||||
_sectSize = ss;
|
||||
_sectBuff = new uint8_t[_sectSize];
|
||||
_sectNum = -1;
|
||||
return true;
|
||||
}
|
||||
|
||||
void FatFSUSBClass::end() {
|
||||
if (_started) {
|
||||
_started = false;
|
||||
delete[] _sectBuff;
|
||||
}
|
||||
}
|
||||
|
||||
// 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 FatFSUSBClass::testUnitReady() {
|
||||
bool ret = _started;
|
||||
if (_driveReady) {
|
||||
ret &= _driveReady(_driveReadyData);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// 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 FatFSUSB.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;
|
||||
fatfs::LBA_t p;
|
||||
fatfs::disk_ioctl(0, GET_SECTOR_COUNT, &p);
|
||||
*block_count = p;
|
||||
fatfs::WORD ss;
|
||||
fatfs::disk_ioctl(0, GET_SECTOR_SIZE, &ss);
|
||||
*block_size = ss;
|
||||
}
|
||||
|
||||
|
||||
// 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 FatFSUSB.read10(lba, offset, buffer, bufsize);
|
||||
}
|
||||
|
||||
int32_t FatFSUSBClass::read10(uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize) {
|
||||
fatfs::LBA_t _hddsects;
|
||||
fatfs::disk_ioctl(0, GET_SECTOR_COUNT, &_hddsects);
|
||||
|
||||
if (!_started || (lba >= _hddsects)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
assert(offset + bufsize <= _sectSize);
|
||||
|
||||
if (_sectNum >= 0) {
|
||||
// Flush the temp data out, we need to use the space
|
||||
fatfs::disk_write(0, _sectBuff, _sectNum, 1);
|
||||
_sectNum = -1;
|
||||
}
|
||||
fatfs::disk_read(0, _sectBuff, lba, 1);
|
||||
memcpy(buffer, _sectBuff + offset, bufsize);
|
||||
return bufsize;
|
||||
}
|
||||
|
||||
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 FatFSUSB.write10(lba, offset, buffer, bufsize);
|
||||
}
|
||||
|
||||
int32_t FatFSUSBClass::write10(uint32_t lba, uint32_t offset, uint8_t* buffer, uint32_t bufsize) {
|
||||
fatfs::LBA_t _hddsects;
|
||||
fatfs::disk_ioctl(0, GET_SECTOR_COUNT, &_hddsects);
|
||||
|
||||
if (!_started || (lba >= _hddsects)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
assert(offset + bufsize <= _sectSize);
|
||||
|
||||
if ((offset == 0) && (bufsize == _sectSize)) {
|
||||
fatfs::disk_write(0, buffer, lba, 1);
|
||||
return _sectSize;
|
||||
}
|
||||
|
||||
if ((int)_sectNum == (int)lba) {
|
||||
memcpy(_sectBuff + offset, buffer, bufsize);
|
||||
} else {
|
||||
if (_sectNum >= 0) {
|
||||
// Need to flush old sector out
|
||||
fatfs::disk_write(0, _sectBuff, _sectNum, 1);
|
||||
}
|
||||
fatfs::disk_read(0, _sectBuff, lba, 1);
|
||||
memcpy(_sectBuff + offset, buffer, bufsize);
|
||||
_sectNum = lba;
|
||||
}
|
||||
|
||||
if (offset + bufsize >= _sectSize) {
|
||||
// We've filled up a sector, write it out!
|
||||
fatfs::disk_write(0, _sectBuff, lba, 1);
|
||||
_sectNum = -1;
|
||||
}
|
||||
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) {
|
||||
FatFSUSB.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) {
|
||||
FatFSUSB.unplug();
|
||||
} else if (start_stop->start && start_stop->load_eject) {
|
||||
FatFSUSB.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 FatFSUSBClass::plug() {
|
||||
if (_started && _cbPlug) {
|
||||
_cbPlug(_cbPlugData);
|
||||
}
|
||||
}
|
||||
|
||||
void FatFSUSBClass::unplug() {
|
||||
if (_started) {
|
||||
if (_sectNum >= 0) {
|
||||
// Flush the temp data out
|
||||
fatfs::disk_write(0, _sectBuff, _sectNum, 1);
|
||||
_sectNum = -1;
|
||||
}
|
||||
fatfs::disk_ioctl(0, CTRL_SYNC, nullptr);
|
||||
if (_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) {
|
||||
FatFSUSB.plug();
|
||||
} else if (!start && load_eject) {
|
||||
FatFSUSB.unplug();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
FatFSUSB - Export onboard FatFS/FTL to host for data movement
|
||||
Copyright (c) 2024 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 FatFSUSBClass {
|
||||
public:
|
||||
FatFSUSBClass();
|
||||
~FatFSUSBClass();
|
||||
|
||||
bool begin();
|
||||
void end();
|
||||
|
||||
void driveReady(bool (*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:
|
||||
bool _started = false;
|
||||
|
||||
int32_t _sectNum = -1;
|
||||
uint8_t *_sectBuff = nullptr;
|
||||
uint16_t _sectSize = 0;
|
||||
|
||||
void (*_cbPlug)(uint32_t) = nullptr;
|
||||
uint32_t _cbPlugData = 0;
|
||||
|
||||
void (*_cbUnplug)(uint32_t) = nullptr;
|
||||
uint32_t _cbUnplugData = 0;
|
||||
|
||||
bool (*_driveReady)(uint32_t) = nullptr;
|
||||
uint32_t _driveReadyData = 0;
|
||||
};
|
||||
|
||||
extern FatFSUSBClass FatFSUSB;
|
||||
@@ -165,14 +165,14 @@ static void __no_inline_not_in_flash_func(IdleThisCore)(void *param) {
|
||||
(void) param;
|
||||
while (true) {
|
||||
ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
|
||||
portDISABLE_INTERRUPTS();
|
||||
vTaskPreemptionDisable(nullptr);
|
||||
portDISABLE_INTERRUPTS();
|
||||
__otherCoreIdled = true;
|
||||
while (__otherCoreIdled) {
|
||||
/* noop */
|
||||
}
|
||||
vTaskPreemptionEnable(nullptr);
|
||||
portENABLE_INTERRUPTS();
|
||||
vTaskPreemptionEnable(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,9 +188,9 @@ extern "C" void __no_inline_not_in_flash_func(__freertos_idle_other_core)() {
|
||||
|
||||
extern "C" void __no_inline_not_in_flash_func(__freertos_resume_other_core)() {
|
||||
__otherCoreIdled = false;
|
||||
portENABLE_INTERRUPTS();
|
||||
xTaskResumeAll();
|
||||
vTaskPreemptionEnable(nullptr);
|
||||
portENABLE_INTERRUPTS();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -157,6 +157,14 @@ public:
|
||||
return false;
|
||||
}
|
||||
int rc = lfs_mkdir(&_lfs, path);
|
||||
if ((rc == 0) && _timeCallback) {
|
||||
time_t now = _timeCallback();
|
||||
// Add metadata with creation time to the directory marker
|
||||
int rc = lfs_setattr(&_lfs, path, 'c', (const void *)&now, sizeof(now));
|
||||
if (rc < 0) {
|
||||
DEBUGV("Unable to set creation time on '%s' to %ld\n", path, (long)now);
|
||||
}
|
||||
}
|
||||
return (rc == 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,8 @@ PWMAudio::PWMAudio(pin_size_t pin, bool stereo) {
|
||||
_buffers = 8;
|
||||
_bufferWords = 0;
|
||||
_stereo = stereo;
|
||||
_sampleRate = 48000;
|
||||
_pacer = -1;
|
||||
}
|
||||
|
||||
PWMAudio::~PWMAudio() {
|
||||
@@ -63,7 +65,7 @@ bool PWMAudio::setStereo(bool stereo) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PWMAudio::setFrequency(int newFreq) {
|
||||
bool PWMAudio::setPWMFrequency(int newFreq) {
|
||||
_freq = newFreq;
|
||||
|
||||
// Figure out the scale factor for PWM values
|
||||
@@ -92,6 +94,17 @@ bool PWMAudio::setFrequency(int newFreq) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PWMAudio::setFrequency(int frequency) {
|
||||
if (_pacer < 0) {
|
||||
return false;
|
||||
}
|
||||
uint16_t _pacer_D, _pacer_N;
|
||||
/*Flip fraction(N for D, D for N) because we are using it as sys_clk * fraction(mechanic of dma_timer_set_fraction) for smaller than sys_clk values*/
|
||||
find_pacer_fraction(frequency, &_pacer_D, &_pacer_N);
|
||||
dma_timer_set_fraction(_pacer, _pacer_N, _pacer_D);
|
||||
return true;
|
||||
}
|
||||
|
||||
void PWMAudio::onTransmit(void(*fn)(void)) {
|
||||
_cb = fn;
|
||||
if (_running) {
|
||||
@@ -117,12 +130,25 @@ bool PWMAudio::begin() {
|
||||
_bufferWords = 16;
|
||||
}
|
||||
|
||||
setFrequency(_freq);
|
||||
setPWMFrequency(_freq);
|
||||
|
||||
/*Calculate and set the DMA pacer timer. This timer will pull data on a fixed sample rate. So the actual PWM frequency can be higher or lower.*/
|
||||
_pacer = dma_claim_unused_timer(false);
|
||||
/*When no unused timer is found, return*/
|
||||
if (_pacer < 0) {
|
||||
return false;
|
||||
}
|
||||
uint16_t _pacer_D = 0;
|
||||
uint16_t _pacer_N = 0;
|
||||
/*Flip fraction(N for D, D for N) because we are using it as sys_clk * fraction(mechanic of dma_timer_set_fraction) for smaller than sys_clk values*/
|
||||
find_pacer_fraction(_sampleRate, &_pacer_D, &_pacer_N);
|
||||
dma_timer_set_fraction(_pacer, _pacer_N, _pacer_D);
|
||||
int _pacer_dreq = dma_get_timer_dreq(_pacer);
|
||||
|
||||
uint32_t ccAddr = PWM_BASE + PWM_CH0_CC_OFFSET + pwm_gpio_to_slice_num(_pin) * 20;
|
||||
|
||||
_arb = new AudioBufferManager(_buffers, _bufferWords, 0x80008000, OUTPUT, DMA_SIZE_32);
|
||||
if (!_arb->begin(pwm_get_dreq(pwm_gpio_to_slice_num(_pin)), (volatile void*)ccAddr)) {
|
||||
if (!_arb->begin(_pacer_dreq, (volatile void*)ccAddr)) {
|
||||
_running = false;
|
||||
delete _arb;
|
||||
_arb = nullptr;
|
||||
@@ -143,6 +169,9 @@ void PWMAudio::end() {
|
||||
}
|
||||
delete _arb;
|
||||
_arb = nullptr;
|
||||
|
||||
dma_timer_unclaim(_pacer);
|
||||
_pacer = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,3 +248,44 @@ size_t PWMAudio::write(const uint8_t *buffer, size_t size) {
|
||||
}
|
||||
return writtenSize;
|
||||
}
|
||||
|
||||
void PWMAudio::find_pacer_fraction(int target, uint16_t *numerator, uint16_t *denominator) {
|
||||
const uint16_t max = 0xFFFF;
|
||||
|
||||
/*Cache last results so we dont have to recalculate*/
|
||||
static int last_target;
|
||||
static uint16_t bestNum;
|
||||
static uint16_t bestDenom;
|
||||
/*Check if we can load the previous values*/
|
||||
if (target == last_target) {
|
||||
*numerator = bestNum;
|
||||
*denominator = bestDenom;
|
||||
return;
|
||||
}
|
||||
|
||||
float targetRatio = (float)F_CPU / target;
|
||||
float lowestError = HUGE_VALF;
|
||||
|
||||
for (uint16_t denom = 1; denom < max; denom++) {
|
||||
uint16_t num = (int)((targetRatio * denom) + 0.5f); /*Calculate numerator, rounding to nearest integer*/
|
||||
|
||||
/*Check if numerator is within bounds*/
|
||||
if (num > 0 && num < max) {
|
||||
float actualRatio = (float)num / denom;
|
||||
float error = fabsf(actualRatio - targetRatio);
|
||||
|
||||
if (error < lowestError) {
|
||||
bestNum = num;
|
||||
bestDenom = denom;
|
||||
lowestError = error;
|
||||
if (error == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
last_target = target;
|
||||
*numerator = bestNum;
|
||||
*denominator = bestDenom;
|
||||
}
|
||||
@@ -29,12 +29,21 @@ public:
|
||||
virtual ~PWMAudio();
|
||||
|
||||
bool setBuffers(size_t buffers, size_t bufferWords);
|
||||
bool setFrequency(int newFreq);
|
||||
/*Sets the frequency of the PWM in hz*/
|
||||
bool setPWMFrequency(int newFreq);
|
||||
/*Sets the sample rate frequency in hz*/
|
||||
bool setFrequency(int frequency);
|
||||
bool setPin(pin_size_t pin);
|
||||
bool setStereo(bool stereo = true);
|
||||
|
||||
bool begin(long sampleRate) {
|
||||
setFrequency(sampleRate);
|
||||
_sampleRate = sampleRate;
|
||||
return begin();
|
||||
}
|
||||
|
||||
bool begin(long sampleRate, long PWMfrequency) {
|
||||
setPWMFrequency(PWMfrequency);
|
||||
_sampleRate = sampleRate;
|
||||
return begin();
|
||||
}
|
||||
|
||||
@@ -70,6 +79,9 @@ private:
|
||||
bool _stereo;
|
||||
|
||||
int _freq;
|
||||
int _sampleRate;
|
||||
|
||||
int _pacer;
|
||||
|
||||
size_t _buffers;
|
||||
size_t _bufferWords;
|
||||
@@ -84,4 +96,7 @@ private:
|
||||
void (*_cb)();
|
||||
|
||||
AudioBufferManager *_arb;
|
||||
|
||||
/*An accurate but brute force method to find 16bit numerator and denominator.*/
|
||||
void find_pacer_fraction(int target, uint16_t *numerator, uint16_t *denominator);
|
||||
};
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
class SDClass {
|
||||
public:
|
||||
bool begin(uint8_t csPin, HardwareSPI &spi) {
|
||||
_spi = &spi;
|
||||
SDFS.setConfig(SDFSConfig(csPin, SPI_HALF_SPEED, spi));
|
||||
return SDFS.begin();
|
||||
}
|
||||
@@ -43,7 +44,7 @@ public:
|
||||
void end(bool endSPI = true) {
|
||||
SDFS.end();
|
||||
if (endSPI) {
|
||||
SPI.end();
|
||||
_spi->end();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,6 +205,7 @@ private:
|
||||
return time(nullptr);
|
||||
}
|
||||
|
||||
HardwareSPI *_spi;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ SPIClassRP2040::SPIClassRP2040(spi_inst_t *spi, pin_size_t rx, pin_size_t cs, pi
|
||||
_spi = spi;
|
||||
_running = false;
|
||||
_initted = false;
|
||||
_spis = SPISettings();
|
||||
_spis = SPISettings(0, LSBFIRST, SPI_MODE0); // Ensure spi_init called by setting current freq to 0
|
||||
_RX = rx;
|
||||
_TX = tx;
|
||||
_SCK = sck;
|
||||
@@ -184,15 +184,18 @@ void SPIClassRP2040::beginTransaction(SPISettings settings) {
|
||||
if (_initted && settings == _spis) {
|
||||
DEBUGSPI("SPI: Reusing existing initted SPI\n");
|
||||
} else {
|
||||
_spis = settings;
|
||||
if (_initted) {
|
||||
DEBUGSPI("SPI: deinitting currently active SPI\n");
|
||||
spi_deinit(_spi);
|
||||
/* Only de-init if the clock changes frequency */
|
||||
if (settings.getClockFreq() != _spis.getClockFreq()) {
|
||||
if (_initted) {
|
||||
DEBUGSPI("SPI: deinitting currently active SPI\n");
|
||||
spi_deinit(_spi);
|
||||
}
|
||||
DEBUGSPI("SPI: initting SPI\n");
|
||||
spi_init(_spi, settings.getClockFreq());
|
||||
DEBUGSPI("SPI: actual baudrate=%u\n", spi_get_baudrate(_spi));
|
||||
}
|
||||
DEBUGSPI("SPI: initting SPI\n");
|
||||
spi_init(_spi, _spis.getClockFreq());
|
||||
_spis = settings;
|
||||
spi_set_format(_spi, 8, cpol(), cpha(), SPI_MSB_FIRST);
|
||||
DEBUGSPI("SPI: actual baudrate=%u\n", spi_get_baudrate(_spi));
|
||||
_initted = true;
|
||||
}
|
||||
// Disable any IRQs that are being used for SPI
|
||||
@@ -338,6 +341,7 @@ void SPIClassRP2040::end() {
|
||||
}
|
||||
gpio_set_function(_SCK, GPIO_FUNC_SIO);
|
||||
gpio_set_function(_TX, GPIO_FUNC_SIO);
|
||||
_spis = SPISettings(0, LSBFIRST, SPI_MODE0);
|
||||
}
|
||||
|
||||
void SPIClassRP2040::setBitOrder(BitOrder order) {
|
||||
|
||||
@@ -206,7 +206,7 @@ void SPISlaveClass::setData(const uint8_t *data, size_t len) {
|
||||
|
||||
|
||||
void SPISlaveClass::begin(SPISettings spis) {
|
||||
DEBUGSPI("SPISlave::begin(%d), rx=%d, cs=%d, sck=%d, tx=%d\n", hwCS, _RX, _CS, _SCK, _TX);
|
||||
DEBUGSPI("SPISlave::begin(), rx=%d, cs=%d, sck=%d, tx=%d\n", _RX, _CS, _SCK, _TX);
|
||||
gpio_set_function(_RX, GPIO_FUNC_SPI);
|
||||
gpio_set_function(_CS, GPIO_FUNC_SPI);
|
||||
gpio_set_function(_SCK, GPIO_FUNC_SPI);
|
||||
|
||||
@@ -21,8 +21,6 @@
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <pico/cyw43_arch.h>
|
||||
#include <cyw43.h>
|
||||
#include "lwip/raw.h"
|
||||
#include "lwip/icmp.h"
|
||||
#include "lwip/inet_chksum.h"
|
||||
@@ -31,7 +29,14 @@
|
||||
|
||||
// This is the real WiFi network object, we just tickle it to do our magic
|
||||
#include <LwipEthernet.h>
|
||||
#ifdef ARDUINO_RASPBERRY_PI_PICO_W
|
||||
#include <pico/cyw43_arch.h>
|
||||
static CYW43lwIP _wifi(1);
|
||||
#elif defined(ESPHOSTSPI)
|
||||
static ESPHostLwIP _wifi;
|
||||
#else
|
||||
static NoDriverLwIP _wifi;
|
||||
#endif
|
||||
|
||||
WiFiClass::WiFiClass() {
|
||||
}
|
||||
@@ -62,31 +67,11 @@ void WiFiClass::mode(WiFiMode_t m) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Start WiFi connection for OPEN networks
|
||||
|
||||
param ssid: Pointer to the SSID string.
|
||||
*/
|
||||
int WiFiClass::begin(const char* ssid) {
|
||||
return begin(ssid, nullptr);
|
||||
}
|
||||
|
||||
int WiFiClass::beginBSSID(const char* ssid, const uint8_t *bssid) {
|
||||
return begin(ssid, nullptr, bssid);
|
||||
}
|
||||
|
||||
#ifdef ARDUINO_RASPBERRY_PI_PICO_W
|
||||
/* Start WiFi connection with passphrase
|
||||
the most secure supported mode will be automatically selected
|
||||
|
||||
param ssid: Pointer to the SSID string.
|
||||
param passphrase: Passphrase. Valid characters in a passphrase
|
||||
must be between ASCII 32-126 (decimal).
|
||||
*/
|
||||
int WiFiClass::begin(const char* ssid, const char *passphrase, const uint8_t *bssid) {
|
||||
bool WiFiClass::_beginInternal(const char* ssid, const char *passphrase, const uint8_t *bssid) {
|
||||
// Simple ESP8266 compatibility hack
|
||||
if (_modeESP == WIFI_AP) {
|
||||
return beginAP(ssid, passphrase);
|
||||
// When beginAP was a success, it returns WL_CONNECTED and we return true as success.
|
||||
return beginAP(ssid, passphrase) == WL_CONNECTED;
|
||||
}
|
||||
|
||||
end();
|
||||
@@ -98,26 +83,76 @@ int WiFiClass::begin(const char* ssid, const char *passphrase, const uint8_t *bs
|
||||
} else {
|
||||
bzero(_bssid, sizeof(_bssid));
|
||||
}
|
||||
_wifi.setSTA();
|
||||
_wifi.setSSID(_ssid.c_str());
|
||||
_wifi.setBSSID(_bssid);
|
||||
_wifi.setPassword(passphrase);
|
||||
_wifi.setTimeout(_timeout);
|
||||
_wifi.setSTA();
|
||||
_apMode = false;
|
||||
_wifiHWInitted = true;
|
||||
uint32_t start = millis(); // The timeout starts from network init, not network link up
|
||||
|
||||
// Internal wifi.begin returns false when failed, therefore we return false as error
|
||||
if (!_wifi.begin()) {
|
||||
return WL_IDLE_STATUS;
|
||||
return false;
|
||||
}
|
||||
noLowPowerMode();
|
||||
// Enable CYW43 event debugging (make sure Debug Port is set)
|
||||
//cyw43_state.trace_flags = 0xffff;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* Start WiFi connection for OPEN networks
|
||||
|
||||
param ssid: Pointer to the SSID string.
|
||||
*/
|
||||
int WiFiClass::begin(const char* ssid) {
|
||||
return begin(ssid, nullptr);
|
||||
}
|
||||
|
||||
/* Start WiFi connection for OPEN networks, but non blocking.
|
||||
|
||||
param ssid: Pointer to the SSID string.
|
||||
*/
|
||||
int WiFiClass::beginNoBlock(const char* ssid) {
|
||||
return beginNoBlock(ssid, nullptr);
|
||||
}
|
||||
|
||||
|
||||
int WiFiClass::beginBSSID(const char* ssid, const uint8_t *bssid) {
|
||||
return begin(ssid, nullptr, bssid);
|
||||
}
|
||||
|
||||
/* Start WiFi connection with passphrase
|
||||
the most secure supported mode will be automatically selected
|
||||
|
||||
param ssid: Pointer to the SSID string.
|
||||
param passphrase: Passphrase. Valid characters in a passphrase
|
||||
must be between ASCII 32-126 (decimal).
|
||||
*/
|
||||
int WiFiClass::begin(const char* ssid, const char *passphrase, const uint8_t *bssid) {
|
||||
uint32_t start = millis(); // The timeout starts from network init, not network link up
|
||||
|
||||
// Returns WL_IDLE_STATUS on error for compatibility.
|
||||
if (!_beginInternal(ssid, passphrase, bssid)) {
|
||||
return WL_IDLE_STATUS;
|
||||
}
|
||||
|
||||
while (!_calledESP && ((millis() - start < (uint32_t)2 * _timeout)) && !connected()) {
|
||||
delay(10);
|
||||
}
|
||||
return status();
|
||||
}
|
||||
|
||||
int WiFiClass::beginNoBlock(const char* ssid, const char *passphrase, const uint8_t *bssid) {
|
||||
// Returns WL_IDLE_STATUS on error for compatibility.
|
||||
if (!_beginInternal(ssid, passphrase, bssid)) {
|
||||
return WL_IDLE_STATUS;
|
||||
}
|
||||
return status();
|
||||
}
|
||||
|
||||
uint8_t WiFiClass::beginAP(const char *ssid) {
|
||||
return beginAP(ssid, nullptr);
|
||||
}
|
||||
@@ -137,10 +172,10 @@ uint8_t WiFiClass::beginAP(const char *ssid, const char* passphrase) {
|
||||
|
||||
_ssid = ssid;
|
||||
_password = passphrase;
|
||||
_wifi.setAP();
|
||||
_wifi.setSSID(_ssid.c_str());
|
||||
_wifi.setPassword(passphrase);
|
||||
_wifi.setTimeout(_timeout);
|
||||
_wifi.setAP();
|
||||
_apMode = true;
|
||||
IPAddress gw = _wifi.gatewayIP();
|
||||
if (!gw.isSet()) {
|
||||
@@ -166,8 +201,8 @@ uint8_t WiFiClass::beginAP(const char *ssid, const char* passphrase) {
|
||||
|
||||
return WL_CONNECTED;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ARDUINO_RASPBERRY_PI_PICO_W
|
||||
uint8_t WiFiClass::softAPgetStationNum() {
|
||||
if (!_apMode || !_wifiHWInitted) {
|
||||
return 0;
|
||||
@@ -182,10 +217,10 @@ uint8_t WiFiClass::softAPgetStationNum() {
|
||||
free(macs);
|
||||
return m;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
bool WiFiClass::connected() {
|
||||
return (_apMode && _wifiHWInitted) || (_wifi.connected() && localIP().isSet() && (cyw43_wifi_link_status(&cyw43_state, _apMode ? 1 : 0) == CYW43_LINK_JOIN));
|
||||
return (_apMode && _wifiHWInitted) || (_wifi.connected() && localIP().isSet());
|
||||
}
|
||||
|
||||
/* Change Ip configuration settings disabling the dhcp client
|
||||
@@ -270,7 +305,6 @@ int WiFiClass::disconnect(bool wifi_off __unused) {
|
||||
}
|
||||
if (_wifiHWInitted) {
|
||||
_wifiHWInitted = false;
|
||||
cyw43_wifi_leave(&cyw43_state, _apMode ? 1 : 0);
|
||||
_wifi.end();
|
||||
}
|
||||
return WL_DISCONNECTED;
|
||||
@@ -288,12 +322,13 @@ void WiFiClass::end(void) {
|
||||
return: pointer to uint8_t array with length WL_MAC_ADDR_LENGTH
|
||||
*/
|
||||
uint8_t* WiFiClass::macAddress(uint8_t* mac) {
|
||||
#ifdef ARDUINO_RASPBERRY_PI_PICO_W
|
||||
if (!_wifiHWInitted) {
|
||||
_apMode = false;
|
||||
cyw43_wifi_set_up(&cyw43_state, _apMode ? 1 : 0, true, CYW43_COUNTRY_WORLDWIDE);
|
||||
}
|
||||
cyw43_wifi_get_mac(&cyw43_state, _apMode ? 1 : 0, mac);
|
||||
return mac;
|
||||
#endif
|
||||
return _wifi.macAddress(_apMode, mac);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -348,30 +383,11 @@ const String &WiFiClass::SSID() {
|
||||
return: pointer to uint8_t array with length WL_MAC_ADDR_LENGTH
|
||||
*/
|
||||
uint8_t* WiFiClass::BSSID(uint8_t* bssid) {
|
||||
#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;
|
||||
return _wifi.BSSID(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 _wifi.channel();
|
||||
}
|
||||
|
||||
|
||||
@@ -382,17 +398,7 @@ int WiFiClass::channel() {
|
||||
return: signed value
|
||||
*/
|
||||
int32_t WiFiClass::RSSI() {
|
||||
#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;
|
||||
return _wifi.RSSI();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -401,31 +407,10 @@ int32_t WiFiClass::RSSI() {
|
||||
return: one value of wl_enc_type enum
|
||||
*/
|
||||
uint8_t WiFiClass::encryptionType() {
|
||||
// TODO - Driver does not return this?!
|
||||
if (_password == nullptr) {
|
||||
return ENC_TYPE_NONE;
|
||||
}
|
||||
return ENC_TYPE_AUTO;
|
||||
}
|
||||
|
||||
//TODO - this can be in the class
|
||||
static uint64_t _to64(uint8_t b[8]) {
|
||||
uint64_t x = 0;
|
||||
for (int i = 0; i < 6; i++) {
|
||||
x <<= 8LL;
|
||||
x |= b[i] & 255;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
int WiFiClass::_scanCB(void *env, const cyw43_ev_scan_result_t *result) {
|
||||
WiFiClass *w = (WiFiClass *)env;
|
||||
if (result) {
|
||||
cyw43_ev_scan_result_t s;
|
||||
memcpy(&s, result, sizeof(s));
|
||||
w->_scan.insert_or_assign(_to64(s.bssid), s);
|
||||
}
|
||||
return 0;
|
||||
return _wifi.encryptionType();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -434,39 +419,22 @@ int WiFiClass::_scanCB(void *env, const cyw43_ev_scan_result_t *result) {
|
||||
return: Number of discovered networks
|
||||
*/
|
||||
int8_t WiFiClass::scanNetworks(bool async) {
|
||||
cyw43_wifi_scan_options_t scan_options;
|
||||
memset(&scan_options, 0, sizeof(scan_options));
|
||||
_scan.clear();
|
||||
if (!_wifiHWInitted) {
|
||||
_apMode = false;
|
||||
#ifdef ARDUINO_RASPBERRY_PI_PICO_W
|
||||
cyw43_arch_enable_sta_mode();
|
||||
#endif
|
||||
_wifiHWInitted = true;
|
||||
}
|
||||
int err = cyw43_wifi_scan(&cyw43_state, &scan_options, this, _scanCB);
|
||||
if (err) {
|
||||
return 0;
|
||||
}
|
||||
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 _wifi.scanNetworks(async);
|
||||
}
|
||||
|
||||
int8_t WiFiClass::scanComplete() {
|
||||
if (cyw43_wifi_scan_active(&cyw43_state)) {
|
||||
return -1;
|
||||
} else {
|
||||
return _scan.size();
|
||||
}
|
||||
return _wifi.scanComplete();
|
||||
}
|
||||
|
||||
void WiFiClass::scanDelete() {
|
||||
_scan.clear();
|
||||
_wifi.scanDelete();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -477,14 +445,7 @@ void WiFiClass::scanDelete() {
|
||||
return: ssid string of the specified item on the networks scanned list
|
||||
*/
|
||||
const char*WiFiClass::SSID(uint8_t networkItem) {
|
||||
if (networkItem >= _scan.size()) {
|
||||
return nullptr;
|
||||
}
|
||||
auto it = _scan.begin();
|
||||
for (int i = 0; i < networkItem; i++) {
|
||||
++it;
|
||||
}
|
||||
return (const char *)it->second.ssid;
|
||||
return _wifi.SSID(networkItem);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -495,44 +456,15 @@ const char*WiFiClass::SSID(uint8_t networkItem) {
|
||||
return: encryption type (enum wl_enc_type) of the specified item on the networks scanned list
|
||||
*/
|
||||
uint8_t WiFiClass::encryptionType(uint8_t networkItem) {
|
||||
if (networkItem >= _scan.size()) {
|
||||
return ENC_TYPE_UNKNOWN;
|
||||
}
|
||||
auto it = _scan.begin();
|
||||
for (int i = 0; i < networkItem; i++) {
|
||||
++it;
|
||||
}
|
||||
// TODO - the driver returns a small integer but does not actually provide a way of mapping that to the proper enc type. My best guesses here...
|
||||
switch (it->second.auth_mode) {
|
||||
case 0: return ENC_TYPE_NONE;
|
||||
case 3: return ENC_TYPE_TKIP;
|
||||
case 5: return ENC_TYPE_CCMP;
|
||||
case 7: return ENC_TYPE_AUTO;
|
||||
}
|
||||
return ENC_TYPE_UNKNOWN;
|
||||
return _wifi.encryptionType(networkItem);
|
||||
}
|
||||
|
||||
uint8_t* WiFiClass::BSSID(uint8_t networkItem, uint8_t* bssid) {
|
||||
if (networkItem >= _scan.size()) {
|
||||
return nullptr;
|
||||
}
|
||||
auto it = _scan.begin();
|
||||
for (int i = 0; i < networkItem; i++) {
|
||||
++it;
|
||||
}
|
||||
memcpy(bssid, it->second.bssid, 6);
|
||||
return bssid;
|
||||
return _wifi.BSSID(networkItem, bssid);
|
||||
}
|
||||
|
||||
uint8_t WiFiClass::channel(uint8_t networkItem) {
|
||||
if (networkItem >= _scan.size()) {
|
||||
return 255;
|
||||
}
|
||||
auto it = _scan.begin();
|
||||
for (int i = 0; i < networkItem; i++) {
|
||||
++it;
|
||||
}
|
||||
return it->second.channel;
|
||||
return _wifi.channel(networkItem);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -543,14 +475,7 @@ uint8_t WiFiClass::channel(uint8_t networkItem) {
|
||||
return: signed value of RSSI of the specified item on the networks scanned list
|
||||
*/
|
||||
int32_t WiFiClass::RSSI(uint8_t networkItem) {
|
||||
if (networkItem >= _scan.size()) {
|
||||
return -9999;
|
||||
}
|
||||
auto it = _scan.begin();
|
||||
for (int i = 0; i < networkItem; i++) {
|
||||
++it;
|
||||
}
|
||||
return it->second.rssi;
|
||||
return _wifi.RSSI(networkItem);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -562,14 +487,7 @@ uint8_t WiFiClass::status() {
|
||||
if (_apMode && _wifiHWInitted) {
|
||||
return WL_CONNECTED;
|
||||
}
|
||||
switch (cyw43_wifi_link_status(&cyw43_state, _apMode ? 1 : 0)) {
|
||||
case CYW43_LINK_DOWN: return WL_IDLE_STATUS;
|
||||
case CYW43_LINK_JOIN: return localIP().isSet() ? WL_CONNECTED : WL_DISCONNECTED;
|
||||
case CYW43_LINK_FAIL: return WL_CONNECT_FAILED;
|
||||
case CYW43_LINK_NONET: return WL_CONNECT_FAILED;
|
||||
case CYW43_LINK_BADAUTH: return WL_CONNECT_FAILED;
|
||||
}
|
||||
return WL_NO_MODULE;
|
||||
return _wifi.status();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -599,6 +517,7 @@ unsigned long WiFiClass::getTime() {
|
||||
return millis();
|
||||
}
|
||||
|
||||
#ifdef ARDUINO_RASPBERRY_PI_PICO_W
|
||||
void WiFiClass::aggressiveLowPowerMode() {
|
||||
cyw43_wifi_pm(&cyw43_state, CYW43_AGGRESSIVE_PM);
|
||||
}
|
||||
@@ -606,10 +525,11 @@ void WiFiClass::aggressiveLowPowerMode() {
|
||||
void WiFiClass::defaultLowPowerMode() {
|
||||
cyw43_wifi_pm(&cyw43_state, CYW43_DEFAULT_PM);
|
||||
}
|
||||
#endif
|
||||
|
||||
// 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);
|
||||
_wifi.noLowPowerMode();
|
||||
}
|
||||
|
||||
int WiFiClass::ping(const char* hostname, uint8_t ttl) {
|
||||
|
||||
@@ -23,13 +23,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
#ifdef ARDUINO_RASPBERRY_PI_PICO_W
|
||||
#include <lwIP_CYW43.h>
|
||||
#elif defined(ESPHOSTSPI)
|
||||
#include <lwIP_ESPHost.h>
|
||||
#else
|
||||
#include "utility/lwIP_nodriver.h"
|
||||
#endif
|
||||
#include "WiFi.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <map>
|
||||
|
||||
#include <cyw43.h>
|
||||
#include "dhcpserver/dhcpserver.h"
|
||||
|
||||
#define WIFI_FIRMWARE_LATEST_VERSION PICO_SDK_VERSION_STRING
|
||||
@@ -65,6 +70,12 @@ public:
|
||||
param ssid: Pointer to the SSID string.
|
||||
*/
|
||||
int begin(const char* ssid);
|
||||
/* Start WiFi connection for OPEN networks, without blocking
|
||||
|
||||
param ssid: Pointer to the SSID string.
|
||||
*/
|
||||
int beginNoBlock(const char* ssid);
|
||||
|
||||
int beginBSSID(const char* ssid, const uint8_t *bssid);
|
||||
|
||||
/* Start WiFi connection with WEP encryption.
|
||||
@@ -87,6 +98,15 @@ public:
|
||||
param bssid: If non-null, the BSSID associated w/the SSID to connect to
|
||||
*/
|
||||
int begin(const char* ssid, const char *passphrase, const uint8_t *bssid = nullptr);
|
||||
/* Start WiFi connection with passphrase, without blocking. Check for .connected() for a connection
|
||||
the most secure supported mode will be automatically selected
|
||||
|
||||
param ssid: Pointer to the SSID string.
|
||||
param passphrase: Passphrase. Valid characters in a passphrase
|
||||
must be between ASCII 32-126 (decimal).
|
||||
param bssid: If non-null, the BSSID associated w/the SSID to connect to
|
||||
*/
|
||||
int beginNoBlock(const char* ssid, const char *passphrase, const uint8_t *bssid = nullptr);
|
||||
|
||||
bool connected();
|
||||
bool isConnected() {
|
||||
@@ -136,7 +156,9 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef ARDUINO_RASPBERRY_PI_PICO_W
|
||||
uint8_t softAPgetStationNum();
|
||||
#endif
|
||||
|
||||
IPAddress softAPIP() {
|
||||
return localIP();
|
||||
@@ -147,7 +169,7 @@ public:
|
||||
}
|
||||
|
||||
String softAPmacAddress(void) {
|
||||
uint8_t mac[8];
|
||||
uint8_t mac[6];
|
||||
macAddress(mac);
|
||||
char buff[32];
|
||||
sprintf(buff, "%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
@@ -233,7 +255,7 @@ public:
|
||||
*/
|
||||
uint8_t* macAddress(uint8_t* mac);
|
||||
String macAddress(void) {
|
||||
uint8_t mac[8];
|
||||
uint8_t mac[6];
|
||||
macAddress(mac);
|
||||
char buff[32];
|
||||
sprintf(buff, "%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
@@ -381,8 +403,10 @@ public:
|
||||
|
||||
unsigned long getTime();
|
||||
|
||||
#ifdef ARDUINO_RASPBERRY_PI_PICO_W
|
||||
void aggressiveLowPowerMode();
|
||||
void defaultLowPowerMode();
|
||||
#endif
|
||||
void noLowPowerMode();
|
||||
|
||||
int ping(const char* hostname, uint8_t ttl = 128);
|
||||
@@ -404,6 +428,9 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
// Internal wifi begin. Returns true on success
|
||||
bool _beginInternal(const char* ssid, const char *passphrase, const uint8_t *bssid = nullptr);
|
||||
|
||||
int _timeout = 15000;
|
||||
String _ssid;
|
||||
uint8_t _bssid[6];
|
||||
@@ -411,10 +438,6 @@ private:
|
||||
bool _wifiHWInitted = false;
|
||||
bool _apMode = false;
|
||||
|
||||
// WiFi Scan callback
|
||||
std::map<uint64_t, cyw43_ev_scan_result_t> _scan;
|
||||
static int _scanCB(void *env, const cyw43_ev_scan_result_t *result);
|
||||
|
||||
// DHCP for AP mode
|
||||
dhcp_server_t *_dhcpServer = nullptr;
|
||||
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
#pragma once
|
||||
|
||||
#include <LwipIntfDev.h>
|
||||
#include "nodriver.h"
|
||||
|
||||
class NoDriverLwIP : public LwipIntfDev<NoDriver> {
|
||||
public:
|
||||
|
||||
NoDriverLwIP() :
|
||||
LwipIntfDev<NoDriver>() {
|
||||
}
|
||||
|
||||
bool initHW(bool apMode) {
|
||||
(void) apMode;
|
||||
return false;
|
||||
}
|
||||
|
||||
void setSSID(const char *p) {
|
||||
(void) p;
|
||||
}
|
||||
|
||||
void setBSSID(const uint8_t *bssid) {
|
||||
(void) bssid;
|
||||
}
|
||||
|
||||
void setPassword(const char *p) {
|
||||
(void) p;
|
||||
}
|
||||
|
||||
void setSTA() {
|
||||
}
|
||||
|
||||
void setAP() {
|
||||
}
|
||||
|
||||
void setTimeout(int timeout) {
|
||||
(void) timeout;
|
||||
}
|
||||
|
||||
void end() {
|
||||
}
|
||||
|
||||
bool connected() {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t* macAddress(bool apMode, uint8_t *mac) {
|
||||
(void) apMode;
|
||||
return mac;
|
||||
}
|
||||
|
||||
uint8_t* BSSID(uint8_t *bssid) {
|
||||
return bssid;
|
||||
}
|
||||
|
||||
int32_t RSSI() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int channel() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint8_t encryptionType() {
|
||||
return ENC_TYPE_AUTO;
|
||||
}
|
||||
|
||||
int8_t scanNetworks(bool async = false) {
|
||||
(void) async;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int8_t scanComplete() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void scanDelete() {
|
||||
}
|
||||
|
||||
const char* SSID(uint8_t networkItem) {
|
||||
(void) networkItem;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint8_t encryptionType(uint8_t networkItem) {
|
||||
(void) networkItem;
|
||||
return ENC_TYPE_AUTO;
|
||||
}
|
||||
|
||||
uint8_t* BSSID(uint8_t networkItem, uint8_t *bssid) {
|
||||
(void) networkItem;
|
||||
return bssid;
|
||||
}
|
||||
|
||||
uint8_t channel(uint8_t networkItem) {
|
||||
(void) networkItem;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t RSSI(uint8_t networkItem) {
|
||||
(void) networkItem;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t status() {
|
||||
return WL_NO_MODULE;
|
||||
}
|
||||
|
||||
void noLowPowerMode() {
|
||||
}
|
||||
|
||||
};
|
||||
@@ -0,0 +1,59 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <SPI.h>
|
||||
|
||||
class NoDriver {
|
||||
public:
|
||||
|
||||
NoDriver(int8_t cs, arduino::SPIClass& spi, int8_t intrpin) {
|
||||
(void) cs;
|
||||
(void) spi;
|
||||
(void) intrpin;
|
||||
}
|
||||
|
||||
bool begin(const uint8_t* address, netif *netif) {
|
||||
(void) address;
|
||||
(void) netif;
|
||||
return false;
|
||||
}
|
||||
|
||||
uint16_t sendFrame(const uint8_t* data, uint16_t datalen) {
|
||||
(void) data;
|
||||
(void) datalen;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint16_t readFrame(uint8_t* buffer, uint16_t bufsize) {
|
||||
(void) buffer;
|
||||
(void) bufsize;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint16_t readFrameSize() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void discardFrame(uint16_t ign) {
|
||||
(void) ign;
|
||||
}
|
||||
|
||||
uint16_t readFrameData(uint8_t *ign1, uint16_t ign2) {
|
||||
(void) ign1;
|
||||
(void) ign2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool interruptIsPossible() {
|
||||
return true;
|
||||
}
|
||||
|
||||
PinStatus interruptMode() {
|
||||
return LOW;
|
||||
}
|
||||
|
||||
constexpr bool needsSPI() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
@@ -0,0 +1,227 @@
|
||||
/*
|
||||
WiFiClass methods implementations for the CYG43 chip
|
||||
|
||||
Copyright (c) 2022 Earle F. Philhower, III <earlephilhower@yahoo.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "lwIP_CYW43.h"
|
||||
#include <pico/cyw43_arch.h>
|
||||
|
||||
CYW43lwIP::CYW43lwIP(int8_t cs) : LwipIntfDev<CYW43>(cs) {
|
||||
|
||||
}
|
||||
|
||||
void CYW43lwIP::end() {
|
||||
cyw43_wifi_leave(&cyw43_state, _ap ? 1 : 0);
|
||||
LwipIntfDev<CYW43>::end();
|
||||
}
|
||||
|
||||
bool CYW43lwIP::connected() {
|
||||
return (LwipIntfDev<CYW43>::connected() && (cyw43_wifi_link_status(&cyw43_state, 0) == CYW43_LINK_JOIN));
|
||||
}
|
||||
|
||||
uint8_t* CYW43lwIP::macAddress(bool apMode, uint8_t* mac) {
|
||||
cyw43_wifi_get_mac(&cyw43_state, apMode ? 1 : 0, mac);
|
||||
return mac;
|
||||
}
|
||||
|
||||
uint8_t* CYW43lwIP::BSSID(uint8_t* bssid) {
|
||||
#ifndef CYW43_IOCTL_GET_BSSID
|
||||
#define CYW43_IOCTL_GET_BSSID ( (uint32_t)23 * 2 )
|
||||
#endif
|
||||
|
||||
if (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 CYW43lwIP::channel() {
|
||||
#ifndef CYW43_IOCTL_GET_CHANNEL
|
||||
#define CYW43_IOCTL_GET_CHANNEL 0x3a
|
||||
#endif
|
||||
|
||||
int32_t channel;
|
||||
if (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
|
||||
|
||||
return: signed value
|
||||
*/
|
||||
int32_t CYW43lwIP::RSSI() {
|
||||
#ifndef CYW43_IOCTL_GET_RSSI
|
||||
#define CYW43_IOCTL_GET_RSSI 0xFE
|
||||
#endif
|
||||
|
||||
int32_t rssi;
|
||||
if (connected()) {
|
||||
cyw43_ioctl(&cyw43_state, CYW43_IOCTL_GET_RSSI, sizeof rssi, (uint8_t *)&rssi, CYW43_ITF_STA);
|
||||
} else {
|
||||
rssi = -255;
|
||||
}
|
||||
return rssi;
|
||||
}
|
||||
|
||||
/*
|
||||
Return the Encryption Type associated with the network
|
||||
|
||||
return: one value of wl_enc_type enum
|
||||
*/
|
||||
uint8_t CYW43lwIP::encryptionType() {
|
||||
// TODO - Driver does not return this?!
|
||||
return ENC_TYPE_AUTO;
|
||||
}
|
||||
|
||||
//TODO - this can be in the class
|
||||
static uint64_t _to64(uint8_t b[8]) {
|
||||
uint64_t x = 0;
|
||||
for (int i = 0; i < 6; i++) {
|
||||
x <<= 8LL;
|
||||
x |= b[i] & 255;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
int CYW43lwIP::_scanCB(void *env, const cyw43_ev_scan_result_t *result) {
|
||||
CYW43lwIP *w = (CYW43lwIP *)env;
|
||||
if (result) {
|
||||
cyw43_ev_scan_result_t s;
|
||||
memcpy(&s, result, sizeof(s));
|
||||
w->_scan.insert_or_assign(_to64(s.bssid), s);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int8_t CYW43lwIP::scanNetworks(bool async) {
|
||||
cyw43_wifi_scan_options_t scan_options;
|
||||
memset(&scan_options, 0, sizeof(scan_options));
|
||||
_scan.clear();
|
||||
int err = cyw43_wifi_scan(&cyw43_state, &scan_options, this, _scanCB);
|
||||
if (err) {
|
||||
return 0;
|
||||
}
|
||||
if (!async) {
|
||||
uint32_t now = millis();
|
||||
while (cyw43_wifi_scan_active(&cyw43_state) && (millis() - now < 10000)) {
|
||||
delay(10);
|
||||
}
|
||||
return _scan.size();
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int8_t CYW43lwIP::scanComplete() {
|
||||
if (cyw43_wifi_scan_active(&cyw43_state)) {
|
||||
return -1;
|
||||
} else {
|
||||
return _scan.size();
|
||||
}
|
||||
}
|
||||
|
||||
void CYW43lwIP::scanDelete() {
|
||||
_scan.clear();
|
||||
}
|
||||
|
||||
const char*CYW43lwIP::SSID(uint8_t networkItem) {
|
||||
if (networkItem >= _scan.size()) {
|
||||
return nullptr;
|
||||
}
|
||||
auto it = _scan.begin();
|
||||
for (int i = 0; i < networkItem; i++) {
|
||||
++it;
|
||||
}
|
||||
return (const char *)it->second.ssid;
|
||||
}
|
||||
|
||||
uint8_t CYW43lwIP::encryptionType(uint8_t networkItem) {
|
||||
if (networkItem >= _scan.size()) {
|
||||
return ENC_TYPE_UNKNOWN;
|
||||
}
|
||||
auto it = _scan.begin();
|
||||
for (int i = 0; i < networkItem; i++) {
|
||||
++it;
|
||||
}
|
||||
// TODO - the driver returns a small integer but does not actually provide a way of mapping that to the proper enc type. My best guesses here...
|
||||
switch (it->second.auth_mode) {
|
||||
case 0: return ENC_TYPE_NONE;
|
||||
case 3: return ENC_TYPE_TKIP;
|
||||
case 5: return ENC_TYPE_CCMP;
|
||||
case 7: return ENC_TYPE_AUTO;
|
||||
}
|
||||
return ENC_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
uint8_t* CYW43lwIP::BSSID(uint8_t networkItem, uint8_t* bssid) {
|
||||
if (networkItem >= _scan.size()) {
|
||||
return nullptr;
|
||||
}
|
||||
auto it = _scan.begin();
|
||||
for (int i = 0; i < networkItem; i++) {
|
||||
++it;
|
||||
}
|
||||
memcpy(bssid, it->second.bssid, 6);
|
||||
return bssid;
|
||||
}
|
||||
|
||||
uint8_t CYW43lwIP::channel(uint8_t networkItem) {
|
||||
if (networkItem >= _scan.size()) {
|
||||
return 255;
|
||||
}
|
||||
auto it = _scan.begin();
|
||||
for (int i = 0; i < networkItem; i++) {
|
||||
++it;
|
||||
}
|
||||
return it->second.channel;
|
||||
}
|
||||
|
||||
int32_t CYW43lwIP::RSSI(uint8_t networkItem) {
|
||||
if (networkItem >= _scan.size()) {
|
||||
return -9999;
|
||||
}
|
||||
auto it = _scan.begin();
|
||||
for (int i = 0; i < networkItem; i++) {
|
||||
++it;
|
||||
}
|
||||
return it->second.rssi;
|
||||
}
|
||||
|
||||
uint8_t CYW43lwIP::status() {
|
||||
switch (cyw43_wifi_link_status(&cyw43_state, 0)) {
|
||||
case CYW43_LINK_DOWN: return WL_IDLE_STATUS;
|
||||
case CYW43_LINK_JOIN: return localIP().isSet() ? WL_CONNECTED : WL_DISCONNECTED;
|
||||
case CYW43_LINK_FAIL: return WL_CONNECT_FAILED;
|
||||
case CYW43_LINK_NONET: return WL_CONNECT_FAILED;
|
||||
case CYW43_LINK_BADAUTH: return WL_CONNECT_FAILED;
|
||||
}
|
||||
return WL_NO_MODULE;
|
||||
}
|
||||
|
||||
void CYW43lwIP::noLowPowerMode() {
|
||||
cyw43_wifi_pm(&cyw43_state, 0xA11140);
|
||||
}
|
||||
@@ -3,4 +3,38 @@
|
||||
#include <LwipIntfDev.h>
|
||||
#include <utility/CYW43shim.h>
|
||||
|
||||
using CYW43lwIP = LwipIntfDev<CYW43>;
|
||||
class CYW43lwIP: public LwipIntfDev<CYW43> {
|
||||
public:
|
||||
CYW43lwIP(int8_t cs = SS);
|
||||
|
||||
void end();
|
||||
bool connected();
|
||||
|
||||
uint8_t* macAddress(bool apMode, uint8_t *mac);
|
||||
|
||||
uint8_t* BSSID(uint8_t *bssid);
|
||||
int32_t RSSI();
|
||||
int channel();
|
||||
uint8_t encryptionType();
|
||||
|
||||
int8_t scanNetworks(bool async = false);
|
||||
int8_t scanComplete();
|
||||
void scanDelete();
|
||||
|
||||
const char* SSID(uint8_t networkItem);
|
||||
uint8_t encryptionType(uint8_t networkItem);
|
||||
uint8_t* BSSID(uint8_t networkItem, uint8_t *bssid);
|
||||
uint8_t channel(uint8_t networkItem);
|
||||
int32_t RSSI(uint8_t networkItem);
|
||||
|
||||
uint8_t status();
|
||||
|
||||
void noLowPowerMode();
|
||||
|
||||
private:
|
||||
|
||||
// WiFi Scan callback
|
||||
std::map<uint64_t, cyw43_ev_scan_result_t> _scan;
|
||||
static int _scanCB(void *env, const cyw43_ev_scan_result_t *result);
|
||||
|
||||
};
|
||||
|
||||
@@ -91,6 +91,10 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
PinStatus interruptMode() {
|
||||
return LOW;
|
||||
}
|
||||
|
||||
void setSSID(const char *p) {
|
||||
_ssid = p;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
# lwIP_ESPHost library
|
||||
|
||||
RP2040 Arduino integration with the ESPHost library.
|
||||
|
||||
[ESPHost library](https://github.com/JAndrassy/ESPHost) is a driver for communication with Espressif's esp-hosted-fg firmware.
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
name=lwIP_ESPHost
|
||||
version=1
|
||||
author=Juraj Andrassy
|
||||
maintainer=Earle F. Philhower, III <earlephilhower@yahoo.com>
|
||||
sentence=RP2040 ESPHost wifi driver
|
||||
paragraph=Driver for the esp-hosted-fg firmware with the ESPHosted library
|
||||
category=Communication
|
||||
url=https://github.com/earlephilhower/arduino-pico
|
||||
architectures=rp2040
|
||||
dot_a_linkage=true
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
WiFi <-> LWIP for ESPHost library in RP2040 Core
|
||||
|
||||
Copyright (c) 2024 Juraj Andrassy
|
||||
|
||||
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 "ESPHost.h"
|
||||
#include <CEspControl.h>
|
||||
#include <LwipEthernet.h>
|
||||
|
||||
ESPHost::ESPHost(int8_t cs, arduino::SPIClass &spi, int8_t intrpin) {
|
||||
(void) cs;
|
||||
(void) spi;
|
||||
(void) intrpin;
|
||||
// CS and SPI are configured in ESPHost library
|
||||
}
|
||||
|
||||
bool ESPHost::begin(const uint8_t *address, netif *netif) {
|
||||
(void) address;
|
||||
(void) netif;
|
||||
|
||||
// WiFi is initialized in ESPHostLwIP
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ESPHost::end() {
|
||||
// WiFi is ended in ESPHostLwIP
|
||||
}
|
||||
|
||||
uint16_t ESPHost::sendFrame(const uint8_t *data, uint16_t datalen) {
|
||||
ethernet_arch_lwip_gpio_mask();
|
||||
int res = CEspControl::getInstance().sendBuffer(apMode ? ESP_AP_IF : ESP_STA_IF, 0, (uint8_t*) data, datalen);
|
||||
CEspControl::getInstance().communicateWithEsp();
|
||||
ethernet_arch_lwip_gpio_unmask();
|
||||
return (res == ESP_CONTROL_OK) ? datalen : 0;
|
||||
}
|
||||
|
||||
uint16_t ESPHost::readFrameData(uint8_t *buffer, uint16_t bufsize) {
|
||||
uint8_t ifn = 0;
|
||||
uint16_t res;
|
||||
if (apMode) {
|
||||
res = CEspControl::getInstance().getSoftApRx(ifn, buffer, bufsize);
|
||||
} else {
|
||||
res = CEspControl::getInstance().getStationRx(ifn, buffer, bufsize);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
uint16_t ESPHost::readFrameSize() {
|
||||
CEspControl::getInstance().communicateWithEsp();
|
||||
uint16_t res;
|
||||
if (apMode) {
|
||||
res = CEspControl::getInstance().peekSoftApRxPayloadLen();
|
||||
} else {
|
||||
res = CEspControl::getInstance().peekStationRxPayloadLen();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
WiFi <-> LWIP for ESPHost library in RP2040 Core
|
||||
|
||||
Copyright (c) 2024 Juraj Andrassy
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <SPI.h>
|
||||
|
||||
class ESPHost {
|
||||
public:
|
||||
|
||||
// constructor and methods as required by LwipIntfDev
|
||||
|
||||
ESPHost(int8_t cs, arduino::SPIClass &spi, int8_t intrpin);
|
||||
|
||||
bool begin(const uint8_t *address, netif *netif);
|
||||
void end();
|
||||
|
||||
uint16_t sendFrame(const uint8_t *data, uint16_t datalen);
|
||||
|
||||
uint16_t readFrameData(uint8_t *buffer, uint16_t bufsize);
|
||||
|
||||
uint16_t readFrameSize();
|
||||
|
||||
void discardFrame(uint16_t ign) {
|
||||
(void) ign;
|
||||
}
|
||||
|
||||
bool interruptIsPossible() {
|
||||
return true;
|
||||
}
|
||||
|
||||
PinStatus interruptMode() {
|
||||
return HIGH;
|
||||
}
|
||||
|
||||
constexpr bool needsSPI() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected:
|
||||
bool apMode = false;
|
||||
|
||||
};
|
||||
@@ -0,0 +1,340 @@
|
||||
/*
|
||||
WiFi <-> LWIP for ESPHost library in RP2040 Core
|
||||
|
||||
Copyright (c) 2024 Juraj Andrassy
|
||||
|
||||
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 "lwIP_ESPHost.h"
|
||||
#include "CEspControl.h"
|
||||
|
||||
#define MAX_SOFTAP_CONNECTION_DEF 5
|
||||
|
||||
#if defined(SPIWIFI_ACK) // Arduino Nano RP2040 Connect
|
||||
#define ESPHOST_DATA_READY SPIWIFI_ACK
|
||||
#endif
|
||||
|
||||
bool ESPHostLwIP::wifiHwInitialized = false;
|
||||
ESPHostLwIP* ESPHostLwIP::instance = nullptr;
|
||||
|
||||
ESPHostLwIP::ESPHostLwIP() :
|
||||
LwipIntfDev<ESPHost>(SS, SPI, ESPHOST_DATA_READY) {
|
||||
|
||||
}
|
||||
|
||||
void ESPHostLwIP::setSTA() {
|
||||
apMode = false;
|
||||
}
|
||||
|
||||
void ESPHostLwIP::setAP() {
|
||||
apMode = true;
|
||||
}
|
||||
|
||||
void ESPHostLwIP::setSSID(const char *ssid) {
|
||||
if (apMode) {
|
||||
if (ssid == nullptr) {
|
||||
softAP.ssid[0] = 0;
|
||||
} else {
|
||||
memcpy(softAP.ssid, ssid, sizeof(softAP.ssid));
|
||||
}
|
||||
} else {
|
||||
if (ssid == nullptr) {
|
||||
ap.ssid[0] = 0;
|
||||
} else {
|
||||
memcpy(ap.ssid, ssid, sizeof(ap.ssid));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ESPHostLwIP::setBSSID(const uint8_t *bssid) {
|
||||
if (bssid == nullptr || !(bssid[0] | bssid[1] | bssid[2] | bssid[3] | bssid[4] | bssid[5])) {
|
||||
ap.bssid[0] = 0;
|
||||
} else {
|
||||
snprintf((char *)ap.bssid, sizeof(ap.bssid), "%02x:%02x:%02x:%02x:%02x:%02x", bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5]);
|
||||
}
|
||||
}
|
||||
|
||||
void ESPHostLwIP::setPassword(const char *pass) {
|
||||
if (apMode) {
|
||||
if (pass == nullptr) {
|
||||
softAP.pwd[0] = 0;
|
||||
} else {
|
||||
memcpy(softAP.pwd, pass, sizeof(softAP.pwd));
|
||||
}
|
||||
} else {
|
||||
if (pass == nullptr) {
|
||||
ap.pwd[0] = 0;
|
||||
} else {
|
||||
memcpy(ap.pwd, pass, sizeof(ap.pwd));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ESPHostLwIP::setChannel(uint8_t channel) {
|
||||
softAP.channel = (channel > MAX_CHNL_NO) ? MAX_CHNL_NO : channel;
|
||||
}
|
||||
|
||||
void ESPHostLwIP::setTimeout(int _timeout) {
|
||||
timeout = _timeout;
|
||||
}
|
||||
|
||||
int ESPHostLwIP::initEventCb(CCtrlMsgWrapper *resp) {
|
||||
(void) resp;
|
||||
wifiHwInitialized = true;
|
||||
return ESP_CONTROL_OK;
|
||||
}
|
||||
|
||||
int ESPHostLwIP::disconnectEventCb(CCtrlMsgWrapper *resp) {
|
||||
(void) resp;
|
||||
instance->onDisconnectEvent();
|
||||
return ESP_CONTROL_OK;
|
||||
}
|
||||
|
||||
bool ESPHostLwIP::initHW() {
|
||||
if (wifiHwInitialized) {
|
||||
return true;
|
||||
}
|
||||
instance = this;
|
||||
|
||||
CEspControl::getInstance().listenForStationDisconnectEvent(disconnectEventCb);
|
||||
CEspControl::getInstance().listenForInitEvent(initEventCb);
|
||||
if (CEspControl::getInstance().initSpiDriver() != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t start = millis();
|
||||
while (!wifiHwInitialized && (millis() - start < timeout)) {
|
||||
CEspControl::getInstance().communicateWithEsp();
|
||||
delay(100);
|
||||
}
|
||||
if (wifiHwInitialized) {
|
||||
wifiStatus = WL_IDLE_STATUS;
|
||||
}
|
||||
__startEthernetContext();
|
||||
return wifiHwInitialized;
|
||||
}
|
||||
|
||||
bool ESPHostLwIP::begin() {
|
||||
if (!initHW()) {
|
||||
return false;
|
||||
}
|
||||
ethernet_arch_lwip_gpio_mask();
|
||||
if (!apMode) {
|
||||
CEspControl::getInstance().setWifiMode(WIFI_MODE_STA);
|
||||
if (CEspControl::getInstance().connectAccessPoint(ap) != ESP_CONTROL_OK) {
|
||||
wifiStatus = WL_CONNECT_FAILED;
|
||||
ethernet_arch_lwip_end();
|
||||
return false;
|
||||
}
|
||||
CEspControl::getInstance().getAccessPointConfig(ap);
|
||||
} else {
|
||||
CEspControl::getInstance().setWifiMode(WIFI_MODE_AP);
|
||||
if (softAP.channel == 0 || softAP.channel > MAX_CHNL_NO) {
|
||||
softAP.channel = 1;
|
||||
}
|
||||
softAP.max_connections = MAX_SOFTAP_CONNECTION_DEF;
|
||||
softAP.encryption_mode = softAP.pwd[0] == 0 ? WIFI_AUTH_OPEN : WIFI_AUTH_WPA_WPA2_PSK;
|
||||
softAP.bandwidth = WIFI_BW_HT40;
|
||||
softAP.ssid_hidden = false;
|
||||
int rv = CEspControl::getInstance().startSoftAccessPoint(softAP);
|
||||
if (rv != ESP_CONTROL_OK) {
|
||||
wifiStatus = WL_AP_FAILED;
|
||||
ethernet_arch_lwip_end();
|
||||
return false;
|
||||
}
|
||||
CEspControl::getInstance().getSoftAccessPointConfig(softAP);
|
||||
}
|
||||
ethernet_arch_lwip_gpio_unmask();
|
||||
uint8_t mac[6];
|
||||
if (!LwipIntfDev<ESPHost>::begin(macAddress(apMode, mac))) {
|
||||
ethernet_arch_lwip_gpio_mask();
|
||||
if (apMode) {
|
||||
CEspControl::getInstance().stopSoftAccessPoint();
|
||||
wifiStatus = WL_AP_FAILED;
|
||||
} else {
|
||||
CEspControl::getInstance().disconnectAccessPoint();
|
||||
wifiStatus = WL_CONNECT_FAILED;
|
||||
}
|
||||
ethernet_arch_lwip_gpio_unmask();
|
||||
return false;
|
||||
}
|
||||
if (apMode) {
|
||||
wifiStatus = WL_AP_LISTENING;
|
||||
} else {
|
||||
joined = true;
|
||||
wifiStatus = LwipIntfDev<ESPHost>::connected() ? WL_CONNECTED : WL_DISCONNECTED;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void ESPHostLwIP::end() {
|
||||
LwipIntfDev<ESPHost>::end();
|
||||
if (apMode) {
|
||||
CEspControl::getInstance().stopSoftAccessPoint();
|
||||
} else {
|
||||
CEspControl::getInstance().disconnectAccessPoint();
|
||||
joined = false;
|
||||
}
|
||||
wifiStatus = WL_IDLE_STATUS;
|
||||
}
|
||||
|
||||
void ESPHostLwIP::onDisconnectEvent() {
|
||||
LwipIntfDev<ESPHost>::end();
|
||||
joined = false;
|
||||
wifiStatus = WL_CONNECTION_LOST;
|
||||
}
|
||||
|
||||
bool ESPHostLwIP::connected() {
|
||||
return (status() == WL_CONNECTED);
|
||||
}
|
||||
|
||||
uint8_t ESPHostLwIP::status() {
|
||||
initHW();
|
||||
if (joined && wifiStatus == WL_DISCONNECTED && LwipIntfDev<ESPHost>::connected()) {
|
||||
wifiStatus = WL_CONNECTED; // DHCP finished
|
||||
}
|
||||
return wifiStatus;
|
||||
}
|
||||
|
||||
uint8_t* ESPHostLwIP::macAddress(bool apMode, uint8_t *mac) {
|
||||
if (!initHW()) {
|
||||
return mac;
|
||||
}
|
||||
WifiMac_t MAC;
|
||||
MAC.mode = apMode ? WIFI_MODE_AP : WIFI_MODE_STA;
|
||||
ethernet_arch_lwip_gpio_mask();
|
||||
if (CEspControl::getInstance().getWifiMacAddress(MAC) == ESP_CONTROL_OK) {
|
||||
CNetUtilities::macStr2macArray(mac, MAC.mac);
|
||||
}
|
||||
ethernet_arch_lwip_gpio_unmask();
|
||||
return mac;
|
||||
}
|
||||
|
||||
uint8_t* ESPHostLwIP::BSSID(uint8_t *bssid) {
|
||||
CNetUtilities::macStr2macArray(bssid, (char*) ap.bssid);
|
||||
return bssid;
|
||||
}
|
||||
|
||||
int ESPHostLwIP::channel() {
|
||||
return ap.channel;
|
||||
}
|
||||
|
||||
int32_t ESPHostLwIP::RSSI() {
|
||||
if (!joined) {
|
||||
return 0;
|
||||
}
|
||||
ethernet_arch_lwip_gpio_mask();
|
||||
CEspControl::getInstance().getAccessPointConfig(ap);
|
||||
ethernet_arch_lwip_gpio_unmask();
|
||||
return ap.rssi;
|
||||
}
|
||||
|
||||
static uint8_t encr2wl_enc(int enc) {
|
||||
// the ESPHost returns authentication mode as encryption mode
|
||||
if (enc == WIFI_AUTH_OPEN) {
|
||||
return ENC_TYPE_NONE;
|
||||
} else if (enc == WIFI_AUTH_WEP) {
|
||||
return ENC_TYPE_WEP;
|
||||
} else if (enc == WIFI_AUTH_WPA_PSK) {
|
||||
return ENC_TYPE_WPA;
|
||||
} else if (enc == WIFI_AUTH_WPA2_PSK) {
|
||||
return ENC_TYPE_WPA2;
|
||||
} else if (enc == WIFI_AUTH_WPA_WPA2_PSK) {
|
||||
return ENC_TYPE_WPA2;
|
||||
} else if (enc == WIFI_AUTH_WPA3_PSK) {
|
||||
return ENC_TYPE_WPA3;
|
||||
} else if (enc == WIFI_AUTH_WPA2_WPA3_PSK) {
|
||||
return ENC_TYPE_WPA3;
|
||||
} else {
|
||||
return ENC_TYPE_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t ESPHostLwIP::encryptionType() {
|
||||
return encr2wl_enc(ap.encryption_mode);
|
||||
}
|
||||
|
||||
int8_t ESPHostLwIP::scanNetworks(bool async) {
|
||||
(void) async;
|
||||
accessPoints.clear();
|
||||
if (!initHW()) {
|
||||
return -1;
|
||||
}
|
||||
ethernet_arch_lwip_gpio_mask();
|
||||
int res = CEspControl::getInstance().getAccessPointScanList(accessPoints);
|
||||
ethernet_arch_lwip_gpio_unmask();
|
||||
wifiStatus = WL_SCAN_COMPLETED;
|
||||
if (res != ESP_CONTROL_OK) {
|
||||
return -1;
|
||||
}
|
||||
return accessPoints.size();
|
||||
}
|
||||
|
||||
int8_t ESPHostLwIP::scanComplete() {
|
||||
return accessPoints.size();
|
||||
}
|
||||
|
||||
void ESPHostLwIP::scanDelete() {
|
||||
accessPoints.clear();
|
||||
}
|
||||
|
||||
const char* ESPHostLwIP::SSID(uint8_t networkItem) {
|
||||
if (networkItem < accessPoints.size()) {
|
||||
return (const char*) accessPoints[networkItem].ssid;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint8_t ESPHostLwIP::encryptionType(uint8_t networkItem) {
|
||||
if (networkItem < accessPoints.size()) {
|
||||
return encr2wl_enc(accessPoints[networkItem].encryption_mode);
|
||||
}
|
||||
return ENC_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
uint8_t* ESPHostLwIP::BSSID(uint8_t networkItem, uint8_t *bssid) {
|
||||
if (networkItem < accessPoints.size()) {
|
||||
CNetUtilities::macStr2macArray(bssid, (char*) accessPoints[networkItem].bssid);
|
||||
}
|
||||
return bssid;
|
||||
}
|
||||
|
||||
uint8_t ESPHostLwIP::channel(uint8_t networkItem) {
|
||||
if (networkItem < accessPoints.size()) {
|
||||
return accessPoints[networkItem].channel;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t ESPHostLwIP::RSSI(uint8_t networkItem) {
|
||||
if (networkItem < accessPoints.size()) {
|
||||
return accessPoints[networkItem].rssi;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ESPHostLwIP::lowPowerMode() {
|
||||
if (!initHW()) {
|
||||
return;
|
||||
}
|
||||
ethernet_arch_lwip_gpio_mask();
|
||||
CEspControl::getInstance().setPowerSaveMode(1);
|
||||
ethernet_arch_lwip_gpio_unmask();
|
||||
}
|
||||
|
||||
void ESPHostLwIP::noLowPowerMode() {
|
||||
// not supported by firmware
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
WiFi <-> LWIP for ESPHost library in RP2040 Core
|
||||
|
||||
Copyright (c) 2024 Juraj Andrassy
|
||||
|
||||
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 <LwipIntfDev.h>
|
||||
#include "CCtrlWrapper.h"
|
||||
#include "ESPHost.h"
|
||||
|
||||
class ESPHostLwIP : public LwipIntfDev<ESPHost> {
|
||||
public:
|
||||
|
||||
ESPHostLwIP();
|
||||
|
||||
void setSTA();
|
||||
void setAP();
|
||||
|
||||
void setSSID(const char *p);
|
||||
void setBSSID(const uint8_t *bssid);
|
||||
void setPassword(const char *p);
|
||||
void setChannel(uint8_t channel);
|
||||
|
||||
bool begin();
|
||||
void end();
|
||||
bool connected();
|
||||
uint8_t status();
|
||||
|
||||
uint8_t* macAddress(bool apMode, uint8_t *mac);
|
||||
|
||||
uint8_t* BSSID(uint8_t *bssid);
|
||||
int32_t RSSI();
|
||||
int channel();
|
||||
uint8_t encryptionType();
|
||||
|
||||
int8_t scanNetworks(bool async = false);
|
||||
int8_t scanComplete();
|
||||
void scanDelete();
|
||||
|
||||
const char* SSID(uint8_t networkItem);
|
||||
uint8_t encryptionType(uint8_t networkItem);
|
||||
uint8_t* BSSID(uint8_t networkItem, uint8_t *bssid);
|
||||
uint8_t channel(uint8_t networkItem);
|
||||
int32_t RSSI(uint8_t networkItem);
|
||||
|
||||
void lowPowerMode();
|
||||
void noLowPowerMode();
|
||||
|
||||
void setTimeout(int timeout);
|
||||
|
||||
private:
|
||||
static int initEventCb(CCtrlMsgWrapper *resp);
|
||||
static int disconnectEventCb(CCtrlMsgWrapper *resp);
|
||||
|
||||
static bool wifiHwInitialized;
|
||||
static ESPHostLwIP* instance;
|
||||
|
||||
bool initHW();
|
||||
void onDisconnectEvent();
|
||||
|
||||
uint32_t timeout = 10000;
|
||||
uint8_t wifiStatus = WL_NO_MODULE;
|
||||
WifiApCfg_t ap;
|
||||
bool joined = false;
|
||||
SoftApCfg_t softAP;
|
||||
|
||||
std::vector<AccessPoint_t> accessPoints;
|
||||
}
|
||||
;
|
||||
@@ -31,6 +31,7 @@ bool __ethernetContextInitted = false;
|
||||
|
||||
// Async context that pumps the ethernet controllers
|
||||
static async_context_threadsafe_background_t lwip_ethernet_async_context_threadsafe_background;
|
||||
static async_when_pending_worker_t always_pending_update_timeout_worker;
|
||||
static async_at_time_worker_t ethernet_timeout_worker;
|
||||
static async_context_t *_context = nullptr;
|
||||
|
||||
@@ -71,6 +72,45 @@ void __removeEthernetPacketHandler(int id) {
|
||||
ethernet_arch_lwip_end();
|
||||
}
|
||||
|
||||
#define GPIOSTACKSIZE 8
|
||||
static uint32_t gpioMaskStack[GPIOSTACKSIZE][4];
|
||||
static uint32_t gpioMask[4] = {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff};
|
||||
|
||||
void ethernet_arch_lwip_gpio_mask() {
|
||||
noInterrupts();
|
||||
memmove(gpioMaskStack[1], gpioMaskStack[0], 4 * sizeof(uint32_t) * (GPIOSTACKSIZE - 1)); // Push down the stack
|
||||
io_irq_ctrl_hw_t *irq_ctrl_base = get_core_num() ? &iobank0_hw->proc1_irq_ctrl : &iobank0_hw->proc0_irq_ctrl;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
gpioMaskStack[0][i] = irq_ctrl_base->inte[i];
|
||||
irq_ctrl_base->inte[i] = irq_ctrl_base->inte[i] & gpioMask[i];
|
||||
}
|
||||
interrupts();
|
||||
}
|
||||
|
||||
void ethernet_arch_lwip_gpio_unmask() {
|
||||
noInterrupts();
|
||||
io_irq_ctrl_hw_t *irq_ctrl_base = get_core_num() ? &iobank0_hw->proc1_irq_ctrl : &iobank0_hw->proc0_irq_ctrl;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
irq_ctrl_base->inte[i] = gpioMaskStack[0][i];
|
||||
}
|
||||
memmove(gpioMaskStack[0], gpioMaskStack[1], 4 * sizeof(uint32_t) * (GPIOSTACKSIZE - 1)); // Pop up the stack
|
||||
interrupts();
|
||||
}
|
||||
|
||||
// To be called after IRQ is set, so we can just rad from the IOREG instead of duplicating the calculation
|
||||
void __addEthernetGPIO(int pin) {
|
||||
int idx = pin / 8;
|
||||
int off = (pin % 8) * 4;
|
||||
gpioMask[idx] &= ~(0xf << off);
|
||||
}
|
||||
|
||||
void __removeEthernetGPIO(int pin) {
|
||||
int idx = pin / 8;
|
||||
int off = (pin % 8) * 4;
|
||||
gpioMask[idx] |= 0xf << off;
|
||||
}
|
||||
|
||||
|
||||
static volatile bool _dns_lookup_pending = false;
|
||||
|
||||
static void _dns_found_callback(const char *name, const ip_addr_t *ipaddr, void *callback_arg) {
|
||||
@@ -127,10 +167,13 @@ static async_context_t *lwip_ethernet_init_default_async_context(void) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uint32_t __ethernet_timeout_reached_calls = 0;
|
||||
static uint32_t _pollingPeriod = 20;
|
||||
// This will only be called under the protection of the async context mutex, so no re-entrancy checks needed
|
||||
static void ethernet_timeout_reached(async_context_t *context, __unused async_at_time_worker_t *worker) {
|
||||
static void ethernet_timeout_reached(__unused async_context_t *context, __unused async_at_time_worker_t *worker) {
|
||||
assert(worker == ðernet_timeout_worker);
|
||||
__ethernet_timeout_reached_calls++;
|
||||
ethernet_arch_lwip_gpio_mask(); // Ensure non-polled devices won't interrupt us
|
||||
for (auto handlePacket : _handlePacketList) {
|
||||
handlePacket.second();
|
||||
}
|
||||
@@ -141,6 +184,12 @@ static void ethernet_timeout_reached(async_context_t *context, __unused async_at
|
||||
#else
|
||||
sys_check_timeouts();
|
||||
#endif
|
||||
ethernet_arch_lwip_gpio_unmask();
|
||||
}
|
||||
|
||||
static void update_next_timeout(async_context_t *context, async_when_pending_worker_t *worker) {
|
||||
assert(worker == &always_pending_update_timeout_worker);
|
||||
worker->work_pending = true;
|
||||
async_context_add_at_time_worker_in_ms(context, ðernet_timeout_worker, _pollingPeriod);
|
||||
}
|
||||
|
||||
@@ -158,7 +207,9 @@ void __startEthernetContext() {
|
||||
_context = lwip_ethernet_init_default_async_context();
|
||||
#endif
|
||||
ethernet_timeout_worker.do_work = ethernet_timeout_reached;
|
||||
async_context_add_at_time_worker_in_ms(_context, ðernet_timeout_worker, _pollingPeriod);
|
||||
always_pending_update_timeout_worker.work_pending = true;
|
||||
always_pending_update_timeout_worker.do_work = update_next_timeout;
|
||||
async_context_add_when_pending_worker(_context, &always_pending_update_timeout_worker);
|
||||
__ethernetContextInitted = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,11 @@
|
||||
|
||||
void ethernet_arch_lwip_begin() __attribute__((weak));
|
||||
void ethernet_arch_lwip_end() __attribute__((weak));
|
||||
void ethernet_arch_lwip_gpio_mask() __attribute__((weak));
|
||||
void ethernet_arch_lwip_gpio_unmask() __attribute__((weak));
|
||||
|
||||
void __addEthernetGPIO(int pin);
|
||||
void __removeEthernetGPIO(int pin);
|
||||
|
||||
// Internal Ethernet helper functions
|
||||
void __startEthernetContext();
|
||||
|
||||
@@ -50,6 +50,11 @@
|
||||
#define DEFAULT_MTU 1500
|
||||
#endif
|
||||
|
||||
enum EthernetLinkStatus {
|
||||
Unknown,
|
||||
LinkON,
|
||||
LinkOFF
|
||||
};
|
||||
|
||||
extern "C" void cyw43_hal_generate_laa_mac(__unused int idx, uint8_t buf[6]);
|
||||
|
||||
@@ -137,10 +142,21 @@ public:
|
||||
_spiSettings = s;
|
||||
}
|
||||
|
||||
uint32_t packetsReceived() {
|
||||
return _packetsReceived;
|
||||
}
|
||||
uint32_t packetsSent() {
|
||||
return _packetsSent;
|
||||
}
|
||||
|
||||
|
||||
// ESP8266WiFi API compatibility
|
||||
|
||||
wl_status_t status();
|
||||
|
||||
// Arduino Ethernet compatibility
|
||||
EthernetLinkStatus linkStatus();
|
||||
|
||||
protected:
|
||||
err_t netif_init();
|
||||
void check_route();
|
||||
@@ -149,6 +165,7 @@ protected:
|
||||
static err_t netif_init_s(netif* netif);
|
||||
static err_t linkoutput_s(netif* netif, struct pbuf* p);
|
||||
static void netif_status_callback_s(netif* netif);
|
||||
static void _irq(void *param);
|
||||
public:
|
||||
// called on a regular basis or on interrupt
|
||||
err_t handlePackets();
|
||||
@@ -172,6 +189,9 @@ protected:
|
||||
|
||||
// Packet handler number
|
||||
int _phID = -1;
|
||||
|
||||
uint32_t _packetsReceived = 0;
|
||||
uint32_t _packetsSent = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -348,7 +368,9 @@ bool LwipIntfDev<RawDev>::begin(const uint8_t* macAddress, const uint16_t mtu) {
|
||||
return false;
|
||||
}
|
||||
|
||||
_phID = __addEthernetPacketHandler([this] { this->handlePackets(); });
|
||||
if (_intrPin < 0) {
|
||||
_phID = __addEthernetPacketHandler([this] { this->handlePackets(); });
|
||||
}
|
||||
|
||||
if (localIP().v4() == 0) {
|
||||
// IP not set, starting DHCP
|
||||
@@ -383,7 +405,11 @@ bool LwipIntfDev<RawDev>::begin(const uint8_t* macAddress, const uint16_t mtu) {
|
||||
|
||||
if (_intrPin >= 0) {
|
||||
if (RawDev::interruptIsPossible()) {
|
||||
// attachInterrupt(_intrPin, [&]() { this->handlePackets(); }, FALLING);
|
||||
noInterrupts(); // Ensure this is atomically set up
|
||||
pinMode(_intrPin, INPUT);
|
||||
attachInterruptParam(_intrPin, _irq, RawDev::interruptMode(), (void*)this);
|
||||
__addEthernetGPIO(_intrPin);
|
||||
interrupts();
|
||||
} else {
|
||||
::printf((PGM_P)F(
|
||||
"lwIP_Intf: Interrupt not implemented yet, enabling transparent polling\r\n"));
|
||||
@@ -396,7 +422,12 @@ bool LwipIntfDev<RawDev>::begin(const uint8_t* macAddress, const uint16_t mtu) {
|
||||
|
||||
template<class RawDev>
|
||||
void LwipIntfDev<RawDev>::end() {
|
||||
__removeEthernetPacketHandler(_phID);
|
||||
if (_intrPin < 0) {
|
||||
__removeEthernetPacketHandler(_phID);
|
||||
} else {
|
||||
detachInterrupt(_intrPin);
|
||||
__removeEthernetGPIO(_intrPin);
|
||||
}
|
||||
|
||||
RawDev::end();
|
||||
|
||||
@@ -405,18 +436,31 @@ void LwipIntfDev<RawDev>::end() {
|
||||
_started = false;
|
||||
}
|
||||
|
||||
template<class RawDev>
|
||||
void LwipIntfDev<RawDev>::_irq(void *param) {
|
||||
LwipIntfDev *d = static_cast<LwipIntfDev*>(param);
|
||||
ethernet_arch_lwip_begin();
|
||||
d->handlePackets();
|
||||
sys_check_timeouts();
|
||||
ethernet_arch_lwip_end();
|
||||
}
|
||||
|
||||
template<class RawDev>
|
||||
wl_status_t LwipIntfDev<RawDev>::status() {
|
||||
return _started ? (connected() ? WL_CONNECTED : WL_DISCONNECTED) : WL_NO_SHIELD;
|
||||
}
|
||||
|
||||
template<class RawDev>
|
||||
EthernetLinkStatus LwipIntfDev<RawDev>::linkStatus() {
|
||||
return RawDev::isLinkDetectable() ? _started && RawDev::isLinked() ? LinkON : LinkOFF : Unknown;
|
||||
}
|
||||
|
||||
template<class RawDev>
|
||||
err_t LwipIntfDev<RawDev>::linkoutput_s(netif* netif, struct pbuf* pbuf) {
|
||||
LwipIntfDev* lid = (LwipIntfDev*)netif->state;
|
||||
ethernet_arch_lwip_begin();
|
||||
uint16_t len = lid->sendFrame((const uint8_t*)pbuf->payload, pbuf->len);
|
||||
|
||||
lid->_packetsSent++;
|
||||
#if PHY_HAS_CAPTURE
|
||||
if (phy_capture) {
|
||||
phy_capture(lid->_netif.num, (const char*)pbuf->payload, pbuf->len, /*out*/ 1,
|
||||
@@ -530,6 +574,8 @@ err_t LwipIntfDev<RawDev>::handlePackets() {
|
||||
return ERR_BUF;
|
||||
}
|
||||
|
||||
_packetsReceived++;
|
||||
|
||||
err_t err = _netif.input(pbuf, &_netif);
|
||||
|
||||
#if PHY_HAS_CAPTURE
|
||||
|
||||
@@ -69,6 +69,9 @@
|
||||
#define ECON2_AUTOINC 0x80
|
||||
#define ECON2_PKTDEC 0x40
|
||||
|
||||
#define EIE_PKTIE 0x40
|
||||
#define EIE_INTIE 0x80
|
||||
|
||||
#define EIR_TXIF 0x08
|
||||
|
||||
#define ERXTX_BANK 0x00
|
||||
@@ -153,8 +156,7 @@
|
||||
// The ENC28J60 SPI Interface supports clock speeds up to 20 MHz
|
||||
static const SPISettings spiSettings(20000000, MSBFIRST, SPI_MODE0);
|
||||
|
||||
ENC28J60::ENC28J60(int8_t cs, SPIClass& spi, int8_t intr) : _bank(ERXTX_BANK), _cs(cs), _spi(spi) {
|
||||
(void)intr;
|
||||
ENC28J60::ENC28J60(int8_t cs, SPIClass& spi, int8_t intr) : _bank(ERXTX_BANK), _cs(cs), _intr(intr), _spi(spi) {
|
||||
}
|
||||
|
||||
void ENC28J60::enc28j60_arch_spi_select(void) {
|
||||
@@ -488,6 +490,12 @@ bool ENC28J60::reset(void) {
|
||||
/* Turn on autoincrement for buffer access */
|
||||
setregbitfield(ECON2, ECON2_AUTOINC);
|
||||
|
||||
/* Enable interrupt on packet receive if desired */
|
||||
if (_intr >= 0) {
|
||||
setregbitfield(EIE, EIE_PKTIE);
|
||||
setregbitfield(EIE, EIE_INTIE);
|
||||
}
|
||||
|
||||
/* Turn on reception */
|
||||
writereg(ECON1, ECON1_RXEN);
|
||||
|
||||
@@ -508,9 +516,17 @@ bool ENC28J60::begin(const uint8_t* address, netif *net) {
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
void ENC28J60::end() {
|
||||
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
uint16_t ENC28J60::sendFrame(const uint8_t* data, uint16_t datalen) {
|
||||
uint16_t dataend;
|
||||
|
||||
ethernet_arch_lwip_gpio_mask(); // So we don't fire an IRQ and interrupt the send w/a receive!
|
||||
|
||||
/*
|
||||
1. Appropriately program the ETXST pointer to point to an unused
|
||||
location in memory. It will point to the per packet control
|
||||
@@ -582,6 +598,8 @@ uint16_t ENC28J60::sendFrame(const uint8_t* data, uint16_t datalen) {
|
||||
}
|
||||
#endif
|
||||
|
||||
ethernet_arch_lwip_gpio_unmask();
|
||||
|
||||
// sent_packets++;
|
||||
// PRINTF("enc28j60: sent_packets %d\n", sent_packets);
|
||||
return datalen;
|
||||
@@ -697,8 +715,10 @@ uint16_t ENC28J60::phyread(uint8_t reg) {
|
||||
|
||||
bool ENC28J60::isLinked() {
|
||||
// ( https://github.com/JAndrassy/EthernetENC/tree/master/src/utility/enc28j60.h )
|
||||
ethernet_arch_lwip_gpio_mask();
|
||||
ethernet_arch_lwip_begin();
|
||||
auto ret = !!(phyread(MACSTAT2) & 0x400);
|
||||
ethernet_arch_lwip_end();
|
||||
ethernet_arch_lwip_gpio_unmask();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -61,6 +61,11 @@ public:
|
||||
*/
|
||||
bool begin(const uint8_t* address, netif *net);
|
||||
|
||||
/**
|
||||
Shut down the Ethernet controlled
|
||||
*/
|
||||
void end();
|
||||
|
||||
/**
|
||||
Send an Ethernet frame
|
||||
@param data a pointer to the data to send
|
||||
@@ -99,7 +104,11 @@ public:
|
||||
netif *_netif;
|
||||
protected:
|
||||
static constexpr bool interruptIsPossible() {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static constexpr PinStatus interruptMode() {
|
||||
return LOW;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -154,6 +163,7 @@ private:
|
||||
|
||||
uint8_t _bank;
|
||||
int8_t _cs;
|
||||
int8_t _intr;
|
||||
SPIClass& _spi;
|
||||
|
||||
const uint8_t* _localMac;
|
||||
|
||||
@@ -8,14 +8,21 @@
|
||||
const char* host = "djxmmx.net";
|
||||
const uint16_t port = 17;
|
||||
|
||||
#ifdef ARDUINO_WIZNET_5100S_EVB_PICO
|
||||
// To use Interrupt-driven mode, pass in an SPI object and an IRQ pin like so:
|
||||
Wiznet5100lwIP eth(17, SPI, 21);
|
||||
#else
|
||||
Wiznet5100lwIP eth(1 /* chip select */);
|
||||
#endif
|
||||
|
||||
void setup() {
|
||||
#ifndef ARDUINO_WIZNET_5100S_EVB_PICO
|
||||
// Set up SPI pinout to match your HW
|
||||
SPI.setRX(0);
|
||||
SPI.setCS(1);
|
||||
SPI.setSCK(2);
|
||||
SPI.setTX(3);
|
||||
#endif
|
||||
|
||||
Serial.begin(115200);
|
||||
delay(5000);
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
|
||||
#include <SPI.h>
|
||||
#include "w5100.h"
|
||||
#include <LwipEthernet.h>
|
||||
|
||||
uint8_t Wiznet5100::wizchip_read(uint16_t address) {
|
||||
uint8_t ret;
|
||||
@@ -178,8 +179,7 @@ void Wiznet5100::wizchip_sw_reset() {
|
||||
setSHAR(_mac_address);
|
||||
}
|
||||
|
||||
Wiznet5100::Wiznet5100(int8_t cs, SPIClass& spi, int8_t intr) : _spi(spi), _cs(cs) {
|
||||
(void)intr;
|
||||
Wiznet5100::Wiznet5100(int8_t cs, SPIClass& spi, int8_t intr) : _spi(spi), _cs(cs), _intr(intr) {
|
||||
}
|
||||
|
||||
bool Wiznet5100::begin(const uint8_t* mac_address, netif *net) {
|
||||
@@ -189,13 +189,6 @@ bool Wiznet5100::begin(const uint8_t* mac_address, netif *net) {
|
||||
pinMode(_cs, OUTPUT);
|
||||
wizchip_cs_deselect();
|
||||
|
||||
#if 0
|
||||
_spi.begin();
|
||||
_spi.setClockDivider(SPI_CLOCK_DIV4); // 4 MHz?
|
||||
_spi.setBitOrder(MSBFIRST);
|
||||
_spi.setDataMode(SPI_MODE0);
|
||||
#endif
|
||||
|
||||
wizchip_sw_reset();
|
||||
|
||||
// Set the size of the Rx and Tx buffers
|
||||
@@ -213,6 +206,11 @@ bool Wiznet5100::begin(const uint8_t* mac_address, netif *net) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_intr >= 0) {
|
||||
setSn_IR(0xff); // Clear everything
|
||||
setIMR(IM_IR0);
|
||||
}
|
||||
|
||||
// Success
|
||||
return true;
|
||||
}
|
||||
@@ -245,6 +243,8 @@ uint16_t Wiznet5100::readFrame(uint8_t* buffer, uint16_t bufsize) {
|
||||
}
|
||||
|
||||
uint16_t Wiznet5100::readFrameSize() {
|
||||
setSn_IR(Sn_IR_RECV);
|
||||
|
||||
uint16_t len = getSn_RX_RSR();
|
||||
|
||||
if (len == 0) {
|
||||
@@ -273,25 +273,18 @@ uint16_t Wiznet5100::readFrameData(uint8_t* buffer, uint16_t framesize) {
|
||||
wizchip_recv_data(buffer, framesize);
|
||||
setSn_CR(Sn_CR_RECV);
|
||||
|
||||
#if 1
|
||||
// let lwIP deal with mac address filtering
|
||||
return framesize;
|
||||
#else
|
||||
// W5100 doesn't have any built-in MAC address filtering
|
||||
if ((buffer[0] & 0x01) || memcmp(&buffer[0], _mac_address, 6) == 0) {
|
||||
// Addressed to an Ethernet multicast address or our unicast address
|
||||
return framesize;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
uint16_t Wiznet5100::sendFrame(const uint8_t* buf, uint16_t len) {
|
||||
ethernet_arch_lwip_gpio_mask(); // So we don't fire an IRQ and interrupt the send w/a receive!
|
||||
|
||||
// Wait for space in the transmit buffer
|
||||
while (1) {
|
||||
uint16_t freesize = getSn_TX_FSR();
|
||||
if (getSn_SR() == SOCK_CLOSED) {
|
||||
ethernet_arch_lwip_gpio_unmask();
|
||||
return -1;
|
||||
}
|
||||
if (len <= freesize) {
|
||||
@@ -311,9 +304,11 @@ uint16_t Wiznet5100::sendFrame(const uint8_t* buf, uint16_t len) {
|
||||
} else if (tmp & Sn_IR_TIMEOUT) {
|
||||
setSn_IR(Sn_IR_TIMEOUT);
|
||||
// There was a timeout
|
||||
ethernet_arch_lwip_gpio_unmask();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
ethernet_arch_lwip_gpio_unmask();
|
||||
return len;
|
||||
}
|
||||
|
||||
@@ -101,7 +101,11 @@ public:
|
||||
netif *_netif;
|
||||
protected:
|
||||
static constexpr bool interruptIsPossible() {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static constexpr PinStatus interruptMode() {
|
||||
return LOW;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,6 +148,7 @@ private:
|
||||
|
||||
SPIClass& _spi;
|
||||
int8_t _cs;
|
||||
int8_t _intr;
|
||||
uint8_t _mac_address[6];
|
||||
|
||||
/**
|
||||
@@ -308,6 +313,17 @@ private:
|
||||
MR_IND = 0x01, ///< Indirect Bus Interface mode
|
||||
};
|
||||
|
||||
/** Interrupt Mask register values */
|
||||
enum {
|
||||
IM_IR0 = 0x01, ///< Occurrence of Socket 0 Socket Interrupt Enable
|
||||
IM_IR1 = 0x02, ///< Occurrence of Socket 1 Socket Interrupt Enable
|
||||
IM_IR2 = 0x04, ///< Occurrence of Socket 2 Socket Interrupt Enable
|
||||
IM_IR3 = 0x08, ///< Occurrence of Socket 3 Socket Interrupt Enable
|
||||
IM_IR5 = 0x20, ///< PPPoE Close Enable
|
||||
IM_IR6 = 0x40, ///< Destination unreachable Enable
|
||||
IM_IR7 = 0x80, ///< IP Conflict Enable
|
||||
};
|
||||
|
||||
/** Socket Mode Register values @ref Sn_MR */
|
||||
enum {
|
||||
Sn_MR_CLOSE = 0x00, ///< Unused socket
|
||||
@@ -375,6 +391,24 @@ private:
|
||||
return wizchip_read(MR);
|
||||
}
|
||||
|
||||
/**
|
||||
Set Interrupt Mask Register
|
||||
@param (uint8_t)mr The value to be set.
|
||||
@sa geIMR()
|
||||
*/
|
||||
inline void setIMR(uint8_t mode) {
|
||||
wizchip_write(IMR, mode);
|
||||
}
|
||||
|
||||
/**
|
||||
Get Mode Register
|
||||
@return uint8_t. The value of Mode register.
|
||||
@sa setIMR()
|
||||
*/
|
||||
inline uint8_t getIMR() {
|
||||
return wizchip_read(IMR);
|
||||
}
|
||||
|
||||
/**
|
||||
Set local MAC address
|
||||
@param (uint8_t*)shar Pointer variable to set local MAC address. It should be allocated 6
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
|
||||
#include <SPI.h>
|
||||
#include "w5500.h"
|
||||
#include <LwipEthernet.h>
|
||||
|
||||
uint8_t Wiznet5500::wizchip_read(uint8_t block, uint16_t address) {
|
||||
uint8_t ret;
|
||||
@@ -238,8 +239,7 @@ int8_t Wiznet5500::wizphy_setphypmode(uint8_t pmode) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
Wiznet5500::Wiznet5500(int8_t cs, SPIClass& spi, int8_t intr) : _spi(spi), _cs(cs) {
|
||||
(void)intr;
|
||||
Wiznet5500::Wiznet5500(int8_t cs, SPIClass& spi, int8_t intr) : _spi(spi), _cs(cs), _intr(intr) {
|
||||
}
|
||||
|
||||
bool Wiznet5500::begin(const uint8_t* mac_address, netif *net) {
|
||||
@@ -249,13 +249,6 @@ bool Wiznet5500::begin(const uint8_t* mac_address, netif *net) {
|
||||
pinMode(_cs, OUTPUT);
|
||||
wizchip_cs_deselect();
|
||||
|
||||
#if 0
|
||||
_spi.begin();
|
||||
_spi.setClockDivider(SPI_CLOCK_DIV4); // 4 MHz?
|
||||
_spi.setBitOrder(MSBFIRST);
|
||||
_spi.setDataMode(SPI_MODE0);
|
||||
#endif
|
||||
|
||||
wizchip_sw_reset();
|
||||
|
||||
// Use the full 16Kb of RAM for Socket 0
|
||||
@@ -273,6 +266,11 @@ bool Wiznet5500::begin(const uint8_t* mac_address, netif *net) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_intr >= 0) {
|
||||
setSn_IR(0xff); // Clear everything
|
||||
setSIMR(1);
|
||||
}
|
||||
|
||||
// Success
|
||||
return true;
|
||||
}
|
||||
@@ -305,6 +303,8 @@ uint16_t Wiznet5500::readFrame(uint8_t* buffer, uint16_t bufsize) {
|
||||
}
|
||||
|
||||
uint16_t Wiznet5500::readFrameSize() {
|
||||
setSn_IR(Sn_IR_RECV);
|
||||
|
||||
uint16_t len = getSn_RX_RSR();
|
||||
|
||||
if (len == 0) {
|
||||
@@ -333,26 +333,18 @@ uint16_t Wiznet5500::readFrameData(uint8_t* buffer, uint16_t framesize) {
|
||||
wizchip_recv_data(buffer, framesize);
|
||||
setSn_CR(Sn_CR_RECV);
|
||||
|
||||
#if 1
|
||||
// let lwIP deal with mac address filtering
|
||||
return framesize;
|
||||
#else
|
||||
// Had problems with W5500 MAC address filtering (the Sn_MR_MFEN option)
|
||||
// Do it in software instead:
|
||||
if ((buffer[0] & 0x01) || memcmp(&buffer[0], _mac_address, 6) == 0) {
|
||||
// Addressed to an Ethernet multicast address or our unicast address
|
||||
return framesize;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
uint16_t Wiznet5500::sendFrame(const uint8_t* buf, uint16_t len) {
|
||||
ethernet_arch_lwip_gpio_mask(); // So we don't fire an IRQ and interrupt the send w/a receive!
|
||||
|
||||
// Wait for space in the transmit buffer
|
||||
while (1) {
|
||||
uint16_t freesize = getSn_TX_FSR();
|
||||
if (getSn_SR() == SOCK_CLOSED) {
|
||||
ethernet_arch_lwip_gpio_unmask();
|
||||
return -1;
|
||||
}
|
||||
if (len <= freesize) {
|
||||
@@ -372,9 +364,11 @@ uint16_t Wiznet5500::sendFrame(const uint8_t* buf, uint16_t len) {
|
||||
} else if (tmp & Sn_IR_TIMEOUT) {
|
||||
setSn_IR(Sn_IR_TIMEOUT);
|
||||
// There was a timeout
|
||||
ethernet_arch_lwip_gpio_unmask();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
ethernet_arch_lwip_gpio_unmask();
|
||||
return len;
|
||||
}
|
||||
|
||||
@@ -84,9 +84,11 @@ public:
|
||||
@return true when physical link is up
|
||||
*/
|
||||
bool isLinked() {
|
||||
ethernet_arch_lwip_gpio_mask();
|
||||
ethernet_arch_lwip_begin();
|
||||
auto ret = wizphy_getphylink() == PHY_LINK_ON;
|
||||
ethernet_arch_lwip_end();
|
||||
ethernet_arch_lwip_gpio_unmask();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -104,7 +106,11 @@ public:
|
||||
|
||||
protected:
|
||||
static constexpr bool interruptIsPossible() {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static constexpr PinStatus interruptMode() {
|
||||
return LOW;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,6 +158,7 @@ private:
|
||||
|
||||
SPIClass& _spi;
|
||||
int8_t _cs;
|
||||
int8_t _intr;
|
||||
uint8_t _mac_address[6];
|
||||
|
||||
/**
|
||||
@@ -319,7 +326,7 @@ private:
|
||||
IR = 0x0015, ///< Interrupt Register (R/W)
|
||||
_IMR_ = 0x0016, ///< Interrupt mask register (R/W)
|
||||
SIR = 0x0017, ///< Socket Interrupt Register (R/W)
|
||||
SIMR = 0x0018, ///< Socket Interrupt Mask Register (R/W)
|
||||
_SIMR_ = 0x0018, ///< Socket Interrupt Mask Register (R/W)
|
||||
_RTR_ = 0x0019, ///< Timeout register address (1 is 100us) (R/W)
|
||||
_RCR_ = 0x001B, ///< Retry count register (R/W)
|
||||
UIPR = 0x0028, ///< Unreachable IP register address in UDP mode (R)
|
||||
@@ -520,6 +527,24 @@ private:
|
||||
return wizchip_read(BlockSelectCReg, IR) & 0xF0;
|
||||
}
|
||||
|
||||
/**
|
||||
Set @ref SIR register
|
||||
@param (uint8_t)ir Value to set @ref SIR register.
|
||||
@sa getSIR()
|
||||
*/
|
||||
inline void setSIR(uint8_t ir) {
|
||||
wizchip_write(BlockSelectCReg, SIR, ir);
|
||||
}
|
||||
|
||||
/**
|
||||
Get @ref SIR register
|
||||
@return uint8_t. Value of @ref SIR register.
|
||||
@sa setSIR()
|
||||
*/
|
||||
inline uint8_t getSIR() {
|
||||
return wizchip_read(BlockSelectCReg, SIR);
|
||||
}
|
||||
|
||||
/**
|
||||
Set @ref _IMR_ register
|
||||
@param (uint8_t)imr Value to set @ref _IMR_ register.
|
||||
@@ -538,6 +563,24 @@ private:
|
||||
return wizchip_read(BlockSelectCReg, _IMR_);
|
||||
}
|
||||
|
||||
/**
|
||||
Set @ref _SIMR_ register
|
||||
@param (uint8_t)imr Value to set @ref _SIMR_ register.
|
||||
@sa getIMR()
|
||||
*/
|
||||
inline void setSIMR(uint8_t imr) {
|
||||
wizchip_write(BlockSelectCReg, _SIMR_, imr);
|
||||
}
|
||||
|
||||
/**
|
||||
Get @ref _SIMR_ register
|
||||
@return uint8_t. Value of @ref _SIMR_ register.
|
||||
@sa setSIMR()
|
||||
*/
|
||||
inline uint8_t getSIMR() {
|
||||
return wizchip_read(BlockSelectCReg, _SIMR_);
|
||||
}
|
||||
|
||||
/**
|
||||
Set @ref PHYCFGR register
|
||||
@param (uint8_t)phycfgr Value to set @ref PHYCFGR register.
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "framework-arduinopico",
|
||||
"version": "1.30603.0",
|
||||
"version": "1.30800.0",
|
||||
"description": "Arduino Wiring-based Framework (RPi Pico RP2040)",
|
||||
"keywords": [
|
||||
"framework",
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
"name": "Cytron Maker Pi RP2040"
|
||||
},
|
||||
{
|
||||
"name": "Cytron Maker UNO RP2040"
|
||||
"name": "Cytron Maker Uno RP2040"
|
||||
},
|
||||
{
|
||||
"name": "DatanoiseTV PicoADK"
|
||||
@@ -101,6 +101,9 @@
|
||||
{
|
||||
"name": "DFRobot Beetle RP2040"
|
||||
},
|
||||
{
|
||||
"name": "L'atelier d'Arnoz DudesCab"
|
||||
},
|
||||
{
|
||||
"name": "ElectronicCats HunterCat NFC RP2040"
|
||||
},
|
||||
@@ -137,6 +140,9 @@
|
||||
{
|
||||
"name": "iLabs Challenger 2040 UWB"
|
||||
},
|
||||
{
|
||||
"name": "iLabs Connectivity 2040 LTE/WiFi/BLE"
|
||||
},
|
||||
{
|
||||
"name": "iLabs RPICO32"
|
||||
},
|
||||
@@ -152,6 +158,12 @@
|
||||
{
|
||||
"name": "nullbits Bit-C PRO"
|
||||
},
|
||||
{
|
||||
"name": "Olimex RP2040-Pico30 2MB"
|
||||
},
|
||||
{
|
||||
"name": "Olimex RP2040-Pico30 16MB"
|
||||
},
|
||||
{
|
||||
"name": "Pimoroni PGA2040"
|
||||
},
|
||||
@@ -179,6 +191,9 @@
|
||||
{
|
||||
"name": "Solder Party RP2040 Stamp"
|
||||
},
|
||||
{
|
||||
"name": "SparkFun MicroMod RP2040"
|
||||
},
|
||||
{
|
||||
"name": "SparkFun ProMicro RP2040"
|
||||
},
|
||||
@@ -206,6 +221,12 @@
|
||||
{
|
||||
"name": "Waveshare RP2040 One"
|
||||
},
|
||||
{
|
||||
"name": "Waveshare RP2040 Matrix"
|
||||
},
|
||||
{
|
||||
"name": "Waveshare RP2040 PiZero"
|
||||
},
|
||||
{
|
||||
"name": "Waveshare RP2040 Plus 4MB"
|
||||
},
|
||||
@@ -234,22 +255,22 @@
|
||||
"toolsDependencies": [
|
||||
{
|
||||
"packager": "rp2040",
|
||||
"version": "2.1.0-a-d3d2e6b",
|
||||
"version": "2.2.0-d04e724",
|
||||
"name": "pqt-gcc"
|
||||
},
|
||||
{
|
||||
"packager": "rp2040",
|
||||
"version": "2.1.0-a-d3d2e6b",
|
||||
"version": "2.2.0-d04e724",
|
||||
"name": "pqt-mklittlefs"
|
||||
},
|
||||
{
|
||||
"packager": "rp2040",
|
||||
"version": "2.1.0-a-d3d2e6b",
|
||||
"version": "2.2.0-d04e724",
|
||||
"name": "pqt-elf2uf2"
|
||||
},
|
||||
{
|
||||
"packager": "rp2040",
|
||||
"version": "2.1.0-a-d3d2e6b",
|
||||
"version": "2.2.0-d04e724",
|
||||
"name": "pqt-pioasm"
|
||||
},
|
||||
{
|
||||
@@ -259,12 +280,12 @@
|
||||
},
|
||||
{
|
||||
"packager": "rp2040",
|
||||
"version": "2.1.0-a-d3d2e6b",
|
||||
"version": "2.2.0-d04e724",
|
||||
"name": "pqt-openocd"
|
||||
},
|
||||
{
|
||||
"packager": "rp2040",
|
||||
"version": "2.1.0-a-d3d2e6b",
|
||||
"version": "2.2.0-d04e724",
|
||||
"name": "pqt-picotool"
|
||||
}
|
||||
],
|
||||
@@ -275,112 +296,126 @@
|
||||
],
|
||||
"tools": [
|
||||
{
|
||||
"version": "2.1.0-a-d3d2e6b",
|
||||
"version": "2.2.0-d04e724",
|
||||
"name": "pqt-picotool",
|
||||
"systems": [
|
||||
{
|
||||
"host": "arm64-apple-darwin",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/picotool.macosarm.tar.gz",
|
||||
"archiveFileName": "picotool.macosarm.tar.gz",
|
||||
"checksum": "SHA-256:6b9d28dee6f3c67ab705ff1bc9bd96de3fcb7f1d73753a0e802999b408d39011",
|
||||
"size": "174728"
|
||||
},
|
||||
{
|
||||
"host": "aarch64-linux-gnu",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/aarch64-linux-gnu.picotool-f6fe6b7.230911.tar.gz",
|
||||
"archiveFileName": "aarch64-linux-gnu.picotool-f6fe6b7.230911.tar.gz",
|
||||
"checksum": "SHA-256:95192ab12bbe99eb64b7c50c883e971b306e1fc0fc43738ff2a6ffaf8e684325",
|
||||
"size": "172728"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/aarch64-linux-gnu.picotool-f6fe6b7.240125.tar.gz",
|
||||
"archiveFileName": "aarch64-linux-gnu.picotool-f6fe6b7.240125.tar.gz",
|
||||
"checksum": "SHA-256:3d3aec025f74e146d9d27b3a64604fa271ac6a25dc8bf61855035c75829f55c0",
|
||||
"size": "179609"
|
||||
},
|
||||
{
|
||||
"host": "arm-linux-gnueabihf",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/arm-linux-gnueabihf.picotool-f6fe6b7.230911.tar.gz",
|
||||
"archiveFileName": "arm-linux-gnueabihf.picotool-f6fe6b7.230911.tar.gz",
|
||||
"checksum": "SHA-256:734b30df29b884de711bc9eb1859a44275c02c7d2c067259070a5abadb2e4dd1",
|
||||
"size": "153317"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/arm-linux-gnueabihf.picotool-f6fe6b7.240125.tar.gz",
|
||||
"archiveFileName": "arm-linux-gnueabihf.picotool-f6fe6b7.240125.tar.gz",
|
||||
"checksum": "SHA-256:d2ea134a0dfea2a5d0ab4bc206f1a823e9bff632218e5476b56acbb3f4c99837",
|
||||
"size": "168619"
|
||||
},
|
||||
{
|
||||
"host": "i686-pc-linux-gnu",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/i686-linux-gnu.picotool-f6fe6b7.230911.tar.gz",
|
||||
"archiveFileName": "i686-linux-gnu.picotool-f6fe6b7.230911.tar.gz",
|
||||
"checksum": "SHA-256:f8cceebdf270beba3d5282ec30911bc8cd1c2afc4733772fd2b32ba8c62d87a8",
|
||||
"size": "184349"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/i686-linux-gnu.picotool-f6fe6b7.240125.tar.gz",
|
||||
"archiveFileName": "i686-linux-gnu.picotool-f6fe6b7.240125.tar.gz",
|
||||
"checksum": "SHA-256:56ebf53f6ce0748faca2fc06c05bad9cb8bfcb429f5c4336e56738f344b99e38",
|
||||
"size": "202882"
|
||||
},
|
||||
{
|
||||
"host": "i686-mingw32",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/i686-w64-mingw32.picotool1-f6fe6b7.230911.zip",
|
||||
"archiveFileName": "i686-w64-mingw32.picotool1-f6fe6b7.230911.zip",
|
||||
"checksum": "SHA-256:5c8fc5a9a9a6f4cc49a84bcf4cde6f4188d64008d11754bda4da48affca39f13",
|
||||
"size": "291812"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/i686-w64-mingw32.picotool-f6fe6b7.240125a.zip",
|
||||
"archiveFileName": "i686-w64-mingw32.picotool-f6fe6b7.240125a.zip",
|
||||
"checksum": "SHA-256:75a6672f56972bdc95cd6422a4709c372cd84e08ac07eefd8b1c2842b8617d99",
|
||||
"size": "291095"
|
||||
},
|
||||
{
|
||||
"host": "x86_64-apple-darwin",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/x86_64-apple-darwin15.picotool2-f6fe6b7.230911.tar.gz",
|
||||
"archiveFileName": "x86_64-apple-darwin15.picotool2-f6fe6b7.230911.tar.gz",
|
||||
"checksum": "SHA-256:b17a8a53737084f046ae27dc082f3732b39f273d8cd61a55ffaa8a9737999e5d",
|
||||
"size": "166362"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/x86_64-apple-darwin20.4.picotool-f6fe6b7.240125.tar.gz",
|
||||
"archiveFileName": "x86_64-apple-darwin20.4.picotool-f6fe6b7.240125.tar.gz",
|
||||
"checksum": "SHA-256:b04fccd0416cfa753d1e2dd431b7bfc24a971819eab255eaec2a3e7d76c5966f",
|
||||
"size": "167079"
|
||||
},
|
||||
{
|
||||
"host": "x86_64-pc-linux-gnu",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/x86_64-linux-gnu.picotool-f6fe6b7.230911.tar.gz",
|
||||
"archiveFileName": "x86_64-linux-gnu.picotool-f6fe6b7.230911.tar.gz",
|
||||
"checksum": "SHA-256:1282e7ff7985537cac549eaa8b1e4107f5e27f8a1b99b56c5b239a6e1545e6b0",
|
||||
"size": "131937"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/x86_64-linux-gnu.picotool-f6fe6b7.240125.tar.gz",
|
||||
"archiveFileName": "x86_64-linux-gnu.picotool-f6fe6b7.240125.tar.gz",
|
||||
"checksum": "SHA-256:ba7c3a168fe7813de9645f64f22fbdbf81841412550338df02c0e20701caee66",
|
||||
"size": "192471"
|
||||
},
|
||||
{
|
||||
"host": "x86_64-mingw32",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/x86_64-w64-mingw32.picotool1-f6fe6b7.230911.zip",
|
||||
"archiveFileName": "x86_64-w64-mingw32.picotool1-f6fe6b7.230911.zip",
|
||||
"checksum": "SHA-256:1a0cbf35adcc1fa696af8a97ea37d9f413fb4de152713b8f97f1d0ca393a5593",
|
||||
"size": "277139"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/x86_64-w64-mingw32.picotool-f6fe6b7.240125a.zip",
|
||||
"archiveFileName": "x86_64-w64-mingw32.picotool-f6fe6b7.240125a.zip",
|
||||
"checksum": "SHA-256:79a68e3d3d080cacfafc9c1546a3675ce5c7f858e6e85c690584251e63a2bee3",
|
||||
"size": "276468"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "2.1.0-a-d3d2e6b",
|
||||
"version": "2.2.0-d04e724",
|
||||
"name": "pqt-openocd",
|
||||
"systems": [
|
||||
{
|
||||
"host": "arm64-apple-darwin",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/openocd.macosarm.tar.gz",
|
||||
"archiveFileName": "openocd.macosarm.tar.gz",
|
||||
"checksum": "SHA-256:585128f38286c0026f0c3d3d14aab098282ef0958882226907fefb1824ddd350",
|
||||
"size": "1877283"
|
||||
},
|
||||
{
|
||||
"host": "aarch64-linux-gnu",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/aarch64-linux-gnu.openocd-4d87f6dca.230911.tar.gz",
|
||||
"archiveFileName": "aarch64-linux-gnu.openocd-4d87f6dca.230911.tar.gz",
|
||||
"checksum": "SHA-256:ca0e58739a5af5d4726668e6613fe9ec21c04d28eb857a640638ca94860b9229",
|
||||
"size": "6440041"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/aarch64-linux-gnu.openocd-4d87f6dca.240125.tar.gz",
|
||||
"archiveFileName": "aarch64-linux-gnu.openocd-4d87f6dca.240125.tar.gz",
|
||||
"checksum": "SHA-256:470bedcfc7e26006e3789439b7c3806e0ee4e715e28330c4e3a48a19c6efbefa",
|
||||
"size": "7439489"
|
||||
},
|
||||
{
|
||||
"host": "arm-linux-gnueabihf",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/arm-linux-gnueabihf.openocd-4d87f6dca.230911.tar.gz",
|
||||
"archiveFileName": "arm-linux-gnueabihf.openocd-4d87f6dca.230911.tar.gz",
|
||||
"checksum": "SHA-256:0acb02f16080fdd0d1cb5e89708a9df954d2ba97a6fc7e963bbc8e27ff92c786",
|
||||
"size": "6156659"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/arm-linux-gnueabihf.openocd-4d87f6dca.240125.tar.gz",
|
||||
"archiveFileName": "arm-linux-gnueabihf.openocd-4d87f6dca.240125.tar.gz",
|
||||
"checksum": "SHA-256:d086bfc425829984d9257e5629277ae8eb4dff780ef3e92d292b132764246ed2",
|
||||
"size": "7256877"
|
||||
},
|
||||
{
|
||||
"host": "i686-pc-linux-gnu",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/i686-linux-gnu.openocd-4d87f6dca.230911.tar.gz",
|
||||
"archiveFileName": "i686-linux-gnu.openocd-4d87f6dca.230911.tar.gz",
|
||||
"checksum": "SHA-256:a2db908d408949dea7785e062eeb1226465378590e54ae3561d31cb859ef2b7a",
|
||||
"size": "5960505"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/i686-linux-gnu.openocd-4d87f6dca.240125.tar.gz",
|
||||
"archiveFileName": "i686-linux-gnu.openocd-4d87f6dca.240125.tar.gz",
|
||||
"checksum": "SHA-256:06e97a31d77ed690767eaf579f7be8e295dec4eecbbe504650726631d94379e6",
|
||||
"size": "6978839"
|
||||
},
|
||||
{
|
||||
"host": "i686-mingw32",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/i686-w64-mingw32.openocd-4d87f6dca.230911.zip",
|
||||
"archiveFileName": "i686-w64-mingw32.openocd-4d87f6dca.230911.zip",
|
||||
"checksum": "SHA-256:2205a5746f869170448ee9fda68aa8388f3cb030a5e2a3847c502840f56ad33c",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/i686-w64-mingw32.openocd-4d87f6dca.240125.zip",
|
||||
"archiveFileName": "i686-w64-mingw32.openocd-4d87f6dca.240125.zip",
|
||||
"checksum": "SHA-256:0151d237bb7d4418130346d9296daee2a903bad93ca0fd676db2e0ecc3742b4c",
|
||||
"size": "2468166"
|
||||
},
|
||||
{
|
||||
"host": "x86_64-apple-darwin",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/x86_64-apple-darwin15.openocd2-4d87f6dca.230911.tar.gz",
|
||||
"archiveFileName": "x86_64-apple-darwin15.openocd2-4d87f6dca.230911.tar.gz",
|
||||
"checksum": "SHA-256:18414d66c774538364e566169917d0f162f8c25fb553e5f32d81a1939fba7f1a",
|
||||
"size": "3060420"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/x86_64-apple-darwin20.4.openocd-4d87f6dca.240125.tar.gz",
|
||||
"archiveFileName": "x86_64-apple-darwin20.4.openocd-4d87f6dca.240125.tar.gz",
|
||||
"checksum": "SHA-256:c37f3f1222b2b5614d09a08ed820a27f79be78daa699884abfa26da9f96b2126",
|
||||
"size": "3083387"
|
||||
},
|
||||
{
|
||||
"host": "x86_64-pc-linux-gnu",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/x86_64-linux-gnu.openocd-4d87f6dca.230911.tar.gz",
|
||||
"archiveFileName": "x86_64-linux-gnu.openocd-4d87f6dca.230911.tar.gz",
|
||||
"checksum": "SHA-256:327f80305ab5d02162bc5b88b1bdf05a41bfe6717b8a27153d62cad60f88a19c",
|
||||
"size": "6355683"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/x86_64-linux-gnu.openocd-4d87f6dca.240125.tar.gz",
|
||||
"archiveFileName": "x86_64-linux-gnu.openocd-4d87f6dca.240125.tar.gz",
|
||||
"checksum": "SHA-256:cf7163e0c3981cd1025a3eba64dda1ea02cc8042f340ae2740c89c1048b55f20",
|
||||
"size": "7454235"
|
||||
},
|
||||
{
|
||||
"host": "x86_64-mingw32",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/x86_64-w64-mingw32.openocd-4d87f6dca.230911.zip",
|
||||
"archiveFileName": "x86_64-w64-mingw32.openocd-4d87f6dca.230911.zip",
|
||||
"checksum": "SHA-256:99e6b543fd648f033299b6a49e1895e75c720386b1d31d1574fab973689937f5",
|
||||
"size": "2412179"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/x86_64-w64-mingw32.openocd-4d87f6dca.240125.zip",
|
||||
"archiveFileName": "x86_64-w64-mingw32.openocd-4d87f6dca.240125.zip",
|
||||
"checksum": "SHA-256:a15ba6f4a8054ca787c5ec47ce9a866b033667bbbf3dcbd0941a55539b2fbe37",
|
||||
"size": "2412178"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -437,6 +472,13 @@
|
||||
"checksum": "SHA-256:01a5bf1fa264c6f04cfaadf4c6e9f6caaacb6833ef40104dfbe953fcdb9bca1c",
|
||||
"size": "25494144"
|
||||
},
|
||||
{
|
||||
"host": "arm64-apple-darwin",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/python3.18-portable-darwin_arm64.tar.gz",
|
||||
"archiveFileName": "python3.18-portable-darwin_arm64.tar.gz",
|
||||
"checksum": "SHA-256:ac6ee694191ac4db770e147429a7606b50063110db9ccbaf46e0e5ff8f7dcd20",
|
||||
"size": "90294119"
|
||||
},
|
||||
{
|
||||
"host": "x86_64-pc-linux-gnu",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.0.1-base/python3-via-env.tar.gz",
|
||||
@@ -447,222 +489,250 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "2.1.0-a-d3d2e6b",
|
||||
"version": "2.2.0-d04e724",
|
||||
"name": "pqt-gcc",
|
||||
"systems": [
|
||||
{
|
||||
"host": "arm64-apple-darwin",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/aarch64-apple-darwin20.4.arm-none-eabi-d04e724.240127.tar.gz",
|
||||
"archiveFileName": "aarch64-apple-darwin20.4.arm-none-eabi-d04e724.240127.tar.gz",
|
||||
"checksum": "SHA-256:f70431e62a1d64b43d8730911be6b6f18ece3b91a216ce6c40d5318ad263756f",
|
||||
"size": "86285430"
|
||||
},
|
||||
{
|
||||
"host": "aarch64-linux-gnu",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/aarch64-linux-gnu.arm-none-eabi-d3d2e6b.230911.tar.gz",
|
||||
"archiveFileName": "aarch64-linux-gnu.arm-none-eabi-d3d2e6b.230911.tar.gz",
|
||||
"checksum": "SHA-256:248690d021b9da120ecf459972b35aba03b051b6cae6c7215fa7450c5e5c1ea4",
|
||||
"size": "92005838"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/aarch64-linux-gnu.arm-none-eabi-d04e724.240125.tar.gz",
|
||||
"archiveFileName": "aarch64-linux-gnu.arm-none-eabi-d04e724.240125.tar.gz",
|
||||
"checksum": "SHA-256:752be9aebf0f040794232a331bd6fd17a8843f7ebe819c73e728d1a9fe8de3c3",
|
||||
"size": "93501390"
|
||||
},
|
||||
{
|
||||
"host": "arm-linux-gnueabihf",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/arm-linux-gnueabihf.arm-none-eabi-d3d2e6b.230911.tar.gz",
|
||||
"archiveFileName": "arm-linux-gnueabihf.arm-none-eabi-d3d2e6b.230911.tar.gz",
|
||||
"checksum": "SHA-256:fea1f309249344a6ff09e965e2e4e35aa6c51dbf46fb2cbd18c8efe37f7b6974",
|
||||
"size": "85920067"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/arm-linux-gnueabihf.arm-none-eabi-d04e724.240125.tar.gz",
|
||||
"archiveFileName": "arm-linux-gnueabihf.arm-none-eabi-d04e724.240125.tar.gz",
|
||||
"checksum": "SHA-256:494dc88980d0f1e2cc0ac10f0bd3adb5d6964cc31b43f44a14b8a167781a0316",
|
||||
"size": "87330830"
|
||||
},
|
||||
{
|
||||
"host": "i686-pc-linux-gnu",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/i686-linux-gnu.arm-none-eabi-d3d2e6b.230911.tar.gz",
|
||||
"archiveFileName": "i686-linux-gnu.arm-none-eabi-d3d2e6b.230911.tar.gz",
|
||||
"checksum": "SHA-256:01f0cde4760ddfe1614f30c42b50153d392971edaec9a356bdb525c472441b44",
|
||||
"size": "94592210"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/i686-linux-gnu.arm-none-eabi-d04e724.240125.tar.gz",
|
||||
"archiveFileName": "i686-linux-gnu.arm-none-eabi-d04e724.240125.tar.gz",
|
||||
"checksum": "SHA-256:b00b8e138886c7957b28615762285c70b8ac84172c32b189a673bc33c2f29e2d",
|
||||
"size": "96150883"
|
||||
},
|
||||
{
|
||||
"host": "i686-mingw32",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/i686-w64-mingw32.arm-none-eabi-d3d2e6b.230911-v2.zip",
|
||||
"archiveFileName": "i686-w64-mingw32.arm-none-eabi-d3d2e6b.230911-v2.zip",
|
||||
"checksum": "SHA-256:cbda04d0327c963504c1c71bfbfd2f6fb27ca964e2004704108939a7716cb7a4",
|
||||
"size": "99150816"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/i686-w64-mingw32.arm-none-eabi-d04e724.240125.zip",
|
||||
"archiveFileName": "i686-w64-mingw32.arm-none-eabi-d04e724.240125.zip",
|
||||
"checksum": "SHA-256:f9b35511c2385b9351f70d5503b1e7f86ab4e47035402749ea7220175c9bf7fa",
|
||||
"size": "102603587"
|
||||
},
|
||||
{
|
||||
"host": "x86_64-apple-darwin",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/x86_64-apple-darwin15.arm-none-eabi-d3d2e6b.230911.tar.gz",
|
||||
"archiveFileName": "x86_64-apple-darwin15.arm-none-eabi-d3d2e6b.230911.tar.gz",
|
||||
"checksum": "SHA-256:7e8a6fb52b947850fcb10f5c6bf7e26d08edab060ac42237d3d7739f6b226400",
|
||||
"size": "97134440"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/x86_64-apple-darwin20.4.arm-none-eabi-d04e724.240125.tar.gz",
|
||||
"archiveFileName": "x86_64-apple-darwin20.4.arm-none-eabi-d04e724.240125.tar.gz",
|
||||
"checksum": "SHA-256:a2d9ea24986973c31082b35ada0fe9d1577167e6a68a908b69aa6d99490b2499",
|
||||
"size": "97543047"
|
||||
},
|
||||
{
|
||||
"host": "x86_64-pc-linux-gnu",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/x86_64-linux-gnu.arm-none-eabi-d3d2e6b.230911.tar.gz",
|
||||
"archiveFileName": "x86_64-linux-gnu.arm-none-eabi-d3d2e6b.230911.tar.gz",
|
||||
"checksum": "SHA-256:4bbf08c2c529e76763cf29be7580f55f4932d691cb0090e41e9d7f22ede8612d",
|
||||
"size": "94544555"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/x86_64-linux-gnu.arm-none-eabi-028e019.240125.tar.gz",
|
||||
"archiveFileName": "x86_64-linux-gnu.arm-none-eabi-028e019.240125.tar.gz",
|
||||
"checksum": "SHA-256:447951503effc0238cdc83b23b5253909b4b9d9f1175f4cc6c29169927fa0964",
|
||||
"size": "96301885"
|
||||
},
|
||||
{
|
||||
"host": "x86_64-mingw32",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/x86_64-w64-mingw32.arm-none-eabi-d3d2e6b.230911-v2.zip",
|
||||
"archiveFileName": "x86_64-w64-mingw32.arm-none-eabi-d3d2e6b.230911-v2.zip",
|
||||
"checksum": "SHA-256:97dda385e4c20a228bfe59b8d61ebb23f2f419e9ebd4d04fb57980a6a1e6edd2",
|
||||
"size": "102620481"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/x86_64-w64-mingw32.arm-none-eabi-d04e724.240125.zip",
|
||||
"archiveFileName": "x86_64-w64-mingw32.arm-none-eabi-d04e724.240125.zip",
|
||||
"checksum": "SHA-256:f8f79b3da6b4997dc30c91689e6aeb126a37eb034b51c9f9356b382f1982c075",
|
||||
"size": "106485317"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "2.1.0-a-d3d2e6b",
|
||||
"version": "2.2.0-d04e724",
|
||||
"name": "pqt-elf2uf2",
|
||||
"systems": [
|
||||
{
|
||||
"host": "arm64-apple-darwin",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/aarch64-apple-darwin20.4.elf2uf2-6a7db34.240127.tar.gz",
|
||||
"archiveFileName": "aarch64-apple-darwin20.4.elf2uf2-6a7db34.240127.tar.gz",
|
||||
"checksum": "SHA-256:3fb12aa0d39bb03520a46ff5e3d0dbd0eb0df31843056f5dcd8b6fffa1d7ff86",
|
||||
"size": "30084"
|
||||
},
|
||||
{
|
||||
"host": "aarch64-linux-gnu",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/aarch64-linux-gnu.elf2uf2-6a7db34.230911.tar.gz",
|
||||
"archiveFileName": "aarch64-linux-gnu.elf2uf2-6a7db34.230911.tar.gz",
|
||||
"checksum": "SHA-256:5eed824fdd1c529295c1fd3945017f0e9baed8250055749651aeee72c3e11ae5",
|
||||
"size": "83825"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/aarch64-linux-gnu.elf2uf2-6a7db34.240125.tar.gz",
|
||||
"archiveFileName": "aarch64-linux-gnu.elf2uf2-6a7db34.240125.tar.gz",
|
||||
"checksum": "SHA-256:b8ab83714f963dd42164ff1093a02822d63a2825fc04ac395f5ce9c98224fc6a",
|
||||
"size": "85433"
|
||||
},
|
||||
{
|
||||
"host": "arm-linux-gnueabihf",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/arm-linux-gnueabihf.elf2uf2-6a7db34.230911.tar.gz",
|
||||
"archiveFileName": "arm-linux-gnueabihf.elf2uf2-6a7db34.230911.tar.gz",
|
||||
"checksum": "SHA-256:137792ded226d15fc7ce9041b1322cdc895d8423328cf08fbe0f3eb8f63a98fe",
|
||||
"size": "56866"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/arm-linux-gnueabihf.elf2uf2-6a7db34.240125.tar.gz",
|
||||
"archiveFileName": "arm-linux-gnueabihf.elf2uf2-6a7db34.240125.tar.gz",
|
||||
"checksum": "SHA-256:027de6742745bd27bb79e98563da95fc72f7aad28af19d2893e40b14602b3e99",
|
||||
"size": "59530"
|
||||
},
|
||||
{
|
||||
"host": "i686-pc-linux-gnu",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/i686-linux-gnu.elf2uf2-6a7db34.230911.tar.gz",
|
||||
"archiveFileName": "i686-linux-gnu.elf2uf2-6a7db34.230911.tar.gz",
|
||||
"checksum": "SHA-256:7956e5365d647f1c810c1ac3c6786f8b81e7b1b89d90c2edc495448dbd7b82b9",
|
||||
"size": "92453"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/i686-linux-gnu.elf2uf2-6a7db34.240125.tar.gz",
|
||||
"archiveFileName": "i686-linux-gnu.elf2uf2-6a7db34.240125.tar.gz",
|
||||
"checksum": "SHA-256:b8ab8cf6fe09a6ce0c30861ded3e88c785cec06f1b3ccb888522ba6da8fc3220",
|
||||
"size": "96835"
|
||||
},
|
||||
{
|
||||
"host": "i686-mingw32",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/i686-w64-mingw32.elf2uf2-6a7db34.230911.zip",
|
||||
"archiveFileName": "i686-w64-mingw32.elf2uf2-6a7db34.230911.zip",
|
||||
"checksum": "SHA-256:74e9be8f520b2752010978f4f140671da95d7faa385d4cca5aae06d719674ae0",
|
||||
"size": "72746"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/i686-w64-mingw32.elf2uf2-6a7db34.240125.zip",
|
||||
"archiveFileName": "i686-w64-mingw32.elf2uf2-6a7db34.240125.zip",
|
||||
"checksum": "SHA-256:80c2b269d50475f0bcc518b3cc08d3ee639470603912bc17fbcd695efb5ac825",
|
||||
"size": "73951"
|
||||
},
|
||||
{
|
||||
"host": "x86_64-apple-darwin",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/x86_64-apple-darwin15.elf2uf2-6a7db34.230911.tar.gz",
|
||||
"archiveFileName": "x86_64-apple-darwin15.elf2uf2-6a7db34.230911.tar.gz",
|
||||
"checksum": "SHA-256:29b23e904fab7f373a082a09fe197555f79372aeef1e4d4cdef8ac8860476655",
|
||||
"size": "105035"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/x86_64-apple-darwin20.4.elf2uf2-6a7db34.240125.tar.gz",
|
||||
"archiveFileName": "x86_64-apple-darwin20.4.elf2uf2-6a7db34.240125.tar.gz",
|
||||
"checksum": "SHA-256:3d3e47d70981b852e553e1250b90c5442320232952f18d4a74ca87ff14a55ea7",
|
||||
"size": "106528"
|
||||
},
|
||||
{
|
||||
"host": "x86_64-pc-linux-gnu",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/x86_64-linux-gnu.elf2uf2-6a7db34.230911.tar.gz",
|
||||
"archiveFileName": "x86_64-linux-gnu.elf2uf2-6a7db34.230911.tar.gz",
|
||||
"checksum": "SHA-256:ff48939331d44d51418e55e7ca2cf3e63a746e2617d307ac8000422c05914ee4",
|
||||
"size": "83343"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/x86_64-linux-gnu.elf2uf2-6a7db34.240125.tar.gz",
|
||||
"archiveFileName": "x86_64-linux-gnu.elf2uf2-6a7db34.240125.tar.gz",
|
||||
"checksum": "SHA-256:ba9cbfa2b6a46ced939b7c02f2c21f923cfb98228468634618e4a1ea2e4f10a1",
|
||||
"size": "86035"
|
||||
},
|
||||
{
|
||||
"host": "x86_64-mingw32",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/x86_64-w64-mingw32.elf2uf2-6a7db34.230911.zip",
|
||||
"archiveFileName": "x86_64-w64-mingw32.elf2uf2-6a7db34.230911.zip",
|
||||
"checksum": "SHA-256:bd932b64376557790ab130cfef941c4cf0c4f636ea373fb1bb30ccb7d9a667d0",
|
||||
"size": "81346"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/x86_64-w64-mingw32.elf2uf2-6a7db34.240125.zip",
|
||||
"archiveFileName": "x86_64-w64-mingw32.elf2uf2-6a7db34.240125.zip",
|
||||
"checksum": "SHA-256:8bd4440c8a0a5102235377ab3437d75324e7cfa58aa69bbce24c5dff29f5947d",
|
||||
"size": "81681"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "2.1.0-a-d3d2e6b",
|
||||
"version": "2.2.0-d04e724",
|
||||
"name": "pqt-pioasm",
|
||||
"systems": [
|
||||
{
|
||||
"host": "arm64-apple-darwin",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/aarch64-apple-darwin20.4.pioasm-6a7db34.240127.tar.gz",
|
||||
"archiveFileName": "aarch64-apple-darwin20.4.pioasm-6a7db34.240127.tar.gz",
|
||||
"checksum": "SHA-256:b325fdf8c2e7712e821049c68fc29dfac80bc492fb03c0fb3597de272ff42deb",
|
||||
"size": "246217"
|
||||
},
|
||||
{
|
||||
"host": "aarch64-linux-gnu",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/aarch64-linux-gnu.pioasm-6a7db34.230911.tar.gz",
|
||||
"archiveFileName": "aarch64-linux-gnu.pioasm-6a7db34.230911.tar.gz",
|
||||
"checksum": "SHA-256:db0e42e85463d3ff61fa07e40fad274f414161ea9d54098ee41a048c38cf9bed",
|
||||
"size": "453497"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/aarch64-linux-gnu.pioasm-6a7db34.240125.tar.gz",
|
||||
"archiveFileName": "aarch64-linux-gnu.pioasm-6a7db34.240125.tar.gz",
|
||||
"checksum": "SHA-256:fb9faf961945bd2f0773feeb760750f38028740c34b279ea85904377f16d5a55",
|
||||
"size": "456608"
|
||||
},
|
||||
{
|
||||
"host": "arm-linux-gnueabihf",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/arm-linux-gnueabihf.pioasm-6a7db34.230911.tar.gz",
|
||||
"archiveFileName": "arm-linux-gnueabihf.pioasm-6a7db34.230911.tar.gz",
|
||||
"checksum": "SHA-256:afaabb3367f8fe1c5d95d8324eccc288c20a7fd29d0499ec52488a6a317cdeb5",
|
||||
"size": "360810"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/arm-linux-gnueabihf.pioasm-6a7db34.240125.tar.gz",
|
||||
"archiveFileName": "arm-linux-gnueabihf.pioasm-6a7db34.240125.tar.gz",
|
||||
"checksum": "SHA-256:14bcd7305a2542b807eb9d3e31c043a7465dea170a928c8dc5a651476d8b9a14",
|
||||
"size": "379178"
|
||||
},
|
||||
{
|
||||
"host": "i686-pc-linux-gnu",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/i686-linux-gnu.pioasm-6a7db34.230911.tar.gz",
|
||||
"archiveFileName": "i686-linux-gnu.pioasm-6a7db34.230911.tar.gz",
|
||||
"checksum": "SHA-256:62d58a88c22d94081a20d2005fddcdce08ebeb6cf3eb3ad824f28e5f3bb05424",
|
||||
"size": "511516"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/i686-linux-gnu.pioasm-6a7db34.240125.tar.gz",
|
||||
"archiveFileName": "i686-linux-gnu.pioasm-6a7db34.240125.tar.gz",
|
||||
"checksum": "SHA-256:2822abdfb3226c9cfa6bd7e58cbd9f0699cc9fe8ec319bb7adceb31c209095d2",
|
||||
"size": "530142"
|
||||
},
|
||||
{
|
||||
"host": "i686-mingw32",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/i686-w64-mingw32.pioasm-6a7db34.230911.zip",
|
||||
"archiveFileName": "i686-w64-mingw32.pioasm-6a7db34.230911.zip",
|
||||
"checksum": "SHA-256:c5bb884e3e8452495152662946be6ff5c9dc03981a6694df33d17572037888d2",
|
||||
"size": "386187"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/i686-w64-mingw32.pioasm-6a7db34.240125.zip",
|
||||
"archiveFileName": "i686-w64-mingw32.pioasm-6a7db34.240125.zip",
|
||||
"checksum": "SHA-256:a1f8f36ef039c3081d80d874949d243282889f81868ca626389b7d0c2ffef40a",
|
||||
"size": "404747"
|
||||
},
|
||||
{
|
||||
"host": "x86_64-apple-darwin",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/x86_64-apple-darwin15.pioasm-6a7db34.230911.tar.gz",
|
||||
"archiveFileName": "x86_64-apple-darwin15.pioasm-6a7db34.230911.tar.gz",
|
||||
"checksum": "SHA-256:74c3d7f5502674763cb205ed87df469abd5d763a84d37c28ca9fb7b66b583062",
|
||||
"size": "585394"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/x86_64-apple-darwin20.4.pioasm-6a7db34.240125.tar.gz",
|
||||
"archiveFileName": "x86_64-apple-darwin20.4.pioasm-6a7db34.240125.tar.gz",
|
||||
"checksum": "SHA-256:4c54204a7d5312825d6609cc326d4b4072728f8446ead346bae1c319256d7abe",
|
||||
"size": "650257"
|
||||
},
|
||||
{
|
||||
"host": "x86_64-pc-linux-gnu",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/x86_64-linux-gnu.pioasm-6a7db34.230911.tar.gz",
|
||||
"archiveFileName": "x86_64-linux-gnu.pioasm-6a7db34.230911.tar.gz",
|
||||
"checksum": "SHA-256:029bbc6f1ab44481583730aedc58a091341267c4089aa151a1e50ba17aca4ba5",
|
||||
"size": "458908"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/x86_64-linux-gnu.pioasm-6a7db34.240125.tar.gz",
|
||||
"archiveFileName": "x86_64-linux-gnu.pioasm-6a7db34.240125.tar.gz",
|
||||
"checksum": "SHA-256:13db79fd0992a0aa8c6a78684fcf6538d77eb645758ccc5dc16b148d452ad796",
|
||||
"size": "477990"
|
||||
},
|
||||
{
|
||||
"host": "x86_64-mingw32",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/x86_64-w64-mingw32.pioasm-6a7db34.230911.zip",
|
||||
"archiveFileName": "x86_64-w64-mingw32.pioasm-6a7db34.230911.zip",
|
||||
"checksum": "SHA-256:3c506a8163ed5d3c6408343f5768f87bbcc6209a049313b51b1dda8bcfe634f4",
|
||||
"size": "408968"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/x86_64-w64-mingw32.pioasm-6a7db34.240125.zip",
|
||||
"archiveFileName": "x86_64-w64-mingw32.pioasm-6a7db34.240125.zip",
|
||||
"checksum": "SHA-256:71eee9c820774328cbd5d082a032fb960587af6a7568b2502ee75ebc6fe6c9a2",
|
||||
"size": "429999"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "2.1.0-a-d3d2e6b",
|
||||
"version": "2.2.0-d04e724",
|
||||
"name": "pqt-mklittlefs",
|
||||
"systems": [
|
||||
{
|
||||
"host": "arm64-apple-darwin",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/aarch64-apple-darwin20.4.mklittlefs-6e2fa17.240127.tar.gz",
|
||||
"archiveFileName": "aarch64-apple-darwin20.4.mklittlefs-6e2fa17.240127.tar.gz",
|
||||
"checksum": "SHA-256:ad46da0560569a97edd11490829479e70aa3c53b4525c5a8f6ae154f2d41c0bb",
|
||||
"size": "70714"
|
||||
},
|
||||
{
|
||||
"host": "aarch64-linux-gnu",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/aarch64-linux-gnu.mklittlefs-4aca452.230911.tar.gz",
|
||||
"archiveFileName": "aarch64-linux-gnu.mklittlefs-4aca452.230911.tar.gz",
|
||||
"checksum": "SHA-256:ebaa3a47e4004afc40e68c948d4811eec546b9e971691faa6cdb8798b450ceca",
|
||||
"size": "63224"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/aarch64-linux-gnu.mklittlefs-6e2fa17.240125.tar.gz",
|
||||
"archiveFileName": "aarch64-linux-gnu.mklittlefs-6e2fa17.240125.tar.gz",
|
||||
"checksum": "SHA-256:63e549d45addddc0e029efed36fdf4684cb4b9f3f965426c56282fef890f7a3f",
|
||||
"size": "68800"
|
||||
},
|
||||
{
|
||||
"host": "arm-linux-gnueabihf",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/arm-linux-gnueabihf.mklittlefs-4aca452.230911.tar.gz",
|
||||
"archiveFileName": "arm-linux-gnueabihf.mklittlefs-4aca452.230911.tar.gz",
|
||||
"checksum": "SHA-256:2865730ce61934f9b24b91ee675a9bcca3db7e2676520363062cd49f501f6f29",
|
||||
"size": "53459"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/arm-linux-gnueabihf.mklittlefs-6e2fa17.240125.tar.gz",
|
||||
"archiveFileName": "arm-linux-gnueabihf.mklittlefs-6e2fa17.240125.tar.gz",
|
||||
"checksum": "SHA-256:79746a9b44590ab132c03f686529c3894caf557a15720b2d9e4d64c91742093d",
|
||||
"size": "59810"
|
||||
},
|
||||
{
|
||||
"host": "i686-pc-linux-gnu",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/i686-linux-gnu.mklittlefs-4aca452.230911.tar.gz",
|
||||
"archiveFileName": "i686-linux-gnu.mklittlefs-4aca452.230911.tar.gz",
|
||||
"checksum": "SHA-256:d8042d1d0d8d052af6c3979cfa61d63790cf940e74ad670df7591530081be923",
|
||||
"size": "69995"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/i686-linux-gnu.mklittlefs-6e2fa17.240125.tar.gz",
|
||||
"archiveFileName": "i686-linux-gnu.mklittlefs-6e2fa17.240125.tar.gz",
|
||||
"checksum": "SHA-256:084c016bf074b028cb40471b2087a6d54ef31a3d34709f5879b86e9577bff44d",
|
||||
"size": "76575"
|
||||
},
|
||||
{
|
||||
"host": "i686-mingw32",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/i686-w64-mingw32.mklittlefs-4aca452.230911.zip",
|
||||
"archiveFileName": "i686-w64-mingw32.mklittlefs-4aca452.230911.zip",
|
||||
"checksum": "SHA-256:0ddc40ccd20f36101543ea4a7a3ff56c63450d417746db2de8a499cb7cdd59b5",
|
||||
"size": "347611"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/i686-w64-mingw32.mklittlefs-6e2fa17.240125.zip",
|
||||
"archiveFileName": "i686-w64-mingw32.mklittlefs-6e2fa17.240125.zip",
|
||||
"checksum": "SHA-256:35c1bcdd05be6389992e78fdb890e81cdd9c298408d811293a2bc7605ac59e7a",
|
||||
"size": "369155"
|
||||
},
|
||||
{
|
||||
"host": "x86_64-apple-darwin",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/x86_64-apple-darwin15.mklittlefs-4aca452.230911.tar.gz",
|
||||
"archiveFileName": "x86_64-apple-darwin15.mklittlefs-4aca452.230911.tar.gz",
|
||||
"checksum": "SHA-256:bdb0d7ec9e2ae9f7ab672a7dd5cc103db3bae287ab3e1b000bbbb6d8141c34f7",
|
||||
"size": "435002"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/x86_64-apple-darwin20.4.mklittlefs-6e2fa17.240125.tar.gz",
|
||||
"archiveFileName": "x86_64-apple-darwin20.4.mklittlefs-6e2fa17.240125.tar.gz",
|
||||
"checksum": "SHA-256:5d0eb016a0712b17f3178acf835590557a6a4990c0400e325f27db4fc9d9813c",
|
||||
"size": "508017"
|
||||
},
|
||||
{
|
||||
"host": "x86_64-pc-linux-gnu",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/x86_64-linux-gnu.mklittlefs-4aca452.230911.tar.gz",
|
||||
"archiveFileName": "x86_64-linux-gnu.mklittlefs-4aca452.230911.tar.gz",
|
||||
"checksum": "SHA-256:a2b5b89c2535a426d59edd51495ba162c347632aeed2af9af27e8378ebeaad4b",
|
||||
"size": "64930"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/x86_64-linux-gnu.mklittlefs-6e2fa17.240125.tar.gz",
|
||||
"archiveFileName": "x86_64-linux-gnu.mklittlefs-6e2fa17.240125.tar.gz",
|
||||
"checksum": "SHA-256:91efeabcd4765d4f6a8e07b1561a226aaaf176abacee3d5f879e94c68dcc5617",
|
||||
"size": "71165"
|
||||
},
|
||||
{
|
||||
"host": "x86_64-mingw32",
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.1.0-a/x86_64-w64-mingw32.mklittlefs-4aca452.230911.zip",
|
||||
"archiveFileName": "x86_64-w64-mingw32.mklittlefs-4aca452.230911.zip",
|
||||
"checksum": "SHA-256:49c18c392c86106ca317bc6fa1db0f3bd7430f937cab372987ebae9cb5194f6a",
|
||||
"size": "359296"
|
||||
"url": "https://github.com/earlephilhower/pico-quick-toolchain/releases/download/2.2.0/x86_64-w64-mingw32.mklittlefs-6e2fa17.240125.zip",
|
||||
"archiveFileName": "x86_64-w64-mingw32.mklittlefs-6e2fa17.240125.zip",
|
||||
"checksum": "SHA-256:cf7291de4633f3a041f38973771a4298128b7641c4c65a94f080fd13cbd50275",
|
||||
"size": "381186"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification
|
||||
|
||||
name=Raspberry Pi RP2040 Boards
|
||||
version=3.6.3
|
||||
version=3.8.0
|
||||
|
||||
# Required discoveries and monitors
|
||||
# ---------------------------------
|
||||
|
||||
+2
-5
@@ -24,6 +24,8 @@ function skip_ino()
|
||||
/p13_TouchSensorLamp/
|
||||
/StringComparisonOperators/
|
||||
/PDMSerialPlotter/
|
||||
/debug/
|
||||
/BackwardCompatibility/
|
||||
EOL
|
||||
echo $ino | grep -q -F "$skiplist"
|
||||
echo $(( 1 - $? ))
|
||||
@@ -178,11 +180,6 @@ function install_ide()
|
||||
unzip -q ${core_path}/tools/dist/arduino-windows.zip
|
||||
mv arduino-${idever} arduino-distrib
|
||||
elif [ "$MACOSX" = "1" ]; then
|
||||
# MACOS only has next-to-obsolete Python2 installed. Install Python 3 from python.org
|
||||
wget -q https://www.python.org/ftp/python/3.7.4/python-3.7.4-macosx10.9.pkg
|
||||
sudo installer -pkg python-3.7.4-macosx10.9.pkg -target /
|
||||
# Install the Python3 certificates, because SSL connections fail w/o them and of course they aren't installed by default.
|
||||
( cd "/Applications/Python 3.7/" && sudo "./Install Certificates.command" )
|
||||
# Hack to place arduino-builder in the same spot as sane OSes
|
||||
test -r ${core_path}/tools/dist/arduino-macos.zip || wget -q -O ${core_path}/tools/dist/arduino-macos.zip "${ideurl}-macosx.zip"
|
||||
unzip -q ${core_path}/tools/dist/arduino-macos.zip
|
||||
|
||||
+2
-1
@@ -14,7 +14,8 @@ for dir in ./cores/rp2040 ./libraries/EEPROM ./libraries/I2S ./libraries/SingleF
|
||||
./libraries/MouseBT ./libraries/SerialBT ./libraries/HID_Bluetooth \
|
||||
./libraries/JoystickBLE ./libraries/KeyboardBLE ./libraries/MouseBLE \
|
||||
./libraries/lwIP_w5500 ./libraries/lwIP_w5100 ./libraries/lwIP_enc28j60 \
|
||||
./libraries/SPISlave ; do
|
||||
./libraries/SPISlave ./libraries/lwIP_ESPHost ./libraries/FatFS\
|
||||
./libraries/FatFSUSB; do
|
||||
find $dir -type f \( -name "*.c" -o -name "*.h" -o -name "*.cpp" \) -a \! -path '*api*' -exec astyle --suffix=none --options=./tests/astyle_core.conf \{\} \;
|
||||
find $dir -type f -name "*.ino" -exec astyle --suffix=none --options=./tests/astyle_examples.conf \{\} \;
|
||||
done
|
||||
|
||||
+11
-10
@@ -99,22 +99,23 @@ def load_tools_list(filename, platform):
|
||||
return tools_to_download
|
||||
|
||||
def identify_platform():
|
||||
arduino_platform_names = {'Darwin' : {32 : 'i386-apple-darwin', 64 : 'x86_64-apple-darwin'},
|
||||
'Linux' : {32 : 'i686-pc-linux-gnu', 64 : 'x86_64-pc-linux-gnu'},
|
||||
'LinuxARM': {32 : 'arm-linux-gnueabihf', 64 : 'aarch64-linux-gnu'},
|
||||
'Windows' : {32 : 'i686-mingw32', 64 : 'x86_64-mingw32'}}
|
||||
arduino_platform_names = {'Darwin' : {32 : 'i386-apple-darwin', 64 : 'x86_64-apple-darwin'},
|
||||
'DarwinARM': {32 : 'arm64-apple-darwin', 64 : 'arm64-apple-darwin'},
|
||||
'Linux' : {32 : 'i686-pc-linux-gnu', 64 : 'x86_64-pc-linux-gnu'},
|
||||
'LinuxARM' : {32 : 'arm-linux-gnueabihf', 64 : 'aarch64-linux-gnu'},
|
||||
'Windows' : {32 : 'i686-mingw32', 64 : 'x86_64-mingw32'}}
|
||||
bits = 32
|
||||
if sys.maxsize > 2**32:
|
||||
bits = 64
|
||||
sys_name = platform.system()
|
||||
if 'Linux' in sys_name and (platform.platform().find('arm') > 0 or platform.platform().find('aarch64') > 0):
|
||||
sys_platform = platform.platform()
|
||||
if 'Darwin' in sys_name and (sys_platform.find('arm') > 0 or sys_platform.find('arm64') > 0):
|
||||
sys_name = 'DarwinARM'
|
||||
if 'Linux' in sys_name and (sys_platform.find('arm') > 0 or sys_platform.find('aarch64') > 0):
|
||||
sys_name = 'LinuxARM'
|
||||
if 'CYGWIN_NT' in sys_name:
|
||||
sys_name = 'Windows'
|
||||
if 'MSYS_NT' in sys_name:
|
||||
sys_name = 'Windows'
|
||||
if 'MINGW' in sys_name:
|
||||
if ('CYGWIN_NT' in sys_name) or ('MSYS_NT' in sys_name) or ('MINGW' in sys_name):
|
||||
sys_name = 'Windows'
|
||||
print('System: %s, Bits: %d, Info: %s' % (sys_name, bits, sys_platform))
|
||||
return arduino_platform_names[sys_name][bits]
|
||||
|
||||
def main():
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
{
|
||||
"build": {
|
||||
"arduino": {
|
||||
"earlephilhower": {
|
||||
"boot2_source": "boot2_w25q080_2_padded_checksum.S",
|
||||
"usb_vid": "0x2E8A",
|
||||
"usb_pid": "0x106F"
|
||||
}
|
||||
},
|
||||
"core": "earlephilhower",
|
||||
"cpu": "cortex-m0plus",
|
||||
"extra_flags": "-D ARDUINO_RASPBERRY_PI_PICO -DARDUINO_ARCH_RP2040 -DUSBD_MAX_POWER_MA=250",
|
||||
"f_cpu": "133000000L",
|
||||
"hwids": [
|
||||
[
|
||||
"0x2E8A",
|
||||
"0x00C0"
|
||||
],
|
||||
[
|
||||
"0x2E8A",
|
||||
"0x106F"
|
||||
]
|
||||
],
|
||||
"mcu": "rp2040",
|
||||
"variant": "DudesCab"
|
||||
},
|
||||
"debug": {
|
||||
"jlink_device": "RP2040_M0_0",
|
||||
"openocd_target": "rp2040.cfg",
|
||||
"svd_path": "rp2040.svd"
|
||||
},
|
||||
"frameworks": [
|
||||
"arduino"
|
||||
],
|
||||
"name": "DudesCab",
|
||||
"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": [
|
||||
"blackmagic",
|
||||
"cmsis-dap",
|
||||
"jlink",
|
||||
"raspberrypi-swd",
|
||||
"picotool",
|
||||
"picoprobe",
|
||||
"pico-debug"
|
||||
]
|
||||
},
|
||||
"url": "https://www.raspberrypi.org/products/raspberry-pi-pico/",
|
||||
"vendor": "L'atelier d'Arnoz"
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
{
|
||||
"build": {
|
||||
"arduino": {
|
||||
"earlephilhower": {
|
||||
"boot2_source": "boot2_w25q080_2_padded_checksum.S",
|
||||
"usb_vid": "0x2E8A",
|
||||
"usb_pid": "0x107B"
|
||||
}
|
||||
},
|
||||
"core": "earlephilhower",
|
||||
"cpu": "cortex-m0plus",
|
||||
"extra_flags": "-D ARDUINO_CONNECTIVITY_2040_LTE_WIFI_BLE_RP2040 -DARDUINO_ARCH_RP2040 -DUSBD_MAX_POWER_MA=500 -DWIFIESPAT2",
|
||||
"f_cpu": "133000000L",
|
||||
"hwids": [
|
||||
[
|
||||
"0x2E8A",
|
||||
"0x00C0"
|
||||
],
|
||||
[
|
||||
"0x2E8A",
|
||||
"0x107B"
|
||||
]
|
||||
],
|
||||
"mcu": "rp2040",
|
||||
"variant": "connectivity_2040_lte_wifi_ble"
|
||||
},
|
||||
"debug": {
|
||||
"jlink_device": "RP2040_M0_0",
|
||||
"openocd_target": "rp2040.cfg",
|
||||
"svd_path": "rp2040.svd"
|
||||
},
|
||||
"frameworks": [
|
||||
"arduino"
|
||||
],
|
||||
"name": "Connectivity 2040 LTE/WiFi/BLE",
|
||||
"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": [
|
||||
"blackmagic",
|
||||
"cmsis-dap",
|
||||
"jlink",
|
||||
"raspberrypi-swd",
|
||||
"picotool",
|
||||
"picoprobe",
|
||||
"pico-debug"
|
||||
]
|
||||
},
|
||||
"url": "https://www.raspberrypi.org/products/raspberry-pi-pico/",
|
||||
"vendor": "iLabs"
|
||||
}
|
||||
@@ -32,7 +32,7 @@
|
||||
"frameworks": [
|
||||
"arduino"
|
||||
],
|
||||
"name": "Maker UNO RP2040",
|
||||
"name": "Maker Uno RP2040",
|
||||
"upload": {
|
||||
"maximum_ram_size": 270336,
|
||||
"maximum_size": 2097152,
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
},
|
||||
"core": "earlephilhower",
|
||||
"cpu": "cortex-m0plus",
|
||||
"extra_flags": "-D ARDUINO_ILABS_2040_RPICO32_RP2040 -DARDUINO_ARCH_RP2040 -DUSBD_MAX_POWER_MA=250",
|
||||
"extra_flags": "-D ARDUINO_ILABS_2040_RPICO32_RP2040 -DARDUINO_ARCH_RP2040 -DUSBD_MAX_POWER_MA=250 -DWIFIESPAT2",
|
||||
"f_cpu": "133000000L",
|
||||
"hwids": [
|
||||
[
|
||||
|
||||
+16
-4
@@ -34,7 +34,7 @@ def BuildDebugLevel(name):
|
||||
print("%s.menu.dbglvl.%s.build.debug_level=%s" % (name, l[0], l[1]))
|
||||
|
||||
def BuildFreq(name):
|
||||
for f in [ 133, 50, 100, 120, 125, 150, 175, 200, 225, 240, 250, 275, 300]:
|
||||
for f in [ 133, 50, 100, 120, 125, 128, 150, 175, 200, 225, 240, 250, 275, 300]:
|
||||
warn = ""
|
||||
if f > 133: warn = " (Overclock)"
|
||||
print("%s.menu.freq.%s=%s MHz%s" % (name, f, f, warn))
|
||||
@@ -88,7 +88,7 @@ def BuildUSBStack(name):
|
||||
print('%s.menu.usbstack.picosdk.build.usbstack_flags=' % (name))
|
||||
print("%s.menu.usbstack.tinyusb=Adafruit TinyUSB" % (name))
|
||||
print('%s.menu.usbstack.tinyusb.build.usbstack_flags=-DUSE_TINYUSB "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino"' % (name))
|
||||
print("%s.menu.usbstack.tinyusb_host=Adafruit TinyUSB Host" % (name))
|
||||
print("%s.menu.usbstack.tinyusb_host=Adafruit TinyUSB Host (native)" % (name))
|
||||
print('%s.menu.usbstack.tinyusb_host.build.usbstack_flags=-DUSE_TINYUSB -DUSE_TINYUSB_HOST "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino"' % (name))
|
||||
print("%s.menu.usbstack.nousb=No USB" % (name))
|
||||
print('%s.menu.usbstack.nousb.build.usbstack_flags="-DNO_USB -DDISABLE_USB_SERIAL -I{runtime.platform.path}/tools/libpico"' % (name))
|
||||
@@ -372,7 +372,7 @@ MakeBoard("bridgetek_idm2040-7a", "BridgeTek", "IDM2040-7A", "0x2e8a", "0x1041",
|
||||
# Cytron
|
||||
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")
|
||||
MakeBoard("cytron_maker_uno_rp2040", "Cytron", "Maker UNO RP2040", "0x2e8a", "0x1071", 250, "CYTRON_MAKER_UNO_RP2040", 2, "boot2_w25q080_2_padded_checksum")
|
||||
MakeBoard("cytron_maker_uno_rp2040", "Cytron", "Maker Uno RP2040", "0x2e8a", "0x1071", 250, "CYTRON_MAKER_UNO_RP2040", 2, "boot2_w25q080_2_padded_checksum")
|
||||
|
||||
# DatanoiseTV
|
||||
MakeBoard("datanoisetv_picoadk", "DatanoiseTV", "PicoADK", "0x2e8a", "0x000a", 250, "DATANOISETV_PICOADK", 2, "boot2_w25q080_2_padded_checksum")
|
||||
@@ -386,6 +386,10 @@ MakeBoard("flyboard2040_core", "DeRuiLab", "FlyBoard2040Core", "0x2e8a", "0x008a
|
||||
# DFRobot
|
||||
MakeBoard("dfrobot_beetle_rp2040", "DFRobot", "Beetle RP2040", "0x3343", "0x4253", 250, "DFROBOT_BEETLE_RP2040", 2, "boot2_w25q080_2_padded_checksum")
|
||||
|
||||
# DudesCab
|
||||
MakeBoard("DudesCab", "L'atelier d'Arnoz", "DudesCab", "0x2e8a", "0x106F", 250, "RASPBERRY_PI_PICO", 4, "boot2_w25q080_2_padded_checksum")
|
||||
|
||||
|
||||
# ElectronicCat
|
||||
MakeBoard("electroniccats_huntercat_nfc", "ElectronicCats", "HunterCat NFC RP2040", "0x2E8A", "0x1037", 500, "ELECTRONICCATS_HUNTERCAT_NFC", 2, "boot2_w25q080_2_padded_checksum")
|
||||
|
||||
@@ -403,7 +407,8 @@ MakeBoard("challenger_nb_2040_wifi", "iLabs", "Challenger NB 2040 WiFi", "0x2e8a
|
||||
MakeBoard("challenger_2040_sdrtc", "iLabs", "Challenger 2040 SD/RTC", "0x2e8a", "0x102d", 250, "CHALLENGER_2040_SDRTC_RP2040", 8, "boot2_w25q080_2_padded_checksum")
|
||||
MakeBoard("challenger_2040_nfc", "iLabs", "Challenger 2040 NFC", "0x2e8a", "0x1036", 250, "CHALLENGER_2040_NFC_RP2040", 8, "boot2_w25q080_2_padded_checksum")
|
||||
MakeBoard("challenger_2040_uwb", "iLabs", "Challenger 2040 UWB", "0x2e8a", "0x1052", 500, "CHALLENGER_2040_UWB_RP2040", 8, "boot2_w25q080_2_padded_checksum")
|
||||
MakeBoard("ilabs_rpico32", "iLabs", "RPICO32", "0x2e8a", "0x1010", 250, "ILABS_2040_RPICO32_RP2040", 8, "boot2_w25q080_2_padded_checksum")
|
||||
MakeBoard("connectivity_2040_lte_wifi_ble", "iLabs", "Connectivity 2040 LTE/WiFi/BLE", "0x2e8a", "0x107b", 500, "CONNECTIVITY_2040_LTE_WIFI_BLE_RP2040", 8, "boot2_w25q080_2_padded_checksum", ["WIFIESPAT2"])
|
||||
MakeBoard("ilabs_rpico32", "iLabs", "RPICO32", "0x2e8a", "0x1010", 250, "ILABS_2040_RPICO32_RP2040", 8, "boot2_w25q080_2_padded_checksum", ["WIFIESPAT2"])
|
||||
|
||||
# Melopero
|
||||
MakeBoard("melopero_cookie_rp2040", "Melopero", "Cookie RP2040", "0x2e8a", "0x1011", 250, "MELOPERO_COOKIE_RP2040", 8, "boot2_w25q080_2_padded_checksum")
|
||||
@@ -415,6 +420,10 @@ MakeBoard("nekosystems_bl2040_mini", "Neko Systems", "BL2040 Mini", "0x2e8a", "0
|
||||
# nullbits
|
||||
MakeBoard("nullbits_bit_c_pro", "nullbits", "Bit-C PRO", "0x2e8a", "0x6e61", 500, "NULLBITS_BIT_C_PRO", 4, "boot2_w25x10cl_4_padded_checksum")
|
||||
|
||||
# Olimex
|
||||
MakeBoard("olimex_rp2040pico30_2mb", "Olimex", "RP2040-Pico30 2MB", "0x15ba", "0x0026", 250, "OLIMEX_RP2040_PICO30_2MB", 2, "boot2_w25q080_2_padded_checksum")
|
||||
MakeBoard("olimex_rp2040pico30_16mb", "Olimex", "RP2040-Pico30 16MB", "0x15ba", "0x0026", 250, "OLIMEX_RP2040_PICO30_16MB", 16, "boot2_w25q080_2_padded_checksum")
|
||||
|
||||
# Pimoroni
|
||||
MakeBoard("pimoroni_pga2040", "Pimoroni", "PGA2040", "0x2e8a", "0x1008", 250, "PIMORONI_PGA2040", 8, "boot2_w25q64jv_4_padded_checksum")
|
||||
MakeBoard("pimoroni_plasma2040", "Pimoroni", "Plasma2040", "0x2e8a", "0x100a", 500, "PIMORONI_PLASMA2040", 2, "boot2_w25q080_2_padded_checksum")
|
||||
@@ -437,6 +446,7 @@ MakeBoard("silicognition_rp2040_shim", "Silicognition", "RP2040-Shim", "0x1209",
|
||||
MakeBoard("solderparty_rp2040_stamp", "Solder Party", "RP2040 Stamp", "0x1209", "0xa182", 500, "SOLDERPARTY_RP2040_STAMP", 8, "boot2_generic_03h_4_padded_checksum")
|
||||
|
||||
# SparkFun
|
||||
MakeBoard("sparkfun_micromodrp2040", "SparkFun", "MicroMod RP2040", "0x1b4f", "0x0026", 250, "SPARKFUN_MICROMOD_RP2040", 16, "boot2_w25q080_2_padded_checksum")
|
||||
MakeBoard("sparkfun_promicrorp2040", "SparkFun", "ProMicro RP2040", "0x1b4f", "0x0026", 250, "SPARKFUN_PROMICRO_RP2040", 16, "boot2_generic_03h_4_padded_checksum")
|
||||
MakeBoard("sparkfun_thingplusrp2040", "SparkFun", "Thing Plus RP2040", "0x1b4f", "0x0026", 250, "SPARKFUN_THINGPLUS_RP2040", 16, "boot2_w25q080_2_padded_checksum")
|
||||
|
||||
@@ -456,6 +466,8 @@ MakeBoard("viyalab_mizu", "Viyalab", "Mizu RP2040", "0x2e8a", "0x000a", 250, "VI
|
||||
# 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_matrix", "Waveshare", "RP2040 Matrix", "0x2e8a", "0x103a", 500, "WAVESHARE_RP2040_MATRIX", 2, "boot2_w25q16jvxq_4_padded_checksum")
|
||||
MakeBoard("waveshare_rp2040_pizero", "Waveshare", "RP2040 PiZero", "0x2e8a", "0x0003", 500, "WAVESHARE_RP2040_PIZERO", 16, "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")
|
||||
|
||||
Executable
+66
@@ -0,0 +1,66 @@
|
||||
#!/bin/sh
|
||||
|
||||
# this shell script refreshes world timezone definitions in
|
||||
# cores/rp2040/TZ.h
|
||||
#
|
||||
# to run it, use:
|
||||
# /path/to/TZupdate.sh
|
||||
# tools/TZupdate.sh
|
||||
# ./TZupdate.sh
|
||||
|
||||
dir=$(cd ${0%/*} 2>/dev/null; pwd)
|
||||
base=${0##*/}
|
||||
|
||||
csv=https://raw.githubusercontent.com/nayarsystems/posix_tz_db/master/zones.csv
|
||||
|
||||
set -e
|
||||
|
||||
tz_tmpdir=$(mktemp -d)
|
||||
trap 'rm -r $tz_tmpdir' EXIT
|
||||
|
||||
input=$tz_tmpdir/zones.csv
|
||||
names=$tz_tmpdir/names.txt
|
||||
values=$tz_tmpdir/values.txt
|
||||
|
||||
wget -O $input $csv || curl $csv > $input
|
||||
|
||||
sed -e 's/^[^,]*,//g' -e 's,^,(,g' -e 's,$,),g' < $input > $values
|
||||
sed -e 's/^\([^,]*\),.*/#define TZ_\1/g' -e 's,["],,g' < $input | tr '/\-+' '_mp' > $names
|
||||
|
||||
(
|
||||
|
||||
cat << EOF
|
||||
|
||||
// autogenerated from $csv
|
||||
// by script <rp2040 arduino core>/tools/${base}
|
||||
// $(date -u)
|
||||
//
|
||||
// This database is autogenerated from IANA timezone database
|
||||
// ${csv}
|
||||
// (using https://www.iana.org/time-zones)
|
||||
// and can be updated on demand in this repository
|
||||
// or by yourself using the above script
|
||||
|
||||
#pragma once
|
||||
|
||||
EOF
|
||||
|
||||
paste $names $values
|
||||
|
||||
) > $tz_tmpdir/TZ.h
|
||||
|
||||
backup=$(date +%s)
|
||||
mv ${dir}/../cores/rp2040/TZ.h ${dir}/../cores/rp2040/TZ.h.$backup
|
||||
mv $tz_tmpdir/TZ.h ${dir}/../cores/rp2040/TZ.h
|
||||
|
||||
cat << EOF
|
||||
|
||||
Done:
|
||||
'${dir}/../cores/rp2040/TZ.h' is updated
|
||||
|
||||
Diff:
|
||||
----8<-------8<------8<---
|
||||
$(diff -u ${dir}/../cores/rp2040/TZ.h.$backup ${dir}/../cores/rp2040/TZ.h)
|
||||
--->8----->8------>8------
|
||||
|
||||
EOF
|
||||
+1
-1
@@ -261,7 +261,7 @@ def get_drives():
|
||||
print("Unable to build drive list");
|
||||
sys.exit(1)
|
||||
for line in to_str(r).split('\n'):
|
||||
words = re.split('\s+', line)
|
||||
words = re.split(r'\s+', line)
|
||||
if len(words) >= 3 and words[1] == "2" and words[2] == "FAT":
|
||||
drives.append(words[0])
|
||||
else:
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
// Pin definitions taken from:
|
||||
// https://datasheets.raspberrypi.org/pico/pico-datasheet.pdf
|
||||
|
||||
|
||||
// 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 (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 (18u)
|
||||
#define PIN_WIRE0_SCL (19u)
|
||||
|
||||
#define PIN_WIRE1_SDA (10u)
|
||||
#define PIN_WIRE1_SCL (11u)
|
||||
|
||||
#define SERIAL_HOWMANY (3u)
|
||||
#define SPI_HOWMANY (2u)
|
||||
#define WIRE_HOWMANY (2u)
|
||||
|
||||
#include "../generic/common.h"
|
||||
@@ -24,7 +24,7 @@
|
||||
#define SARA_SERIAL_PORT Serial2
|
||||
|
||||
// SPI
|
||||
#define PIN_SPI0_MISO (24u)
|
||||
#define PIN_SPI0_MISO (20u)
|
||||
#define PIN_SPI0_MOSI (23u)
|
||||
#define PIN_SPI0_SCK (22u)
|
||||
#define PIN_SPI0_SS (21u)
|
||||
|
||||
@@ -0,0 +1,280 @@
|
||||
/*
|
||||
UBlox SARA/ESP helper class for the Connectivity RP2040 LTE/WIFI/BLE board
|
||||
|
||||
Copyright (c) 2024 P. Oldberg <pontus@ilabs.se>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <Connectivity.h>
|
||||
|
||||
iLabsConnectivityClass::iLabsConnectivityClass(HardwareSerial* espSerial, HardwareSerial* modemSerial) {
|
||||
_espSerial = espSerial;
|
||||
_modemSerial = modemSerial;
|
||||
/* SARA pins */
|
||||
pinMode(PIN_SARA_ON, OUTPUT);
|
||||
digitalWrite(PIN_SARA_ON, LOW); // Output register must always be low
|
||||
pinMode(PIN_SARA_ON, INPUT_PULLUP);
|
||||
|
||||
pinMode(PIN_SARA_RST, INPUT_PULLUP); // Keep as input for now
|
||||
|
||||
pinMode(PIN_SARA_PWR, OUTPUT);
|
||||
digitalWrite(PIN_SARA_PWR, LOW); // No power to SARA yet
|
||||
|
||||
pinMode(PIN_SARA_DTR, OUTPUT);
|
||||
digitalWrite(PIN_SARA_PWR, HIGH); // Make sure DTR is low on the R412M
|
||||
|
||||
modemSerialPortConfigured = false;
|
||||
|
||||
/* ESP Pins */
|
||||
pinMode(PIN_ESP_RST, OUTPUT);
|
||||
digitalWrite(PIN_ESP_RST, LOW); // Hold ESP in reset
|
||||
pinMode(PIN_ESP_MODE, OUTPUT);
|
||||
digitalWrite(PIN_ESP_MODE, HIGH); // Prepare for normal start
|
||||
espSerialPortConfigured = false;
|
||||
}
|
||||
|
||||
// Do a HW reset by applying a low pulse to the reset line for 1mSec
|
||||
bool iLabsConnectivityClass::doModemPowerOn() {
|
||||
bool ret;
|
||||
digitalWrite(PIN_SARA_PWR, HIGH); // Make sure LDO is on
|
||||
delay(100); // let the power stabilize
|
||||
pinMode(PIN_SARA_ON, OUTPUT); // Pull power on control low
|
||||
delay(150); // For 150mS
|
||||
pinMode(PIN_SARA_ON, INPUT_PULLUP); // before releasing it again.
|
||||
delay(1000); // Now wait for 1 second
|
||||
|
||||
SARA_SERIAL_PORT.setRTS(PIN_SERIAL2_RTS); // Enable hardware handshaking
|
||||
SARA_SERIAL_PORT.setCTS(PIN_SERIAL2_CTS);
|
||||
SARA_SERIAL_PORT.begin(DEFAULT_SARA_BAUDRATE);
|
||||
modemSerialPortConfigured = true;
|
||||
ret = isModemAlive(); // Make sure the modem is up and running
|
||||
|
||||
delay(250); // Allow for any extra characters
|
||||
// before flushing the input buffer
|
||||
while (SARA_SERIAL_PORT.available()) {
|
||||
SARA_SERIAL_PORT.read();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Checks to see if the modem responds to the "AT" poll command.
|
||||
bool iLabsConnectivityClass::isModemAlive(uint32_t timeout) {
|
||||
SARA_SERIAL_PORT.setTimeout(100);
|
||||
SARA_SERIAL_PORT.println(F("AT"));
|
||||
String rdy = SARA_SERIAL_PORT.readStringUntil('\n');
|
||||
while (!rdy.startsWith(F("OK")) && --timeout) {
|
||||
SARA_SERIAL_PORT.println(F("AT"));
|
||||
rdy = SARA_SERIAL_PORT.readStringUntil('\n');
|
||||
//Serial.println(rdy);
|
||||
}
|
||||
SARA_SERIAL_PORT.setTimeout(1000); // Restore serial timeout
|
||||
if (timeout) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Return the current MNO profile
|
||||
// Returns -1 if the serial port is not yet setup or the number of the current
|
||||
// MNO profile setting from the modem.
|
||||
int iLabsConnectivityClass::getModemMNOProfile() {
|
||||
if (!modemSerialPortConfigured) {
|
||||
return -1;
|
||||
}
|
||||
SARA_SERIAL_PORT.println(F("AT+UMNOPROF?"));
|
||||
String resp = getModemResponse();
|
||||
return resp.substring(resp.indexOf("+UMNOPROF: ") + 11).toInt();
|
||||
}
|
||||
|
||||
// Set a new MNO profile
|
||||
// Returns false if the serial port is not yet setup or if an error
|
||||
// is detected during the communication with the modem.
|
||||
// This call is synchronous and will wait for the modem to start after
|
||||
// the soft restart which takes about 10 seconds.
|
||||
bool iLabsConnectivityClass::setModemMNOProfile(int profile) {
|
||||
if (!modemSerialPortConfigured) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Disconnect from the network
|
||||
SARA_SERIAL_PORT.println("AT+COPS=2");
|
||||
if (!getModemResponse().endsWith("OK")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String cmd = "AT+UMNOPROF=" + String(profile) + ",1";
|
||||
SARA_SERIAL_PORT.println(cmd);
|
||||
if (!getModemResponse().endsWith("OK")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Restart the modem to apply the new MNO profile
|
||||
SARA_SERIAL_PORT.println("AT+CFUN=15");
|
||||
if (!getModemResponse().endsWith("OK")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return isModemAlive(15000);
|
||||
}
|
||||
|
||||
// Disable power save features
|
||||
bool iLabsConnectivityClass::enableModemPS(bool enable) {
|
||||
if (!modemSerialPortConfigured) {
|
||||
return false;
|
||||
}
|
||||
if (enable) {
|
||||
SARA_SERIAL_PORT.println(F("AT+CPSMS=1"));
|
||||
} else {
|
||||
SARA_SERIAL_PORT.println(F("AT+CPSMS=0"));
|
||||
}
|
||||
|
||||
if (!getModemResponse().endsWith("OK")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Get a response from SARA
|
||||
// A default serial timeout of 2 seconds allow for reading really slow
|
||||
// responses which should accommodate most replies. Replies are then trimmed
|
||||
// from control characters and appended with a tab character as a separator.
|
||||
//
|
||||
String iLabsConnectivityClass::getModemResponse(int timeout) {
|
||||
SARA_SERIAL_PORT.setTimeout(2000); // allow for really slow responses
|
||||
|
||||
String resp = SARA_SERIAL_PORT.readStringUntil('\n');
|
||||
resp.trim();
|
||||
String acc = resp;
|
||||
while (resp.indexOf("OK") == -1 && resp.indexOf("ERROR") == -1 && --timeout) {
|
||||
resp = SARA_SERIAL_PORT.readStringUntil('\n');
|
||||
resp.trim();
|
||||
if (resp.length()) {
|
||||
acc += "\t" + resp;
|
||||
}
|
||||
}
|
||||
return acc;
|
||||
}
|
||||
|
||||
// Do a HW reset by applying a low pulse to the reset line for 1mSec
|
||||
void iLabsConnectivityClass::doEspHWReset() {
|
||||
digitalWrite(PIN_ESP_RST, LOW); // Hold ESP in reset
|
||||
delay(1);
|
||||
digitalWrite(PIN_ESP_RST, HIGH); // Release ESP reset
|
||||
}
|
||||
|
||||
// Set the mode flag high to indicate normal run operation and do a HW
|
||||
// reset.
|
||||
void iLabsConnectivityClass::runEspReset() { // Prepare ESP for normal op
|
||||
digitalWrite(PIN_ESP_MODE, HIGH); // Prepare for normal start
|
||||
doEspHWReset();
|
||||
}
|
||||
|
||||
// Set the mode flag low to indicate flash operation and do a HW
|
||||
// reset.
|
||||
void iLabsConnectivityClass::flashEspReset() { // Prepare ESP for flashing
|
||||
digitalWrite(PIN_ESP_MODE, LOW); // Prepare for normal start
|
||||
doEspHWReset();
|
||||
}
|
||||
|
||||
// Wait for the modem to reply with a "ready" prompt. This can be done
|
||||
// after a sw or hw reset have been performed to ensure that the AT
|
||||
// interpreter is up and running.
|
||||
bool iLabsConnectivityClass::waitForEspReady() {
|
||||
int timeout = 20; // Aprox max 2 sec
|
||||
|
||||
_espSerial->setTimeout(100);
|
||||
String rdy = _espSerial->readStringUntil('\n');
|
||||
while (!rdy.startsWith("ready") && timeout--) {
|
||||
rdy = _espSerial->readStringUntil('\n');
|
||||
}
|
||||
_espSerial->setTimeout(1000); // Reset default timeout to 1000
|
||||
if (timeout) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Reset the ESP and wait for the "ready" prompt to be returned.
|
||||
bool iLabsConnectivityClass::resetEsp() {
|
||||
runEspReset();
|
||||
_espSerial->begin(DEFAULT_ESP_BAUDRATE);
|
||||
return waitForEspReady();
|
||||
}
|
||||
|
||||
// Checks to see if the modem responds to the "AT" poll command.
|
||||
bool iLabsConnectivityClass::isEspAlive() {
|
||||
int timeout = 100;
|
||||
|
||||
_espSerial->setTimeout(250);
|
||||
_espSerial->println(F("AT"));
|
||||
String rdy = _espSerial->readStringUntil('\n');
|
||||
while (!rdy.startsWith(F("OK")) && timeout--) {
|
||||
_espSerial->println(F("AT"));
|
||||
rdy = _espSerial->readStringUntil('\n');
|
||||
}
|
||||
_espSerial->setTimeout(1000);
|
||||
|
||||
if (timeout) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Change the baud rate of the ESP device as well as the local UART.
|
||||
// No checking is done on the input baud rate so the user must know what
|
||||
// baud rates are valid. The function ends by checking if the ESP is
|
||||
// reachable by doing an "AT" poll.
|
||||
bool iLabsConnectivityClass::changeEspBaudRate(int baud) {
|
||||
_espSerial->print(F("AT+UART_CUR="));
|
||||
_espSerial->print(baud);
|
||||
_espSerial->println(F(",8,1,0,0"));
|
||||
delay(100);
|
||||
_espSerial->end();
|
||||
_espSerial->begin(baud);
|
||||
return isEspAlive();
|
||||
}
|
||||
|
||||
// This method should be called if the builtin object isn't needed any more
|
||||
// It basically just releases the UART pins for other use.
|
||||
void iLabsConnectivityClass::releaseEsp() {
|
||||
_espSerial->end();
|
||||
}
|
||||
|
||||
// We can assign a new hardware serial port to accommodate the ESP device here.
|
||||
// The function will release the previously used serial port and assign the
|
||||
// new port. The ESP will be left in a reset state ready to start normal
|
||||
// operation when exiting the function.
|
||||
// This function is useful for when using the PIO serial ports to communicate
|
||||
// with the ESP instead of the built in hardware serial port.
|
||||
void iLabsConnectivityClass::setEspSerial(HardwareSerial* serial) {
|
||||
|
||||
releaseEsp();
|
||||
_espSerial = serial;
|
||||
|
||||
pinMode(PIN_ESP_RST, OUTPUT);
|
||||
digitalWrite(PIN_ESP_RST, LOW); // Hold ESP in reset
|
||||
pinMode(PIN_ESP_MODE, OUTPUT);
|
||||
digitalWrite(PIN_ESP_MODE, HIGH); // Prepare for normal start
|
||||
}
|
||||
|
||||
// Return the current serial object
|
||||
HardwareSerial* iLabsConnectivityClass::getEspSerial() {
|
||||
return _espSerial;
|
||||
}
|
||||
|
||||
iLabsConnectivityClass iLabsConnectivity;
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
UBlox SARA/ESP helper class for the Connectivity RP2040 LTE/WIFI/BLE board
|
||||
|
||||
Copyright (c) 2024 P. Oldberg <pontus@ilabs.se>
|
||||
|
||||
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
|
||||
|
||||
#define DEFAULT_SARA_BAUDRATE 115200
|
||||
#define DEFAULT_ESP_BAUDRATE 115200
|
||||
|
||||
class iLabsConnectivityClass {
|
||||
public:
|
||||
iLabsConnectivityClass(HardwareSerial* = &ESP_SERIAL_PORT, HardwareSerial* = &SARA_SERIAL_PORT);
|
||||
|
||||
// Modem stuff
|
||||
bool doModemPowerOn();
|
||||
bool isModemAlive(uint32_t timeout = 50);
|
||||
int getModemMNOProfile();
|
||||
bool setModemMNOProfile(int profile);
|
||||
bool enableModemPS(bool enable = true);
|
||||
String getModemResponse(int timeout = 5);
|
||||
|
||||
// ESP stuff
|
||||
void doEspHWReset();
|
||||
void runEspReset();
|
||||
void flashEspReset();
|
||||
bool waitForEspReady();
|
||||
bool resetEsp();
|
||||
bool isEspAlive();
|
||||
bool changeEspBaudRate(int);
|
||||
void releaseEsp();
|
||||
void setEspSerial(HardwareSerial*);
|
||||
HardwareSerial* getEspSerial();
|
||||
|
||||
|
||||
private:
|
||||
bool modemSerialPortConfigured;
|
||||
bool espSerialPortConfigured;
|
||||
HardwareSerial* _espSerial;
|
||||
HardwareSerial* _modemSerial;
|
||||
};
|
||||
|
||||
extern iLabsConnectivityClass iLabsConnectivity;
|
||||
@@ -0,0 +1,55 @@
|
||||
#pragma once
|
||||
|
||||
// LEDs
|
||||
#define PIN_LED (19u)
|
||||
|
||||
// Serial1, (UART0) Connected to ESP32 chip)
|
||||
#define PIN_SERIAL1_TX (16u)
|
||||
#define PIN_SERIAL1_RX (17u)
|
||||
#define PIN_ESP32_RST (24u)
|
||||
#define PIN_ESP32_MODE (25u)
|
||||
#define ESP32_SERIAL Serial1
|
||||
// Uart define esp serial abstraction pins
|
||||
#define PIN_ESP_TX PIN_SERIAL1_TX
|
||||
#define PIN_ESP_RX PIN_SERIAL1_RX
|
||||
#define PIN_ESP_RST PIN_ESP32_RST
|
||||
#define PIN_ESP_MODE PIN_ESP32_MODE
|
||||
#define ESP_SERIAL_PORT ESP32_SERIAL
|
||||
|
||||
// Serial2, (UART1) connected to SARA-R4XX modem
|
||||
#define PIN_SERIAL2_TX (4u)
|
||||
#define PIN_SERIAL2_RX (5u)
|
||||
#define PIN_SERIAL2_CTS (6u)
|
||||
#define PIN_SERIAL2_RTS (7u)
|
||||
#define PIN_SARA_DTR (12u)
|
||||
#define PIN_SARA_ON (13u)
|
||||
#define PIN_SARA_RST (14u)
|
||||
#define PIN_SARA_PWR (15u)
|
||||
#define SARA_SERIAL_PORT Serial2
|
||||
|
||||
// SPI
|
||||
#define PIN_SPI0_MISO (20u)
|
||||
#define PIN_SPI0_MOSI (23u)
|
||||
#define PIN_SPI0_SCK (22u)
|
||||
#define PIN_SPI0_SS (21u)
|
||||
|
||||
// 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 (0u)
|
||||
#define PIN_WIRE0_SCL (1u)
|
||||
|
||||
// Not pinned out
|
||||
#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,2 @@
|
||||
#pragma once
|
||||
#include "../rpipico/pins_arduino.h"
|
||||
@@ -0,0 +1,2 @@
|
||||
#pragma once
|
||||
#include "../rpipico/pins_arduino.h"
|
||||
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
// Taken from schematic at https://cdn.sparkfun.com/assets/e/2/7/6/b/ProMicroRP2040_Graphical_Datasheet.pdf
|
||||
// Changes to match https://cdn.sparkfun.com/assets/1/6/f/a/2/MicroMod_General_Pinout_v10_Graphical_Datasheet.pdf
|
||||
|
||||
// LEDs
|
||||
#define PIN_LED (25u)
|
||||
|
||||
#define PIN_NEOPIXEL (31)
|
||||
#define NUM_NEOPIXEL (0)
|
||||
|
||||
// UARTs
|
||||
#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 (20u)
|
||||
#define PIN_SPI0_MOSI (23u)
|
||||
#define PIN_SPI0_SCK (22u)
|
||||
#define PIN_SPI0_SS (21u)
|
||||
|
||||
#define PIN_SPI1_MISO (12u)
|
||||
#define PIN_SPI1_MOSI (15u)
|
||||
#define PIN_SPI1_SCK (14u)
|
||||
#define PIN_SPI1_SS (9u) // not pinned out
|
||||
|
||||
// Wire
|
||||
#define PIN_WIRE0_SDA (4u)
|
||||
#define PIN_WIRE0_SCL (5u)
|
||||
#define PIN_WIRE1_SDA (31u)
|
||||
#define PIN_WIRE1_SCL (31u)
|
||||
|
||||
#define SERIAL_HOWMANY (3u)
|
||||
#define SPI_HOWMANY (1u)
|
||||
#define WIRE_HOWMANY (1u)
|
||||
|
||||
#include "../generic/common.h"
|
||||
@@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
// Waveshare RP2040 Matrix
|
||||
// https://files.waveshare.com/upload/4/49/RP2040-Matrix.pdf
|
||||
// Pins taken from https://github.com/earlephilhower/arduino-pico/files/14470983/WaveshareRP2040Matrix.hs.txt
|
||||
|
||||
// NeoPixel
|
||||
#define PIN_NEOPIXEL (16u)
|
||||
#define NUM_NEOPIXEL (25u)
|
||||
//#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,36 @@
|
||||
#pragma once
|
||||
|
||||
// Waveshare RP2040 PiZero
|
||||
// https://www.waveshare.com/wiki/RP2040-PiZero
|
||||
// https://files.waveshare.com/wiki/RP2040-PiZero/RP2040-PiZero-Schematic.pdf
|
||||
|
||||
// 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 (20u)
|
||||
#define PIN_SPI0_MOSI (19u)
|
||||
#define PIN_SPI0_SCK (18u)
|
||||
#define PIN_SPI0_SS (21u)
|
||||
|
||||
#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"
|
||||
Reference in New Issue
Block a user