test codes to test DMA features

Dependencies:   mDMA mbed

Revision:
1:5b946b818a29
Parent:
0:9b2f77afaacd
--- a/main.cpp	Mon Mar 09 21:47:50 2015 +0000
+++ b/main.cpp	Tue Mar 10 22:31:59 2015 +0000
@@ -3,25 +3,8 @@
 M2P : demenstrate while DMA-UART working, LED swtich is also working 
 P2M : demenstrate m2m, m2p, p2m, could work together ; keep sending 
 P2P
- 
-Do we need constructor?
-Select which ever free or which ever not declared?
-How to put comments?
-
-
-Done 1. make init struct generic -- Done
-2. make trigger type generic .-- Done
-3. support pass method callback -- no solution 
-4. read_adc -- Done
-5. PC app to received data from uart
-6. start ADC transfer rate
-7. trigger on Timer 
-8. Add assert --- Done
-9. Destructor - Done 
-10. add space/ comments  
 */
 
-// disassembler memcpy
 #include "mbed.h"
 #include "dma.h"
 
@@ -168,8 +151,6 @@
 
     
 #if test_attach
-
-        
     pc.printf("start to test mehtod attach function now!\r\n");
         
     char src2[] = "this  is for test_attach test";
@@ -195,13 +176,13 @@
     /* test the DMA M2M, copy data from src to dest, and then print out the dest mem data */
 
     pc.printf("start to test DMA M2M test now!\r\n");   
-     // wait(1);                
+                
     size_t size = sizeof(src);
-    char *dst1  = (char *) malloc(size);
-        
+    char *dst1  = (char *) malloc(size);        
     char *dst2  = (char *) malloc(size);
     memset(dst1, '\0', size+1);
     memset(dst2, '\0', size+1);
+    
     t.start();
     memcpy(dst1,src,size);
     t.stop();
@@ -295,9 +276,6 @@
     dmaLLI.attach_Err(IRQ_err);
 
     dmaLLI.next((uint32_t)src_LLI, (uint32_t)&(LPC_UART0->THR), sizeof(src_LLI));
-    // dmaLLI.next((uint32_t)src_LLI, (uint32_t)dst_LLI, 7);
-    //  DMA dmaLLI2(3);
-    //  dmaLLI2.next((uint32_t)src_LLI, (uint32_t)dst_LLI, 7);
     dmaLLI.start(sizeof(src_dma));
     dmaLLI.wait();
     while(1);
@@ -418,14 +396,7 @@
     {
         LPC_ADC->ADCR |= 1 << 24;// start the conversion now
         dma4.start(1);
-    
-    /*      
-            data= float(dst3[0]>>4 & 0xfff); // Only bit4-bit16 contains the valid ADC data
-              raw_data= (unsigned int )dst3[0] &0x7fffffff;
-              pc.printf("The ADC data of raw data is: %d\r\n", raw_data);
-              pc.printf("The ADC data of DMA is: %d\r\n", data);
-        */  
-          wait (3);
+        wait (3);
     }
             
 
@@ -434,7 +405,6 @@
         
         
 
-
 #if test_all
         
     DMA dma1 (1) ; 
@@ -448,9 +418,6 @@
     dma1.attach_TC(led_switchon_m2m) ;
     dma1.attach_Err (IRQ_err);
     
-
-
-   // char src2[] = "This message was transmitted via UART DMA from memor";
         
     size_t size2 = sizeof (src);
     pc.printf("the size is %d",size2);
@@ -652,4 +619,4 @@
     // Stop conversion
     LPC_ADC->ADCR &= ~(1 << 24);
     return (data >> 4) & 0xfff; // 12 bit
-    }
+}