mirror of
https://github.com/torlando-tech/pyxis.git
synced 2026-08-21 18:19:48 +00:00
Fix SD card SPI init: use FSPI before Display claims HSPI
SD card was unresponsive (MISO stuck 0xFF) because Display's HSPI peripheral had already claimed the GPIO pins via the matrix, preventing FSPI from routing MISO. Fix by initializing SD card BEFORE Display, using the global SPI (FSPI) instance — matching LilyGo's reference code. - Move SD card init before display init in boot sequence - Use global SPI (FSPI) instead of Display's SPIClass(HSPI) - Lower SPI frequency to 800kHz matching LilyGo example - Drive all CS lines (display, LoRa, SD) high before SD init - Add MISO=38 to Display's SPI.begin for post-init bus sharing - Add Display::get_spi() accessor for future shared use Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
d03f0b308f
commit
b4afa6d3f7
+17
-13
@@ -1277,12 +1277,24 @@ void setup() {
|
||||
}
|
||||
}
|
||||
|
||||
// Create shared SPI bus mutex (display, LoRa, SD card all share HSPI)
|
||||
// Create shared SPI bus mutex (display, LoRa, SD card all share SPI)
|
||||
SemaphoreHandle_t spi_mutex = xSemaphoreCreateMutex();
|
||||
if (!spi_mutex) {
|
||||
ERROR("Failed to create SPI bus mutex!");
|
||||
}
|
||||
|
||||
// Try SD card FIRST, before display claims pins — matches LilyGo init order.
|
||||
// Uses global SPI (FSPI) with no competing peripheral on the bus.
|
||||
BOOT_PROFILE_START("sd_card");
|
||||
if (spi_mutex) {
|
||||
if (Hardware::TDeck::SDAccess::init(spi_mutex)) {
|
||||
INFO("SD card initialized on shared SPI bus");
|
||||
} else {
|
||||
INFO("SD card not available (no card inserted?)");
|
||||
}
|
||||
}
|
||||
BOOT_PROFILE_END("sd_card");
|
||||
|
||||
// Set SPI mutex on Display before init (null-safe if mutex creation failed)
|
||||
Hardware::TDeck::Display::set_spi_mutex(spi_mutex);
|
||||
|
||||
@@ -1301,20 +1313,12 @@ void setup() {
|
||||
setup_reticulum();
|
||||
BOOT_PROFILE_END("reticulum");
|
||||
|
||||
// Initialize SD card on shared SPI bus (after display + LoRa)
|
||||
BOOT_PROFILE_START("sd_card");
|
||||
if (spi_mutex) {
|
||||
if (Hardware::TDeck::SDAccess::init(spi_mutex)) {
|
||||
INFO("SD card initialized on shared SPI bus");
|
||||
// Initialize SD logging now that SDAccess is ready
|
||||
if (Hardware::TDeck::SDLogger::init()) {
|
||||
INFO("SD card logging active");
|
||||
}
|
||||
} else {
|
||||
INFO("SD card not available (no card inserted?)");
|
||||
// Initialize SD logging (SDAccess already initialized above)
|
||||
if (Hardware::TDeck::SDAccess::is_ready()) {
|
||||
if (Hardware::TDeck::SDLogger::init()) {
|
||||
INFO("SD card logging active");
|
||||
}
|
||||
}
|
||||
BOOT_PROFILE_END("sd_card");
|
||||
|
||||
// Initialize LXMF
|
||||
BOOT_PROFILE_START("lxmf");
|
||||
|
||||
Reference in New Issue
Block a user