Simple USBSerial test available, _getc test + LED

Dependencies:   USBDevice mbed

Files at this revision

API Documentation at this revision

Comitter:
Bongjun
Date:
Wed Jun 25 02:25:16 2014 +0000
Commit message:
simple USBSerial Example; getc, available test

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 1ec32b38f724 USBDevice.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDevice.lib	Wed Jun 25 02:25:16 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/USBDevice/#0c6524151939
diff -r 000000000000 -r 1ec32b38f724 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Jun 25 02:25:16 2014 +0000
@@ -0,0 +1,38 @@
+#include "mbed.h"
+#include "USBSerial.h"
+
+DigitalOut myled1(LED1);
+DigitalOut myled2(LED2);
+DigitalOut myled3(LED3);
+
+//Virtual serial port over USB
+USBSerial serial;
+Serial pc(USBTX, USBRX);
+
+int main()
+{
+    uint8_t buf[1];
+    while(1) {
+//        pc.printf("I am a PC serial port\r\n");
+        serial.printf("I am a virtual serial port\r\n");
+
+        //if data is exist
+        if (serial.available()) {
+            buf[0] = serial._getc();
+            serial.printf("recv char is 0x%.2x\r\n", buf[0]);
+        }
+
+        myled1 = 1;
+        wait(0.2);
+        myled1 = 0;
+        wait(0.2);
+        myled2 = 1;
+        wait(0.2);
+        myled2 = 0;
+        wait(0.2);
+        myled3 = 1;
+        wait(0.2);
+        myled3 = 0;
+        wait(0.2);
+    }
+}
diff -r 000000000000 -r 1ec32b38f724 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Jun 25 02:25:16 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/024bf7f99721
\ No newline at end of file