NervousPuppySprintTwo

Dependencies:   C12832_lcd Servo USBHost mbed

Fork of USBHostSerial_HelloWorld by Samuel Mokrani

Files at this revision

API Documentation at this revision

Comitter:
samux
Date:
Wed Mar 06 17:07:28 2013 +0000
Child:
1:6b743a29c48a
Commit message:
USBHostSerial Hello World

Changed in this revision

USBHost.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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBHost.lib	Wed Mar 06 17:07:28 2013 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/USBHost/#a554658735bf
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Mar 06 17:07:28 2013 +0000
@@ -0,0 +1,40 @@
+#include "mbed.h"
+#include "USBHostSerial.h"
+
+DigitalOut led(LED1);
+Serial pc(USBTX, USBRX);
+
+void serial_task(void const*) {
+    char buf[100];
+    USBHostSerial serial;
+    
+    while(1) {
+    
+        // try to connect a virtual serial port
+        while(!serial.connect())
+            Thread::wait(500);
+    
+        while(1) {
+        
+            // if serial not connected, try to connect again
+            if (!serial.connected())
+                break;
+                
+            // if char available on the virtual serial port, print them
+            if (serial.available()) {
+                serial.scanf("%s", buf);
+                printf("recv: %s\r\n", buf);
+            }
+            
+        }
+        
+    }
+}
+
+int main() {
+    Thread serialTask(serial_task, NULL, osPriorityNormal, 1024 * 4);
+    while(1) {
+        led=!led;
+        Thread::wait(500);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Mar 06 17:07:28 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/5e5da4a5990b
\ No newline at end of file