Skip to content

Commit f425815

Browse files
committed
In SD.init, when already open, close root directory before trying to init.
1 parent 4672d45 commit f425815

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

libraries/SD/SD.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,13 @@ boolean SDClass::begin(uint8_t csPin) {
340340
Return true if initialization succeeds, false otherwise.
341341
342342
*/
343+
344+
/* before trying to initialize the card, close the root if open */
345+
/* this fixes a bug when we turn off the SD card to save power */
346+
if (root.isOpen())
347+
if (!root.close())
348+
return false;
349+
343350
return card.init(SPI_HALF_SPEED, csPin) &&
344351
volume.init(card) &&
345352
root.openRoot(volume);

0 commit comments

Comments
 (0)