http://mbed.org/cookbook/MODDMA

Dependencies:   MODDMA mbed

Revision:
0:ad229870f727
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Sep 04 19:44:37 2013 +0000
@@ -0,0 +1,62 @@
+#ifdef OLD
+#include "mbed.h"
+
+DigitalOut myled(LED1);
+
+int main() {
+    while(1) {
+        myled = 1;
+        wait(0.2);
+        myled = 0;
+        wait(0.2);
+    }
+}
+#endif
+
+#include "mbed.h"
+#include "MODDMA.h"
+ 
+DigitalOut myled(LED1);
+Serial pc(USBTX, USBRX);
+MODDMA dma;
+ 
+int main() {
+    pc.baud(115200);
+    pc.printf("Hello World\r\n");
+    
+    // Create a source buffer we are going to move.
+    char src[] = "TEST TEST TEST";
+    
+    // Create a buffer for the destination to copy to.
+    char dst[sizeof(src)];
+    
+    // Create a MODDMA configuration object.
+    MODDMA_Config *config = new MODDMA_Config;
+    
+    // Setup that configuration
+    config
+     ->channelNum    ( MODDMA::Channel_0 )
+     ->srcMemAddr    ( (uint32_t) &src )
+     ->dstMemAddr    ( (uint32_t) &dst )
+     ->transferSize  ( sizeof(src) )
+     ->transferType  ( MODDMA::m2m )     
+    ; // config end
+ 
+    // Pass the configuration to the controller
+    dma.Setup( config );
+    
+    // Tell the controller to perform the DMA operation
+    // defined by that configuration.
+    dma.Enable ( config );
+    
+    wait(1);
+    
+    pc.printf("%s\r\n", dst);
+    
+    while(1) {
+        myled = 1;
+        wait(0.2);
+        myled = 0;
+        wait(0.2);
+    }
+}
\ No newline at end of file