CDMS code for testing sbc

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of CDMS_CODE by shubham c

Committer:
ee12b079
Date:
Fri Apr 22 11:27:33 2016 +0000
Revision:
174:44a6d7c7674c
Parent:
173:f81ded27423d
Child:
175:e869e7837978
Next commit will include ADF Changes

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