mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-04 21:24:32 +02:00
examples: sdmmc: set slot width and pins explicitly
... and prefer SDMMC_SLOT_FLAG_INTERNAL_PULLUP over explicitly setting pullups on pins.
This commit is contained in:
@@ -52,17 +52,24 @@ void app_main(void)
|
|||||||
// Modify slot_config.gpio_cd and slot_config.gpio_wp if your board has these signals.
|
// Modify slot_config.gpio_cd and slot_config.gpio_wp if your board has these signals.
|
||||||
sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();
|
sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();
|
||||||
|
|
||||||
// To use 1-line SD mode, uncomment the following line:
|
// To use 1-line SD mode, change this to 1:
|
||||||
// slot_config.width = 1;
|
slot_config.width = 4;
|
||||||
|
|
||||||
// GPIOs 15, 2, 4, 12, 13 should have external 10k pull-ups.
|
// On chips where the GPIOs used for SD card can be configured, set them in
|
||||||
// Internal pull-ups are not sufficient. However, enabling internal pull-ups
|
// the slot_config structure:
|
||||||
// does make a difference some boards, so we do that here.
|
#ifdef SOC_SDMMC_USE_GPIO_MATRIX
|
||||||
gpio_set_pull_mode(15, GPIO_PULLUP_ONLY); // CMD, needed in 4- and 1- line modes
|
slot_config.clk = GPIO_NUM_14;
|
||||||
gpio_set_pull_mode(2, GPIO_PULLUP_ONLY); // D0, needed in 4- and 1-line modes
|
slot_config.cmd = GPIO_NUM_15;
|
||||||
gpio_set_pull_mode(4, GPIO_PULLUP_ONLY); // D1, needed in 4-line mode only
|
slot_config.d0 = GPIO_NUM_2;
|
||||||
gpio_set_pull_mode(12, GPIO_PULLUP_ONLY); // D2, needed in 4-line mode only
|
slot_config.d1 = GPIO_NUM_4;
|
||||||
gpio_set_pull_mode(13, GPIO_PULLUP_ONLY); // D3, needed in 4- and 1-line modes
|
slot_config.d2 = GPIO_NUM_12;
|
||||||
|
slot_config.d3 = GPIO_NUM_13;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Enable internal pullups on enabled pins. The internal pullups
|
||||||
|
// are insufficient however, please make sure 10k external pullups are
|
||||||
|
// connected on the bus. This is for debug / example purpose only.
|
||||||
|
slot_config.flags |= SDMMC_SLOT_FLAG_INTERNAL_PULLUP;
|
||||||
|
|
||||||
ret = esp_vfs_fat_sdmmc_mount(mount_point, &host, &slot_config, &mount_config, &card);
|
ret = esp_vfs_fat_sdmmc_mount(mount_point, &host, &slot_config, &mount_config, &card);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user