|
TB2026-YDS Firmware
|
Mount/unmount a FAT volume at "/sdcard" and read card presence. More...

Macros | |
| #define | SDCARD_MOUNT_POINT "/sdcard" |
| Mount point; prefix every path passed to fopen/fread/fwrite. | |
Functions | |
| esp_err_t | sdcard_mount (void) |
| Initialize SPI3, attach the card via sdspi, and mount the FAT volume. | |
| esp_err_t | sdcard_unmount (void) |
| Unmount the FAT volume and detach the sdspi device. | |
| bool | sdcard_present (void) |
| Report whether a card is physically inserted (synchronous read of PIN_SD_DETECT). | |
| int | sdcard_freq_khz (void) |
| Actual SPI clock negotiated with the card by the host, in kHz. | |
Mount/unmount a FAT volume at "/sdcard" and read card presence.
| #define SDCARD_MOUNT_POINT "/sdcard" |
Mount point; prefix every path passed to fopen/fread/fwrite.
| int sdcard_freq_khz | ( | void | ) |
Actual SPI clock negotiated with the card by the host, in kHz.
May be lower than the frequency requested at mount (the host rounds down to a reachable divider), so this is the value to trust when checking throughput.
| esp_err_t sdcard_mount | ( | void | ) |
Initialize SPI3, attach the card via sdspi, and mount the FAT volume.
Does not auto-format: if the card has no valid FAT, mounting fails and the card is left untouched. After this returns ESP_OK, files are accessible with the POSIX API under SDCARD_MOUNT_POINT.
| bool sdcard_present | ( | void | ) |
Report whether a card is physically inserted (synchronous read of PIN_SD_DETECT).
Configures the detect GPIO on first call. Safe to call before mounting, e.g. to decide whether sdcard_mount() is worth attempting.
| esp_err_t sdcard_unmount | ( | void | ) |
Unmount the FAT volume and detach the sdspi device.
Flushes FATFS. The SPI3 bus itself stays initialized: on the classic ESP32 both SPI hosts share one DMA clock bit, so freeing SPI3 would stall an in-flight display (SPI2) DMA transfer (see sdcard_mount()).