TB2026-YDS Firmware
Loading...
Searching...
No Matches
sdcard.h File Reference

microSD card over SPI3 (VSPI), mounted as a FATFS volume at "/sdcard". More...

#include "esp_err.h"
#include <stdbool.h>

Go to the source code of this file.

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.

Detailed Description

microSD card over SPI3 (VSPI), mounted as a FATFS volume at "/sdcard".

The driver owns SPI3 entirely: sdcard_mount() initializes the bus, attaches the card via sdspi, and mounts the FAT volume; after that, read/write files with the standard POSIX API on paths under "/sdcard" (e.g. fopen("/sdcard/track.mp3", "rb")).

Like the GPIO expander, this driver owns no interrupt and no event queue: card presence is read synchronously via sdcard_present(). Hot-plug handling (an ISR on PIN_SD_DETECT that mounts/unmounts) belongs to the consumer, not here.

Note
Développé avec l'assistance de Claude Opus 4.8 (Anthropic), sous la direction de Y. Dos Santos : spécification, revue et validation sur cible par l'auteur.