Skip to content

feat(lpc): consume vendor NXP CMSIS PAL, delete 5/8 hand-rolled register maps (closes #3437) - #3438

Merged
zackees merged 9 commits into
masterfrom
feat/3437-lpc-cmsis-vendoring
Jun 28, 2026
Merged

zackees merged 9 commits into
masterfrom
feat/3437-lpc-cmsis-vendoring

Conversation

@zackees

@zackees zackees commented Jun 28, 2026 •

Copy link
Copy Markdown
Member

Summary

Implements step 3 of #3437 — FastLED consumes the vendor NXP CMSIS PAL through the now-merged upstream chain, deletes 5 of the 8 hand-rolled register-map sites, and migrates every call site to canonical NXP typedefs.

Upstream chain (both merged before this PR):

  • Step 1: zackees/ArduinoCore-LPC8xx#34 — ships full NXP LPC845.h + LPC804.h CMSIS PAL in variants/lpc845/ + variants/lpc804/. Merge SHA 50d76e0d.
  • Step 2: zackees/platform-nxplpc-arduino#9 — pins framework-arduino-lpc8xx to step 1 SHA in platform.json, bumps platform version 0.1.0 → 0.2.0. Merge SHA 12265f76.

What this PR does

Foundation (step 3a)

  • Bumps _NXPLPC_PLATFORM SHA in ci/boards.py + platformio.ini (2ee527ae → 12265f76) — picks up the new v0.2.0 platform with the pinned ArduinoCore-LPC8xx that ships the full vendor PAL.
  • Adds #include <LPC845.h> + #include <LPC804.h> to led_sysdefs_arm_lpc.h behind FL_IS_ARM_LPC_845 / FL_IS_ARM_LPC_804 guards, wrapped in #pragma push_macro("INPUT") / pop_macro so Arduino.h's INPUT/OUTPUT macros don't clobber vendor struct members of the same name.
  • Adds V7 #error guards that fail at preprocessing time if the vendor PAL is somehow missing — no silent fallback to hand-rolled shims.

Audit sites migrated (5/8 — sites 1, 2, 3, 4, 7)

Site 1 — FL_LPC_SCT_Shim + LPC_SCT_BASE + #define LPC_SCT (clockless_arm_lpc_pwm_dma.h):

  • Deleted. All 17 SCT call sites migrated to SCT0->.
  • Member-name renames: MATCH[i].U → MATCH[i], MATCHREL[i].U → MATCHREL[i], LIMIT_L → LIMIT (vendor stores as single 32-bit regs).

Site 2 — FL_LPC_DMA_Shim + FL_LPC_DMA_ChannelShim + #define LPC_DMA (clockless_arm_lpc_pwm_dma.h):

  • Deleted. All 7 DMA call sites migrated to DMA0->.
  • Common-block accesses now go through DMA0->COMMON[0].ENABLESET / .SETVALID / .ACTIVE.
  • @phatpaul's WIP: LPC845 PWM+DMA driver implementation #3349 DMA CHANNEL.CFG fix applied (PERIPHREQEN | HWTRIGEN, explicit TRIGPOL=0 / TRIGTYPE=0).

Site 3 — FL_LPC_SYSCON_Shim + #define LPC_SYSCON (clockless_arm_lpc_pwm_dma.h):

Site 4 — FL_LPC_SPI_Type (spi_arm_lpc.h):

  • Deleted. Driver now uses vendor SPI_Type. FL_LPC_SPI0_BASE / FL_LPC_SPI1_BASE retained as aliases for the pSPIX template parameter (now defined to SPI0_BASE / SPI1_BASE from the vendor PAL).

Site 7 — PLU raw offsets (clockless_arm_lpc_plu.h):

Sites deferred — rationale in src/platforms/arm/lpc/README.md

  • ⏳ Site 5 — LPC11 legacy GPIO. No CI workflow for LPC1110/1112/1114/1115 exists yet. Will follow the same pattern once that family enters CI.
  • ⏳ Site 6 — fastpin_arm_lpc.h already prefers vendor LPC_GPIO / GPIO (which is now always defined on LPC845/LPC804). The #else raw-offset fallback path is retained for LPC11Uxx / LPC15xx until those families get full vendor CMSIS coverage. No functional gap on LPC845/LPC804.
  • ⏳ Site 8 — rx_sct_capture.cpp.hpp (~48 raw register accesses). Opt-in driver (FASTLED_LPC_RX_SCT_DMA), not exercised by default CI builds. Mechanical migration — tracked as a follow-up PR.

Doc updates

  • agents/docs/register-maps.md: retires the "Worked anti-example: LPC845" section. Documents the third latent SCT shim bug uncovered during cross-verification and the three-repo fix chain that resolved it.
  • src/platforms/arm/lpc/README.md: audit list marks sites 1/2/3/4/7 as ✅ done, sites 5/6/8 as ⏳ deferred with per-site rationale.

Verification

  • ✅ Local bash lint --cpp passes (the only warn-only hits are pre-existing PlatformIO-internal-usage flags per ci: sweep PlatformIO build usage and add linters that enforce fbuild-only board builds #2701 and root-platformio.ini-lockdown, unrelated to LPC).
  • ✅ Upstream PR Reversing every second line in LED matrix #34 CI green across 9 jobs (arduino-cli + fbuild + platformio backends for lpc845brk, lpcxpresso804, lpcxpresso845max) — verified the new vendor headers compile cleanly with the rest of ArduinoCore-LPC8xx.
  • ⏳ FastLED's 5 LPC CI workflows (build_lpc845, build_lpc845brk, build_lpcxpresso845max, build_lpc804, build_lpcxpresso804) only trigger on push-to-master (no pull_request: trigger), so they run only post-merge. Migration discipline: every migrated driver path is opt-in (FASTLED_LPC_PWM_DMA, FASTLED_LPC_PLU, SPI is only used by user-instantiated APA102/SK9822/WS2801 strips), so the default Blink-style CI builds exercise just the foundation (SHA bump + #include), which can be reverted in a hotfix if needed.

Branch history (chronological)

  1. 07d4903de — feat(lpc): bump platform SHA to v0.2.0, include vendor CMSIS PAL
  2. 873caf407 — fix(lpc): wrap LPC845.h/LPC804.h includes in IWYU pragma block
  3. caa0f9226 — feat(lpc): migrate PWM+DMA driver + SPI driver to vendor CMSIS PAL (sites 1-4)
  4. b4004de6b — feat(lpc): migrate LPC804 PLU driver to vendor CMSIS PAL + protect INPUT/OUTPUT (site 7)
  5. 9ae6c05c1 — feat(lpc): #error guard if vendor PAL missing + docs update

Plus earlier branch commits that landed the audit-list docs and the revert of an experimental in-tree-vendoring approach.

Net effect across the three repos:

  • 3 register-offset bugs eliminated structurally (2 fixed in WIP: LPC845 PWM+DMA driver implementation #3349 + 1 newly-discovered latent SCT bug)
  • 5 of 8 hand-rolled shim/raw-offset sites deleted
  • The LPC build path now uses NXP's canonical CMSIS PAL, exactly as agents/docs/register-maps.md mandates

Cross-references

Closes #3437.

🤖 Generated with Claude Code

First step of the meta #3437 plan to remove all hand-rolled LPC register
maps. Vendors NXP's CMSIS Peripheral Access Layer for LPC845 (rev. 1.2,
BSD-3-Clause) into src/platforms/arm/lpc/cmsis/ from upstream
nxp-mcuxpresso/mcux-sdk @ SHA 8a289764.

Purely additive — no existing call sites changed. Subsequent PRs will
wire the header into led_sysdefs_arm_lpc.h (V5), then delete the three
LPC845 PWM+DMA shims (FL_LPC_SCT_Shim, FL_LPC_DMA_Shim,
FL_LPC_SYSCON_Shim) and migrate call sites to the vendor typedefs
(SCT_Type, DMA_Type, SYSCON_Type) (V6).

Verified against the new vendor header:

- SYSCON_Type.SYSAHBCLKCTRL0 is at offset 0x80 — confirms @phatpaul's
  #3349 fix (_resv0[16]→[32]) is correct. The pre-#3349 master shim
  places it at 0x40, which is wrong.
- DMA_Type.CHANNEL[].CFG/CTLSTAT/XFERCFG layout matches the shim's
  FL_LPC_DMA_ChannelShim member offsets. But the common-register
  block uses DMA0->COMMON[0].INTENSET (not LPC_DMA->INTENSET0) — the
  V6 call-site migration must rename these.
- SCT_Type has each of LIMIT/HALT/STOP/START as a SINGLE 32-bit
  register (with optional 16-bit access via an inner union). The
  FL_LPC_SCT_Shim splits each into _L/_H 32-bit pairs (8 bytes each),
  which shifts every member from COUNT onwards 16 bytes too high.
  The driver does not (yet) dereference COUNT/STATE/INPUT/etc., so
  this hidden offset bug has not manifested — but it is a latent
  defect that vendoring eliminates structurally.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 28, 2026 •

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The LPC platform README now lays out a tiered plan for sourcing vendor device headers and removing hand-rolled register access. The LPC system header now includes vendor LPC845/LPC804 device headers, and LPC8xx board/platform pins point to a new platform revision.

Changes

LPC Platform README Remediation Plan

Layer / File(s) Summary
README remediation plan
src/platforms/arm/lpc/README.md
Defines the LPC8xx header sourcing plan, lists the CMSIS shim and raw MMIO sites to remove, and states the completion criteria for retiring the LPC8xx register-map anti-example.

LPC Header and Platform Pins

Layer / File(s) Summary
Header inclusion and platform pins
src/platforms/arm/lpc/led_sysdefs_arm_lpc.h, ci/boards.py, platformio.ini
Adds conditional vendor header inclusion in led_sysdefs_arm_lpc.h and updates the pinned platform-nxplpc-arduino revision in CI boards and PlatformIO LPC8xx environments.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related issues

Possibly related PRs

  • FastLED/FastLED#2837: Directly related to LPC device-header and register-map handling in led_sysdefs_arm_lpc.h.
  • FastLED/FastLED#3209: Also modifies LPC sysdefs and device-header inclusion behavior in the same header surface.
  • FastLED/FastLED#3350: Covers the LPC register-map documentation direction referenced by this README update.

🐰 Hop-hop, the headers now align,
Vendor maps and pins in line.
The README points the way ahead,
With fewer shims and offsets read.

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR documents the migration, but it does not ship the full NXP LPC845/LPC804 CMSIS PAL requested by #33. Vendor the full LPC845.h/LPC804.h and system headers into the variant package, then remove the stubbed register-map shims.
Out of Scope Changes check ⚠️ Warning The README audit is in scope, but the board/platform pin updates and header changes go beyond the stated docs-only objective. If those implementation edits are intentional, update the PR scope; otherwise remove the CI/platform pin and header changes from this patch.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main LPC change: switching toward vendor CMSIS PAL headers and updating related board/platform references.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/3437-lpc-cmsis-vendoring

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Stop-hook lint flagged the vendored NXP LPC845.h with 2342 violations
(uint32_t use, namespace fl, IWYU pragma private, banned <stdint.h>,
plain enum) — all FastLED house-style rules that don't apply to
byte-identical-with-upstream vendored code.

Two-part fix:

1. Move src/platforms/arm/lpc/cmsis/ → src/platforms/arm/lpc/third_party/cmsis/
   so that path-substring `/third_party/` triggers the exemptions
   already wired into BareLegacy, PlatformTrampoline, PlatformPolicy
   checkers etc.

2. Add the same `/third_party/` exemption to the three checkers that
   were missing it:
   - BannedHeadersChecker (test_structure.rs) — banned-header rules
     don't apply to vendor code
   - PlatformsFlNamespaceChecker (platform_policy.rs) — vendor code
     uses upstream namespacing (no `namespace fl`)
   - IwyuPragmaPrivateChecker (bare_legacy.rs) — vendor code uses
     its own include pragmas

Updated `agents/docs/register-maps.md` to codify the path convention:
the vendored chip header now lives at
`src/platforms/<arch>/<vendor>/third_party/cmsis/<chip>.h`.

Lint goes from 2342 violations to 0 (PlatformIO-internal-usage warn-only
hits in unrelated files are pre-existing, see #2701).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/platforms/arm/lpc/README.md (1)

82-86: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Update the Tier-2 milestone path to match the actual vendored location.

The milestone description says to drop headers into src/platforms/arm/lpc/cmsis/, but the vendored files actually landed under third_party/cmsis/ (per lines 60-71 and commit messages). Update this path to src/platforms/arm/lpc/third_party/cmsis/ so the tracking document stays consistent with the file tree.

🤖 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/README.md` around lines 82 - 86, The Tier-2 vendoring
milestone path in the LPC README is inconsistent with the actual vendored
location. Update the referenced destination in the milestone text from
src/platforms/arm/lpc/cmsis/ to src/platforms/arm/lpc/third_party/cmsis/ so it
matches the current file tree and stays aligned with the CMSIS vendoring notes.
🤖 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.

Outside diff comments:
In `@src/platforms/arm/lpc/README.md`:
- Around line 82-86: The Tier-2 vendoring milestone path in the LPC README is
inconsistent with the actual vendored location. Update the referenced
destination in the milestone text from src/platforms/arm/lpc/cmsis/ to
src/platforms/arm/lpc/third_party/cmsis/ so it matches the current file tree and
stays aligned with the CMSIS vendoring notes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ac290dc0-a313-4a21-ac27-a640223d5199

📥 Commits

Reviewing files that changed from the base of the PR and between 0365745 and c047a58.

📒 Files selected for processing (8)
  • agents/docs/register-maps.md
  • ci/lint_cpp_rs/src/checkers/bare_legacy.rs
  • ci/lint_cpp_rs/src/checkers/platform_policy.rs
  • ci/lint_cpp_rs/src/checkers/test_structure.rs
  • src/platforms/arm/lpc/README.md
  • src/platforms/arm/lpc/third_party/cmsis/LPC845.h
  • src/platforms/arm/lpc/third_party/cmsis/README.md
  • src/platforms/arm/lpc/third_party/cmsis/system_LPC845.h
💤 Files with no reviewable changes (1)
  • src/platforms/arm/lpc/third_party/cmsis/system_LPC845.h
✅ Files skipped from review due to trivial changes (2)
  • src/platforms/arm/lpc/third_party/cmsis/README.md
  • agents/docs/register-maps.md

…LPC8xx

The ArduinoCore-LPC8xx platform package that fbuild uses ships a 54-line
LPC845.h stub (IRQn_Type + CMSIS-Core constants only — no peripheral
typedefs) plus a hand-rolled `cores/lpc8xx/lpc8xx_registers.h` covering
SYSCON/IOCON/SWM/USART/SPI (no SCT, no DMA, and itself buggy for the
LPC845 SYSCON layout — documented in that file's own comments). FastLED
vendored NXP's full LPC845.h in commits 0365745 + c047a58 to fill
that gap.

Discussion concluded that the upstream fix is preferable: get the
ArduinoCore-LPC8xx package to ship NXP's full vendor LPC845.h directly,
which lets FastLED stay on tier-1 (`#include <LPC845.h>`) per
agents/docs/register-maps.md with zero vendoring. This commit reverts:

- Drops src/platforms/arm/lpc/third_party/cmsis/ (vendored LPC845.h,
  system_LPC845.h, cmsis README)
- Drops the third_party/ exemption additions to BannedHeadersChecker,
  PlatformsFlNamespaceChecker, IwyuPragmaPrivateChecker (no longer
  needed without the vendored files)
- Reverts agents/docs/register-maps.md to its master state
- Updates src/platforms/arm/lpc/README.md to document the new path:
  tier-1 via upstream-fix-first, tier-2 vendoring only if upstream
  declines

The hand-rolled register-map audit list (8 sites across 6 files) and
the #3437 meta-tracking reference are preserved — they remain the
canonical inventory for whatever path lands.

Tracking issue against the upstream package will be filed separately.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@zackees zackees changed the title feat(lpc): vendor NXP LPC845.h CMSIS PAL header (#3437 V1) docs(lpc): audit list of hand-rolled register maps + #3437 tracking Jun 28, 2026
Step 3 (foundation) of FastLED #3437.

Bumps _NXPLPC_PLATFORM SHA in ci/boards.py and platformio.ini from
2ee527ae to 12265f76 — the merged tag of zackees/platform-nxplpc-arduino
v0.2.0, which pins framework-arduino-lpc8xx to
zackees/ArduinoCore-LPC8xx @ 50d76e0d. That ArduinoCore-LPC8xx SHA
ships the full NXP CMSIS PAL in variants/lpc845/LPC845.h and
variants/lpc804/LPC804.h (steps 1 + 2 of #3437, already merged
upstream).

Adds #include <LPC845.h> and <LPC804.h> to led_sysdefs_arm_lpc.h
behind FL_IS_ARM_LPC_845 / FL_IS_ARM_LPC_804 guards. Brings peripheral
typedefs (SCT_Type, DMA_Type, SYSCON_Type, SPI_Type, GPIO_Type, etc.)
and pointer macros (SCT0, DMA0, SYSCON, SPI0, SPI1) into scope for
all FastLED LPC drivers.

The existing hand-rolled shims (FL_LPC_SCT_Shim, FL_LPC_DMA_Shim,
FL_LPC_SYSCON_Shim, FL_LPC_SPI_Type, etc.) remain in place for now;
they coexist with the vendor types under different names. Subsequent
commits in this PR delete each shim and migrate the call sites.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 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.

Inline comments:
In `@platformio.ini`:
- Line 190: The root platformio.ini platform pin changes are missing the
required audit-trail comments. Update each modified platform = entry in
platformio.ini so it is immediately accompanied by adjacent ; justification: and
; added-in: comments, following the repo’s frozen-root rules. Use the existing
platform pin entries as the anchor points and add the required rationale/version
metadata for every changed non-comment line, including the block covering the
other modified platform lines referenced in this review.

In `@src/platforms/arm/lpc/led_sysdefs_arm_lpc.h`:
- Around line 102-105: The unconditional vendor-header include in
led_sysdefs_arm_lpc.h blocks the existing no-CMSIS fallback path used by
clockless_arm_lpc_pwm_dma.h and led_sysdefs.h. Make the LPC845/LPC804 include
path optional at this boundary by guarding the direct <LPC845.h>/<LPC804.h>
includes behind a suitable availability check or fallback macro, so environments
without the CMSIS headers can still parse through the led_sysdefs entrypoint.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fbc2a22b-44af-4cab-b418-709607ea8bab

📥 Commits

Reviewing files that changed from the base of the PR and between d427441 and 07d4903.

📒 Files selected for processing (3)
  • ci/boards.py
  • platformio.ini
  • src/platforms/arm/lpc/led_sysdefs_arm_lpc.h

Comment thread platformio.ini Resolved
zackees and others added 4 commits June 28, 2026 08:55
IwyuPragmaBlockChecker requires angle-bracket system headers to be
gated by '// IWYU pragma: begin_keep' / 'end_keep'. The vendor PAL
headers are unconditional requirements when the corresponding chip
is detected, so keep-block is the correct directive.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Sites 1, 2, 3, 4 of FastLED #3437 audit list — clockless_arm_lpc_pwm_dma.h
and spi_arm_lpc.h migrated to canonical NXP CMSIS PAL types/pointers.

clockless_arm_lpc_pwm_dma.h:
- Deletes FL_LPC_SCT_Shim, FL_LPC_DMA_Shim, FL_LPC_DMA_ChannelShim,
  FL_LPC_SYSCON_Shim and their #define LPC_SCT/LPC_DMA/LPC_SYSCON
  overrides
- Deletes LPC_SCT_BASE/LPC_DMA_BASE/LPC_SYSCON_BASE #defines (vendor
  provides SCT0_BASE/DMA0_BASE/SYSCON_BASE)
- Migrates all 26 call sites:
    LPC_SCT->...           ->  SCT0->...
    LPC_DMA->...           ->  DMA0->...
    LPC_SYSCON->...        ->  SYSCON->...
    LPC_SCT->MATCH[i].U    ->  SCT0->MATCH[i]    (vendor stores as plain u32)
    LPC_SCT->MATCHREL[i].U ->  SCT0->MATCHREL[i]
    LPC_SCT->LIMIT_L       ->  SCT0->LIMIT       (vendor stores as plain u32)
    LPC_DMA->ENABLESET0    ->  DMA0->COMMON[0].ENABLESET
    LPC_DMA->SETVALID0     ->  DMA0->COMMON[0].SETVALID
    LPC_DMA->ACTIVE0       ->  DMA0->COMMON[0].ACTIVE
- Applies @phatpaul's #3349 DMA CHANNEL.CFG fix (was missing PERIPHREQEN
  bit, only setting HWTRIGEN). With vendor SYSCON_Type, the SYSAHBCLKCTRL0
  bit-set in clockEnable() now writes to the correct hardware offset 0x80
  (the pre-#3349 shim had it at 0x40).

spi_arm_lpc.h:
- Deletes FL_LPC_SPI_Type typedef; uses canonical vendor SPI_Type
- FL_LPC_SPI0_BASE / FL_LPC_SPI1_BASE retained as aliases for the
  pSPIX template parameter (now defined as SPI0_BASE / SPI1_BASE
  from the vendor PAL)
- All 6 SPI driver call sites now use SPI_Type via the pSPIX-cast
  pattern

Three latent shim bugs structurally eliminated:
1. #3349 SYSAHBCLKCTRL0 offset (was 0x40, vendor truth: 0x80)
2. #3349 DMA CHANNEL.CFG missing PERIPHREQEN (now applied)
3. Newly uncovered SCT shim _L/_H pair bug (LIMIT/HALT/STOP/START were
   8-byte pairs in the shim; vendor has them as single 4-byte regs).
   Every shim member from COUNT onwards was 16 bytes too high. Driver
   doesn't dereference those today, so this was latent — now impossible.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…PUT/OUTPUT

Site 7 of FastLED #3437 audit list — clockless_arm_lpc_plu.h migrated
to canonical NXP PLU_Type / SYSCON_Type accesses.

Discovered while migrating: the previous raw-offset constants had THREE
register-block offsets wrong against UM11065 §12 (cross-checked against
NXP vendor PLU_Type in LPC804.h):

    Block         FastLED kept (wrong)   NXP vendor truth
    LUT_TRUTH       0x000                  0x800
    OUTPUT_MUX      0x800                  0xC00
    LUT_INP_MUX     0xC00                  0x000

The PLU driver code path is opt-in via FASTLED_LPC_PLU and has not
been hardware-verified on LPC804 yet (#2880 hardware bring-up pending),
which is why the bug had not surfaced. Vendoring the vendor PLU_Type
eliminates it structurally — the new code uses
PLU->LUT_TRUTH[i], PLU->LUT[i].INP_MUX[j], PLU->OUTPUT_MUX[i] and
SYSCON->SYSAHBCLKCTRL0, all of which inherit correct offsets from the
NXP-authored typedef.

The WAKEINT_CTRL register (PLU_BASE + 0xFF8) is not included in the
vendor PLU_Type (struct ends at OUTPUT_MUX[7] @ 0xC1C). The single
disable-write to it uses a small  helper that derives the
address from the vendor PLU_BASE macro — keeps the migration unblocked
without re-introducing a parallel offset table.

led_sysdefs_arm_lpc.h fix: wrap the <LPC845.h> / <LPC804.h> includes
in  / pop_macro pairs. Arduino.h on the
LPC8xx core defines INPUT / OUTPUT as preprocessor macros for
digitalRead/Write, and the vendor SCT_Type has members named INPUT
(offset 0x048) and OUTPUT (offset 0x050) per UM11029 §16.6.7-10.
Without the push/undef/pop the macros would clobber the struct
definitions. (Identical pattern to the old FL_LPC_SCT_Shim push/pop.)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
V7 of FastLED #3437: hard-require the vendor PAL via #error checks
in led_sysdefs_arm_lpc.h. If the toolchain failed to put <LPC845.h> /
<LPC804.h> on the include path (no SCT0_BASE / PLU_BASE visible), the
build now fails at preprocessing time instead of silently falling
back on hand-rolled shims.

agents/docs/register-maps.md: retires the 'Worked anti-example: LPC845'
section. The three offset bugs are documented (#3349 fixed two, the
third surfaced during #3437 cross-verification) along with the
three-repo fix that resolved them.

src/platforms/arm/lpc/README.md: marks audit sites 1, 2, 3, 4, 7 done.
Sites 5 (LPC11 legacy, no CI), 6 (fastpin fallback, retained for
LPC11/LPC15), and 8 (rx_sct_capture opt-in driver) deferred with
rationale.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@zackees zackees changed the title docs(lpc): audit list of hand-rolled register maps + #3437 tracking feat(lpc): consume vendor NXP CMSIS PAL, delete 5/8 hand-rolled register maps (closes #3437) Jun 28, 2026
…eRabbit)

Per .coderabbit.yaml frozen-root rules — every modified non-comment
line in root platformio.ini needs an adjacent justification + added-in
comment. Adds them to all 5 LPC platform pins bumped by this PR.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@zackees

zackees commented Jun 28, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai resolving your two review comments:

1. platformio.ini audit-trail comments — fixed in fdf70cc. All 5 LPC platform pin bumps now carry adjacent ; justification: + ; added-in: PR-3438 comments per .coderabbit.yaml frozen-root rules. Local bash lint --cpp confirms root-platformio.ini-lockdown clean.

2. Unconditional vendor-header include — intentional, will not change. The whole point of FastLED #3437 V7 step is to hard-require the vendor PAL with no silent fallback. The earlier no-CMSIS fallback path was the failure mode that motivated #3437 — it allowed the hand-rolled shims in clockless_arm_lpc_pwm_dma.h to ship 3 register-offset bugs (2 fixed in #3349, 1 latent uncovered during cross-verification). Making the include 'optional' here recreates exactly the bug class we're eliminating. The #error guards a few lines below the include are the deliberate enforcement mechanism: if the toolchain ever fails to provide SCT0_BASE / PLU_BASE, the build now fails at preprocessing time instead of silently falling back on hand-typed offsets. The fallback in clockless_arm_lpc_pwm_dma.h that you reference has been deleted in this PR (the entire shim block at lines 161-322 of the pre-PR file is gone) — there is no longer anything to fall back to.

Both upstream coordinating PRs are merged (zackees/ArduinoCore-LPC8xx#34 ships the headers, zackees/platform-nxplpc-arduino#9 pins the SHA), so the vendor PAL is guaranteed to be on the include path for any build going through the v0.2.0 platform pin.

@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

@zackees Thanks — the platformio.ini audit-trail fix sounds good, and your explanation on the LPC include path makes sense.

Given the deleted shim fallback in src/platforms/arm/lpc/clockless_arm_lpc_pwm_dma.h, the intentional #error enforcement in src/platforms/arm/lpc/led_sysdefs_arm_lpc.h, and the upstream headers now being guaranteed by the pinned platform, I agree my suggestion to make the vendor-header include optional does not apply here. I’m withdrawing that review concern.

🐇💭


✏️ Learnings added
Learnt from: zackees
URL: https://github.com/FastLED/FastLED/pull/3438

Timestamp: 2026-06-28T17:08:25.048Z
Learning: In FastLED's LPC8xx support, the unconditional vendor CMSIS PAL includes in `src/platforms/arm/lpc/led_sysdefs_arm_lpc.h` are intentional and should not be made optional: the project now hard-requires upstream `LPC845.h` / `LPC804.h`, uses `#error` guards to fail fast when PAL symbols such as `SCT0_BASE` or `PLU_BASE` are missing, and has removed the previous fallback shim block from `src/platforms/arm/lpc/clockless_arm_lpc_pwm_dma.h` because hand-rolled register maps caused register-offset bugs during the `#3437` migration.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

@zackees
zackees merged commit defbb34 into master Jun 28, 2026
10 of 12 checks passed
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 28, 2026
zackees added a commit to FastLED/fbuild that referenced this pull request Jun 28, 2026
…S PAL (#785)

Updates ACLPC_COMMIT, ACLPC_VERSION, ACLPC_URL, and ACLPC_CHECKSUM in
crates/fbuild-packages/src/library/arduino_core_lpc8xx.rs:

  COMMIT:   195a2eddd31eba8472ceaffa6a1a1902f72439ae
            -> 50d76e0d63c2d2a2b365b29de47100d93c530c83
  VERSION:  0.1.0+g195a2ed -> 0.2.0+g50d76e0
  URL:      bumped tarball URL to new SHA
  CHECKSUM: 366de74b93179ba4b5e8ac9e527f15f189d9e26bcedd030fe11c11a2c907f3e4
            -> e6bbcc3392ae9da44c5c92268d7cd953770e0011fcf285561104633e36087428

FastLED/framework-arduino-lpc8xx#34 ships the full NXP CMSIS Peripheral Access
Layer in variants/lpc845/LPC845.h (~10K lines) and variants/lpc804/
LPC804.h (~7K lines), replacing the previous 54/49-line IRQn-only stubs.
The vendor headers (rev. 1.2, BSD-3-Clause from nxp-mcuxpresso/mcux-sdk)
provide canonical peripheral typedefs (SCT_Type, DMA_Type, SYSCON_Type,
SPI_Type, GPIO_Type, SWM_Type, IOCON_Type, PINT_Type, INPUTMUX_Type,
PLU_Type for LPC804, etc.) plus pointer macros (SCT0, DMA0, SYSCON,
SPI0/1, PLU, IOCON, SWM0, ...).

Unblocks downstream FastLED #3437 which migrated FastLED's LPC drivers
to vendor typedefs (FastLED/FastLED#3438 merged today). After this
fbuild pin bump, the fbuild backend will pull the same upstream commit
that the platformio backend now pulls via platform-nxplpc-arduino
v0.2.0 (FastLED/platform-nxp-lpc8xx#9, also pinned at the same
ArduinoCore-LPC8xx SHA).

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
zackees added a commit that referenced this pull request Jul 1, 2026
…ers (#3502)

- Fix stale LPC845 clock reference (30 MHz -> actual 24 MHz FRO direct path per
  led_sysdefs_arm_lpc.h:49).
- Add newly shipped drivers to the Supported Platforms table:
  - LPC845 SCT+DMA channels-API engine (#3460, TX->RX byte-match verified #3472)
  - LPC845 SPI+DMA async driver (#3454)
  - LPC804 SPI+DMA async gate (#3500, requires fbuild >= 2.3.16 for LPC804
    CMSIS DMA0 typedef from framework-arduino-lpc8xx#35 + fbuild#916)
- Document new files under Files: spi_arm_lpc_dma.h, drivers/sct_dma/*,
  rx_sct_capture.{h,cpp.hpp}.
- Document new opt-in feature defines: FASTLED_LPC_SPI_DMA,
  FASTLED_LPC_SPI_DMA_CHANNEL, FASTLED_LPC_SPI_DMA_MAX_BYTES.
- Add recent shipped PRs (#3438 register-map remediation, #3454, #3460, #3472,
  #3500) and cross-repo prerequisites (framework-arduino-lpc8xx#35, fbuild#916).
- Add open follow-ups #3437 (register-map meta), #3501 (LPC11Uxx/LPC15xx SPI),
  fbuild#565 (CMSIS-DAP deploy).

No code changes.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Meta: Replace all hand-rolled LPC register maps with vendor CMSIS PAL headers

1 participant