USB Serial application

Fork of USBSerial_HelloWorld by Samuel Mokrani

Revision:
10:41552d038a69
Parent:
9:d88699a0905a
Child:
11:b3f2a8bdac4d
diff -r d88699a0905a -r 41552d038a69 main.cpp
--- a/main.cpp	Fri Mar 01 13:33:02 2013 +0000
+++ b/main.cpp	Tue Jan 10 20:42:26 2017 +0000
@@ -1,14 +1,26 @@
 #include "mbed.h"
+
 #include "USBSerial.h"
- 
-//Virtual serial port over USB
-USBSerial serial;
- 
-int main(void) {
- 
-    while(1)
-    {
-        serial.printf("I am a virtual serial port\r\n");
-        wait(1);
+
+DigitalOut  myled(LED1);
+void confSysClock();
+
+int main() {
+    //confSysClock();     //Configure system clock (72MHz HSE clock, 48MHz USB clock)
+    //SYSTEM CLOCK changed in stm32f4xx_hal.c
+    Serial    pc(PA_2, PA_3);  // you may substitute any buffered serial driver here
+    USBSerial usbSerial;
+    
+    while(1) {
+        
+        myled = !myled;
+        if(pc.readable()) //if there is any character to read from pc
+        {
+           usbSerial.putc(pc.getc()); //send it over to usbSerial
+        }
+        if(usbSerial.readable()) //if there is any character to read from usbSerial
+        {
+           pc.putc(usbSerial.getc()); //send it over to pc
+        }
     }
 }
\ No newline at end of file