Skip to content

Commit 5ccc94b

Browse files
Kees Bakkercmaglie
Kees Bakker
authored andcommitted
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 cac36d3 commit 5ccc94b

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
@@ -358,6 +358,12 @@ boolean SDClass::begin(uint32_t clock, uint8_t csPin) {
358358
root.openRoot(volume);
359359
}
360360

361+
//call this when a card is removed. It will allow you to insert and initialise a new card.
362+
void SDClass::end()
363+
{
364+
root.close();
365+
}
366+
361367
// this little helper is used to traverse paths
362368
SdFile SDClass::getParentDir(const char *filepath, int *index) {
363369
// 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 insert 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)