aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/test-fsmc.cpp61
1 files changed, 28 insertions, 33 deletions
diff --git a/examples/test-fsmc.cpp b/examples/test-fsmc.cpp
index 9102be6..7cb1764 100644
--- a/examples/test-fsmc.cpp
+++ b/examples/test-fsmc.cpp
@@ -19,14 +19,13 @@ void setup() {
pinMode(BOARD_LED_PIN, OUTPUT);
digitalWrite(BOARD_LED_PIN, HIGH);
- Serial1.begin(115200);
- Serial1.println("*** Beginning RAM chip test");
+ SerialUSB.println("*** Beginning RAM chip test");
test_single_write();
test_all_addresses();
- Serial1.println("Tests pass, finished.");
- Serial1.println("***\n");
+ SerialUSB.println("Tests pass, finished.");
+ SerialUSB.println("***\n");
}
void loop() {
@@ -36,17 +35,17 @@ void test_single_write() {
uint16 *ptr = sram_start;
uint16 tmp;
- Serial1.print("Writing 0x1234... ");
+ SerialUSB.print("Writing 0x1234... ");
*ptr = 0x1234;
- Serial1.println("Done.");
+ SerialUSB.println("Done.");
- Serial1.print("Reading... ");
+ SerialUSB.print("Reading... ");
tmp = *ptr;
- Serial1.print("Done: 0x");
- Serial1.println(tmp, HEX);
+ SerialUSB.print("Done: 0x");
+ SerialUSB.println(tmp, HEX);
if (tmp != 0x1234) {
- Serial1.println("Mismatch; abort.");
+ SerialUSB.println("Mismatch; abort.");
ASSERT(0);
}
}
@@ -56,10 +55,7 @@ void test_all_addresses() {
uint16 count = 0;
uint16 *ptr;
- Serial1.println("Now writing all memory addresses (unrolled loop)");
- // Turn off the USB interrupt, as it interferes most with timing
- // (don't turn off SysTick, or we won't get micros()).
- SerialUSB.end();
+ SerialUSB.println("Now writing all memory addresses (unrolled loop)");
start = micros();
for (ptr = sram_start; ptr < sram_end;) {
*ptr++ = count++;
@@ -80,35 +76,34 @@ void test_all_addresses() {
*ptr++ = count++;
}
end = micros();
- SerialUSB.begin();
- Serial1.print("Done. Elapsed time (us): ");
- Serial1.println(end - start);
+ SerialUSB.print("Done. Elapsed time (us): ");
+ SerialUSB.println(end - start);
- Serial1.println("Validating writes.");
+ SerialUSB.println("Validating writes.");
for (ptr = sram_start, count = 0; ptr < sram_end; ptr++, count++) {
uint16 value = *ptr;
if (value != count) {
- Serial1.print("mismatch: 0x");
- Serial1.print((uint32)ptr);
- Serial1.print(" = 0x");
- Serial1.print(value, HEX);
- Serial1.print(", should be 0x");
- Serial1.print(count, HEX);
- Serial1.println(".");
+ SerialUSB.print("mismatch: 0x");
+ SerialUSB.print((uint32)ptr);
+ SerialUSB.print(" = 0x");
+ SerialUSB.print(value, HEX);
+ SerialUSB.print(", should be 0x");
+ SerialUSB.print(count, HEX);
+ SerialUSB.println(".");
ASSERT(0);
}
}
- Serial1.println("Done; all writes seem valid.");
+ SerialUSB.println("Done; all writes seem valid.");
ptrdiff_t nwrites = sram_end - sram_start;
double us_per_write = double(end-start) / double(nwrites);
- Serial1.print("Number of writes = ");
- Serial1.print(nwrites);
- Serial1.print("; avg. time per write = ");
- Serial1.print(us_per_write);
- Serial1.print(" us (");
- Serial1.print(1 / us_per_write);
- Serial1.println(" MHz)");
+ SerialUSB.print("Number of writes = ");
+ SerialUSB.print(nwrites);
+ SerialUSB.print("; avg. time per write = ");
+ SerialUSB.print(us_per_write);
+ SerialUSB.print(" us (");
+ SerialUSB.print(1 / us_per_write);
+ SerialUSB.println(" MHz)");
}
__attribute__((constructor)) void premain() {