本文整理汇总了C++中SdBaseFile::createContiguous方法的典型用法代码示例。如果您正苦于以下问题:C++ SdBaseFile::createContiguous方法的具体用法?C++ SdBaseFile::createContiguous怎么用?C++ SdBaseFile::createContiguous使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SdBaseFile
的用法示例。
在下文中一共展示了SdBaseFile::createContiguous方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: startBinLogger
void startBinLogger(void (*dateTime)(uint16_t *date, uint16_t *time)){
#ifdef LOGGER_DEBUG
Serial.print("Size of Struct: ");
Serial.println(sizeof(salus_data_t));
Serial.print("Data_DIM: ");
Serial.println(DATA_DIM);
Serial.print("FILL_DIM: ");
Serial.println(FILL_DIM);
Serial.print("Sizeof Block: ");
Serial.println(sizeof(block_t));
Serial.println();
#endif
if (!sd.begin(SD_CHIPSELECT, SD_SPI_SPEED)) {
sd.initErrorHalt();
}
int number = 0;
char sName[80];
// Find a filename that hasn't been used already
do
{
sprintf(sName, "Salus_Results_%d.bin", number++);
} while (sd.exists(sName));
binFile.close();
binFile.dateTimeCallback(dateTime);
if (!binFile.createContiguous(sd.vwd(), sName, 512 * FILE_BLOCK_COUNT)){
error("createContiguous failed");
}
if (!binFile.contiguousRange(&bgnBlock, &endBlock)){
error("contiguousRange failed");
}
// Use SdFat's internal buffer ( ???? )
uint8_t* cache = (uint8_t*)sd.vol()->cacheClear();
if (cache == 0) {
error("cacheClear failed");
}
binFile.dateTimeCallbackCancel();
uint32_t bgnErase = bgnBlock;
uint32_t endErase;
while (bgnErase < endBlock) {
endErase = bgnErase + ERASE_SIZE;
if (endErase > endBlock) {
endErase = endBlock;
}
if (!sd.card()->erase(bgnErase, endErase)) {
error("erase failed");
}
bgnErase = endErase + 1;
}
// Start a multiple block write.
if (!sd.card()->writeStart(bgnBlock, FILE_BLOCK_COUNT)) {
error("writeBegin failed");
}
}