Use mbed as a Pi console cable to run command line Linux

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
4180_1
Date:
Sun May 14 15:39:24 2017 +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 4f64dd8a2ca3 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun May 14 15:39:24 2017 +0000
@@ -0,0 +1,41 @@
+#include "mbed.h"
+//Pi Console Cable function
+// connect gnd on Pi header to mbed
+// connect mbed p9 to Pi RX pin
+// connect mbed p10 to Pi TX pin
+// Enable serial console on Pi (needed one time only)
+// Run terminal application on PC at 115200 baud
+// See https://developer.mbed.org/users/4180_1/notebook/using-mbed-for-a-pi-console-cable/#
+RawSerial  pc(USBTX, USBRX);
+RawSerial  dev(p9, p10);
+DigitalOut led1(LED1);
+DigitalOut led4(LED4);
+ 
+void dev_recv()
+{
+    led1 = !led1;
+    while(dev.readable()) {
+        pc.putc(dev.getc());
+    }
+}
+ 
+void pc_recv()
+{
+    led4 = !led4;
+    while(pc.readable()) {
+        dev.putc(pc.getc());
+    }
+}
+ 
+int main()
+{
+    pc.baud(115200);
+    dev.baud(115200);
+ 
+    pc.attach(&pc_recv, Serial::RxIrq);
+    dev.attach(&dev_recv, Serial::RxIrq);
+ 
+    while(1) {
+        sleep();
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r 4f64dd8a2ca3 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun May 14 15:39:24 2017 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/mbed/builds/4eea097334d6
\ No newline at end of file