]> granicus.if.org Git - esp-idf/commitdiff
examples/sdmmc: enable internal pull-ups in SD mode
authorIvan Grokhotkov <ivan@espressif.com>
Fri, 13 Oct 2017 00:21:06 +0000 (08:21 +0800)
committerIvan Grokhotkov <ivan@espressif.com>
Fri, 13 Oct 2017 00:21:06 +0000 (08:21 +0800)
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

index 975fbc4b0c4190d5acb292bb019aee341fac14ae..459673e9582be62000e5743690225fa760432286 100644 (file)
@@ -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");