Commit graph

247 commits

Author SHA1 Message Date
Earle F. Philhower, III
1bfd07c19a Update version 2023-02-11 12:34:40 -08:00
Andrew Kroll
5dafbf57e9
Optimize and improve upload experience (#1136)
Stop the IDE from reporting large "Serial port not fount"-type errors after
every upload by delaying a bit before the uploader exits to give the OS/Pico
time to renegotiate.

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

Make 1200bps reset tickle more robust

Co-authored-by: Earle F. Philhower, III <earlephilhower@yahoo.com>
2023-02-11 12:33:44 -08:00
Earle F. Philhower, III
b400897ca2
Avoid initial glitch on Serial1/2 when RX high (#1154)
Fixes #1153

Set up the GPIO redirects before the UART is pulled from reset to avoid
a possible bad byte at `Serial1/2.begin()`.
2023-02-01 19:15:58 -08:00
Earle F. Philhower, III
a1af9698ac
Fix USB VID/PID setting, rationalize boards.txt (#1144)
The USB VID was always being set to the Raspberry Pi foundation code,
causing other brand boards to show up incorrectly.

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

See #1129 for more info
2023-01-28 11:10:39 -08:00
Earle F. Philhower, III
ecaa2bd778
Fix SerialUART::overflow reporting race condition (#1133)
Fixes #1132
2023-01-21 01:38:15 -08:00
Earle F. Philhower, III
d619bf0bc1
More minor ESP8266 compatibility tweaks (#1131) 2023-01-20 17:06:40 -08:00
Gavin Hurlbut
9a241b0e43
Add Serial UART break reporting (#1130)
Added SerialUART::getBreakReceived()
2023-01-20 16:54:31 -08:00
Earle F. Philhower, III
e3f2f87e2d
Add more ESP8266 WiFi compatibility wrappers (#1128) 2023-01-19 12:44:05 -08:00
Earle F. Philhower, III
f212720484 Update version 2023-01-14 14:34:45 -08:00
Earle F. Philhower, III
ae386d4308
Redo boards menu, separate out upload method, add picotool upload (#1112)
Instead of listing each board three times (normal upload, picoprobe,
and pico-debug uploads), list each board once and use a menu to select
the actual upload method.

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

Fix #1111
2023-01-13 13:04:24 -08:00
Earle F. Philhower, III
94abf9d19f
Move analogReadTemp() to C++-only (#1097)
Now that we have a default parameter, need to only allow it in C++ since
default values are not part of C spec.  Should not affect any users since
only legacy code is in C.
2023-01-03 13:30:11 -08:00
Earle F. Philhower, III
444bb24464
Remove debug printout warnings (#1091)
Exposed by #1090, remove ugly printf format warnings while in debug mode
2023-01-02 10:51:04 -08:00
NuclearPhoenix
0e6ca28316
Update wiring_analog.cpp (#1092) 2023-01-02 10:44:49 -08:00
Axotron
1e2f1a19ff
Adding sei() and cli() as aliases for interrupts() and noInterrupts(). (#1089) 2023-01-01 14:18:06 -08:00
Earle F. Philhower, III
a781ec2fdd
Add WString.h include redirect for broader compat (#1083)
See #1079
2022-12-31 11:03:28 -08:00
Earle F. Philhower, III
6a30e4b7a4 Update version 2022-12-30 13:28:23 -08:00
neilger
b8906e0a83
digitalRead/WriteFast to sio_hw->gpio (#1077) 2022-12-30 09:09:04 -08:00
NuclearPhoenix
729360379f
Universal analogReadTemp() (#1075) 2022-12-29 10:33:49 -08:00
Earle F. Philhower, III
0a58e91523
Reduce ADC memory footprint slightly (#1073)
Saves 28 bytes by using a bitmask and smaller ADC settings globals, see #1072

~1% performance impact so negligible.
2022-12-29 09:31:37 -08:00
Earle F. Philhower, III
c9ae04c784
Speed up ADC reads by not re-initting (#1072)
Only change the ADC mux/GPIO control when things re not yet set up.
See #1070
2022-12-28 14:11:24 -08:00
Earle F. Philhower, III
47b18ea84a
Add digitalWrite/ReadFast macros (#1069)
* Add digitalWrite/ReadFast macros

Fix #1067

* Update using @neilger's macros
2022-12-28 11:08:18 -08:00
Earle F. Philhower, III
4cc8e6d6db Update version 2022-12-17 12:07:51 -08:00
Earle F. Philhower, III
fca7fb5e0f
Add USB drive mode to TinyUSB, SingleFileDisk (#1034)
SingleFileDisk allows for exporting a file from the onboard LittleFS
filesystem to a PC through an emulated FAT drive when connected.  The
PC can open and copy the file, as well as delete it, but the PC has no
access to the main onboard LittleFS and no actual on-flash FAT
structures are used.

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

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

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

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

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

This commit switches the function to use String::concat, which doesn't
treat NUL bytes any differently (and is a bit faster, because it doesn't
need to use strlen).
2022-12-04 13:23:16 -08:00
Earle F. Philhower, III
f9321b034f Update version 2022-11-28 10:07:41 -08:00
diesel437
f11c22d984
Using PIO_FRAMEWORK_ARDUINO_NO_USB build flag would cause internal rp2040 fifo not being initialized correct. (#1001) 2022-11-24 10:02:25 -08:00
imwoo90
a7cf5cd1ca
Fix GPIO interrupt on freeRTOS (#959) 2022-11-22 18:26:19 -08:00
Earle F. Philhower, III
ea5f8241e3
Remove stdio.h include from CYW43 SDK override (#965) 2022-11-07 08:48:54 -08:00
Earle F. Philhower, III
895ffced8e
Fix analogWrite scaling issues (#962)
The PWM internals on the RP2040 are based on 8 slices with independent
clocking.  Make sure that we init the PWM slice being used only once per
change of frequency/range.

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

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

* Fixed buffer overflow in getChipId

* ESP compatibility fixes

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

Instead of allocating it out of the free-slot check, do it inside.
While at it, also check if the mutex creation succeeded before assigning
it to a FMMap slot.
2022-10-31 14:29:00 -07:00
Earle F. Philhower, III
9d0b9bef67 Update version 2022-10-25 08:02:54 -07:00
Earle F. Philhower, III
4fdcc6e5ac
Only init PWM on requested pin (#926)
Avoid glitches on other pins, fix #919
2022-10-20 04:56:44 -07:00
Earle F. Philhower, III
075958883f Update version 2022-10-16 10:50:29 -07:00
Fredrik Jansson
fe632cde4b
Increase analogWrite frequency range, bugfixes (#918)
* analogWrite: fix overflow and wrap value (#917)

-avoid overflow when calculating analogScale * analogFreq, perform
the multiplication in floating point.

-use analogScale - 1 to set the PWM wrap value. Wrap is the highest
value the counter reaches, not the counter period.

* analogWrite: increase frequency range (#917)

- increase frequency range to 10 MHz

- decrease the lowest allowed resolution to 2 bits, and the
  minimal analogRange value to 3. This makes 10 MHz output possible
  with system clock frequencies down to 50 MHz.

- allow clkdiv values >= 1.0, was 2.0. This makes it possible to
  manually set frequency and analogRange so that
  frequency * analogRange = system clock frequency.
  This gives the best possible frequency accuracy and
  resolution.
2022-10-16 10:43:49 -07:00
Earle F. Philhower, III
10090b60a9
Rewrite PicoW LWIP interface for stability (#916)
Random crashes, infinite loops, and other lockups were happening to the PicoW
while under high load from multiple clients.

This seems to have been due to two issues:

* The periodic sys_check_timeouts() call from an alarm/IRQ was happening while
  the core was in LWIP code. LWIP is not re-entrant or multi-core/thread safe
  so this is a bad thing. Some calls may not have been locked with a manual
  addition of the LWIPMutex object to hit this.
* The WiFi driver supplies packet data during an interrupt. PBUF work is
  legal in an interrupt, but actually calling netif->input() from an IRQ to
  queue up the Ethernet packet for processing is illegal if LWIP is already
  in progress.
   
Rearchitect the LWIP interface to fix these problems:
* Disable interrupts during malloc/etc. to avoid the possibility of the
  periodic LWIP timeout check interrupting and potentially calling user
  code which did a memory operation
* Wrap all used LWIP calls to note LWIP code will be executing, instead of
  manually eyeballing and adding in protection in user code.
* Remove all user code LWIPMutex blocking, the wrapping takes care of it.
* When an Ethernet packet is received by interrupt and we're in LWIP code,
  just throw the packet away for now. The upper layers can handle retransmit.
  (A possible optimization would be to set the packet aside and add a
  housekeeping portion to the LWIP wrappers to netif->input() them when safe).
* Ignore callbacks during TCP connection teardown when the ClientContext
  passed from LWIP == nullptr
2022-10-15 12:00:35 -07:00
Earle F. Philhower, III
a6bdb27178
Use static allocation for IRQ stack (#915)
noInterrupts/interrupts use a stack to allow multiple calls to work
properly.  The original code was using a std::stack which will use
malloc() to allocate entry space.  This seems like a bad idea, and
makes it so it's impossible to disable interrupts for malloc/free,
etc.

Define a fixed stack size and use straight C code to manage the IRQ
stacks.  Slightly more fixed memory requirements, but significantly
lower total RAM requirements and no malloc() dependency.
2022-10-14 13:46:00 -07:00
Earle F. Philhower, III
69ab736cf8 Update version 2022-10-04 17:14:52 -07:00
Earle F. Philhower, III
7f216f35ab
Allow double-reset to jump to USB bootloader (#893)
Call `rp2040.enableDoubleResetBootloader()` anywhere in the code to
enable the check.  W/o that call, the checker will be linked in.

See #892

CORE1 doesn't start until well after the C runtime initialization,
so the flag won't be overwritten.

Also increase timeout to 350ms because OTA bootup can be
slow.
2022-10-04 14:04:40 -07:00
Earle F. Philhower, III
029471ecca
Drive pin LOW after Tone(period) timeout (#887)
Fixes #886
2022-09-29 13:03:49 -07:00
Earle F. Philhower, III
4cc6c36c37
Fix Serial1/2 debug output mode in CoreMutex (#883)
Fixes #882
2022-09-26 14:19:00 -07:00
Earle F. Philhower, III
0cd5b0ac47
Allow setCTS/RTS(UART_PIN_NOT_DEFINED) (#881)
Fixes #880
2022-09-26 08:13:44 -07:00
Earle F. Philhower, III
939c83127e
Fix deadlock during attachInterrupt (#879)
Fixes #878
2022-09-25 10:02:48 -07:00
Earle F. Philhower, III
cd0e83843f Update version 2022-09-21 19:19:24 -07:00