Skip to content

feat(platform): LPC804 PLU clockless driver (Stage 2b of #2836) #2841

Closed

Description

@zackees

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:

Proposal

Create src/platforms/arm/lpc/clockless_arm_lpc_plu.h that:

  1. Configures the PLU LUT/FF graph at init time to emit the WS2812 bit-timing pattern when fed serialized data bits.
  2. 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.
  3. Replaces the bit-banged C++ driver for LPC804 specifically when FL_LPC804 is 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.h exists and is gated by FL_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.ino compiles for LPC804 via fbuild with PLU driver active
  • WS2812 output verified on hardware (scope trace OR visible LED output)
  • CI workflow build-lpc804.yml in fbuild drops continue-on-error: true once 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions