DMA issue to be tested

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of CDMS_CODE by shubham c

Committer:
ee12b079
Date:
Mon Apr 18 12:18:53 2016 +0000
Revision:
164:be3b4b760d0c
Parent:
161:a63672bf4423
Child:
172:c508bbf7e89a
Working Code : OBSRS and MMS cheked with GS using actual CDMS Hardware

Who changed what in which revision?

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