CDMS_CODE_samp_23SEP_DMA_flag

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of CDMS_CODE_samp_23SEP_DMA by iitm sat

Committer:
ee12b079
Date:
Wed Jul 06 08:09:22 2016 +0000
Revision:
235:c127b15409b2
Parent:
225:e6a3ffe4a530
Child:
240:946a9342a95f
Integrated Chaitanya's changes for HK thread and FMS TCs

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ee12b079 210:f4acf895b598 1 int pl_next_index=-1;
ee12b079 210:f4acf895b598 2 uint8_t pl_main_flag=0;
ee12b079 210:f4acf895b598 3 uint8_t PL_PREV_STATE=0x00;
ee12b079 210:f4acf895b598 4 uint8_t POWER_LEVEL = 3; //Would be present in HK data extracted
ee12b079 210:f4acf895b598 5 uint32_t pl_block[192]={0};
ee12b079 210:f4acf895b598 6 uint32_t pl_time;
ee12b079 210:f4acf895b598 7 uint32_t TIME_LATEST_PL=0;
ee12b079 210:f4acf895b598 8 uint8_t i;
ee12b079 210:f4acf895b598 9 uint8_t PL_BEE_SW_STATUS=0;
ee12b079 210:f4acf895b598 10
ee12b079 210:f4acf895b598 11 //Serial pc(USBTX,USBRX);
ee12b079 210:f4acf895b598 12
ee12b079 210:f4acf895b598 13 #define PL_MAIN_STATUS 0x01
ee12b079 210:f4acf895b598 14 #define PL_LOW_POWER 0x02
ee12b079 210:f4acf895b598 15 #define STATE_OFF 0x00
ee12b079 210:f4acf895b598 16 #define STATE_STANDBY 0x04
ee12b079 210:f4acf895b598 17 #define STATE_HIBERNATE 0x08
ee12b079 210:f4acf895b598 18 #define STATE_SCIENCE 0x0C //also used as mask for PL_STATE
ee12b079 210:f4acf895b598 19 #define PL_OFF 0x00
ee12b079 210:f4acf895b598 20 #define PL_STANDBY 0x10
ee12b079 210:f4acf895b598 21 #define PL_HIBERNATE 0x20
ee12b079 210:f4acf895b598 22 #define PL_SCIENCE 0x30
ee12b079 210:f4acf895b598 23 #define PL_SUCCESS_I2C 0x40
ee12b079 210:f4acf895b598 24 #define PL_ERR_I2C 0x50
ee12b079 210:f4acf895b598 25 #define PL_INVALID_STATE 0x60
ee12b079 210:f4acf895b598 26 #define PL_DISABLED 0x70 //also used as mask for PL_STATUS
ee12b079 210:f4acf895b598 27 #define EXECUTED 0x00000001
ee12b079 210:f4acf895b598 28 #define RETRY 0x00000002
ee12b079 210:f4acf895b598 29 #define UNEXECUTED 0x00000003 //also used as mask for EXEC_STATUS
ee12b079 210:f4acf895b598 30
ee12b079 210:f4acf895b598 31
ee12b079 210:f4acf895b598 32 Base_tm* FCTN_CDMS_RLY_TMTC(Base_tc *tc_ptr);
ee12b079 210:f4acf895b598 33
ee12b079 210:f4acf895b598 34 // waiting 1us for setup time,hold time and propagation delay
ee12b079 210:f4acf895b598 35 #define SET_PL_BEE_OFF {\
ee12b079 210:f4acf895b598 36 PYLD_DFF_CLK = 0;\
ee12b079 210:f4acf895b598 37 PYLD_DFF = 0;\
ee12b079 210:f4acf895b598 38 wait_us(1);\
ee12b079 210:f4acf895b598 39 PYLD_DFF_CLK = 1;\
ee12b079 210:f4acf895b598 40 wait_us(1);\
ee12b079 210:f4acf895b598 41 PYLD_DFF_CLK = 0;\
ee12b079 210:f4acf895b598 42 wait_us(1);\
ee12b079 210:f4acf895b598 43 }
ee12b079 210:f4acf895b598 44 #define SET_PL_BEE_ON {\
ee12b079 210:f4acf895b598 45 PYLD_DFF_CLK = 0;\
ee12b079 210:f4acf895b598 46 PYLD_DFF = 1;\
ee12b079 210:f4acf895b598 47 wait_us(1);\
ee12b079 210:f4acf895b598 48 PYLD_DFF_CLK = 1;\
ee12b079 210:f4acf895b598 49 wait_us(1);\
ee12b079 210:f4acf895b598 50 PYLD_DFF_CLK = 0;\
ee12b079 210:f4acf895b598 51 wait_us(1);\
ee12b079 210:f4acf895b598 52 }
ee12b079 210:f4acf895b598 53
ee12b079 210:f4acf895b598 54 //TC_string[0] should not be 0x00
ee12b079 210:f4acf895b598 55
ee12b079 210:f4acf895b598 56 #define SET_PL_BEE_STANDBY(tm_ptr_standby) {\
ee12b079 210:f4acf895b598 57 Base_tc *pl_tc_standby = new Short_tc;\
ee12b079 210:f4acf895b598 58 pl_tc_standby->next_TC = NULL;\
ee12b079 210:f4acf895b598 59 PUTshort_or_long(pl_tc_standby,0);\
ee12b079 210:f4acf895b598 60 PUTcrc_pass(pl_tc_standby,0x1);\
ee12b079 210:f4acf895b598 61 PUTexec_status(pl_tc_standby,0);\
ee12b079 210:f4acf895b598 62 pl_tc_standby->TC_string[0] = 0x01;\
ee12b079 210:f4acf895b598 63 pl_tc_standby->TC_string[1] = 0xE1;\
ee12b079 210:f4acf895b598 64 pl_tc_standby->TC_string[2] = 0x81;\
ee12b079 210:f4acf895b598 65 pl_tc_standby->TC_string[3] = 0x02;\
ee12b079 210:f4acf895b598 66 pl_tc_standby->TC_string[4] = 0;\
ee12b079 210:f4acf895b598 67 pl_tc_standby->TC_string[5] = 0;\
ee12b079 210:f4acf895b598 68 pl_tc_standby->TC_string[6] = 0;\
ee12b079 210:f4acf895b598 69 pl_tc_standby->TC_string[7] = 0;\
ee12b079 210:f4acf895b598 70 pl_tc_standby->TC_string[8] = 0;\
ee12b079 210:f4acf895b598 71 uint16_t crc16 = crc16_gen(pl_tc_standby->TC_string, 9);\
ee12b079 210:f4acf895b598 72 pl_tc_standby->TC_string[9] = (uint8_t)(crc16 & 0xFF00)>>8;\
ee12b079 210:f4acf895b598 73 pl_tc_standby->TC_string[10] = (uint8_t)(crc16 & 0x00FF);\
ee12b079 210:f4acf895b598 74 tm_ptr_standby = FCTN_CDMS_RLY_TMTC(pl_tc_standby);\
ee12b079 210:f4acf895b598 75 VERIFY_TM(tm_ptr_standby);\
chaithanyarss 225:e6a3ffe4a530 76 delete pl_tc_standby;\
chaithanyarss 225:e6a3ffe4a530 77 delete tm_ptr_standby;\
ee12b079 210:f4acf895b598 78 }
ee12b079 210:f4acf895b598 79
ee12b079 210:f4acf895b598 80 //TC_string[0] should not be 0x00
ee12b079 210:f4acf895b598 81
ee12b079 210:f4acf895b598 82 #define SET_PL_BEE_HIBERNATE(tm_ptr_hibernate) {\
ee12b079 210:f4acf895b598 83 Base_tc *pl_tc_hibernate = new Short_tc;\
ee12b079 210:f4acf895b598 84 pl_tc_hibernate->next_TC = NULL;\
ee12b079 210:f4acf895b598 85 PUTshort_or_long(pl_tc_hibernate,0);\
ee12b079 210:f4acf895b598 86 PUTcrc_pass(pl_tc_hibernate,0x1);\
ee12b079 210:f4acf895b598 87 PUTexec_status(pl_tc_hibernate,0);\
ee12b079 210:f4acf895b598 88 pl_tc_hibernate->TC_string[0] = 0x01;\
ee12b079 210:f4acf895b598 89 pl_tc_hibernate->TC_string[1] = 0xE1;\
ee12b079 210:f4acf895b598 90 pl_tc_hibernate->TC_string[2] = 0x81;\
ee12b079 210:f4acf895b598 91 pl_tc_hibernate->TC_string[3] = 0x03;\
ee12b079 210:f4acf895b598 92 pl_tc_hibernate->TC_string[4] = 0;\
ee12b079 210:f4acf895b598 93 pl_tc_hibernate->TC_string[5] = 0;\
ee12b079 210:f4acf895b598 94 pl_tc_hibernate->TC_string[6] = 0;\
ee12b079 210:f4acf895b598 95 pl_tc_hibernate->TC_string[7] = 0;\
ee12b079 210:f4acf895b598 96 pl_tc_hibernate->TC_string[8] = 0;\
ee12b079 210:f4acf895b598 97 uint16_t crc16 = crc16_gen(pl_tc_hibernate->TC_string, 9);\
ee12b079 210:f4acf895b598 98 pl_tc_hibernate->TC_string[9] = (uint8_t)(crc16 & 0xFF00)>>8;\
ee12b079 210:f4acf895b598 99 pl_tc_hibernate->TC_string[10] = (uint8_t)(crc16 & 0x00FF);\
ee12b079 210:f4acf895b598 100 tm_ptr_hibernate = FCTN_CDMS_RLY_TMTC(pl_tc_hibernate);\
ee12b079 210:f4acf895b598 101 VERIFY_TM(tm_ptr_hibernate);\
chaithanyarss 225:e6a3ffe4a530 102 delete pl_tc_hibernate;\
chaithanyarss 225:e6a3ffe4a530 103 delete tm_ptr_hibernate;\
ee12b079 210:f4acf895b598 104 }
ee12b079 210:f4acf895b598 105
ee12b079 210:f4acf895b598 106 //TC_string[0] should not be 0x00
ee12b079 210:f4acf895b598 107 /*
ee12b079 210:f4acf895b598 108 PUTshort_or_long(pl_tc_science,0);\
ee12b079 210:f4acf895b598 109 PUTcrc_pass(pl_tc_science,0x1);\
ee12b079 210:f4acf895b598 110 PUTexec_status(pl_tc_science,0);\*/
ee12b079 210:f4acf895b598 111
ee12b079 210:f4acf895b598 112 #define SET_PL_BEE_SCIENCE(tm_ptr_science) {\
ee12b079 210:f4acf895b598 113 Base_tc *pl_tc_science = new Short_tc;\
ee12b079 210:f4acf895b598 114 pl_tc_science->next_TC = NULL;\
ee12b079 210:f4acf895b598 115 pl_tc_science->TC_string[0] = 0x01;\
ee12b079 210:f4acf895b598 116 pl_tc_science->TC_string[1] = 0xE1;\
ee12b079 210:f4acf895b598 117 pl_tc_science->TC_string[2] = 0x81;\
ee12b079 210:f4acf895b598 118 pl_tc_science->TC_string[3] = 0x04;\
ee12b079 210:f4acf895b598 119 pl_tc_science->TC_string[4] = 0;\
ee12b079 210:f4acf895b598 120 pl_tc_science->TC_string[5] = 0;\
ee12b079 210:f4acf895b598 121 pl_tc_science->TC_string[6] = 0;\
ee12b079 210:f4acf895b598 122 pl_tc_science->TC_string[7] = 0;\
ee12b079 210:f4acf895b598 123 pl_tc_science->TC_string[8] = 0;\
ee12b079 210:f4acf895b598 124 uint16_t crc16 = crc16_gen(pl_tc_science->TC_string, 9);\
ee12b079 210:f4acf895b598 125 pl_tc_science->TC_string[9] = (uint8_t)(crc16 & 0xFF00)>>8;\
ee12b079 210:f4acf895b598 126 pl_tc_science->TC_string[10] = (uint8_t)(crc16 & 0x00FF);\
ee12b079 210:f4acf895b598 127 tm_ptr_science = FCTN_CDMS_RLY_TMTC(pl_tc_science);\
ee12b079 210:f4acf895b598 128 VERIFY_TM(tm_ptr_science);\
chaithanyarss 225:e6a3ffe4a530 129 delete pl_tc_science;\
chaithanyarss 225:e6a3ffe4a530 130 delete tm_ptr_science;\
ee12b079 210:f4acf895b598 131 }
ee12b079 210:f4acf895b598 132 void print_processed_block(uint8_t index)
ee12b079 210:f4acf895b598 133 {
ee12b079 210:f4acf895b598 134 gPC.printf("\n\n\rBlock after processing:");
ee12b079 210:f4acf895b598 135 gPC.printf("\n\rTime of block:");
ee12b079 210:f4acf895b598 136 gPC.printf("\n\rYear :%d",((((pl_block[index]&0xFFFFFFF0)>>4) & 0x0C000000)>>26)+2016);
ee12b079 210:f4acf895b598 137 gPC.printf("\tMonth :%d",((((pl_block[index]&0xFFFFFFF0)>>4) & 0x03C00000)>>22));
ee12b079 210:f4acf895b598 138 gPC.printf("\tDay :%d",((((pl_block[index]&0xFFFFFFF0)>>4) & 0x003E0000)>>17));
ee12b079 210:f4acf895b598 139 gPC.printf("\n\rHours :%d",((((pl_block[index]&0xFFFFFFF0)>>4) & 0x0001F000)>>12));
ee12b079 210:f4acf895b598 140 gPC.printf("\tMin :%d",((((pl_block[index]&0xFFFFFFF0)>>4) & 0x00000FC0)>>6));
ee12b079 210:f4acf895b598 141 gPC.printf("\tSec :%d",(((pl_block[index]&0xFFFFFFF0)>>4) & 0x0000003F));
ee12b079 210:f4acf895b598 142 gPC.printf("\n\rSID :%d",(pl_block[index] & 0x0000000C)>>2);
ee12b079 210:f4acf895b598 143 gPC.printf("\tExecution Status :%d",pl_block[index] & UNEXECUTED);
ee12b079 210:f4acf895b598 144 }
ee12b079 210:f4acf895b598 145 void print_exit(uint8_t* temp)
ee12b079 210:f4acf895b598 146 {
ee12b079 210:f4acf895b598 147 uint8_t temp2[3];
ee12b079 210:f4acf895b598 148 temp2[0] = (pl_main_flag&STATE_SCIENCE)>>2;
ee12b079 210:f4acf895b598 149 temp2[1] = (pl_main_flag&PL_DISABLED)>>4;
ee12b079 210:f4acf895b598 150 temp2[2] = (PL_PREV_STATE & STATE_SCIENCE)>>2;
ee12b079 210:f4acf895b598 151 gPC.printf("\n\rAt exit");
ee12b079 210:f4acf895b598 152 char state[][17] = {"STATE_OFF","STATE_STANDBY","STATE_HIBERNATE","STATE_SCIENCE"};
ee12b079 210:f4acf895b598 153 char status[][17] = {"PL_OFF","PL_STANDBY","PL_HIBERNATE","PL_SCIENCE","PL_SUCCESS_I2C","PL_ERR_I2C","PL_INVALID_STATE","PL_DISABLED"};
ee12b079 210:f4acf895b598 154 gPC.printf("\n\rPL_state:%s -> %s",state[(uint8_t)temp[0]],state[(uint8_t)temp2[0]]);
ee12b079 210:f4acf895b598 155 gPC.printf("\n\rPL_status:%s -> %s",status[(uint8_t)temp[1]],status[(uint8_t)temp2[1]]);
ee12b079 210:f4acf895b598 156 gPC.printf("\n\rPL_PREV_state:%s -> %s",state[(uint8_t)temp[2]],state[(uint8_t)temp2[2]]);
ee12b079 210:f4acf895b598 157 }
ee12b079 210:f4acf895b598 158 void VERIFY_TM(Base_tm *tm_ptr)
ee12b079 210:f4acf895b598 159 {
ee12b079 210:f4acf895b598 160 uint8_t temp = tm_ptr->TM_string[2]; //Obatining ACK_CODE
ee12b079 210:f4acf895b598 161 if(GETshort_or_long_tm(tm_ptr)==1) //short TM
ee12b079 210:f4acf895b598 162 {
ee12b079 210:f4acf895b598 163 gPC.printf("\n\rSHORT TM received");
ee12b079 210:f4acf895b598 164 uint16_t crc16 = crc16_gen(tm_ptr->TM_string, 11);
ee12b079 210:f4acf895b598 165 if(tm_ptr->TM_string[12]==((uint8_t)(crc16 & 0x00FF)) && tm_ptr->TM_string[11]==((uint8_t)((crc16 & 0xFF00)>>8)))
ee12b079 210:f4acf895b598 166 {
ee12b079 210:f4acf895b598 167 if(temp!=0x00 && temp!=0x01 && temp!=0x02 && temp!=0x03 && temp!=0x84 && temp!=0x85)
ee12b079 210:f4acf895b598 168 {
ee12b079 210:f4acf895b598 169 gPC.printf("\n\rTime_Latest_PL Updated");
ee12b079 210:f4acf895b598 170 TIME_LATEST_PL = pl_time; //update latest time when I2C communication was successful
ee12b079 210:f4acf895b598 171 }
ee12b079 210:f4acf895b598 172 if(temp==0xA0 || temp==0xC0)
ee12b079 210:f4acf895b598 173 {
ee12b079 210:f4acf895b598 174 gPC.printf("\n\rACK_CODE Success");
ee12b079 210:f4acf895b598 175 if(temp==0xA0)
ee12b079 210:f4acf895b598 176 gPC.printf("\n\rACK_CODE = 0x%02X",temp);
ee12b079 210:f4acf895b598 177 else
ee12b079 210:f4acf895b598 178 gPC.printf("\n\rACK_CODE = 0x%02X",temp);
ee12b079 210:f4acf895b598 179 pl_main_flag = pl_main_flag & (~PL_DISABLED);
ee12b079 210:f4acf895b598 180 pl_main_flag |= PL_SUCCESS_I2C;
ee12b079 210:f4acf895b598 181 pl_block[pl_next_index-1] &= (~UNEXECUTED); //changing exec_status
ee12b079 210:f4acf895b598 182 pl_block[pl_next_index-1] |= EXECUTED;
ee12b079 210:f4acf895b598 183 }
ee12b079 210:f4acf895b598 184 else
ee12b079 210:f4acf895b598 185 {
ee12b079 210:f4acf895b598 186 gPC.printf("\n\rACK_CODE failure (0x%02X)",temp);
ee12b079 210:f4acf895b598 187 //gPC.printf("\n\rACK_CODE = 0x%02X",temp);
ee12b079 210:f4acf895b598 188 pl_main_flag = pl_main_flag & (~PL_DISABLED);
ee12b079 210:f4acf895b598 189 pl_main_flag |= PL_ERR_I2C;
ee12b079 210:f4acf895b598 190 pl_block[pl_next_index-1] &= (~UNEXECUTED); //changing exec_status
ee12b079 210:f4acf895b598 191 pl_block[pl_next_index-1] |= RETRY;
ee12b079 210:f4acf895b598 192 }
ee12b079 210:f4acf895b598 193 }
ee12b079 210:f4acf895b598 194 else
ee12b079 210:f4acf895b598 195 {
ee12b079 210:f4acf895b598 196 gPC.printf("\n\rShort_TM CRC failed");
ee12b079 210:f4acf895b598 197 pl_main_flag = pl_main_flag & (~PL_DISABLED);
ee12b079 210:f4acf895b598 198 pl_main_flag |= PL_ERR_I2C;
ee12b079 210:f4acf895b598 199 pl_block[pl_next_index-1] &= (~UNEXECUTED); //changing exec_status
ee12b079 210:f4acf895b598 200 pl_block[pl_next_index-1] |= RETRY;
ee12b079 210:f4acf895b598 201 }
ee12b079 210:f4acf895b598 202 }
ee12b079 210:f4acf895b598 203 else if(GETshort_or_long_tm(tm_ptr)==0) //LONG TM
ee12b079 210:f4acf895b598 204 {
ee12b079 210:f4acf895b598 205 gPC.printf("\n\rLONG TM received");
ee12b079 210:f4acf895b598 206 uint16_t crc16 = crc16_gen(tm_ptr->TM_string,132);
ee12b079 210:f4acf895b598 207 if(tm_ptr->TM_string[133]==((uint8_t)(crc16 & 0x00FF)) && tm_ptr->TM_string[132]==((uint8_t)((crc16 & 0xFF00)>>8)))
ee12b079 210:f4acf895b598 208 {
ee12b079 210:f4acf895b598 209 if(temp!=0x00 && temp!=0x01 && temp!=0x02 && temp!=0x03 && temp!=0x84 && temp!=0x85)
ee12b079 210:f4acf895b598 210 {
ee12b079 210:f4acf895b598 211 gPC.printf("\n\rTime_Latest_PL Updated");
ee12b079 210:f4acf895b598 212 TIME_LATEST_PL = pl_time; //update latest time when I2C communication was successful
ee12b079 210:f4acf895b598 213 }
ee12b079 210:f4acf895b598 214 if(temp==0xA0 || temp==0xC0)
ee12b079 210:f4acf895b598 215 {
ee12b079 210:f4acf895b598 216 gPC.printf("\n\rACK_CODE Success");
ee12b079 210:f4acf895b598 217 if(temp==0xA0)
ee12b079 210:f4acf895b598 218 gPC.printf("\n\rACK_CODE = 0x%02X",temp);
ee12b079 210:f4acf895b598 219 else
ee12b079 210:f4acf895b598 220 gPC.printf("\n\rACK_CODE = 0x%02X",temp);
ee12b079 210:f4acf895b598 221 pl_main_flag = pl_main_flag & (~PL_DISABLED);
ee12b079 210:f4acf895b598 222 pl_main_flag |= PL_SUCCESS_I2C;
ee12b079 210:f4acf895b598 223 pl_block[pl_next_index-1] &= (~UNEXECUTED); //changing exec_status
ee12b079 210:f4acf895b598 224 pl_block[pl_next_index-1] |= EXECUTED;
ee12b079 210:f4acf895b598 225 }
ee12b079 210:f4acf895b598 226 else
ee12b079 210:f4acf895b598 227 {
ee12b079 210:f4acf895b598 228 gPC.printf("\n\rACK_CODE failure (0x%02X)",temp);
ee12b079 210:f4acf895b598 229 pl_main_flag = pl_main_flag & (~PL_DISABLED);
ee12b079 210:f4acf895b598 230 pl_main_flag |= PL_ERR_I2C;
ee12b079 210:f4acf895b598 231 pl_block[pl_next_index-1] &= (~UNEXECUTED); //changing exec_status
ee12b079 210:f4acf895b598 232 pl_block[pl_next_index-1] |= RETRY;
ee12b079 210:f4acf895b598 233 }
ee12b079 210:f4acf895b598 234 }
ee12b079 210:f4acf895b598 235 else
ee12b079 210:f4acf895b598 236 {
ee12b079 210:f4acf895b598 237 gPC.printf("\n\rLong_TM CRC failed");
ee12b079 210:f4acf895b598 238 pl_main_flag = pl_main_flag & (~PL_DISABLED);
ee12b079 210:f4acf895b598 239 pl_main_flag |= PL_ERR_I2C;
ee12b079 210:f4acf895b598 240 pl_block[pl_next_index-1] &= (~UNEXECUTED); //changing exec_status
ee12b079 210:f4acf895b598 241 pl_block[pl_next_index-1] |= RETRY;
ee12b079 210:f4acf895b598 242 }
ee12b079 210:f4acf895b598 243 }
ee12b079 210:f4acf895b598 244 }
ee12b079 210:f4acf895b598 245 void test1(uint8_t t)
ee12b079 210:f4acf895b598 246 {
ee12b079 210:f4acf895b598 247 //Output should be PL_STATUS = PL_DISABLED
ee12b079 210:f4acf895b598 248 if(t!=0)
ee12b079 210:f4acf895b598 249 {
ee12b079 210:f4acf895b598 250 gPC.printf("\n\rTesting OC protection");
ee12b079 210:f4acf895b598 251 PL_BEE_SW_STATUS = 2; //OC protection
ee12b079 210:f4acf895b598 252 }
ee12b079 210:f4acf895b598 253 }
ee12b079 210:f4acf895b598 254 void test2(uint8_t t)
ee12b079 210:f4acf895b598 255 {
ee12b079 210:f4acf895b598 256 //output should be same as test1()
ee12b079 210:f4acf895b598 257 if(t!=0)
ee12b079 210:f4acf895b598 258 {
ee12b079 210:f4acf895b598 259 gPC.printf("\n\rTesting Deviced Disabled case");
ee12b079 210:f4acf895b598 260 PL_BEE_SW_STATUS = 3; //Device DISABLED
ee12b079 210:f4acf895b598 261 }
ee12b079 210:f4acf895b598 262 }
ee12b079 210:f4acf895b598 263 void test3(uint8_t t)
ee12b079 210:f4acf895b598 264 {
ee12b079 210:f4acf895b598 265 if(t!=0)
ee12b079 210:f4acf895b598 266 {
ee12b079 210:f4acf895b598 267 gPC.printf("\n\rTesting RTC failed case");
ee12b079 210:f4acf895b598 268 pl_time = 0; //RTC failed
ee12b079 210:f4acf895b598 269 }
ee12b079 210:f4acf895b598 270 }
ee12b079 210:f4acf895b598 271 /*void test4(uint8_t t)
ee12b079 210:f4acf895b598 272 {
ee12b079 210:f4acf895b598 273 if(t!=0)
ee12b079 210:f4acf895b598 274 {
ee12b079 210:f4acf895b598 275 gPC.printf("\n\rTesting No future blocks available");
ee12b079 210:f4acf895b598 276 schedule1[0] = {0,0,0,0,0,0,0,0};
ee12b079 210:f4acf895b598 277 }
ee12b079 210:f4acf895b598 278 }*/
ee12b079 210:f4acf895b598 279 void FCTN_CDMS_PL_MAIN(void const *args)
ee12b079 210:f4acf895b598 280 {
ee12b079 210:f4acf895b598 281 uint8_t temp[3];
ee12b079 210:f4acf895b598 282 pl_main_flag|=PL_MAIN_STATUS; //Setting PL_MAIN_STATUS
ee12b079 210:f4acf895b598 283 PL_MAIN_COUNTER++;
ee12b079 210:f4acf895b598 284 pl_main_flag&=~(PL_LOW_POWER); //Clearing PL_LOW_POWER
ee12b079 210:f4acf895b598 285 temp[0] = (pl_main_flag&STATE_SCIENCE)>>2;
ee12b079 210:f4acf895b598 286 temp[1] = (pl_main_flag&PL_DISABLED)>>4;
ee12b079 210:f4acf895b598 287 temp[2] = (PL_PREV_STATE & STATE_SCIENCE)>>2;
ee12b079 210:f4acf895b598 288 //test2(1);
ee12b079 210:f4acf895b598 289
ee12b079 210:f4acf895b598 290 if(PL_BEE_SW_STATUS==2 || PL_BEE_SW_STATUS==3)
ee12b079 210:f4acf895b598 291 {
ee12b079 210:f4acf895b598 292 gPC.printf("\n\rDevice Disabled or OC Fault");
ee12b079 210:f4acf895b598 293 pl_main_flag = pl_main_flag & (~PL_DISABLED);
ee12b079 210:f4acf895b598 294 pl_main_flag |= PL_DISABLED; //setting PL_STATUS as PL_DISABLED
ee12b079 210:f4acf895b598 295 pl_main_flag = pl_main_flag & (~PL_MAIN_STATUS); //Clearing pl_main status
ee12b079 210:f4acf895b598 296 print_exit(temp);
ee12b079 210:f4acf895b598 297 return;
ee12b079 210:f4acf895b598 298 }
ee12b079 210:f4acf895b598 299 PL_PREV_STATE = (pl_main_flag & STATE_SCIENCE); //saving current pl_state
ee12b079 210:f4acf895b598 300 uint64_t temp_time;
ee12b079 210:f4acf895b598 301 temp_time=FCTN_CDMS_RD_RTC();
ee12b079 210:f4acf895b598 302 pl_time = (uint32_t)((temp_time>>7) & 0x000000000FFFFFFF);
ee12b079 210:f4acf895b598 303
ee12b079 210:f4acf895b598 304 //call test3() here
ee12b079 210:f4acf895b598 305 //test3(1);
ee12b079 210:f4acf895b598 306
ee12b079 210:f4acf895b598 307 //gPC.printf("\n\rprev_state :%d",(PL_PREV_STATE)>>4);
ee12b079 210:f4acf895b598 308 gPC.printf("\n\n\rtTime_RTC:");
ee12b079 210:f4acf895b598 309 gPC.printf("\n\rYear :%d\t",((pl_time & 0x0C000000)>>26)+2016);
ee12b079 210:f4acf895b598 310 gPC.printf("Month :%d\t",((pl_time & 0x03C00000)>>22));
ee12b079 210:f4acf895b598 311 gPC.printf("Day :%d",((pl_time & 0x003E0000)>>17));
ee12b079 210:f4acf895b598 312 gPC.printf("\n\rHours :%d",((pl_time & 0x0001F000)>>12));
ee12b079 210:f4acf895b598 313 gPC.printf("\tMin :%d",((pl_time & 0x00000FC0)>>6));
ee12b079 210:f4acf895b598 314 gPC.printf("\t\tSec :%d",(pl_time & 0x0000003F));
ee12b079 210:f4acf895b598 315 if(pl_time!=0) //RTC read successful
ee12b079 210:f4acf895b598 316 {
ee12b079 210:f4acf895b598 317 // run the loop until end of schedule is reached or month and day are both zeros or future block is found
ee12b079 210:f4acf895b598 318 gPC.printf("\n\rRTC read success");
ee12b079 210:f4acf895b598 319 for(i=0;(i<192)&&(((uint16_t)((pl_block[i] & 0x3FE00000)>>21))!=0);i++)
ee12b079 210:f4acf895b598 320 {
ee12b079 210:f4acf895b598 321 if(((pl_block[i]>>4) & 0x0FFFFFFF)>pl_time) //Checking for future blocks
ee12b079 210:f4acf895b598 322 {
ee12b079 210:f4acf895b598 323 pl_next_index=i;
ee12b079 210:f4acf895b598 324 gPC.printf("\n\rFuture block found at index = %d",pl_next_index);
ee12b079 210:f4acf895b598 325 break;
ee12b079 210:f4acf895b598 326 }
ee12b079 210:f4acf895b598 327 }
ee12b079 210:f4acf895b598 328 }
ee12b079 210:f4acf895b598 329 if((pl_next_index==-1) || pl_time==0) //RTC read failed or Future block not found
ee12b079 210:f4acf895b598 330 {
ee12b079 210:f4acf895b598 331 if(PL_PREV_STATE==STATE_SCIENCE)
ee12b079 210:f4acf895b598 332 {
ee12b079 210:f4acf895b598 333 pl_main_flag = pl_main_flag & (~STATE_SCIENCE);
ee12b079 210:f4acf895b598 334 pl_main_flag |= STATE_HIBERNATE;
ee12b079 210:f4acf895b598 335 }
ee12b079 210:f4acf895b598 336 else
ee12b079 210:f4acf895b598 337 {
ee12b079 210:f4acf895b598 338 pl_main_flag = pl_main_flag & (~STATE_SCIENCE);
ee12b079 210:f4acf895b598 339 pl_main_flag |= PL_PREV_STATE;
ee12b079 210:f4acf895b598 340 }
ee12b079 210:f4acf895b598 341 if(pl_time==0)
ee12b079 210:f4acf895b598 342 {
ee12b079 210:f4acf895b598 343 gPC.printf("\n\rRTC read failed");
ee12b079 210:f4acf895b598 344 }
ee12b079 210:f4acf895b598 345 if(pl_next_index==-1)
ee12b079 210:f4acf895b598 346 {
ee12b079 210:f4acf895b598 347 gPC.printf("\n\rFuture block not found");
ee12b079 210:f4acf895b598 348 gPC.printf("\n\rpl_next_index = %d",pl_next_index);
ee12b079 210:f4acf895b598 349 }
ee12b079 210:f4acf895b598 350 gPC.printf("\n\rNew pl_state = %d",(pl_main_flag&(~STATE_SCIENCE))>>2);
ee12b079 210:f4acf895b598 351 }
ee12b079 210:f4acf895b598 352
ee12b079 210:f4acf895b598 353 //Processing the PL schedule
ee12b079 210:f4acf895b598 354 if(((pl_block[pl_next_index-1] & UNEXECUTED)==3)||((pl_block[pl_next_index-1] & UNEXECUTED)==2))
ee12b079 210:f4acf895b598 355 {
ee12b079 210:f4acf895b598 356 if(((pl_block[pl_next_index-1] & UNEXECUTED)==3))
ee12b079 210:f4acf895b598 357 gPC.printf("\n\rElapsed blocked not executed");
ee12b079 210:f4acf895b598 358 else
ee12b079 210:f4acf895b598 359 gPC.printf("\n\rElapsed block marked for retry");
ee12b079 210:f4acf895b598 360
ee12b079 210:f4acf895b598 361 gPC.printf("\n\r Retrieving pl_state from schedule");
ee12b079 210:f4acf895b598 362 if((pl_block[pl_next_index-1] & 0x0000000C)==0)
ee12b079 210:f4acf895b598 363 {
ee12b079 210:f4acf895b598 364 pl_main_flag = pl_main_flag & (~STATE_SCIENCE);
ee12b079 210:f4acf895b598 365 pl_main_flag |= STATE_OFF;
ee12b079 210:f4acf895b598 366 }
ee12b079 210:f4acf895b598 367 if((pl_block[pl_next_index-1] & 0x0000000C)==4)
ee12b079 210:f4acf895b598 368 {
ee12b079 210:f4acf895b598 369 pl_main_flag = pl_main_flag & (~STATE_SCIENCE);
ee12b079 210:f4acf895b598 370 pl_main_flag |= STATE_STANDBY;
ee12b079 210:f4acf895b598 371 }
ee12b079 210:f4acf895b598 372 if((pl_block[pl_next_index-1] & 0x0000000C)==8)
ee12b079 210:f4acf895b598 373 {
ee12b079 210:f4acf895b598 374 pl_main_flag = pl_main_flag & (~STATE_SCIENCE);
ee12b079 210:f4acf895b598 375 pl_main_flag |= STATE_HIBERNATE;
ee12b079 210:f4acf895b598 376 }
ee12b079 210:f4acf895b598 377 if((pl_block[pl_next_index-1] & 0x0000000C)==12)
ee12b079 210:f4acf895b598 378 {
ee12b079 210:f4acf895b598 379 pl_main_flag = pl_main_flag & (~STATE_SCIENCE);
ee12b079 210:f4acf895b598 380 pl_main_flag |= STATE_SCIENCE;
ee12b079 210:f4acf895b598 381 }
ee12b079 210:f4acf895b598 382 }
ee12b079 210:f4acf895b598 383 else if((pl_block[pl_next_index-1] & UNEXECUTED)==1)
ee12b079 210:f4acf895b598 384 {
ee12b079 210:f4acf895b598 385 gPC.printf("\n\rElapsed block is executed");
ee12b079 210:f4acf895b598 386 pl_main_flag = pl_main_flag & (~PL_MAIN_STATUS); //Clearing pl_main status
ee12b079 210:f4acf895b598 387 print_exit(temp);
ee12b079 210:f4acf895b598 388 return;
ee12b079 210:f4acf895b598 389 }
ee12b079 210:f4acf895b598 390 else if((pl_block[pl_next_index-1] & UNEXECUTED)==0)
ee12b079 210:f4acf895b598 391 {
ee12b079 210:f4acf895b598 392 gPC.printf("\n\rEmpty Schedule Block");
ee12b079 210:f4acf895b598 393 pl_main_flag = pl_main_flag & (~PL_MAIN_STATUS); //Clearing pl_main status
ee12b079 210:f4acf895b598 394 print_exit(temp);
ee12b079 210:f4acf895b598 395 return;
ee12b079 210:f4acf895b598 396 }
ee12b079 210:f4acf895b598 397 switch(pl_main_flag & STATE_SCIENCE) //Checking PL_STATE
ee12b079 210:f4acf895b598 398 {
ee12b079 210:f4acf895b598 399 case STATE_OFF:
ee12b079 210:f4acf895b598 400 {
ee12b079 210:f4acf895b598 401 gPC.printf("\n\rEntered PL_OFF case");
ee12b079 210:f4acf895b598 402 if(PL_BEE_SW_STATUS!=0)
ee12b079 210:f4acf895b598 403 {
ee12b079 210:f4acf895b598 404 gPC.printf("\n\rCommanding PL_BEE to go to Standby State");
ee12b079 210:f4acf895b598 405 Base_tm *tm_ptr_standby;
ee12b079 210:f4acf895b598 406 SET_PL_BEE_STANDBY(tm_ptr_standby); //No ack needed now
ee12b079 210:f4acf895b598 407 gPC.printf("\n\rPowering OFF PL_BEE");
ee12b079 210:f4acf895b598 408 SET_PL_BEE_OFF;
ee12b079 210:f4acf895b598 409 PL_BEE_SW_STATUS=0;
ee12b079 210:f4acf895b598 410 }
ee12b079 210:f4acf895b598 411 pl_main_flag = pl_main_flag & (~PL_DISABLED);
ee12b079 210:f4acf895b598 412 pl_main_flag |= PL_OFF;
ee12b079 210:f4acf895b598 413 pl_block[pl_next_index-1] &= (~UNEXECUTED); //changing exec_status
ee12b079 210:f4acf895b598 414 pl_block[pl_next_index-1] |= EXECUTED;
ee12b079 210:f4acf895b598 415 pl_main_flag = pl_main_flag & (~PL_MAIN_STATUS); //Clearing PL_MAIN_STATUS
ee12b079 210:f4acf895b598 416 print_processed_block(pl_next_index-1);
ee12b079 210:f4acf895b598 417 print_exit(temp);
ee12b079 210:f4acf895b598 418 return;
ee12b079 210:f4acf895b598 419 }
ee12b079 210:f4acf895b598 420 case STATE_STANDBY:
ee12b079 210:f4acf895b598 421 {
ee12b079 210:f4acf895b598 422 gPC.printf("\n\rEntered PL_STANDBY case");
ee12b079 210:f4acf895b598 423 if(PL_BEE_SW_STATUS==0)
ee12b079 210:f4acf895b598 424 {
ee12b079 210:f4acf895b598 425 gPC.printf("\n\rPowering on PL_BEE");
ee12b079 210:f4acf895b598 426 SET_PL_BEE_ON;
ee12b079 210:f4acf895b598 427 PL_BEE_SW_STATUS=1;
ee12b079 210:f4acf895b598 428 }
ee12b079 210:f4acf895b598 429 gPC.printf("\n\rCommanding PL_BEE to go to Standby State");
ee12b079 210:f4acf895b598 430 Base_tm *tm_ptr_standby;
ee12b079 210:f4acf895b598 431 SET_PL_BEE_STANDBY(tm_ptr_standby);
ee12b079 210:f4acf895b598 432 if((pl_main_flag & PL_DISABLED)==PL_SUCCESS_I2C)
ee12b079 210:f4acf895b598 433 {
ee12b079 210:f4acf895b598 434 pl_main_flag = pl_main_flag & (~PL_DISABLED);
ee12b079 210:f4acf895b598 435 pl_main_flag |= PL_STANDBY;
ee12b079 210:f4acf895b598 436 }
ee12b079 210:f4acf895b598 437 pl_main_flag = pl_main_flag & (~PL_MAIN_STATUS); //Clearing PL_MAIN_STATUS
ee12b079 210:f4acf895b598 438 print_processed_block(pl_next_index-1);
ee12b079 210:f4acf895b598 439 print_exit(temp);
ee12b079 210:f4acf895b598 440 return;
ee12b079 210:f4acf895b598 441 //////DELETE THE TM AND TC LATER
ee12b079 210:f4acf895b598 442 }
ee12b079 210:f4acf895b598 443 case STATE_HIBERNATE:
ee12b079 210:f4acf895b598 444 {
ee12b079 210:f4acf895b598 445 gPC.printf("\n\rEntered PL_HIBERNATE case");
ee12b079 210:f4acf895b598 446 if(POWER_LEVEL==2 || POWER_LEVEL==3 || POWER_LEVEL==0)
ee12b079 210:f4acf895b598 447 {
ee12b079 210:f4acf895b598 448 if(PL_BEE_SW_STATUS==0)
ee12b079 210:f4acf895b598 449 {
ee12b079 210:f4acf895b598 450 gPC.printf("Powering on PL_BEE\r\n");
ee12b079 210:f4acf895b598 451 SET_PL_BEE_ON;
ee12b079 210:f4acf895b598 452 PL_BEE_SW_STATUS=1;
ee12b079 210:f4acf895b598 453 }
ee12b079 210:f4acf895b598 454 gPC.printf("\n\rCommanding PL_BEE to go to Hibernate State");
ee12b079 210:f4acf895b598 455 Base_tm *tm_ptr_hibernate;
ee12b079 210:f4acf895b598 456 SET_PL_BEE_HIBERNATE(tm_ptr_hibernate);
ee12b079 210:f4acf895b598 457 if((pl_main_flag & PL_DISABLED)==PL_SUCCESS_I2C)
ee12b079 210:f4acf895b598 458 {
ee12b079 210:f4acf895b598 459 pl_main_flag = pl_main_flag & (~PL_DISABLED);
ee12b079 210:f4acf895b598 460 pl_main_flag |= PL_HIBERNATE;
ee12b079 210:f4acf895b598 461 }
ee12b079 210:f4acf895b598 462 }
ee12b079 210:f4acf895b598 463 else
ee12b079 210:f4acf895b598 464 {
ee12b079 210:f4acf895b598 465 pl_main_flag |= PL_LOW_POWER;
ee12b079 210:f4acf895b598 466 if(PL_BEE_SW_STATUS==0)
ee12b079 210:f4acf895b598 467 {
ee12b079 210:f4acf895b598 468 gPC.printf("\n\rPowering on PL_BEE");
ee12b079 210:f4acf895b598 469 SET_PL_BEE_ON;
ee12b079 210:f4acf895b598 470 PL_BEE_SW_STATUS=1;
ee12b079 210:f4acf895b598 471 }
ee12b079 210:f4acf895b598 472 gPC.printf("\n\rCommanding PL_BEE to go to Standby State");
ee12b079 210:f4acf895b598 473 Base_tm *tm_ptr_standby;
ee12b079 210:f4acf895b598 474 SET_PL_BEE_STANDBY(tm_ptr_standby);
ee12b079 210:f4acf895b598 475 if((pl_main_flag & PL_DISABLED)==PL_SUCCESS_I2C)
ee12b079 210:f4acf895b598 476 {
ee12b079 210:f4acf895b598 477 pl_main_flag = pl_main_flag & (~PL_DISABLED);
ee12b079 210:f4acf895b598 478 pl_main_flag |= PL_STANDBY;
ee12b079 210:f4acf895b598 479 }
ee12b079 210:f4acf895b598 480 pl_main_flag = pl_main_flag & (~PL_MAIN_STATUS); //Clearing PL_MAIN_STATUS
ee12b079 210:f4acf895b598 481 print_processed_block(pl_next_index-1);
ee12b079 210:f4acf895b598 482 print_exit(temp);
ee12b079 210:f4acf895b598 483 return;
ee12b079 210:f4acf895b598 484 //////DELETE THE TM AND TC LATER
ee12b079 210:f4acf895b598 485 }
ee12b079 210:f4acf895b598 486 pl_main_flag = pl_main_flag & (~PL_MAIN_STATUS); //Clearing PL_MAIN_STATUS
ee12b079 210:f4acf895b598 487 print_processed_block(pl_next_index-1);
ee12b079 210:f4acf895b598 488 print_exit(temp);
ee12b079 210:f4acf895b598 489 return;
ee12b079 210:f4acf895b598 490 //////DELETE THE TM LATER
ee12b079 210:f4acf895b598 491 }
ee12b079 210:f4acf895b598 492 case STATE_SCIENCE:
ee12b079 210:f4acf895b598 493 {
ee12b079 210:f4acf895b598 494 gPC.printf("\n\rEntered PL_SCIENCE case");
ee12b079 210:f4acf895b598 495 if(POWER_LEVEL==3 || POWER_LEVEL==0) //POWER_LEVEL = 0 = NA
ee12b079 210:f4acf895b598 496 {
ee12b079 210:f4acf895b598 497 gPC.printf("\n\rPOWER_LEVEL = 3 or NA");
ee12b079 210:f4acf895b598 498 if(PL_BEE_SW_STATUS==0)
ee12b079 210:f4acf895b598 499 {
ee12b079 210:f4acf895b598 500 gPC.printf("\n\rPowering on PL_BEE");
ee12b079 210:f4acf895b598 501 SET_PL_BEE_ON;
ee12b079 210:f4acf895b598 502 PL_BEE_SW_STATUS=1;
ee12b079 210:f4acf895b598 503 }
ee12b079 210:f4acf895b598 504 gPC.printf("\n\rCommanding PL_BEE to go to Science State");
ee12b079 210:f4acf895b598 505 Base_tm *tm_ptr_science;
ee12b079 210:f4acf895b598 506 SET_PL_BEE_SCIENCE(tm_ptr_science);
ee12b079 210:f4acf895b598 507 if((pl_main_flag & PL_DISABLED)==PL_SUCCESS_I2C)
ee12b079 210:f4acf895b598 508 {
ee12b079 210:f4acf895b598 509 pl_main_flag = pl_main_flag & (~PL_DISABLED);
ee12b079 210:f4acf895b598 510 pl_main_flag |= PL_SCIENCE;
ee12b079 210:f4acf895b598 511 }
ee12b079 210:f4acf895b598 512 pl_main_flag = pl_main_flag & (~PL_MAIN_STATUS); //Clearing PL_MAIN_STATUS
ee12b079 210:f4acf895b598 513 print_processed_block(pl_next_index-1);
ee12b079 210:f4acf895b598 514 print_exit(temp);
ee12b079 210:f4acf895b598 515 return;
ee12b079 210:f4acf895b598 516 }
ee12b079 210:f4acf895b598 517 else
ee12b079 210:f4acf895b598 518 {
ee12b079 210:f4acf895b598 519 gPC.printf("\n\rPower level = 2,3 or NA");
ee12b079 210:f4acf895b598 520 pl_main_flag |= PL_LOW_POWER;
ee12b079 210:f4acf895b598 521 if(POWER_LEVEL==2 || POWER_LEVEL==3 || POWER_LEVEL==0)
ee12b079 210:f4acf895b598 522 {
ee12b079 210:f4acf895b598 523 if(PL_BEE_SW_STATUS==0)
ee12b079 210:f4acf895b598 524 {
ee12b079 210:f4acf895b598 525 gPC.printf("\n\rPowering on PL_BEE");
ee12b079 210:f4acf895b598 526 SET_PL_BEE_ON;
ee12b079 210:f4acf895b598 527 PL_BEE_SW_STATUS=1;
ee12b079 210:f4acf895b598 528 }
ee12b079 210:f4acf895b598 529 gPC.printf("\n\rCommanding PL_BEE to go to Hibernate State");
ee12b079 210:f4acf895b598 530 Base_tm *tm_ptr_hibernate;
ee12b079 210:f4acf895b598 531 SET_PL_BEE_HIBERNATE(tm_ptr_hibernate);
ee12b079 210:f4acf895b598 532 if((pl_main_flag & PL_DISABLED)==PL_SUCCESS_I2C)
ee12b079 210:f4acf895b598 533 {
ee12b079 210:f4acf895b598 534 pl_main_flag = pl_main_flag & (~PL_DISABLED);
ee12b079 210:f4acf895b598 535 pl_main_flag |= PL_HIBERNATE;
ee12b079 210:f4acf895b598 536 }
ee12b079 210:f4acf895b598 537 }
ee12b079 210:f4acf895b598 538 else
ee12b079 210:f4acf895b598 539 {
ee12b079 210:f4acf895b598 540 pl_main_flag |= PL_LOW_POWER;
ee12b079 210:f4acf895b598 541 if(PL_BEE_SW_STATUS==0)
ee12b079 210:f4acf895b598 542 {
ee12b079 210:f4acf895b598 543 gPC.printf("\n\rPowering on PL_BEE");
ee12b079 210:f4acf895b598 544 SET_PL_BEE_ON;
ee12b079 210:f4acf895b598 545 PL_BEE_SW_STATUS=1;
ee12b079 210:f4acf895b598 546 }
ee12b079 210:f4acf895b598 547 gPC.printf("\n\rCommanding PL_BEE to go to Standby State");
ee12b079 210:f4acf895b598 548 Base_tm *tm_ptr_standby;
ee12b079 210:f4acf895b598 549 SET_PL_BEE_STANDBY(tm_ptr_standby);
ee12b079 210:f4acf895b598 550 if((pl_main_flag & PL_DISABLED)==PL_SUCCESS_I2C)
ee12b079 210:f4acf895b598 551 {
ee12b079 210:f4acf895b598 552 pl_main_flag = pl_main_flag & (~PL_DISABLED);
ee12b079 210:f4acf895b598 553 pl_main_flag |= PL_STANDBY;
ee12b079 210:f4acf895b598 554 }
ee12b079 210:f4acf895b598 555 pl_main_flag = pl_main_flag & (~PL_MAIN_STATUS); //Clearing PL_MAIN_STATUS
ee12b079 210:f4acf895b598 556 print_processed_block(pl_next_index-1);
ee12b079 210:f4acf895b598 557 print_exit(temp);
ee12b079 210:f4acf895b598 558 return;
ee12b079 210:f4acf895b598 559 //////DELETE THE TM AND TC LATER
ee12b079 210:f4acf895b598 560 }
ee12b079 210:f4acf895b598 561 pl_main_flag = pl_main_flag & (~PL_MAIN_STATUS); //Clearing PL_MAIN_STATUS
ee12b079 210:f4acf895b598 562 print_processed_block(pl_next_index-1);
ee12b079 210:f4acf895b598 563 print_exit(temp);
ee12b079 210:f4acf895b598 564 return;
ee12b079 210:f4acf895b598 565 //////DELETE THE TM LATER
ee12b079 210:f4acf895b598 566 }
ee12b079 210:f4acf895b598 567 }
ee12b079 210:f4acf895b598 568 default:
ee12b079 210:f4acf895b598 569 {
ee12b079 210:f4acf895b598 570 gPC.printf("\n\rInvalid PL_STATE in block at index = %d",pl_next_index-1);
ee12b079 210:f4acf895b598 571 pl_main_flag = pl_main_flag & (~PL_DISABLED);
ee12b079 210:f4acf895b598 572 pl_main_flag |= PL_INVALID_STATE;
ee12b079 210:f4acf895b598 573 pl_block[pl_next_index-1] &= (~UNEXECUTED); //changing exec_status
ee12b079 210:f4acf895b598 574 pl_block[pl_next_index-1] |= EXECUTED;
ee12b079 210:f4acf895b598 575 pl_main_flag = pl_main_flag & (~PL_MAIN_STATUS); //Clearing PL_MAIN_STATUS
ee12b079 210:f4acf895b598 576 print_processed_block(pl_next_index-1);
ee12b079 210:f4acf895b598 577 print_exit(temp);
ee12b079 210:f4acf895b598 578 return;
ee12b079 210:f4acf895b598 579 }
ee12b079 210:f4acf895b598 580 }
ee12b079 210:f4acf895b598 581 }