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