Accessing an SD card via the ESP32 SDMMC interface using low-level API.
More...
#include <Esp32SdmmcIO.h>
|
|
| Esp32SdmmcIO () |
| | Default constructor - card must be initialized with begin()
|
| |
| | Esp32SdmmcIO (bool mode1bit, int max_freq_khz=SDMMC_FREQ_DEFAULT) |
| | Constructor with bus mode and frequency.
|
| |
| | Esp32SdmmcIO (bool mode1bit, int max_freq_khz, const sdmmc_host_t &host_cfg, const sdmmc_slot_config_t &slot_cfg) |
| | Constructor with custom host and slot configuration.
|
| |
|
| ~Esp32SdmmcIO () |
| | Destructor - cleanup resources.
|
| |
| bool | begin (bool mode1bit=false, int max_freq_khz=SDMMC_FREQ_DEFAULT) |
| | Initialize the SDMMC interface and mount the SD card.
|
| |
| bool | begin (bool mode1bit, int max_freq_khz, sdmmc_host_t host_cfg, sdmmc_slot_config_t slot_cfg) |
| | Initialize with custom host and slot configuration.
|
| |
|
void | end () |
| | End SDMMC interface and unmount SD card.
|
| |
| DSTATUS | disk_initialize (BYTE drv) override |
| | Initialize disk drive.
|
| |
| DSTATUS | disk_status (BYTE drv) override |
| | Get disk status.
|
| |
| DRESULT | disk_read (BYTE drv, BYTE *buff, LBA_t sector, UINT count) override |
| | Read sector(s)
|
| |
| DRESULT | disk_write (BYTE drv, const BYTE *buff, LBA_t sector, UINT count) override |
| | Write sector(s)
|
| |
| DRESULT | disk_ioctl (BYTE drv, ioctl_cmd_t cmd, void *buff) override |
| | Miscellaneous drive controls.
|
| |
| uint64_t | cardSize () const |
| | Get the card size in bytes.
|
| |
| uint8_t | cardType () const |
| | Get the card type flags.
|
| |
| uint64_t | totalSectors () const |
| | Get the total number of sectors.
|
| |
| sdmmc_card_t * | getCard () |
| | Get pointer to the card structure (for advanced use)
|
| |
| bool | isMMC () const |
| | Check if card is MMC.
|
| |
| uint32_t | getFreqKHz () const |
| | Get card frequency in kHz.
|
| |
| virtual FRESULT | mount (FatFs &fs) |
| | mount the file system - implementation at end of header to avoid recursive include
|
| |
| virtual FRESULT | un_mount (FatFs &fs) |
| | unmount the file system - implementation at end of header to avoid recursive include
|
| |
|
|
volatile DSTATUS | stat = STA_NOINIT |
| | Physical drive status.
|
| |
|
BYTE | CardType = 0 |
| | Card type flags.
|
| |
|
sdmmc_card_t * | card |
| | Pointer to card structure.
|
| |
|
sdmmc_host_t | host_config |
| | Host configuration.
|
| |
|
sdmmc_slot_config_t | slot_config |
| | Slot configuration.
|
| |
|
bool | auto_init |
| | Whether to auto-init on first use.
|
| |
|
bool | init_mode1bit |
| | Stored 1-bit mode setting.
|
| |
|
int | init_max_freq_khz |
| | Stored max frequency setting.
|
| |
Accessing an SD card via the ESP32 SDMMC interface using low-level API.
This driver uses the ESP32's built-in SDMMC controller for high-speed SD card access via the ESP-IDF low-level driver API. It supports both 1-bit and 4-bit bus modes with custom pin configuration.
Example usage:
#include "fatfs.h"
using namespace fatfs;
void setup() {
if (!driver1.
begin(
false, SDMMC_FREQ_DEFAULT)) {
Serial.println("Card Mount Failed");
return;
}
}
void setup() {
driver2.mount(fs2);
}
Accessing an SD card via the ESP32 SDMMC interface using low-level API.
Definition Esp32SdmmcIO.h:60
bool begin(bool mode1bit=false, int max_freq_khz=SDMMC_FREQ_DEFAULT)
Initialize the SDMMC interface and mount the SD card.
Definition Esp32SdmmcIO.h:117
API for FatFS See http://elm-chan.org/fsw/ff/00index_e.html.
Definition ff.h:34
virtual FRESULT mount(FatFs &fs)
mount the file system - implementation at end of header to avoid recursive include
Definition IO.h:100
◆ Esp32SdmmcIO() [1/2]
| fatfs::Esp32SdmmcIO::Esp32SdmmcIO |
( |
bool |
mode1bit, |
|
|
int |
max_freq_khz = SDMMC_FREQ_DEFAULT |
|
) |
| |
|
inline |
Constructor with bus mode and frequency.
- Parameters
-
| mode1bit | Use 1-bit mode (true) or 4-bit mode (false, default) |
| max_freq_khz | Maximum frequency in kHz (default: SDMMC_FREQ_DEFAULT) |
Note: Card initialization is deferred until disk_initialize() is called, or you can call begin() explicitly.
◆ Esp32SdmmcIO() [2/2]
| fatfs::Esp32SdmmcIO::Esp32SdmmcIO |
( |
bool |
mode1bit, |
|
|
int |
max_freq_khz, |
|
|
const sdmmc_host_t & |
host_cfg, |
|
|
const sdmmc_slot_config_t & |
slot_cfg |
|
) |
| |
|
inline |
Constructor with custom host and slot configuration.
- Parameters
-
| mode1bit | Use 1-bit mode (true) or 4-bit mode (false) |
| max_freq_khz | Maximum frequency in kHz |
| host_cfg | Host configuration (from SDMMC_HOST_DEFAULT()) |
| slot_cfg | Slot configuration (from SDMMC_SLOT_CONFIG_DEFAULT()) |
Note: Card initialization is deferred until disk_initialize() is called, or you can call begin() explicitly.
◆ begin() [1/2]
| bool fatfs::Esp32SdmmcIO::begin |
( |
bool |
mode1bit, |
|
|
int |
max_freq_khz, |
|
|
sdmmc_host_t |
host_cfg, |
|
|
sdmmc_slot_config_t |
slot_cfg |
|
) |
| |
|
inline |
Initialize with custom host and slot configuration.
- Parameters
-
| mode1bit | Use 1-bit mode (true) or 4-bit mode (false) |
| max_freq_khz | Maximum frequency in kHz |
| host_cfg | Host configuration (from SDMMC_HOST_DEFAULT()) |
| slot_cfg | Slot configuration (from SDMMC_SLOT_CONFIG_DEFAULT()) |
- Returns
- true if initialization succeeded, false otherwise
◆ begin() [2/2]
| bool fatfs::Esp32SdmmcIO::begin |
( |
bool |
mode1bit = false, |
|
|
int |
max_freq_khz = SDMMC_FREQ_DEFAULT |
|
) |
| |
|
inline |
Initialize the SDMMC interface and mount the SD card.
- Parameters
-
| mode1bit | Use 1-bit mode (true) or 4-bit mode (false, default) |
| max_freq_khz | Maximum frequency in kHz (default: SDMMC_FREQ_DEFAULT) |
- Returns
- true if initialization succeeded, false otherwise
◆ cardSize()
| uint64_t fatfs::Esp32SdmmcIO::cardSize |
( |
| ) |
const |
|
inline |
Get the card size in bytes.
- Returns
- Card size in bytes
◆ cardType()
| uint8_t fatfs::Esp32SdmmcIO::cardType |
( |
| ) |
const |
|
inline |
Get the card type flags.
- Returns
- Card type flags (CT_MMC, CT_SD1, CT_SD2, CT_BLOCK)
◆ disk_initialize()
| DSTATUS fatfs::Esp32SdmmcIO::disk_initialize |
( |
BYTE |
drv | ) |
|
|
inlineoverridevirtual |
Initialize disk drive.
- Parameters
-
| drv | Physical drive number (0) |
- Returns
- Disk status
Reimplemented from fatfs::BaseIO.
◆ disk_ioctl()
| DRESULT fatfs::Esp32SdmmcIO::disk_ioctl |
( |
BYTE |
drv, |
|
|
ioctl_cmd_t |
cmd, |
|
|
void * |
buff |
|
) |
| |
|
inlineoverridevirtual |
Miscellaneous drive controls.
- Parameters
-
| drv | Physical drive number (0) |
| cmd | Control command code |
| buff | Pointer to the control data |
- Returns
- Result code
Reimplemented from fatfs::BaseIO.
◆ disk_read()
| DRESULT fatfs::Esp32SdmmcIO::disk_read |
( |
BYTE |
drv, |
|
|
BYTE * |
buff, |
|
|
LBA_t |
sector, |
|
|
UINT |
count |
|
) |
| |
|
inlineoverridevirtual |
Read sector(s)
- Parameters
-
| drv | Physical drive number (0) |
| buff | Pointer to the data buffer to store read data |
| sector | Start sector number (LBA) |
| count | Number of sectors to read (1..128) |
- Returns
- Result code
Reimplemented from fatfs::BaseIO.
◆ disk_status()
| DSTATUS fatfs::Esp32SdmmcIO::disk_status |
( |
BYTE |
drv | ) |
|
|
inlineoverridevirtual |
Get disk status.
- Parameters
-
| drv | Physical drive number (0) |
- Returns
- Disk status
Reimplemented from fatfs::BaseIO.
◆ disk_write()
| DRESULT fatfs::Esp32SdmmcIO::disk_write |
( |
BYTE |
drv, |
|
|
const BYTE * |
buff, |
|
|
LBA_t |
sector, |
|
|
UINT |
count |
|
) |
| |
|
inlineoverridevirtual |
Write sector(s)
- Parameters
-
| drv | Physical drive number (0) |
| buff | Pointer to the data to write |
| sector | Start sector number (LBA) |
| count | Number of sectors to write (1..128) |
- Returns
- Result code
Reimplemented from fatfs::BaseIO.
◆ getCard()
| sdmmc_card_t * fatfs::Esp32SdmmcIO::getCard |
( |
| ) |
|
|
inline |
Get pointer to the card structure (for advanced use)
- Returns
- Pointer to sdmmc_card_t or nullptr if not initialized
◆ getFreqKHz()
| uint32_t fatfs::Esp32SdmmcIO::getFreqKHz |
( |
| ) |
const |
|
inline |
Get card frequency in kHz.
- Returns
- Card operating frequency in kHz
◆ isMMC()
| bool fatfs::Esp32SdmmcIO::isMMC |
( |
| ) |
const |
|
inline |
Check if card is MMC.
- Returns
- true if MMC card, false if SD card
◆ mount()
| FRESULT fatfs::IO::mount |
( |
FatFs & |
fs | ) |
|
|
inlinevirtualinherited |
mount the file system - implementation at end of header to avoid recursive include
Reimplemented in fatfs::MultiIO, and fatfs::RamIO.
◆ totalSectors()
| uint64_t fatfs::Esp32SdmmcIO::totalSectors |
( |
| ) |
const |
|
inline |
Get the total number of sectors.
- Returns
- Total sectors (0 if not initialized)
◆ un_mount()
| FRESULT fatfs::IO::un_mount |
( |
FatFs & |
fs | ) |
|
|
inlinevirtualinherited |
unmount the file system - implementation at end of header to avoid recursive include
Reimplemented in fatfs::MultiIO.
The documentation for this class was generated from the following file: