Marcelo Salazar
/
passthrough
Serial passthrough tested on K64
Diff: main.cpp
- Revision:
- 86:bb53196f7557
- Parent:
- 82:abf1b1785bd7
--- a/main.cpp Wed Dec 19 13:45:03 2018 +0000 +++ b/main.cpp Tue Mar 31 08:42:42 2020 +0000 @@ -1,24 +1,15 @@ -/* mbed Microcontroller Library - * Copyright (c) 2018 ARM Limited - * SPDX-License-Identifier: Apache-2.0 - */ - #include "mbed.h" -#include "stats_report.h" - -DigitalOut led1(LED1); - -// main() runs in its own thread in the OS -int main() -{ - SystemReport sys_state(500 /* Loop delay time in ms */); - - while (true) { - // Blink LED and wait 0.5 seconds - led1 = !led1; - wait(0.5f); - - // Following the main thread wait, report on the current system status - sys_state.report_state(); + +RawSerial pc(USBTX, USBRX, 115200); // tx, rx +RawSerial device(D1, D0, 115200); // tx, rx + +int main() { + while(1) { + if(pc.readable()) { + device.putc(pc.getc()); + } + if(device.readable()) { + pc.putc(device.getc()); + } } -} +} \ No newline at end of file