publishing to check changes in cdms code

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of CDMS_CODE_samp_23SEP_DMA_flag by samp Srinivasan

Committer:
chaithanyarss
Date:
Sun Aug 28 14:47:38 2016 +0000
Revision:
296:ec1317ab9c50
Parent:
295:699801854b71
Child:
302:5ff4b9ce185e
testing counters;

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