CDMS code for testing sbc

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of CDMS_CODE by shubham c

Revision:
215:6848a51af734
Parent:
210:f4acf895b598
--- a/main.cpp	Sat Jul 02 15:28:21 2016 +0000
+++ b/main.cpp	Sun Jul 03 09:33:33 2016 +0000
@@ -1,7 +1,4 @@
-
 // TESTING PUSH PULL IN MAIN CPP
-
-
 #include "mbed.h"
 
 #define DEBUG 1
@@ -15,18 +12,18 @@
 #include "pinconfig.h"
 #include "DefinitionsAndGlobals.h"
 #include "crc.h"
+#include "cdms_rtc.h"
+#include "cdms_sd.h"
 #include "i2c.h"
 #include "COM_SND_TM_functions.h"
 #include "COM_SND_TM.h"
-#include "cdms_rtc.h"
-#include "cdms_sd.h"
 #include "common_functions.h"
 #include "RESET_functions.h"
 #include "CDMS_HK.h"
 #include "OBSRS.h"
 #include "adf.h"
 #include "COM_RCV_TC.h"
-//#include "Flash.h"
+#include "Flash.h"
 #include "FMS_all.h"
 #include "CDMS_PL.h"
 #include "COM_MNG_TMTC.h"
@@ -36,6 +33,8 @@
 #include "ThreadsAndFunctions.h"
 #include "TEST_PL.h"
 
+void CDMS_INIT();
+
 #define PL_TC(tm_ptr){\
     Base_tc *beacon_tc = new Short_tc;\
     beacon_tc->next_TC = NULL;\
@@ -84,108 +83,112 @@
                             transmit_adf;\
                             gPC.puts("exit_adf\r\n");\
 }
-//void set_sig(){gSCIENCE_THREAD->signal_set(SCIENCE_SIGNAL);}
+
+void CDMS_INIT()
+{
+    CDMS_INIT_STATUS = 1;
+    
+    spi.format(8,0);
+    spi.frequency(1000000);
+
+    cs_sd = 1;
+    gCS_RTC = 1;
+    gCS_ADF = 1;
+
+    FCTN_CDMS_INIT_RTC();
+    FCTN_CDMS_SD_INIT();
+    
+}
+
 int main()
 {
-    
-    CDMS_I2C_GPIO = 0; 
-    PL_I2C_GPIO = 0; 
-    
-    //gLEDR = 1;
-    
+
+    CDMS_I2C_GPIO = 0;
+    PL_I2C_GPIO = 0;
+
     // ******************INITIALISATIONS START******************
-    // COM RX
-    
+
     RX1M.baud(1200);
     gRX_HEAD_DATA_NODE = new COM_RX_DATA_NODE;
     gRX_HEAD_DATA_NODE->next_node = NULL;
     gRX_CURRENT_DATA_NODE = gRX_HEAD_DATA_NODE;
     gRX_COUNT = 0;
-//    gRX_CURRENT_PTR = gRX_CURRENT_DATA_NODE->values;
+    //gRX_CURRENT_PTR = gRX_CURRENT_DATA_NODE->values;
     RX1M.attach(&rx_read, Serial::RxIrq);
-    
+
     // DEBUG
     //gPC.puts("welcome to mng_tm_tc\r\n");
     gPC.baud(115200);//changed for bypassing COM
-    
-    // COMMON SPI
-    spi.format(8,0);
-    spi.frequency(1000000);
+
 
-    // SD CARD
-    cs_sd = 1;
-    gCS_RTC = 1;
-    gCS_ADF = 1;
     
-    FCTN_CDMS_INIT_RTC();/* rtc initialization*/
-    FCTN_CDMS_SD_INIT();/* sd card initialization*/
-    
-    
+
+
     uint8_t test[512] = {0};
     disk_write(test,7000); //to be used only just before launch
-    
-    #if DEBUG
+
+#if DEBUG
     gPC.puts("welcome to mng_tmtc\r\n");
-    #endif
-    
-    
-    
+#endif
+
+
+
     // COM_MNG_TMTC THREAD
     gCOM_MNG_TMTC_THREAD = new Thread(COM_MNG_TMTC_FUN);
     gCOM_MNG_TMTC_THREAD->set_priority(osPriorityHigh);
-    #if DEBUG
+#if DEBUG
     gPC.puts("allocating threads\r\n");
-    #endif
+#endif
     gSCIENCE_THREAD = new Thread(SCIENCE_FUN);
-   // gPC.puts("step one complete\r\n");
+    // gPC.puts("step one complete\r\n");
     gSCIENCE_THREAD->set_priority(osPriorityAboveNormal);
-    #if DEBUG
+#if DEBUG
     gPC.puts("competed allocating threads\r\n");
-    #endif
-    
-    
+#endif
+
+
     master.frequency(400000);
     PL_wo_dma = new RtosTimer(payload_isr_fun_dma, osTimerPeriodic,(void * )NULL);
     //PL_wo_dma->start(6000);//
     gSCIENCE_THREAD->signal_set(SCIENCE_SIGNAL);
-    
-    
-    
-    
+
+
+
+
     /*gPC.printf("PL_TC sending\r\n");
-    
+
     Base_tm *tm_ptr = new Short_tm;
     OBSRS_TC(tm_ptr);
-    
+
     gPC.printf("PL_TC sent");
     */
     // *******************INITIALISATIONS END********************
-    
+
     //RtosTimer gCDMS_HK_TIMER(FCTN_CDMS_HK_MAIN, osTimerPeriodic);
     //gCDMS_HK_TIMER.start(5000);
-    
+
     /*starting the thread with signal*/
     //set_sig();
     //payload_isr_fun();
-    
+
     /*Calculating Stack used*/
-    
+
     int state;
-    /*while (true) { 
-    Thread::wait(500); 
-    state = gSCIENCE_THREAD->get_state(); 
-    //gPC.printf("Thread state %d\r\n", state); 
-    if(state == Thread::Inactive) 
+    /*while (true) {
+    Thread::wait(500);
+    state = gSCIENCE_THREAD->get_state();
+    //gPC.printf("Thread state %d\r\n", state);
+    if(state == Thread::Inactive)
     {delete gSCIENCE_THREAD;
     break;}
     }*/
-    
-    
-    
-    while(true){
+
+
+
+    while(true) {
         Thread::wait(osWaitForever);
         //state = gCOM_MNG_TMTC_THREAD->get_state() + '0';
-         gLEDG = !gLEDG;
-        //gPC.putc(state); 
+        gLEDG = !gLEDG;
+        //gPC.putc(state);
     }
 }
\ No newline at end of file