sd 32 update

Dependencies:   FreescaleIAP mbed-rtos mbed

Fork of COM_MNG_TMTC_SIMPLE by Shreesha S

Revision:
2:2caf2a9a13aa
Parent:
1:a0055b3280c8
Child:
4:104dd82c99b8
--- a/COM_MNG_TMTC.h	Mon Dec 14 12:04:01 2015 +0000
+++ b/COM_MNG_TMTC.h	Tue Dec 22 06:09:48 2015 +0000
@@ -81,6 +81,15 @@
     }\
 }
 
+#define isPAhot(returnHere){\
+    /*PENDING : COMPLETE THIS FUNCTION*/\
+    returnHere = 0xFF;\
+}
+
+void after_cooling_pa(){
+    gCOM_MNG_TMTC_THREAD->signal_set(COM_MNG_TMTC_SIGNAL_UART_INT);
+}
+
 /*
 @brief:     check for missing tc, also check crc, i.e. 
             if true execution can be started else have to wait
@@ -127,6 +136,32 @@
 }
 
 /*
+return 1 if code match
+return 0 if code mismatch
+*/
+#define GScodeVerification(returnHere){\
+    Base_tc *testTC = gHEAD_NODE_TCL;\
+    uint16_t overflowCount = 0;\
+    returnHere = 0;\
+    while( (overflowCount < TCL_OVERFLOW_CONSTANT) && (testTC != NULL) ){\
+        if( (GETpacket_seq_count(testTC) == PSC_CALLSIGN) && (GETapid(testTC) == APID_CALLSIGN) ){\
+            uint8_t temp8 = testTC->TC_string[1];\
+            if( temp8 & 0x04 ){\
+                for( int i = 2 ; i <= 8 ; ++i ){\
+                    if( testTC->TC_string[i] != gGSCODE[i-2] ){\
+                        returnHere = 0;\
+                        break;\
+                    }\
+                }\
+            }\
+            break;\
+        }\
+        testTC = testTC->next_TC;\
+        ++overflowCount;\
+    }\
+}
+
+/*
 @brief:     DELETE THE CRC FAILED TC FROM THE LIST TO FREE-UP MEMORY AND UPDATE 
             THE TOTAL VALID TC AND GENERATE L1_ACK_TM
 @param:     none
@@ -312,8 +347,9 @@
 
 #define EXECUTE_TC {\
     for(uint8_t execute_psc = PSC_START_VALUE ; execute_psc < (PSC_START_VALUE+gTOTAL_VALID_TC) ; ++execute_psc ){\
-        gLEDG = !gLEDG;\
-        gLEDR = !gLEDR;\
+        /*gLEDG = !gLEDG;*/\
+        /*gLEDR = !gLEDR;*/\
+        uint8_t tempPAhot = 0xFF;\
         Base_tc* current_TC = gHEAD_NODE_TCL;\
         while(current_TC != NULL){\
             if( (GETcrc_pass(current_TC) == 1) && (GETpacket_seq_count(current_TC) == execute_psc) ){\
@@ -341,8 +377,14 @@
                             /*call CDMS_RLY_TMTC*/\
                             CDMS_RLY_TMTC(current_TC, tm_ptr);\
                         }\
+                        /*CHECK FOR HOT PA*/\
+                        isPAhot(tempPAhot);\
+                        if( tempPAhot == 0x00 ){\
+                            gFLAGS = gFLAGS | COM_PA_HOT_FLAG;\
+                        }\
+                        /*SEND DATA TO GS*/\
                         snd_tm.head_pointer(tm_ptr);\
-                        /*adf_not_SDcard();*/\
+                        adf_not_SDcard();\
                         uint8_t temp83 = 0x00;\
                         detect_ack(tm_ptr, temp83);\
                         if( temp83 == 0x01){\
@@ -369,6 +411,11 @@
                     }\
                     else{\
                         /*EXECUTION OF SD-CARD DATA SENDING (OBSRS)*/\
+                        /*CHECK FOR HOT PA*/\
+                        isPAhot(tempPAhot);\
+                        if( tempPAhot == 0x00 ){\
+                            gFLAGS = gFLAGS | COM_PA_HOT_FLAG;\
+                        }\
                         read_TC(current_TC);\
                     }\
                     /*ABORT ON NACK*/\
@@ -379,7 +426,28 @@
             }\
             current_TC = current_TC->next_TC;\
         }\
-        if( gMASTER_STATE == TCL_STATE_ABORTED )\
+        if( !(execute_psc == (PSC_START_VALUE+gTOTAL_VALID_TC-1)) ){\
+            if( tempPAhot == 0 ){\
+                gCOM_PA_COOLING_TIMER.attach(&after_cooling_pa, COM_PA_COOLING_TIME_LIMIT);\
+                /*PENDING : POWER OFF COMM TX*/\
+                RX1M.attach(&rx_read, Serial::RxIrq);\
+                gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\
+                break;\
+            }\
+        }\
+        else if( gMASTER_STATE == TCL_STATE_ABORTED ){\
+            /*PENDING : POWER OFF COM TX*/\
+            RX1M.attach(&rx_read, Serial::RxIrq);\
+            gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\
             break;\
+        }\
+        else{\
+            /*PENDING : COM POWER OFF TX*/\
+            reset_all;\
+            /*PENDING : ENABLE THREADS*/\
+            gSESSION_TIMEOUT.detach();\
+            gFLAGS = gFLAGS & (~COM_SESSION_FLAG);\
+            break;\
+        }\
     }\
 }
\ No newline at end of file