Skip to content

Fix SPI bus detach issue on ESP32-C3 with Arduino 3.x#176

Open
hallard wants to merge 1 commit intoLSatan:masterfrom
hallard:fix-spi-esp32c3
Open

Fix SPI bus detach issue on ESP32-C3 with Arduino 3.x#176
hallard wants to merge 1 commit intoLSatan:masterfrom
hallard:fix-spi-esp32c3

Conversation

@hallard
Copy link

@hallard hallard commented Feb 14, 2026

Summary

  • Fix SPI bus initialization/teardown that breaks CC1101 on ESP32-C3 with Arduino 3.x (IDF 5.x)
  • SPI.end() now fully detaches the SPI bus and releases GPIO pins on newer ESP32 Arduino cores
  • Since SpiStart()/SpiEnd() wrap every single SPI transaction, this caused the bus to be repeatedly torn down and rebuilt, hanging the firmware

Changes

  • SpiStart(): Only call SPI.begin() and pinMode() once (first use), skip on subsequent calls
  • SpiEnd(): Remove SPI.end(), keep only SPI.endTransaction()

Testing

  • Tested on ESP32-C3 with CC1101 module using custom SPI pins
  • Arduino ESP32 core 3.3.3 / IDF v5.5.1
  • Compatible with ESP32, ESP32-S3, and ESP8266 (no behavior change on those platforms)

🤖 Generated with Claude Code

On ESP32-C3 with Arduino 3.x (IDF 5.x), SPI.end() fully detaches the
SPI bus and releases GPIO pins. Since SpiStart()/SpiEnd() are called
around every single SPI transaction, this causes the bus to be
repeatedly torn down and rebuilt, which breaks GPIO pin assignments
and hangs the firmware.

Fix by:
- Only calling SPI.begin() once (on first use) instead of every transaction
- Removing SPI.end() from SpiEnd(), keeping only SPI.endTransaction()

This fixes CC1101 operation on ESP32-C3 boards while remaining
compatible with ESP32, ESP32-S3, and ESP8266.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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