blob: 409d1f9a025c36e20bf29c6cff2a2ae656a4eb2f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
/*
* Tests the "flush" Serial function.
*/
#include <wirish/wirish.h>
void setup() {
Serial1.begin(9600);
Serial1.println("Hello world!");
}
void loop() {
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 objects that need libmaple may fail.
__attribute__((constructor)) void premain() {
init();
}
int main(void) {
setup();
while (true) {
loop();
}
return 0;
}
|