diff options
Diffstat (limited to 'examples/fsmc-stress-test.cpp')
-rw-r--r-- | examples/fsmc-stress-test.cpp | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/examples/fsmc-stress-test.cpp b/examples/fsmc-stress-test.cpp index 12e8650..66d325f 100644 --- a/examples/fsmc-stress-test.cpp +++ b/examples/fsmc-stress-test.cpp @@ -72,9 +72,12 @@ char snprintf_buf[200]; snprintf(snprintf_buf, sizeof snprintf_buf, \ "ERROR: " fmt " (seed %d, ncalls %d, line %d)", \ __VA_ARGS__, seed, num_rand_calls, __LINE__); \ - Serial1.println(snprintf_buf); \ + SerialUSB.println(snprintf_buf); \ } while (0) +// Set to 1 for more output +#define VERBOSE 0 + // -- setup()/loop() ---------------------------------------------------------- void setup() { @@ -89,8 +92,10 @@ void setup() { *btrs[i] = (DATAST << 8) | ADDSET; } - Serial1.begin(115200); randomSeed(seed); + + SerialUSB.read(); + SerialUSB.println("Starting test"); } // stress_test() and simple_roundtrip() are the available test routines @@ -99,17 +104,20 @@ bool simple_roundtrip(void); void loop() { uint32 count = 0; + uint32 last; bool ok = true; bool (*test)(void) = stress_test; + last = millis(); while (true) { count++; bool result = test(); ok = ok && result; - if (ok) { + if (ok && (millis() - last > 300)) { snprintf(snprintf_buf, sizeof snprintf_buf, "everything ok so far, timestamp %d ms", millis()); - Serial1.println(snprintf_buf); + SerialUSB.println(snprintf_buf); + last = millis(); } } } @@ -138,7 +146,7 @@ bool simple_roundtrip(void) { __io uint16 *addr = starts[i] + 4; snprintf(snprintf_buf, sizeof snprintf_buf, "round-trip 0x%x at %p", wval, addr); - Serial1.println(snprintf_buf); + SerialUSB.println(snprintf_buf); *addr = wval; uint16 rval = *addr; @@ -148,7 +156,7 @@ bool simple_roundtrip(void) { return false; } else { snprintf(snprintf_buf, sizeof snprintf_buf, "got back 0x%x", rval); - Serial1.println(snprintf_buf); + SerialUSB.println(snprintf_buf); } } @@ -156,6 +164,9 @@ bool simple_roundtrip(void) { } bool random_trips(void) { +#if VERBOSE + SerialUSB.println("[random]"); +#endif for (int n = 0; n < N; n++) { __io uint16 *const start = starts[n]; @@ -177,7 +188,9 @@ bool random_trips(void) { bool sequential_trips(void) { static const uint32 seq_length = 300; - +#if VERBOSE + SerialUSB.println("[seq]"); +#endif for (int n = 0; n < N; n++) { __io uint16 *const start = starts[n]; |