Merge branch 'feat/sdspi_option_to_disable_waiting_for_miso_poll_busy' into 'master'

feat(sdspi): Add an option to modify the waiting time for MISO before sending next command

Closes IDFGH-15977 and IDFGH-9089

See merge request espressif/esp-idf!41175
This commit is contained in:
Adam Múdry
2025-08-22 12:51:45 +02:00
8 changed files with 121 additions and 21 deletions
+12
View File
@@ -236,3 +236,15 @@ In the absence of connected pullups and having the weak pullups enabled, you can
It will also provide the voltage levels at the corresponding SD pins. By default, this information is provided for ESP32 chip only, and for other chipsets, verify the availability of ADC pins for the respective GPIO using [this](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/gpio.html#gpio-summary) and configure ADC mapped pins using menuconfig. Then test the voltage levels accordingly.
You can monitor the voltage levels of individual pins using `PIN voltage levels` and `PIN voltage levels with weak pullup`. However, if one pin being pulled low and experiencing interference with another pin, you can detect it through `PIN cross-talk` and `PIN cross-talk with weak pullup`. In the absence of pullups, voltage levels at each pin should range from 0 to 0.3V. With 10k pullups connected, the voltage will be between 3.1V to 3.3V, contingent on the connection between ADC pins and SD pins, and with weak pullups connected, it can fluctuate between 0.8V to 1.2V, depending on pullup strength.
### Slow performance / low throughput (no or incorrect pull-up resistor on MISO line)
The current driver implementation waits for the MISO line to be high before sending the next transaction. This is the correct behavior and fixes certain issues especially when there are more SPI devices connected to same SPI bus. However this can slow down SD throughput on boards lacking a sufficiently strong pull-up resistor on the MISO line.
If you experience this slowdown, you can try adding the following line. Modifying this value can cause problems in certain scenarios (e.g. SD card and another device like TFT screen sharing the same SPI bus resulting in failed communication with SD card), so please use it with caution.
```c
sdspi_device_config_t slot_config = SDSPI_DEVICE_CONFIG_DEFAULT()
slot_config.wait_for_miso = -1; // <--- Add this line
// If this causes problems, try to set the value higher (-1: no waiting (0ms); 0: default value (40ms); 1-127: timeout in ms; else: invalid value, default will be used)
```