From 28d8ad565fa88e09a0b3f17209e4d6d22451dbca Mon Sep 17 00:00:00 2001 From: Justin Mitchell Date: Mon, 15 Jun 2026 12:14:19 -0400 Subject: [PATCH] Fix SPI bus initialization for non-C3 boards Change SPI pre-claim logic to only apply on C3/Xteink hardware where EPD_* pins are hardcoded. Other boards (M5Paper, Sticky) need to initialize SPI from BoardConfig::ACTIVE pins to avoid incorrect pin assignments for display and SD card. --- lib/hal/HalGPIO.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/hal/HalGPIO.cpp b/lib/hal/HalGPIO.cpp index 88104fb9..1fffde56 100644 --- a/lib/hal/HalGPIO.cpp +++ b/lib/hal/HalGPIO.cpp @@ -192,11 +192,13 @@ HalGPIO::DeviceType detectDeviceTypeWithFingerprint() { void HalGPIO::begin() { inputMgr.begin(); -#if !(defined(FREEINK_DEVICE_M5PAPER) && FREEINK_DEVICE_M5PAPER) - // Claim the shared SPI bus with the X4/X3 display+SD pins. On M5Paper the SDK's - // IT8951 driver and SDCardManager each bring up SPI from BoardConfig::ACTIVE - // pins; pre-claiming VSPI here would stick (SPIClass::begin early-returns if the - // bus is already started) and leave the SD card on the wrong pins. +#if FREEINK_MCU_C3 + // Claim the shared SPI bus with the X4/X3 display+SD pins. These EPD_* pin + // macros are hardcoded C3/Xteink values, so this pre-claim is only valid on the + // C3 family. On other boards (M5Paper's IT8951, Sticky's SSD1677, ...) the SDK + // driver and SDCardManager bring up SPI from BoardConfig::ACTIVE pins; pre- + // claiming here would stick (SPIClass::begin early-returns once the bus is + // started) and leave the display/SD on the wrong pins. SPI.begin(EPD_SCLK, SPI_MISO, EPD_MOSI, EPD_CS); #endif