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:
17:6c9b57c14868
Parent:
16:8b1dbf4cce4e
Child:
18:21ef26402365
--- a/MODSERIAL.h	Sat Feb 12 08:59:03 2011 +0000
+++ b/MODSERIAL.h	Tue Mar 08 01:42:25 2011 +0000
@@ -820,6 +820,8 @@
     
 #ifdef MODDMA_H
 
+    MODDMA_Config *config;
+    
     /**
      * Set the "void pointer" moddma_p to be a pointer to a
      * MODDMA controller class instance. Used to manage the
@@ -855,7 +857,7 @@
             case 3: conn = MODDMA::UART3_Tx; break;
         }
         
-        MODDMA_Config *config = new MODDMA_Config;
+        config = new MODDMA_Config;
         config
          ->channelNum    ( (MODDMA::CHANNELS)(dmaSendChannel & 0x7) )
          ->srcMemAddr    ( (uint32_t) buffer )
@@ -867,7 +869,7 @@
         ; // config end
         
         // Setup the configuration.
-        if (dma->Setup(config) != MODDMA::Ok) {
+        if (dma->Setup(config) == 0) { 
             return -1;
         }
         
@@ -920,6 +922,7 @@
         if (dma->irqType() == MODDMA::ErrIrq) dma->clearErrIrq();
         dmaSendChannel = -1;
         _isrDmaSendComplete.call();
+        delete(config);
     }
     
 #endif // MODDMA_H