CDMS_CODE_samp_23SEP_DMA_flag

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of CDMS_CODE_samp_23SEP_DMA by iitm sat

Committer:
ee12b079
Date:
Fri Aug 05 17:13:23 2016 +0000
Revision:
288:aa93d6652381
Parent:
278:1d837d6dfb6e
Child:
289:9bd62b69874c
CDMS Code currently dumped in Satellite

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