SPI slave DMA-read program for FRDMKL46Z, verified, working

Dependencies:   SimpleDMA mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
shreeshas95
Date:
Tue Sep 27 10:39:48 2016 +0000
Parent:
3:e59d61aac1e1
Commit message:
Simple test program for spi-DMA

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r e59d61aac1e1 -r 33fc4fec3087 main.cpp
--- a/main.cpp	Fri Apr 22 17:58:23 2016 +0000
+++ b/main.cpp	Tue Sep 27 10:39:48 2016 +0000
@@ -11,7 +11,7 @@
 
 dmaSPISlave spi(PAY_SPI_MOSI, PAY_SPI_MISO, PAY_SPI_CLK, PAY_SPI_CS);
 RawSerial pc(USBTX, USBRX);
-//DigitalOut ledg(LED_GREEN);
+DigitalOut ledg(LED_GREEN);
 //DigitalOut ledr(LED_RED);
 
 bool flag = false;
@@ -19,9 +19,6 @@
 void do_this(void){
     flag = true;
 }
-void do_this2(void){
-    flag = true;
-}
 
 int main(){
 //    ledr = 1;
@@ -38,9 +35,9 @@
     spi.bulkRead_init(buffer, PAYLOAD_LENGTH, &do_this);
 //    start dma read
     spi.bulkRead_start();
-    int count = 0;
     
     while(true){
+
 //        int i = 0;
 //        while(i < PAYLOAD_LENGTH){
 //            if(spi.receive()){
@@ -55,29 +52,11 @@
 
         
         if(flag){
-            count++;
             flag = false;
-//            ledg = !ledg;
-
-//            for(int i = 0 ; i < PAYLOAD_LENGTH ; ++i){
-//                pc.printf("%02x ", buffer[i]);
-//            }
-            pc.printf("DATA RECEIVED\r\n");
             
 //            start dma again after handling the data
-            if(count == 3){
-                count = 0;
-                spi.bulkRead_end();
-                pc.printf("tried END\r\n");
-                wait(1);
-                pc.printf("restarting the procedure\r\n");
-                spi.bulkRead_restart();
-                spi.bulkRead_start();
-            }
-            else{
-                spi.bulkRead_start();
-            }
+            spi.bulkRead_start();
+            ledg = !ledg;
         }
-    }
-    
+    }    
 }
\ No newline at end of file