Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: FreescaleIAP SimpleDMA mbed-rtos mbed
Fork of CDMS_CODE by
CDMS_PL.h
00001 int pl_next_index=-1; 00002 uint8_t pl_main_flag=0; 00003 uint8_t PL_PREV_STATE=0x00; 00004 uint8_t POWER_LEVEL = 3; //Would be present in HK data extracted 00005 uint32_t pl_block[192]={0}; 00006 uint32_t pl_time; 00007 uint32_t TIME_LATEST_PL=0; 00008 uint8_t i; 00009 //extern uint8_t PL_BEE_SW_STATUS=0; 00010 00011 //Serial pc(USBTX,USBRX); 00012 00013 #define PL_MAIN_STATUS 0x01 00014 #define PL_LOW_POWER 0x02 00015 #define STATE_OFF 0x00 00016 #define STATE_STANDBY 0x04 00017 #define STATE_HIBERNATE 0x08 00018 #define STATE_SCIENCE 0x0C //also used as mask for PL_STATE 00019 #define PL_OFF 0x00 00020 #define PL_STANDBY 0x10 00021 #define PL_HIBERNATE 0x20 00022 #define PL_SCIENCE 0x30 00023 #define PL_SUCCESS_I2C 0x40 00024 #define PL_ERR_I2C 0x50 00025 #define PL_INVALID_STATE 0x60 00026 #define PL_DISABLED 0x70 //also used as mask for PL_STATUS 00027 #define EXECUTED 0x00000001 00028 #define RETRY 0x00000002 00029 #define UNEXECUTED 0x00000003 //also used as mask for EXEC_STATUS 00030 00031 00032 Base_tm* FCTN_CDMS_RLY_TMTC(Base_tc *tc_ptr); 00033 00034 // waiting 1us for setup time,hold time and propagation delay 00035 #define SET_PL_BEE_OFF {\ 00036 PYLD_DFF_CLK = 0;\ 00037 PYLD_DFF = 0;\ 00038 wait_us(1);\ 00039 PYLD_DFF_CLK = 1;\ 00040 wait_us(1);\ 00041 PYLD_DFF_CLK = 0;\ 00042 wait_us(1);\ 00043 } 00044 #define SET_PL_BEE_ON {\ 00045 PYLD_DFF_CLK = 0;\ 00046 PYLD_DFF = 1;\ 00047 wait_us(1);\ 00048 PYLD_DFF_CLK = 1;\ 00049 wait_us(1);\ 00050 PYLD_DFF_CLK = 0;\ 00051 wait_us(1);\ 00052 } 00053 00054 //TC_string[0] should not be 0x00 00055 00056 #define SET_PL_BEE_STANDBY(tm_ptr_standby) {\ 00057 Base_tc *pl_tc_standby = new Short_tc;\ 00058 pl_tc_standby->next_TC = NULL;\ 00059 PUTshort_or_long(pl_tc_standby,0);\ 00060 PUTcrc_pass(pl_tc_standby,0x1);\ 00061 PUTexec_status(pl_tc_standby,0);\ 00062 pl_tc_standby->TC_string[0] = 0x01;\ 00063 pl_tc_standby->TC_string[1] = 0xE1;\ 00064 pl_tc_standby->TC_string[2] = 0x81;\ 00065 pl_tc_standby->TC_string[3] = 0x02;\ 00066 pl_tc_standby->TC_string[4] = 0;\ 00067 pl_tc_standby->TC_string[5] = 0;\ 00068 pl_tc_standby->TC_string[6] = 0;\ 00069 pl_tc_standby->TC_string[7] = 0;\ 00070 pl_tc_standby->TC_string[8] = 0;\ 00071 uint16_t crc16 = crc16_gen(pl_tc_standby->TC_string, 9);\ 00072 pl_tc_standby->TC_string[9] = (uint8_t)(crc16 & 0xFF00)>>8;\ 00073 pl_tc_standby->TC_string[10] = (uint8_t)(crc16 & 0x00FF);\ 00074 tm_ptr_standby = FCTN_CDMS_RLY_TMTC(pl_tc_standby);\ 00075 VERIFY_TM(tm_ptr_standby);\ 00076 delete pl_tc_standby;\ 00077 Base_tm *temp;\ 00078 temp = tm_ptr_standby;\ 00079 while(tm_ptr_standby!=NULL)\ 00080 {\ 00081 temp = temp->next_TM;\ 00082 delete tm_ptr_standby;\ 00083 tm_ptr_standby = temp;\ 00084 }\ 00085 } 00086 00087 //TC_string[0] should not be 0x00 00088 00089 #define SET_PL_BEE_HIBERNATE(tm_ptr_hibernate) {\ 00090 Base_tc *pl_tc_hibernate = new Short_tc;\ 00091 pl_tc_hibernate->next_TC = NULL;\ 00092 PUTshort_or_long(pl_tc_hibernate,0);\ 00093 PUTcrc_pass(pl_tc_hibernate,0x1);\ 00094 PUTexec_status(pl_tc_hibernate,0);\ 00095 pl_tc_hibernate->TC_string[0] = 0x01;\ 00096 pl_tc_hibernate->TC_string[1] = 0xE1;\ 00097 pl_tc_hibernate->TC_string[2] = 0x81;\ 00098 pl_tc_hibernate->TC_string[3] = 0x03;\ 00099 pl_tc_hibernate->TC_string[4] = 0;\ 00100 pl_tc_hibernate->TC_string[5] = 0;\ 00101 pl_tc_hibernate->TC_string[6] = 0;\ 00102 pl_tc_hibernate->TC_string[7] = 0;\ 00103 pl_tc_hibernate->TC_string[8] = 0;\ 00104 uint16_t crc16 = crc16_gen(pl_tc_hibernate->TC_string, 9);\ 00105 pl_tc_hibernate->TC_string[9] = (uint8_t)(crc16 & 0xFF00)>>8;\ 00106 pl_tc_hibernate->TC_string[10] = (uint8_t)(crc16 & 0x00FF);\ 00107 tm_ptr_hibernate = FCTN_CDMS_RLY_TMTC(pl_tc_hibernate);\ 00108 VERIFY_TM(tm_ptr_hibernate);\ 00109 delete pl_tc_hibernate;\ 00110 Base_tm *temp;\ 00111 temp = tm_ptr_hibernate;\ 00112 while(tm_ptr_hibernate!=NULL)\ 00113 {\ 00114 temp = temp->next_TM;\ 00115 delete tm_ptr_hibernate;\ 00116 tm_ptr_hibernate = temp;\ 00117 }\ 00118 } 00119 00120 //TC_string[0] should not be 0x00 00121 /* 00122 PUTshort_or_long(pl_tc_science,0);\ 00123 PUTcrc_pass(pl_tc_science,0x1);\ 00124 PUTexec_status(pl_tc_science,0);\*/ 00125 00126 #define SET_PL_BEE_SCIENCE(tm_ptr_science) {\ 00127 Base_tc *pl_tc_science = new Short_tc;\ 00128 pl_tc_science->next_TC = NULL;\ 00129 pl_tc_science->TC_string[0] = 0x01;\ 00130 pl_tc_science->TC_string[1] = 0xE1;\ 00131 pl_tc_science->TC_string[2] = 0x81;\ 00132 pl_tc_science->TC_string[3] = 0x04;\ 00133 pl_tc_science->TC_string[4] = 0;\ 00134 pl_tc_science->TC_string[5] = 0;\ 00135 pl_tc_science->TC_string[6] = 0;\ 00136 pl_tc_science->TC_string[7] = 0;\ 00137 pl_tc_science->TC_string[8] = 0;\ 00138 uint16_t crc16 = crc16_gen(pl_tc_science->TC_string, 9);\ 00139 pl_tc_science->TC_string[9] = (uint8_t)(crc16 & 0xFF00)>>8;\ 00140 pl_tc_science->TC_string[10] = (uint8_t)(crc16 & 0x00FF);\ 00141 tm_ptr_science = FCTN_CDMS_RLY_TMTC(pl_tc_science);\ 00142 VERIFY_TM(tm_ptr_science);\ 00143 delete pl_tc_science;\ 00144 Base_tm *temp;\ 00145 temp = tm_ptr_science;\ 00146 while(tm_ptr_science!=NULL)\ 00147 {\ 00148 temp = temp->next_TM;\ 00149 delete tm_ptr_science;\ 00150 tm_ptr_science = temp;\ 00151 }\ 00152 } 00153 void print_processed_block(uint8_t index) 00154 { 00155 gPC.printf("\n\n\rBlock after processing:"); 00156 gPC.printf("\n\rTime of block:"); 00157 gPC.printf("\n\rYear :%d",((((pl_block[index]&0xFFFFFFF0)>>4) & 0x0C000000)>>26)+2016); 00158 gPC.printf("\tMonth :%d",((((pl_block[index]&0xFFFFFFF0)>>4) & 0x03C00000)>>22)); 00159 gPC.printf("\tDay :%d",((((pl_block[index]&0xFFFFFFF0)>>4) & 0x003E0000)>>17)); 00160 gPC.printf("\n\rHours :%d",((((pl_block[index]&0xFFFFFFF0)>>4) & 0x0001F000)>>12)); 00161 gPC.printf("\tMin :%d",((((pl_block[index]&0xFFFFFFF0)>>4) & 0x00000FC0)>>6)); 00162 gPC.printf("\tSec :%d",(((pl_block[index]&0xFFFFFFF0)>>4) & 0x0000003F)); 00163 gPC.printf("\n\rSID :%d",(pl_block[index] & 0x0000000C)>>2); 00164 gPC.printf("\tExecution Status :%d",pl_block[index] & UNEXECUTED); 00165 } 00166 void print_exit(uint8_t* temp) 00167 { 00168 uint8_t temp2[3]; 00169 temp2[0] = (pl_main_flag&STATE_SCIENCE)>>2; 00170 temp2[1] = (pl_main_flag&PL_DISABLED)>>4; 00171 temp2[2] = (PL_PREV_STATE & STATE_SCIENCE)>>2; 00172 //gPC.printf("\n\rAt exit"); 00173 char state[][17] = {"STATE_OFF","STATE_STANDBY","STATE_HIBERNATE","STATE_SCIENCE"}; 00174 char status[][17] = {"PL_OFF","PL_STANDBY","PL_HIBERNATE","PL_SCIENCE","PL_SUCCESS_I2C","PL_ERR_I2C","PL_INVALID_STATE","PL_DISABLED"}; 00175 //gPC.printf("\n\rPL_state:%s -> %s",state[(uint8_t)temp[0]],state[(uint8_t)temp2[0]]); 00176 //gPC.printf("\n\rPL_status:%s -> %s",status[(uint8_t)temp[1]],status[(uint8_t)temp2[1]]); 00177 //gPC.printf("\n\rPL_PREV_state:%s -> %s",state[(uint8_t)temp[2]],state[(uint8_t)temp2[2]]); 00178 } 00179 void VERIFY_TM(Base_tm *tm_ptr) 00180 { 00181 uint8_t temp = tm_ptr->TM_string[2]; //Obatining ACK_CODE 00182 if(GETshort_or_long_tm(tm_ptr)==1) //short TM 00183 { 00184 gPC.printf("\n\rSHORT TM received"); 00185 uint16_t crc16 = crc16_gen(tm_ptr->TM_string, 11); 00186 if(tm_ptr->TM_string[12]==((uint8_t)(crc16 & 0x00FF)) && tm_ptr->TM_string[11]==((uint8_t)((crc16 & 0xFF00)>>8))) 00187 { 00188 if(temp!=0x00 && temp!=0x01 && temp!=0x02 && temp!=0x03 && temp!=0x84 && temp!=0x85) 00189 { 00190 gPC.printf("\n\rTime_Latest_PL Updated"); 00191 TIME_LATEST_PL = pl_time; //update latest time when I2C communication was successful 00192 } 00193 if(temp==0xA0 || temp==0xC0) 00194 { 00195 gPC.printf("\n\rACK_CODE Success"); 00196 if(temp==0xA0) 00197 gPC.printf("\n\rACK_CODE = 0x%02X",temp); 00198 else 00199 gPC.printf("\n\rACK_CODE = 0x%02X",temp); 00200 pl_main_flag = pl_main_flag & (~PL_DISABLED); 00201 pl_main_flag |= PL_SUCCESS_I2C; 00202 PL_STATUS = 0x04; 00203 pl_block[pl_next_index-1] &= (~UNEXECUTED); //changing exec_status 00204 pl_block[pl_next_index-1] |= EXECUTED; 00205 } 00206 else 00207 { 00208 gPC.printf("\n\rACK_CODE failure (0x%02X)",temp); 00209 //gPC.printf("\n\rACK_CODE = 0x%02X",temp); 00210 pl_main_flag = pl_main_flag & (~PL_DISABLED); 00211 pl_main_flag |= PL_ERR_I2C; 00212 PL_STATUS = 0x05; 00213 pl_block[pl_next_index-1] &= (~UNEXECUTED); //changing exec_status 00214 pl_block[pl_next_index-1] |= RETRY; 00215 } 00216 } 00217 else 00218 { 00219 gPC.printf("\n\rShort_TM CRC failed"); 00220 pl_main_flag = pl_main_flag & (~PL_DISABLED); 00221 pl_main_flag |= PL_ERR_I2C; 00222 PL_STATUS = 0x05; 00223 pl_block[pl_next_index-1] &= (~UNEXECUTED); //changing exec_status 00224 pl_block[pl_next_index-1] |= RETRY; 00225 } 00226 } 00227 else if(GETshort_or_long_tm(tm_ptr)==0) //LONG TM 00228 { 00229 gPC.printf("\n\rLONG TM received"); 00230 uint16_t crc16 = crc16_gen(tm_ptr->TM_string,132); 00231 if(tm_ptr->TM_string[133]==((uint8_t)(crc16 & 0x00FF)) && tm_ptr->TM_string[132]==((uint8_t)((crc16 & 0xFF00)>>8))) 00232 { 00233 if(temp!=0x00 && temp!=0x01 && temp!=0x02 && temp!=0x03 && temp!=0x84 && temp!=0x85) 00234 { 00235 gPC.printf("\n\rTime_Latest_PL Updated"); 00236 TIME_LATEST_PL = pl_time; //update latest time when I2C communication was successful 00237 } 00238 if(temp==0xA0 || temp==0xC0) 00239 { 00240 gPC.printf("\n\rACK_CODE Success"); 00241 if(temp==0xA0) 00242 gPC.printf("\n\rACK_CODE = 0x%02X",temp); 00243 else 00244 gPC.printf("\n\rACK_CODE = 0x%02X",temp); 00245 pl_main_flag = pl_main_flag & (~PL_DISABLED); 00246 pl_main_flag |= PL_SUCCESS_I2C; 00247 PL_STATUS = 0x04; 00248 pl_block[pl_next_index-1] &= (~UNEXECUTED); //changing exec_status 00249 pl_block[pl_next_index-1] |= EXECUTED; 00250 } 00251 else 00252 { 00253 gPC.printf("\n\rACK_CODE failure (0x%02X)",temp); 00254 pl_main_flag = pl_main_flag & (~PL_DISABLED); 00255 pl_main_flag |= PL_ERR_I2C; 00256 PL_STATUS = 0x05; 00257 pl_block[pl_next_index-1] &= (~UNEXECUTED); //changing exec_status 00258 pl_block[pl_next_index-1] |= RETRY; 00259 } 00260 } 00261 else 00262 { 00263 gPC.printf("\n\rLong_TM CRC failed"); 00264 pl_main_flag = pl_main_flag & (~PL_DISABLED); 00265 pl_main_flag |= PL_ERR_I2C; 00266 PL_STATUS = 0x05; 00267 pl_block[pl_next_index-1] &= (~UNEXECUTED); //changing exec_status 00268 pl_block[pl_next_index-1] |= RETRY; 00269 } 00270 } 00271 } 00272 void test1(uint8_t t) 00273 { 00274 //Output should be PL_STATUS = PL_DISABLED 00275 if(t!=0) 00276 { 00277 gPC.printf("\n\rTesting OC protection"); 00278 PL_STATUS = 2; //OC protection 00279 } 00280 } 00281 void test2(uint8_t t) 00282 { 00283 //output should be same as test1() 00284 if(t!=0) 00285 { 00286 gPC.printf("\n\rTesting Deviced Disabled case"); 00287 PL_STATUS = 3; //Device DISABLED 00288 } 00289 } 00290 void test3(uint8_t t) 00291 { 00292 if(t!=0) 00293 { 00294 gPC.printf("\n\rTesting RTC failed case"); 00295 pl_time = 0; //RTC failed 00296 } 00297 } 00298 /*void test4(uint8_t t) 00299 { 00300 if(t!=0) 00301 { 00302 gPC.printf("\n\rTesting No future blocks available"); 00303 schedule1[0] = {0,0,0,0,0,0,0,0}; 00304 } 00305 }*/ 00306 void FCTN_CDMS_PL_MAIN(void const *args) 00307 { 00308 if(EN_PL == 0x00) 00309 return; 00310 uint8_t temp[3]; 00311 pl_main_flag|=PL_MAIN_STATUS; //Setting PL_MAIN_STATUS 00312 PL_MAIN_status = 1; 00313 PL_MAIN_COUNTER++; 00314 pl_main_flag&=~(PL_LOW_POWER); //Clearing PL_LOW_POWER 00315 PL_LOW_power = 0; 00316 temp[0] = (pl_main_flag&STATE_SCIENCE)>>2; 00317 temp[1] = (pl_main_flag&PL_DISABLED)>>4; 00318 temp[2] = (PL_PREV_STATE & STATE_SCIENCE)>>2; 00319 //test2(1); 00320 00321 if(PL_STATUS==2 || PL_STATUS==3) 00322 { 00323 gPC.printf("\n\rDevice Disabled or OC Fault"); 00324 pl_main_flag = pl_main_flag & (~PL_DISABLED); 00325 pl_main_flag |= PL_DISABLED; //setting PL_STATUS as PL_DISABLED 00326 PL_STATUS = 0x07; 00327 pl_main_flag = pl_main_flag & (~PL_MAIN_STATUS); //Clearing pl_main status 00328 PL_MAIN_status = 0; 00329 print_exit(temp); 00330 return; 00331 } 00332 PL_PREV_STATE = (pl_main_flag & STATE_SCIENCE); //saving current pl_state 00333 uint64_t temp_time; 00334 temp_time=FCTN_CDMS_RD_RTC(); 00335 pl_time = (uint32_t)((temp_time>>7) & 0x000000000FFFFFFF); 00336 00337 //call test3() here 00338 //test3(1); 00339 00340 //gPC.printf("\n\rprev_state :%d",(PL_PREV_STATE)>>4); 00341 /*gPC.printf("\n\n\rtTime_RTC:"); 00342 gPC.printf("\n\rYear :%d\t",((pl_time & 0x0C000000)>>26)+2016); 00343 gPC.printf("Month :%d\t",((pl_time & 0x03C00000)>>22)); 00344 gPC.printf("Day :%d",((pl_time & 0x003E0000)>>17)); 00345 gPC.printf("\n\rHours :%d",((pl_time & 0x0001F000)>>12)); 00346 gPC.printf("\tMin :%d",((pl_time & 0x00000FC0)>>6)); 00347 gPC.printf("\t\tSec :%d",(pl_time & 0x0000003F));*/ 00348 if(pl_time!=0) //RTC read successful 00349 { 00350 // run the loop until end of schedule is reached or month and day are both zeros or future block is found 00351 //gPC.printf("\n\rRTC read success"); 00352 for(i=0;(i<192)&&(((uint16_t)((pl_block[i] & 0x3FE00000)>>21))!=0);i++) 00353 { 00354 if(((pl_block[i]>>4) & 0x0FFFFFFF)>pl_time) //Checking for future blocks 00355 { 00356 pl_next_index=i; 00357 gPC.printf("\n\rFuture block found at index = %d",pl_next_index); 00358 break; 00359 } 00360 } 00361 } 00362 if((pl_next_index==-1) || pl_time==0) //RTC read failed or Future block not found 00363 { 00364 if(PL_PREV_STATE==STATE_SCIENCE) 00365 { 00366 pl_main_flag = pl_main_flag & (~STATE_SCIENCE); 00367 pl_main_flag |= STATE_HIBERNATE; 00368 PL_STATE = 0x02; 00369 } 00370 else 00371 { 00372 pl_main_flag = pl_main_flag & (~STATE_SCIENCE); 00373 pl_main_flag |= PL_PREV_STATE; 00374 } 00375 if(pl_time==0) 00376 { 00377 gPC.printf("\n\rRTC read failed"); 00378 } 00379 if(pl_next_index==-1) 00380 { 00381 //gPC.printf("\n\rFuture block not found"); 00382 gPC.printf("\n\rpl_next_index = %d\n\r",pl_next_index); 00383 } 00384 //gPC.printf("\n\rNew pl_state = %d",(pl_main_flag&(~STATE_SCIENCE))>>2); 00385 } 00386 00387 //Processing the PL schedule 00388 if(((pl_block[pl_next_index-1] & UNEXECUTED)==3)||((pl_block[pl_next_index-1] & UNEXECUTED)==2)) 00389 { 00390 if(((pl_block[pl_next_index-1] & UNEXECUTED)==3)) 00391 gPC.printf("\n\rElapsed blocked not executed"); 00392 else 00393 gPC.printf("\n\rElapsed block marked for retry"); 00394 00395 gPC.printf("\n\r Retrieving pl_state from schedule"); 00396 if((pl_block[pl_next_index-1] & 0x0000000C)==0) 00397 { 00398 pl_main_flag = pl_main_flag & (~STATE_SCIENCE); 00399 pl_main_flag |= STATE_OFF; 00400 PL_STATE = 0x00; 00401 } 00402 if((pl_block[pl_next_index-1] & 0x0000000C)==4) 00403 { 00404 pl_main_flag = pl_main_flag & (~STATE_SCIENCE); 00405 pl_main_flag |= STATE_STANDBY; 00406 PL_STATE = 0x01; 00407 } 00408 if((pl_block[pl_next_index-1] & 0x0000000C)==8) 00409 { 00410 pl_main_flag = pl_main_flag & (~STATE_SCIENCE); 00411 pl_main_flag |= STATE_HIBERNATE; 00412 PL_STATE = 0x02; 00413 } 00414 if((pl_block[pl_next_index-1] & 0x0000000C)==12) 00415 { 00416 pl_main_flag = pl_main_flag & (~STATE_SCIENCE); 00417 pl_main_flag |= STATE_SCIENCE; 00418 PL_STATE = 0x03; 00419 } 00420 } 00421 else if((pl_block[pl_next_index-1] & UNEXECUTED)==1) 00422 { 00423 gPC.printf("\n\rElapsed block is executed"); 00424 pl_main_flag = pl_main_flag & (~PL_MAIN_STATUS); //Clearing pl_main status 00425 PL_MAIN_status = 0; 00426 print_exit(temp); 00427 return; 00428 } 00429 else if((pl_block[pl_next_index-1] & UNEXECUTED)==0) 00430 { 00431 //gPC.printf("\n\rEmpty Schedule Block"); 00432 pl_main_flag = pl_main_flag & (~PL_MAIN_STATUS); //Clearing pl_main status 00433 PL_MAIN_status = 0; 00434 print_exit(temp); 00435 return; 00436 } 00437 switch(pl_main_flag & STATE_SCIENCE) //Checking PL_STATE 00438 { 00439 case STATE_OFF: 00440 { 00441 gPC.printf("\n\rEntered PL_OFF case"); 00442 if(PL_STATUS!=0) 00443 { 00444 gPC.printf("\n\rCommanding PL_BEE to go to Standby State"); 00445 Base_tm *tm_ptr_standby; 00446 SET_PL_BEE_STANDBY(tm_ptr_standby); //No ack needed now 00447 gPC.printf("\n\rPowering OFF PL_BEE"); 00448 SET_PL_BEE_OFF; 00449 PL_STATUS=0; 00450 } 00451 pl_main_flag = pl_main_flag & (~PL_DISABLED); 00452 pl_main_flag |= PL_OFF; 00453 PL_STATUS = 0x00; 00454 pl_block[pl_next_index-1] &= (~UNEXECUTED); //changing exec_status 00455 pl_block[pl_next_index-1] |= EXECUTED; 00456 pl_main_flag = pl_main_flag & (~PL_MAIN_STATUS); //Clearing PL_MAIN_STATUS 00457 PL_MAIN_status = 0; 00458 print_processed_block(pl_next_index-1); 00459 print_exit(temp); 00460 return; 00461 } 00462 case STATE_STANDBY: 00463 { 00464 gPC.printf("\n\rEntered PL_STANDBY case"); 00465 if(PL_STATUS==0) 00466 { 00467 gPC.printf("\n\rPowering on PL_BEE"); 00468 SET_PL_BEE_ON; 00469 PL_STATUS=1; 00470 } 00471 gPC.printf("\n\rCommanding PL_BEE to go to Standby State"); 00472 Base_tm *tm_ptr_standby; 00473 SET_PL_BEE_STANDBY(tm_ptr_standby); 00474 if((pl_main_flag & PL_DISABLED)==PL_SUCCESS_I2C) 00475 { 00476 pl_main_flag = pl_main_flag & (~PL_DISABLED); 00477 pl_main_flag |= PL_STANDBY; 00478 PL_STATUS = 0x01; 00479 } 00480 pl_main_flag = pl_main_flag & (~PL_MAIN_STATUS); //Clearing PL_MAIN_STATUS 00481 PL_MAIN_status = 0; 00482 print_processed_block(pl_next_index-1); 00483 print_exit(temp); 00484 return; 00485 //////DELETE THE TM AND TC LATER 00486 } 00487 case STATE_HIBERNATE: 00488 { 00489 gPC.printf("\n\rEntered PL_HIBERNATE case"); 00490 if(POWER_LEVEL==2 || POWER_LEVEL==3 || POWER_LEVEL==0) 00491 { 00492 if(PL_STATUS==0) 00493 { 00494 gPC.printf("Powering on PL_BEE\r\n"); 00495 SET_PL_BEE_ON; 00496 PL_STATUS=1; 00497 } 00498 gPC.printf("\n\rCommanding PL_BEE to go to Hibernate State"); 00499 Base_tm *tm_ptr_hibernate; 00500 SET_PL_BEE_HIBERNATE(tm_ptr_hibernate); 00501 if((pl_main_flag & PL_DISABLED)==PL_SUCCESS_I2C) 00502 { 00503 pl_main_flag = pl_main_flag & (~PL_DISABLED); 00504 pl_main_flag |= PL_HIBERNATE; 00505 PL_STATUS = 0x02; 00506 } 00507 } 00508 else 00509 { 00510 pl_main_flag |= PL_LOW_POWER; 00511 PL_LOW_power = 1; 00512 if(PL_STATUS==0) 00513 { 00514 gPC.printf("\n\rPowering on PL_BEE"); 00515 SET_PL_BEE_ON; 00516 PL_STATUS=1; 00517 } 00518 gPC.printf("\n\rCommanding PL_BEE to go to Standby State"); 00519 Base_tm *tm_ptr_standby; 00520 SET_PL_BEE_STANDBY(tm_ptr_standby); 00521 if((pl_main_flag & PL_DISABLED)==PL_SUCCESS_I2C) 00522 { 00523 pl_main_flag = pl_main_flag & (~PL_DISABLED); 00524 pl_main_flag |= PL_STANDBY; 00525 PL_STATUS = 0x01; 00526 } 00527 pl_main_flag = pl_main_flag & (~PL_MAIN_STATUS); //Clearing PL_MAIN_STATUS 00528 PL_MAIN_status = 0; 00529 print_processed_block(pl_next_index-1); 00530 print_exit(temp); 00531 return; 00532 //////DELETE THE TM AND TC LATER 00533 } 00534 pl_main_flag = pl_main_flag & (~PL_MAIN_STATUS); //Clearing PL_MAIN_STATUS 00535 PL_MAIN_status = 0; 00536 print_processed_block(pl_next_index-1); 00537 print_exit(temp); 00538 return; 00539 //////DELETE THE TM LATER 00540 } 00541 case STATE_SCIENCE: 00542 { 00543 gPC.printf("\n\rEntered PL_SCIENCE case"); 00544 if(POWER_LEVEL==3 || POWER_LEVEL==0) //POWER_LEVEL = 0 = NA 00545 { 00546 gPC.printf("\n\rPOWER_LEVEL = 3 or NA"); 00547 if(PL_STATUS==0) 00548 { 00549 gPC.printf("\n\rPowering on PL_BEE"); 00550 SET_PL_BEE_ON; 00551 PL_STATUS=1; 00552 } 00553 gPC.printf("\n\rCommanding PL_BEE to go to Science State"); 00554 Base_tm *tm_ptr_science; 00555 SET_PL_BEE_SCIENCE(tm_ptr_science); 00556 if((pl_main_flag & PL_DISABLED)==PL_SUCCESS_I2C) 00557 { 00558 pl_main_flag = pl_main_flag & (~PL_DISABLED); 00559 pl_main_flag |= PL_SCIENCE; 00560 PL_STATUS = 0x03; 00561 } 00562 pl_main_flag = pl_main_flag & (~PL_MAIN_STATUS); //Clearing PL_MAIN_STATUS 00563 PL_MAIN_status = 0; 00564 print_processed_block(pl_next_index-1); 00565 print_exit(temp); 00566 return; 00567 } 00568 else 00569 { 00570 gPC.printf("\n\rPower level = 2,3 or NA"); 00571 pl_main_flag |= PL_LOW_POWER; 00572 PL_LOW_power = 1; 00573 if(POWER_LEVEL==2 || POWER_LEVEL==3 || POWER_LEVEL==0) 00574 { 00575 if(PL_STATUS==0) 00576 { 00577 gPC.printf("\n\rPowering on PL_BEE"); 00578 SET_PL_BEE_ON; 00579 PL_STATUS=1; 00580 } 00581 gPC.printf("\n\rCommanding PL_BEE to go to Hibernate State"); 00582 Base_tm *tm_ptr_hibernate; 00583 SET_PL_BEE_HIBERNATE(tm_ptr_hibernate); 00584 if((pl_main_flag & PL_DISABLED)==PL_SUCCESS_I2C) 00585 { 00586 pl_main_flag = pl_main_flag & (~PL_DISABLED); 00587 pl_main_flag |= PL_HIBERNATE; 00588 PL_STATUS = 0x02; 00589 } 00590 } 00591 else 00592 { 00593 pl_main_flag |= PL_LOW_POWER; 00594 PL_LOW_power = 1; 00595 if(PL_STATUS==0) 00596 { 00597 gPC.printf("\n\rPowering on PL_BEE"); 00598 SET_PL_BEE_ON; 00599 PL_STATUS=1; 00600 } 00601 gPC.printf("\n\rCommanding PL_BEE to go to Standby State"); 00602 Base_tm *tm_ptr_standby; 00603 SET_PL_BEE_STANDBY(tm_ptr_standby); 00604 if((pl_main_flag & PL_DISABLED)==PL_SUCCESS_I2C) 00605 { 00606 pl_main_flag = pl_main_flag & (~PL_DISABLED); 00607 pl_main_flag |= PL_STANDBY; 00608 PL_STATUS = 0x01; 00609 } 00610 pl_main_flag = pl_main_flag & (~PL_MAIN_STATUS); //Clearing PL_MAIN_STATUS 00611 PL_MAIN_status = 0; 00612 print_processed_block(pl_next_index-1); 00613 print_exit(temp); 00614 return; 00615 //////DELETE THE TM AND TC LATER 00616 } 00617 pl_main_flag = pl_main_flag & (~PL_MAIN_STATUS); //Clearing PL_MAIN_STATUS 00618 PL_MAIN_status = 0; 00619 print_processed_block(pl_next_index-1); 00620 print_exit(temp); 00621 return; 00622 //////DELETE THE TM LATER 00623 } 00624 } 00625 default: 00626 { 00627 gPC.printf("\n\rInvalid PL_STATE in block at index = %d",pl_next_index-1); 00628 pl_main_flag = pl_main_flag & (~PL_DISABLED); 00629 pl_main_flag |= PL_INVALID_STATE; 00630 PL_STATUS = 0x06; 00631 pl_block[pl_next_index-1] &= (~UNEXECUTED); //changing exec_status 00632 pl_block[pl_next_index-1] |= EXECUTED; 00633 pl_main_flag = pl_main_flag & (~PL_MAIN_STATUS); //Clearing PL_MAIN_STATUS 00634 PL_MAIN_status = 0; 00635 print_processed_block(pl_next_index-1); 00636 print_exit(temp); 00637 return; 00638 } 00639 } 00640 }
Generated on Tue Jul 26 2022 00:15:16 by
