Repository navigation
Description
Stage 2b follow-up to meta issue #2836 — implement WS2812 output on LPC804 via its Programmable Logic Unit (PLU).
Context
Stage 2a (#2837, merged) shipped the platform headers and a bit-banged M0+ C++ clockless driver under src/platforms/arm/lpc/. That path works for LPC845 (30 MHz, comfortable cycle budget) but is marginal on LPC804 at 15 MHz: WS2812's T1/T2/T3 reduce to roughly 5/12/7 cycles, leaving ~1 cycle of margin after branch overhead.
The LPC804 has a Programmable Logic Unit (PLU) — a small reconfigurable logic fabric — which can generate WS2812 bit timing in hardware and free the CPU from cycle-counted ASM. This mirrors the RP2040 PIO architectural pattern.
References from #2831:
- NXP video demo: https://www.nxp.com/video/part-ii-creative-ways-to-leverage-the-lpc804-mcus-integrated-programmable-logic-feature:LPC80X-LEVERAGE-PLU
- Drolli blog WS2812 via PLU: https://drolliblog.wordpress.com/2019/11/03/nxp-lpc804-plu-ws2812b-controller/
- LPC804 datasheet: https://www.nxp.com/docs/en/nxp/data-sheets/LPC804_DS.pdf
Proposal
Create src/platforms/arm/lpc/clockless_arm_lpc_plu.h that:
- Configures the PLU LUT/FF graph at init time to emit the WS2812 bit-timing pattern when fed serialized data bits.
- Feeds data either via DMA (no DMA on LPC804 — fall back to tight CPU FIFO push) or via a CPU-driven inner loop that simply hands the next bit to the PLU input register.
- Replaces the bit-banged C++ driver for LPC804 specifically when
FL_LPC804is defined and a build-time opt-in macro (e.g.FASTLED_LPC_PLU=1) is set.
Architectural template: src/platforms/arm/rp/rpcommon/clockless_rp_pio.h — the RP2040 PIO driver. Mirror its ClocklessController template + CMinWait frame-rate gating pattern, adapted for PLU's much simpler register interface.
The PLU program can be expressed as a small constexpr table of LUT configurations and FF connection IDs, generated either by hand (matching the drolliblog reference) or by porting NXP's plu_designer JSON output.
Acceptance criteria
-
src/platforms/arm/lpc/clockless_arm_lpc_plu.hexists and is gated byFL_LPC804 && FASTLED_LPC_PLU - PLU init sequence (clock enable, LUT config, FF mux, output mux) is written and documented with NXP UM11065 register references
- Bit-feed loop respects the 15 MHz CPU clock budget (no inner-loop ASM required, but verify with
objdump -d) -
examples/Blink/Blink.inocompiles for LPC804 via fbuild with PLU driver active - WS2812 output verified on hardware (scope trace OR visible LED output)
- CI workflow
build-lpc804.ymlin fbuild dropscontinue-on-error: trueonce this lands
Decisions
- Priority: P3 — Optional optimization for a community-contributor port. The bit-banged C++ driver from feat(platform): LPC845 bit-bang clockless driver (Stage 2a of #2836) #2837 will probably work at 15 MHz with careful inlining; PLU is the elegant solution, not the only one.
- Build-time opt-in via
FASTLED_LPC_PLU— Don't auto-enable. Users who don't need WS2812 on LPC804 shouldn't pay the PLU init cost or pin-allocation constraints. - Hardware validation required before merge — PLU register sequences are not portable across the NXP M0+ family and must be verified on a real LPC804 board. Not mergeable from a paper analysis.
Related issues
- Meta: meta: port FastLED to NXP LPC8xx (LPC804 + LPC845) — two-stage plan #2836 (the two-stage plan)
- Origin discussion: Porting to LPC8xx #2831
- Stage 2a (merged, gives the platform headers this driver hooks into): feat(platform): LPC845 bit-bang clockless driver (Stage 2a of #2836) #2837
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
feat(platform): LPC804 PLU clockless driver (#2841) (#2848)