Skip to content

feat(lpc): wire show()/poll() body via runtime SCT+DMA transmitter (#3459) - #3466

Merged
zackees merged 1 commit into
masterfrom
feat/3459-show-body-lift
Jul 1, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/3459-show-body-lift

Conversation

@zackees

@zackees zackees commented Jun 30, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes the show()/poll() TODO(3459) block left over from the channels-API scaffold in #3460. 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 helpers + transmitter class
  lpc_sct_dma_runtime.cpp.hpp  — LPC845 register impl + host no-op stubs

LpcSctDmaTransmitter is the non-template runtime form of the legacy template's configureSct + configureDma + encodeChunk + startDmaChunk + waitDmaChunk surface. 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 the TODO(2842) markers from clockless_arm_lpc_pwm_dma.h (the legacy template shares one static buffer across all controller instances).

Engine wiring

ChannelEngineLpcSctDma gains a LpcSctDmaTransmitter mTransmitter member.

Issue acceptance criteria closed

  • State machine transitions READY → BUSY → DRAINING → READY driven by poll(); no busy-wait in show(). (The chunk-stream loop in transmit() does block, matching the legacy template's own pattern. The TODO to swap busy-wait for WFI + DMA-done IRQ is inherited.)
  • Close at least one TODO(2842) from clockless_arm_lpc_pwm_dma.h — the static sChannelBuf is now per-instance via LpcSctDmaTransmitter::mChannelBuf.

Still open under #3459

Tests

Style

  • All new files use #pragma once only — no #ifndef … #define … #endif guards. The modified channel_engine_lpc_sct_dma.cpp.hpp and _build.cpp.hpp were converted to match.
  • 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). Legacy template requires -Ds; runtime form inherits sane defaults.

Refs

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added runtime support for LPC845 SCT+DMA channel output, enabling faster clockless LED updates on supported hardware.
    • Improved transmission handling so queued channel data is configured and sent automatically during show().
  • Bug Fixes

    • Fixed the channel engine state flow so it now waits for transmission to finish before returning to ready state.
    • Added validation for missing data and invalid pin ranges to avoid failed updates.

…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]>
@coderabbitai

coderabbitai Bot commented Jun 30, 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: 86822e7b-501c-49d5-bc7d-2316f593e687

📥 Commits

Reviewing files that changed from the base of the PR and between 5eddaa9 and 90bfe71.

📒 Files selected for processing (5)
  • src/platforms/arm/lpc/drivers/sct_dma/_build.cpp.hpp
  • src/platforms/arm/lpc/drivers/sct_dma/channel_engine_lpc_sct_dma.cpp.hpp
  • src/platforms/arm/lpc/drivers/sct_dma/channel_engine_lpc_sct_dma.h
  • src/platforms/arm/lpc/drivers/sct_dma/lpc_sct_dma_runtime.cpp.hpp
  • src/platforms/arm/lpc/drivers/sct_dma/lpc_sct_dma_runtime.h

📝 Walkthrough

Walkthrough

Adds 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.

Changes

SCT+DMA transmitter and engine integration

Layer / File(s) Summary
Transmitter class declaration
src/platforms/arm/lpc/drivers/sct_dma/lpc_sct_dma_runtime.h
Declares LpcSctDmaTransmitter with init, configureForChannel, transmit, isDone, private per-instance chunk-stream buffers/timing state, and a lpc_sct_ticks nanoseconds-to-ticks helper, gated for LPC845/host builds.
Transmitter runtime implementation
src/platforms/arm/lpc/drivers/sct_dma/lpc_sct_dma_runtime.cpp.hpp
Implements SCT/DMA peripheral init, per-channel timing configuration, chunked byte-to-DMA-stream encoding (encodeChunkFromBytes), chunked transmit loop with DMA arming/SCT halt-release, isDone polling via DMA active bits, and host/stub no-op equivalents.
Engine integration
src/platforms/arm/lpc/drivers/sct_dma/channel_engine_lpc_sct_dma.h, .../channel_engine_lpc_sct_dma.cpp.hpp, .../_build.cpp.hpp
Adds mTransmitter member, includes runtime header, reworks show() to validate queue/pin/data and configure+start transmission, changes poll() to return DRAINING until isDone(), and reorders unity-build includes.

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
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related issues

Possibly related PRs

  • FastLED/FastLED#2850: Implements the same LPC845 SCT+DMA chunked, match-driven DMA streaming approach at the ClocklessController level.
  • FastLED/FastLED#3460: Earlier scaffold PR for the same channel_engine_lpc_sct_dma driver that this PR now completes with real transmitter logic.
  • FastLED/FastLED#3464: Modifies the same channel_engine_lpc_sct_dma.cpp.hpp/.h compilation gates and show()/timing paths touched here.

Poem

A bunny hops through SCT and DMA lanes,
Match ticks rising, falling, no more scaffolds' chains.
🐇 Chunks of pixels stream out bit by bit,
isDone() whispers when the glow shall sit.
Carrots counted, channels queued with care —
LPC845 lights now dance in the air!

✨ 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/3459-show-body-lift

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: Done

Development

Successfully merging this pull request may close these issues.

1 participant