jim hamblen / Mbed 2 deprecated SerialPassthrough_LPC1768

Dependencies:   mbed

Fork of SerialPassthrough by Austin Blackstone

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 RawSerial  pc(USBTX, USBRX);
00004 RawSerial  dev(p28,p27);
00005 DigitalOut led1(LED1);
00006 DigitalOut led4(LED4);
00007 
00008 void dev_recv()
00009 {
00010     led1 = !led1;
00011     while(dev.readable()) {
00012         pc.putc(dev.getc());
00013     }
00014 }
00015 
00016 void pc_recv()
00017 {
00018     led4 = !led4;
00019     while(pc.readable()) {
00020         dev.putc(pc.getc());
00021     }
00022 }
00023 
00024 int main()
00025 {
00026     pc.baud(9600);
00027     dev.baud(9600);
00028 
00029     pc.attach(&pc_recv, Serial::RxIrq);
00030     dev.attach(&dev_recv, Serial::RxIrq);
00031 
00032     while(1) {
00033         sleep();
00034     }
00035 }