diff options
| author | Marti Bolivar <mbolivar@leaflabs.com> | 2011-04-06 13:57:30 -0400 |
|---|---|---|
| committer | Marti Bolivar <mbolivar@leaflabs.com> | 2011-04-07 13:18:36 -0400 |
| commit | f6f9a1122706ed336c52c984d76219dee0594487 (patch) | |
| tree | cfc2c163ae8327734c1b0d092e8683209571d1b7 /examples/test-serial-flush.cpp | |
| parent | 77eae0960d209b96d2cfdc2ca32f0ccec9029ad9 (diff) | |
USART refactor.
Diffstat (limited to 'examples/test-serial-flush.cpp')
| -rw-r--r-- | examples/test-serial-flush.cpp | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/examples/test-serial-flush.cpp b/examples/test-serial-flush.cpp index 1cd82b6..6c4e100 100644 --- a/examples/test-serial-flush.cpp +++ b/examples/test-serial-flush.cpp @@ -1,21 +1,26 @@ -// Tests the "flush" Serial function +/* + * Tests the "flush" Serial function. + */ #include "wirish.h" +#define COMM Serial1 + void setup() { - /* Send a message out USART2 */ - Serial2.begin(9600); - Serial2.println("Hello world!"); + COMM.begin(9600); + COMM.println("Hello world!"); } void loop() { - Serial2.println("Waiting for multiple input..."); - while(Serial2.available() < 5) { } - Serial2.println(Serial2.read()); - Serial2.println(Serial2.read()); - Serial2.flush(); - if(Serial2.available()) { - Serial2.println("FAIL! Still had junk in the buffer..."); + COMM.println("Waiting for multiple input..."); + while (COMM.available() < 5) + ; + COMM.println(COMM.read()); + COMM.println(COMM.read()); + COMM.flush(); + + if (COMM.available()) { + COMM.println("FAIL! Still had junk in the buffer..."); } } @@ -28,7 +33,7 @@ __attribute__((constructor)) void premain() { int main(void) { setup(); - while (1) { + while (true) { loop(); } return 0; |
