aboutsummaryrefslogtreecommitdiff
path: root/examples/test-serial-flush.cpp
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2011-05-09 16:43:27 -0400
committerMarti Bolivar <mbolivar@leaflabs.com>2011-05-09 16:49:08 -0400
commitb8b2607ad117822f5eba4224965cbf0456ac8a0d (patch)
tree8bcf39c3c32905f6aaf64e4b7199c1edd1c7f752 /examples/test-serial-flush.cpp
parent5df53a5274cb29fd66aecdbb06f49c1d0369476d (diff)
parenta00029e1325393d779bd5294efc86a990ba0521b (diff)
Merge branch 'refactor'
This merges the libmaple refactor work into master. The contents of libmaple proper (/libmaple/) are almost completely incompatible with previous APIs in master. See /docs/source/libmaple/overview.rst for more information on the new design. Wirish incompatibilities are limited to the HardwareTimer class; however, there are several new deprecations, most likely to be removed in 0.1.0.
Diffstat (limited to 'examples/test-serial-flush.cpp')
-rw-r--r--examples/test-serial-flush.cpp45
1 files changed, 19 insertions, 26 deletions
diff --git a/examples/test-serial-flush.cpp b/examples/test-serial-flush.cpp
index d7fbf7a..adc9c3e 100644
--- a/examples/test-serial-flush.cpp
+++ b/examples/test-serial-flush.cpp
@@ -1,44 +1,37 @@
-// Tests the "flush" Serial function
+/*
+ * Tests the "flush" Serial function.
+ */
#include "wirish.h"
-void setup()
-{
- /* Send a message out USART2 */
- Serial2.begin(9600);
- Serial2.println("Hello world!");
+void setup() {
+ Serial1.begin(9600);
+ Serial1.println("Hello world!");
}
-int toggle = 0;
-
void loop() {
-
- Serial2.println("This is the first line.");
- Serial2.end();
- Serial2.println("This is the second line.");
-
- Serial2.begin(9600);
- 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...");
+ Serial1.println("Waiting for multiple input...");
+ while (Serial1.available() < 5)
+ ;
+ Serial1.println(Serial1.read());
+ Serial1.println(Serial1.read());
+ Serial1.flush();
+
+ if (Serial1.available()) {
+ Serial1.println("FAIL! Still had junk in the buffer...");
}
}
// Force init to be called *first*, i.e. before static object allocation.
-// Otherwise, statically allocated object that need libmaple may fail.
- __attribute__(( constructor )) void premain() {
+// Otherwise, statically allocated objects that need libmaple may fail.
+__attribute__((constructor)) void premain() {
init();
}
-int main(void)
-{
+int main(void) {
setup();
- while (1) {
+ while (true) {
loop();
}
return 0;