Skip to content

LPC845: clockless+DMA channels-API engine — ChannelEngineLpcSctDma wrapping clockless_arm_lpc_pwm_dma.h #3459

Closed

Description

@zackees

Goal

Implement the LPC845 SCT+DMA clockless driver under the channels API (fl::IChannelDriver / ChannelManager / Bus enum), wrapping the existing clockless_arm_lpc_pwm_dma.h engine in a new ChannelEngineLpcSctDma. This is the LPC analogue of ChannelEngineObjectFLED (Teensy 4.x FlexPWM + eDMA) — the canonical "clockless via DMA, parallel-IO peripheral, channels-API-routed" engine in the repo today.

The driver source in src/platforms/arm/lpc/clockless_arm_lpc_pwm_dma.h was landed under the legacy ClocklessController template path. It currently can't be reached through the runtime channels-API dispatch (addLeds<> → BusTraits<Bus::X>::instancePtr() → ChannelManager::show). Lifting it into a channel engine restores parity with the other DMA clockless drivers (ObjectFLED, ESP32 RMT/LCD_CLOCKLESS, PARLIO) and is required before LPC can take part in:

Reference engine

src/platforms/arm/teensy/teensy4_common/drivers/objectfled/ is the model:

  • channel_engine_objectfled.h — class ChannelEngineObjectFLED : public IChannelDriver with state machine READY → BUSY → DRAINING → READY. Groups channels by ChipsetTimingConfig; instantiates one peripheral instance per timing group; caches across frames.
  • channel_engine_objectfled.cpp.hpp — show() routes per-channel on data->isClockless() vs data->isSpi() (Teensy 4 ObjectFLED handles BOTH per the parallel-IO peripheral rule).
  • bus_traits.h — template<> struct BusTraits<Bus::FLEX_IO, 0> { using engine_type = ChannelEngineObjectFLED; static void registerWithManager(); static shared_ptr<engine_type> instancePtr(); }.
  • _build.cpp.hpp — unity-build entry pulled in by src/platforms/_build.cpp.hpp under the platform gate.

Scope of the new LPC engine

Files to land

  • src/platforms/arm/lpc/drivers/sct_dma/channel_engine_lpc_sct_dma.h — declaration of class ChannelEngineLpcSctDma : public IChannelDriver.
  • src/platforms/arm/lpc/drivers/sct_dma/channel_engine_lpc_sct_dma.cpp.hpp — implementation; wraps the existing clockless_arm_lpc_pwm_dma.h engine internals (or absorbs them, since the legacy ClocklessController template path doesn't need to coexist for the same chipset×pin combo).
  • src/platforms/arm/lpc/drivers/sct_dma/bus_traits.h — BusTraits<Bus::BIT_BANG> specialization for LPC845. Note: LPC8xx exposes only Bus::BIT_BANG today (per feat(channels): add LPC DefaultBus<> specializations (#3450 B4) #3451). LPC's SCT is parallel-IO-capable but doesn't fit Bus::FLEX_IO semantically. Decision needed during implementation:
    • Option A: route through Bus::BIT_BANG and make this the LPC-845-only DMA fast path under that slot. Matches today's DefaultBus<ClocklessChipset> = BIT_BANG LPC routing.
    • Option B: add Bus::SCT_DMA (or generic Bus::PARALLEL_IO) to the portable Bus enum if more LPC variants gain similar drivers.
    • Recommend Option A for first cut — keeps the Bus enum stable and matches the channels-API rule that the peripheral is the dispatch boundary, not the mode.
  • src/platforms/arm/lpc/drivers/sct_dma/_build.cpp.hpp — unity-build entry; pulled in by src/platforms/arm/lpc/_build.cpp.hpp under #if defined(FL_IS_ARM_LPC_845) && defined(FASTLED_LPC_PWM_DMA).
  • Update src/fl/channels/bus_priorities.h to put Bus::BIT_BANG priority above the per-byte software bit-bang fallback on LPC (so the DMA fast path wins runtime selection).
  • Update src/platforms/channel_drivers.impl.cpp.hpp LPC arm to call BusTraits<Bus::BIT_BANG>::registerWithManager() for enableAllDrivers().

Parallel-IO peripheral rule applicability

Per CLAUDE.md (project-specific) and src/fl/channels/README.md → "Rule: Parallel-IO peripherals — one engine for both clockless and SPI modes":

Any LED channel-engine wrapping a parallel-IO peripheral (FlexIO, ObjectFLED, ESP32 PARLIO, LCD_CAM, I2S, etc.) MUST handle both its clockless and its SPI mode in the SAME ChannelEngine class.

LPC's SCT is parallel-IO-capable but does not drive SPI — the LPC845 SPI peripheral is a completely separate block (SPI0 @ 0x40058000, SPI1 @ 0x4005C000) with its own SPI DMA engine landing under #3453 Phase 1 (PR #3454). This is the rule's documented exception:

different-peripheral-same-protocol (e.g. ESP32 LPSPI vs I2S_SPI) correctly get separate drivers

So ChannelEngineLpcSctDma is clockless-only (Capabilities(true, false)), and the SPI DMA engine being built in #3456 will land separately as ChannelEngineLpcSpiDma. Do NOT try to unify them.

State machine + show() routing

Match ObjectFLED's pattern verbatim:

  • READY → BUSY → DRAINING → READY driven by poll() reading the SCT DMA channel ACTIVE flag (the existing waitDmaChunk busy-wait becomes a poll()-driven advance).
  • Group channels by ChipsetTimingConfig (so WS2812 + SK6812 don't fight over the SCT match values).
  • One SCT match-register configuration per timing group; the SCT match values are already templated on TIMING::T1/T2/T3 in the existing driver (see LpcSctTicks<> helper) — lift those to runtime traits.
  • show() performs the encode + chunk-stream-kick; poll() advances past the DMA wait.
  • Channel data layout: raw RGB / RGBW bytes via ChannelPixelFormat metadata, same as ObjectFLED. Do NOT infer RGBW from byte counts.

Capabilities

Capabilities capabilities() const noexcept override {
    return Capabilities{
        .clockless = true,
        .spi = false,            // LPC SPI is a separate peripheral; see #3453 Phase 1
        .max_channels_per_show = 1,  // single-strip in v1; multi-strip is #2879
        .async_completion = true,    // DMA + poll() supplies it
    };
}

Acceptance criteria

  • ChannelEngineLpcSctDma registers via BusTraits<Bus::BIT_BANG>::registerWithManager() under the LPC845 + PWM_DMA gate.
  • addLeds<WS2812, PIN, GRB>(leds, N) on LPC845 with -DFASTLED_LPC_PWM_DMA=1 routes to ChannelEngineLpcSctDma::show() via the channels-API path (not the legacy ClocklessController template), verified by stepping into the dispatch in a debug build.
  • State machine transitions READY → BUSY → DRAINING → READY driven by poll(); no busy-wait in show().
  • Host-side compile-only smoke: 340/340 unit tests still pass; ESP32-S3 and Teensy 4 default builds unaffected (the new files self-gate).
  • An on-device validation harness — examples/AutoResearch/AutoResearchPwmDmaClockless.h + --pwm-dma-cl host flag — lands as a separate follow-up (paired sibling of AutoResearch: SPI-DMA validation harness for LPC845 (Phase 1 of #3453 bench bring-up) #3456 for the SPI side).
  • At least one TODO(2842) marker from the underlying clockless_arm_lpc_pwm_dma.h is closed out as a result of the channels-API wiring (probably the static sChannelBuf move-to-per-instance, since the channel engine now owns instance state).

Dependencies

Hard-blocked by (same toolchain blockers as the rest of the LPC bring-up):

  1. [META] LPC8xx compile + autoresearch + channels API end-to-end restoration — all blockers #3450 B1 — fbuild matcher (fix(core): match nxp-lpc (hyphenated GitHub form) in platform parser fbuild#900 open) → fbuild 2.3.15 release → pyproject.toml bump.
  2. [META] LPC8xx compile + autoresearch + channels API end-to-end restoration — all blockers #3450 B2 — framework-arduino-lpc8xx tarball checksum mismatch.

Soft-blocked by:

  1. [BLOCKER] LPC845-BRK AutoResearch bring-up echo returns empty RX (suspected HardFault) — blocks #3102 #3300 — AutoResearch echo silence (for the eventual bench bring-up).
  2. feat(platform): LPC845 PWM+DMA-to-GPIO clockless driver (Stage 2c of #2836) #2842 — the original PWM-DMA clockless Stage 2c bench validation. Channels-API wiring lands cleanly without it but adds a second user of an unvalidated DMA stream until silicon confirms.

Out of scope:

Relationships

Activity

  1. zackees commented on Jun 30, 2026

    @zackees
    MemberAuthor

    @phatpaul — heads up that the channels-API scaffold for the LPC845 SCT+DMA engine just landed as #3460 (admin-merged into master as ddbadc49c1).

    The plumbing is in:

    • src/platforms/arm/lpc/drivers/sct_dma/channel_engine_lpc_sct_dma.{h,cpp.hpp} — IChannelDriver subclass with READY → BUSY → DRAINING → READY state machine.
    • BusTraits<Bus::BIT_BANG> specialization (LPC routes clockless under BIT_BANG — see PR feat(channels): add LPC DefaultBus<> specializations (#3450 B4) #3451 for the DefaultBus<> rationale).
    • channel_drivers_lpc.impl.hpp fragment so fl::enableAllDrivers() registers it.
    • LPC arm added to the top-level channel_drivers.impl.cpp.hpp dispatcher.

    What's intentionally deferred to follow-up (documented as TODO(3459) in the source): show()/poll() bodies that lift LpcSctTicks, configureSct(), configureDma(), startDmaChunk(), waitDmaChunk() from the legacy template engine in clockless_arm_lpc_pwm_dma.h and iterate them across mEnqueuedChannels. Today show() is a no-op past state transitions — the channels-API dispatch path is reachable but does not transmit yet.

    One callout for the validation side: while writing this I went back and looked at src/platforms/arm/lpc/rx_sct_capture.cpp.hpp and noticed the begin() body is fully implemented now (both polling under FASTLED_LPC_RX_SCT and the autonomous DMA path under FASTLED_LPC_RX_SCT_DMA, with real SCT/SWM/INPUTMUX/DMA register sequencing per UM11029 §10/§14/§16/§21). So the self-loopback validation harness sketched in #3015 / #3456 has a working RX side to lean on once show() gets its body. Worth knowing if you pick this up.

    Same toolchain blockers still apply on the bench side: #3300 echo bring-up and #3450 B2 (framework-arduino-lpc8xx tarball checksum). fbuild 2.3.15 already landed (closing #3450 B1).

  2. moved this from Triage to Done in FastLED Trackeron Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions