This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* This program is a simple binary write/read benchmark.
|
||||
*/
|
||||
#include "FreeStack.h"
|
||||
#include "SdFat.h"
|
||||
#include "sdios.h"
|
||||
#include "FreeStack.h"
|
||||
|
||||
// SD_FAT_TYPE = 0 for SdFat/File as defined in SdFatConfig.h,
|
||||
// 1 for FAT16/FAT32, 2 for exFAT, 3 for FAT16/FAT32 and exFAT.
|
||||
@@ -19,7 +19,7 @@
|
||||
// SDCARD_SS_PIN is defined for the built-in SD on some boards.
|
||||
#ifndef SDCARD_SS_PIN
|
||||
const uint8_t SD_CS_PIN = SS;
|
||||
#else // SDCARD_SS_PIN
|
||||
#else // SDCARD_SS_PIN
|
||||
// Assume built-in SD is used.
|
||||
const uint8_t SD_CS_PIN = SDCARD_SS_PIN;
|
||||
#endif // SDCARD_SS_PIN
|
||||
@@ -30,7 +30,7 @@ const uint8_t SD_CS_PIN = SDCARD_SS_PIN;
|
||||
// Try to select the best SD card configuration.
|
||||
#if HAS_SDIO_CLASS
|
||||
#define SD_CONFIG SdioConfig(FIFO_SDIO)
|
||||
#elif ENABLE_DEDICATED_SPI
|
||||
#elif ENABLE_DEDICATED_SPI
|
||||
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI, SPI_CLOCK)
|
||||
#else // HAS_SDIO_CLASS
|
||||
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI, SPI_CLOCK)
|
||||
@@ -58,10 +58,10 @@ const uint8_t READ_COUNT = 2;
|
||||
// End of configuration constants.
|
||||
//------------------------------------------------------------------------------
|
||||
// File size in bytes.
|
||||
const uint32_t FILE_SIZE = 1000000UL*FILE_SIZE_MB;
|
||||
const uint32_t FILE_SIZE = 1000000UL * FILE_SIZE_MB;
|
||||
|
||||
// Insure 4-byte alignment.
|
||||
uint32_t buf32[(BUF_SIZE + 3)/4];
|
||||
uint32_t buf32[(BUF_SIZE + 3) / 4];
|
||||
uint8_t* buf = (uint8_t*)buf32;
|
||||
|
||||
#if SD_FAT_TYPE == 0
|
||||
@@ -125,8 +125,8 @@ void setup() {
|
||||
cout << F("\nUse a freshly formatted SD for best performance.\n");
|
||||
if (!ENABLE_DEDICATED_SPI) {
|
||||
cout << F(
|
||||
"\nSet ENABLE_DEDICATED_SPI nonzero in\n"
|
||||
"SdFatConfig.h for best SPI performance.\n");
|
||||
"\nSet ENABLE_DEDICATED_SPI nonzero in\n"
|
||||
"SdFatConfig.h for best SPI performance.\n");
|
||||
}
|
||||
// use uppercase in hex and use 0X base prefix
|
||||
cout << uppercase << showbase << endl;
|
||||
@@ -161,7 +161,7 @@ void loop() {
|
||||
cout << F("Type is FAT") << int(sd.fatType()) << endl;
|
||||
}
|
||||
|
||||
cout << F("Card size: ") << sd.card()->sectorCount()*512E-9;
|
||||
cout << F("Card size: ") << sd.card()->sectorCount() * 512E-9;
|
||||
cout << F(" GB (GB = 1E9 bytes)") << endl;
|
||||
|
||||
cidDmp();
|
||||
@@ -176,17 +176,17 @@ void loop() {
|
||||
for (size_t i = 0; i < (BUF_SIZE - 2); i++) {
|
||||
buf[i] = 'A' + (i % 26);
|
||||
}
|
||||
buf[BUF_SIZE-2] = '\r';
|
||||
buf[BUF_SIZE - 2] = '\r';
|
||||
}
|
||||
buf[BUF_SIZE-1] = '\n';
|
||||
buf[BUF_SIZE - 1] = '\n';
|
||||
|
||||
cout << F("FILE_SIZE_MB = ") << FILE_SIZE_MB << endl;
|
||||
cout << F("BUF_SIZE = ") << BUF_SIZE << F(" bytes\n");
|
||||
cout << F("Starting write test, please wait.") << endl << endl;
|
||||
|
||||
// do write test
|
||||
uint32_t n = FILE_SIZE/BUF_SIZE;
|
||||
cout <<F("write speed and latency") << endl;
|
||||
uint32_t n = FILE_SIZE / BUF_SIZE;
|
||||
cout << F("write speed and latency") << endl;
|
||||
cout << F("speed,max,min,avg") << endl;
|
||||
cout << F("KB/Sec,usec,usec,usec") << endl;
|
||||
for (uint8_t nTest = 0; nTest < WRITE_COUNT; nTest++) {
|
||||
@@ -223,11 +223,11 @@ void loop() {
|
||||
file.sync();
|
||||
t = millis() - t;
|
||||
s = file.fileSize();
|
||||
cout << s/t <<',' << maxLatency << ',' << minLatency;
|
||||
cout << ',' << totalLatency/n << endl;
|
||||
cout << s / t << ',' << maxLatency << ',' << minLatency;
|
||||
cout << ',' << totalLatency / n << endl;
|
||||
}
|
||||
cout << endl << F("Starting read test, please wait.") << endl;
|
||||
cout << endl <<F("read speed and latency") << endl;
|
||||
cout << endl << F("read speed and latency") << endl;
|
||||
cout << F("speed,max,min,avg") << endl;
|
||||
cout << F("KB/Sec,usec,usec,usec") << endl;
|
||||
|
||||
@@ -240,7 +240,7 @@ void loop() {
|
||||
skipLatency = SKIP_FIRST_LATENCY;
|
||||
t = millis();
|
||||
for (uint32_t i = 0; i < n; i++) {
|
||||
buf[BUF_SIZE-1] = 0;
|
||||
buf[BUF_SIZE - 1] = 0;
|
||||
uint32_t m = micros();
|
||||
int32_t nr = file.read(buf, BUF_SIZE);
|
||||
if (nr != BUF_SIZE) {
|
||||
@@ -248,8 +248,7 @@ void loop() {
|
||||
}
|
||||
m = micros() - m;
|
||||
totalLatency += m;
|
||||
if (buf[BUF_SIZE-1] != '\n') {
|
||||
|
||||
if (buf[BUF_SIZE - 1] != '\n') {
|
||||
error("data check error");
|
||||
}
|
||||
if (skipLatency) {
|
||||
@@ -265,8 +264,8 @@ void loop() {
|
||||
}
|
||||
s = file.fileSize();
|
||||
t = millis() - t;
|
||||
cout << s/t <<',' << maxLatency << ',' << minLatency;
|
||||
cout << ',' << totalLatency/n << endl;
|
||||
cout << s / t << ',' << maxLatency << ',' << minLatency;
|
||||
cout << ',' << totalLatency / n << endl;
|
||||
}
|
||||
cout << endl << F("Done") << endl;
|
||||
file.close();
|
||||
|
||||
Reference in New Issue
Block a user