From cac36d356b936d3562a633091c9b1d7a8e82bac6 Mon Sep 17 00:00:00 2001 From: Dario Salvi Date: Tue, 3 Oct 2017 12:46:07 +0100 Subject: [PATCH] fixes #35 --- src/SD.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/SD.cpp b/src/SD.cpp index 5f4e465..0649370 100644 --- a/src/SD.cpp +++ b/src/SD.cpp @@ -335,6 +335,8 @@ boolean callback_rmdir(SdFile& parentDir, const char *filePathComponent, boolean SDClass::begin(uint8_t csPin) { + if(root.isOpen()) root.close(); + /* Performs the initialisation required by the sdfatlib library. @@ -348,6 +350,8 @@ boolean SDClass::begin(uint8_t csPin) { } boolean SDClass::begin(uint32_t clock, uint8_t csPin) { + if(root.isOpen()) root.close(); + return card.init(SPI_HALF_SPEED, csPin) && card.setSpiClock(clock) && volume.init(card) &&