To fix the hang problem

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of CDMS_CODE by shubham c

Committer:
ee12b079
Date:
Fri Aug 26 14:40:29 2016 +0000
Revision:
292:61aa2169ea1c
Parent:
290:3159ff1081a2
Child:
293:442564c72202
Testing , mutex issue solved

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