Repository navigation
feat(esp32): make ESP-IDF spi_master the only ESP32 SPI backend - #3727
Conversation
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]>
|
Warning Review limit reached
Next review available in: 4 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughESP32 SPI dispatch now uses the ESP-IDF backend by default for Arduino and bare ESP-IDF builds. The Arduino ChangesESP32 SPI dispatch
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (2)
src/platforms/esp/32/core/fastspi_esp32.hsrc/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]>
There was a problem hiding this comment.
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
📒 Files selected for processing (2)
src/platforms/esp/32/core/fastspi_esp32.hsrc/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
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]>
Closes #3718. Part of meta #3715 (ESP Arduino-decoupling).
Problem
fastspi_esp32.hdispatched to the ArduinoSPIClassbackend (fastspi_esp32_arduino.h,<SPI.h>) wheneverARDUINOwas defined, and only used the already-complete native IDF backend (fastspi_esp32_idf.h,driver/spi_master.h) otherwise (FL_NO_ARDUINObuilds). Since Arduino-ESP32 bundles the same IDF SPI driver, there was no reason for these to diverge.Fix
fastspi_esp32.hto always usefastspi_esp32_idf.h.fastspi_esp32_arduino.has an opt-in escape hatch behindFL_ESP32_SPI_ARDUINO=1, in case a regression is found (rather than deleting it outright).<SPI.h>LDF hint inldf_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.his not new code — it's a pre-existing, complete backend already reachable viaFL_NO_ARDUINO.What I validated:
bash compile esp32dev --examples Apa102against 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— cleanbash test --cpp— unaffected (ESP32 platform code isn't compiled on host)bash compile esp32dev --examples Apa102— compiles and linksFASTLED_ESP32_SPI_ARDUINO→FL_ESP32_SPI_ARDUINO(frozenFASTLED_*vocabulary rule), clarified "default" vs "only" wordingSummary by CodeRabbit
New Features
Documentation
<SPI.h>dependency.