blob: adc9c3ee96cffe13a3f7b113a690f4ab1f6bc0fe (
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.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;
}
|