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.

Files at this revision

API Documentation at this revision

Comitter:
AjK
Date:
Tue Mar 08 01:42:25 2011 +0000
Parent:
16:8b1dbf4cce4e
Child:
18:21ef26402365
Commit message:
1.17 See ChangeLog.c

Changed in this revision

ChangeLog.c Show annotated file Show diff for this revision Revisions of this file
MODSERIAL.h Show annotated file Show diff for this revision Revisions of this file
--- a/ChangeLog.c	Sat Feb 12 08:59:03 2011 +0000
+++ b/ChangeLog.c	Tue Mar 08 01:42:25 2011 +0000
@@ -1,5 +1,8 @@
 /* $Id:$
 
+1.17   08/Mar/2011
+       Fixed a memory leak in the DMA code.
+       
 1.16 - 12 Feb 2011
     
     * Missed one, doh!
--- 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