SD Card Peripheral

If your board has a SD card connected, use this API to initialize, mount and unmount the card, see functions periph_sdcard_init(), periph_sdcard_mount() and periph_sdcard_unmount(). The data reading / writing is implemented in a separate API described in FatFs Stream.

Application Examples

Implementation of this API is demonstrated in couple of examples:

API Reference

Functions

esp_periph_handle_t periph_sdcard_init(periph_sdcard_cfg_t *sdcard_config)

Create the sdcard peripheral handle for esp_peripherals.

Note
The handle was created by this function automatically destroy when esp_periph_destroy is called
Return
The esp peripheral handle
Parameters
  • sdcard_config: The sdcard configuration

bool periph_sdcard_is_mounted(esp_periph_handle_t periph)

Check the sdcard is mounted or not.

Return
SDCARD mounted state
Parameters
  • periph: The periph

Structures

struct periph_sdcard_cfg_t

The SD Card Peripheral configuration.

Public Members

int card_detect_pin

Card detect gpio number

const char *root

Base path for vfs

Enumerations

enum periph_sdcard_event_id_t

Peripheral sdcard event id.

Values:

SDCARD_STATUS_UNKNOWN

No event

SDCARD_STATUS_CARD_DETECT_CHANGE

Detect changes in the card_detect pin

SDCARD_STATUS_MOUNTED

SDCARD mounted successfully

SDCARD_STATUS_UNMOUNTED

SDCARD unmounted successfully

SDCARD_STATUS_MOUNT_ERROR

SDCARD mount error

SDCARD_STATUS_UNMOUNT_ERROR

SDCARD unmount error