mirror of
https://github.com/espressif/esp-idf.git
synced 2026-05-05 12:25:03 +02:00
Merge branch 'feature/sdcard_custom_freq' into 'master'
[Storage] Enable SD card custom frequency setup Closes IDFGH-7089 See merge request espressif/esp-idf!19038
This commit is contained in:
@@ -45,6 +45,7 @@ extern "C" {
|
||||
.io_int_enable = sdmmc_host_io_int_enable, \
|
||||
.io_int_wait = sdmmc_host_io_int_wait, \
|
||||
.command_timeout_ms = 0, \
|
||||
.get_real_freq = &sdmmc_host_get_real_freq \
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -259,6 +260,23 @@ esp_err_t sdmmc_host_io_int_wait(int slot, TickType_t timeout_ticks);
|
||||
*/
|
||||
esp_err_t sdmmc_host_deinit(void);
|
||||
|
||||
/**
|
||||
* @brief Provides a real frequency used for an SD card installed on specific slot
|
||||
* of SD/MMC host controller
|
||||
*
|
||||
* This function calculates real working frequency given by current SD/MMC host
|
||||
* controller setup for required slot: it reads associated host and card dividers
|
||||
* from corresponding SDMMC registers, calculates respective frequency and stores
|
||||
* the value into the 'real_freq_khz' parameter
|
||||
*
|
||||
* @param slot slot number (SDMMC_HOST_SLOT_0 or SDMMC_HOST_SLOT_1)
|
||||
* @param[out] real_freq_khz output parameter for the result frequency (in kHz)
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG on real_freq_khz == NULL or invalid slot number used
|
||||
*/
|
||||
esp_err_t sdmmc_host_get_real_freq(int slot, int* real_freq_khz);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -183,6 +183,7 @@ typedef struct {
|
||||
esp_err_t (*io_int_enable)(int slot); /*!< Host function to enable SDIO interrupt line */
|
||||
esp_err_t (*io_int_wait)(int slot, TickType_t timeout_ticks); /*!< Host function to wait for SDIO interrupt line to be active */
|
||||
int command_timeout_ms; /*!< timeout, in milliseconds, of a single command. Set to 0 to use the default value. */
|
||||
esp_err_t (*get_real_freq)(int slot, int* real_freq); /*!< Host function to provide real working freq, based on SDMMC controller setup */
|
||||
} sdmmc_host_t;
|
||||
|
||||
/**
|
||||
@@ -202,6 +203,7 @@ typedef struct {
|
||||
sdmmc_ext_csd_t ext_csd; /*!< decoded EXT_CSD (Extended Card Specific Data) register value */
|
||||
uint16_t rca; /*!< RCA (Relative Card Address) */
|
||||
uint16_t max_freq_khz; /*!< Maximum frequency, in kHz, supported by the card */
|
||||
int real_freq_khz; /*!< Real working frequency, in kHz, configured on the host controller */
|
||||
uint32_t is_mem : 1; /*!< Bit indicates if the card is a memory card */
|
||||
uint32_t is_sdio : 1; /*!< Bit indicates if the card is an IO card */
|
||||
uint32_t is_mmc : 1; /*!< Bit indicates if the card is MMC */
|
||||
|
||||
@@ -50,6 +50,7 @@ typedef int sdspi_dev_handle_t;
|
||||
.io_int_enable = &sdspi_host_io_int_enable, \
|
||||
.io_int_wait = &sdspi_host_io_int_wait, \
|
||||
.command_timeout_ms = 0, \
|
||||
.get_real_freq = &sdspi_host_get_real_freq \
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -156,6 +157,18 @@ esp_err_t sdspi_host_do_transaction(sdspi_dev_handle_t handle, sdmmc_command_t *
|
||||
*/
|
||||
esp_err_t sdspi_host_set_card_clk(sdspi_dev_handle_t host, uint32_t freq_khz);
|
||||
|
||||
/**
|
||||
* @brief Calculate working frequency for specific device
|
||||
*
|
||||
* @param handle SDSPI device handle
|
||||
* @param[out] real_freq_khz output parameter to hold the calculated frequency (in kHz)
|
||||
*
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG : ``handle`` is NULL or invalid or ``real_freq_khz`` parameter is NULL
|
||||
* - ESP_OK : Success
|
||||
*/
|
||||
esp_err_t sdspi_host_get_real_freq(sdspi_dev_handle_t handle, int* real_freq_khz);
|
||||
|
||||
/**
|
||||
* @brief Release resources allocated using sdspi_host_init
|
||||
*
|
||||
|
||||
@@ -333,6 +333,18 @@ esp_err_t spi_device_acquire_bus(spi_device_handle_t device, TickType_t wait);
|
||||
*/
|
||||
void spi_device_release_bus(spi_device_handle_t dev);
|
||||
|
||||
/**
|
||||
* @brief Calculate working frequency for specific device
|
||||
*
|
||||
* @param handle SPI device handle
|
||||
* @param[out] freq_khz output parameter to hold calculated frequency in kHz
|
||||
*
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG : ``handle`` or ``freq_khz`` parameter is NULL
|
||||
* - ESP_OK : Success
|
||||
*/
|
||||
esp_err_t spi_device_get_actual_freq(spi_device_handle_t handle, int* freq_khz);
|
||||
|
||||
/**
|
||||
* @brief Calculate the working frequency that is most close to desired frequency.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user