Virtual Serial USB Communication

Dependencies:   USBDevice mbed

Files at this revision

API Documentation at this revision

Comitter:
mercadrs
Date:
Mon Nov 10 18:34:47 2014 +0000
Commit message:
Virtual Serial USB Communication

Changed in this revision

USBDevice.lib Show annotated file Show diff for this revision Revisions of this file
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 d48409ed9d39 USBDevice.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDevice.lib	Mon Nov 10 18:34:47 2014 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/mbed_official/code/USBDevice/#a4e9ddc2e2af
diff -r 000000000000 -r d48409ed9d39 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Nov 10 18:34:47 2014 +0000
@@ -0,0 +1,43 @@
+#include "mbed.h"
+#include "USBSerial.h"
+#include <iostream>
+#include <string>
+
+//sending data example
+//https://developer.mbed.org/forum/helloworld/topic/2579/
+
+//Outgoing comm from board to chip
+Serial micro(p9, p10);//tx, rx
+//Virtual serial port over USB
+Serial pc(USBTX, USBRX);
+ 
+int main(void) {
+    pc.printf("%s", "connected...\n");
+    //config for outgoing comm
+    micro.format(8, Serial::None, 1);
+    micro.baud(9600); //maybe back down to 9600
+    
+    int word_size = 0;
+    uint8_t arr[50];
+    while(1){
+        for(int i = 0; i < 50; i++)
+        {
+         
+                arr[i] = pc.getc();
+                pc.putc(arr[i]);
+                word_size += 1;
+                if(arr[i] == '.'){break;}
+        }
+        for(int i = 0; i < word_size; i++)
+        {
+                if(micro.writeable()){
+                    micro.printf("%c", arr[i]);
+                }
+                pc.printf("%c", arr[i]);
+        }
+        pc.printf("\n");
+        
+        word_size = 0;
+    }
+    
+}
\ No newline at end of file
diff -r 000000000000 -r d48409ed9d39 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Nov 10 18:34:47 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/031413cf7a89
\ No newline at end of file