Fix SD card integration and Lua game loading

- Fix SD card MISO pin (was using display MISO instead of SD MISO)
- Add FatFS mounting after SD card initialization
- Restore SPI baudrate on all SD init failure paths
- Add case-insensitive .lua file extension check
- Filter out hidden 8.3 filename entries
- Add SPI speed management functions for shared SPI bus
- Wrap all FatFS operations with SPI speed switching
- Restore display SPI speed (32 MHz) after SD operations
- Add debug output to Lua game loader

This fixes slow display refresh when SD card is present and enables
reliable Lua game loading from SD card /games directory.
This commit is contained in:
Adolfo Reyna
2026-02-07 19:31:38 -05:00
parent 2a472fc29f
commit b16211f148
109 changed files with 38964 additions and 20 deletions

View File

@@ -75,6 +75,19 @@ bool sd_card_init(const sd_card_config_t *config);
*/
bool sd_card_init_with_board_config(void);
/**
* Set SPI speed to SD card speed (12.5 MHz) before SD operations
* Call this before any FatFS file operations if SPI is shared with display
* @return Previous baudrate to restore later
*/
uint sd_card_set_spi_speed(void);
/**
* Restore SPI speed after SD card operations
* @param baudrate Previous baudrate to restore
*/
void sd_card_restore_spi_speed(uint baudrate);
/**
* Get card information
* @param info Pointer to info structure to fill