Skip to content

feat(lpc): channels-API SCT+DMA clockless engine scaffold (#3459) - #3460

Merged
zackees merged 1 commit into
masterfrom
feat/3459-lpc-sct-dma-engine
Jun 30, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/3459-lpc-sct-dma-engine

Conversation

@zackees

@zackees zackees commented Jun 30, 2026 •

Copy link
Copy Markdown
Member

Status: Draft — scaffold + state machine, show() body deferred

This is the channels-API plumbing for LPC845's SCT+DMA clockless engine, per #3459. Opens as draft because the show() body is a documented TODO(3459) (same scaffold convention used for rx_sct_capture.h::begin() (#3015) and spi_arm_lpc_dma.h (PR #3454)).

Summary

Lifts the existing legacy-template DMA clockless engine in clockless_arm_lpc_pwm_dma.h onto IChannelDriver so LPC845 can take part in runtime channels-API dispatch (addLeds<> → BusTraits<Bus::X>::instancePtr() → ChannelManager). Reference engine: src/platforms/arm/teensy/teensy4_common/drivers/objectfled/.

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 three dispatch wires:

  • src/platforms/arm/lpc/channel_drivers_lpc.impl.hpp — new enableAllChannelDrivers() fragment.
  • src/platforms/arm/lpc/_build.cpp.hpp — pulls in drivers/sct_dma/_build.cpp.hpp.
  • src/platforms/channel_drivers.impl.cpp.hpp — adds the FL_IS_ARM_LPC arm to the top-level platform dispatch.

Routing decisions

  • Bus::BIT_BANG for registration. The portable Bus enum has no SCT_DMA slot, and the channels-API convention is that the peripheral — not the protocol mode — is the dispatch boundary. Reusing BIT_BANG for LPC's parallel-IO clockless peripheral is consistent with Bus::FLEX_IO covering both Teensy FlexPWM and ESP32 LCD_CAM/I2S/PARLIO. It also matches DefaultBus<ClocklessChipset> = Bus::BIT_BANG that landed for LPC in PR feat(channels): add LPC DefaultBus<> specializations (#3450 B4) #3451.
  • 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 feat(lpc): LPC845 SPI + DMA0 async driver — Phase 1 of #3453 #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 chipsets with total bit period 1000-2500 ns (WS2812/SK6812 range), same convention as ChannelEngineObjectFLED.

What's deferred

show() and poll() carry an explicit TODO(3459) block listing the structural lift required:

  1. Convert LpcSctTicks<NS>::value from compile-time template helper to runtime helper lpc_sct_ticks(u32 ns).
  2. Hoist configureSct() / configureDma() / startDmaChunk() / waitDmaChunk() out of the templated ClocklessController into a non-template helper struct owned by this engine.
  3. Iterate mEnqueuedChannels, dispatching each through the lifted helper. Single-strip v1 just takes the first entry; multi-strip parallel is feat(platform/lpc): multi-strip parallel output for LPC845 (SCT + DMA) — Stage 4.4 from #2845, gated on Stage 2c hardware validation #2879.

In the scaffold, show() transitions READY → BUSY and poll() immediately transitions back to READY, so calls do not transmit but also do not stall the manager.

Tests run

What's NOT tested

References

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added support for LPC845 clockless channel driving via a new SCT + DMA-based engine.
    • Enabled automatic registration of channel drivers on supported LPC builds.
    • Added platform dispatch so LPC-specific channel driver support is included when available.
  • Documentation

    • Clarified supported device scope and capability notes for the new LPC845 channel driver path.

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]>
@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: 31c6e983-1554-49ca-92de-b126cc37faa1

📥 Commits

Reviewing files that changed from the base of the PR and between 5f2f1bc and aba27b1.

📒 Files selected for processing (7)
  • src/platforms/arm/lpc/_build.cpp.hpp
  • src/platforms/arm/lpc/channel_drivers_lpc.impl.hpp
  • src/platforms/arm/lpc/drivers/sct_dma/_build.cpp.hpp
  • src/platforms/arm/lpc/drivers/sct_dma/bus_traits.h
  • 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/channel_drivers.impl.cpp.hpp

📝 Walkthrough

Walkthrough

Adds a new LPC845 SCT+DMA clockless channel driver (ChannelEngineLpcSctDma) implementing IChannelDriver with scaffolded canHandle/enqueue/show/poll methods, a BusTraitsBus::BIT_BANG specialization registering it with ChannelManager, and wiring through unity-build includes and a new enableAllChannelDrivers() function dispatched from the platform channel driver selection logic.

Changes

LPC845 SCT+DMA channel engine

Layer / File(s) Summary
Channel engine class declaration
src/platforms/arm/lpc/drivers/sct_dma/channel_engine_lpc_sct_dma.h
Declares ChannelEngineLpcSctDma implementing IChannelDriver with overrides for canHandle, enqueue, show, poll, getName, getCapabilities, plus scaffolding members, documented as v1 single-strip clockless-only scope.
Channel engine implementation
src/platforms/arm/lpc/drivers/sct_dma/channel_engine_lpc_sct_dma.cpp.hpp
Implements timing-based canHandle filtering (1000–2500ns), enqueue/show queueing scaffold without real hardware programming, and poll returning READY immediately, all gated to FL_IS_ARM_LPC_845.
BusTraits registration for BIT_BANG
src/platforms/arm/lpc/drivers/sct_dma/bus_traits.h
Specializes BusTraits<Bus::BIT_BANG> with a singleton driver, instance()/instancePtr(), registerWithManager(), and adds BusSupports<Bus::BIT_BANG, ClocklessChipset, 0> as true_type.
Unity-build and platform dispatch wiring
src/platforms/arm/lpc/drivers/sct_dma/_build.cpp.hpp, src/platforms/arm/lpc/_build.cpp.hpp, src/platforms/arm/lpc/channel_drivers_lpc.impl.hpp, src/platforms/channel_drivers.impl.cpp.hpp
Adds unity-build includes for the new driver and bus traits, defines enableAllChannelDrivers() registering the driver on LPC845, and adds an FL_IS_ARM_LPC dispatch branch.

Sequence Diagram(s)

sequenceDiagram
  participant channel_drivers.impl.cpp.hpp
  participant channel_drivers_lpc.impl.hpp
  participant BusTraits
  participant ChannelManager
  participant ChannelEngineLpcSctDma
  channel_drivers.impl.cpp.hpp->>channel_drivers_lpc.impl.hpp: include (FL_IS_ARM_LPC)
  channel_drivers_lpc.impl.hpp->>BusTraits: enableAllChannelDrivers() calls registerWithManager()
  BusTraits->>ChannelManager: register ChannelEngineLpcSctDma instance
  Note over ChannelEngineLpcSctDma: enqueue()/show()/poll() scaffold, no hardware programming yet
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Possibly related PRs

  • FastLED/FastLED#2437: Shares the BusTraits::registerWithManager() + singleton-holder pattern with default_bus_priority used here.
  • FastLED/FastLED#2448: Relates to the same driver-registration mechanism via fl::enableAllDrivers() enumerating BusTraits-provided drivers.
  • FastLED/FastLED#2480: Shares the fl::platforms::enableAllChannelDrivers() trampoline mechanism extended here for LPC.

Poem

Hop, hop, through SCT and DMA streams,
A bunny wires up bit-bang dreams,
READY, BUSY, DRAINING soon to be true,
For now I queue channels, then say "READY too!" 🐇
Carrots compiled, LPC845 gleams. ✨

✨ 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-lpc-sct-dma-engine

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 23:02
@zackees
zackees merged commit ddbadc4 into master Jun 30, 2026
8 of 11 checks passed
@zackees
zackees deleted the feat/3459-lpc-sct-dma-engine branch June 30, 2026 23:02
@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 Jul 1, 2026
…#3468) (#3475)

While validating the #3468 harness on real LPC845-BRK silicon
(VID:PID 1FC9:0132 on COM10), three separate blockers prevented
`bash compile lpc845brk --examples AutoResearch --build-flag
-DFASTLED_LPC_PWM_DMA=1` from producing a firmware image. Each is a
legitimate bug fix and lands here together because they are only
observable end-to-end when the LPC compile path actually gets exercised.

## Fix 1 — `ci/boards.py`: nxplpc@ prefix workaround

fbuild 2.3.15 shipped 2026-06-30 20:09 UTC; my platform-matcher fix
FastLED/fbuild#900 merged 2026-06-30 21:47 UTC (after 2.3.15 was cut).
2.3.15's matcher still only substring-matches `nxplpc` (no separator)
and rejects the hyphenated `nxp-lpc` in the raw GitHub URL. Prepending
`nxplpc@` to the platform URL is valid PlatformIO name-at-source
syntax and makes the substring match, unblocking the build under
2.3.15. Once fbuild 2.3.16 ships with #900 the prefix becomes redundant
but stays syntactically valid.

## Fix 2 — `led_sysdefs_arm_lpc.h`: define `FASTLED_HAS_CMSIS`

`src/platforms/arm/common/m0clockless_c.h:51` guards the local
`__get_PRIMASK` / `__enable_irq` / `__disable_irq` stubs with
`#if !defined(FASTLED_HAS_CMSIS)`, and the comment on that guard says
"LPC builds set FASTLED_HAS_CMSIS in led_sysdefs". But the define was
never actually added — so LPC builds got the local stubs plus the
vendor CMSIS versions from `core_cm0plus.h` and gcc rejected the pair
with

    error: redefinition of 'fl::u32 __get_PRIMASK()'

Adding `#define FASTLED_HAS_CMSIS 1` in `led_sysdefs_arm_lpc.h`
immediately after the vendor `<LPC845.h>` / `<LPC804.h>` include
matches the intent of the m0clockless guard and silences the collision.

## Fix 3 — `platforms/shared/bitbang/bus_traits.h`: LPC845 gate

`ChannelEngineLpcSctDma` registers under `BusTraits<Bus::BIT_BANG>`
(see `src/platforms/arm/lpc/drivers/sct_dma/bus_traits.h` — FastLED
#3459 / PR #3460). The shared `BitBangChannelDriver` also specialises
`BusTraits<Bus::BIT_BANG>` unconditionally. On LPC845 both TUs land in
the same translation unit and gcc rejects the pair with

    error: redefinition of 'struct fl::BusTraits<fl::Bus::BIT_BANG>'
    error: redefinition of 'struct fl::BusSupports<fl::Bus::BIT_BANG,
                                                    fl::ClocklessChipset, 0>'

Gate the shared bit-bang specialization on `!FL_IS_ARM_LPC_845` so the
dedicated SCT+DMA engine owns the slot on that platform. Every other
platform continues to use the universal-GPIO fallback.

## Verification

Applied all three fixes and confirmed:

  bash compile lpc845brk --examples AutoResearch \
      --build-flag "-DFASTLED_LPC_PWM_DMA=1"

  Board: NXP LPC845-BRK / LPC845 @ 24MHz
  Toolchain: arm-none-eabi-gcc 15.2.1
  Flash: 53.52KB / 64.00KB (83.6%)
  RAM:   9.07KB / 16.00KB (56.7%)
  Artifact: firmware.elf (159.79KB) / firmware.bin (53.54KB)
  build succeeded in 212.2s

  bash test --cpp → 343/343 passed
  C++ lint → clean

## What's still open on the actual on-wire verification

- fbuild-side: an additional blocker surfaced during this bring-up —
  the FastLED/framework-arduino-lpc8xx tarball SHA256 changed after
  the 2026-06-28 org transfer (`e6bbcc3392…` → `e64f0cb81a…`). This
  needs a fbuild-side update to `ACLPC_CHECKSUM` in
  `crates/fbuild-packages/src/library/arduino_core_lpc8xx.rs`; I filed
  the change on a local fbuild branch during this session and will
  push it as a follow-up PR to the fbuild repo.
- Flash + serial monitoring: `bash autoresearch --pwm-dma-cl` still
  hits pre-existing infrastructure gaps unrelated to #3468 —
  `ci/util/port_utils.py` only recognises the LPCXpresso VCOM
  fingerprint (VID:PID 16C0:0483), not the LPC-Link2 CMSIS-DAP
  variant (1FC9:0132) that ships on this specific LPC845-BRK unit,
  and fbuild's LPC deploy path uses `lpc21isp` which requires ISP-mode
  entry rather than the board's default CMSIS-DAP SWD. Both are
  tracked separately.

The host TX→RX byte-flow readback contract (the #3468 primary
acceptance criterion) is already confirmed in PR #3472
(`tests/fl/channels/lpc_sct_dma_engine.cpp` "#3468: end-to-end TX→RX
readback through engine.show()", passing 343/343). This PR takes the
verification one step further by making the compile path work on the
LPC845 target so any user with an LPC845-BRK can now build and flash
the firmware and run the on-silicon self-loopback via
`pwmDmaClCaptureSelf`.

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
…M_DMA CHUNK_BITS (#3522)

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]>
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]>
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