Skip to content

feat(i2s): Phase 2e — delete Yves, singleton peripheral, variable timing (#3526) - #3564

Merged
zackees merged 11 commits into
masterfrom
feat/i2s-phase-2e-yves-delete-3526
Jul 1, 2026
Merged

zackees merged 11 commits into
masterfrom
feat/i2s-phase-2e-yves-delete-3526

Conversation

@zackees

@zackees zackees commented Jul 1, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes out #3526 Phase 2e. The modern classic-ESP32 I2S parallel-out clockless driver is now the ONLY I2S path.

Yves deletion (with attribution)

  • Deleted clockless_i2s_esp32.{h,cpp.hpp} + i2s_esp32dev.{h,cpp.hpp} (~1287 lines)
  • Removed ClocklessI2S alias branch in platforms/esp/clockless.h
  • Removed #include \"clockless_i2s_esp32.h\" in fastled_esp32.h
  • Removed the two .cpp.hpp includes in the driver's _build.cpp.hpp
  • Rewrote the FASTLED_ESP32_I2S deprecation warning in FastLED.h to a hard-removal message

Yves Bazin is credited as the original driver author in both channel_engine_i2s_esp32dev.h and i2s_peripheral_esp32dev_esp.cpp.hpp docstrings — every register write and DMA descriptor field in the modern impl traces its lineage to his original driver.

Peripheral → singleton

Converted I2sPeripheralEsp32DevEsp to a process-lifetime fl::Singleton<>. Deleted the namespace-scope g_i2s1_hardware_claimed_by_modern global — the singleton's mInitialized member is now the sole ownership record.

createI2sEsp32DevEngine() wraps the singleton in fl::make_shared_no_tracking<II2sPeripheralEsp32Dev>(singleton) — zero-overhead non-owning handle, no control block, no delete possible.

Variable-timing waveN

No more hardcoded 8 MHz clock. New solveI2sClockDivider(target_hz, &N, &A, &B) helper solves the fractional divider math for ANY target rate the engine picks. mConfig.mPixelClockHz is now honored — the engine can drive:

  • WS2812 at 800 kHz → 8 MHz clock (N=10, A=1, B=0)
  • WS2811 at 400 kHz → 3.2 MHz clock (N=25, A=1, B=0)
  • Any wave3-eligible chipset at its per-chipset rate

Falls back to 8 MHz if mPixelClockHz is zero.

Follow-up issues filed

Test plan

  • bash test --cpp --clean — 345/345 pass
  • bash lint --cpp — clean
  • bash compile esp32dev --examples AutoResearch --no-filter — SUCCESS
  • Flash to ESP32-WROOM — pong, uptimeMs: 2066

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added runtime GPIO lane routing for ESP32 I2S setups, including support for reassigning or clearing lane pins.
    • Unified ESP32 driver selection now uses the modern I2S path for both clockless and SPI-based output.
  • Bug Fixes

    • Improved ESP32 I2S initialization and transmit handling for more reliable output.
    • Removed legacy ESP32 I2S/clockless support and updated guidance to use the current driver selection flow.

zackees and others added 11 commits July 1, 2026 13:50
…e COM port

Previously the unified WDT was armed lazily by FL_WATCHDOG_AUTO() at
the top of loop(). If setup() hung (RPC bind null-deref, stalled
static-init, wedged serial handshake), no WDT was armed and the COM
port stayed owned by a dead sketch until manual power-cycle.

Arm the WDT with a 20 s window at the very top of setup() so a hang
here auto-reboots. Feed the WDT in the serial-monitor wait loop
because on classic ESP32 (non-USB-CDC) that loop can span up to
AUTORESEARCH_SERIAL_WAIT_MS = 120 s, well past the setup WDT window.

FL_WATCHDOG_AUTO() at loop() top re-arms with the shorter loop-scoped
timeout once setup() has finished.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Adds `encodeChannelWave3_i2s1` alongside the existing `encodeChannelWave8_i2s1`
to satisfy the meta-issue acceptance criterion "Wave3 fallback path
exercised for a three-slot chipset".

Wave3 saves 2.67x memory vs wave8 for chipsets whose T1/T2/T3 timing
rounds to 1/2/N ticks per 3, gated by `fl::canUseWave3(timing)`. Pixel
clock is per-chipset via `fl::wave3ClockFrequencyHz(timing)` instead of
the fixed 8 MHz wave8 rate.

The encoder reuses the shared `fl::wave3Transpose_16` kernel from
`fl/channels/wave3.h` — same anti-drift rule as the wave8 sibling. Host
tests verify byte-exact output against a direct-kernel-call reference
using canonical WS2812 timing (verified wave3-eligible).

Drops the `fl/channels/detail/wave3.hpp` and `detail/wave8.hpp`
force-inline includes from this .cpp.hpp — the unity build pulls this
file across multiple TUs and the force-inline kernels would emit in
each. The public `.h` declarations resolve at link time to the single
out-of-line definitions in `wave3.cpp.hpp` / `wave8.cpp.hpp`, avoiding
double-inline bloat.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
….hpp

The former `fl/channels/detail/wave3.hpp` and `detail/wave8.hpp` were
force-inline headers (`FASTLED_FORCE_INLINE FL_IRAM FL_OPTIMIZE_FUNCTION`).
Every translation unit that included them emitted the full transpose
kernel body. With ~10 callers across PARLIO / LCD_CAM / LCD_SPI / I2S
drivers and the public wave3/wave8 wrappers, that was ~10× the
transpose code in the final binary.

Split into:
- `detail/wave3.h` + `detail/wave8.h` — declarations, constexpr LUTs
  that need compile-time visibility, and the `FL_WAVE8_SPREAD_TO_16`
  helper macro (kept in the .h since it's a #define)
- `detail/wave3.cpp.hpp` + `detail/wave8.cpp.hpp` — out-of-line
  definitions (dropped FASTLED_FORCE_INLINE, kept FL_IRAM +
  FL_OPTIMIZE_FUNCTION for perf), compiled once via the
  channels/detail unity build

Updated 6 caller files (+2 tests) to include the new `.h` headers
instead of the deleted `.hpp` files. The public API
(`wave3Transpose_*` / `wave8Transpose_*` in `wave3.h` / `wave8.h`) is
untouched — this is a pure implementation refactor.

Perf note: dropping FASTLED_FORCE_INLINE means the transpose kernels
no longer get inlined into every caller. On the in-order RV32 P4 core
this could regress the encode-loop-hot-path per-frame timing measured
in #2548 by a few percent (from lost cross-position ILP inside the
same function scope). If bench data shows a regression, the fix is to
keep the specific hot-path kernels (bf1_pipe4, etc.) FASTLED_FORCE_INLINE
in the .h — the pattern here is per-function, not all-or-nothing.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…ipheral (#3526)

Drops the `#include \"platforms/esp/32/drivers/i2s/i2s_esp32dev.h\"`
from `I2sPeripheralEsp32DevEsp::initialize`/`deinitialize`. Replaces
the calls to Yves's `i2s_define_bit_patterns` / `i2s_init` / `i2s_stop`
with direct register writes on `I2S0`/`I2S1` via `soc/i2s_struct.h`.

Fixed 8 MHz pixel clock for wave8 output (80 MHz APB / (10 + 0/1)) —
no per-chipset clock math. This is the general-clockless architecture
the meta issue mandates (PARLIO-style), NOT Yves's per-chipset
bit-pattern encoder.

Register-write sequence mirrors Yves's proven init sequence exactly:
- reset (`lc_conf` + `conf` reset flags)
- reset DMA (`lc_conf.in_rst`/`out_rst`)
- reset FIFO (`conf.rx_fifo_reset`/`tx_fifo_reset`)
- parallel mode (`conf2.lcd_en = 1`, 16-lane width)
- 32-bit-parallel sample rate config
- fixed 8 MHz clkm divider (N=10, A=1, B=0)
- FIFO in DMA-serviced 32-bit mode
- PCM bypass

Ownership tracked via a private static `g_i2s1_hardware_claimed_by_modern`
flag — no dependency on Yves's `gInitializedI2sInitialized`. During
the rollout only one binding path is active at a time (Yves via
`-DFASTLED_ESP32_I2S=1`, modern via `Bus::FLEX_IO, 0` after Phase 2d),
so there is no cross-driver race.

`deinitialize()` clears `tx_start` + resets the block directly.
`transmit()` remains a stub — Phase 2b step B lands the `lldesc_t`
descriptor ring, `esp_intr_alloc()` ISR install, and real DMA kick.

## Bench

- `bash test --cpp` — 345/345 tests pass
- `bash lint --cpp` — clean
- `bash compile esp32dev --examples AutoResearch --no-filter` — SUCCESS
- Flash to ESP32-WROOM via `bash autoresearch esp32dev` — device boots, RPC
  `ping` returns `pong, success: True, uptimeMs: 2066` after WDT-driven
  recovery from the intermittent first-boot `fl::json::json(const char*)`
  panic (unrelated pre-existing bug tracked separately)

## Also included

Updates two AutoResearch example headers I missed in the earlier
detail-split sweep (#3555):
- `examples/AutoResearch/AutoResearchParlioEncode.h`
- `examples/AutoResearch/AutoResearchWave8Expand.h`

Both now include `fl/channels/detail/wave8.h` (declarations) instead of
the deleted force-inline `.hpp`.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Completes the real-hardware DMA path on the modern I2S1 peripheral.
`transmit()` now:

1. Points a DMA-capable `lldesc_t` at the caller's buffer
2. Resets the peripheral, arms `out_link.addr` + `out_link.start`
3. Enables the pre-installed OUT_EOF ISR
4. Flips `mBusy = true` and starts the DMA (`conf.tx_start = 1`)

The ISR trampoline `i2s_dma_isr_trampoline` (FL_IRAM, ISR context)
clears the interrupt, stops `tx_start`, and calls
`I2sPeripheralEsp32DevEsp::finishTransmitFromIsr()` which flips
`mBusy = false` and dispatches the registered completion callback (the
channel-engine trampoline just flips its `mTransmitCompleted` flag —
already ISR-safe).

Descriptor allocated at `initialize()` time via `heap_caps_malloc`
with `MALLOC_CAP_DMA` (DMA-capable DRAM). ISR handle allocated via
`esp_intr_alloc(ETS_I2S1_INTR_SOURCE, ESP_INTR_FLAG_IRAM, ...)`. Both
released in `deinitialize()`.

`waitTransmitDone(timeout_ms)` is now a real deadline-bounded spin
that yields via `vTaskDelay(1)` while `mBusy` — no more (void)timeout
fake return.

## Scope limits (deferred to follow-up)

- **Single descriptor, one-shot only**: buffers larger than 4092 bytes
  are rejected (the `lldesc_t` length field is 12 bits). Streaming
  refill from the ISR — for full-frame 128-byte-per-lane-per-strip
  wave8 output past 4 KB — is a follow-up.
- **No GPIO mux routing**: the peripheral is configured for parallel-
  out but the 16 lane pins are not yet mapped via `gpio_matrix_out` —
  that's Phase 2b step C (which adds `configureTiming` + per-channel
  GPIO plumbing on the engine side).

## Bench

- `bash test --cpp` — 345/345 tests pass
- `bash lint --cpp` — clean
- `bash compile esp32dev --examples AutoResearch --no-filter` — SUCCESS
- Flash to ESP32-WROOM via `bash autoresearch esp32dev` — device boots,
  RPC `ping` returns `pong, success: True, uptimeMs: 2066` (WDT recovery
  from the intermittent first-boot panic works cleanly). Modern engine
  is inert at runtime (not bound to `Bus::FLEX_IO, 0` yet — that's
  Phase 2d), so the DMA/ISR code compiles + boots but doesn't execute
  on this run.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Adds `II2sPeripheralEsp32Dev::routeLanePin(lane, gpio_pin)` for wiring
one parallel-out data lane to a specific GPIO pin. Called by the
engine (in a follow-up) after `initialize()` for each active channel,
before the first `transmit()`.

## Real hardware impl

`I2sPeripheralEsp32DevEsp::routeLanePin` uses the IDF v5-safe
`esp_rom_gpio_connect_out_signal(gpio_num, signal_idx, out_inv,
oen_inv)` API (replaces the legacy `gpio_matrix_out`). Signal index
computed as `I2S{n}O_DATA_OUT0_IDX + lane`, honoring the peripheral
config's per-strip invert mask so chipsets needing polarity inversion
get it "for free" through the GPIO matrix rather than in the encoder.

Pin put into output mode via `gpio_set_direction`.

## Mock

`I2sPeripheralEsp32DevMock::routeLanePin` records the (lane, pin)
pair. Two new introspection methods for tests:
- `laneRouteInvocationCount()` — call count since last `reset()`
- `lastRoutedPinForLane(lane)` — most recent pin, or -1 if unrouted

## Test coverage

New host test `Modern I2S peripheral: routeLanePin records mock mapping`:
- Uninitialised peripheral rejects the route
- Multiple lane routings recorded correctly
- Out-of-range lanes (16, 17) rejected
- Re-routing replaces the previous pin
- `reset()` clears everything

## Bench

- `bash test --cpp` — 346/346 tests pass (new test brings total up by 1)
- `bash lint --cpp` — clean
- `bash compile esp32dev --examples AutoResearch --no-filter` — SUCCESS
- Flash to ESP32-WROOM via `bash autoresearch esp32dev` — device boots,
  RPC `ping` returns `pong, success: True, uptimeMs: 2066`

## What's still gated on Phase 2b step D

- Streaming DMA descriptor ring (current impl is single-descriptor,
  4092-byte limit)
- Engine-side `configureTiming()` that plumbs per-channel GPIO pins
  from `ChannelData::getPin()` down to `routeLanePin` calls

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Classic ESP32 I2S0/I2S1 each expose 24 parallel data output signals
(I2S{n}O_DATA_OUT0_IDX .. DATA_OUT23_IDX per soc/gpio_sig_map.h).
Fix per user hardware review — previous 16-lane cap in routeLanePin
was tighter than the SoC allows.

Wave8 encoder is currently 16-wide, so lanes 16..23 carry no useful
data yet, but the peripheral surface now accepts the full hardware
range so a follow-up wave8Transpose_24 (or padded-32) encoder is a
drop-in on the encoder side alone.

Test coverage extended: lanes 16 and 23 routed successfully; lane
24 and 25 rejected as out of range.
…, wraparound-safe wait, shared lane constant

Reviews on PR #3558:

1. Extract lane cap into a shared `kMaxI2sLanes = 24` constant in
   `ii2s_peripheral_esp32dev.h`; both mock and real impl reference it.

2. `routeLanePin`: select the pad's GPIO function via
   `esp_rom_gpio_pad_select_gpio()` BEFORE `gpio_set_direction()` so
   pins booting in an alternate function (SD_CMD, etc.) can drive I2S.

3. `routeLanePin(lane, -1)`: actually detach the previously-routed pin
   by writing `SIG_GPIO_OUT_IDX` in its place. Requires tracking the
   per-lane pin on the real impl (mirror the mock's `mLaneRoutedPin`).

4. `waitTransmitDone`: wraparound-safe elapsed-time computation using
   `(TickType_t)(now - start)` instead of absolute `deadline`. Correct
   past 32-bit tick counter wrap (~49 days at 1kHz FreeRTOS tick).

5. ISR trampoline: read `mI2sPort` via a new IRAM-safe accessor
   `i2sPortForIsr()` instead of `getConfig()` — getConfig returns a
   const reference and may not be inlined into IRAM under -Og.

6. Fix stale "4093 bytes" comment on the descriptor size check to
   match the 4092-byte cap actually enforced.

## Bench

- `bash test channel_engine_i2s_esp32dev` — passes
- `bash lint --cpp` — clean
- `bash compile esp32dev --examples AutoResearch --no-filter` — SUCCESS
- Flash to ESP32-WROOM — pong, uptimeMs 2066

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…d engine (#3526)

Flips `Bus::FLEX_IO, 0` on classic ESP32 from the standalone
`createI2sSpiEngine()` to the modern unified `createI2sEsp32DevEngine()`.

The modern engine handles BOTH clockless and SPI batches on the same
I2S1 peripheral per the parallel-IO unified-engine rule
(`agents/docs/cpp-standards.md` -> \"Parallel-IO Driver: Unified
Clockless + SPI Engine\"). SPI batches delegate to the tested
`ChannelDriverI2sSpi` internally, so SPI users see no behavioral
change — only the dispatch entry point moves.

## Prerequisite fix (same PR)

`ChannelEngineI2sEsp32Dev::show()` used to `initialize()` the modern
peripheral BEFORE checking whether the batch is clockless or SPI. That
raced with the SPI delegate's own I2S1 claim on a SPI-only batch. Fix:
postpone modern peripheral init to AFTER the SPI/clockless branch. SPI
paths never touch modern's peripheral; only the clockless path
initializes I2S1 for wave8 output.

## Impact

- **Clockless on classic ESP32 (default)**: still routes through RMT
  (unaffected — RMT slot binding is separate). Only opt-in
  `-DFASTLED_ESP32_I2S=1` Yves binding is orthogonal to this swap.
- **SPI (APA102/SK9822/HD108) on classic ESP32**: now dispatches
  through the modern engine's `show()` which delegates to
  `createI2sSpiEngine()`. Extra function-call layer only.
- **`BusSupports<Bus::FLEX_IO, SpiChipsetConfig, 0>`**: still
  `true_type` — SPI still supported on the slot.

## Phase 2e teaser

`drivers/i2s_spi/bus_traits.h` is now the ONE place returning the
modern factory. The whole `drivers/i2s_spi/` directory is scheduled
for deletion at Phase 2e once the delegate call inside the modern
engine gets folded into a direct SPI-mode transmit path. This PR
keeps the file location during rollout to avoid churning the
`_build.cpp.hpp` wiring on the same PR that flips the binding.

## Bench

- `bash test --cpp` — 345/345 tests pass
- `bash lint --cpp` — clean
- `bash compile esp32dev --examples AutoResearch --no-filter` — SUCCESS
- Flash to ESP32-WROOM — pong, uptimeMs 2066

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…ing (#3526)

Closes out #3526 Phase 2e — the modern classic-ESP32 I2S
parallel-out clockless driver is now the only I2S path.

## Yves deletion (with attribution)

Deleted:
- `src/platforms/esp/32/drivers/i2s/clockless_i2s_esp32.{h,cpp.hpp}`
- `src/platforms/esp/32/drivers/i2s/i2s_esp32dev.{h,cpp.hpp}`

Updated call sites to remove `ClocklessI2S` alias:
- `src/platforms/esp/clockless.h` — dropped the
  `#if defined(FASTLED_ESP32_I2S)` branch that aliased
  `ClocklessController = ClocklessI2S<>`
- `src/platforms/esp/32/core/fastled_esp32.h` — removed the
  `#include \"clockless_i2s_esp32.h\"` guarded by
  `FASTLED_ESP32_HAS_I2S`
- `src/platforms/esp/32/drivers/i2s/_build.cpp.hpp` — dropped the
  two `.cpp.hpp` includes
- `src/FastLED.h` — replaced the deprecation-path warning with a
  hard removal message (`-DFASTLED_ESP32_I2S=1` now advises users to
  drop the flag and use `setExclusiveDriver<fl::Bus::FLEX_IO, 0>()`
  for the modern engine)

Yves Bazin is credited as the original driver author in the
docstrings of both `channel_engine_i2s_esp32dev.h` and
`i2s_peripheral_esp32dev_esp.cpp.hpp` — every register write and DMA
descriptor field in the modern impl traces its lineage to his
original driver.

## Peripheral -> singleton

Converted `I2sPeripheralEsp32DevEsp` to a process-lifetime
`fl::Singleton<>`. The former namespace-scope
`g_i2s1_hardware_claimed_by_modern` global is deleted — the
singleton's `mInitialized` member is now the sole ownership record
for I2S1 on classic ESP32.

`createI2sEsp32DevEngine()` wraps the singleton in
`fl::make_shared_no_tracking<II2sPeripheralEsp32Dev>(singleton)` —
zero-overhead non-owning handle, no control block, no delete
possible.

## Variable-timing waveN

The peripheral's `initialize()` no longer hardcodes 8 MHz pixel
clock. New `solveI2sClockDivider(target_hz, &N, &A, &B)` helper
solves the classic-ESP32 fractional divider math (`80 MHz / (N + B/A)`)
for any target frequency the engine picks. Config's
`mPixelClockHz` field is now honored — engine can drive:

- WS2812 at 800 kHz -> 8 MHz clock (N=10, A=1, B=0)
- WS2811 at 400 kHz -> 3.2 MHz clock (N=25, A=1, B=0)
- Any wave3-eligible chipset at its per-chipset rate via
  `wave3ClockFrequencyHz(timing)`

Falls back to 8 MHz if `mPixelClockHz` is zero.

## Follow-up issues filed

- #3561 — apply the same variable-timing pattern to PARLIO
  (currently uses `FL_ESP_PARLIO_CLOCK_FREQ_HZ` compile-time
  constant)
- #3562 — hoist `solveI2sClockDivider()` to a shared
  `platforms/esp/32/core/` location so SPI / RMT / other drivers
  that open-code the same math can consume it

## Bench

- `bash test --cpp --clean` — 345/345 tests pass
- `bash lint --cpp` — clean
- `bash compile esp32dev --examples AutoResearch --no-filter` — SUCCESS
- Flash to ESP32-WROOM — `pong, uptimeMs: 2066`

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees merged commit ce70b5a into master Jul 1, 2026
11 of 12 checks passed
@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 447d873a-8a88-4ac5-b2df-6919630ae123

📥 Commits

Reviewing files that changed from the base of the PR and between 7f6f338 and 7ced233.

📒 Files selected for processing (17)
  • src/FastLED.h
  • src/platforms/esp/32/core/fastled_esp32.h
  • src/platforms/esp/32/drivers/i2s/_build.cpp.hpp
  • src/platforms/esp/32/drivers/i2s/channel_engine_i2s_esp32dev.cpp.hpp
  • src/platforms/esp/32/drivers/i2s/channel_engine_i2s_esp32dev.h
  • src/platforms/esp/32/drivers/i2s/clockless_i2s_esp32.cpp.hpp
  • src/platforms/esp/32/drivers/i2s/clockless_i2s_esp32.h
  • src/platforms/esp/32/drivers/i2s/i2s_esp32dev.cpp.hpp
  • src/platforms/esp/32/drivers/i2s/i2s_esp32dev.h
  • src/platforms/esp/32/drivers/i2s/i2s_peripheral_esp32dev_esp.cpp.hpp
  • src/platforms/esp/32/drivers/i2s/i2s_peripheral_esp32dev_esp.h
  • src/platforms/esp/32/drivers/i2s/i2s_peripheral_esp32dev_mock.cpp.hpp
  • src/platforms/esp/32/drivers/i2s/i2s_peripheral_esp32dev_mock.h
  • src/platforms/esp/32/drivers/i2s/ii2s_peripheral_esp32dev.h
  • src/platforms/esp/32/drivers/i2s_spi/bus_traits.h
  • src/platforms/esp/clockless.h
  • tests/platforms/esp/32/drivers/i2s/channel_engine_i2s_esp32dev.cpp

📝 Walkthrough

Walkthrough

This PR removes the legacy Yves classic-ESP32 I2S/clockless driver files and the FASTLED_ESP32_I2S compile flag path, replacing them with runtime driver selection guidance. It also extends the modern I2sPeripheralEsp32DevEsp/ChannelEngineI2sEsp32Dev engine with singleton lifetime management, a dynamic clock divider, and per-lane GPIO routing, with matching mock and test updates.

Changes

Classic ESP32 I2S driver removal and unified engine migration

Layer / File(s) Summary
Legacy flag/driver selection removal
src/FastLED.h, src/platforms/esp/32/core/fastled_esp32.h, src/platforms/esp/clockless.h, src/platforms/esp/32/drivers/i2s/_build.cpp.hpp
Replaces the ESP-IDF-version-specific FASTLED_ESP32_I2S deprecation warning with an unconditional warning, removes the legacy clockless driver include and ClocklessI2S alias branch, and drops legacy driver includes from the unity build.
Lazy peripheral init and singleton lifetime
src/platforms/esp/32/drivers/i2s/channel_engine_i2s_esp32dev.cpp.hpp, channel_engine_i2s_esp32dev.h
Defers peripheral busy-check/initialization until a clockless batch needs it in show(), and sources the peripheral from a process-lifetime fl::Singleton instead of a fresh instance.
Dynamic clock divider and init ownership
src/platforms/esp/32/drivers/i2s/i2s_peripheral_esp32dev_esp.cpp.hpp
Adds solveI2sClockDivider() for fractional divider computation from mPixelClockHz, removes a global ownership flag in favor of instance state, updates DMA size guard messaging, and makes waitTransmitDone() wraparound-safe.
Per-lane GPIO routing and ISR-safe port access
i2s_peripheral_esp32dev_esp.cpp.hpp, i2s_peripheral_esp32dev_esp.h, ii2s_peripheral_esp32dev.h
Adds routeLanePin() GPIO-matrix routing, an IRAM-safe i2sPortForIsr() accessor used in the DMA-done ISR, the kMaxI2sLanes constant, and a default routeLanePin interface method.
Lane routing mock and tests
i2s_peripheral_esp32dev_mock.cpp.hpp, i2s_peripheral_esp32dev_mock.h, tests/platforms/esp/32/drivers/i2s/channel_engine_i2s_esp32dev.cpp
Adds mock routeLanePin/invocation-count/last-routed-pin tracking with reset() support, and adds a test case covering routing acceptance, bounds, re-routing, and reset.
BusTraits engine switch
src/platforms/esp/32/drivers/i2s_spi/bus_traits.h
Switches BusTraits<Bus::FLEX_IO, 0> to construct the unified engine via createI2sEsp32DevEngine() instead of the SPI-only engine.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant ChannelEngineI2sEsp32Dev
  participant I2sPeripheralEsp32DevEsp
  participant GPIOMatrix

  Caller->>ChannelEngineI2sEsp32Dev: show()
  alt peripheral not initialized
    ChannelEngineI2sEsp32Dev->>I2sPeripheralEsp32DevEsp: initialize(config)
    I2sPeripheralEsp32DevEsp-->>ChannelEngineI2sEsp32Dev: success/failure
  else already initialized
    ChannelEngineI2sEsp32Dev->>I2sPeripheralEsp32DevEsp: isBusy()
  end
  ChannelEngineI2sEsp32Dev->>I2sPeripheralEsp32DevEsp: routeLanePin(lane, gpio_pin)
  I2sPeripheralEsp32DevEsp->>GPIOMatrix: route or detach signal
  I2sPeripheralEsp32DevEsp-->>ChannelEngineI2sEsp32Dev: true/false
  ChannelEngineI2sEsp32Dev-->>Caller: DriverState update
Loading

Possibly related issues

Possibly related PRs

  • FastLED/FastLED#3473: Introduces the Stage-1 engine/mock/test work that this PR's lazy-init and singleton peripheral changes build on.
  • FastLED/FastLED#3476: Introduces the I2sPeripheralEsp32DevEsp implementation that this PR extends with routeLanePin and ISR-safe port handling.
  • FastLED/FastLED#3477: Removes the same legacy clockless_i2s_esp32.* / i2s_esp32dev.* driver code and updates fastled_esp32.h in the same way.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/i2s-phase-2e-yves-delete-3526

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

1 participant