Skip to content

Update SPI_PORT logic for ESP32C3 and legacy ESP32 support - #3921

Open
gsoros wants to merge 1 commit into
Bodmer:masterfrom
gsoros:SPI_PORT-logic
Open

gsoros wants to merge 1 commit into
Bodmer:masterfrom
gsoros:SPI_PORT-logic

Conversation

@gsoros

@gsoros gsoros commented May 21, 2026

Copy link
Copy Markdown

Fix SPI_PORT selection for ESP32-C3 (and other non-classic targets) on Arduino 2.x

The existing #if ESP_ARDUINO_VERSION_MAJOR < 3 guard sets SPI_PORT to SPI2_HOST (value 1) on Arduino 2.x. However, per the ESP-IDF enumeration, SPI2_HOST = 1 maps to the SPI1 hardware bus, which is reserved for internal flash on ESP32-C3 (and C5, C6, H2, S2, S3). The correct port for these targets is value 2 (SPI3_HOST, actually SPI2 hardware) — which is what the Arduino 3.x branch already hardcodes.

This replaces the Arduino version check with a chip target check using CONFIG_IDF_TARGET_* macros, so the correct port is selected regardless of Arduino version. The original classic ESP32 code path is unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant