Skip to content

feat(esp32): make ESP-IDF spi_master the only ESP32 SPI backend - #3727

Merged
zackees merged 3 commits into
masterfrom
feat/esp32-spi-idf-only
Jul 22, 2026
Merged

zackees merged 3 commits into
masterfrom
feat/esp32-spi-idf-only

Conversation

@zackees

@zackees zackees commented Jul 22, 2026 •

Copy link
Copy Markdown
Member

Closes #3718. Part of meta #3715 (ESP Arduino-decoupling).

Problem

fastspi_esp32.h dispatched to the Arduino SPIClass backend (fastspi_esp32_arduino.h, <SPI.h>) whenever ARDUINO was defined, and only used the already-complete native IDF backend (fastspi_esp32_idf.h, driver/spi_master.h) otherwise (FL_NO_ARDUINO builds). Since Arduino-ESP32 bundles the same IDF SPI driver, there was no reason for these to diverge.

Fix

  • Flip the default in fastspi_esp32.h to always use fastspi_esp32_idf.h.
  • Keep fastspi_esp32_arduino.h as an opt-in escape hatch behind FL_ESP32_SPI_ARDUINO=1, in case a regression is found (rather than deleting it outright).
  • Drop the <SPI.h> LDF hint in ldf_headers.h, which existed only to pre-install the Arduino SPI library for the now-non-default backend.

Risk / hardware note

This is the highest hardware-behavior-risk sub-issue in the #3715 series — it changes what actually drives the SPI clock/data pins for clocked chipsets (APA102, SK9822, LPD8806, DotStar). fastspi_esp32_idf.h is not new code — it's a pre-existing, complete backend already reachable via FL_NO_ARDUINO.

What I validated: bash compile esp32dev --examples Apa102 against real Arduino-ESP32 3.3.7 (IDF 5.x) — compiles and links successfully with the native backend now active by default (flash 433.64KB, ram 149.91KB).

What I did not validate: wire-level SPI protocol correctness (scope/logic-analyzer capture, or an LED strip lighting up correctly) — no LED strip or logic analyzer was available in this session. Recommend a bench smoke-test (an APA102 strip, or a SPI loopback capture per the original issue's acceptance criteria) before merging, or as a fast follow-up validation.

Test plan

  • bash lint --cpp — clean
  • bash test --cpp — unaffected (ESP32 platform code isn't compiled on host)
  • bash compile esp32dev --examples Apa102 — compiles and links
  • CodeRabbit review addressed: renamed FASTLED_ESP32_SPI_ARDUINO → FL_ESP32_SPI_ARDUINO (frozen FASTLED_* vocabulary rule), clarified "default" vs "only" wording
  • Hardware smoke test (APA102 strip / SPI loopback capture) — not performed, see note above

Summary by CodeRabbit

  • New Features

    • ESP32 builds now use the native ESP-IDF SPI implementation by default (same behavior for Arduino-ESP32 and bare ESP-IDF builds).
    • Added an opt-in configuration to switch back to the legacy Arduino SPI backend.
  • Documentation

    • Clarified how SPI support is provided by default and how to enable the legacy backend.
    • Updated build dependency guidance so enabling the legacy backend also includes the required <SPI.h> dependency.

fastspi_esp32.h dispatched to the Arduino SPIClass backend
(fastspi_esp32_arduino.h, <SPI.h>) whenever ARDUINO was defined, and only
used the already-complete native IDF backend (fastspi_esp32_idf.h,
driver/spi_master.h) otherwise. Since Arduino-ESP32 bundles the same IDF
SPI driver, there is no reason for the two backends to diverge — flip the
default to the native backend unconditionally, with the Arduino backend
kept only as an opt-in escape hatch (FASTLED_ESP32_SPI_ARDUINO=1) in case
a regression surfaces.

Also drops the now-unneeded <SPI.h> LDF hint in ldf_headers.h — that hint
existed only to pre-install the Arduino SPI library for the (now
non-default) Arduino backend.

Validated: `bash compile esp32dev --examples Apa102` (a clocked SPI
chipset) builds and links successfully against real Arduino-ESP32 3.3.7
(IDF 5.x) with the native backend now active by default (flash 433KB,
ram 150KB).

Part of #3715. Closes #3718.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@zackees, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 4 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8522ca63-c92f-497b-a8ae-c35a19ee1584

📥 Commits

Reviewing files that changed from the base of the PR and between 92e8b20 and 88dabed.

📒 Files selected for processing (1)
  • src/platforms/esp/32/core/fastspi_esp32.h
📝 Walkthrough

Walkthrough

ESP32 SPI dispatch now uses the ESP-IDF backend by default for Arduino and bare ESP-IDF builds. The Arduino SPIClass backend is available only through FL_ESP32_SPI_ARDUINO=1, and the LDF header no longer forces an Arduino SPI dependency.

Changes

ESP32 SPI dispatch

Layer / File(s) Summary
Default backend and dependency dispatch
src/platforms/esp/32/core/fastspi_esp32.h, src/platforms/esp/32/ldf_headers.h
ESP-IDF SPI is selected by default; the Arduino SPIClass backend requires FL_ESP32_SPI_ARDUINO=1, and <SPI.h> is no longer forced by the LDF header.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

  • #3722 — Covers the ESP32 SPI dispatch refactor to native IDF selection with an explicit Arduino opt-in.

Possibly related PRs

  • FastLED/FastLED#3730 — Uses the same opt-in and Arduino-exception model for ESP32 SPI backend dispatch.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR matches #3718 by defaulting to IDF spi_master on all ESP32 builds and removing the SPI.h hint while keeping Arduino as opt-in.
Out of Scope Changes check ✅ Passed The changes stay within the ESP32 SPI backend and LDF dependency scope described by the issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is closely related to the change, though "only" overstates it because the Arduino backend remains as an opt-in fallback.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/esp32-spi-idf-only

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.

@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 `@src/platforms/esp/32/core/fastspi_esp32.h`:
- Around line 20-25: Update the documentation at
src/platforms/esp/32/core/fastspi_esp32.h lines 20-25 to describe the ESP-IDF
native SPI backend as the default implementation rather than the only
implementation, preserving the Arduino SPIClass escape-hatch note. Update
src/platforms/esp/32/ldf_headers.h lines 16-19 to state that this default
applies to both Arduino-ESP32 and bare ESP-IDF builds.
- Around line 41-50: The ESP32 SPI backend flag uses the prohibited FASTLED_*
vocabulary. Rename every reference from FASTLED_ESP32_SPI_ARDUINO to
FL_ESP32_SPI_ARDUINO in the dispatcher within fastspi_esp32.h and the related
documentation or temporary comments in ldf_headers.h, preserving the existing
conditional behavior.
🪄 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: 91e99b02-f69a-4afd-b840-15adcaa00a64

📥 Commits

Reviewing files that changed from the base of the PR and between 1404736 and 6cf6fd7.

📒 Files selected for processing (2)
  • src/platforms/esp/32/core/fastspi_esp32.h
  • src/platforms/esp/32/ldf_headers.h

FASTLED_* is frozen vocabulary (agents/docs config) — new configuration
macros use the FL_* prefix. Also clarifies fastspi_esp32.h/ldf_headers.h
comments: the IDF backend is the default (not "the only") implementation,
applying identically to Arduino-ESP32 and bare ESP-IDF builds.

Addresses CodeRabbit review on #3727.

Co-Authored-By: Claude Sonnet 5 <[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: 1

🤖 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 `@src/platforms/esp/32/core/fastspi_esp32.h`:
- Around line 20-25: Soften the absolute “no behavioral difference” claim in the
introductory comments for the ESP32 SPI backend, acknowledging that the native
ESP-IDF and Arduino SPIClass implementations use separate APIs and have not been
hardware-validated against each other. Keep the documented default backend and
FL_ESP32_SPI_ARDUINO escape-hatch guidance unchanged.
🪄 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: 8dc1bd1b-719d-4b68-8991-904b421797c7

📥 Commits

Reviewing files that changed from the base of the PR and between 6cf6fd7 and 92e8b20.

📒 Files selected for processing (2)
  • src/platforms/esp/32/core/fastspi_esp32.h
  • src/platforms/esp/32/ldf_headers.h
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/platforms/esp/32/ldf_headers.h

zackees added a commit that referenced this pull request Jul 22, 2026
Matches the rename in #3727/#3718 (frozen FASTLED_* vocabulary rule).

Addresses CodeRabbit review on #3730.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
The IDF-native and Arduino SPIClass backends are separate implementations,
not a thin wrapper of one over the other, and have not been
hardware-validated bit-for-bit against each other (matches the honest
caveat already in the PR description).

Addresses CodeRabbit re-review on #3727.

Co-Authored-By: Claude Sonnet 5 <[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.

esp32: retire fastspi_esp32_arduino.h — make IDF spi_master the only ESP32 SPI backend

1 participant