MODDMA GPDMA Controller New features: transfer pins to memory buffer under periodic timer control and send double buffers to DAC

Dependents:   FirstTest WaveSim IO-dma-memmem DACDMAfuncgenlib ... more

Files at this revision

API Documentation at this revision

Comitter:
AjK
Date:
Tue Nov 23 16:04:32 2010 +0000
Parent:
4:67f327b9278e
Child:
6:40d38be4bb59
Commit message:
1.2

Changed in this revision

ChangeLog.c Show annotated file Show diff for this revision Revisions of this file
MODDMA.h Show annotated file Show diff for this revision Revisions of this file
example1.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/ChangeLog.c	Tue Nov 23 15:33:30 2010 +0000
+++ b/ChangeLog.c	Tue Nov 23 16:04:32 2010 +0000
@@ -1,5 +1,10 @@
 /* $Id:$
 
+1.2 - 23/10/2010
+
+    * Improved the IRQ callback attachment API to make 
+      easier attachments when creating configurations.
+      
 1.1 - 23/10/2010
 
     * Tidied up example1.cpp
--- a/MODDMA.h	Tue Nov 23 15:33:30 2010 +0000
+++ b/MODDMA.h	Tue Nov 23 16:04:32 2010 +0000
@@ -21,7 +21,7 @@
     
     @file          MODDMA.h 
     @purpose       Adds DMA controller and multiple transfer configurations
-    @version       1.1
+    @version       1.2
     @date          Nov 2010
     @author        Andy Kirkham    
 */
@@ -106,7 +106,58 @@
     uint32_t srcConn(void)       { return SrcConn;       }
     uint32_t dstConn(void)       { return DstConn;       }
     uint32_t dmaLLI(void)        { return DMALLI;        }
+
+    /**
+     * Attach a callback to the TC IRQ configuration.
+     *
+     * @param fptr A function pointer to call
+     * @return this
+     */
+    class MODDMA_Config * attach_tc(void (*fptr)(void)) {  
+        isrIntTCStat->attach(fptr); 
+        return this;
+    }
     
+    /**
+     * Attach a callback to the ERR IRQ configuration.
+     *
+     * @param fptr A function pointer to call
+     * @return this
+     */
+    class MODDMA_Config * attach_err(void (*fptr)(void)) {  
+        isrIntErrStat->attach(fptr);         
+        return this;
+    }
+    
+    /**
+     * Attach a callback to the TC IRQ configuration.
+     *
+     * @param tptr A template pointer to the calling object
+     * @param mptr A method pointer within the object to call.
+     * @return this
+     */
+    template<typename T>
+    class MODDMA_Config * attach_tc(T* tptr, void (T::*mptr)(void)) {  
+        if((mptr != NULL) && (tptr != NULL)) {
+            isrIntTCStat->attach(tptr, mptr);
+        }
+        return this;
+    }
+    
+    /**
+     * Attach a callback to the ERR IRQ configuration.
+     *
+     * @param tptr A template pointer to the calling object
+     * @param mptr A method pointer within the object to call.
+     * @return this
+     */
+    template<typename T>
+    class MODDMA_Config * attach_err(T* tptr, void (T::*mptr)(void)) {  
+        if((mptr != NULL) && (tptr != NULL)) {
+            isrIntErrStat->attach(tptr, mptr);
+        }
+        return this;
+    }
     FunctionPointer *isrIntTCStat;                        
     FunctionPointer *isrIntErrStat;                        
 };
@@ -483,11 +534,63 @@
     void haltAndWaitChannelComplete(CHANNELS n) { haltChannel(n); while (isActive(n)); }
     
     /**
+     * Attach a callback to the TC IRQ controller.
+     *
+     * @ingroup API
+     * @param fptr A function pointer to call
+     * @return this
+     */
+    void attach_tc(void (*fptr)(void)) {  
+        isrIntTCStat.attach(fptr);         
+    }
+    
+    /**
+     * Attach a callback to the TC IRQ controller.
+     *
+     * @ingroup API
+     * @param tptr A template pointer to the calling object
+     * @param mptr A method pointer within the object to call.
+     * @return this
+     */
+    template<typename T>
+    class MODDMA_Config * attach_tc(T* tptr, void (T::*mptr)(void)) {  
+        if((mptr != NULL) && (tptr != NULL)) {
+            isrIntTCStat.attach(tptr, mptr);         
+        }
+    }
+       
+    /**
      * The MODDMA controllers terminal count interrupt callback.
      */
     FunctionPointer isrIntTCStat;                        
     
     /**
+     * Attach a callback to the ERR IRQ controller.
+     *
+     * @ingroup API
+     * @param fptr A function pointer to call
+     * @return this
+     */
+    void attach_err(void (*fptr)(void)) {  
+        isrIntErrStat.attach(fptr);         
+    }
+    
+    /**
+     * Attach a callback to the ERR IRQ controller.
+     *
+     * @ingroup API
+     * @param tptr A template pointer to the calling object
+     * @param mptr A method pointer within the object to call.
+     * @return this
+     */
+    template<typename T>
+    class MODDMA_Config * attach_err(T* tptr, void (T::*mptr)(void)) {  
+        if((mptr != NULL) && (tptr != NULL)) {
+            isrIntErrStat.attach(tptr, mptr);         
+        }
+    }
+    
+    /**
      * The MODDMA controllers error interrupt callback.
      */
     FunctionPointer isrIntErrStat;                        
--- a/example1.cpp	Tue Nov 23 15:33:30 2010 +0000
+++ b/example1.cpp	Tue Nov 23 16:04:32 2010 +0000
@@ -22,8 +22,8 @@
     
     pc.baud(PC_BAUD);
     
-    dma.isrIntTCStat.attach(&dmaTCCallback);
-    dma.isrIntErrStat.attach(&dmaERRCallback);
+    dma.attach_tc( &dmaTCCallback );
+    dma.attach_err( &dmaERRCallback );
     
     MODDMA_Config *config = new MODDMA_Config;
     config
@@ -36,12 +36,10 @@
      ->srcConn       ( 0 )
      ->dstConn       ( MODDMA::UART0_Tx )
      ->dmaLLI        ( 0 )
+     ->attach_tc     ( &TC0_callback )
+     ->attach_err    ( &ERR0_callback )
     ; // config end
     
-    // Attach configuration callbacks if required.
-    config->isrIntTCStat->attach(&TC0_callback);
-    config->isrIntErrStat->attach(&ERR0_callback);
-    
     // Setup the configuration.
     dma.Setup(config);