Skip to content

Commit bcb3c32

Browse files
committed
Merge branch 'bugfix/sdmmc_reset_pins_slot_width_v5.4' into 'release/v5.4'
fix(sdmmc): fix reset of pins above slot width (v5.4) See merge request espressif/esp-idf!36874
2 parents c93d7d0 + 8ad144a commit bcb3c32

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

components/esp_driver_sdmmc/src/sdmmc_host.c

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -849,16 +849,32 @@ static int sdmmc_host_decrease_init_slot_num(void)
849849
#endif
850850
}
851851

852+
static void reset_pin_if_valid(gpio_num_t gpio_num)
853+
{
854+
if (gpio_num != GPIO_NUM_NC && GPIO_IS_VALID_GPIO(gpio_num)) {
855+
gpio_reset_pin(gpio_num);
856+
}
857+
}
858+
852859
static void sdmmc_host_deinit_slot_internal(int slot)
853860
{
854-
int8_t gpio_pin_num;
855861
sdmmc_slot_io_info_t* gpio = &s_host_ctx.slot_ctx[slot].slot_gpio_num;
856862
// Disconnect signals and reset used GPIO pins
857-
for (size_t i = 0; i < (sizeof(gpio->val) / (sizeof(gpio->val[0]))); i++) {
858-
gpio_pin_num = gpio->val[i];
859-
if (gpio_pin_num != GPIO_NUM_NC && GPIO_IS_VALID_GPIO(gpio_pin_num)) {
860-
gpio_reset_pin(gpio_pin_num);
861-
}
863+
reset_pin_if_valid(gpio->cd);
864+
reset_pin_if_valid(gpio->wp);
865+
reset_pin_if_valid(gpio->clk);
866+
reset_pin_if_valid(gpio->cmd);
867+
reset_pin_if_valid(gpio->d0);
868+
if (s_host_ctx.slot_ctx[slot].slot_width >= 4) {
869+
reset_pin_if_valid(gpio->d1);
870+
reset_pin_if_valid(gpio->d2);
871+
reset_pin_if_valid(gpio->d3);
872+
}
873+
if (s_host_ctx.slot_ctx[slot].slot_width == 8) {
874+
reset_pin_if_valid(gpio->d4);
875+
reset_pin_if_valid(gpio->d5);
876+
reset_pin_if_valid(gpio->d6);
877+
reset_pin_if_valid(gpio->d7);
862878
}
863879
// Reset the slot context
864880
memset(&(s_host_ctx.slot_ctx[slot]), 0, sizeof(slot_ctx_t));

0 commit comments

Comments
 (0)