Skip to content

Commit 900ab0b

Browse files
Fix host tests, reinstaet FAT formatting
1 parent 042b7ca commit 900ab0b

File tree

4 files changed

+11
-415
lines changed

4 files changed

+11
-415
lines changed

libraries/SDFS/src/SDFS.cpp

+9-5
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,16 @@ bool SDFSImpl::format() {
146146
if (_mounted) {
147147
return false;
148148
}
149-
return false; // TODO - Update implementation!
150-
#if 0
151-
SDFSFormatter formatter;
152-
bool ret = formatter.format(&_fs, _cfg._csPin, _cfg._spiSettings);
149+
sdfat::SdCardFactory cardFactory;
150+
sdfat::SdCard* card = cardFactory.newCard(sdfat::SdSpiConfig(_cfg._csPin, DEDICATED_SPI, _cfg._spiSettings));
151+
if (!card || card->errorCode()) {
152+
return false;
153+
}
154+
sdfat::FatFormatter fatFormatter;
155+
uint8_t *sectorBuffer = new uint8_t[512];
156+
bool ret = fatFormatter.format(card, sectorBuffer, nullptr);
157+
delete sectorBuffer;
153158
return ret;
154-
#endif
155159
}
156160

157161

0 commit comments

Comments
 (0)