Repository navigation
feat(lpc): LPC845 SPI + DMA0 async driver — Phase 1 of #3453 - #3454
Conversation
Adds `src/platforms/arm/lpc/spi_arm_lpc_dma.h`: a drop-in async peer of
the polled `ARMHardwareSPIOutput` from `spi_arm_lpc.h`. Streams a frame
to SPI0/SPI1 via a DMA0 channel tied to the SPI block's TX request line
so the CPU can sit in WFI during transmission instead of busy-waiting
on `STAT.TXRDY`. Same template surface as the polled driver — users
swap by gating on `FASTLED_LPC_SPI_DMA` without changing `addLeds<>`
call sites.
Wired into `fastled_arm_lpc.h` after the polled include; the new file
self-gates with `#if defined(FL_IS_ARM_LPC_845) && defined(FASTLED_LPC_SPI_DMA)`
so default LPC845 builds keep the polled driver and other LPC variants
(LPC804 / LPC11Uxx / LPC15xx) compile out cleanly.
Engine design follows the LPC845 conventions already established in
`clockless_arm_lpc_pwm_dma.h`:
- `DMA0->CHANNEL[ch].CFG = PERIPHREQEN` — SPI's TXRDY drives descriptor
consumption, one byte per request, no `HWTRIGEN` needed.
- Default channel is 4 (UM11029 Table 80 conventional SPI0_TX). With
the PWM-DMA clockless driver's default `_BASECH=0` consuming channels
0/1/2, the defaults don't collide.
- TXCTL latched once at `init()` with `LEN_8BIT | RXIGNORE`. The DMA
stream writes halfwords to TXDAT and inherits the latched control,
so we don't burn a u32-per-byte by widening to TXDATCTL.
- Byte → u16 widening into a static 2 KB encode buffer (tunable via
`FASTLED_LPC_SPI_DMA_MAX_BYTES`), then a single `SETVALID` to arm.
The encode pass is the only CPU work per frame; transmission itself
is hardware-driven.
- `done()` / `waitDma()` expose the channel `ACTIVE` flag for the async
contract; `waitFully()` drains DMA + SPI master shift register.
Per-byte and per-bit primitives (`writeByte`, `writeBit`, `writeWord`)
remain polled — arming a one-byte DMA descriptor costs more than the
TXRDY spin, and APA102's per-LED `FLAG_START_BIT` is a single-frame
write anyway.
**Untested on silicon.** Phase 1 ships register-level wiring per
UM11029 §15 (SPI) and §17 (DMA) and is host-compile clean (340/340
unit tests pass), but cannot be bench-validated from this session
because:
- The LPC compile path on master is broken at the fbuild matcher
level (meta #3450 B1; PR FastLED/fbuild#900 open).
- The framework-arduino-lpc8xx tarball checksum mismatch (#3450 B2)
blocks the platform install after B1 lands.
- AutoResearch echo bring-up (#3300) is the gate for any real
on-device RPC validation.
Marking the PR as Draft per the user's "Full draft, marked WIP" call
on the /clud-pr scope question; explicit `TODO(3453)` markers point
at every spot most likely to need silicon-side adjustment (TXCTL
persistence semantics, SYSCON power-up bits, BURSTPOWER default,
INMUX wiring above channel 15, SRAMBASE allocation, chunked-stream
support for frames > buffer capacity).
Implements #3453 Phase 1 source. Phase 2 (clockless PWM-DMA bench
validation + multi-strip) and the meta's other blockers (B1/B2/B3
fbuild work, #3300 hardware echo) stay tracked separately.
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 (2)
📝 WalkthroughWalkthroughAdds a new opt-in LPC845 SPI+DMA0 asynchronous SPI driver header ( ChangesLPC845 SPI+DMA0 driver
Sequence Diagram(s)sequenceDiagram
participant Caller
participant ARMHardwareSPIOutputDMA
participant sEncodeBuf
participant DMA0
participant SPI
Caller->>ARMHardwareSPIOutputDMA: select()
ARMHardwareSPIOutputDMA->>SPI: init() configure master mode
Caller->>ARMHardwareSPIOutputDMA: writeBytes(data, len)
loop per chunk (up to FASTLED_LPC_SPI_DMA_MAX_BYTES)
ARMHardwareSPIOutputDMA->>sEncodeBuf: encode bytes into u16 entries
ARMHardwareSPIOutputDMA->>DMA0: configureChannelDescriptor + SETVALID
DMA0->>SPI: stream TXDAT halfwords
ARMHardwareSPIOutputDMA->>DMA0: waitDma() poll ACTIVE flag
end
ARMHardwareSPIOutputDMA->>SPI: waitFully() drain + MSTIDLE
ARMHardwareSPIOutputDMA->>ARMHardwareSPIOutputDMA: release()
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 |
) Wires LPC845 into the runtime channels-API dispatch path. The legacy template clockless engine in `clockless_arm_lpc_pwm_dma.h` was unreachable from `BusTraits<Bus::X>::instancePtr()` → `ChannelManager` because no `IChannelDriver` subclass wrapped it. This change lifts the peripheral onto the channels API, matching the structural pattern established by `ChannelEngineObjectFLED` on Teensy 4. New driver tree: src/platforms/arm/lpc/drivers/sct_dma/ channel_engine_lpc_sct_dma.h — IChannelDriver subclass channel_engine_lpc_sct_dma.cpp.hpp — impl (scaffold + state machine) bus_traits.h — BusTraits<Bus::BIT_BANG> _build.cpp.hpp — unity build entry Plus the platform dispatch wiring: src/platforms/arm/lpc/channel_drivers_lpc.impl.hpp — new fragment src/platforms/arm/lpc/_build.cpp.hpp — pull in sct_dma/ src/platforms/channel_drivers.impl.cpp.hpp — add FL_IS_ARM_LPC arm Routing decisions: - Registers under `Bus::BIT_BANG` to match `DefaultBus<ClocklessChipset> = Bus::BIT_BANG` that landed for LPC in PR #3451. The portable Bus enum has no `SCT_DMA` slot; the channels-API convention is that the peripheral is the dispatch boundary, not the protocol mode, so reusing `BIT_BANG` for the LPC parallel-IO clockless peripheral is consistent with `Bus::FLEX_IO` covering Teensy FlexPWM AND ESP32 LCD_CAM/I2S/PARLIO. - `Capabilities(true, false)` — clockless only. LPC's SCT does not drive SPI; the LPC845 SPI block is a separate peripheral with its own DMA engine in `spi_arm_lpc_dma.h` (PR #3454). This is the documented "different-peripheral-same-protocol" exception to the parallel-IO unification rule in `src/fl/channels/README.md`. - `canHandle()` filters to clockless WS2812-range chipsets (total bit period 1000-2500 ns) — same convention as ObjectFLED. **Scaffold status.** The channels-API surface (canHandle / enqueue / show / poll / capabilities / name) is in. The actual SCT match-register programming + 3-channel DMA chunk-stream lift from `clockless_arm_lpc_pwm_dma.h` is intentionally a documented `TODO(3459)` block in `show()`/`poll()`. The state machine transitions through `READY → BUSY → DRAINING → READY` so the manager doesn't stall, but `show()` does not actually program the SCT in v1. This mirrors the scaffold convention used for `rx_sct_capture.h::begin()` (#3015) and `spi_arm_lpc_dma.h` (PR #3454) — channels-API plumbing first, peripheral body next. The structural lift required for the follow-up is itemised in the `TODO(3459)` comment: convert `LpcSctTicks<NS>` from compile-time template helper to runtime helper, hoist `configureSct/configureDma/startDmaChunk/waitDmaChunk` out of the templated `ClocklessController`, and iterate enqueued channels through the lifted helper (single-strip v1 just takes the first; multi-strip parallel is #2879). Host-compile clean: `bash test --cpp` 340/340 passed. The new files self-gate on `FL_IS_ARM_LPC_845`, so default builds on every other platform are unaffected. Untested on silicon — same blockers as #3454 on the bench-validation side (#3300 echo bring-up still open). fbuild matcher (#3450 B1) IS resolved in fbuild 2.3.15 which just landed in master, so the LPC compile path itself can be exercised once #3450 B2 (framework-arduino-lpc8xx tarball checksum) clears. Implements #3459 scaffold. Issue stays open until the `TODO(3459)` show()/poll() body lands and at least one on-device frame transmits through the channels-API path. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
…ers (#3502) - Fix stale LPC845 clock reference (30 MHz -> actual 24 MHz FRO direct path per led_sysdefs_arm_lpc.h:49). - Add newly shipped drivers to the Supported Platforms table: - LPC845 SCT+DMA channels-API engine (#3460, TX->RX byte-match verified #3472) - LPC845 SPI+DMA async driver (#3454) - LPC804 SPI+DMA async gate (#3500, requires fbuild >= 2.3.16 for LPC804 CMSIS DMA0 typedef from framework-arduino-lpc8xx#35 + fbuild#916) - Document new files under Files: spi_arm_lpc_dma.h, drivers/sct_dma/*, rx_sct_capture.{h,cpp.hpp}. - Document new opt-in feature defines: FASTLED_LPC_SPI_DMA, FASTLED_LPC_SPI_DMA_CHANNEL, FASTLED_LPC_SPI_DMA_MAX_BYTES. - Add recent shipped PRs (#3438 register-map remediation, #3454, #3460, #3472, #3500) and cross-repo prerequisites (framework-arduino-lpc8xx#35, fbuild#916). - Add open follow-ups #3437 (register-map meta), #3501 (LPC11Uxx/LPC15xx SPI), fbuild#565 (CMSIS-DAP deploy). No code changes. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
…3456) (#3503) Phase 1 of the #3453 bench bring-up series. Adds the device-side + host-side plumbing to exercise `ARMHardwareSPIOutputDMA<>` (from #3454) on real LPC845 silicon via the AutoResearch RPC contract, following the same pattern as `--pwm-dma-cl` (#3468). Device-side (`examples/AutoResearch/AutoResearchSpiDma.h`, self-gated on `FL_IS_ARM_LPC_845 && FASTLED_LPC_SPI_DMA`) exposes three RPC handlers: - `dmaSpiTransferOnce(byte_count, byte_pattern)` — single-shot DMA transfer with CPU-poll wait; reports timing. - `dmaSpiTransferOverlap(byte_count, byte_pattern)` — kicks the stream then runs a `volatile` beacon-toggle counter until `done()`. Non-zero counter under DMA load is the affirmative async claim. - `dmaSpiMeasureSck(divider_hint)` — 512-byte burst; host computes effective SCK Hz via wall-clock (no SCT capture — that's #3015 territory). Wired into `AutoResearchLowMemory.h` with a compile-time `#error` if the user tries to combine `FASTLED_LPC_SPI_DMA` with `FASTLED_LPC_PWM_DMA` (both claim DMA0 and the LowMemory flash budget doesn't fit both). Host-side: - `--dma-spi` flag on `bash autoresearch`, LPC845-only, mutually exclusive with `--pwm-dma-cl` (both would fight over DMA0 channels). - New `_run_lpc_dma_spi_tests` phase entry in `ci/autoresearch/phases.py`. - `ci/autoresearch/test_lpc_dma_spi.py` test runner: 4 cases — transferOnce@32B, transferOnce@256B (crosses driver's DMA-vs-polled fast-path threshold at 16B), transferOverlap@512B (async proof), measureSck@512B (±25 % band vs. compile-time divider). The user compiles with `-DFASTLED_LPC_SPI_DMA=1` (add to platformio.ini or fbuild config) before running the wrapper. Silicon validation deferred to next hardware bring-up run — the harness compiles clean on host (WASM + `bash test --cpp` 344/344 green) and gates out on all non-LPC targets. Closes #3456 (harness deliverable). #3453 Phase 1 device-side plumbing done; Phase 2 (clockless SCT+DMA) was already delivered via `--pwm-dma-cl` (#3468). Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
… A.2) Delivers Phase A.2 of the LPC845 DMA-driver burn-down meta issue. ## Changes 1. **`src/platforms/arm/lpc/clockless_channel_lpc.h`** (new) — LPC845 `ClocklessController<>` template that routes classic `addLeds<WS2812, PIN, GRB>()` through the SCT+DMA channels-API engine via `BusTraits<Bus::BIT_BANG>::instancePtr()`. Mirrors the pattern from `src/platforms/wasm/clockless_channel_wasm.h` and `src/platforms/stub/clockless_channel_stub.h`. Sets `FL_CLOCKLESS_CONTROLLER_DEFINED` so the classic template selection downstream sees the adapter first. Only compiles when `FL_IS_ARM_LPC_845 && FASTLED_LPC_PWM_DMA` — vanilla LPC845 builds without the flag stay on the bit-bang default. 2. **`src/platforms/arm/lpc/fastled_arm_lpc.h`** — dispatch reorder. `FASTLED_LPC_PWM_DMA=1` now picks the channels-API adapter instead of the legacy `clockless_arm_lpc_pwm_dma.h` template. The bit-bang default is still included on any build that has NOT set `FL_CLOCKLESS_CONTROLLER_DEFINED` above it. The legacy header is no longer transitively pulled in on any path — it's slated for retirement per #3517 Phase A.3 once silicon validation confirms parity. 3. **`src/fl/remote/rpc/type_to_json.h`** — fix pre-existing u32/u16 overload ambiguity. Adding an explicit `TypeToJson<fl::u32>` / `TypeToJson<fl::u16>` specialization routes unsigned 32/16-bit values through the `i64` json constructor. Without this, GCC 15 flags: error: call of overloaded 'json(const long unsigned int&)' is ambiguous for any RPC handler that carries a `fl::u32` (e.g. `pwmDmaClFrameOnce(int, fl::u32 rgb, int)` from `AutoResearchPwmDmaClockless.h`). Bug was masked before this PR because the legacy `clockless_arm_lpc_pwm_dma.h` compile error short-circuited the build earlier — the new adapter path exposes it because it actually compiles. ## Measured flash-budget impact on LPC845 - Vanilla AutoResearch: **53.29 KB / 64 KB (83.3%)** — unchanged (my Phase A.2 adapter is compile-gated on `FASTLED_LPC_PWM_DMA`, not active in vanilla) - With `-DFASTLED_LPC_PWM_DMA=1`: **64.23 KB — 236 bytes OVER budget** Before this PR: `-DFASTLED_LPC_PWM_DMA=1` failed to compile at all (`FASTLED_LPC_PWM_DMA_CHUNK_BITS undeclared` + `FastPin<>` template visibility errors from the abandoned legacy header). After this PR: it compiles, links to 64.23 KB. The remaining 236 B is a real budget gap that Phase A.3 (retire the legacy template file entirely) and/or the `FL_AUTORESEARCH_LITE_RPC` implementation (from #3522) will close. ## Verification - [x] `bash test --cpp` — 344/344 tests pass - [x] `bash compile wasm --examples AutoResearch` — clean - [x] `bash bloat lpc845` vanilla — 53.29 KB (unchanged) - [ ] Silicon validation of `--pwm-dma-cl` — env-blocked (pyocd hangs enumerating CMSIS-DAP on this Windows session; #3517 Phase A.1 acceptance requires working flash + serial round-trip) Refs: #3517 (meta), #3460 (channels engine PR), #3468 (host TX→RX byte-match), #3454 (SPI DMA driver), #3522 (LITE_RPC tier define + CHUNK_BITS bug fix). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
… A.2) (#3527) * feat(autoresearch): FL_AUTORESEARCH_LITE_RPC tier define + fix LPC PWM_DMA CHUNK_BITS Two related additions from planning the AutoResearch flash-budget squeeze on LPC845 (#3517 Phase A prerequisite): 1. `FL_AUTORESEARCH_LITE_RPC` — auto-derived from the existing memory tier (`!FL_PLATFORM_HAS_LARGE_MEMORY`). On LPC8xx / AVR Uno-class / STM32F1 / ESP8266 / Teensy LC/3.0-3.2 / Renesas UNO / ATtiny 2-3 KB it evaluates to 1 by default. Users can override with `-DFL_AUTORESEARCH_LITE_RPC=0` to force full-fat mode on a low-memory platform (will overflow) or `-DFL_AUTORESEARCH_LITE_RPC=1` to force lite mode on a large-memory platform (useful for measuring what lite mode ships). Follows the same override / `_OVERRIDDEN` flag pattern as the sibling `FL_PLATFORM_HAS_LARGE_MEMORY` tier defines. Rationale: LPC845 vanilla AutoResearch sits at 53.3 KB / 64 KB (83%). Adding `FASTLED_LPC_PWM_DMA=1` and/or `FASTLED_LPC_SPI_DMA=1` (the #3517 Phase A/B silicon acceptance payloads) will push over budget without a lite path. Ownership of the actual RPC-infrastructure swap-out (JSON → line-based text or protobuf) is a follow-up decision; this define lands first so the gate exists. 2. `src/platforms/arm/lpc/clockless_arm_lpc_pwm_dma.h` — add a defensive `#ifndef FASTLED_LPC_PWM_DMA_CHUNK_BITS #define ... 64u #endif` at the top. The macro used to live in the legacy template header; it was moved into the channels-API runtime helper (`drivers/sct_dma/lpc_sct_dma_runtime.h`) as part of PR #3460 without leaving a fallback for the legacy path. Result: any user building with `-DFASTLED_LPC_PWM_DMA=1` on top of `addLeds<>` today hits `error: 'FASTLED_LPC_PWM_DMA_CHUNK_BITS' was not declared in this scope`. Fixed here so the legacy template compiles again while #3517 Phase A.3 retirement is being planned. ## Verification - `bash test --cpp` — 344/344 pass - `bash bloat lpc845 --allow-overflow` — vanilla AutoResearch still fits at 53.3 KB / 64 KB (83.3%) — the tier define has zero code footprint when it evaluates to auto-default Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * feat(lpc): route addLeds<WS2812> through channels engine (#3517 Phase A.2) Delivers Phase A.2 of the LPC845 DMA-driver burn-down meta issue. ## Changes 1. **`src/platforms/arm/lpc/clockless_channel_lpc.h`** (new) — LPC845 `ClocklessController<>` template that routes classic `addLeds<WS2812, PIN, GRB>()` through the SCT+DMA channels-API engine via `BusTraits<Bus::BIT_BANG>::instancePtr()`. Mirrors the pattern from `src/platforms/wasm/clockless_channel_wasm.h` and `src/platforms/stub/clockless_channel_stub.h`. Sets `FL_CLOCKLESS_CONTROLLER_DEFINED` so the classic template selection downstream sees the adapter first. Only compiles when `FL_IS_ARM_LPC_845 && FASTLED_LPC_PWM_DMA` — vanilla LPC845 builds without the flag stay on the bit-bang default. 2. **`src/platforms/arm/lpc/fastled_arm_lpc.h`** — dispatch reorder. `FASTLED_LPC_PWM_DMA=1` now picks the channels-API adapter instead of the legacy `clockless_arm_lpc_pwm_dma.h` template. The bit-bang default is still included on any build that has NOT set `FL_CLOCKLESS_CONTROLLER_DEFINED` above it. The legacy header is no longer transitively pulled in on any path — it's slated for retirement per #3517 Phase A.3 once silicon validation confirms parity. 3. **`src/fl/remote/rpc/type_to_json.h`** — fix pre-existing u32/u16 overload ambiguity. Adding an explicit `TypeToJson<fl::u32>` / `TypeToJson<fl::u16>` specialization routes unsigned 32/16-bit values through the `i64` json constructor. Without this, GCC 15 flags: error: call of overloaded 'json(const long unsigned int&)' is ambiguous for any RPC handler that carries a `fl::u32` (e.g. `pwmDmaClFrameOnce(int, fl::u32 rgb, int)` from `AutoResearchPwmDmaClockless.h`). Bug was masked before this PR because the legacy `clockless_arm_lpc_pwm_dma.h` compile error short-circuited the build earlier — the new adapter path exposes it because it actually compiles. ## Measured flash-budget impact on LPC845 - Vanilla AutoResearch: **53.29 KB / 64 KB (83.3%)** — unchanged (my Phase A.2 adapter is compile-gated on `FASTLED_LPC_PWM_DMA`, not active in vanilla) - With `-DFASTLED_LPC_PWM_DMA=1`: **64.23 KB — 236 bytes OVER budget** Before this PR: `-DFASTLED_LPC_PWM_DMA=1` failed to compile at all (`FASTLED_LPC_PWM_DMA_CHUNK_BITS undeclared` + `FastPin<>` template visibility errors from the abandoned legacy header). After this PR: it compiles, links to 64.23 KB. The remaining 236 B is a real budget gap that Phase A.3 (retire the legacy template file entirely) and/or the `FL_AUTORESEARCH_LITE_RPC` implementation (from #3522) will close. ## Verification - [x] `bash test --cpp` — 344/344 tests pass - [x] `bash compile wasm --examples AutoResearch` — clean - [x] `bash bloat lpc845` vanilla — 53.29 KB (unchanged) - [ ] Silicon validation of `--pwm-dma-cl` — env-blocked (pyocd hangs enumerating CMSIS-DAP on this Windows session; #3517 Phase A.1 acceptance requires working flash + serial round-trip) Refs: #3517 (meta), #3460 (channels engine PR), #3468 (host TX→RX byte-match), #3454 (SPI DMA driver), #3522 (LITE_RPC tier define + CHUNK_BITS bug fix). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
…arness (#3537) `examples/AutoResearch/AutoResearchSpiDma.h` line 88 declares `HarnessDriver` as `ARMHardwareSPIOutputDMA<...>` without the `fl::` namespace prefix. The template lives in `namespace fl` inside `src/platforms/arm/lpc/spi_arm_lpc_dma.h`, and the harness itself is in `namespace autoresearch { namespace dma_spi { ... } }` — so the bare name never resolves. Under #3517 Phase B silicon-validation attempt (build LPC845 AutoResearch with `-DFASTLED_LPC_SPI_DMA=1`), the compile fails with: src/sketch/AutoResearchSpiDma.h:88: error: 'ARMHardwareSPIOutputDMA' does not name a type src/sketch/AutoResearchSpiDma.h:101: error: 'HarnessDriver' does not name a type src/sketch/AutoResearchSpiDma.h:128: error: 'HarnessDriver' was not declared in this scope (... plus 7 more cascade errors) After this fix the LPC845 AutoResearch build with `-DFASTLED_LPC_SPI_DMA=1` succeeds and links at 56.43 KB / 64 KB (88.2%). Real silicon validation of #3517 Phase B.1 is now unblocked — just requires a working deploy pipeline (env-blocked per #3517 discussion of the pyocd HIDAPI hang on LPC-Link2 CMSIS-DAP v1.0.7 firmware). Bug was masked until now because #3527 (Phase A.2 addLeds routing) was landing at the same time and everyone's builds hit the abandoned legacy-header errors first — this SPI harness compile path was never reached. ## Verification - LPC845 with `-DFASTLED_LPC_SPI_DMA=1`: 56.43 KB / 64 KB, links clean - Grep confirms no other bare-namespace uses in the harness files Refs: #3517 Phase B, #3454 (SPI DMA driver PR). Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Status: Draft — untested on silicon
This is Phase 1 of #3453, opened as a draft per the
/clud-prscoping call ("Full draft, marked WIP"). The register-level wiring is in against UM11029 but cannot be bench-validated from the session that wrote it — see the blockers section below.Summary
Adds
src/platforms/arm/lpc/spi_arm_lpc_dma.h— a drop-in DMA0-driven peer of the polledARMHardwareSPIOutput<>fromspi_arm_lpc.h. Same template surface, same constructor, sameselect() / writeBytes / writePixelsAPI. The bulk paths stream a frame to SPI0/SPI1 via a DMA0 channel tied to the SPI block's TX request line so the CPU sits in WFI during transmission instead of busy-waiting onSTAT.TXRDY.Wired into
fastled_arm_lpc.hafter the existing polled include; the new file self-gates with#if defined(FL_IS_ARM_LPC_845) && defined(FASTLED_LPC_SPI_DMA). Default LPC845 builds and every other LPC variant (LPC804 / LPC11Uxx / LPC15xx) compile out cleanly.Engine design
Conventions follow
clockless_arm_lpc_pwm_dma.hso the two DMA engines look familiar side by side:DMA0->CHANNEL[ch].CFG = PERIPHREQEN— SPI's TXRDY drives descriptor consumption, one byte per request. NoHWTRIGENbecause SPI's request line is level/handshake, not an edge trigger.FASTLED_LPC_SPI_DMA_CHANNEL = 4(UM11029 Table 80 conventional SPI0_TX). The PWM-DMA clockless driver defaults to_BASECH = 0and consumes channels 0/1/2 — no collision.TXCTLlatched once atinit()withLEN_8BIT | RXIGNORE. The DMA stream writes halfwords toTXDATand inherits the latched control bits, so we don't burn a u32-per-byte by widening intoTXDATCTL.u16widening into a static 2 KB encode buffer (override via-DFASTLED_LPC_SPI_DMA_MAX_BYTES=N), then a singleSETVALIDarms the channel for the next TXRDY.done()/waitDma()expose the channelACTIVEflag for the async contract;waitFully()drains DMA + SPI master shift register.Per-byte / per-bit primitives (
writeByte,writeBit,writeWord) remain polled — arming a one-byte DMA descriptor costs more than the TXRDY spin, and APA102's per-LEDFLAG_START_BITis a single SPI frame anyway.What's tested
bash test --cpp— 340/340 passed.What's NOT tested
SCKHz vs requested divider, no shift-register underrun under sustained DMA pressure,TXCTLpersistence across the activity thatwriteBit<0>injects between bulk frames — all need an LPC845-BRK with a scope.nxp-lpc(hyphenated GitHub form) in platform parser fbuild#900 (PR open).framework-arduino-lpc8xxtarball checksum mismatch ([META] LPC8xx compile + autoresearch + channels API end-to-end restoration — all blockers #3450 B2) blocks platform install after B1 lands.TODO(3453)markers in the source flag every spot most likely to need silicon-side adjustment:TXCTLpersistence semantics (assumed to survive across CFG cycles per UM11029 §15.6.5)SYSCON->SYSAHBCLKCTRL0bit 29 = DMA (verified againstclockless_arm_lpc_pwm_dma.h, re-verify on bench)BURSTPOWERdefault of 0 (1 transfer per request — matches per-byte TXRDY)SRAMBASEallocation — punted to the user's framework startup; future revision should own astatic alignas(256)descriptor blockFASTLED_LPC_SPI_DMA_MAX_BYTESwritePixelsdoes NOT engage DMA yet (still per-byte polled); the bulk-DMA path iswriteByteswhich the APA102 controller chains internally. WiringwritePixelsproperly requires a flat pre-encoded buffer of the pixel-controller output.Out of scope for this PR
--dma-spiflag and the on-deviceAutoResearchSpiDma.hRPC harness. Tracked as a follow-up under LPC8xx: async DMA output drivers — Phase 1 SPI, Phase 2 clockless bring-up #3453.waitFully).Closes / refs
TODO(3453)markers.nxp-lpc(hyphenated GitHub form) in platform parser fbuild#900 (matcher fix), the gate for ever exercising this driver in CI.🤖 Generated with Claude Code
Summary by CodeRabbit