mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
sdmmc: Add width field to the slot config.
Therefore if the width is set to 1, you can choose to only configure the CLK, DAT0 and CMD pins. Merges #361 https://github.com/espressif/esp-idf/pull/361
This commit is contained in:
parent
f4c4787281
commit
c08a2871e6
@ -50,6 +50,7 @@ extern "C" {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
gpio_num_t gpio_cd; ///< GPIO number of card detect signal
|
gpio_num_t gpio_cd; ///< GPIO number of card detect signal
|
||||||
gpio_num_t gpio_wp; ///< GPIO number of write protect signal
|
gpio_num_t gpio_wp; ///< GPIO number of write protect signal
|
||||||
|
uint8_t width; ///< Bus width used by the slot (might be less than the max width supported)
|
||||||
} sdmmc_slot_config_t;
|
} sdmmc_slot_config_t;
|
||||||
|
|
||||||
#define SDMMC_SLOT_NO_CD ((gpio_num_t) -1) ///< indicates that card detect line is not used
|
#define SDMMC_SLOT_NO_CD ((gpio_num_t) -1) ///< indicates that card detect line is not used
|
||||||
@ -61,6 +62,7 @@ typedef struct {
|
|||||||
#define SDMMC_SLOT_CONFIG_DEFAULT() {\
|
#define SDMMC_SLOT_CONFIG_DEFAULT() {\
|
||||||
.gpio_cd = SDMMC_SLOT_NO_CD, \
|
.gpio_cd = SDMMC_SLOT_NO_CD, \
|
||||||
.gpio_wp = SDMMC_SLOT_NO_WP, \
|
.gpio_wp = SDMMC_SLOT_NO_WP, \
|
||||||
|
.width = 4, \
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -302,17 +302,24 @@ esp_err_t sdmmc_host_init_slot(int slot, const sdmmc_slot_config_t* slot_config)
|
|||||||
|
|
||||||
// Configure pins
|
// Configure pins
|
||||||
const sdmmc_slot_info_t* pslot = &s_slot_info[slot];
|
const sdmmc_slot_info_t* pslot = &s_slot_info[slot];
|
||||||
|
|
||||||
|
if (slot_config->width > pslot->width) {
|
||||||
|
return ESP_ERR_INVALID_ARG;
|
||||||
|
}
|
||||||
|
|
||||||
configure_pin(pslot->clk);
|
configure_pin(pslot->clk);
|
||||||
configure_pin(pslot->cmd);
|
configure_pin(pslot->cmd);
|
||||||
configure_pin(pslot->d0);
|
configure_pin(pslot->d0);
|
||||||
configure_pin(pslot->d1);
|
if (slot_config->width >= 4) {
|
||||||
configure_pin(pslot->d2);
|
configure_pin(pslot->d1);
|
||||||
configure_pin(pslot->d3);
|
configure_pin(pslot->d2);
|
||||||
if (pslot->width == 8) {
|
configure_pin(pslot->d3);
|
||||||
configure_pin(pslot->d4);
|
if (slot_config->width == 8) {
|
||||||
configure_pin(pslot->d5);
|
configure_pin(pslot->d4);
|
||||||
configure_pin(pslot->d6);
|
configure_pin(pslot->d5);
|
||||||
configure_pin(pslot->d7);
|
configure_pin(pslot->d6);
|
||||||
|
configure_pin(pslot->d7);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (gpio_cd != -1) {
|
if (gpio_cd != -1) {
|
||||||
gpio_set_direction(gpio_cd, GPIO_MODE_INPUT);
|
gpio_set_direction(gpio_cd, GPIO_MODE_INPUT);
|
||||||
|
Loading…
Reference in New Issue
Block a user