diff options
| author | Marti Bolivar <mbolivar@leaflabs.com> | 2012-06-01 01:29:23 -0400 |
|---|---|---|
| committer | Marti Bolivar <mbolivar@leaflabs.com> | 2012-06-01 01:29:23 -0400 |
| commit | 93a2a86a02743a3247f6f5b1d88131e5bc1eee8b (patch) | |
| tree | de48ec1e2c77321cd7905cbc0473ef2c0b6752d2 /examples | |
| parent | d2c4bd65649d22fce225a68ba3f0c2775ac49964 (diff) | |
Add examples/serial-echo.cpp.
Serial1 writes back what it receives.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/serial-echo.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/examples/serial-echo.cpp b/examples/serial-echo.cpp new file mode 100644 index 0000000..204f011 --- /dev/null +++ b/examples/serial-echo.cpp @@ -0,0 +1,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; +} |
