DMA issue to be tested

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of CDMS_CODE by shubham c

Committer:
ee12b079
Date:
Fri Apr 22 11:52:54 2016 +0000
Revision:
175:e869e7837978
Parent:
174:44a6d7c7674c
Child:
177:2fa8582896e0
Testing DMA...22 Apr

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