Skip to content

Commit 56b466f

Browse files
author
Kees Bakker
committed
Add SDClass::end function
Call end function to fully de-initialize SD object. Allows you to call SD.begin again to init a new card. This change was taken from Adafruit's SD library. Author: driverblock <[email protected]>
1 parent a638e87 commit 56b466f

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/SD.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,12 @@ boolean SDClass::begin(uint32_t clock, uint8_t csPin) {
354354
root.openRoot(volume);
355355
}
356356

357+
//call this when a card is removed. It will allow you to inster and initialise a new card.
358+
void SDClass::end()
359+
{
360+
root.close();
361+
}
362+
357363
// this little helper is used to traverse paths
358364
SdFile SDClass::getParentDir(const char *filepath, int *index) {
359365
// get parent directory

src/SD.h

+3
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ class SDClass {
7070
boolean begin(uint8_t csPin = SD_CHIP_SELECT_PIN);
7171
boolean begin(uint32_t clock, uint8_t csPin);
7272

73+
//call this when a card is removed. It will allow you to inster and initialise a new card.
74+
void end();
75+
7376
// Open the specified file/directory with the supplied mode (e.g. read or
7477
// write, etc). Returns a File object for interacting with the file.
7578
// Note that currently only one file can be open at a time.

0 commit comments

Comments
 (0)