Commit graph

183 commits

Author SHA1 Message Date
Earle F. Philhower, III
166f63f955
Update PicoOTA.h 2022-08-31 14:40:53 -07:00
Earle F. Philhower, III
d2beb2da19
Add upsteam multicast compatibility APIs (#821)
Fixes #747 while remaining ESP8266 compatible
2022-08-31 11:06:18 -07:00
Earle F. Philhower, III
7ef44d9878
Clean up WebServer send() methods (#820)
Avoid creating Strings when sending out results.
2022-08-31 08:21:16 -07:00
Earle F. Philhower, III
408813c387 Add SDFS header to SpeedTest to simplify use 2022-08-31 08:09:42 -07:00
Earle F. Philhower, III
4d2f64a12b
Add bidirectional bulk SPI transfer, update SdFAT (#819)
Should speed up SD transfers significantly (2.5x+).

See #801
2022-08-31 07:42:34 -07:00
Earle F. Philhower, III
9997461e3a
Shrink MIME table flash usage by ~500 bytes (#818)
Decreases WebServer sketch sizes.
2022-08-30 19:21:57 -07:00
Filipe Mendonça
024ae9bb42
Fix WiFi MAC Address string output (#812)
Fixes #811
2022-08-29 17:51:40 -07:00
Earle F. Philhower, III
38bcf4f956
Minor WebServer style/unused var cleanup (#810) 2022-08-29 13:25:32 -07:00
Earle F. Philhower, III
486caf42a0
Remove microscopic malloc() from WebServer (#809)
Don't try and heap allocate temporaty <16b chunks.
2022-08-29 12:35:14 -07:00
Earle F. Philhower, III
bde4da2b7e
Protect core/Newlib mutexes from task preemption under FreeRTOS (#798)
Fixes #795 

Replace all CoreMutex and Newlib mutex accesses with FreeRTOS calls
when in FreeRTOS mode.  Avoid issues with hange/etc. due to priority
inversion.

No changes to normal operating mode.

Add a FreeRTOS stress test that caught the issue fixed here.
2022-08-29 08:56:59 -07:00
Earle F. Philhower, III
064dd4794f
Minor header/directrory cleanup (#802) 2022-08-27 13:04:57 -07:00
Earle F. Philhower, III
257db5ac7d Update version 2022-08-27 09:33:50 -07:00
Earle F. Philhower, III
0edba2ee2a
Add WebServer, WebServerSecure, HTTPUpdateServer, HTTPUpdateServerSecure (#791)
* Add HTTP-parser lib to support ESP32 WebServer
* Add WebServer from ESP32.  Only supports HTTP
* Separate HTTP server from the network server
Instead of managing the WiFiServer/WiFiServerSecure in the same object
as the HTTP handling, split them into separate objects.  This lets
HTTP and HTTPS servers work without templates or duplicating code.
The HTTP block just gets a `WiFiClient*` and works with that to only
do HTTP processing, while the upper object handles the appropriate
server and client types.
* Add HTTPS server
* Clean up some THandlerFunction refs
* Refactor into a template-ized WebServer/WebServerSecure
* Add DNSServer examples which need WebServer
* Fix CoreMutex infinite recursion crash
Core could crash while Serial debugging was going on and prints were
happening from LWIP/IRQ land and the main app.
* Add HTTPUpdateServer(Secure)
* Add MIME include, optimize WebServer::send(size,len)
When send()ing a large buffer, the WebServer::send() call would
actually convert that buffer into a String (i.e. duplicate it, and
potential issues with embedded \0s in binary data).
Make a simple override to send(size, len) to allow writing from the
source buffer instead.
* Fix WiFiClient::send(Stream), add FSBrowser example
2022-08-23 15:51:32 -07:00
Earle F. Philhower, III
de215a6e1b Add WiFi.getHostname() call 2022-08-21 19:53:18 -07:00
Earle F. Philhower, III
0b390d7dc4
Add HTTPUpdate class to pull updates from HTTP(S) (#789)
* Add HTTPUpdate class to pull updates from HTTP(S)
* Increase GH runners for pulls
WiFi builds and examples are taking some serious time now
* HTTPUpdate tests build on Pico W
2022-08-21 18:24:59 -07:00
Earle F. Philhower, III
a3f5fee6a5
Make StreamDev stubs private to HTTPClient (#788) 2022-08-21 17:20:34 -07:00
Earle F. Philhower, III
a3f4d89bc4
Ensure OTA errors are sent in single UDP packet (#787)
OTA text error messages were getting lost because they were sent in
multiple UDP packets, one per print(). Now collect the full error and
report in a single print, allowing text messages to appear in ESPOTA.
2022-08-21 15:29:23 -07:00
Earle F. Philhower, III
2044d2e51c
Fix OTA signing (#786)
Force the builder to include the path where we build the signing header.

Undo a breaking bug in the Updater class (TBD fix in ESP8266)

Fixes #783
2022-08-21 15:20:00 -07:00
Earle F. Philhower, III
f9e3278863
Report "no filesystem" on OTA uploads w/o a FS (#785)
Give a meaningful error when OTA is attempted against a chip which does
not have a filesystem configured.
2022-08-21 13:19:26 -07:00
Earle F. Philhower, III
0d15723444
Add HTTPClient, ported from the ESP8266 (#784)
Remove the need to have a separate WiFiClient that's destroyed after
the HTTPClient.  Let the object handle its own client, and pass through
any SSL requests.

Also supports the original ::begin methods which need a
WiFiClient(Secure) to be passed in and managed by the app.
2022-08-21 12:49:06 -07:00
Earle F. Philhower, III
6e0d6a27ec
Avoid rescanning/connecting on WiFiMulti.run (#782)
If the WiFi network is already up, don't run the scan and connection
algorithm in WiFiMulti.
2022-08-21 08:33:17 -07:00
Earle F. Philhower, III
a2465f5fb7
Port ESP8266 DNSServer (#779)
Add a simple DNS server for AP mode
Point DHCP server DNS entry to GW for DNSServer
2022-08-20 17:58:54 -07:00
arturo182
88e98f17b6
EEPROM: Add an update function (#780)
According to the Arduino docs, update works just like put, but it first checks if the value is different from the current one.
This is how our put already works, so we just alias update to put and we're done.
Function added to be more compatible with the Arduino API.
Also see #778
2022-08-20 17:50:40 -07:00
Earle F. Philhower, III
b4db1ad54a Fix softAP config call 2022-08-20 12:24:08 -07:00
Earle F. Philhower, III
7be472932b
Add ESP8266 compat functions for AP mode (#777)
Fixes #767
2022-08-20 12:00:05 -07:00
Earle F. Philhower, III
d019f31ef1
Report ::connected() as false when WiFi link drops (#774)
There may be an issue in the CYW43 driver that causes a link to never be
reported as going down once it has connected, when it was disassociated or
when the wlan shuts off unexpectedly.

Work around it by clearing the internal link active in a TCP callback for
the CYW43 driver.

Reports disconnection properly now, as well as reconnection.

Fixes #762
2022-08-19 18:03:21 -07:00
Earle F. Philhower, III
e2afeaef27
Add simple WiFiMulti support (#771)
Takes a list of APs, finds the one with highest RSSI, and tries to connect.
2022-08-19 12:28:56 -07:00
Earle F. Philhower, III
0ef026cfa4
Avoid spurious -O3 warning (#770)
Fixes #768
2022-08-18 13:56:09 -07:00
Earle F. Philhower, III
5787b4c02b
Allow selecting SPI port for SD/SDFS filesystem (#759)
Fixes #758
2022-08-14 21:59:13 -07:00
Earle F. Philhower, III
bb91d978b1
Add OTA.O to make p.io builds function (#755)
Partial #754
2022-08-12 06:09:29 -07:00
Earle F. Philhower, III
da86a8942b
Add OTA update support (#711)
Adds a 12K OTA stub 3rd stage bootloader, which reads new firmware
from the LittleFS filesystem and flashes on reboot.

By storing the OTA commands in a file in flash, it is possible to
recover from a power failure during OTA programming.  On power
resume, the OTA block will simply re-program from the beginning.

Support cryptographic signed OTA updates, if desired.  Includes
host-side signing logic via openssl.

Add PicoOTA library which encapsulates the file format for
the updater, including CRC32 checking.

Add LEAmDNS support to allow Arduino IDE discovery

Add ArduinoOTA class for IDE uploads

Add MD5Builder class

Add Updater class which supports writing and validating
cryptographically signed binaries from any source (http,
Ethernet, WiFi, Serial, etc.)

Add documentation and readmes.
2022-08-12 00:26:51 -07:00
freeasabeer
71be07e69f
Increase FreeRTOS timer task stack to 1024 (#752) 2022-08-11 14:30:57 -07:00
Odd Stråbø
be18c76c99
Udp: default local_ip to IP_ANY_TYPE when IPv6 is enabled (#750) 2022-08-10 15:25:02 -07:00
Earle F. Philhower, III
af2671d8eb
IPv6 initial support from @oddstr13 (#748)
* Apply @oddstr13 multicast patch to cyw43 driver
* Initial work for enabling IPv6
* Allow accessing CYW43 stats when LWIP_SYS_CHECK_MS is not set
* Use cyw43_set_allmulti to allow receiving multicast
* Add tools/libpico/build to gitignore

Co-authored-by: Odd Stråbø <oddstr13@openshell.no>
2022-08-09 18:05:43 -07:00
Earle F. Philhower, III
005cba3acd
Stop random crashes while writing to flash (#730)
FreeRTOS SMP was updated to:
a) Move ths SYSTICK handler, which cannot be disabled and can fire
   even with IRQs disabled, to RAM
b) Add a flag from the core to the SYSTICK handler to hold off on
   any PendSV (task switch) calls while we are doing the idleOtherCore.

The core now sets this flag, _holdPendSV, and adds add'l FreeRTOS SMP
calls to really, really tell the OS we can't, don't, and better not
be swapped out while writing to flash.

Fixes #719
2022-07-29 22:40:48 -07:00
Earle F. Philhower, III
8fd56ada8b
Adjust tcp_write size when memory is tight (#729)
Increases the MEM_SIZE outstanding write buffer to 8K

Allows the ClientContext to attempt to send smaller buffer chunks in the
case where MEM_SIZE won't allow the full tcp_sndbuf() transfer.

Fixes #725
2022-07-29 13:40:03 -07:00
Earle F. Philhower, III
5ab19e9a9f
Fix I2S timing (#728)
BCLK was running at 50% of expected speed.

Fixes #714
2022-07-29 12:40:04 -07:00
Earle F. Philhower, III
2397d034e3 Remove SPI init from CYW43 ethernet shim 2022-07-23 14:20:10 -07:00
Earle F. Philhower, III
c889a3c1f0
Add NTP waitSet callback (#705)
Allows printing "."s or flashing an LED while NTP is waiting for sync.
2022-07-23 14:07:11 -07:00
Earle F. Philhower, III
cfc05dab2c
Add basic ESP32 WiFiClientSecure support (#704)
Simple sketches should work without modification, but some modes (listed
in the docs) are not possible to support on the Pico W with BearSSL.

Fixes #691
2022-07-23 10:59:40 -07:00
Earle F. Philhower, III
f04c8536c8
Make AP mode report WL_CONNECTED (#702) 2022-07-22 12:32:28 -07:00
Earle F. Philhower, III
0e18f0986a
Enable IPv4 or IPv4/IPv6 stacks, Ethernet class (#695)
IPv4-only mode saves 20KB+ of flash memory.

Add some backwards compatibility with the global Arduino Ethernet
class when running in IPv4 only mode.

Fixes #687

* Speed P.IO build by not cloning 2GB of sources
* Document P.IO new option
2022-07-21 11:57:21 -07:00
Benjamin Aigner
67b3c8fc25
Adding a Joystick library, concurrently usable with Keyboard & Mouse (#692)
Co-authored-by: Benjamin Aigner <beni@asterics-foundation.org>
2022-07-21 04:40:04 -07:00
Earle F. Philhower, III
c3a580ee89
Add WiFiClientSecure and WifiServerSecure (TLS) support, NTP (#683)
* Add TLS (https) support
* Add NTP server
* Clean up include path, add BearSSL headers
* Allow 2 NTP servers, add ESP8266 compat define
* Add MFLN SSL example, free/used/total heap getters
* Enable stack thunking
* Add tested SSL examples
* Add BSSL_validation demo
* Add Client Certificate example
* Add RP2040 helper docs
* Clean up doc errors, missing doc version info
* Add WiFiClientSecure documentation
* Add NTP docs

Fixes #679
2022-07-18 20:24:11 -07:00
Earle F. Philhower, III
61742c9357
Disable WiFi.begin on plain Pico, add JSON (#682) 2022-07-17 05:51:03 -07:00
Earle F. Philhower, III
abf2c586c7
Add Pico W WiFi support (#670)
* Add support for the WiFi chip on the Pico W board.
* USB interrupt now no longer hard coded (conflicted with the WiFi IRQ).
* Add in Pico W board to makeboards.py
* Add in GPIO and variant support
* Initialize WiFi in the Variant
* Use manual LWIP, fix size accounting
* Remove the SDK WiFi overrides
* Pulling in work done in the ESP8266 core.
* Make IPAddress support IPv6
* Build LWIP with IPv4 and IPv6 support
* Use proper MAC
* Avoid cyw_warn crash.  Make macro to a comment while building
* Add WiFiServer
* Add WiFiUdp
* Move LWIP-specific support files to LWIP_Ethernet
* Add WiFi::ping (ICMP ping)
* Move ICMP echo (ping) to LWIPIntfDev
* Move hostByName to LwipIntfDev
* Add AP mode with simple DHCP server
* Add some examples and basic ESP8266 compat hacks
* Update Adafruit TinyUSB to fix crash
* Set DHCP hostname
* Make Wifi.begin() return CONNECTED with link + IP
* Return connected() on WiFi::begin
* Fix spurious TCP retransmission
* Protect LWIP from reentrancy

The Pico SDK calls "sys_check_timeouts() from inside a periodic interrupt.
This appears unsafe, as the interrupt could happen while already in the
(non-reentrant) LWIP code.

Block the interrupt from calling sys_check_timeouts by using a global flag
manually set via an RAII recursive lock.

Add interrupt protection macros around critical sections inside LWIP via
the standard defines.

These two changes should make LWIP significantly more stable and long
running.

* Support disconnecting and reconnecting WiFi
* Add WiFiServer simple example
* Update documentation

Fixes #666
Fixed #665
2022-07-15 16:47:53 -07:00
Earle F. Philhower, III
8eb030ed89
Update TinyUSB to 1.13.3 (#672)
Fix errors in WebUSB buffering
Fixes #642
2022-07-08 13:45:01 -07:00
Earle F. Philhower, III
8cf8923a18
Update to Adafruit_TinyUSB_Arduino 1.12.0 (#654)
* Update to Adafruit_TinyUSB_Arduino 1.12.0

* DualRole requires add'l libraries, skip in CI
2022-06-24 11:24:31 -07:00
Earle F. Philhower, III
3d9611d020
Update FreeRTOS SMP branch to latest upstream (#649) 2022-06-22 17:18:50 -07:00
Earle F. Philhower, III
66eb0613b0
Major multicore fixes Newlib and FreeRTOS (#640)
Instead of wrapping the memory functions in the link stage, rebuild
Newlib and enable retargetable locks.  Override the weak definitions
in the libc.a with our own, SDK based ones.

The wrapping utilized before catches app-level memory allocations
but misses allocations inside Newlib libc (like printf/etc.).

Each core needs its own _impure_ptr or else crashes like the one seen
in parallel printf_floats can happen.  Enable it in the toolchain
build and implement a simple swapper here.

FreeRTOS SMP doesn't support Newlib's dynamic reent which is needed
to allow save MT support.  Minor patch to FreeRTOS and update the
FreeRTOS variant.cpp and setup to support it.
2022-06-20 07:35:30 -07:00
Earle F. Philhower, III
803184c164
Update to latest Adafruit_TinyUSB (#639)
Fixes #582
2022-06-19 08:57:14 -07:00
Earle F. Philhower, III
c4623f4297
Disable Wire slave interrupt on ::end (#621)
Fixes #620
2022-06-10 11:42:04 -07:00
Earle F. Philhower, III
10b869ef30
Fix XIAO RP2040, allow swapping HW units 0/1 (#606)
Add plumbing to allow `Wire`, `Serial1`, `SPI1` to map to the 2nd
hardware unit for devices where the PCB layout only brings out the
2nd port.

Fix the Seeedstudio XAIO pins

Fixes #594
2022-06-04 21:37:28 -07:00
Earle F. Philhower, III
24583494c6
Fix Wire::available() when ::requestFrom fails (#604)
Avoids returning 2^32 bytes in the case of a requestFrom read fails
due to timeout.
2022-06-01 17:58:54 -07:00
Earle F. Philhower, III
a3a5abac23
Fix Wire I2C restart handling (#586)
Fixes #585

On an I2C bus restart, call the onReceive callback and clear the buffer.

Thanks to @DWiskow for the debug and patch!
2022-05-19 16:00:52 -07:00
Earle F. Philhower, III
07500e89db
Rewrite I2S from scratch, add I2S input support (#569)
Rewrite the I2S code from scratch to eliminate the dependence on the
pico-extras implementation and to support I2S input as well.

8-bit, 16-bit, 24-bit, and 32-bit words are supported.

Multiple I2S ports are allowed (theoretically up to 6 because
2 DMA channels are required per port).

I2S input and I2S output are supported.

Add input example

Fixes #535
Fixes #99
Fixes #562
2022-05-04 18:43:27 -07:00
ogatatsu
55394a7dcd
Fix compile error when configSUPPORT_STATIC_ALLOCATION is set to 1 (#564) (#566) 2022-04-30 19:07:21 -07:00
Earle F. Philhower, III
cfc91804c8
Fix memory corruption introducted in FreeRTOS port (#556)
To remove compiler warning the valid core macro was modified to only check
that the core passed in was < # of total cores.  Unfortunately there are
parts of the FreeRTOS code where the passed in core # is -1.  The upstream
catches this and returns FALSE, but my hacked version returned TRUE.  This
caused interesting memory corruption errors and crashes when the
current task block[-1] was updated.

Undo the change and fix the 1 spot where a warning happens instead.

Undo the forced compiler -O0 for port.c, it was only masking the fault.
2022-04-27 09:42:15 -07:00
Earle F. Philhower, III
88d213a30b
Additional FreeRTOS adjustments (#555)
Use low power WFE when idle.

Set PORT.C to built `-O0` always because it seems to occasinally end
up with interrupts disabled in task code, causing the SYSTICK never to
fire and killing task switching.

No need for dynamic exceptions.  We don't move the execbase.
2022-04-27 03:53:07 -07:00
Earle F. Philhower, III
189b796499 More FreeRTOS ISR work 2022-04-25 19:11:38 -07:00
Andy2No
797abb5a7f
Update SimpleTone.ino (#552)
Adds code to define which pins are used, moving them from the defaults, which are the same as the only three analogue input pins, and adding comments to explain how to change them.

The original didn't give any clues about which pins were used, which isn't ideal for a beginner - it was necessary to look at the code for the library, to work that out.

The new code redundantly defines a pWS pin number (as pBCLK+1), which isn't used in the example, but is meant as a reminder to the person using it, of how to wire up WS.
2022-04-25 12:21:34 -07:00
Earle F. Philhower, III
ffff21a936
Update FreeRTOS library to avoid random crashes (#553) 2022-04-25 12:10:48 -07:00
Earle F. Philhower, III
bda630e419
Add FreeRTOS support thanks to @hfellner (#533)
Using all the work from @hfellner and others, add FreeRTOS
SMP support.

Allow idling cores through the FreeRTOS FIFO queue to
allow for file system and EEPROM support.

Make delay a weak function so FreeRTOS can override.

Add cycle count support under FreeRTOS using a PIO SM.

Use a task-based approach for handling the USB periodic work
instead of the IRQ-based one in the main core.

Set 8 prio levels so it fits in 3 bits nicely (0..7).
2022-04-24 20:59:57 -07:00
Earle F. Philhower, III
1c0133704e
Update to LittleFS 2.5 (#545) 2022-04-22 12:22:27 -07:00
Bodmer
5a0d67f1ac
PDM library: Update PIO and interrupt use (#496)
The PIO and state machine were hard wired, so this caused problems if they were not free. The approach used by the Servo library has been adopted so a free PIO and SM are searched.

The DMA_IRQ_0 was grabbed exclusively, but this conflicts with SPI DMA use. The interrupt is now shared, but has been allocated the highest possible priority.

Since the PDM PIO use is receive only, the PIO state machine RX FIFO's can be joined to reduce DMA interrupt load.
2022-02-20 13:20:43 -08:00
Earle F. Philhower, III
c4046602f0
Allow changing I2C clock speed while running (#459)
Fixes #458
2022-02-04 18:08:35 -08:00
Spegs21
36bb604d38
Update tinyusb 1.9.2 (#445) 2022-01-29 03:22:14 -08:00
Earle F. Philhower, III
a7035ab61e Rename SDFat directory for Adafruit compatibility
Fixes #416
2022-01-24 12:38:35 -08:00
Earle F. Philhower, III
2c97bffc54
Update to latest upstream LittleFS (#425)
Also clean up output in SpeedTest, make more human friendly
2022-01-19 18:09:40 -08:00
Earle F. Philhower, III
626b62c413
Update to latest upstream Keyboard/Mouse (#424)
Keyboard class now has support for non-en_US layouts, and documentation has
been added to the Mouse class.

Thanks to @rico0260 for letting me know about the update, and for the initial PR!
2022-01-19 17:46:31 -08:00
Earle F. Philhower, III
25b9ca821e
Only call Wire.onReceive if data is available (#423)
The Pico HW seems to generate an interrupt on the end of every I2C
write cycle, even if the slave address wasn't actually targeted.
This would cause the onReceive method to be called with a 0-len
parameter for every write on the I2C bus.

Now, only call onReceive if there is 1 or more bytes of data available.
2022-01-19 16:16:39 -08:00
Earle F. Philhower, III
d5ddf4cd7f
Move SdFat to master/head (#422)
SdFat used to point to unnamed commit in the ESP8266SdFat repo.
Master in that repo has now been moved to that commit, so make this
core use the master branch for sanity's sake.
2022-01-19 12:30:12 -08:00
Earle F. Philhower, III
464ee85884
Make Wire buffer default to 256 for MBED compatibility (#412)
Fixes #411
2022-01-05 12:14:34 -08:00
Earle F. Philhower, III
f46d7cc84f
Speed up SPI by not reinitting if the paramters are the same as before (#394)
Leave the SPI port initted after a transaction, and when a new one comes in
check if it is the same settings we're already running.  If so, do nothing.
If not, deinit and reinit.  In general the settings will be identical, so
this will speed things up massively.

Fixes #392
2021-12-27 12:25:12 -08:00
Earle F. Philhower, III
29756de336
Update to SDFat 2.1.1 with UTF-8 support (#343) 2021-11-30 17:06:58 -08:00
SirSydom
3585c58688
Reset the SDA and SCL pins to INPUT at Wire.end() to prevent multiple pins connected to I2C when changing pins (#302) 2021-09-03 08:40:18 -07:00
Earle F. Philhower, III
580970cd72
Use Stream::setTimeout to specify I2C TO (#263)
Use the existing Arduino Stream method of setTimeout to set the Wire
I2C timeout delay.

Fixes #260
2021-07-23 15:20:34 -07:00
Earle F. Philhower, III
c13bb1ec2b
Make multiple SDFS/LittleFS.begin calls noops (#262)
When LittleFS.begin() or SDFS.begin() is called after the filesystem is
already mounted, don't unmount/remount.  When an unmount happens, all old
Files become invalid (but the core doesn't know this), so you would end
up with random crashes in FS code.

Now, check for _mounted, and if so just return immediately from begin().
2021-07-23 14:16:57 -07:00
Earle F. Philhower, III
cb9931f3e8
Set available() to 0 when Wire.requestFrom fails (#259)
Wire::requestFrom() returns the number of bytes read from the slave.  In
the case of error, the slave can end up returning a very large integer
for PICO_GENERIC_ERROR which would then be used as the # of bytes read
causing crashes and errors.

Running TalkingToMyself without connecting the I2C ports would show
this behavior.

Now, when PICO_GENERIC_ERROR is returned, set the read-back buffer len
to 0 explicitly.
2021-07-21 18:59:24 -07:00
Ha Thach
3a9703fc20
Update tinyusb 1.3.0 (#228)
* update included tinyusb to 1.2.0

move tusb_config.h from core to library for more portability

* pump tinyusb

* update tinyusb to 1.3.0

* try to fix ci warning
2021-06-30 08:22:36 -07:00
Earle F. Philhower, III
03e740a511
Add CPU cycle counter accessors (#226)
Use the 24-bit SYSTICK peripheral, wrapped in logic to extend it to a
full 32 or 64bits.  W/o the wrapper, SYSTICK will wrap around in ~100ms.

Adds rp2040.getCycleCount() and rp2040.getCycleCount64()

Clean up the libpico build process as crt0.S from the pico-sdk should
be directly used.

Clean up the keywords file.
2021-06-28 20:53:40 -07:00
Earle F. Philhower, III
f299120798 Remove accidental debug message 2021-06-25 18:47:02 -07:00
Earle F. Philhower, III
aac8146f00 Clear I2C status on short slave reads
Fixes #222

The HW needs to have the TXC_ABRT flag cleared when a slave transmission is
cut short by the master, or else it will effectively break the I2C bus and
never recover.
2021-06-25 18:39:44 -07:00
Earle F. Philhower, III
35c974d4c0
Fix file creation on SD and SDFS (#216)
The O_CREAT/etc. flags on the Pico are a full 32-bits in size, but the
core was generating a flag for SdFat using an 8-bit type, so all the
O_CREAT, O_TRUNC, O_APPEND, etc. flags got cut off.

Fix the flag size.

Fixes #214
2021-06-19 12:15:11 -07:00
Earle F. Philhower, III
b02b9c4be8
Add PDM library for Arduino Nano RP2040 Connect (#213)
* Add PDM library for Arduino Nano RP2040 Connect

* No PDM test in CI, only works on Arduino Nano RP2040
2021-06-16 08:17:09 -07:00
Earle F. Philhower, III
bedfbda372
Clear PIO FIFOs when updating Tone and Servos (#206)
The PIO programs that generate tone() and Servo() use the TX FIFO to
receive updates to the period/duty cycle.

The original code would push into the FIFO (potentially blocking the
app if the FIFO was full) and generate at least one cycle of every
value written into the control.  Basically, the output would
lag the changes by 1 cycle or more (which could be 20ms+ on Servo).

Fix this by clearing any old, ungrabbed values from the FIFO before
sending a new one to the program.  Instead of a FIFO, there is
effectively now just a control register and updates will be immediate.

Update the Siren.ino example with delays because now the tone() calls
will not block and run 10x+ faster.
2021-06-11 12:27:48 -07:00
Earle F. Philhower, III
c65c4bfb4e
Allow continuous tone frequency changes (#186)
Fixes #121
Supersedes #185

Redo the PIO program to allow the tone generator on a pin to be updated
without interruption, at waveform boundaries.  This allows for things like
sirens or slurs to be implemented simply.

Use an alarm, not the PIO hardware, to manage time-limited tones().

Add a simple siren example.
2021-06-04 02:45:13 -07:00
Ha Thach
6431b8157b
Add tone music example (#185) 2021-06-04 02:39:04 -07:00
per1234
7d1e83b416
Use optimal bundled library names (#183)
When multiple libraries contain files matching an #include directive in the program, the Arduino build system must pick
one to use for compilation. Multiple factors are used in order to make an intelligent determination of which library is
best.

In order to enhance this determination, the closeness of match between the library.properties name value and the
filename in the #include directive is being added as one of those factors. This new factor is referred to as
"Library Name Priority".

Unfortunately, this change can result in platform bundled libraries which had previously been correctly correctly chosen
no longer being given priority over their equivalent standalone libraries, which may be incompatible or not optimized
for the platform's boards.

This priority inversion only occurs when all the following conditions are true:

- There is a standalone library installed which provides a header filename collision.
- The platform bundled library is architecture optimized (e.g., architectures=esp32).
- The standalone library is architecture compatible (architectures=*).
- The standalone library has equal "Folder Name Priority".
- The standalone library has better "Library Name Priority" (e.g., name=SD vs name=SD(ESP32) for a library with primary
  header file SD.h.

The fix is to simply give the platform bundled library a perfect "Library Name Priority".

Some platform bundled libraries were given a modified name as a workaround to a bug in the Arduino IDE's Library Manager
which caused Library Manager to always show the library as updatable under specific circumstances. That bug was fixed in
Arduino IDE 1.8.6, ~3 years ago.
2021-05-31 07:32:20 -07:00
Earle F. Philhower, III
fd685aac82
PANIC on attempting an invalid setXXX pin (#182)
Fixes #169

Trying to change pinout while running, or to an illegal configuration,
will now immediately panic() with an error message.  Such an attempt
is a pretty big problem since pinouts are hardware related/static.

Prior code would fail silently and return false, but nobody checked
the setXXX return values, anyway.
2021-05-29 10:50:13 -07:00
Earle F. Philhower, III
1fd0b0404d
Add TinyUSB include to all libs (#180)
Fixes #167

For Serial when selecting TinyUSB.  Can't include in the core because Arduino IDE
will not link in libraries called from the core.  Instead, add the header to all
the standard libraries in the hope it will still catch some user cases where they
use these libraries.

See https://github.com/earlephilhower/arduino-pico/issues/167#issuecomment-848622174
2021-05-28 19:23:19 -07:00
Limor "Ladyada" Fried
860b43b342
Two board variant definitions and a high speed SPI transfer function (#172) 2021-05-26 18:09:49 -07:00
Earle F. Philhower, III
8016a932f3
Add astyle format, boards.txt, and package check (#166)
Miscellaneous CI checks for code style, boards.txt update, and that all
referenced packages are available.
2021-05-24 15:01:03 -07:00
Earle F. Philhower, III
fd4f7bbf0b
Add TinyUSB examples to CI (#163) 2021-05-23 09:29:44 -07:00
Earle F. Philhower, III
83a32f1ba3
Add compilation to CI (#155)
Stolen from ESP8266, modified to run basic sanity compiles on the core.

Fix warnings identified by the new checks.
2021-05-22 02:58:57 -07:00
Earle F. Philhower, III
052331168e
Fix repo spelling issues (#152) 2021-05-19 18:03:12 -07:00
Earle F. Philhower, III
a0dac52e0e
Rationalize Adafruit Feather infra, update docs (#145)
Use same board.txt format as other Adafruit boards.
Add in quick note about the new USB stack to the docs.
2021-05-19 10:07:03 -07:00
Ha Thach
f8a2f38fe7
Port Adafruit_TinyUSB_Arduino lib (#127)
* initial tinyusb lib port

* add Adafruit_TinyUSB_Arduino as submodules

* add yield() to main loop

* sync with tinyusb lib latest

* add USB manufacturer and product

* fix typo in tinyusb lib

* sync with master

updating implementation

* Rationalize link stage command line

Make the build process less insane.

* clean up delay

* clean up platform and board

* update makeboards.py for generating usbstack menu

* update tinyusb lib to 1.0.0
2021-05-18 18:10:47 -07:00
Earle F. Philhower, III
af8b548e29
Add time support (time, gettimeofday, etc.) (#138) 2021-05-16 03:23:25 -07:00
Earle F. Philhower, III
d3c5039c2f Clean up USB includes and naming 2021-05-14 12:08:00 -07:00