Repository navigation
fix(lpc): native LPC845/LPC804 pin backend; honor forced software pins - #5261
Conversation
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
|
Caution Review failedThe pull request is closed. Walkthrough
Merge Risk:
|
Memory usage (this PR vs. its merge base)Change in
|
Fixes #5260.
Production path
BIT_BANGdriver.FastLED.enableAllDrivers()registers the sharedBitBangChannelDriverasBusTraits<Bus::BIT_BANG,0>whenFASTLED_LPC_PWM_DMAis not set. That driver writes every lane and the SPI clock throughfl::digitalWrite(DigitalMultiWrite8). Before this PR, LPC routed those calls topin_noop.hpp, so the driver produced no signal.FASTLED_FORCE_SOFTWARE_PINSon LPC845/LPC804. Software SPI (APA102 on any pins) now goesNoPinMapPin<N>→fl::digitalWrite→platforms::digitalWriteinpin_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-bytelpc_pin_detail::IoconTable<void>::kIndex.fl::DigitalPin,fl::Pin, analog-RGBpinModeand RX validation on LPC8xx now reach real GPIO.Changes
New
src/platforms/arm/lpc/pin_lpc.hpp(LPC845/LPC804 only).lpc_detailaccessors, which wrap the vendorGPIO->DIRSET/DIRCLR/SET/CLR/PIN[0]registers.IOCON->PIO[IoconTable::kIndex[n]]. The table is built from the vendorIOCON_INDEX_PIO0_nmacros. PIO0_6 and PIO0_31 do not exist on LPC804 and are guarded. AFL_STATIC_ASSERTchecks every index againstIOCON_Type::PIO.FastPin<N>. Invalid pins are a no-op, and reads returnLow.Outputleaves the pull setting alone.Inputmeans no pull, which matches the documented meaning ofPinMode::Input(high impedance).src/platforms/pin.h: LPC845/LPC804 dispatch topin_lpc.hpp. LPC11xx/LPC11Uxx/LPC15xx keeppin_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:
FL_FASTPIN_HAS_NO_PINMAP,_ARMPINderives fromNoPinMapPin. LPC8xx joins the checked primary template, so pins outside the PIO0_0..31 grid stay invalid.FL_LPC_ENABLE_FAST_SOFTWARE_SPIBitbangPinpolicy andHAS_HARDWARE_PIN_SUPPORTare turned off in forced mode.clockless_arm_lpc.handclockless_arm_lpc_plu.hnow fail withFL_STATIC_ASSERT(DATA_PIN != DATA_PIN, "FASTLED_FORCE_SOFTWARE_PINS is not supported by ..."). Both needFastPin::port()or per-bit register writes.#errorinfastpin_base.hnow 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.hppbindsBusTraits<DefaultBus<Chipset>::value>. LPC'sDefaultBuspointed at BusTraits that do not exist:Bus::SPIfor SPI chipsets on LPC845/LPC804. LPC has no channels-API SPI driver;spi_arm_lpc.his a legacy SPIOutput.Bus::BIT_BANGfor 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 underFASTLED_LPC_PWM_DMA). I did not route LPC804 to the sharedBitBangChannelDriver: 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. Newci/tests/test_lpc_default_bus.pypins this.README: updated the file list and forced-pin notes, and corrected the stale claim that
fastled_arm_lpc.hemits#errorfor LPC11/15.Evidence (fbuild, run one at a time)
bus.hfix-DFASTLED_FORCE_SOFTWARE_PINSstatic assertion failed: FASTLED_FORCE_SOFTWARE_PINS is not supported by the LPC bit-bang clockless driverSTRIP_DATA_PIN=20,STRIP_CLOCK_PIN=21FASTLED_LPC_UART_DMA=0, pins 20/21Master
b95c3031fcfails to build lpc845 and lpc804 Blink (theBusTraitserrors 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_bindingsandbash test bus_traits: both passed./code-review mediumraised 8 findings. Fixed:default:from thePinModeswitch so-Wswitchflags any new mode.BitBangChannelDriverdefault-bus include. It would have silently produced bad WS2812 output on LPC804 and nothing on LPC11/15.Declined, with reasons:
Inputclearing the pull: that is the documentedPinMode::Inputsemantics.Not done
fbuild port scan. The--pin-toggle-rxbench still uses the core's::digitalWrite, so a mode that drivesfl::pinMode/digitalWriteis a follow-up.DIRSETbug: belongs to LPC11Uxx/LPC15xx: verify modern GPIO template, no board entry in ci/boards.py #5108. The narrowed#errorstays for those families.framework-arduino-lpc8xxIOCON mis-indexing inpinMode: reported separately.Summary by CodeRabbit