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:
Sun Jul 10 21:32:28 2016 +0000
Parent:
245:da9d1bd999da
Child:
247:d0be0773b951
Commit message:
part of HK commented, threads integrated, a bug to be solved : change all unsigned char to uint8_t

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
DefinitionsAndGlobals.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	Sun Jul 10 13:47:26 2016 +0000
+++ b/CDMS_HK.h	Sun Jul 10 21:32:28 2016 +0000
@@ -84,22 +84,22 @@
     uint16_t crc = crc16_gen(CDMS_HK_FRAME,132);      /*Adding CRC to TM frame*/
     CDMS_HK_FRAME[133] = crc;
     CDMS_HK_FRAME[132] = crc >> 8;
-
-    Convolution CDMS_HEALTH;
-    Convolution BAE_HEALTH;
-    CDMS_HEALTH.convolutionEncode(CDMS_HK_FRAME , convoluted_CDMS_HK);
-    CDMS_HEALTH.convolutionEncode(CDMS_HK_FRAME + 67, convoluted_CDMS_HK + 135);
+    
+    
+    exor(CDMS_HK_FRAME);
+    ConvObj.convolutionEncode(CDMS_HK_FRAME , convoluted_CDMS_HK);
+    ConvObj.convolutionEncode(CDMS_HK_FRAME + 67, convoluted_CDMS_HK + 135);
     interleave(convoluted_CDMS_HK ,  interleave_CDMS_HK);
     interleave(convoluted_CDMS_HK +135, interleave_CDMS_HK + 144);
-    for(int i=0; i<288; i++)
-        CDMS_HEALTH_FINAL[i] = interleave_CDMS_HK[i];
-
-    SD_WRITE(CDMS_HEALTH_FINAL,FSC_CURRENT[4]+1,4);
-    gPC.printf("\rCompleted CDMS HK\n");
-
-    /*---------------------------------- BAE HK --------------------------------------------*/
-
-
+//    for(int i=0; i<288; i++)
+//        CDMS_HEALTH_FINAL[i] = interleave_CDMS_HK[i];
+//
+//    SD_WRITE(CDMS_HEALTH_FINAL,FSC_CURRENT[4]+1,4);
+//    gPC.printf("\rCompleted CDMS HK\n");
+//
+//    /*---------------------------------- BAE HK --------------------------------------------*/
+//
+//
     BAE_HK_I2C = FCTN_I2C_READ(BAE_HK,134);
     gPC.printf("\rEntering BAE HK\n");
     if(BAE_HK_I2C == 0) {
@@ -119,15 +119,15 @@
             crc = crc16_gen(BAE_HK_FRAME,132);               /*Adding CRC to TM frame*/
             BAE_HK_FRAME[133] = crc;
             BAE_HK_FRAME[132] = crc >> 8;
-            BAE_HEALTH.convolutionEncode(BAE_HK_FRAME , convoluted_BAE_HK);
-            BAE_HEALTH.convolutionEncode(BAE_HK_FRAME + 67, convoluted_BAE_HK + 135);
-            interleave(convoluted_BAE_HK ,  interleave_BAE_HK);
-            interleave(convoluted_BAE_HK +135, interleave_BAE_HK + 144);
-            for(int i=0; i<288; i++)
-                BAE_HEALTH_FINAL[i] = interleave_BAE_HK[i];
-            SD_WRITE(BAE_HEALTH_FINAL,FSC_CURRENT[5]+1,5);
+//            BAE_HEALTH.convolutionEncode(BAE_HK_FRAME , convoluted_BAE_HK);
+//            BAE_HEALTH.convolutionEncode(BAE_HK_FRAME + 67, convoluted_BAE_HK + 135);
+//            interleave(convoluted_BAE_HK ,  interleave_BAE_HK);
+//            interleave(convoluted_BAE_HK +135, interleave_BAE_HK + 144);
+//            for(int i=0; i<288; i++)
+//                BAE_HEALTH_FINAL[i] = interleave_BAE_HK[i];
+//            SD_WRITE(BAE_HEALTH_FINAL,FSC_CURRENT[5]+1,5);
         }
-        
+//        
     } else {
         gPC.printf("\rBAE HK data not recieved through I2C\n");
         for(int i = 0; i<134; i++)
--- a/COM_MNG_TMTC.h	Sun Jul 10 13:47:26 2016 +0000
+++ b/COM_MNG_TMTC.h	Sun Jul 10 21:32:28 2016 +0000
@@ -1494,6 +1494,7 @@
         reset_all;\
         /*PENDING : ENABLE THREADS*/\
         gPAY_SPI->bulkRead_resume(&payload_isr_fun);\
+        HK_counter->start(10000);\
         gSESSION_TIMEOUT.detach();\
         gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\
         gFLAGS = gFLAGS & (~COM_SESSION_FLAG);\
--- a/DefinitionsAndGlobals.h	Sun Jul 10 13:47:26 2016 +0000
+++ b/DefinitionsAndGlobals.h	Sun Jul 10 21:32:28 2016 +0000
@@ -144,7 +144,7 @@
     #define RF_RELAY_CNTRL_BCN PTA12 
     
 //CDMS HK
-#define HK_SIGNAL 0x04
+#define HK_SIGNAL 0x05
 #define COMRX_ALIVE 0x01
 #define COMRX_DEAD 0x00
 #define DEVICE_ENABLED 0x00
--- a/ThreadsAndFunctions.h	Sun Jul 10 13:47:26 2016 +0000
+++ b/ThreadsAndFunctions.h	Sun Jul 10 21:32:28 2016 +0000
@@ -28,7 +28,7 @@
 //HK Thread(Contains HK_main() and PL_main())
 //RTOS timer calllback func
 void hk_isr(void const *args){
-    gSCIENCE_THREAD->signal_set(SCIENCE_SIGNAL);
+    gHK_THREAD->signal_set(HK_SIGNAL);
 }
 
 
@@ -114,6 +114,7 @@
             gFLAGS = gFLAGS & (~UART_INT_FLAG);
             if( !(gFLAGS & COM_SESSION_FLAG) ){
                 // PENDING : DISABLE THREADS
+                HK_counter->stop();\
                 gPAY_SPI->bulkRead_pause();
                 gFLAGS = gFLAGS | COM_SESSION_FLAG;
                 gSESSION_TIMEOUT.attach(&after_session, SESSION_TIME_LIMIT);
@@ -198,6 +199,7 @@
                             reset_all;
                             gFLAGS = gFLAGS & (~COM_SESSION_VALIDITY);
                             // PENDING : ENABLE THREADS
+                            HK_counter->start(10000);\
                             gPAY_SPI->bulkRead_resume(&payload_isr_fun);
                             gSESSION_TIMEOUT.detach();
                             gFLAGS = gFLAGS & (~COM_SESSION_FLAG);
@@ -251,6 +253,7 @@
                 gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);
                 reset_all;
                 // PENDING : ENABLE THREADS
+                HK_counter->start(10000);
                 gPAY_SPI->bulkRead_resume(&payload_isr_fun);
                 gSESSION_TIMEOUT.detach();
                 gFLAGS = gFLAGS & (~COM_SESSION_FLAG);
@@ -291,6 +294,7 @@
             /*gPC.puts("session timeout: resetting in main\r\n");*/
             COM_POWER_OFF_TX;
             /*PENDING : ENABLE THREADS*/
+            HK_counter->start(10000);
             gPAY_SPI->bulkRead_resume(&payload_isr_fun);
             gSESSION_TIMEOUT.detach();
             gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);
@@ -303,6 +307,7 @@
             COM_POWER_OFF_TX;
             reset_all;
             // PENDING : ENABLE THREADS
+            HK_counter->start(10000);
             gPAY_SPI->bulkRead_resume(&payload_isr_fun);
             gSESSION_TIMEOUT.detach();
             gFLAGS = gFLAGS & (~COM_SESSION_FLAG);
--- a/main.cpp	Sun Jul 10 13:47:26 2016 +0000
+++ b/main.cpp	Sun Jul 10 21:32:28 2016 +0000
@@ -85,28 +85,20 @@
                             transmit_adf;\
                             gPC.puts("exit_adf\r\n");\
 }
-//void set_sig(){gSCIENCE_THREAD->signal_set(SCIENCE_SIGNAL);}
+
 int main()
 {
     
     CDMS_I2C_GPIO = 0; 
     PL_I2C_GPIO = 0; 
     
-    //gLEDR = 1;
-    
-    // ******************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;
     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
@@ -118,34 +110,42 @@
     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};
-    disk_write(test,7000); //to be used only just before launch
+    //uint8_t test[512] = {0};
+    //disk_write(test,7000); //to be used only just before launch
     
     #if DEBUG
     gPC.puts("welcome to mng_tmtc\r\n");
     #endif
     
-    
+    #if DEBUG
+    gPC.puts("allocating threads\r\n");
+    #endif
     
     // COM_MNG_TMTC THREAD
     gCOM_MNG_TMTC_THREAD = new Thread(COM_MNG_TMTC_FUN);
     gCOM_MNG_TMTC_THREAD->set_priority(osPriorityHigh);
-    #if DEBUG
-    gPC.puts("allocating threads\r\n");
-    #endif
+    
+    gHK_THREAD = new Thread(FCTN_CDMS_HK_MAIN);
+    gHK_THREAD->set_priority(osPriorityAboveNormal);
+    
     gSCIENCE_THREAD = new Thread(SCIENCE_FUN);
-   // gPC.puts("step one complete\r\n");
     gSCIENCE_THREAD->set_priority(osPriorityAboveNormal);
+    
     #if DEBUG
     gPC.puts("competed allocating threads\r\n");
     #endif
     
     
+    
     master.frequency(400000);
+    
+    /*HK_counter = new RtosTimer(hk_isr, osTimerPeriodic,(void * )NULL);
+    HK_counter->start(10000);*/
+    
     //PL_wo_dma = new RtosTimer(payload_isr_fun_dma, osTimerPeriodic,(void * )NULL);
     //PL_wo_dma->start(6000);//
     //gSCIENCE_THREAD->signal_set(SCIENCE_SIGNAL);
@@ -161,39 +161,8 @@
     }
     gPC.printf("PL_TC sent");*/
     
-    // *******************INITIALISATIONS END********************
-    
-    //FCTN_CDMS_HK_MAIN((void *)NULL);
-    //RtosTimer gCDMS_HK_TIMER(FCTN_CDMS_HK_MAIN, osTimerPeriodic);
-    //gCDMS_HK_TIMER.start(5000);
-    
-    /*test_pl_main();
-    
-    RtosTimer gCDMS_PL_TIMER(FCTN_CDMS_PL_MAIN, osTimerPeriodic);
-    gCDMS_PL_TIMER.start(10000);
-    */
-    /*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) 
-    {delete gSCIENCE_THREAD;
-    break;}
-    }*/
-    
-    
-    
     while(true){
         Thread::wait(osWaitForever);
-        //state = gCOM_MNG_TMTC_THREAD->get_state() + '0';
          gLEDG = !gLEDG;
-        //gPC.putc(state); 
     }
 }
\ No newline at end of file