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