Repository navigation
lpc: move bare-metal support into platform code - #2989
Conversation
📝 WalkthroughWalkthroughThis PR introduces complete ARM LPC platform support to FastLED by implementing LPC-specific timing via SysTick, I/O stubs, runtime symbols, and platform configuration. It also refactors the core delay loop to consistently use the namespaced ChangesLPC Platform Support
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
072e47c to
0b47521
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/platforms/arm/lpc/runtime_lpc.cpp.hpp (1)
19-35: 💤 Low valueNo-op delete operators assume no dynamic allocation.
The weak no-op
operator deleteoverloads will silently leak memory if any code usesnew/delete. This is acceptable for bare-metal LPC where dynamic allocation is typically avoided, but consider adding a compile-time guard or runtime assertion if dynamic allocation is attempted, or document this constraint clearly in the header comments.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/platforms/arm/lpc/runtime_lpc.cpp.hpp` around lines 19 - 35, The no-op weak operator delete overloads (operator delete, operator delete[], operator delete(void*, size_t), operator delete[](void*, size_t)) silently drop frees and can hide use of dynamic allocation; update these overloads to either (1) add a compile-time guard (e.g., a macro or static_assert flag like FL_ALLOW_DYNAMIC_ALLOCAION) so the no-op definitions are only compiled for a no-dynamic mode, or (2) insert a runtime trap/assert (e.g., call to platform panic/assert handler) inside each operator to fail-fast when delete is used, and add a header comment documenting that dynamic allocation is unsupported unless the guard is enabled; reference and change the four operator delete definitions accordingly.src/platforms/arm/lpc/clockless_arm_lpc_pwm_dma.h (1)
314-314: ⚡ Quick winStatic buffer sharing constraint is documented but not enforced.
The static
sChannelBufis shared across allClocklessControllerinstances, which limits the design to a single active controller. The comment on lines 312-313 documents this, but there's no runtime enforcement. If a user accidentally creates multiple LPC PWM/DMA controllers, they will silently corrupt each other's buffer state.Consider adding a debug-mode assertion in
init()orshowPixels()to detect multiple concurrent instances, or document this constraint more prominently in the class documentation.🛡️ Proposed guard to detect multiple instances
Add a debug assertion in
init():virtual void init() FL_NOEXCEPT { + `#ifdef` FASTLED_DEBUG + static bool sInstanceActive = false; + if (sInstanceActive) { + // Multiple LPC PWM/DMA controllers detected - only one supported + while(1) {} // Halt in debug builds + } + sInstanceActive = true; + `#endif` + FastPin<DATA_PIN>::setOutput();🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/platforms/arm/lpc/clockless_arm_lpc_pwm_dma.h` at line 314, The static buffer sChannelBuf is shared across all ClocklessController instances but there's no runtime check to prevent multiple active controllers; add a debug-only guard to detect and fail-fast when a second instance is initialized or used—for example, introduce a static or global flag (e.g., sChannelBufInUse or sActiveControllerCount) and assert in ClocklessController::init() (and/or ClocklessController::showPixels()) that no other instance is active, set the flag on successful init and clear it in the destructor or a deinit method, and ensure the check is compiled only in debug builds so production size/perf is unaffected.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/platforms/arm/lpc/clockless_arm_lpc_pwm_dma.h`:
- Line 314: The static buffer sChannelBuf is shared across all
ClocklessController instances but there's no runtime check to prevent multiple
active controllers; add a debug-only guard to detect and fail-fast when a second
instance is initialized or used—for example, introduce a static or global flag
(e.g., sChannelBufInUse or sActiveControllerCount) and assert in
ClocklessController::init() (and/or ClocklessController::showPixels()) that no
other instance is active, set the flag on successful init and clear it in the
destructor or a deinit method, and ensure the check is compiled only in debug
builds so production size/perf is unaffected.
In `@src/platforms/arm/lpc/runtime_lpc.cpp.hpp`:
- Around line 19-35: The no-op weak operator delete overloads (operator delete,
operator delete[], operator delete(void*, size_t), operator delete[](void*,
size_t)) silently drop frees and can hide use of dynamic allocation; update
these overloads to either (1) add a compile-time guard (e.g., a macro or
static_assert flag like FL_ALLOW_DYNAMIC_ALLOCAION) so the no-op definitions are
only compiled for a no-dynamic mode, or (2) insert a runtime trap/assert (e.g.,
call to platform panic/assert handler) inside each operator to fail-fast when
delete is used, and add a header comment documenting that dynamic allocation is
unsupported unless the guard is enabled; reference and change the four operator
delete definitions accordingly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 9b814fab-217a-441d-bb42-2fd88595758e
📒 Files selected for processing (11)
src/FastLED.cpp.hppsrc/platforms/arm/_build.cpp.hppsrc/platforms/arm/lpc/_build.cpp.hppsrc/platforms/arm/lpc/clockless_arm_lpc.hsrc/platforms/arm/lpc/clockless_arm_lpc_pwm_dma.hsrc/platforms/arm/lpc/io_lpc.cpp.hppsrc/platforms/arm/lpc/led_sysdefs_arm_lpc.hsrc/platforms/arm/lpc/platform_time_lpc.cpp.hppsrc/platforms/arm/lpc/runtime_lpc.cpp.hppsrc/platforms/arm/lpc/spi_arm_lpc.hsrc/platforms/pin.h
|
@coderabbitai review |
✅ Action performedReview finished.
|
Summary
src/platforms/arm/lpcinstead of keeping board-support files under an examplefl::yield()so Arduino globalyield()stubs do not collideThis intentionally does not bring over the misplaced
examples/BlinkLPC845include tree or generated build-info JSON from external PR #2988. Those fbuild-owned pieces are in the companion PR: FastLED/fbuild#512.Validation
git diff --check master..HEADexamples/Blink/platformio.ini:..\fbuild\target\debug\fbuild.exe ci --board lpc845 examples\Blink\Blink.ino --lib . --quick -vexamples/Blink/platformio.ini:..\fbuild\target\debug\fbuild.exe ci --board lpc804 examples\Blink\Blink.ino --lib . --quick -vSummary by CodeRabbit
New Features
Bug Fixes
Refactor