Make a serial bridge from a serial I/O device on mbed to the PC

Dependencies:   mbed

Committer:
4180_1
Date:
Wed Nov 05 17:36:32 2014 +0000
Revision:
0:382dfbad4ad1
ver 1.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
4180_1 0:382dfbad4ad1 1 #include "mbed.h"
4180_1 0:382dfbad4ad1 2 // Make a serial bridge from a serial I/O device on mbed to the PC
4180_1 0:382dfbad4ad1 3 Serial pc(USBTX, USBRX); // tx, rx
4180_1 0:382dfbad4ad1 4 Serial device(p13, p14); // tx, rx
4180_1 0:382dfbad4ad1 5 // Defaults to 9600 baud on each device - use .baud(baudrate) to change
4180_1 0:382dfbad4ad1 6 int main() {
4180_1 0:382dfbad4ad1 7 while(1) {
4180_1 0:382dfbad4ad1 8 if(pc.readable()) {
4180_1 0:382dfbad4ad1 9 device.putc(pc.getc());
4180_1 0:382dfbad4ad1 10 }
4180_1 0:382dfbad4ad1 11 if(device.readable()) {
4180_1 0:382dfbad4ad1 12 pc.putc(device.getc());
4180_1 0:382dfbad4ad1 13 }
4180_1 0:382dfbad4ad1 14 }
4180_1 0:382dfbad4ad1 15 }
4180_1 0:382dfbad4ad1 16