DMA issue to be tested

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of CDMS_CODE by shubham c

Committer:
chaithanyarss
Date:
Sat Jul 30 15:25:21 2016 +0000
Revision:
282:74a04dec4b95
Parent:
279:9501ee30957d
testing HK thread Indo MIM

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