Skip to content

feat(esp8266): expose hardware HSPI as Bus::SPI; retire FASTLED_ALL_PINS_HARDWARE_SPI (#4942) - #4951

Merged
zackees merged 1 commit into
masterfrom
feat/4942-esp8266-hspi-bus
Oct 28, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/4942-esp8266-hspi-bus

Conversation

@zackees

@zackees zackees commented Oct 27, 2026

Copy link
Copy Markdown
Member

Stacked on #4950 (#4941). Fixes #4942. Part of #4949.

Problem

The register-level HSPI driver (fastspi_esp8266_hspi.h, SPI1 on GPIO13/14) was
reachable only through the legacy SPIOutput<> dispatch, and a non-HSPI pin pair
needed the define-gated Arduino-SPI shim (FASTLED_ALL_PINS_HARDWARE_SPI →
fastspi_esp8266.h). No ESP8266 BusTraits<Bus::SPI>, so the channel API could
not select the hardware engine.

Change (template selection, not a code-enabling define)

  • hspi_channel_driver.{h,cpp.hpp} (new) — Esp8266HspiChannelDriver
    streams the already-encoded SPI byte stream (start frame + pixels + end frame)
    over the SPI1 FIFO, blocking per ≤64-byte transfer. canHandle() accepts only
    the fixed GPIO13 (data) / GPIO14 (clock) pad pair; every other pair falls
    through to the shared bit-bang bus. Extraction of the register sequence mirrors
    the proven ESP8266HSPIOutput (GPC/GPEC/GPF, SPI1U/SPI1U1/SPI1CLK,
    SPI1W0..15/SPI1CMD); clock division reuses host-tested
    esp8266::hspiClockFor().
  • hspi_bus_traits.h (new) — specializes BusTraits<Bus::SPI> +
    BusSupports<Bus::SPI, SpiChipsetConfig>, so naming Bus::SPI keeps the TU and
    everything else dead-strips (feat(channels): compile-time Bus binding via templated ChannelConfig (eliminates Channel API binary bloat) #2428). Registered in the ESP8266 channel-driver
    fragment.
  • Retire FASTLED_ALL_PINS_HARDWARE_SPI — delete fastspi_esp8266.h, drop
    its include from fastled_esp8266.h and the spi_output_template.h branch, and
    remove the ESP8266 clause from fastspi.h's FL_DATA_RATE_MHZ interpretation.
  • compile_test.hpp — assert the Bus::SPI specialization is present and
    resolves through TypedChannel<Bus::SPI, SpiChipsetConfig>.
  • READMEs updated.

Test plan / evidence

  • bash compile esp8266 --examples Blink succeeds; the firmware image is
    byte-for-byte identical to the pre-change build (flash 264667 B, RAM 27536 B)
    — the unused driver is link-eliminated, which is the point.
  • compile_test.hpp asserts run on every ESP8266 build.
  • On-hardware APA102 on 13/14 (channel API add<SpiChipsetConfig>()) is the
    remaining acceptance step (needs a board).

…INS_HARDWARE_SPI

The register-level HSPI driver (SPI1 on GPIO13/14) was reachable only
through the legacy SPIOutput<> dispatch, and a non-HSPI pair needed the
define-gated Arduino-SPI shim (FASTLED_ALL_PINS_HARDWARE_SPI). Add a
channel-API driver for the hardware pair and drop the define.

- Esp8266HspiChannelDriver streams the already-encoded SPI byte stream
  (start frame + pixels + end frame) over the SPI1 FIFO, blocking per
  transfer. canHandle() accepts only the fixed GPIO13 (data) / GPIO14
  (clock) pad pair; every other pair falls through to the shared
  bit-bang bus.
- bus_traits.h specializes BusTraits<Bus::SPI> + BusSupports<Bus::SPI,
  SpiChipsetConfig> so the driver is selected by template and
  dead-stripped unless named (#2428). Registered in the ESP8266
  channel-driver fragment.
- Retire FASTLED_ALL_PINS_HARDWARE_SPI: delete the Arduino-SPI shim
  (fastspi_esp8266.h), drop its include from fastled_esp8266.h and the
  spi_output_template.h branch, and remove the ESP8266 clause from
  fastspi.h's FL_DATA_RATE_MHZ interpretation. The software bit-bang
  covers all non-HSPI pairs.

Verified: bash compile esp8266 --examples Blink succeeds and the
firmware image is byte-for-byte unchanged (unused driver eliminated).

Refs #4942, #4949.
@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Caution

Review failed

The pull request is closed.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • 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

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

@zackees

zackees commented Oct 27, 2026

Copy link
Copy Markdown
Member Author

Memory check (fbuild bloat, Blink, esp8266)

uv run ci/bloat.py esp8266 compared against the master baseline:

master this stack Δ
image_flash 264,671 B 264,667 B -4 B
attributed flash 203,252 B 203,249 B -3 B
RAM 6,808 B 6,808 B 0 B

No memory regression: the unused ESP8266 engines are dead-stripped (template selection + linker elimination), so naming none of them costs ~nothing, as intended (#2428).

@zackees
zackees changed the base branch from feat/4941-esp8266-default-bus to master October 28, 2026 00:22
@zackees
zackees merged commit 8e276c5 into master Oct 28, 2026
116 of 125 checks passed
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Oct 28, 2026
@zackees
zackees deleted the feat/4942-esp8266-hspi-bus branch November 5, 2026 05:52
TKDFusion pushed a commit to TKDFusion/Software-FastLED-FASTLED that referenced this pull request Nov 8, 2026
…rule (FastLED#4940)

Umbrella for the ESP8266 define-elimination epic (FastLED#4949): state the rule and
guard it.

- agents/docs/cpp-standards.md: new REQUIRED section 'Driver selection is by
  template, never a code-enabling define' with the BusTraits/BusSupports shape
  and the retired offenders (FASTLED_ESP8266_UART, FASTLED_ALL_PINS_HARDWARE_SPI,
  FL_ESP8266_EMBEDDED_FS).
- ci/lint_cpp/driver_enable_define_checker.py (new): a Python FileContentChecker
  that flags a preprocessor guard wrapping a 'platforms/...' include under
  src/platforms/** in an FL_*/FASTLED_* macro -- the code-enabling-define shape.
  The guards shipping today are grandfathered in
  driver_enable_define_amnesty.txt (regenerate with --generate-amnesty); new ones
  fail. Registered in run_all_checkers.py.
- ci/tests/test_driver_enable_define_checker.py (new): flagged/allowed cases plus
  a tree-wide check that the amnesty still covers src/platforms. Wired into
  PY_SMOKE (guard in test_native_ci_modes.py bumped 9 -> 10).

The three conversions land in FastLED#4951 / FastLED#4952 / FastLED#4953; this PR is the rule + guard.

Refs FastLED#4940, FastLED#4949.
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.

ESP8266: expose native HSPI as a channel/Bus::SPI driver; retire FASTLED_ALL_PINS_HARDWARE_SPI

1 participant