CDMS code for testing sbc

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of CDMS_CODE by shubham c

Files at this revision

API Documentation at this revision

Comitter:
ee12b079
Date:
Tue Jul 12 10:01:32 2016 +0000
Parent:
252:9c631b2f5da8
Child:
254:22d97475ca79
Commit message:
Threads integrated, HK_counter disables in com_fun,

Changed in this revision

CDMS_HK.h Show annotated file Show diff for this revision Revisions of this file
COM_MNG_TMTC.h Show annotated file Show diff for this revision Revisions of this file
RESET_functions.h Show annotated file Show diff for this revision Revisions of this file
ThreadsAndFunctions.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/CDMS_HK.h	Tue Jul 12 05:35:21 2016 +0000
+++ b/CDMS_HK.h	Tue Jul 12 10:01:32 2016 +0000
@@ -43,9 +43,8 @@
     {
     gPC.printf("Entering HK thread");
     gHK_THREAD->signal_wait(HK_SIGNAL);
-
     gMutex.lock();
-
+    gPC.printf("HK thread signal set");
     CDMS_HK_MAIN_STATUS = 0x01;
     CDMS_HK_MAIN_COUNTER++;
 
@@ -55,7 +54,7 @@
     VERIFY_RTC();
     HANDLE_HW_FAULTS();
     FUNC_CDMS_GPIO_STATUS(); //yet to be done
-
+    gPC.printf("Checking RTCoun");
     uint8_t CDMS_quant[19];
     for(int i=0; i<16; i++) {
         CDMS_quant[i]= (uint8_t)quant_data.temp_quant[i];
@@ -63,14 +62,14 @@
     CDMS_quant[16]= (uint8_t)RSSI_volatge;
     CDMS_quant[17]= (uint8_t)quant_data.CDMS_temp_quant;
     minMaxHkData();
-
+    gPC.printf("here1");
     uint64_t time = FCTN_CDMS_RD_RTC();             //Reading Time from RTC
     gPC.printf("0x%08X \n",time);
     time = time>>7;
     uint32_t HK_time = (uint32_t)time;
     for(int i = 0; i<4; i++)
         CDMS_HEALTH_DATA[i] = HK_time >> i;
-
+    gPC.printf("here2");
     // Here: Have to FIT flash data.
     for(int i = 0; i<19; i++)                       //Collecting Data from Temp sensors
         CDMS_HEALTH_DATA[i+24] = CDMS_quant[i];
@@ -84,7 +83,7 @@
     CDMS_HK_FRAME[1] = FSC_CURRENT[4]+1;
     CDMS_HK_FRAME[2] = (FSC_CURRENT[4]+1) >> 8;
     CDMS_HK_FRAME[3] = (FSC_CURRENT[4]+1) >> 16;
-
+    gPC.printf("here3");
     for(int i = 0; i<128; i++)                       /*Adding actual CDMS Health data to TM frame*/
         CDMS_HK_FRAME[4+i] = CDMS_HEALTH_DATA[i];
 
@@ -307,6 +306,7 @@
         gCS_RTC=0;
         spi.write(0x0F);
         if(spi.write(0x00) & 0x04 == 0x04) {
+            
             RTC_STATUS = 0x00;
             RESET_RTC();
             RTC_FAULTCOUNT++;
--- a/COM_MNG_TMTC.h	Tue Jul 12 05:35:21 2016 +0000
+++ b/COM_MNG_TMTC.h	Tue Jul 12 10:01:32 2016 +0000
@@ -1322,7 +1322,7 @@
                             /*SEND call sign, ACK_L1, NON OBSRS TM TO GS*/\
                             snd_tm.head_pointer(tm_ptr_head);\
                             gPC.puts("enter_adf\r\n");\
-                            transmit_adf;\
+                            /*transmit_adf;*/\
                             gPC.puts("exit_adf\r\n");\ 
                             /*DELETE THE TM AFTER USE*/\
                             tm_ptr = tm_ptr_head;\
@@ -1351,7 +1351,7 @@
                             /*read_TC(current_TC);*/\
                             execute_OBSRS_TC(current_TC);\
                             gPC.puts("en_adf");\
-                            transmit_adf;\
+                            /*transmit_adf;*/\
                             gPC.puts("ex_adf");\
                             uint8_t tempExec = TC_STATE_SUCCESSFULLY_EXECUTED;\
                             PUTexec_status(current_TC, tempExec);\
--- a/RESET_functions.h	Tue Jul 12 05:35:21 2016 +0000
+++ b/RESET_functions.h	Tue Jul 12 10:01:32 2016 +0000
@@ -10,18 +10,18 @@
 }
 
 void RESET_RTC()
-{
+{   
     gCS_RTC=1;
     gCS_RTC=0;
     spi.write(0x81); //register address with write flag
     spi.write(0x80);//enabling stop bit in the seconds register
- 
+
     gCS_RTC=1;
     gCS_RTC=0;
     spi.write(0x81);
     spi.write(0x00);//disabling the stop bit to restart the oscillator 
 
-    wait(4000);
+    wait_ms(4000);
     //clearing the halt bit 
     gCS_RTC=1;
     gCS_RTC=0;
--- a/ThreadsAndFunctions.h	Tue Jul 12 05:35:21 2016 +0000
+++ b/ThreadsAndFunctions.h	Tue Jul 12 10:01:32 2016 +0000
@@ -117,7 +117,7 @@
             gFLAGS = gFLAGS & (~UART_INT_FLAG);
             if( !(gFLAGS & COM_SESSION_FLAG) ){
                 // PENDING : DISABLE THREADS
-                HK_counter->stop();\
+                /*HK_counter->stop();*/
                 gPAY_SPI->bulkRead_pause();
                 gFLAGS = gFLAGS | COM_SESSION_FLAG;
                 gSESSION_TIMEOUT.attach(&after_session, SESSION_TIME_LIMIT);
@@ -160,7 +160,7 @@
             gFLAGS = gFLAGS & (~COM_RX_FLAG);
             
             //Mutex
-            gMutex.lock();
+            /*gMutex.lock();*/
             
             if( gTOTAL_VALID_TC > 0 ){
                 /*gPC.printf("valid TC rx: %u\r\n", gTOTAL_VALID_TC);*/
@@ -205,7 +205,7 @@
                             reset_all;
                             gFLAGS = gFLAGS & (~COM_SESSION_VALIDITY);
                             // PENDING : ENABLE THREADS
-                            HK_counter->start(10000);\
+                            HK_counter->start(10000);
                             gPAY_SPI->bulkRead_resume(&payload_isr_fun);
                             gSESSION_TIMEOUT.detach();
                             gFLAGS = gFLAGS & (~COM_SESSION_FLAG);
@@ -318,6 +318,6 @@
             gSESSION_TIMEOUT.detach();
             gFLAGS = gFLAGS & (~COM_SESSION_FLAG);
         }
-        gMutex.unlock();
+        /*gMutex.unlock();*/
     }
 }
\ No newline at end of file
--- a/main.cpp	Tue Jul 12 05:35:21 2016 +0000
+++ b/main.cpp	Tue Jul 12 10:01:32 2016 +0000
@@ -110,8 +110,8 @@
     gCS_RTC = 1;
     gCS_ADF = 1;
     
-    FCTN_CDMS_INIT_RTC();/* rtc initialization*/
-    //FCTN_CDMS_SD_INIT();/* sd card initialization*/
+    //FCTN_CDMS_INIT_RTC();/* rtc initialization*/
+    FCTN_CDMS_SD_INIT();/* sd card initialization*/
     
     
     //uint8_t test[512] = {0};
@@ -143,8 +143,10 @@
     
     master.frequency(400000);
     
-    /*HK_counter = new RtosTimer(hk_isr, osTimerPeriodic,(void * )NULL);
-    HK_counter->start(10000);*/
+    HK_counter = new RtosTimer(hk_isr, osTimerPeriodic,(void * )NULL);
+    HK_counter->start(10000);
+    
+    gPC.printf("HK counter started");
     
     /*PL_wo_dma = new RtosTimer(payload_isr_fun_dma, osTimerPeriodic,(void * )NULL);
     PL_wo_dma->start(6000);*///