CDMS code for testing sbc

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of CDMS_CODE by shubham c

Committer:
chaithanyarss
Date:
Sun Jul 03 09:47:05 2016 +0000
Revision:
216:570251b23c7b
Parent:
214:867de6d350fa
Child:
217:93505a6f8db7
Reset added

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ee12b079 173:f81ded27423d 1 //Science Thread
ee12b079 173:f81ded27423d 2 //SPI ISR
ee12b079 173:f81ded27423d 3 void payload_isr_fun(){
ee12b079 173:f81ded27423d 4 gSCIENCE_THREAD->signal_set(SCIENCE_SIGNAL);
ee12b079 173:f81ded27423d 5 }
ee12b079 173:f81ded27423d 6
ee12b079 189:0636c8391407 7 void payload_isr_fun_dma(void const *args ){
ee12b079 189:0636c8391407 8 gSCIENCE_THREAD->signal_set(SCIENCE_SIGNAL);
ee12b079 189:0636c8391407 9 }
ee12b079 190:f0d5fde60221 10
ee12b079 173:f81ded27423d 11 void SCIENCE_FUN(void const *args){
ee12b079 173:f81ded27423d 12
ee12b079 173:f81ded27423d 13 // initialisation of payload spi
ee12b079 173:f81ded27423d 14 gPAY_SPI.frequency(1000000);
ee12b079 173:f81ded27423d 15 gPAY_SPI.format(8,0);
ee12b079 173:f81ded27423d 16 gPAY_SPI.bulkRead_init(gPAYLOAD_BUFFER, PAYLOAD_BUFFER_LENGTH, &payload_isr_fun);
ee12b079 173:f81ded27423d 17 gPAY_SPI.bulkRead_start();
ee12b079 177:2fa8582896e0 18
ee12b079 173:f81ded27423d 19 while(true){
ee12b079 173:f81ded27423d 20 gPC.puts("entering sci\r\n");
ee12b079 173:f81ded27423d 21 gSCIENCE_THREAD->signal_wait(SCIENCE_SIGNAL);
ee12b079 199:9f03d6ca94c9 22 PL_wo_dma->stop();//
ee12b079 173:f81ded27423d 23 gPC.puts("sig_set\r\n");
ee12b079 173:f81ded27423d 24 srp(gPAYLOAD_BUFFER);
ee12b079 173:f81ded27423d 25 gPC.puts("exit_srp\r\n");
ee12b079 190:f0d5fde60221 26 //gPAY_SPI.bulkRead_start();
ee12b079 175:e869e7837978 27
ee12b079 173:f81ded27423d 28 }
ee12b079 173:f81ded27423d 29 }
ee12b079 173:f81ded27423d 30
ee12b079 173:f81ded27423d 31 //COM THREAD
shreeshas95 0:f016e9e8d48b 32 // UART ISR
shreeshas95 0:f016e9e8d48b 33 void rx_read(){
shreeshas95 2:2caf2a9a13aa 34 gRX_CURRENT_DATA_NODE->values[gRX_COUNT] = RX1M.getc();
shreeshas95 2:2caf2a9a13aa 35 gFLAGS = gFLAGS | UART_INT_FLAG;
shreeshas95 0:f016e9e8d48b 36 gCOM_MNG_TMTC_THREAD->signal_set(COM_MNG_TMTC_SIGNAL_UART_INT);
shreeshas95 0:f016e9e8d48b 37 }
shreeshas95 0:f016e9e8d48b 38
shreeshas95 0:f016e9e8d48b 39 // RX_TIMEOUT ISR
shreeshas95 0:f016e9e8d48b 40 void after_receive(){
shreeshas95 0:f016e9e8d48b 41 gRX_TIMEOUT.detach();
shreeshas95 2:2caf2a9a13aa 42 gFLAGS = gFLAGS | NEW_TC_RECEIVED;
shreeshas95 0:f016e9e8d48b 43 gCOM_MNG_TMTC_THREAD->signal_set(COM_MNG_TMTC_SIGNAL_UART_INT);
shreeshas95 0:f016e9e8d48b 44 }
shreeshas95 0:f016e9e8d48b 45
shreeshas95 0:f016e9e8d48b 46 // SESSION_TIMOUT ISR
shreeshas95 0:f016e9e8d48b 47 void after_session(){
shreeshas95 0:f016e9e8d48b 48 gSESSION_TIMEOUT.detach();
shreeshas95 6:79d422d1ed42 49 gFLAGS = gFLAGS | COM_SESSION_TIMEOUT_FLAG;
shreeshas95 6:79d422d1ed42 50 if( gMASTER_STATE != TCL_STATE_EXECUTING ){
shreeshas95 6:79d422d1ed42 51 gCOM_MNG_TMTC_THREAD->signal_set(COM_MNG_TMTC_SIGNAL_UART_INT);
shreeshas95 6:79d422d1ed42 52 }
shreeshas95 0:f016e9e8d48b 53 }
shreeshas95 0:f016e9e8d48b 54
shreeshas95 0:f016e9e8d48b 55 #define reset_all {\
shreeshas95 0:f016e9e8d48b 56 Base_tc *tcp = gHEAD_NODE_TCL;\
aniruddhv 12:ffdb29353058 57 /*gPC.puts("inside reset\r\n");*/\
shreeshas95 5:ab276a17ca07 58 gFLAGS = 0x0000;\
shreeshas95 0:f016e9e8d48b 59 while(tcp != NULL){\
shreeshas95 0:f016e9e8d48b 60 Base_tc *temp = tcp->next_TC;\
shreeshas95 0:f016e9e8d48b 61 delete tcp;\
shreeshas95 0:f016e9e8d48b 62 tcp = temp;\
shreeshas95 0:f016e9e8d48b 63 }\
shreeshas95 5:ab276a17ca07 64 gHEAD_NODE_TCL = NULL;\
shreeshas95 5:ab276a17ca07 65 gLAST_NODE_TCL = NULL;\
chaithanyarss 216:570251b23c7b 66 gMASTER_STATE = TCL_STATE_INCOMPLETE;\
shreeshas95 0:f016e9e8d48b 67 gTOTAL_INCORRECT_SIZE_TC = 0;\
shreeshas95 0:f016e9e8d48b 68 gTOTAL_CRC_FAIL_TC = 0;\
shreeshas95 2:2caf2a9a13aa 69 gTOTAL_REPEATED_TC = 0;\
shreeshas95 5:ab276a17ca07 70 gTOTAL_VALID_TC = 0;\
shreeshas95 5:ab276a17ca07 71 for(int i = 0 ; i < TM_LONG_SIZE ; ++i){\
chaithanyarss 216:570251b23c7b 72 gLAST_TM[i] = 0x00;\
shreeshas95 5:ab276a17ca07 73 }\
chaithanyarss 216:570251b23c7b 74 gLAST_TM_SHORT_OR_LONG = SHORT_TM_CODE;\
shreeshas95 0:f016e9e8d48b 75 COM_RX_DATA_NODE *dataptr = gRX_HEAD_DATA_NODE;\
shreeshas95 0:f016e9e8d48b 76 while( dataptr != NULL ){\
shreeshas95 0:f016e9e8d48b 77 COM_RX_DATA_NODE *temp = dataptr->next_node;\
shreeshas95 0:f016e9e8d48b 78 delete dataptr;\
shreeshas95 0:f016e9e8d48b 79 dataptr = temp;\
shreeshas95 0:f016e9e8d48b 80 }\
shreeshas95 0:f016e9e8d48b 81 gRX_HEAD_DATA_NODE = new COM_RX_DATA_NODE;\
shreeshas95 0:f016e9e8d48b 82 gRX_HEAD_DATA_NODE->next_node = NULL;\
shreeshas95 0:f016e9e8d48b 83 gRX_CURRENT_DATA_NODE = gRX_HEAD_DATA_NODE;\
shreeshas95 0:f016e9e8d48b 84 gRX_COUNT = 0;\
shreeshas95 2:2caf2a9a13aa 85 /*PENDING : ALL GLOBAL VAARIABLES AND FLAGS*/\
aniruddhv 12:ffdb29353058 86 /*gPC.puts("finished reset all\r\n");*/\
shreeshas95 2:2caf2a9a13aa 87 }
shreeshas95 2:2caf2a9a13aa 88
shreeshas95 2:2caf2a9a13aa 89 #define PUT_RAW_BYTE {\
shreeshas95 2:2caf2a9a13aa 90 if( gRX_COUNT < (RX_BUFFER_LENGTH-1) ){\
shreeshas95 2:2caf2a9a13aa 91 ++gRX_COUNT;\
shreeshas95 2:2caf2a9a13aa 92 }\
shreeshas95 2:2caf2a9a13aa 93 else{\
shreeshas95 2:2caf2a9a13aa 94 gRX_COUNT = 0;\
shreeshas95 2:2caf2a9a13aa 95 gRX_CURRENT_DATA_NODE->next_node = new COM_RX_DATA_NODE;\
shreeshas95 2:2caf2a9a13aa 96 gRX_CURRENT_DATA_NODE = gRX_CURRENT_DATA_NODE->next_node;\
shreeshas95 2:2caf2a9a13aa 97 gRX_CURRENT_DATA_NODE->next_node = NULL;\
shreeshas95 2:2caf2a9a13aa 98 }\
shreeshas95 2:2caf2a9a13aa 99 gRX_TIMEOUT.attach(&after_receive, RX_TIMEOUT_LIMIT);\
shreeshas95 0:f016e9e8d48b 100 }
shreeshas95 0:f016e9e8d48b 101
shreeshas95 0:f016e9e8d48b 102 void COM_MNG_TMTC_FUN(void const *args){
shreeshas95 4:104dd82c99b8 103 if( !(gFLAGS & COM_SESSION_FLAG) ){
ee12b079 96:4ca92f9775e0 104 //gLEDR = 1;
ee12b079 96:4ca92f9775e0 105 //gLEDG = 1;
shreeshas95 4:104dd82c99b8 106 }
shreeshas95 0:f016e9e8d48b 107 while(true){
shreeshas95 0:f016e9e8d48b 108 Thread::signal_wait( COM_MNG_TMTC_SIGNAL_UART_INT );
shreeshas95 0:f016e9e8d48b 109 if( gFLAGS & UART_INT_FLAG ){
shreeshas95 0:f016e9e8d48b 110 gFLAGS = gFLAGS & (~UART_INT_FLAG);
shreeshas95 2:2caf2a9a13aa 111 if( !(gFLAGS & COM_SESSION_FLAG) ){
shreeshas95 2:2caf2a9a13aa 112 // PENDING : DISABLE THREADS
ee12b079 190:f0d5fde60221 113 PL_wo_dma->stop();
shreeshas95 2:2caf2a9a13aa 114 gFLAGS = gFLAGS | COM_SESSION_FLAG;
shreeshas95 2:2caf2a9a13aa 115 gSESSION_TIMEOUT.attach(&after_session, SESSION_TIME_LIMIT);
shreeshas95 2:2caf2a9a13aa 116 gFLAGS = gFLAGS | COM_RX_FLAG;
shreeshas95 2:2caf2a9a13aa 117 PUT_RAW_BYTE;
shreeshas95 2:2caf2a9a13aa 118 // PENDING : MEASURE RSSI
shreeshas95 4:104dd82c99b8 119 if( gFLAGS & COM_SESSION_FLAG ){
ee12b079 96:4ca92f9775e0 120 //gLEDR = 0;
ee12b079 96:4ca92f9775e0 121 //gLEDG = 0;
shreeshas95 4:104dd82c99b8 122 }
shreeshas95 2:2caf2a9a13aa 123 }
shreeshas95 2:2caf2a9a13aa 124 else if( gFLAGS & COM_RX_FLAG ){
ee12b079 96:4ca92f9775e0 125 //gLEDR = 0;
ee12b079 96:4ca92f9775e0 126 //gLEDG = 1;
shreeshas95 2:2caf2a9a13aa 127 PUT_RAW_BYTE;
shreeshas95 0:f016e9e8d48b 128 }
shreeshas95 0:f016e9e8d48b 129 else{
ee12b079 96:4ca92f9775e0 130 //gLEDR = 1;
ee12b079 96:4ca92f9775e0 131 //gLEDG = 0;
shreeshas95 2:2caf2a9a13aa 132 gFLAGS = gFLAGS | COM_RX_FLAG;
shreeshas95 2:2caf2a9a13aa 133 PUT_RAW_BYTE;
shreeshas95 0:f016e9e8d48b 134 }
shreeshas95 0:f016e9e8d48b 135 }
shreeshas95 4:104dd82c99b8 136 else if( gFLAGS & NEW_TC_RECEIVED ){
ee12b079 98:fd99ddc0e0a1 137 gPC.puts("NEW TC RECEIVED\r\n");
chaithanyarss 216:570251b23c7b 138 Thread::wait(1000);
shreeshas95 0:f016e9e8d48b 139 gFLAGS = gFLAGS & (~NEW_TC_RECEIVED);
shreeshas95 4:104dd82c99b8 140 gFLAGS = gFLAGS | COM_MNG_TMTC_RUNNING_FLAG;
shreeshas95 2:2caf2a9a13aa 141
shreeshas95 0:f016e9e8d48b 142 // DISABLE THE RX1M INTERRUPT
shreeshas95 0:f016e9e8d48b 143 RX1M.attach(NULL);
shreeshas95 0:f016e9e8d48b 144
shreeshas95 4:104dd82c99b8 145 // VERIFY CRC, REPEATED PSC AND UPDATE TOTAL_VALID_TC, INCORRECT SIZE TC, CRC FAIL TC
shreeshas95 2:2caf2a9a13aa 146 while(gRX_COUNT < (RX_BUFFER_LENGTH)){
shreeshas95 2:2caf2a9a13aa 147 gRX_CURRENT_DATA_NODE->values[gRX_COUNT] = 0x00;
shreeshas95 0:f016e9e8d48b 148 ++gRX_COUNT;
shreeshas95 0:f016e9e8d48b 149 }
shreeshas95 0:f016e9e8d48b 150 gRX_COUNT = 0;
shreeshas95 4:104dd82c99b8 151 raw_data_to_tc();
shreeshas95 6:79d422d1ed42 152 gFLAGS = gFLAGS & (~COM_RX_FLAG);
aniruddhv 51:da85d84768e2 153
shreeshas95 2:2caf2a9a13aa 154 if( gTOTAL_VALID_TC > 0 ){
aniruddhv 12:ffdb29353058 155 /*gPC.printf("valid TC rx: %u\r\n", gTOTAL_VALID_TC);*/
shreeshas95 4:104dd82c99b8 156 if( gTOTAL_VALID_TC < COM_MAX_TC_LIMIT ){
shreeshas95 4:104dd82c99b8 157 // CHECK WEATHER TC LIST HAS MISSING TC OR WEATHER LAST FRAME BIT IS HIGH IN THE LAST PSC-TC
aniruddhv 12:ffdb29353058 158 /*gPC.puts("checking for tc list complete\r\n");*/
shreeshas95 4:104dd82c99b8 159 uint8_t tempContinue = 0xFF;
shreeshas95 4:104dd82c99b8 160 continueToExecute(tempContinue);
shreeshas95 4:104dd82c99b8 161 if(tempContinue == 0x00){
aniruddhv 12:ffdb29353058 162 /*gPC.puts("tc list is complete\r\n");*/
shreeshas95 4:104dd82c99b8 163 // CHECK WEATHER GS VERIFICATION CODE MATCHES
shreeshas95 4:104dd82c99b8 164 uint8_t tempGSver = 0x00;
shreeshas95 4:104dd82c99b8 165 GScodeVerification(tempGSver);
chaithanyarss 216:570251b23c7b 166 /*PENDING: INCLUDE GS VERIFICATION CODE*/
aniruddhv 37:c9a739750806 167 if( tempGSver == 0xFF ){
aniruddhv 37:c9a739750806 168 /*gPC.puts("GS code match !!\r\n");*/
shreeshas95 4:104dd82c99b8 169 gFLAGS = gFLAGS | COM_SESSION_VALIDITY;
shreeshas95 4:104dd82c99b8 170 COM_POWER_ON_TX;
chaithanyarss 216:570251b23c7b 171 // PENDING: PA HOT HANDLED IN EXECUTE_XXX FUNCTIONS
chaithanyarss 216:570251b23c7b 172 uint8_t tempPAHot = 0x00;
chaithanyarss 216:570251b23c7b 173 isPAhot(tempPAHot);
chaithanyarss 216:570251b23c7b 174 if( tempPAHot == 0xFF ){
chaithanyarss 216:570251b23c7b 175 gFLAGS = gFLAGS & ~(COM_PA_HOT_FLAG);
chaithanyarss 216:570251b23c7b 176 gCOM_PA_COOLING_TIMEOUT.detach();
chaithanyarss 216:570251b23c7b 177 gPC.puts("EXECUTING TELECOMMANDS\r\n");
chaithanyarss 216:570251b23c7b 178 // DEBUF_PRINT("EXECUTING TELECOMMANDS\r\n");
chaithanyarss 216:570251b23c7b 179 EXECUTE_OBOSC_ONLY;
chaithanyarss 216:570251b23c7b 180 EXECUTE_TC;
chaithanyarss 216:570251b23c7b 181 gPC.puts("COMPLETED EXECUTION\r\n");
chaithanyarss 216:570251b23c7b 182 }
chaithanyarss 216:570251b23c7b 183 else{
chaithanyarss 216:570251b23c7b 184 gFLAGS = gFLAGS | COM_PA_HOT_FLAG;
chaithanyarss 216:570251b23c7b 185 // PENDING: power off transmitter only
aniruddhv 214:867de6d350fa 186 gCOM_PA_COOLING_TIMEOUT.attach(&after_cooling_pa, COM_PA_COOLING_TIME_LIMIT);
aniruddhv 214:867de6d350fa 187 gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);
aniruddhv 214:867de6d350fa 188 RX1M.attach(&rx_read, Serial::RxIrq);
aniruddhv 214:867de6d350fa 189 }
shreeshas95 4:104dd82c99b8 190 }
shreeshas95 4:104dd82c99b8 191 else{
aniruddhv 12:ffdb29353058 192 /*gPC.puts("GS code mismatch !!\r\n");*/
shreeshas95 6:79d422d1ed42 193 RX1M.attach(&rx_read, Serial::RxIrq);
shreeshas95 4:104dd82c99b8 194 reset_all;
shreeshas95 4:104dd82c99b8 195 gFLAGS = gFLAGS & (~COM_SESSION_VALIDITY);
shreeshas95 4:104dd82c99b8 196 // PENDING : ENABLE THREADS
ee12b079 190:f0d5fde60221 197 PL_wo_dma->start(6000);
shreeshas95 4:104dd82c99b8 198 gSESSION_TIMEOUT.detach();
shreeshas95 4:104dd82c99b8 199 gFLAGS = gFLAGS & (~COM_SESSION_FLAG);
chaithanyarss 216:570251b23c7b 200 // WARNING: clear COM_MNG_TMTC ?
shreeshas95 4:104dd82c99b8 201 }
shreeshas95 0:f016e9e8d48b 202 }
shreeshas95 2:2caf2a9a13aa 203 else{
ee12b079 164:be3b4b760d0c 204 gPC.puts("tc list is not complete\r\n");
shreeshas95 5:ab276a17ca07 205 if(tempContinue & 0x01){
aniruddhv 69:20f09a0c3fd2 206 //gPC.puts("last packet bit not found\r\n");
shreeshas95 5:ab276a17ca07 207 }
shreeshas95 5:ab276a17ca07 208 if( tempContinue & 0x02 ){
aniruddhv 69:20f09a0c3fd2 209 //gPC.puts("missing psc found\r\n");
shreeshas95 5:ab276a17ca07 210 }
aniruddhv 69:20f09a0c3fd2 211 //gPC.printf("crc fail tc = %u\r\n", gTOTAL_CRC_FAIL_TC);
aniruddhv 69:20f09a0c3fd2 212 //gPC.printf("incorrect size tc = %u\r\n", gTOTAL_INCORRECT_SIZE_TC);
aniruddhv 69:20f09a0c3fd2 213 //gPC.printf("repeated psc = %u\r\n", gTOTAL_REPEATED_TC);
shreeshas95 5:ab276a17ca07 214 Base_tc *test_tc = gHEAD_NODE_TCL;
shreeshas95 5:ab276a17ca07 215 while( test_tc != NULL ){
shreeshas95 5:ab276a17ca07 216 int length = 0;
shreeshas95 5:ab276a17ca07 217 if( GETshort_or_long_tc(test_tc) == SHORT_TC_CODE ){
shreeshas95 5:ab276a17ca07 218 length = TC_SHORT_SIZE;
shreeshas95 5:ab276a17ca07 219 }
shreeshas95 5:ab276a17ca07 220 else{
shreeshas95 5:ab276a17ca07 221 length = TC_LONG_SIZE;
shreeshas95 5:ab276a17ca07 222 }
rohit3342 16:538de1b20b3a 223 for(int i = 0 ; i < length ; ++i ){
aniruddhv 69:20f09a0c3fd2 224 //gPC.printf("%x ", test_tc->TC_string[i]);
shreeshas95 5:ab276a17ca07 225 }
aniruddhv 69:20f09a0c3fd2 226 //gPC.puts("\r\n");
shreeshas95 5:ab276a17ca07 227 test_tc = test_tc->next_TC;
shreeshas95 5:ab276a17ca07 228 }
aniruddhv 69:20f09a0c3fd2 229 //gPC.puts("\r\n");
shreeshas95 4:104dd82c99b8 230 COM_POWER_ON_TX;
chaithanyarss 216:570251b23c7b 231 // PENDING : POWER OFF TX
shreeshas95 4:104dd82c99b8 232 RX1M.attach(&rx_read, Serial::RxIrq);
shreeshas95 4:104dd82c99b8 233 gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);
shreeshas95 2:2caf2a9a13aa 234 }
shreeshas95 0:f016e9e8d48b 235 }
shreeshas95 0:f016e9e8d48b 236 else{
shreeshas95 4:104dd82c99b8 237 COM_POWER_ON_TX;
chaithanyarss 216:570251b23c7b 238 // POWER OFF TX transmitter only
chaithanyarss 216:570251b23c7b 239 // WARNING: reset_all ? clear com_session ?
shreeshas95 2:2caf2a9a13aa 240 RX1M.attach(&rx_read, Serial::RxIrq);
shreeshas95 4:104dd82c99b8 241 gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);
shreeshas95 0:f016e9e8d48b 242 }
shreeshas95 2:2caf2a9a13aa 243 }
shreeshas95 4:104dd82c99b8 244 else{
ee12b079 164:be3b4b760d0c 245 gPC.puts("No valid TC received\r\n");
shreeshas95 2:2caf2a9a13aa 246 RX1M.attach(&rx_read, Serial::RxIrq);
shreeshas95 4:104dd82c99b8 247 gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);
shreeshas95 6:79d422d1ed42 248 reset_all;
shreeshas95 6:79d422d1ed42 249 // PENDING : ENABLE THREADS
ee12b079 190:f0d5fde60221 250 PL_wo_dma->start(6000);
shreeshas95 6:79d422d1ed42 251 gSESSION_TIMEOUT.detach();
shreeshas95 6:79d422d1ed42 252 gFLAGS = gFLAGS & (~COM_SESSION_FLAG);
shreeshas95 2:2caf2a9a13aa 253 }
shreeshas95 2:2caf2a9a13aa 254 }
shreeshas95 2:2caf2a9a13aa 255 else if( gFLAGS & COM_PA_HOT_FLAG ){
aniruddhv 12:ffdb29353058 256 /*gPC.puts("checking for PA hot in main\r\n");*/
chaithanyarss 216:570251b23c7b 257 if( gFLAGS & COM_RX_FLAG ){
chaithanyarss 216:570251b23c7b 258 uint8_t tempPA = 0xFF;
chaithanyarss 216:570251b23c7b 259 isPAhot(tempPA);
chaithanyarss 216:570251b23c7b 260 if( tempPA == 0x00 ){
chaithanyarss 216:570251b23c7b 261 gCOM_PA_COOLING_TIMEOUT.attach(&after_cooling_pa, COM_PA_COOLING_TIME_LIMIT);
chaithanyarss 216:570251b23c7b 262 }
chaithanyarss 216:570251b23c7b 263 else{
chaithanyarss 216:570251b23c7b 264 gFLAGS = gFLAGS & ~(COM_PA_HOT_FLAG);
chaithanyarss 216:570251b23c7b 265 gCOM_PA_COOLING_TIMEOUT.detach();
chaithanyarss 216:570251b23c7b 266 }
shreeshas95 0:f016e9e8d48b 267 }
shreeshas95 0:f016e9e8d48b 268 else{
chaithanyarss 216:570251b23c7b 269 uint8_t tempPA = 0xFF;
chaithanyarss 216:570251b23c7b 270 isPAhot(tempPA);
chaithanyarss 216:570251b23c7b 271 if( tempPA == 0x00 ){
chaithanyarss 216:570251b23c7b 272 gCOM_PA_COOLING_TIMEOUT.attach(&after_cooling_pa, COM_PA_COOLING_TIME_LIMIT);
chaithanyarss 216:570251b23c7b 273 }
chaithanyarss 216:570251b23c7b 274 else{
aniruddhv 12:ffdb29353058 275 /*gPC.puts("PA IS COOLED DOWN\r\n");*/
chaithanyarss 216:570251b23c7b 276 gFLAGS = gFLAGS & (~COM_PA_HOT_FLAG);
shreeshas95 6:79d422d1ed42 277 gFLAGS = gFLAGS | COM_MNG_TMTC_RUNNING_FLAG;
shreeshas95 6:79d422d1ed42 278 RX1M.attach(NULL);
chaithanyarss 216:570251b23c7b 279 gCOM_PA_COOLING_TIMEOUT.detach();
shreeshas95 6:79d422d1ed42 280 COM_POWER_ON_TX;
shreeshas95 6:79d422d1ed42 281 EXECUTE_OBOSC_ONLY;
shreeshas95 6:79d422d1ed42 282 EXECUTE_TC;
shreeshas95 6:79d422d1ed42 283 }
shreeshas95 0:f016e9e8d48b 284 }
shreeshas95 2:2caf2a9a13aa 285 }
shreeshas95 6:79d422d1ed42 286 else if( gFLAGS & COM_SESSION_TIMEOUT_FLAG ){
aniruddhv 12:ffdb29353058 287 /*gPC.puts("session timeout: resetting in main\r\n");*/
shreeshas95 6:79d422d1ed42 288 COM_POWER_OFF_TX;
shreeshas95 6:79d422d1ed42 289 /*PENDING : ENABLE THREADS*/
chaithanyarss 216:570251b23c7b 290
shreeshas95 6:79d422d1ed42 291 gSESSION_TIMEOUT.detach();
shreeshas95 6:79d422d1ed42 292 gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);
shreeshas95 6:79d422d1ed42 293 gFLAGS = gFLAGS & (~COM_SESSION_FLAG);
shreeshas95 6:79d422d1ed42 294 reset_all;
shreeshas95 6:79d422d1ed42 295 }
shreeshas95 2:2caf2a9a13aa 296 else{
aniruddhv 12:ffdb29353058 297 /*gPC.puts("INVALID SIGNAL RECEIVED IN MAIN\r\n");*/
shreeshas95 2:2caf2a9a13aa 298 // SOME INVALID SIGNAL RECEIVED
shreeshas95 4:104dd82c99b8 299 COM_POWER_OFF_TX;
shreeshas95 2:2caf2a9a13aa 300 reset_all;
shreeshas95 2:2caf2a9a13aa 301 // PENDING : ENABLE THREADS
ee12b079 190:f0d5fde60221 302 PL_wo_dma->start(6000);
shreeshas95 2:2caf2a9a13aa 303 gSESSION_TIMEOUT.detach();
shreeshas95 2:2caf2a9a13aa 304 gFLAGS = gFLAGS & (~COM_SESSION_FLAG);
shreeshas95 0:f016e9e8d48b 305 }
shreeshas95 0:f016e9e8d48b 306 }
shreeshas95 101:bece931236a2 307 }