aboutsummaryrefslogtreecommitdiffstats
path: root/examples/serial-echo.cpp
blob: 204f01131d51fe34a13e028e737618691d308ace (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
// Simple serial port "echo". Send back any received data.

#include <wirish/wirish.h>

// Note: you can change "Serial1" to any other serial port you have on
// your board.

void setup() {
    Serial1.begin(115200);
}

void loop() {
    while (Serial1.available()) {
        Serial1.write(Serial1.read());
    }
}

// Force init() to be called before anything else.
__attribute__((constructor)) void premain() {
    init();
}

int main(void) {
    setup();

    while (true) {
        loop();
    }
    return 0;
}