Commit graph

49 commits

Author SHA1 Message Date
Earle F. Philhower, III
e7a23550ce
Update to GCC 14.3, Newlib 4.5.0 (#2975)
Moves to just released GCC 14.3

Moves to full-fat printf/scanf because Newlib no longer supports all the
calls libstdc++ requires with the older, smaller, nano-formatted-io option.

Moves to latest SDK develop branch with important float acceleration fixes
for the RP2350, among other updates.

Moves to latest pioasm, picotool develop branches

* SDK was refactored, update the includes
* Rebuild PicoSDK and BearSSL libs
* Update certs in BSSL validation example
* Don't spell check the certs!
* Updated tools with full fat++ newlib printf/scanf
2025-06-12 10:54:37 -07:00
Earle F. Philhower, III
60d28d6c92
Add PIO.h header verification to CI (#2911)
* Add PIO.h header verification to CI

Ensure all PIO .pio.h headers match the .pio sources in the tree

* Install all tools for Style check

* Clean up mismatched PIO headers

No functional changes, but the PDM pdm.pio file did not init a data pin
while the pdm.pio.h (the one actually used in the core) did.  Correct to
match.

* No need for submodules in the style check
2025-04-16 14:56:31 -07:00
Eris Fairbanks
0ec1dc6724
Bidirectional TDM Support (#2843)
* Initial commit.

* Works with AK4619 in TDM128 I2S compatibility mode set to rising BCLK.

* Works with I2S compat mode with BCLK mode set to 0 on AK4619.
2025-03-14 11:35:37 -07:00
Cooper Dalrymple
a426fbf51d
Add buffer read to AudioBufferManager and I2S (#2777)
* Added buffer read to `AudioBufferManager` and `I2S`. Example and documentation included.
* Update type of words to unsigned in example.
* Improve buffered loopback example.
* Remove const from read buffer.
2025-01-26 10:03:44 -08:00
Cooper Dalrymple
e133147192
Bi-directional I2S support (#2775)
* Initial bi-directional I2S support.

* Formatting update on pioasm file.

* Added loopback example.

* Updated documentation.

* Fix `getOverUnderflow` naming.

* Revert `getOverUnderflow` naming changes.

* Remove python cache file.

* Remove `availableForRead`.

* Updated naming convention of OverUnderflow methods.

* Update constructor to prevent conflicts with existing code.

* Avoid ambiguous `setDATA` in bi-directional mode.

* Use only input buffer manager in `available`.

* Fix input checks in `read` and `peek`.

* Fix erroneous comment.

* Update pio_i2s.pio to pio v1.

* Change pio_i2s.pio back to pio v0.
2025-01-23 16:30:53 -08:00
Earle F. Philhower, III
5fb5e16be8
Add real block write for AudioRequestBuffer (#2712)
Optimize AudioRequestBuffer writing when large blocks are available (i.e.
I2S writes of full MP3 or AAC frames in BackgroundAudio).  Update I2S to use
the new call.  Reduces 1152 calls to arb::write() to a single call/return
and optimized memcpy in that case.
2024-12-21 14:15:40 -08:00
Markus Gyger
7961d2943d
Overclock to 153.6 MHz (instead of 147.6 MHz) for I²S 48 kHz sample rate (#2708) 2024-12-21 07:36:57 -08:00
Earle F. Philhower, III
eecbcdf59a
Derive playback devices from common AudioOutputBase (#2703)
The audio output objects all have the same general necessary configuration
calls.  Abstract them out to a generic AudioOutputBase interface class that
they will inherit from.  Simplifies letting applications use different
output channels.

Should be backwards compatible with existing code.
2024-12-18 12:19:40 -08:00
Earle F. Philhower, III
f1b965f704
Allow I2S constructor to set pins, like PWMAudio (#2702)
Pins are a physical connection, makes sense to define them at construction.
2024-12-18 10:06:54 -08:00
Earle F. Philhower, III
5b4dff9a77
Add optional callback parameters for I2S/PWMAudio (#2677)
Like GPIO interrupts, allow the user to pass in a callback data pointer.
2024-12-11 14:53:54 -08:00
JimMacA
64156c42b1
Delay LRCK to falling edge of BCK in I2S input (#2592)
In input mode, LRCK needs to change on falling edge of BCK

Fixes #2584.
2024-11-09 12:44:15 -08:00
Earle F. Philhower, III
76811d3c66
Add RP2350B generic/Pimoroni PGA2350 support (#2433)
* Add support for the extra 16 GPIO pins in the menus and core.
* Clean up Generic RP2350 PSRAM ("none" is valid) and flash (other than 16MB) options.
* Add extra GPIO<->peripheral connections
* Add Pimoroni PGA2350 RP2350B-based board
* Pins 32-47 can be used for PIOPrograms
* Avoid hang when PSRAM fails to initialize
* Move libpico to an RP2350B board for SDK (otherwise the SDK drops all GPIOHI support)
2024-09-11 18:55:28 -07:00
Earle F. Philhower, III
f45db86cc2
Migrate to 2.0.0 SDK (#2336)
* Update to 2.0.0 SDK
* Board type needs to be set before earliest SDK setup
* Platform includes update
* Boot2 files
* Simple compilation issues
* Build and link
* PIO rebuild with version
* Newlib wrapper update
* Force inclusion of runtime_init_* fcns
The linker was dropping all references to the library's included
runtime_init_xxx functions and hence things like the IRQ vector
table and mutexes and alarms weren't properly set up leading to
instant crashes on start up..

Explicitly call out one function from the object file stored in
the .A to force the inclusion of all the functions.  May be a better
way, heppy to hear any ideas.
* Fix SPI GPIO calls
* Fix Ethernet GPIO
* Remove SDK warnings
Remove the skipped error messages once the following PR merged:
https://github.com/raspberrypi/pico-sdk/pull/1786
* BTStack moved SBC encode/decode paths
* Platform.IO fixes
* BT No longer has special absolute mouse
* Rebuild and update OTA
* Rebuild BearSSL, too
* Update liker file to latest SDK
* Clean up libpicocmake
* Clean up LWIP/BT library names
2024-08-17 10:39:13 -07:00
Earle F. Philhower, III
a8e6634776
Avoid swapping L/R channels on I2S input (#2124)
Fixes #2123
2024-04-25 11:22:07 -07:00
Earle F. Philhower, III
bd8eb9bca2
Shift I2S input data by 1 bit (#2121)
Fixes #2037
2024-04-24 11:20:22 -07:00
David Ross Smith
db7ba160ae
Allow MCLK multiplier to be set on all I2S devices (#1813)
As discussed in #1765.
2023-11-13 06:57:37 -08:00
Earle F. Philhower, III
e9daaa3589
Add TDM support to I2S (#1673)
Fixes #1066

Implements a simple TDM mode for the I2S output object.
2023-08-30 08:28:34 -07:00
LinusHeu
4c90b295b2
Fix: 'I2S::operator=(const I2S&)' is implicitly (#1588) 2023-07-12 03:26:43 -07:00
Earle F. Philhower, III
43aa0427ea
Reapply #1548 (#1582) 2023-07-07 13:38:04 -07:00
palmerr23
cc5d1779a3
Add MCLK support for I2S, optimize clocks for jitter-free playback (#1555)
Fixes #1065
2023-07-07 13:10:32 -07:00
LinusHeu
0e579792d1
I2S: Don't consider _isHolding when it's an output (#1548) 2023-06-19 07:54:34 -07:00
Earle F. Philhower, III
d18f8dce2f
I2S check for failure of ARB and PIO allocation (#1528)
Per https://github.com/earlephilhower/arduino-pico/pull/1524#issuecomment-1587885054
2023-06-12 12:24:08 -07:00
Earle F. Philhower, III
c64cdc14b6
Call I2S::end() in I2S destructor (#1527)
Per https://github.com/earlephilhower/arduino-pico/pull/1524#issuecomment-1587562257
2023-06-12 12:12:50 -07:00
Earle F. Philhower, III
2888f4d03d
I2S::available/availableForWrite() returns bytes (#1499)
Per the Arduino documentation, I2s::available should return bytes free,
not samples.  Adjust accordingly.
2023-06-04 16:38:12 -07:00
Earle F. Philhower, III
f57b5bc762
Add I2S::getOverUnderflow() (#1497)
See #1491.  Thanks @LinusHeu
2023-06-04 14:21:02 -07:00
Earle F. Philhower, III
35a4d57360
Fix I2s::available/availableForWrite() (#1496)
Return the actual number of samples that can be read/written, not the
number of 32-bit values there is space for.
2023-06-04 14:10:53 -07:00
LinusHeu
3b4fb295ea
Fix I2S::write(const uint8_t *buffer, size_t size) (#1461)
According to this: https://github.com/earlephilhower/arduino-pico/discussions/1450
2023-05-20 11:33:50 -07:00
Earle F. Philhower, III
3dbe5cf930
Add I2S::swapClocks() for boards w/reversed pins (#1298)
Allow users of boards like the Pico-Audiom where the LRCLK comes
before the BCLK pin, to swap the BCLK/LRCLK of the I2S interface.

Fixes #1287
2023-03-15 15:23:56 -07:00
Tim Boldt
9e272733cf
Add instructions for making I2S input work with Adafruit microphone (#1272)
Co-authored-by: timboldt <tim.boldt@gmail.com>
2023-03-05 14:24:31 -08:00
Earle F. Philhower, III
cefea28539
Stop the I2S PIO when I2S::end called (#1103) 2023-01-06 12:23:26 -08:00
Earle F. Philhower, III
da26016edf
DMA-based ADC input (microphone, analog sensor) (#1101)
Mimics the I2S/PWMAudio/Stream interface for ease of use.

* Fix non-32b DMA size transfer calculation in ABM
* Rename wasHolding to isHolding in the I2S/PWM
  It is the **current** number of bits left, not the past number.
* Add commented microphone example
* Add docs
2023-01-05 16:00:34 -08:00
Earle F. Philhower, III
94abf9d19f
Move analogReadTemp() to C++-only (#1097)
Now that we have a default parameter, need to only allow it in C++ since
default values are not part of C spec.  Should not affect any users since
only legacy code is in C.
2023-01-03 13:30:11 -08:00
Thomas Combriat
7a4244180b
Set Right and Left correctly for lsbj format (#1096) 2023-01-03 13:15:08 -08:00
Earle F. Philhower, III
6fe6c474f7
Add LSBJ format support for I2S (#1095)
Fixes #1094
2023-01-03 11:47:55 -08:00
Earle F. Philhower, III
08d37de94e
Add PWMAudio for DAC-free audio playback (#1076)
Use the PWM hardware to generate a signal suitable for filtering and
amplifying 16bps audio output.

Refactor the AudioBufferManager to allow sharing with I2S

Add example
2022-12-30 13:24:06 -08:00
Earle F. Philhower, III
c69c568f49
Fix I2S::flush volatile casting (#1074)
Also clean up unneeded includes for I2S
2022-12-29 09:43:26 -08:00
Earle F. Philhower, III
5ef04daf44
Make the AudioRingBuffer list-based (#1064)
The ring buffer worked but had issues with IRQs and the available()
procesing.  Because it was a pain to debug, move to a linked list
setup where there are filled and empty buffers to work from,
simplifying the underlying logic.

Allow I2S::available() to return free writing space in OUTPUT mode
to make it saner.

* Increase default number of buffers for 32bps

Gives 2x the time between interrutps to handle I2S callbacks.

* Add setBuffers keyword
2022-12-28 14:46:32 -08:00
Earle F. Philhower, III
e2e65fd53b
Fix I2s::available() to skip currently playing (#1043)
Fixes #963

The available space calculation didn't account for the fact that one
of the buffers was currently being output, causing ::available() to
be too large and ::write() to block in that case.
2022-12-14 15:41:36 -08:00
Sylwester
4e6e1d6024
Use PIN_I2S_ defines if they exist in board pin definition. (#991) 2022-11-22 17:42:32 -08:00
Earle F. Philhower, III
0ef026cfa4
Avoid spurious -O3 warning (#770)
Fixes #768
2022-08-18 13:56:09 -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
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
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
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
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
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
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
bbac9d4b96
Add full-fledged documentation, update I2S API (#80)
Last step before 1.0. Docs for readthedocs.io.

Update the I2S API to mimic others where `setXXX` is called before
`begin()` to set the GPIO pins used.
2021-04-06 08:01:45 -07:00
Earle F. Philhower, III
1eb48f724d
Add I2S output support and I2S class/library (#73)
Using the PIO-driven I2S from pico-extras, add I2S output support.

Be sure to `git submodule update --init` to get the new directories.
2021-04-02 16:21:36 -07:00