Serial passthrough with echo back to PC added - used for testing Emic 2 commands

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
4180_1
Date:
Thu Nov 26 01:48:35 2015 +0000
Commit message:
ver 1.0

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 4c2a5ae75108 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Nov 26 01:48:35 2015 +0000
@@ -0,0 +1,38 @@
+#include "mbed.h"
+
+RawSerial  pc(USBTX, USBRX);
+RawSerial  dev(p13,p14);
+DigitalOut led1(LED1);
+DigitalOut led4(LED4);
+
+void dev_recv()
+{
+    led1 = !led1;
+    while(dev.readable()) {
+        pc.putc(dev.getc());
+    }
+}
+
+void pc_recv()
+{
+    led4 = !led4;
+    char x;
+    while(pc.readable()) {
+        x=pc.getc();
+        dev.putc(x);
+        pc.putc(x); //echo back so that you can see what you are typing!
+    }
+}
+
+int main()
+{
+    pc.baud(9600);
+    dev.baud(9600);
+
+    pc.attach(&pc_recv, Serial::RxIrq);
+    dev.attach(&dev_recv, Serial::RxIrq);
+
+    while(1) {
+        sleep();
+    }
+}
diff -r 000000000000 -r 4c2a5ae75108 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Nov 26 01:48:35 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/9296ab0bfc11
\ No newline at end of file