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

Revision:
12:1dfee7208043
Parent:
11:19009be5a0e7
Child:
16:cb10aec6feb1
--- a/SETUP.cpp	Sun Mar 13 12:46:55 2011 +0000
+++ b/SETUP.cpp	Sun Mar 13 23:28:21 2011 +0000
@@ -108,6 +108,38 @@
                 | CxControl_I();
             break;
             
+        // GPIO to memory
+        case g2m:
+            // Assign GPIO source address
+            pChannel->DMACCSrcAddr = config->srcMemAddr();
+            // Assign memory destination address
+            pChannel->DMACCDestAddr = config->dstMemAddr();
+            pChannel->DMACCControl
+                = CxControl_TransferSize((uint32_t)config->transferSize()) 
+                | CxControl_SBSize((uint32_t)LUTPerBurst(config->srcConn())) 
+                | CxControl_DBSize((uint32_t)LUTPerBurst(config->srcConn())) 
+                | CxControl_SWidth((uint32_t)LUTPerWid(config->srcConn())) 
+                | CxControl_DWidth((uint32_t)LUTPerWid(config->srcConn())) 
+                | CxControl_DI() 
+                | CxControl_I();
+            break;
+            
+        // Memory to GPIO
+        case m2g:
+            // Assign physical source
+            pChannel->DMACCSrcAddr = config->srcMemAddr();
+            // Assign peripheral destination address
+            pChannel->DMACCDestAddr = config->dstMemAddr();
+            pChannel->DMACCControl
+                = CxControl_TransferSize((uint32_t)config->transferSize()) 
+                | CxControl_SBSize((uint32_t)LUTPerBurst(config->dstConn())) 
+                | CxControl_DBSize((uint32_t)LUTPerBurst(config->dstConn())) 
+                | CxControl_SWidth((uint32_t)LUTPerWid(config->dstConn())) 
+                | CxControl_DWidth((uint32_t)LUTPerWid(config->dstConn())) 
+                | CxControl_SI() 
+                | CxControl_I();
+            break;
+            
         // Do not support any more transfer type, return ERROR
         default:
             return 0;
@@ -121,7 +153,7 @@
         LPC_SC->RESERVED9 &= ~(1 << (config->srcConn() - 8));
     }
 
-    // Re-Configure DMA Request Select for Destination peripheral
+    // Re-Configure DMA Request Select for destination peripheral
     if (config->dstConn() > 15) {
         LPC_SC->RESERVED9 |= (1 << (config->dstConn() - 16));
     } 
@@ -137,11 +169,21 @@
     uint32_t tmp1 = config->srcConn(); tmp1 = ((tmp1 > 15) ? (tmp1 - 8) : tmp1);
     uint32_t tmp2 = config->dstConn(); tmp2 = ((tmp2 > 15) ? (tmp2 - 8) : tmp2);
 
+    if (config->dmacSync()) {
+        uint32_t tmp3 = config->dmacSync(); tmp3 = ((tmp3 > 15) ? (tmp3 - 8) : tmp3);
+        LPC_GPDMA->DMACSync |= Sync_Src( tmp3 );
+    }
+    
+    uint32_t tfer_type = (uint32_t)config->transferType();
+    if (tfer_type == g2m || tfer_type == m2g) {
+        tfer_type -= 2; // Adjust psuedo transferType to a real transferType.
+    }
+    
     // Configure DMA Channel, enable Error Counter and Terminate counter
     pChannel->DMACCConfig 
         = CxConfig_IE() 
         | CxConfig_ITC() 
-        | CxConfig_TransferType((uint32_t)config->transferType()) 
+        | CxConfig_TransferType(tfer_type) 
         | CxConfig_SrcPeripheral(tmp1) 
         | CxConfig_DestPeripheral(tmp2);