EasyManuals Logo

Espressif ESP32-S2 User Manual

Espressif ESP32-S2
1695 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #369 background imageLoading...
Page #369 background image
Chapter 2. API Reference
How to Use
Firstly, use the macro SDSPI_DEVICE_CONFIG_DEFAULT to initialize a structure sdmmc_slot_config_t,
which is used to initialize an SD SPI device. This macro will also fill in the default pin mappings, which is same as
the pin mappings of SDMMC host driver. Modify the host and pins of the structure to desired value. Then call
sdspi_host_init_device to initialize the SD SPI device and attach to its bus.
Then use SDSPI_HOST_DEFAULT macro to initialize a sdmmc_host_t structure, which is used to store the state
and configurations of upper layer (SD/SDIO/MMC driver). Modify the slot parameter of the structure to the SD SPI
device spi_handle just returned from sdspi_host_init_device. Call sdmmc_card_init with the sdmmc_host_t to
probe and initialize the SD card.
Now you can use SD/SDIO/MMC driver functions to access your card!
Other Details
Only the following drivers API functions are normally used by most applications:
sdspi_host_init()
sdspi_host_init_device()
sdspi_host_remove_device()
sdspi_host_deinit()
Other functions are mostly used by the protocol level SD/SDIO/MMC driver via function pointers in the sd-
mmc_host_t structure. For more details, see the SD/SDIO/MMC Driver.
Note: SD over SPI does not support speeds above SDMMC_FREQ_DEFAULT due to the limitations of the SPI
driver.
API Reference
Header File
components/driver/include/driver/sdspi_host.h
Functions
esp_err_t sdspi_host_init(void)
Initialize SD SPI driver.
Note This function is not thread safe
Return
ESP_OK on success
other error codes may be returned in future versions
esp_err_t sdspi_host_init_device(const sdspi_device_config_t *dev_config, sdspi_dev_handle_t
*out_handle)
Attach and initialize an SD SPI device on the specific SPI bus.
Note This function is not thread safe
Note Initialize the SPI bus by spi_bus_initialize() before calling this function.
Note The SDIO over sdspi needs an extra interrupt line. Call gpio_install_isr_service() before
this function.
Return
ESP_OK on success
ESP_ERR_INVALID_ARG if sdspi_host_init_device has invalid arguments
ESP_ERR_NO_MEM if memory can not be allocated
other errors from the underlying spi_master and gpio drivers
Parameters
dev_config: pointer to device configuration structure
Espressif Systems 358
Submit Document Feedback
Release v4.4

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Espressif ESP32-S2 and is the answer not in the manual?

Espressif ESP32-S2 Specifications

General IconGeneral
BrandEspressif
ModelESP32-S2
CategorySingle board computers
LanguageEnglish