From a5f96b22d1fc126ed470faf4234c1ddd25a3dea0 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Fri, 13 Oct 2017 08:21:06 +0800 Subject: [PATCH] examples/sdmmc: enable internal pull-ups in SD mode Some development boards do not have sufficient external pull-ups on SD card pins. Most notably, if high level on GPIO13 is not registered by the card when GO_IDLE_STATE command is received, the card will enter SPI mode and further communication will not be possible, until power to the card is toggled. This change enables internal pull-ups on SD card pins in an attempt to make this initialization process more reliable. --- examples/storage/sd_card/main/sd_card_example_main.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/storage/sd_card/main/sd_card_example_main.c b/examples/storage/sd_card/main/sd_card_example_main.c index 975fbc4b0c..459673e958 100644 --- a/examples/storage/sd_card/main/sd_card_example_main.c +++ b/examples/storage/sd_card/main/sd_card_example_main.c @@ -54,6 +54,15 @@ void app_main(void) // 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(); + // GPIOs 15, 2, 4, 12, 13 should have external 10k pull-ups. + // Internal pull-ups are not sufficient. However, enabling internal pull-ups + // does make a difference some boards, so we do that here. + gpio_set_pull_mode(15, GPIO_PULLUP_ONLY); // CMD, needed in 4- and 1- line modes + gpio_set_pull_mode(2, GPIO_PULLUP_ONLY); // D0, needed in 4- and 1-line modes + gpio_set_pull_mode(4, GPIO_PULLUP_ONLY); // D1, needed in 4-line mode only + gpio_set_pull_mode(12, GPIO_PULLUP_ONLY); // D2, needed in 4-line mode only + gpio_set_pull_mode(13, GPIO_PULLUP_ONLY); // D3, needed in 4- and 1-line modes + #else ESP_LOGI(TAG, "Using SPI peripheral");