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