Repository navigation
fix(lpc): F_CPU=24MHz + platform-detection ordering + SCT macro shim - #3055
Conversation
Four source-tree fixes uncovered while bringing up the LPC845 SCT+DMA
WS2812 driver against the consolidated AutoResearch sketch:
1. src/platforms/arm/lpc/led_sysdefs_arm_lpc.h -- F_CPU for LPC845 is
24 MHz, NOT 30 MHz. The LPC845 FRO native direct-path rate is
24 MHz per NXP UM11029 sec. 4.1; 30 MHz is only reachable via the
PLL, which neither the Arduino core (zackees/ArduinoCore-LPC8xx
boards.txt declares f_cpu=24000000L) nor fbuild
(lpc845brk.json declares f_cpu=24000000L) configures by default.
The previous 30 MHz default introduced a ~25% cycle-count drift on
both the bit-bang clockless driver and the SCT+DMA hardware driver.
Users programming the PLL up to 30 MHz can override via
-DF_CPU=30000000UL.
2. src/fl/system/sketch_macros.h -- pulls in platforms/is_platform.h
BEFORE the four-tier memory-tier classification fires. Without
this, FL_IS_ARM_LPC (set inside platforms/arm/lpc/is_lpc.h, included
transitively via platforms/arm/is_arm.h) is undefined when
sketch_macros.h is transitively included via
fl/system/engine_events.h before any other platform-aware include.
Result: LPC builds got FL_PLATFORM_HAS_LARGE_MEMORY=1 (wrong) which
set FASTLED_HAS_ENGINE_EVENTS=1, causing
fl::CLEDController::showLeds() to emit calls to
fl::EngineEvents::getInstance() / _onEndFrame() / _onEndShowLeds()
that fail at link time because the matching definitions in
engine_events.cpp.hpp are gated out. With the unified is_platform.h
include, platform detection is canonical regardless of include
order, and the gating evaluates correctly on Low-memory targets.
3. src/platforms/arm/lpc/clockless_arm_lpc_pwm_dma.h -- two fixes:
(a) #pragma push_macro around the FL_LPC_SCT_Shim struct
definition so Arduino.h's INPUT / OUTPUT macros
(#define INPUT 0x0 / #define OUTPUT 0x1) do not corrupt the
SCT register field names INPUT (offset 0x048) and
OUTPUT (offset 0x054) per UM11029 sec. 16.6. The macros are
pop'd at the struct close so downstream user code calling
pinMode(pin, OUTPUT) continues to work as expected.
(b) Updated the SCT timing comment block to reflect the 24 MHz
default match counts (T0_FALL=9, T1_FALL=19, T_END=30, tick =
41.67 ns). The compile-time derivation macro at line 313
(ns * F_CPU + 5e8) / 1e9 picks up whichever F_CPU is set; the
comment now matches reality.
4. examples/AutoResearch/AutoResearchLowMemory.h -- migrated the
ws2812SctTest RPC handler to the current fl::make4PhaseTiming
signature: takes a const fl::ChipsetTiming& + reset_us (u32) rather
than three individual T1/T2/T3 u32 args. Constructs the
ChipsetTiming via fl::to_runtime_timing<fl::WS2812ChipsetTiming>().
The pre-merge LPC sketch used an older 3-u32 prototype that no
longer exists in fl/channels/rx.h.
Net effect: AutoResearch.ino in low-memory mode compiles end-to-end
for lpc845brk; the SCT+DMA driver header compiles cleanly under
-DFASTLED_LPC_PWM_DMA=1. Remaining 64 KB flash-budget work is
tracked separately.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
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 (4)
📝 WalkthroughWalkthroughChanges the LPC845 default ChangesLPC845 Platform Corrections and Supporting Fixes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Possibly related PRs
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
Four source-tree fixes uncovered while bringing up the LPC845 SCT+DMA WS2812 driver against the consolidated AutoResearch sketch. Each is a real bug independent of the bring-up effort.
src/platforms/arm/lpc/led_sysdefs_arm_lpc.hF_CPUcorrected from 30 MHz to 24 MHz. The chip's FRO native direct-path rate is 24 MHz per UM11029 §4.1; both Arduino coreboards.txtand fbuildlpc845brk.jsondeclaref_cpu=24000000L. Previous 30 MHz default → ~25 % cycle-count drift on bit-bang + SCT+DMA. PLL users override via-DF_CPU=30000000UL.src/fl/system/sketch_macros.hplatforms/is_platform.hbefore tier classification fires. Without this,FL_IS_ARM_LPCwas undefined whensketch_macros.hcame in viafl/system/engine_events.hbefore any other platform-aware include — LPC builds gotFL_PLATFORM_HAS_LARGE_MEMORY=1(wrong),FASTLED_HAS_ENGINE_EVENTS=1, andCLEDController::showLeds()emitted unresolved refs tofl::EngineEvents::getInstance()etc.src/platforms/arm/lpc/clockless_arm_lpc_pwm_dma.h#pragma push_macroaroundFL_LPC_SCT_Shimso Arduino.h'sINPUT 0x0/OUTPUT 0x1macros don't corrupt SCT register field namesINPUT(0x048) /OUTPUT(0x054). Macros pop at struct close so userpinMode(pin, OUTPUT)still works. (b) SCT timing comment block updated to reflect 24 MHz match counts (tick = 41.67 ns, T0_FALL=9, T1_FALL=19, T_END=30).examples/AutoResearch/AutoResearchLowMemory.hws2812SctTestmigrated to the currentfl::make4PhaseTiming(const ChipsetTiming&, u32 reset_us)signature usingfl::to_runtime_timing<fl::WS2812ChipsetTiming>(). The retired LPC sketch used a 3-u32 prototype that no longer exists.Test plan
lpc845brkvia local fbuild againstzackees/ArduinoCore-LPC8xx.-DFASTLED_LPC_PWM_DMA=1.🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
Bug Fixes
Documentation
Chores