Repository navigation
feat(platform): LPC845 bit-bang clockless driver (Stage 2a of #2836) - #2837
Conversation
Adds Stage 2a of the NXP LPC8xx FastLED port: a bit-banged WS2812 clockless driver for LPC845 (Cortex-M0+ @ 30 MHz) and LPC804 (Cortex-M0+ @ 15 MHz), templated on the existing M0+ shared driver. New files under src/platforms/arm/lpc/: - is_lpc.h: detects __LPC845__ / __LPC804__ / CPU_LPC845*/CPU_LPC804* defines from the MCUXpresso CMSIS device headers; emits FL_LPC845, FL_LPC804, FL_IS_ARM_LPC. - int.h: delegates to the shared ARM 32-bit integer typedefs. - led_sysdefs_arm_lpc.h: F_CPU per chip (30 MHz / 15 MHz), interrupt policy via __disable_irq / __enable_irq, FL_IS_ARM_M0_PLUS. - fastpin_arm_lpc.h: PIO0_0..PIO0_31 mapped onto LPC_GPIO->SET[0] / CLR[0] / DIRSET[0] / DIRCLR[0] / NOT[0] / PIN[0]. - clockless_arm_lpc.h: WS2812 controller routing through the shared showLedData<HI_OFFSET, LO_OFFSET, ...> template. - fastled_arm_lpc.h: aggregator. Routes the new family through the existing dispatchers (is_arm.h, led_sysdefs.h, platforms.h). All LPC code is guarded by FL_IS_ARM_LPC so host builds are unaffected. Drives the portable C++ implementation of m0clockless instead of the inline-assembly one: the LPC8xx GPIO controller places SET[0] at +0x2200 and CLR[0] at +0x2280 from the controller base, which is beyond the 5-bit imm5*4 encoding the M0+ STR-immediate-offset instruction supports - so the inline-asm template's "I" constraint cannot fit those offsets in a single store. The C++ version performs an indexed store and handles arbitrary byte offsets. Stage 2a only: no PLU (LPC804) or PWM+DMA (LPC845) driver yet. Cross-compile validation depends on Stage 1 (fbuild toolchain), which is a separate PR. Draft until then. Refs #2836
|
Looking for one thing? Review this PR in Change Stack to search files, summaries, diffs, and code without losing your place. 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 (9)
📝 WalkthroughWalkthroughThis PR adds complete ARM LPC8xx microcontroller support to FastLED by introducing platform detection, system configuration, GPIO control via FastPin, a clockless LED output controller with interrupt management, and integration into FastLED's existing platform dispatcher. ChangesARM LPC8xx Platform Implementation
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 |
Summary
Stage 2a of the NXP LPC8xx FastLED port (meta issue #2836).
Adds a bit-banged WS2812 clockless driver for LPC845 (Cortex-M0+ @ 30 MHz) and LPC804 (Cortex-M0+ @ 15 MHz), templated on the existing shared
m0clocklessdriver used by Teensy LC (KL26Z) and nRF51.New files (
src/platforms/arm/lpc/)is_lpc.h__LPC845__/__LPC804__/CPU_LPC845*/CPU_LPC804*defines from the MCUXpresso CMSIS device headers; emitsFL_LPC845,FL_LPC804,FL_IS_ARM_LPC.int.hsrc/platforms/arm/int.h).led_sysdefs_arm_lpc.hF_CPUper chip (30 MHz / 15 MHz),FL_IS_ARM_M0_PLUS,cli()/sei()via__disable_irq/__enable_irq, and includes<LPC845.h>/<LPC804.h>forLPC_GPIO.fastpin_arm_lpc.hLPC_GPIO->SET[0]/CLR[0]/DIRSET[0]/DIRCLR[0]/NOT[0]/PIN[0].clockless_arm_lpc.hshowLedData<HI_OFFSET, LO_OFFSET, ...>template.fastled_arm_lpc.hDispatcher wiring
src/platforms/arm/is_arm.hincludeslpc/is_lpc.hand addsFL_IS_ARM_LPCto theFL_IS_ARMumbrella.src/led_sysdefs.hroutesFL_IS_ARM_LPCtoled_sysdefs_arm_lpc.h.src/platforms.hroutesFL_IS_ARM_LPCtofastled_arm_lpc.h(and now includesis_arm.hfirst so the LPC detection runs before the dispatch chain).Design decisions
m0clockless(FASTLED_M0_USE_C_IMPLEMENTATION) instead of the inline-ASM one. The LPC8xx GPIO controller placesSET[0]at +0x2200 andCLR[0]at +0x2280 from the controller base, which is beyond the 5-bitimm5*4encoding the M0+STR Rt, [Rn, #imm]instruction supports (max byte offset = 124). The inline-asm template's"I"constraint cannot encode those offsets in a single-instruction store. The C++ version performs an indexed store (port[off/4] = bitmask) and handles arbitrary byte offsets at zero cost.FastPin<>::port()returns&LPC_GPIO->PIN[0], withHI_OFFSET = 0x100(relative toPIN[0], this isSET[0]) andLO_OFFSET = 0x180(which isCLR[0]). The C++ clockless driver consumes these as compile-time template parameters.FL_LPC845is gated via__LPC845__or theCPU_LPC845*defines from the MCUXpressoLPC845.hCMSIS device header - that is what the NXP SDK ships.Scope
.inounderexamples/- per the meta issue, Blink validation goes through existing examples once Stage 1 lands. AutoResearch is the canonical scratch target for live-device testing.What was verified from this side
bash lint --cpp: all checks pass on the new LPC files (and the modified dispatchers).defined(FL_IS_ARM_LPC)/defined(__LPC845__)/defined(__LPC804__)so host builds are inert.FastLED.hwithFASTLED_STUB_IMPL(no LPC defines present) compiles cleanly with the new files on the include path.What was NOT verified (and why)
examples/Blinkthenexamples/AutoResearchon an LPC845 dev board.bash test --cpp:src/fl/net/network_detector.h:50usesnamespace fl::net {(C++17 nested namespace syntax) under-Werror=c++17-extensions. The failure is identical on pristine master (verified viagit stash). Out of scope for this PR; flagged here for visibility.Test plan
lpc845platform target.bash compile lpc845 --examples Blinkcompiles clean.m0clockless_ccycle math).Refs #2836.
Summary by CodeRabbit
Release Notes
New Features