Repository navigation
Description
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:
- The
fl::DefaultBus<ClocklessChipset>runtime routing (added for LPC in feat(channels): add LPC DefaultBus<> specializations (#3450 B4) #3451). - Multi-driver / runtime driver switching via
fl::enableAllDrivers(). - Any future channels-API-only convenience surface (
FastLED.setBus(Bus::...)-style selectors, channel-API benchmarks).
Reference engine
src/platforms/arm/teensy/teensy4_common/drivers/objectfled/ is the model:
channel_engine_objectfled.h—class ChannelEngineObjectFLED : public IChannelDriverwith state machineREADY → BUSY → DRAINING → READY. Groups channels byChipsetTimingConfig; instantiates one peripheral instance per timing group; caches across frames.channel_engine_objectfled.cpp.hpp—show()routes per-channel ondata->isClockless()vsdata->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 bysrc/platforms/_build.cpp.hppunder 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 ofclass ChannelEngineLpcSctDma : public IChannelDriver. -
src/platforms/arm/lpc/drivers/sct_dma/channel_engine_lpc_sct_dma.cpp.hpp— implementation; wraps the existingclockless_arm_lpc_pwm_dma.hengine internals (or absorbs them, since the legacyClocklessControllertemplate 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 onlyBus::BIT_BANGtoday (per feat(channels): add LPC DefaultBus<> specializations (#3450 B4) #3451). LPC's SCT is parallel-IO-capable but doesn't fitBus::FLEX_IOsemantically. Decision needed during implementation:- Option A: route through
Bus::BIT_BANGand make this the LPC-845-only DMA fast path under that slot. Matches today'sDefaultBus<ClocklessChipset> = BIT_BANGLPC routing. - Option B: add
Bus::SCT_DMA(or genericBus::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.
- Option A: route through
-
src/platforms/arm/lpc/drivers/sct_dma/_build.cpp.hpp— unity-build entry; pulled in bysrc/platforms/arm/lpc/_build.cpp.hppunder#if defined(FL_IS_ARM_LPC_845) && defined(FASTLED_LPC_PWM_DMA). - Update
src/fl/channels/bus_priorities.hto putBus::BIT_BANGpriority 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.hppLPC arm to callBusTraits<Bus::BIT_BANG>::registerWithManager()forenableAllDrivers().
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 → READYdriven bypoll()reading the SCT DMA channelACTIVEflag (the existingwaitDmaChunkbusy-wait becomes apoll()-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/T3in the existing driver (seeLpcSctTicks<>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
ChannelPixelFormatmetadata, 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
-
ChannelEngineLpcSctDmaregisters viaBusTraits<Bus::BIT_BANG>::registerWithManager()under the LPC845 + PWM_DMA gate. -
addLeds<WS2812, PIN, GRB>(leds, N)on LPC845 with-DFASTLED_LPC_PWM_DMA=1routes toChannelEngineLpcSctDma::show()via the channels-API path (not the legacyClocklessControllertemplate), verified by stepping into the dispatch in a debug build. - State machine transitions
READY → BUSY → DRAINING → READYdriven bypoll(); no busy-wait inshow(). - 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-clhost 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 underlyingclockless_arm_lpc_pwm_dma.his closed out as a result of the channels-API wiring (probably the staticsChannelBufmove-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):
- [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.tomlbump. - [META] LPC8xx compile + autoresearch + channels API end-to-end restoration — all blockers #3450 B2 —
framework-arduino-lpc8xxtarball checksum mismatch.
Soft-blocked by:
- [BLOCKER] LPC845-BRK AutoResearch bring-up echo returns empty RX (suspected HardFault) — blocks #3102 #3300 — AutoResearch echo silence (for the eventual bench bring-up).
- 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:
- Multi-strip parallel SCT output — that's 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 and gets its own engine work once single-strip is signed off.
- LPC804 port — LPC804's 4-channel DMA limits the SCT+DMA engine to single-strip and may need a different opt-in macro. Tracked under meta: LPC dev roadmap — Stages 3 + 4 (port completion, family expansion) #2845 Stage 4.
- Migrating LPC's legacy
ClocklessControllertemplate users to the channels API. The two paths can coexist for now; user-facingaddLeds<>keeps working through either.
Relationships
- Direct follow-up to PR feat(channels): add LPC DefaultBus<> specializations (#3450 B4) #3451 (LPC
DefaultBus<>specializations) — the trait saysBus::BIT_BANG, this engine fills in what BIT_BANG resolves to. - Sibling of the SPI DMA engine work (PR feat(lpc): LPC845 SPI + DMA0 async driver — Phase 1 of #3453 #3454 source / AutoResearch: SPI-DMA validation harness for LPC845 (Phase 1 of #3453 bench bring-up) #3456 validation harness).
- Part of the [META] LPC8xx compile + autoresearch + channels API end-to-end restoration — all blockers #3450 meta restoration plan (one of the things "channels API bring-up for LPC" actually means).
- Reference engine:
src/platforms/arm/teensy/teensy4_common/drivers/objectfled/. - Rule references:
src/fl/channels/README.md+agents/docs/cpp-standards.md→ "Parallel-IO Driver: Unified Clockless + SPI Engine".
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
feat(lpc): channels-API SCT+DMA clockless engine scaffold (#3459) (#3460
zackees commentedon Jun 30, 2026
@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}—IChannelDriversubclass withREADY → BUSY → DRAINING → READYstate machine.BusTraits<Bus::BIT_BANG>specialization (LPC routes clockless underBIT_BANG— see PR feat(channels): add LPC DefaultBus<> specializations (#3450 B4) #3451 for theDefaultBus<>rationale).channel_drivers_lpc.impl.hppfragment sofl::enableAllDrivers()registers it.channel_drivers.impl.cpp.hppdispatcher.What's intentionally deferred to follow-up (documented as
TODO(3459)in the source):show()/poll()bodies that liftLpcSctTicks,configureSct(),configureDma(),startDmaChunk(),waitDmaChunk()from the legacy template engine inclockless_arm_lpc_pwm_dma.hand iterate them acrossmEnqueuedChannels. Todayshow()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.hppand noticed thebegin()body is fully implemented now (both polling underFASTLED_LPC_RX_SCTand the autonomous DMA path underFASTLED_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 onceshow()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).
feat(lpc): wire show()/poll() body via runtime SCT+DMA transmitter (#…
fix(lpc): unblock LPC845 compile path for SCT+DMA channels-API engine (…
feat(lpc): drive SCT+DMA chunk progression via poll() — no busy-wait (F…