Hello,
I have a project where I have created a class that sometimes might be used on its own, sometimes it might be instantiated more than once. This class makes use of read/write operations on the SD card.
The problem is that when you instantiate this class more than once, the initialization process fails, as SD.begin(BUILTIN_SDCARD) returns false when run a second time.
The obvious solution is to potentially check if SD has already been running before calling SD.begin, but there doesn't seem to be an elegant way to do this.
While investigating this I noticed that this problem has been fixed in the arduino version of the SD library such that you can call SD.begin as many times as you want. This fix is not present in the Teensyduino version of the SD library. I have tested the fix and it works fine:
Not sure where else I should post in terms of opening issues for Teensyduino libraries...
I have a project where I have created a class that sometimes might be used on its own, sometimes it might be instantiated more than once. This class makes use of read/write operations on the SD card.
The problem is that when you instantiate this class more than once, the initialization process fails, as SD.begin(BUILTIN_SDCARD) returns false when run a second time.
The obvious solution is to potentially check if SD has already been running before calling SD.begin, but there doesn't seem to be an elegant way to do this.
While investigating this I noticed that this problem has been fixed in the arduino version of the SD library such that you can call SD.begin as many times as you want. This fix is not present in the Teensyduino version of the SD library. I have tested the fix and it works fine:
Code:
boolean SDClass::begin(uint8_t csPin) {
/*
Performs the initialisation required by the sdfatlib library.
Return true if initialization succeeds, false otherwise.
*/
[COLOR="#FF0000"][B]if(root.isOpen()) root.close();[/B][/COLOR]
return card.init(SPI_HALF_SPEED, csPin) &&
volume.init(card) &&
root.openRoot(volume);
}
Not sure where else I should post in terms of opening issues for Teensyduino libraries...