10000 esp32/machine_sdcard: Free SPI bus when deiniting SD card. · lowfatcode/micropython@d108fc9 · GitHub
[go: up one dir, main page]

Skip to content

Commit d108fc9

Browse files
committed
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 micropython#8949. Signed-off-by: Damien George <damien@micropython.org>
1 parent 730e975 commit d108fc9

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

ports/esp32/machine_sdcard.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,10 @@ STATIC mp_obj_t sd_deinit(mp_obj_t self_in) {
283283
{
284284
self->host.deinit();
285285
}
286+
if (self->host.flags & SDMMC_HOST_FLAG_SPI) {
287+
// SD card used a (dedicated) SPI bus, so free that SPI bus.
288+
spi_bus_free(self->host.slot);
289+
}
286290
self->flags &= ~SDCARD_CARD_FLAGS_HOST_INIT_DONE;
287291
}
288292

0 commit comments

Comments
 (0)
0