Repository navigation
feat(i2s): streaming buffer-refill callback interface + mock impl + host tests (#3526 Phase 2b prep) - #3531
Conversation
…e 2b prep) Extends the II2sPeripheralEsp32Dev peripheral interface with the streaming buffer-refill callback surface that #3526 Phase 2b needs when it wires the real DMA-EOF ISR into I2sPeripheralEsp32DevEsp. Ships the API surface + mock impl + host tests now so: 1. Phase 2b (bench work) can be written against a stable, host-tested interface — no design churn when someone with bench access starts. 2. The engine can be structurally exercised end-to-end on host (transmit → refill → refill → ... → done) via the mock's simulateBufferRefill(), matching how simulateTransmitDone() lets the engine test the done-signal path. ## API additions ### `ii2s_peripheral_esp32dev.h` - New callback signature `I2sEsp32DevBufferRefillCallback`: `void(*)(int buffer_index, bool *done, void *user_ctx)`. Fired per DMA-EOF interrupt. Caller sets `*done = true` to stop the refill cadence. - New virtual `registerBufferRefillCallback(cb, user_ctx)`. Default implementation returns false — impls that don't support streaming refill (Stage-4 stub, pure done-only impls) can leave it alone. ### `i2s_peripheral_esp32dev_mock.{h,cpp.hpp}` - Real implementation of `registerBufferRefillCallback` — stores callback + user_ctx. - New mock-only test hook `simulateBufferRefill(buffer_index)` fires the stored callback synchronously and records the `done` return. - New introspection accessors: `bufferRefillInvocationCount()`, `lastRefillBufferIndex()`, `lastRefillDone()`. - `reset()` clears all new state. ### `channel_engine_i2s_esp32dev.cpp` (host tests) Six new FL_TEST_CASE covering the refill surface: - Register + single fire, verify buffer_index + done reporting. - Cadence across a full buffer ring, verify caller-driven stop. - nullptr callback + fire is no-op. - Register nullptr clears the callback. - setRegisterCallbackFailure knob respected. - Coexistence with the transmit-done callback (both fire independently). ## What this does NOT do - Does NOT implement the real DMA-EOF ISR wiring in `I2sPeripheralEsp32DevEsp` — that's Phase 2b proper (needs WROOM bench). The real impl inherits the default `return false` from the interface until it's implemented. - Does NOT touch the Yves classic driver — that's untouched pending Phase 2e deletion. ## Verification - `bash test --cpp`: 345/345 pass (6 new test cases inside the existing `channel_engine_i2s_esp32dev.cpp` test file). - `bash lint --cpp`: clean modulo 2 pre-existing NoexceptAstChecker violations in `src/fl/remote/rpc/type_to_json.h` (unrelated to this PR). Part of #3516 meta / #3526 Phase 2b prep. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR introduces a "buffer refill" callback API to the classic ESP32 I2S parallel-out peripheral interface, adds a corresponding mock implementation with simulation and state-inspection helpers, and adds unit tests validating registration, invocation, clearing, failure handling, and coexistence with the existing transmit-done callback. ChangesBuffer Refill Callback API
Estimated code review effort: 2 (Simple) | ~15 minutes Possibly related issues
Possibly related PRs
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
) * feat(i2s): add streaming buffer-refill callback interface (#3526 Phase 2b prep) Extends the II2sPeripheralEsp32Dev peripheral interface with the streaming buffer-refill callback surface that #3526 Phase 2b needs when it wires the real DMA-EOF ISR into I2sPeripheralEsp32DevEsp. Ships the API surface + mock impl + host tests now so: 1. Phase 2b (bench work) can be written against a stable, host-tested interface — no design churn when someone with bench access starts. 2. The engine can be structurally exercised end-to-end on host (transmit → refill → refill → ... → done) via the mock's simulateBufferRefill(), matching how simulateTransmitDone() lets the engine test the done-signal path. ## API additions ### `ii2s_peripheral_esp32dev.h` - New callback signature `I2sEsp32DevBufferRefillCallback`: `void(*)(int buffer_index, bool *done, void *user_ctx)`. Fired per DMA-EOF interrupt. Caller sets `*done = true` to stop the refill cadence. - New virtual `registerBufferRefillCallback(cb, user_ctx)`. Default implementation returns false — impls that don't support streaming refill (Stage-4 stub, pure done-only impls) can leave it alone. ### `i2s_peripheral_esp32dev_mock.{h,cpp.hpp}` - Real implementation of `registerBufferRefillCallback` — stores callback + user_ctx. - New mock-only test hook `simulateBufferRefill(buffer_index)` fires the stored callback synchronously and records the `done` return. - New introspection accessors: `bufferRefillInvocationCount()`, `lastRefillBufferIndex()`, `lastRefillDone()`. - `reset()` clears all new state. ### `channel_engine_i2s_esp32dev.cpp` (host tests) Six new FL_TEST_CASE covering the refill surface: - Register + single fire, verify buffer_index + done reporting. - Cadence across a full buffer ring, verify caller-driven stop. - nullptr callback + fire is no-op. - Register nullptr clears the callback. - setRegisterCallbackFailure knob respected. - Coexistence with the transmit-done callback (both fire independently). ## What this does NOT do - Does NOT implement the real DMA-EOF ISR wiring in `I2sPeripheralEsp32DevEsp` — that's Phase 2b proper (needs WROOM bench). The real impl inherits the default `return false` from the interface until it's implemented. - Does NOT touch the Yves classic driver — that's untouched pending Phase 2e deletion. ## Verification - `bash test --cpp`: 345/345 pass (6 new test cases inside the existing `channel_engine_i2s_esp32dev.cpp` test file). - `bash lint --cpp`: clean modulo 2 pre-existing NoexceptAstChecker violations in `src/fl/remote/rpc/type_to_json.h` (unrelated to this PR). Part of #3516 meta / #3526 Phase 2b prep. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * fix(lint): add FL_NO_EXCEPT to TypeToJson<u32> / <u16> converters Closes the two `NoexceptAstChecker` violations in `src/fl/remote/rpc/type_to_json.h:37,46` — the `convert(...)` overrides on `TypeToJson<fl::u32>` and `TypeToJson<fl::u16>` were missing `FL_NO_EXCEPT`. Every other `convert(...)` specialization in the file that goes through primitive-type paths is trivially noexcept, so these two just needed the annotation. Also adds the `fl/stl/noexcept.h` include since the macro wasn't transitively available through the existing includes. Discovered while landing #3531 (I2S refill callback interface) — the pre-existing violations surfaced in the lint pass and were noted as unrelated. This fixes them so the classic-ESP32 I2S umbrella (#3516) rollup CI is fully clean. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Summary
Adds the streaming buffer-refill callback API surface that #3526 Phase 2b (real DMA/ISR) will fill in. Ships the interface + mock impl + host tests now so:
mock.simulateBufferRefill(), matching howsimulateTransmitDone()lets the engine test the done-signal path.API additions
ii2s_peripheral_esp32dev.hI2sEsp32DevBufferRefillCallback—void(*)(int buffer_index, bool *done, void *user_ctx). Fired per DMA-EOF interrupt. Caller sets*done = trueto stop.registerBufferRefillCallback(cb, user_ctx). Default returns false — impls that don't support streaming refill can leave it alone.i2s_peripheral_esp32dev_mock.{h,cpp.hpp}simulateBufferRefill(buffer_index)test hook.bufferRefillInvocationCount(),lastRefillBufferIndex(),lastRefillDone().reset()clears new state.6 new host test cases in
channel_engine_i2s_esp32dev.cppWhat this does NOT do
I2sPeripheralEsp32DevEsp— that's Phase 2b proper (WROOM bench required). Real impl inherits the defaultreturn false.Test plan
bash test --cpp: 345/345 passbash lint --cpp: clean modulo 2 pre-existing violations insrc/fl/remote/rpc/type_to_json.h(unrelated)Part of #3516 meta / #3526 Phase 2b prep.
Summary by CodeRabbit
New Features
Tests