Alexandre Lemay / Mbed 2 deprecated APP1_s5_A17

Dependencies:   mbed MMA8452

Revision:
7:b1b4db3eedb4
Child:
9:b9ac1d914762
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CommUART.h	Tue Sep 05 09:50:38 2017 +0000
@@ -0,0 +1,63 @@
+#ifndef COMMUART_H
+#define COMMUART_H
+
+
+#include "mbed.h"
+#include "LPC17xx.h"
+
+class CommUART3
+{
+public:
+    CommUART3()
+    {
+        // Power 
+        LPC_SC->PCONP |=  (1 << 25) ;//0x400F C0C4  -> PCUART3
+        // Peripheral clock selection -> CCLK
+        
+        // DLab enable divide latch
+        LPC_UART3->LCR |= (1 << 7);
+        
+        // MSB of baud rate divisor
+        LPC_UART3->DLM = 0x2;
+        // MLB of baud rate divisor
+        LPC_UART3->DLL = 0x71;
+        
+        // want 8-bit characters
+        LPC_UART3->LCR = 3;
+        
+        // Enable FIFO
+        LPC_UART3->FCR = 1;
+        
+        // PINSEL0 1:0 : mode p9 -> 
+        LPC_PINCON->PINSEL0 &= ~3;
+        LPC_PINCON->PINSEL0 |= 2;
+        LPC_SC->PCLKSEL1 &=  ~ (3 << 18  ) ; // clear the bits 18-19
+        LPC_SC->PCLKSEL1 |=  1 << 18 ;//0x400F C1AC -> PCLK_UART3 =01
+    
+    }
+    
+    void write(char ch)
+    {
+        LPC_UART3->TER = 0x80;
+        Serial pc(USBTX, USBRX); 
+        pc.printf("%c", ch);
+        LPC_UART3->THR = ch;
+    }
+    void write(char* ch, int length, char* unused, int unused2)
+    {
+        Serial pc(USBTX, USBRX); 
+        pc.printf("rip");
+        for(int i = 0 ; i < length ; i ++)
+        {
+            write(ch[i]);
+        } 
+    }
+    
+
+private:    
+};
+
+
+
+
+#endif
\ No newline at end of file