MODSERIAL with support for more devices

Dependents:   1D-Pong BMT-K9_encoder BMT-K9-Regelaar programma_filter ... more

Check the cookbook page for more information: https://mbed.org/cookbook/MODSERIAL

Did you add a device? Please send a pull request so we can keep everything in one library instead of many copies. In that case also send a PM, since currently mbed does not inform of new pull requests. I will then also add you to the developers of this library so you can do other changes directly.

Revision:
27:9c93ce7cb9d8
Parent:
25:ae0408ebdd68
Child:
28:76793a84f9e5
--- a/INIT.cpp	Mon Jun 10 19:06:21 2013 +0000
+++ b/INIT.cpp	Thu Jul 11 13:34:53 2013 +0000
@@ -23,29 +23,23 @@
 #include "MODSERIAL.h"
 #include "MACROS.h"
 
+    #define MODSERIAL_FCR  0x08
+    #define _FCR    *((char *)_base+MODSERIAL_FCR)
+    
+    #define MODSERIAL_FIFO_ENABLE   1
+#define MODSERIAL_FIFO_RX_RESET 2
+#define MODSERIAL_FIFO_TX_RESET 4
+
 
 namespace AjK {
 
 void
 MODSERIAL::init( int txSize, int rxSize, PinName rx )
 {
-    disableIrq();
+    NVIC_DisableIRQ(_IRQ);
+    setBase();
     
     callbackInfo.setSerial(this);
-
-#ifdef __LPC11UXX_H__
-
-    _base = LPC_USART;
-    
-#else    
-    switch( _serial.index ) {
-        case 0: _base = LPC_UART0; break;
-        case 1: _base = LPC_UART1; break;
-        case 2: _base = LPC_UART2; break;
-        case 3: _base = LPC_UART3; break;
-        default: _base = NULL;      break;
-    }
-#endif
     
     dmaSendChannel  = -1;
     moddma_p        = (void *)NULL;
@@ -71,11 +65,15 @@
         error("MODSERIAL must have a defined UART to function.");
     }
     
-    _FCR = MODSERIAL_FIFO_ENABLE | MODSERIAL_FIFO_RX_RESET | MODSERIAL_FIFO_TX_RESET;
+
+    ENABLE_FIFO;
+
+    //_FCR = MODSERIAL_FIFO_ENABLE | MODSERIAL_FIFO_RX_RESET | MODSERIAL_FIFO_TX_RESET;
     
     auto_detect_char = 0;
     
-    enableIrq();
+    NVIC_EnableIRQ(_IRQ);
 }
 
 }; // namespace AjK ends
+