]> granicus.if.org Git - esp-idf/commitdiff
sdmmc: don't use high speed mode with SD over SPI
authorIvan Grokhotkov <ivan@espressif.com>
Thu, 24 Aug 2017 08:28:37 +0000 (16:28 +0800)
committerIvan Grokhotkov <ivan@espressif.com>
Fri, 25 Aug 2017 06:33:19 +0000 (14:33 +0800)
Disabling due to limitation of SPI driver (max 26MHz for full-duplex
mode over GPIO matrix)

components/sdmmc/sdmmc_cmd.c
components/sdmmc/test/test_sd.c
docs/api-reference/storage/sdmmc.rst

index 2e8b0f85c6f2e56dd4d1219fd3669429b3d5269d..3b962d432bbd8a91ce86a290d7b1feb669676020 100644 (file)
@@ -233,7 +233,7 @@ esp_err_t sdmmc_card_init(const sdmmc_host_t* config, sdmmc_card_t* card)
 
     /* Wait for the card to be ready for data transfers */
     uint32_t status = 0;
-    while (!host_is_spi(card) && !(status & MMC_R1_READY_FOR_DATA)) {
+    while (!is_spi && !(status & MMC_R1_READY_FOR_DATA)) {
         // TODO: add some timeout here
         uint32_t count = 0;
         err = sdmmc_send_cmd_send_status(card, &status);
@@ -249,7 +249,8 @@ esp_err_t sdmmc_card_init(const sdmmc_host_t* config, sdmmc_card_t* card)
      * clock rate which both host and the card support, and switch to it.
      */
     bool freq_switched = false;
-    if (config->max_freq_khz >= SDMMC_FREQ_HIGHSPEED) {
+    if (config->max_freq_khz >= SDMMC_FREQ_HIGHSPEED &&
+            !is_spi /* SPI doesn't support >26MHz in some cases */) {
         /* This will determine if the card supports SWITCH_FUNC command,
          * and high speed mode. If the cards supports both, this will enable
          * high speed mode at the card side.
index b431752955c86b6d5b10fa16e4c27e101b997a57..379a2d8cea81adae7e16adf22d34d82cdda135b1 100644 (file)
@@ -164,7 +164,6 @@ TEST_CASE("can write and read back blocks", "[sd][test_env=UT_T1_SDMODE]")
 TEST_CASE("can write and read back blocks(using SPI)", "[sdspi][test_env=UT_T1_SPIMODE]")
 {
     sdmmc_host_t config = SDSPI_HOST_DEFAULT();
-    config.max_freq_khz = SDMMC_FREQ_HIGHSPEED;
     sdspi_slot_config_t slot_config = SDSPI_SLOT_CONFIG_DEFAULT();
     TEST_ESP_OK(sdspi_host_init());
     TEST_ESP_OK(sdspi_host_init_slot(config.slot, &slot_config));
index ba26b9e16d3e852fa747470a68eab108f306cb11..3cd31a8d273249b3aea5d0fc6222fd091742e65d 100644 (file)
@@ -106,6 +106,11 @@ SD SPI driver is represented using an ``sdmmc_host_t`` structure initialized usi
 
 SD SPI driver APIs are very similar to SDMMC host APIs. As with the SDMMC host driver, only ``sdspi_host_init``, ``sdspi_host_init_slot``, and ``sdspi_host_deinit`` functions are normally used by the applications. Other functions are called by the protocol level driver via function pointers in ``sdmmc_host_t`` structure.
 
+.. note:
+       
+       SD over SPI does not support speeds above SDMMC_FREQ_DEFAULT due to a limitation of SPI driver.
+
+
 .. doxygenfunction:: sdspi_host_init
 
 .. doxygendefine:: SDSPI_HOST_DEFAULT