Skip to content

Commit cac36d3

Browse files
dariosalvi78cmaglie
authored andcommitted
fixes #35
1 parent a638e87 commit cac36d3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/SD.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,8 @@ boolean callback_rmdir(SdFile& parentDir, const char *filePathComponent,
335335

336336

337337
boolean SDClass::begin(uint8_t csPin) {
338+
if(root.isOpen()) root.close();
339+
338340
/*
339341
340342
Performs the initialisation required by the sdfatlib library.
@@ -348,6 +350,8 @@ boolean SDClass::begin(uint8_t csPin) {
348350
}
349351

350352
boolean SDClass::begin(uint32_t clock, uint8_t csPin) {
353+
if(root.isOpen()) root.close();
354+
351355
return card.init(SPI_HALF_SPEED, csPin) &&
352356
card.setSpiClock(clock) &&
353357
volume.init(card) &&

0 commit comments

Comments
 (0)