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:
3:0f10f536456e
Parent:
2:b936b4acbd92
Child:
4:28de979b77cf
--- a/MODSERIAL.h	Sun Nov 21 03:31:51 2010 +0000
+++ b/MODSERIAL.h	Sun Nov 21 13:58:53 2010 +0000
@@ -137,7 +137,7 @@
     //! DMA channels.
     enum dmaChannel {
           NotInUse = -1     /*!< DMA not in use */
-        , Channel0 = 0      /*!< Channel 0 */
+        , Channel0 =  0     /*!< Channel 0 */
         , Channel1          /*!< Channel 1 */
         , Channel2          /*!< Channel 2 */
         , Channel3          /*!< Channel 3 */
@@ -510,6 +510,14 @@
     void rxBufferFlush(void) { flushBuffer(RxIrq); }
     
     /**
+     * Function: dmaSend
+     *  
+     * Remove all bytes from the RX buffer.
+     * @ingroup API
+     */
+    int dmaSend(char *buffer, int length, dmaChannel q = Channel7);
+    
+    /**
      * Function: getcNb
      *
      * Like getc() but is non-blocking. If no bytes are in the RX buffer this
@@ -606,6 +614,15 @@
     int scanf(const char* format, ...);
     #endif
     
+    /**
+     * DMA channel in use.
+     * @ingroup INTERNALS
+     */
+    int dmaInUse[2];
+    
+    void isr_rx_dma(void);
+    void isr_tx_dma(void);
+    
 protected:
 
     /**
@@ -663,12 +680,6 @@
     volatile int   buffer_overflow[2];
     
     /**
-     * DMA channel in use.
-     * @ingroup INTERNALS
-     */
-    volatile int dmaInUse[2];
-    
-    /**
      * Callback system.
      * @ingroup INTERNALS
      */
@@ -756,6 +767,40 @@
      * @ingroup INTERNALS
      */
     int upSizeBuffer(int size, IrqType type, bool memory_check); 
+    
+    /** 
+     * Function: this_reset
+     * @see DMA.cpp
+     * @ingroup INTERNALS
+     */
+    void this_reset(void);
+
+    /** 
+     * Function: dmaSetup
+     * @see DMA.cpp
+     * @ingroup INTERNALS
+     */
+    LPC_GPDMACH_TypeDef * dmaSetup(dmaChannel q);
+
+    /** 
+     * Function: dmaSelectChannel
+     * @see DMA.cpp
+     * @ingroup INTERNALS
+     */
+    LPC_GPDMACH_TypeDef * dmaSelectChannel(dmaChannel q = Channel7) {
+        switch (q) {
+            case Channel0: return LPC_GPDMACH0;
+            case Channel1: return LPC_GPDMACH1;
+            case Channel2: return LPC_GPDMACH2;
+            case Channel3: return LPC_GPDMACH3;
+            case Channel4: return LPC_GPDMACH4;
+            case Channel5: return LPC_GPDMACH5;
+            case Channel6: return LPC_GPDMACH6;
+            case Channel7: return LPC_GPDMACH7;
+        }
+        return (LPC_GPDMACH_TypeDef *)NULL;
+    }
+    
 };
 
 }; // namespace AjK ends