DMA issue to be tested

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of CDMS_CODE by shubham c

Revision:
173:f81ded27423d
Parent:
172:c508bbf7e89a
Child:
174:44a6d7c7674c
diff -r c508bbf7e89a -r f81ded27423d ThreadsAndFunctions.h
--- a/ThreadsAndFunctions.h	Thu Apr 21 12:45:12 2016 +0000
+++ b/ThreadsAndFunctions.h	Fri Apr 22 09:52:38 2016 +0000
@@ -1,3 +1,37 @@
+//Science Thread
+//SPI ISR
+void payload_isr_fun(){
+    gSCIENCE_THREAD->signal_set(SCIENCE_SIGNAL);
+}
+
+#define Init_gPAY_SPI{\
+    gPAY_SPI.frequency(1000000);\
+    gPAY_SPI.format(8,0);\
+    gPAY_SPI.bulkRead_init(gPAYLOAD_BUFFER, PAYLOAD_BUFFER_LENGTH, &payload_isr_fun);\
+    gPAY_SPI.bulkRead_start();\
+    }
+
+void SCIENCE_FUN(void const *args){
+    
+    // initialisation of payload spi
+    gPAY_SPI.frequency(1000000);
+    gPAY_SPI.format(8,0);
+    gPAY_SPI.bulkRead_init(gPAYLOAD_BUFFER, PAYLOAD_BUFFER_LENGTH, &payload_isr_fun);
+    gPAY_SPI.bulkRead_start();
+    gPAY_SPI.bulkRead_end();
+    Init_gPAY_SPI;
+    
+    while(true){
+        gPC.puts("entering sci\r\n");
+        gSCIENCE_THREAD->signal_wait(SCIENCE_SIGNAL);
+        gPC.puts("sig_set\r\n");
+        srp(gPAYLOAD_BUFFER);
+        gPC.puts("exit_srp\r\n");
+        gPAY_SPI.bulkRead_start();
+    }
+}
+
+//COM THREAD
 // UART ISR
 void rx_read(){
     gRX_CURRENT_DATA_NODE->values[gRX_COUNT] = RX1M.getc();
@@ -163,7 +197,7 @@
                             reset_all;
                             gFLAGS = gFLAGS & (~COM_SESSION_VALIDITY);
                             // PENDING : ENABLE THREADS
-                            gPAY_SPI.bulkRead_start();
+                            Init_gPAY_SPI;
                             gSESSION_TIMEOUT.detach();
                             gFLAGS = gFLAGS & (~COM_SESSION_FLAG);
                             // WARNING: clear COM_MNG_TMTC ?
@@ -216,7 +250,7 @@
                 gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);
                 reset_all;
                 // PENDING : ENABLE THREADS
-                gPAY_SPI.bulkRead_start();
+                Init_gPAY_SPI;
                 gSESSION_TIMEOUT.detach();
                 gFLAGS = gFLAGS & (~COM_SESSION_FLAG);
             }
@@ -256,7 +290,7 @@
             /*gPC.puts("session timeout: resetting in main\r\n");*/
             COM_POWER_OFF_TX;
             /*PENDING : ENABLE THREADS*/
-            gPAY_SPI.bulkRead_start();
+            
             gSESSION_TIMEOUT.detach();
             gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);
             gFLAGS = gFLAGS & (~COM_SESSION_FLAG);
@@ -268,35 +302,9 @@
             COM_POWER_OFF_TX;
             reset_all;
             // PENDING : ENABLE THREADS
-            gPAY_SPI.bulkRead_start();
+            Init_gPAY_SPI;
             gSESSION_TIMEOUT.detach();
             gFLAGS = gFLAGS & (~COM_SESSION_FLAG);
         }
     }
-}
-
-void payload_isr_fun(){
-    gSCIENCE_THREAD->signal_set(SCIENCE_SIGNAL);
-}
-
-void SCIENCE_FUN(void const *args){
-    
-    // initialisation of payload spi
-    gPAY_SPI.frequency(1000000);
-    gPAY_SPI.format(8,0);
-    gPAY_SPI.bulkRead_init(gPAYLOAD_BUFFER, PAYLOAD_BUFFER_LENGTH, &payload_isr_fun);
-    gPAY_SPI.bulkRead_start();
-    gPAY_SPI.bulkRead_end();
-    gPAY_SPI.frequency(1000000);
-    gPAY_SPI.format(8,0);
-    gPAY_SPI.bulkRead_init(gPAYLOAD_BUFFER, PAYLOAD_BUFFER_LENGTH, &payload_isr_fun);
-    gPAY_SPI.bulkRead_start();
-    while(true){
-        gPC.puts("entering sci\r\n");
-        gSCIENCE_THREAD->signal_wait(SCIENCE_SIGNAL);
-        gPC.puts("sig_set\r\n");
-        srp(gPAYLOAD_BUFFER);
-        gPC.puts("exit_srp\r\n");
-        gPAY_SPI.bulkRead_start();
-    }
 }
\ No newline at end of file