Skip to content

fix(lpc): native LPC845/LPC804 pin backend; honor forced software pins - #5261

Merged
zackees merged 1 commit into
masterfrom
fix/lpc-pin-backend-5260
Nov 17, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/lpc-pin-backend-5260

Conversation

@zackees

@zackees zackees commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Fixes #5260.

Production path

  • LPC845 channels-API BIT_BANG driver. FastLED.enableAllDrivers() registers the shared BitBangChannelDriver as BusTraits<Bus::BIT_BANG,0> when FASTLED_LPC_PWM_DMA is not set. That driver writes every lane and the SPI clock through fl::digitalWrite (DigitalMultiWrite8). Before this PR, LPC routed those calls to pin_noop.hpp, so the driver produced no signal.
  • FASTLED_FORCE_SOFTWARE_PINS on LPC845/LPC804. Software SPI (APA102 on any pins) now goes NoPinMapPin<N> → fl::digitalWrite → platforms::digitalWrite in pin_lpc.hpp. The symbols in the forced LPC845 APA102 firmware confirm it: fl::NoPinMapPin<20/21>::hi/lo, fl::digitalWrite, fl::pinMode, fl::platforms::digitalWrite, and one 32-byte lpc_pin_detail::IoconTable<void>::kIndex.
  • fl::DigitalPin, fl::Pin, analog-RGB pinMode and RX validation on LPC8xx now reach real GPIO.

Changes

  • New src/platforms/arm/lpc/pin_lpc.hpp (LPC845/LPC804 only).

    • Digital ops use the existing lpc_detail accessors, which wrap the vendor GPIO->DIRSET/DIRCLR/SET/CLR/PIN[0] registers.
    • Pulls go through IOCON->PIO[IoconTable::kIndex[n]]. The table is built from the vendor IOCON_INDEX_PIO0_n macros. PIO0_6 and PIO0_31 do not exist on LPC804 and are guarded. A FL_STATIC_ASSERT checks every index against IOCON_Type::PIO.
    • Clocks: the GPIO0/IOCON clock enable is an idempotent OR. SWM is not touched.
    • Analog and PWM are stubs, as in the report. The functions never call FastPin<N>. Invalid pins are a no-op, and reads return Low.
    • Output leaves the pull setting alone. Input means no pull, which matches the documented meaning of PinMode::Input (high impedance).
  • src/platforms/pin.h: LPC845/LPC804 dispatch to pin_lpc.hpp. LPC11xx/LPC11Uxx/LPC15xx keep pin_noop.hpp.

  • Forced pins, following the pattern of fix(esp32): honor forced software pins without Arduino port maps #5241 and fix(esp8266): honor forced software pins in native FastPin specializations #5258:

    • Under FL_FASTPIN_HAS_NO_PINMAP, _ARMPIN derives from NoPinMapPin. LPC8xx joins the checked primary template, so pins outside the PIO0_0..31 grid stay invalid.
    • The FL_LPC_ENABLE_FAST_SOFTWARE_SPI BitbangPin policy and HAS_HARDWARE_PIN_SUPPORT are turned off in forced mode.
    • clockless_arm_lpc.h and clockless_arm_lpc_plu.h now fail with FL_STATIC_ASSERT(DATA_PIN != DATA_PIN, "FASTLED_FORCE_SOFTWARE_PINS is not supported by ..."). Both need FastPin::port() or per-bit register writes.
    • The #error in fastpin_base.h now fires only for LPC families without a backend (LPC11xx/LPC11Uxx/LPC15xx).
  • Pre-existing master breakage fixed (outside the issue's scope, but it blocked every verification build). Since fix(channels): add(cfg) binds default driver when no bus enabled (3.10.9 compat) #5250, FastLED.cpp.hpp binds BusTraits<DefaultBus<Chipset>::value>. LPC's DefaultBus pointed at BusTraits that do not exist:

    • Bus::SPI for SPI chipsets on LPC845/LPC804. LPC has no channels-API SPI driver; spi_arm_lpc.h is a legacy SPIOutput.
    • Bus::BIT_BANG for clockless on LPC804.

    Master Blink failed on both boards with incomplete type 'fl::BusTraits<...>'. Board CI is skipped on master, so nobody noticed. DefaultBus<ClocklessChipset> is now specialized only for LPC845's real engines (UART-DMA by default, SCT-DMA under FASTLED_LPC_PWM_DMA). I did not route LPC804 to the shared BitBangChannelDriver: it cannot meet WS2812 timing at 15 MHz through per-bit function calls. add(cfg) with no enabled bus now binds nothing on those targets, as it did before fix(channels): add(cfg) binds default driver when no bus enabled (3.10.9 compat) #5250. New ci/tests/test_lpc_default_bus.py pins this.

  • README: updated the file list and forced-pin notes, and corrected the stale claim that fastled_arm_lpc.h emits #error for LPC11/15.

Evidence (fbuild, run one at a time)

Config Result Flash / RAM (bytes)
lpc845 Blink ok 13880 / 4720
lpc845 Blink, master + only the bus.h fix ok 13880 / 4720 (no change)
lpc845 Blink -DFASTLED_FORCE_SOFTWARE_PINS ok (UART-DMA clockless does not use FastPin GPIO) 13880 / 4720
lpc804 Blink ok 6764 / 2144
lpc804 Blink, master + only the DefaultBus fix ok 6764 / 2144 (no change)
lpc804 Blink forced expected failure: static assertion failed: FASTLED_FORCE_SOFTWARE_PINS is not supported by the LPC bit-bang clockless driver —
lpc845 Apa102 STRIP_DATA_PIN=20,STRIP_CLOCK_PIN=21 ok 5940 / 4192
lpc845 Apa102 forced, pins 20/21 ok 6480 / 4200 (+540: pin backend + per-pin calls)
lpc804 Apa102 pins 20/21 ok 5772 / 2200
lpc804 Apa102 forced, pins 20/21 ok 6312 / 2208
lpc845brk Blink / forced ok / ok 13880 / 4720 both
lpc845 Apa102 FASTLED_LPC_UART_DMA=0, pins 20/21 ok 5816 / 3992
lpc845 AutoResearch ok 60632 / 10364

Master b95c3031fc fails to build lpc845 and lpc804 Blink (the BusTraits errors above).

  • bash lint: green.

  • uv run pytest ci/tests -k "lpc or forced or pin_remap or bus": 69 passed. LPC tests: 18 passed.

  • bash test driver_bindings and bash test bus_traits: both passed.

  • /code-review medium raised 8 findings. Fixed:

    • ODR: the IOCON table is now a class-template static, so there is one definition program-wide.
    • Removed default: from the PinMode switch so -Wswitch flags any new mode.
    • Dropped the BitBangChannelDriver default-bus include. It would have silently produced bad WS2812 output on LPC804 and nothing on LPC11/15.
    • Added a test for the LPC DefaultBus.

    Declined, with reasons:

    • Input clearing the pull: that is the documented PinMode::Input semantics.
    • FastPin<6>/<31> on LPC804: the native grid already declares these pins in non-forced mode. The backend ignores them safely.
    • Source-text tests: real firmware builds are the end-to-end compile evidence. Hardware is out of scope here.

Not done

  • No hardware run. The LPC845-BRK was not present in fbuild port scan. The --pin-toggle-rx bench still uses the core's ::digitalWrite, so a mode that drives fl::pinMode/digitalWrite is a follow-up.
  • LPC11Uxx/LPC15xx FastPin base address and DIRSET bug: belongs to LPC11Uxx/LPC15xx: verify modern GPIO template, no board entry in ci/boards.py #5108. The narrowed #error stays for those families.
  • Upstream framework-arduino-lpc8xx IOCON mis-indexing in pinMode: reported separately.

Summary by CodeRabbit

  • New Features
    • LPC845 and LPC804 boards now support runtime GPIO mode, read, and write operations for supported pins. Pins unavailable on a board are treated as invalid.
  • Compatibility
    • Forced software pins are supported on LPC845 and LPC804; they remain unsupported on LPC11xx, LPC11Uxx, and LPC15xx. LPC bit-banged clockless drivers reject forced-pin configurations.
    • LPC845 clockless output defaults to UART with UART DMA or bit-bang with PWM DMA. Other LPC targets and configurations have no default clockless specialization, and LPC targets have no default SPI bus.
  • Documentation
    • Updated LPC platform documentation to describe pin support and driver constraints.

fl::pinMode/digitalWrite/digitalRead were no-ops on every LPC target
(platforms/shared/pin_noop.hpp), so the LPC845 channels-API BIT_BANG
driver, fl::DigitalPin and forced software pins drove nothing.

- Add platforms/arm/lpc/pin_lpc.hpp for LPC845/LPC804: GPIO via the
  shared lpc_detail accessors (vendor GPIO->DIRSET/DIRCLR/SET/CLR/PIN),
  pulls via IOCON->PIO[IOCON_INDEX_PIO0_n] from a table built from the
  vendor macros (the IOCON array is not in pin order), idempotent
  GPIO0/IOCON clock enable, no SWM changes, analog/PWM stubs. It never
  calls FastPin<N>, which is NoPinMapPin under forced pins.
- Dispatch LPC845/LPC804 to it; other LPC families keep pin_noop.
- Under FASTLED_FORCE_SOFTWARE_PINS, _ARMPIN derives from NoPinMapPin,
  unlisted pins stay invalid, the register-level BitbangPin policy and
  HAS_HARDWARE_PIN_SUPPORT are gated off, and the cycle-counted and PLU
  clockless drivers (which need FastPin::port()) fail with a static
  assert. The fastpin_base.h #error now covers only LPC11xx/LPC11Uxx/
  LPC15xx.
- Fix master LPC builds broken since #5250: DefaultBus named BusTraits
  that do not exist on LPC (Bus::SPI everywhere, Bus::BIT_BANG on
  LPC804). DefaultBus is now specialized only for the LPC845 UART-DMA
  and SCT-DMA engines.

Fixes #5260
@zackees
zackees enabled auto-merge November 17, 2026 17:16
@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

The PR adds a runtime GPIO backend for LPC845 and LPC804, updates forced-software-pin support and rejection rules across LPC families, and changes LPC default-bus specializations.

Changes: LPC platform support

Layer / File(s) Summary
Runtime pin backend and dispatch
src/platforms/arm/lpc/pin_lpc.hpp, src/platforms/pin.h, ci/tests/test_lpc_forced_software_pins.py
LPC845 and LPC804 now use a runtime GPIO backend for pin mapping, mode, and digital I/O. Other LPC families retain the no-op backend. Tests check backend dispatch and implementation constraints.
Forced software-pin routing and constraints
src/fl/system/fastpin_base.h, src/platforms/arm/lpc/fastpin_arm_lpc.h, src/platforms/arm/lpc/clockless_arm_lpc*.h, ci/tests/test_lpc_forced_software_pins.py, src/platforms/arm/lpc/README.md
Forced software pins are enabled for LPC845 and LPC804 and rejected for LPC11xx, LPC11Uxx, and LPC15xx. Forced mode uses NoPinMapPin; the port-based clockless drivers reject it. Tests and documentation cover these rules.
LPC default-bus selection
src/fl/channels/bus.h, ci/tests/test_lpc_default_bus.py
The LPC845 clockless default selects UART for FASTLED_LPC_UART_DMA or bit-bang for FASTLED_LPC_PWM_DMA. Other LPC configurations have no clockless specialization. The LPC SPI default specialization is removed. Tests check these conditions.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Possibly related issues

Possibly related PRs

Merge Risk: Minimal · up to cfa56

This PR adds an LPC845/LPC804 runtime GPIO backend and fixes the LPC default-bus bindings. No concrete merge-blocking risk was identified; the remaining feedback is minor test hygiene and coverage suggestions.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@github-actions github-actions Bot added the sanitized Title, body and conversation screened; review text requires separate screening. label Nov 17, 2026
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Nov 17, 2026
@github-actions github-actions Bot removed the sanitized Title, body and conversation screened; review text requires separate screening. label Nov 17, 2026
@zackees
zackees added this pull request to the merge queue Nov 17, 2026
@github-actions github-actions Bot added the sanitized Title, body and conversation screened; review text requires separate screening. label Nov 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Memory usage (this PR vs. its merge base)

Change in examples/Blink per target. The left number is this PR's image flash / attributed RAM in bytes; the colored delta is the change from the merge base (red ↑ is larger, green ↓ is smaller, Same is unchanged).

Target FLASH [bytes] RAM [bytes]
attiny85 2,460 (Same) 136 (Same)

@github-actions github-actions Bot added sanitized Title, body and conversation screened; review text requires separate screening. and removed sanitized Title, body and conversation screened; review text requires separate screening. labels Nov 17, 2026
Merged via the queue into master with commit 2e7b0f3 Nov 17, 2026
132 of 133 checks passed
@zackees
zackees deleted the fix/lpc-pin-backend-5260 branch November 17, 2026 17:25
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Nov 17, 2026
@github-actions github-actions Bot added sanitized Title, body and conversation screened; review text requires separate screening. and removed sanitized Title, body and conversation screened; review text requires separate screening. labels Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sanitized Title, body and conversation screened; review text requires separate screening.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

LPC: implement fl::pinMode/digitalWrite backend (replace pin_noop) so FASTLED_FORCE_SOFTWARE_PINS and runtime pins work

1 participant