summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2022-08-30 11:18:08 +1000
committerDamien George <damien@micropython.org>2022-08-30 12:54:18 +1000
commitd108fc9c4793e1846b2ddfad925fb17bbc44cd51 (patch)
tree9c8c738a267b1b73748a5fb052fa805bacfc3c88
parent730e97509117ea9c8b527857c25f8a2bf04ecd86 (diff)
esp32/machine_sdcard: Free SPI bus when deiniting SD card.
So that everything is reset and the SD card can be created again after calling SDCard.deinit() (and after a soft reset). Fixes issue #8949. Signed-off-by: Damien George <damien@micropython.org>
-rw-r--r--ports/esp32/machine_sdcard.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/ports/esp32/machine_sdcard.c b/ports/esp32/machine_sdcard.c
index 82c2e6cd4..3f94356ad 100644
--- a/ports/esp32/machine_sdcard.c
+++ b/ports/esp32/machine_sdcard.c
@@ -283,6 +283,10 @@ STATIC mp_obj_t sd_deinit(mp_obj_t self_in) {
{
self->host.deinit();
}
+ if (self->host.flags & SDMMC_HOST_FLAG_SPI) {
+ // SD card used a (dedicated) SPI bus, so free that SPI bus.
+ spi_bus_free(self->host.slot);
+ }
self->flags &= ~SDCARD_CARD_FLAGS_HOST_INIT_DONE;
}