TI's MQTT Demo with freertos CM4F

Dependencies:   mbed

Revision:
0:1e7b5dd9edb4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cli_uart.cpp	Thu Sep 03 14:07:01 2015 +0000
@@ -0,0 +1,63 @@
+
+#include "mbed.h"
+#include "myBoardInit.h"
+#include "cli_uart.h"
+#include "osi.h"
+
+OsiLockObj_t    g_printLock;
+#if (THIS_BOARD == Seeed_Arch_Max)
+Serial uart(PC_6, PC_7);
+//Serial uart(USBTX, USBRX);
+#else
+Serial uart(p37, p31);
+#endif
+
+
+
+int Uart_Write(unsigned char *inBuff)
+{
+    uint16_t ret, ecount, usLength = strlen((const char *)inBuff);
+    ecount = 0;
+    ret = 0;
+    
+    while(!(uart.writeable())){ecount++;if(ecount>3000)break;};
+
+    if(uart.writeable()) {
+
+        if(inBuff == NULL) {
+            printf("Uart Write buffer empty\r\n");
+            return -1;
+        }
+
+        RTOS_MUTEX_ACQUIRE(&g_printLock);
+        ret = usLength;
+
+        while (usLength) {
+            uart.putc(*inBuff);
+            usLength--;
+            inBuff++;
+        }
+
+        RTOS_MUTEX_RELEASE(&g_printLock);
+    } else {
+        printf("Uart Write failed [uart not writeable] now trying printf\r\n");
+        while (usLength) {
+            printf("%c",*inBuff);
+            usLength--;
+            inBuff++;
+        }
+        return -1;
+    }
+    
+    return (int)ret;
+
+}
+
+void CLI_Configure(void)
+{
+    uart.baud(115200);
+    
+    RTOS_MUTEX_CREATE(&g_printLock);
+
+}
+