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 | 552b8882ef04cb0028ec30a04b5464b1a17bccad (patch) | |
tree | 27332e20a6b5cfad0629917eb257fad24a9589a4 /examples/test-serial-flush.cpp | |
parent | 012d9ba1c2069d4d072685b990cbd01b611bb751 (diff) | |
download | librambutan-552b8882ef04cb0028ec30a04b5464b1a17bccad.tar.gz librambutan-552b8882ef04cb0028ec30a04b5464b1a17bccad.zip |
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; |