Repository navigation
feat(platform): LPC804 PLU clockless driver (#2841) - #2848
Conversation
Adds a Programmable Logic Unit (PLU) clockless WS2812 driver for the NXP LPC804 at 15 MHz, where the shared M0+ bit-banged path has ~1 cycle of margin on T1 and is marginal. The PLU is configured as a 3-LUT graph that synthesises the WS2812 bit pulse-shape in hardware (LUT0 = T0H window, LUT1 = T1H window, LUT2 = DATA-selected bit mux), routed via OUTPUT0_MUX to a SWM-assigned GPIO. The CPU only has to push the next data bit per WS2812 bit interval. Architecturally mirrors the RP2040 PIO driver: - ClocklessController<DATA_PIN, TIMING, RGB_ORDER, XTRA0, FLIP, WAIT> - CMinWait<WAIT_TIME> for reset-gap enforcement - showPixels() disables interrupts and feeds bytes MSB-first Build-time opt-in via -DFASTLED_LPC_PLU=1 (only honoured when FL_LPC804 is also defined). The existing bit-bang driver compiles itself out under the same gate, so LPC845 builds are unaffected. Register layout cited inline against NXP UM11065 chapter 12 (PLU) and chapter 4 (SYSCON clock-gating). Timing-counter source for PLU_IN1/IN2 and SWM PINASSIGN_PLU_IN/OUT pin routing are left as documented TODO(2841) for the hardware-bringup pass; no hex was fabricated. Stage 2b of #2836. Hardware validation is Stage 3. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Too many files changed? Review this PR in Change Stack to see how the pieces fit before you dive in. 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 (3)
📝 WalkthroughWalkthroughThis PR implements a hardware-accelerated WS2812 LED driver for LPC804 microcontrollers using the Programmable Logic Unit (PLU) to generate pulse timing in silicon. The PLU-based driver replaces the software-based approach under a build-time opt-in flag, with conditional compilation preventing double-definition of the ChangesLPC804 PLU Clockless Driver
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
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 |
Closes #2841.
Stage 2b follow-up to #2836 / #2837. Adds an opt-in WS2812 driver for the NXP LPC804 that offloads bit-timing to its on-chip Programmable Logic Unit (PLU), freeing the 15 MHz Cortex-M0+ from cycle-counted bit-banging.
Summary
src/platforms/arm/lpc/clockless_arm_lpc_plu.himplementingfl::ClocklessController<DATA_PIN, TIMING, RGB_ORDER, ...>against the LPC804 PLU.-DFASTLED_LPC_PLU=1(only honoured whenFL_LPC804is also defined).clockless_arm_lpc.h) compiles itself out under the same gate so we don't double-define the template.fastled_arm_lpc.hnow pulls in the PLU header after the bit-bang header; both self-gate, so LPC845 builds are unchanged.PLU graph
Three LUTs synthesise the WS2812 bit waveform:
out = !CNT1— T0H window (high for first half of bit)out = !(CNT0 & CNT1)— T1H window (high for ~75% of bit)out = DATA ? LUT1 : LUT0— bit muxRouting:
LUTn_INP_MUX[m](UM11065 §12.6.1) wires PLU_IN0..2 + LUT cross-feeds.OUTPUT0_MUX(UM11065 §12.6.3) routes LUT2 to PLU_OUT0.SYSCON->SYSAHBCLKCTRL0bit 18 (UM11065 §4.6.13).Result:
DATA=0produces a ~T0H high pulse,DATA=1produces a ~T0H+T1H high pulse — the WS2812 NRZ encoding.Open TODO(2841)s left in code
Documented and grep-able as
TODO(2841):init_timing_source()must run beforeFastLED.show().PINASSIGN_PLU_IN[n]/PINASSIGN_PLU_OUT[n]programming helper. The SWM is fully crossbar-routable per UM11065 Table 88, so no compile-time pin validation is feasible without per-package constraints.SYSCON->SYSAHBCLKCTRL0PLU clock bit position against theLPC804.hCMSIS enum once the device header is available in CI.sendByte()NOP padding once the SCT counter rate is locked.These are all hardware-bringup tasks; none can be resolved without a real LPC804 board.
Files changed
src/platforms/arm/lpc/clockless_arm_lpc_plu.h— new (405 lines)src/platforms/arm/lpc/clockless_arm_lpc.h— add gate so bit-bang compiles out when PLU is selectedsrc/platforms/arm/lpc/fastled_arm_lpc.h— include the new PLU headerCI / hardware status
bash lint --cppgreen.FL_IS_ARM_LPC(unset on host).build-lpc804.ymlworkflow is hardware-gated and may stay red until Stage 3 (per feat(platform): LPC804 PLU clockless driver (Stage 2b of #2836) #2841 acceptance criteria); per maintainer direction the user has accepted this.Draft because
No hardware available in this PR to scope-trace the WS2812 waveform. Marked draft pending Stage 3 hardware verification, after which the workflow can drop
continue-on-error: trueand this PR can be marked ready.Summary by CodeRabbit
New Features
FASTLED_LPC_PLUmacro.Bug Fixes