A USB to UART bridge

Dependencies:   USBDevice BufferedSerial mbed

Revision:
5:10fccccbbb11
Parent:
4:9c038f12d460
--- a/main.cpp	Thu Jul 24 07:18:44 2014 +0000
+++ b/main.cpp	Fri Mar 04 14:00:51 2016 +0000
@@ -6,7 +6,7 @@
 #include "USBSerial.h"
 #include "BufferedSerial.h"
 
-BufferedSerial uart(USBTX, USBRX);
+BufferedSerial uart(P0_19, P0_18, 512);
 USBSerial pc;
 DigitalOut led1(LED1);
 DigitalOut led2(LED2);
@@ -18,6 +18,19 @@
 volatile bool txflag = false;
 
 
+#ifdef TARGET_LPC11UXX
+#include "LPC11Uxx.h"
+void enable_hardware_flow_control()
+{
+    LPC_IOCON->PIO0_17 = 0x01 | (0x1 << 3);     // RTS, 
+    LPC_IOCON->PIO0_7  = 0x01 | (0x1 << 3);     // CTS, pull-down
+    
+    // enable auto RTS and CTS
+    LPC_USART->MCR = (1 << 6) | (1 << 7);
+}
+#endif
+
+
 void indicate()
 {
     if (rxflag) {
@@ -54,8 +67,13 @@
     led1 = 0;
 }
 
+
 int main()
 {
+#ifdef TARGET_LPC11UXX
+    enable_hardware_flow_control();
+#endif
+    
     pc.attach(settings_changed);
     ticker.attach_us(indicate, 500);