Repository navigation
feat(lpc): wire show()/poll() body via runtime SCT+DMA transmitter (#3459) - #3466
Conversation
…3459) Closes the show()/poll() TODO(3459) block in `channel_engine_lpc_sct_dma.cpp.hpp` and hoists the SCT+DMA programming sequence from `clockless_arm_lpc_pwm_dma.h`'s templated `ClocklessController` into a runtime form so the channels-API engine can drive it from `ChannelData`. New files: src/platforms/arm/lpc/drivers/sct_dma/ lpc_sct_dma_runtime.h — runtime `lpc_sct_ticks(u32 ns)` + `LpcSctDmaTransmitter` declaration lpc_sct_dma_runtime.cpp.hpp — register-level implementation (LPC845) + host no-op stubs `LpcSctDmaTransmitter` owns: - A **per-instance** 3 × CHUNK_BITS u32 encode buffer. This closes one of the `TODO(2842)` markers from `clockless_arm_lpc_pwm_dma.h` — the legacy template path shares one static buffer across all `ClocklessController` instances. - Runtime pin mask + SCT tick counts. - `init() / configureForChannel(pin, t1, t2, t3) / transmit(bytes, len, is_rgbw) / isDone()` — the same five-method shape as the legacy template's `configureSct + configureDma + encodeChunk + startDmaChunk + waitDmaChunk` surface, with runtime values substituted for `TIMING::T1/T2/T3` and `FastPin<DATA_PIN>` compile-time inputs. Engine wiring: - `ChannelEngineLpcSctDma` gains a `LpcSctDmaTransmitter mTransmitter` member. - `show()` picks the first enqueued channel (single-strip v1 — multi-strip is #2879 Stage 4.4), validates pin range (PIO0_0..PIO0_31), and dispatches via `mTransmitter.configureForChannel + mTransmitter.transmit`. - `poll()` probes `mTransmitter.isDone()` to drive the `READY → BUSY → DRAINING → READY` state machine. On LPC845 this reads `DMA0->COMMON[0].ACTIVE`; on host it returns true immediately so the test contract from `tests/fl/channels/lpc_sct_dma_engine.cpp` (#3464) still holds. Host build is preserved: - The runtime helper gates its register-level body on `FL_IS_ARM_LPC_845`; host/stub builds get no-op stubs. - `bash test --cpp` → 342/342 passed (the 10 host test cases from PR #3464 still pass; the engine's `show()` is now a delegating call chain through the no-op transmitter rather than a flag toggle). Style: - All new files use `#pragma once` only — no `#ifndef … #define … #endif` guards. Per user direction. - Macro defaults provided in `lpc_sct_dma_runtime.cpp.hpp` for `FASTLED_LPC_PWM_DMA_BASECH` (0) and the four `FASTLED_LPC_PWM_DMA_SCT_MATCH_*` slots (0/1/2/3). The legacy template path requires the consumer to `-D` these; the runtime form inherits sane defaults so a fresh LPC845 build works without extra flags. What's NOT yet covered (stays open under #3459): - Silicon bench validation. Inherits every `TODO(2842)` from the legacy template — `SYSAHBCLKCTRL0` bit assignments, `EVx_CTRL` / `DMAREQ0` / `CONFIG` layouts, `SRAMBASE` allocation, busy-wait replacement with WFI + DMA-done IRQ. - Multi-strip parallel output (#2879 Stage 4.4). - LPC804 port — 4-channel DMA forbids the 3-channel topology. - The `examples/AutoResearch/AutoResearchPwmDmaClockless.h` validation harness — explicitly itemised in the issue as a separate follow-up; the host test already proves the channels-API contract and the RX side (#3464 → `LpcSctRxChannel`). Refs #3459. Closes the show()/poll() body lift line item from its acceptance criteria. Closes one `TODO(2842)` marker (per-instance encoding buffer). 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 (5)
📝 WalkthroughWalkthroughAdds a new LpcSctDmaTransmitter runtime (header and implementation) for LPC845 SCT+DMA clockless LED output, with real hardware initialization, chunked timing/DMA encoding, and completion polling. Integrates this transmitter into ChannelEngineLpcSctDma's show()/poll() methods, replacing prior scaffold behavior, and adjusts include ordering for unity builds. ChangesSCT+DMA transmitter and engine integration
Sequence Diagram(s)sequenceDiagram
participant Caller
participant ChannelEngineLpcSctDma
participant LpcSctDmaTransmitter
participant SCT0_DMA as SCT0/DMA Hardware
Caller->>ChannelEngineLpcSctDma: show()
ChannelEngineLpcSctDma->>ChannelEngineLpcSctDma: validate queue, pin, pixel data
ChannelEngineLpcSctDma->>LpcSctDmaTransmitter: configureForChannel(pin, t1, t2, t3)
LpcSctDmaTransmitter->>SCT0_DMA: program MATCH/MATCHREL registers
ChannelEngineLpcSctDma->>LpcSctDmaTransmitter: transmit(bytes, len, is_rgbw)
LpcSctDmaTransmitter->>LpcSctDmaTransmitter: encodeChunkFromBytes (per chunk)
LpcSctDmaTransmitter->>SCT0_DMA: arm DMA, release SCT halt
SCT0_DMA-->>LpcSctDmaTransmitter: chunk transfer completes
loop poll()
ChannelEngineLpcSctDma->>LpcSctDmaTransmitter: isDone()
LpcSctDmaTransmitter-->>ChannelEngineLpcSctDma: DRAINING or READY
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related issues
Possibly related PRs
Poem
✨ 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 |
Summary
Closes the
show()/poll()TODO(3459)block left over from the channels-API scaffold in #3460. Hoists the SCT+DMA programming sequence fromclockless_arm_lpc_pwm_dma.h's templatedClocklessControllerinto a runtime form so the channels-API engine can drive it fromChannelData.New files
LpcSctDmaTransmitteris the non-template runtime form of the legacy template'sconfigureSct + configureDma + encodeChunk + startDmaChunk + waitDmaChunksurface. Five methods:init,configureForChannel(pin, t1, t2, t3),transmit(bytes, len, is_rgbw),isDone(). It owns a per-instance 3 × CHUNK_BITS u32 encode buffer — this closes one of theTODO(2842)markers fromclockless_arm_lpc_pwm_dma.h(the legacy template shares one static buffer across all controller instances).Engine wiring
ChannelEngineLpcSctDmagains aLpcSctDmaTransmitter mTransmittermember.show()picks the first enqueued channel (single-strip v1; multi-strip is feat(platform/lpc): multi-strip parallel output for LPC845 (SCT + DMA) — Stage 4.4 from #2845, gated on Stage 2c hardware validation #2879 Stage 4.4), validates the pin lives on PIO0_0..PIO0_31, configures the transmitter for the channel's pin + timing, and runs the chunk-stream transmit loop.poll()probesmTransmitter.isDone(). On LPC845 this readsDMA0->COMMON[0].ACTIVE; on host it returnstrueimmediately so the test contract from test(lpc): host tests for the SCT+DMA channels-API engine + RX round-trip #3464 still holds (the engine settles toREADYon the next poll).DRAININGis now actually reachable on LPC845 — previouslypoll()was scaffold-coded to flip straight back to READY.Issue acceptance criteria closed
READY → BUSY → DRAINING → READYdriven bypoll(); no busy-wait inshow(). (The chunk-stream loop intransmit()does block, matching the legacy template's own pattern. The TODO to swap busy-wait forWFI + DMA-done IRQis inherited.)TODO(2842)fromclockless_arm_lpc_pwm_dma.h— the staticsChannelBufis now per-instance viaLpcSctDmaTransmitter::mChannelBuf.Still open under #3459
TODO(2842)from the legacy template — SYSAHBCLKCTRL0 bit assignments, EVx_CTRL / DMAREQ0 / CONFIG layouts, SRAMBASE allocation, busy-wait → WFI/IRQ.examples/AutoResearch/AutoResearchPwmDmaClockless.hvalidation harness — explicitly itemised in the issue as a separate follow-up.Tests
bash test --cpp— 342/342 passed. The 10 host test cases from test(lpc): host tests for the SCT+DMA channels-API engine + RX round-trip #3464 still pass;show()is now a delegating call chain through the no-op host transmitter rather than a flag toggle, andpoll()probes the (always-true on host)isDone()flag.Style
#pragma onceonly — no#ifndef … #define … #endifguards. The modifiedchannel_engine_lpc_sct_dma.cpp.hppand_build.cpp.hppwere converted to match.lpc_sct_dma_runtime.cpp.hppforFASTLED_LPC_PWM_DMA_BASECH(0) and the fourFASTLED_LPC_PWM_DMA_SCT_MATCH_*slots (0/1/2/3). Legacy template requires-Ds; runtime form inherits sane defaults.Refs
TODO(3459)show/poll bodies and oneTODO(2842)per the issue's acceptance checklist.src/platforms/arm/lpc/clockless_arm_lpc_pwm_dma.his unchanged and can be retired once the channels-API path is bench-validated.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
show().Bug Fixes