Skip to content

fix(platform/lpc): address CodeRabbit follow-ups on #2872 (writeBit RX-ignore, writePixels context, stale comments) - #2876

Merged
zackees merged 1 commit into
masterfrom
feat/2875-cr-followup-lpc-spi
Jun 6, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/2875-cr-followup-lpc-spi

Conversation

@zackees

@zackees zackees commented Jun 6, 2026 •

Copy link
Copy Markdown
Member

Closes #2875.

Summary

CodeRabbit posted 6 findings on PR #2872 that were not addressed pre-merge. This PR sweeps 5 of them and documents why the 6th cannot apply.

# Finding Status
1 spi_arm_lpc.h::writeBit() missing FL_LPC_SPI_TXCTL_RXIGNORE (RXOV bug) ✅ Fixed
2 writePixels() / writeBytes() drop context arg → D::postBlock(len, context) ✅ Fixed
3 Move method bodies to .impl.hpp ⚠️ Skipped — conflicts with repo's impl_hpp_includes_checker.py for template-heavy headers (see below)
4 fastpin_arm_lpc.h:36 stale "LPC8xx GPIO" comment ✅ Updated to modern LPC family
5 fastpin_arm_lpc.h:77 stale "LPC8xx pins" comment ✅ Updated
6 README.md "14 items" → "15 items" ✅ Corrected with per-owner subtotals

Why finding 3 was skipped

CR's suggestion: move ARMHardwareSPIOutput method bodies into spi_arm_lpc.impl.hpp per the "no function definitions in src/**/*.h" coding guideline.

When I attempted the split, the repo's own impl_hpp_includes_checker.py lint rule fired: *.impl.hpp files must ONLY be included by *.impl.cpp.hpp router files. ARMHardwareSPIOutput is a class template — definitions must be visible at every instantiation point, so a non-template .impl.cpp.hpp router cannot host them. This matches every other template SPI driver in src/platforms/arm/*/spi_*.h (k20, mxrt1062, samd21, etc.). The non-template SPI drivers (spi_hw_2_nrf52.cpp.hpp etc.) use the .cpp.hpp convention precisely because they're non-template.

Added an inline @file comment to the header explaining the deviation.

Drive-by

  • Pre-existing reinterpret_cast violation on the SPI base-address cast (flagged by ReinterpretCastChecker against master) — converted to the (volatile T*)(base) C-style pattern matching clockless_arm_lpc_plu.h::reg32. Per CLAUDE.md's "fix all encountered errors immediately" rule.

Test plan

  • bash lint --cpp — clean
  • bash test --cpp — 310/310 host tests pass
  • CI fbuild matrix LPC845 / LPC804 jobs
  • Hardware bring-up of the RX-ignore fix is not required for this PR — Stage 3 (meta: LPC dev roadmap — Stages 3 + 4 (port completion, family expansion) #2845) covers scope-measured timing and is maintainer-only. Finding 1 is a register-flag correctness issue verifiable by inspection against UM11029 §SPI.

Related

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved SPI transmit reliability for ARM LPC platforms.
  • API Updates

    • Extended SPI write methods with optional context parameter for enhanced flexibility.
  • Documentation

    • Clarified platform-specific hardware implementation details and GPIO controller specifications.

Closes #2875.

CodeRabbit posted 6 findings on PR #2872 that landed without
addressing. This PR sweeps 5 of them.

1. **spi_arm_lpc.h::writeBit() RX-ignore (correctness).** The
   single-bit transmit helper was the only path writing TXDATCTL
   without setting `FL_LPC_SPI_TXCTL_RXIGNORE`. Every call clocked
   data into RXDAT, and the driver never drained it — repeated bit
   writes (e.g. APA102 / SK9822 / SM16716 start-bit prefixes on
   long strips) would accumulate RXOV. Now ORs the flag in to match
   writeByte().

2. **spi_arm_lpc.h::writePixels() / writeBytes() context forwarding
   (correctness).** Both bracketed paths accepted a `context` arg
   but dropped it before calling `D::postBlock(len)`. Every other
   SPI backend in `src/platforms/*/spi_*.h` forwards the value as
   `D::postBlock(len, context)`. Forwarded here so context-dependent
   adjuster cleanup runs and instantiation against 2-argument-only
   adjusters works.

3. **spi_arm_lpc.h MMIO cast (drive-by clippy).** `reinterpret_cast`
   on the SPI base address was already flagged by
   `ReinterpretCastChecker` against master; converted to the
   `(volatile T*)(base)` C-style pattern the linter allows for MMIO
   (matches `clockless_arm_lpc_plu.h::reg32`).

4. **fastpin_arm_lpc.h:36 stale comment.** GPIO-controller struct
   comment now reflects the modern LPC family (LPC8xx / LPC11Uxx /
   LPC15xx all at 0xA0000000).

5. **fastpin_arm_lpc.h:77 stale comment.** FastPin template comment
   widened from "LPC8xx pins" to "modern LPC GPIO pins" with the
   PORT0-only caveat preserved.

6. **README.md item count.** Implementation map summary said "14
   items" but the table has 15 rows (Stage 4.1 split into two
   during #2872). Corrected to 15 with accurate per-owner subtotals.

## Skipped finding

CR also suggested moving the `ARMHardwareSPIOutput` method bodies
out of `spi_arm_lpc.h` into a `.impl.hpp`. That conflicts with the
repo's own `impl_hpp_includes_checker.py` lint rule: `.impl.hpp`
files may only be included from `.impl.cpp.hpp` routers (non-
template compile units). `ARMHardwareSPIOutput` is a class
template — definitions must be visible at every instantiation
point, which rules out the router pattern. This matches the other
template SPI drivers in `src/platforms/arm/*/spi_*.h`. Added an
inline comment to the header explaining the deviation. The
non-template SPI drivers (`spi_hw_*nrf52.cpp.hpp` etc.) follow the
`.cpp.hpp` convention exactly because they are non-template.

## Test plan

- [x] `bash lint --cpp` clean (also cleared a pre-existing
      ReinterpretCastChecker violation on the SPI base-address cast).
- [x] `bash test --cpp` — 310/310 host tests pass.
- [ ] CI fbuild matrix LPC845 / LPC804 jobs (validate on push).
- [ ] Hardware bring-up of the RX-ignore fix is **not** required
      for this PR — Stage 3 (#2845) covers scope-measured timing
      and is maintainer-only. The Finding 1 fix is a register-flag
      correctness issue verifiable by inspection.
@coderabbitai

coderabbitai Bot commented Jun 6, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9c9b97ce-bcc9-4073-8e01-1c5d8392c1f4

📥 Commits

Reviewing files that changed from the base of the PR and between ff1e888 and 037e574.

📒 Files selected for processing (3)
  • src/platforms/arm/lpc/README.md
  • src/platforms/arm/lpc/fastpin_arm_lpc.h
  • src/platforms/arm/lpc/spi_arm_lpc.h

📝 Walkthrough

Walkthrough

This PR addresses six CodeRabbit follow-ups from issue #2875 targeting the LPC8xx SPI driver and platform documentation. Changes include GPIO controller comment clarifications for the modern LPC family, SPI driver bug fixes (RX-ignore flag, context parameter forwarding), and roadmap documentation updates.

Changes

LPC Platform Fixes and Documentation

Layer / File(s) Summary
Platform GPIO and roadmap documentation
src/platforms/arm/lpc/fastpin_arm_lpc.h, src/platforms/arm/lpc/README.md
LPC GPIO controller comments now clarify the shared DIR/MASK/PIN/SET/CLR/NOT layout at 0xA0000000 across LPC8xx/LPC11Uxx/LPC15xx, note that legacy LPC11xx at 0x50000000 is gated out, and state that PORT0 is primary with multi-port support pending per-variant implementation. README implementation roadmap count updated from 14 to 15 items to match the decomposed task table.
SPI driver implementation and API updates
src/platforms/arm/lpc/spi_arm_lpc.h
Header-only design rationale documented. Register accessor spi_block() uses C-style cast instead of reinterpret_cast. Per-bit transmit path writeBit() now sets FL_LPC_SPI_TXCTL_RXIGNORE flag to prevent RX overrun on repeated calls. Methods writeBytes() and writePixels() now accept void* context parameter (defaulting to nullptr) and forward it to D::postBlock(len, context) instead of the context-less form.

Sequence Diagram(s)

No sequence diagram needed for this PR. The changes consist of documentation clarifications, minor cast changes, flag additions to register writes, and parameter threading through existing call sites without introducing new control flow or component interactions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related issues

  • FastLED/FastLED#2865: Fastpin_arm_lpc.h documentation updates clarifying the LPC8xx ("modern") GPIO base address and gating out legacy LPC11xx directly relate to scoping LPC8xx-specific GPIO code.

Possibly related PRs

  • FastLED/FastLED#2872: This PR addresses CodeRabbit follow-ups (writeBit RX-ignore, writePixels context, documentation freshness) from the merged #2872 Stage 4 LPC8xx SPI driver introduction.

Poem

🐰 A rabbit's note on LPC's fix,
When register flags mix and bits twist,
RX-ignore blooms, context flows through,
Docs say "modern LPC"—the scope crystal-true!
From rabbit feedback, the platform stands tall. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
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 (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main changes: addressing CodeRabbit follow-ups on PR #2872, specifically mentioning writeBit RX-ignore, writePixels context, and stale comments.
Linked Issues check ✅ Passed The PR addresses 5 of 6 coding objectives from issue #2875: writeBit RX-ignore fix [#2875 Finding 1], writePixels context forwarding [#2875 Finding 2], fastpin comments update [#2875 Findings 4-5], and README item-count correction [#2875 Finding 6]. The header-impl split (Finding 3) was deferred due to template constraints.
Out of Scope Changes check ✅ Passed All changes directly address the five implemented CodeRabbit findings from issue #2875; no unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/2875-cr-followup-lpc-spi

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 and usage tips.

@zackees
zackees merged commit 2c346c9 into master Jun 6, 2026
7 checks passed
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 6, 2026
zackees added a commit that referenced this pull request Jun 6, 2026
…-up links (#2881)

Closes #2845.

The Stages 3 + 4 roadmap meta has run its course:

- **3 items shipped** — Stage 4.1 (LPC11Uxx clockless), 4.2 (LPC15xx
  clockless), 4.3 (APA102 / SK9822 / WS2801 SPI). All three landed in
  #2872 with CodeRabbit follow-up fixes in #2876.
- **6 items moved to fbuild** — Stage 3.1 - 3.4 + 3.7 + 3.8 now live
  under fbuild #456 (`Meta: LPC port completion — Stage 3 fbuild-side
  items`).
- **3 items moved to hardware-gated follow-ups** — Stages 3.5 + 3.6
  consolidated at FastLED #2880 (LPC845 hardware bring-up); Stage 4.4
  at #2879 (multi-strip, blocked on Stage 2c).
- **1 item moved to a code-only follow-up** — Stage 4.1 legacy at
  #2878 (the LPC1110/1112/1114/1115 fastpin against the 0x50000000
  masked-access GPIO).
- **2 items deferred** — Stage 4.5 (PIO donation; no upstream nxplpc
  platform exists) and Stage 4.6 (`fl::set_*` clock overrides; no
  concrete user requirement). Either reopens when there is a real
  ask.

This PR is a documentation-only change to
`src/platforms/arm/lpc/README.md`:

1. Adds GitHub Actions build-status badges for the existing
   `build-lpc845.yml` and `build-lpc804.yml` workflows in fbuild,
   matching the badge style used in the root FastLED README.
2. Notes that LPC11Uxx and LPC15xx compile against the same shared
   driver headers (fbuild #456 covers dedicated CI for those
   families).
3. Rewrites the implementation map so each row points at the
   smaller follow-up issue that owns it.
4. Reorganises the References section into Meta + Shipped + Open
   follow-ups + NXP user manuals.

## Test plan

- [x] `bash lint --cpp` clean (README-only change; no source touched).
- [x] All badge URLs and issue links typed against the workflows /
      issues confirmed live via `gh` before commit.
@zackees
zackees deleted the feat/2875-cr-followup-lpc-spi branch August 21, 2026 19:15
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.

feat(platform/lpc): address CodeRabbit follow-ups on #2872 (writeBit RX-ignore, writePixels context, header-impl split, stale comments)

1 participant