Skip to content

feat(lpc): LPC845 SPI + DMA0 async driver — Phase 1 of #3453 - #3454

Merged
zackees merged 1 commit into
masterfrom
feat/3453-spi-dma-lpc845
Jun 30, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/3453-spi-dma-lpc845

Conversation

@zackees

@zackees zackees commented Jun 30, 2026 •

Copy link
Copy Markdown
Member

Status: Draft — untested on silicon

This is Phase 1 of #3453, opened as a draft per the /clud-pr scoping 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 polled ARMHardwareSPIOutput<> from spi_arm_lpc.h. Same template surface, same constructor, same select() / writeBytes / writePixels API. 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 on STAT.TXRDY.

Wired into fastled_arm_lpc.h after 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.h so the two DMA engines look familiar side by side:

  • DMA0->CHANNEL[ch].CFG = PERIPHREQEN — SPI's TXRDY drives descriptor consumption, one byte per request. No HWTRIGEN because SPI's request line is level/handshake, not an edge trigger.
  • Default channel FASTLED_LPC_SPI_DMA_CHANNEL = 4 (UM11029 Table 80 conventional SPI0_TX). The PWM-DMA clockless driver defaults to _BASECH = 0 and consumes channels 0/1/2 — no collision.
  • TXCTL latched once at init() with LEN_8BIT | RXIGNORE. The DMA stream writes halfwords to TXDAT and inherits the latched control bits, so we don't burn a u32-per-byte by widening into TXDATCTL.
  • Byte → u16 widening into a static 2 KB encode buffer (override via -DFASTLED_LPC_SPI_DMA_MAX_BYTES=N), then a single SETVALID arms the channel for the next TXRDY.
  • done() / waitDma() expose the channel ACTIVE flag 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-LED FLAG_START_BIT is a single SPI frame anyway.

What's tested

What's NOT tested

TODO(3453) markers in the source flag every spot most likely to need silicon-side adjustment:

  • TXCTL persistence semantics (assumed to survive across CFG cycles per UM11029 §15.6.5)
  • SYSCON->SYSAHBCLKCTRL0 bit 29 = DMA (verified against clockless_arm_lpc_pwm_dma.h, re-verify on bench)
  • BURSTPOWER default of 0 (1 transfer per request — matches per-byte TXRDY)
  • INMUX wiring for channel overrides > 15 (current path assumes 0..15 dedicated trigger sources)
  • SRAMBASE allocation — punted to the user's framework startup; future revision should own a static alignas(256) descriptor block
  • Chunked-stream support for frames larger than FASTLED_LPC_SPI_DMA_MAX_BYTES
  • writePixels does NOT engage DMA yet (still per-byte polled); the bulk-DMA path is writeBytes which the APA102 controller chains internally. Wiring writePixels properly requires a flat pre-encoded buffer of the pixel-controller output.

Out of scope for this PR

Closes / refs

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added optional asynchronous SPI output support for compatible ARM LPC boards, with DMA-based transfers available when enabled.
    • Default builds continue using the existing standard SPI behavior, so no change is required for current users.
    • Improved handling for larger LED data updates, which can reduce blocking during long refreshes.

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]>
@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: f1315e36-5a18-49b3-b11f-b036c14853a3

📥 Commits

Reviewing files that changed from the base of the PR and between 1874d0f and 379fcd4.

📒 Files selected for processing (2)
  • src/platforms/arm/lpc/fastled_arm_lpc.h
  • src/platforms/arm/lpc/spi_arm_lpc_dma.h

📝 Walkthrough

Walkthrough

Adds a new opt-in LPC845 SPI+DMA0 asynchronous SPI driver header (spi_arm_lpc_dma.h) defining ARMHardwareSPIOutputDMA, which mirrors the polled SPI driver interface but routes bulk writes through DMA0. Wires an unconditional, self-gated include of this header into the existing ARM LPC platform header.

Changes

LPC845 SPI+DMA0 driver

Layer / File(s) Summary
Driver documentation, config macros, and platform wiring
src/platforms/arm/lpc/spi_arm_lpc_dma.h, src/platforms/arm/lpc/fastled_arm_lpc.h
Adds header documentation, opt-in tuning macros (FASTLED_LPC_SPI_DMA_CHANNEL, FASTLED_LPC_SPI_DMA_MAX_BYTES), and a self-gated include wired into the platform header.
Class definition and lifecycle/transaction primitives
src/platforms/arm/lpc/spi_arm_lpc_dma.h
Defines ARMHardwareSPIOutputDMA template, static encoding buffer, SPI base helper, constructors, select/release, init (SPI master + DMA0 setup), and wait/waitFully primitives.
Polled byte helpers, DMA kick, and bulk writeBytes APIs
src/platforms/arm/lpc/spi_arm_lpc_dma.h
Implements writeBit/writeByte/writeWord, done/waitDma/kickDmaStream, and chunked writeBytesValueRaw/writeBytes that encode data and arm DMA transfers.
writePixels polled path and DMA descriptor configuration
src/platforms/arm/lpc/spi_arm_lpc_dma.h
Implements APA102/SK9822/WS2801 writePixels on the polled path (no DMA), adds configureChannelDescriptor for one-shot halfword transfers, and defines the static buffer out-of-class.

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()
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related issues

Possibly related PRs

  • FastLED/FastLED#2837: Both PRs modify fastled_arm_lpc.h to add new driver header includes for the LPC845 platform.
  • FastLED/FastLED#2872: The new DMA driver mirrors and wires alongside the existing polled spi_arm_lpc.h driver for the same SPI pixel output path.
  • FastLED/FastLED#3017: The DMA driver's inclusion gating relies on the FL_IS_ARM_LPC_845 macro naming introduced for LPC detection.

Poem

A bunny hops with wires in paw,
DMA streams without a flaw,
Bytes encoded, halfwords fly,
TXDAT humming to the sky,
Polled or async, pixels glow,
Hop hop hop — watch the data flow! 🐰⚡

✨ 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/3453-spi-dma-lpc845

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.

@fastled-project-sync fastled-project-sync Bot moved this to In Progress in FastLED Tracker Jun 30, 2026
@zackees
zackees marked this pull request as ready for review June 30, 2026 21:56
@zackees
zackees merged commit ac4c0b6 into master Jun 30, 2026
6 of 9 checks passed
@zackees
zackees deleted the feat/3453-spi-dma-lpc845 branch June 30, 2026 21:56
@fastled-project-sync fastled-project-sync Bot moved this from In Progress to Triage in FastLED Tracker Jun 30, 2026
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 30, 2026
zackees added a commit that referenced this pull request Jun 30, 2026
)

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]>
zackees added a commit that referenced this pull request Jul 1, 2026
…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]>
zackees added a commit that referenced this pull request Jul 1, 2026
…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]>
zackees added a commit that referenced this pull request Jul 1, 2026
… 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]>
zackees added a commit that referenced this pull request Jul 1, 2026
… 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]>
zackees added a commit that referenced this pull request Jul 1, 2026
…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]>
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