publishing to check changes in cdms code

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of CDMS_CODE_samp_23SEP_DMA_flag by samp Srinivasan

Committer:
chaithanyarss
Date:
Sat Aug 06 05:54:53 2016 +0000
Revision:
283:5ea9ea429b55
Parent:
282:74a04dec4b95
CDMS V1.1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shreeshas95 103:b55559925dc1 1 void FCTN_CDMS_HK_MAIN();
shreeshas95 103:b55559925dc1 2 void FCTN_CDMS_HK();
ee12b079 210:f4acf895b598 3 void VERIFY_COMRX();
ee12b079 210:f4acf895b598 4 void VERIFY_RTC();
ee12b079 210:f4acf895b598 5 void CDMS_HK_SD();
ee12b079 210:f4acf895b598 6 void HANDLE_HW_FAULTS();
ee12b079 210:f4acf895b598 7 void HANDLE_HW_FAULT_SD();
ee12b079 210:f4acf895b598 8 void HANDLE_HW_FAULT_BAE();
ee12b079 210:f4acf895b598 9 void HANDLE_HW_FAULT_PL();
ee12b079 210:f4acf895b598 10 void FUNC_CDMS_GPIO_STATUS();
ee12b079 210:f4acf895b598 11 void minMaxHkData();
ee12b079 210:f4acf895b598 12 void COLLECT_CDMS_RAM();
shreeshas95 103:b55559925dc1 13
ee12b079 279:9501ee30957d 14 extern uint8_t beacon_array[134];
ee12b079 279:9501ee30957d 15
ee12b079 210:f4acf895b598 16 AnalogIn TempInput(PIN27); // Input from Current Multiplexer
shreeshas95 103:b55559925dc1 17 AnalogIn CDMS_temp_sensor(PIN53);
ee12b079 210:f4acf895b598 18 AnalogIn COMRX_RSSI_volatge(PIN70);
ee12b079 210:f4acf895b598 19
shreeshas95 103:b55559925dc1 20
shreeshas95 103:b55559925dc1 21 DigitalOut SelectLinec3 (PIN79); // MSB of Select Lines
shreeshas95 103:b55559925dc1 22 DigitalOut SelectLinec2 (PIN78);
shreeshas95 103:b55559925dc1 23 DigitalOut SelectLinec1 (PIN77);
shreeshas95 103:b55559925dc1 24 DigitalOut SelectLinec0 (PIN76); // LSB of Select Lines
shreeshas95 103:b55559925dc1 25
chaithanyarss 251:c766afa330a3 26 Convolution CDMS_HEALTH;
chaithanyarss 251:c766afa330a3 27 Convolution BAE_HEALTH;
chaithanyarss 251:c766afa330a3 28 unsigned char CDMS_HK_FRAME[134] = {0};
chaithanyarss 251:c766afa330a3 29 char BAE_HK[134] = {0};
chaithanyarss 251:c766afa330a3 30 uint8_t convoluted_CDMS_HK[270];
chaithanyarss 251:c766afa330a3 31 uint8_t interleave_CDMS_HK[288];
chaithanyarss 251:c766afa330a3 32 uint8_t CDMS_HEALTH_FINAL[512] = {0};
chaithanyarss 251:c766afa330a3 33 uint8_t convoluted_BAE_HK[270];
chaithanyarss 251:c766afa330a3 34 uint8_t interleave_BAE_HK[288];
chaithanyarss 251:c766afa330a3 35 uint8_t BAE_HEALTH_FINAL[512] = {0};
chaithanyarss 251:c766afa330a3 36 unsigned char BAE_HK_FRAME[134] = {0};
chaithanyarss 251:c766afa330a3 37
chaithanyarss 251:c766afa330a3 38
chaithanyarss 251:c766afa330a3 39
shreeshas95 104:a50ae79ca36e 40 void FCTN_CDMS_HK_MAIN(void const *args)
shreeshas95 103:b55559925dc1 41 {
ee12b079 268:ded5306a1fd1 42 uint8_t sd_stat = 0;
chaithanyarss 282:74a04dec4b95 43 uint8_t hk_count=0;
ee12b079 245:da9d1bd999da 44 while(1)
ee12b079 245:da9d1bd999da 45 {
chaithanyarss 257:7d404e9dc9e2 46 gHK_THREAD->signal_wait(HK_SIGNAL);
chaithanyarss 282:74a04dec4b95 47 gMutex.lock();
chaithanyarss 282:74a04dec4b95 48 if(hk_count == 1 || hk_count == 2)
ee12b079 279:9501ee30957d 49 {
ee12b079 279:9501ee30957d 50 FCTN_CDMS_PL_MAIN((void const *)NULL);
chaithanyarss 282:74a04dec4b95 51 hk_count--;
ee12b079 279:9501ee30957d 52 continue;
ee12b079 279:9501ee30957d 53 }
chaithanyarss 282:74a04dec4b95 54 else if(hk_count == 0)
ee12b079 279:9501ee30957d 55 {
ee12b079 279:9501ee30957d 56 FCTN_CDMS_PL_MAIN((void const *)NULL);
chaithanyarss 282:74a04dec4b95 57 hk_count = 2;
ee12b079 279:9501ee30957d 58 }
chaithanyarss 261:1e54415b34d3 59 gPC.printf("\n\nEntering HK thread\n");
chaithanyarss 257:7d404e9dc9e2 60
ee12b079 279:9501ee30957d 61 if(EN_CDMS_HK == 0x00)
ee12b079 279:9501ee30957d 62 continue;
chaithanyarss 224:3ac1f91e0ebc 63 CDMS_HK_MAIN_STATUS = 0x01;
chaithanyarss 224:3ac1f91e0ebc 64 CDMS_HK_MAIN_COUNTER++;
ee12b079 210:f4acf895b598 65
chaithanyarss 282:74a04dec4b95 66 FCTN_CDMS_HK();//collects temperatures
chaithanyarss 282:74a04dec4b95 67 RSSI_volatge = COMRX_RSSI_volatge.read() * 3.3;//to be checked
chaithanyarss 224:3ac1f91e0ebc 68 VERIFY_COMRX();
chaithanyarss 224:3ac1f91e0ebc 69 VERIFY_RTC();
chaithanyarss 224:3ac1f91e0ebc 70 HANDLE_HW_FAULTS();
ee12b079 279:9501ee30957d 71 FUNC_CDMS_GPIO_STATUS();
chaithanyarss 257:7d404e9dc9e2 72
chaithanyarss 257:7d404e9dc9e2 73 uint8_t CDMS_quant[20];
chaithanyarss 257:7d404e9dc9e2 74 CDMS_quant[1]= (uint8_t)quant_data.CDMS_temp_quant;
chaithanyarss 257:7d404e9dc9e2 75 CDMS_quant[2]= (uint8_t)RSSI_volatge;
chaithanyarss 224:3ac1f91e0ebc 76 for(int i=0; i<16; i++) {
chaithanyarss 257:7d404e9dc9e2 77 CDMS_quant[i+4]= (uint8_t)quant_data.temp_quant[i];
chaithanyarss 224:3ac1f91e0ebc 78 }
chaithanyarss 224:3ac1f91e0ebc 79 minMaxHkData();
chaithanyarss 224:3ac1f91e0ebc 80
chaithanyarss 257:7d404e9dc9e2 81 CDMS_HEALTH_DATA[1] = GPIO_STATUS; //Reading GPIO Pins
chaithanyarss 257:7d404e9dc9e2 82 CDMS_HEALTH_DATA[0] = GPIO_STATUS >> 8;
chaithanyarss 257:7d404e9dc9e2 83 COLLECT_CDMS_RAM();
chaithanyarss 257:7d404e9dc9e2 84 for(int i = 0;i<84;i++)
chaithanyarss 257:7d404e9dc9e2 85 CDMS_HEALTH_DATA[2+i] = CDMS_RAM[i]; //Reading RAM parameters
chaithanyarss 257:7d404e9dc9e2 86 for(int i = 0;i<20;i++) //Collecting Data from Temp sensors
chaithanyarss 257:7d404e9dc9e2 87 CDMS_HEALTH_DATA[86+i] = CDMS_quant[i];
chaithanyarss 224:3ac1f91e0ebc 88
ee12b079 279:9501ee30957d 89 // Here: Have to FIT flash data.
chaithanyarss 282:74a04dec4b95 90 CDMS_HEALTH_DATA[106] = (EPS_V_A_EN_STATUS<<7) | ((BAE_STATUS<<5)&0x60) | ((SD_STATUS<<3)&0x18) | ((PL_STATUS<<1)&0x06) | (PL_EPS_LATCH_SW_EN & 0x01);
ee12b079 279:9501ee30957d 91 CDMS_HEALTH_DATA[107] = (RTC_INIT_STATUS<<6) | ((CDMS_RTC_DISABLE<<5)&0x20);
ee12b079 279:9501ee30957d 92 CDMS_HEALTH_DATA[108] = CDMS_RESET_COUNTER >>8;
ee12b079 279:9501ee30957d 93 CDMS_HEALTH_DATA[109] = CDMS_RESET_COUNTER;
ee12b079 279:9501ee30957d 94 CDMS_HEALTH_DATA[110] = TIME_LATEST_CDSMS_RESET >>24;
ee12b079 279:9501ee30957d 95 CDMS_HEALTH_DATA[111] = TIME_LATEST_CDSMS_RESET >>16;
ee12b079 279:9501ee30957d 96 CDMS_HEALTH_DATA[112] = TIME_LATEST_CDSMS_RESET >>8;
ee12b079 279:9501ee30957d 97 CDMS_HEALTH_DATA[113] = TIME_LATEST_CDSMS_RESET;
ee12b079 279:9501ee30957d 98 CDMS_HEALTH_DATA[114] = COM_TC_BYTES_LIMIT>>8;
ee12b079 279:9501ee30957d 99 CDMS_HEALTH_DATA[115] = COM_TC_BYTES_LIMIT;
ee12b079 279:9501ee30957d 100 CDMS_HEALTH_DATA[116] = COM_RX_CURRENT_MAX;
ee12b079 279:9501ee30957d 101 CDMS_HEALTH_DATA[117] = COM_RX_DISABLE_TIMEOUT;
ee12b079 279:9501ee30957d 102 CDMS_HEALTH_DATA[118] = COM_PA_TMP_HIGH;
ee12b079 279:9501ee30957d 103 CDMS_HEALTH_DATA[119] = COM_PA_RECOVERY_TIMEOUT;
ee12b079 279:9501ee30957d 104 CDMS_HEALTH_DATA[120] = COM_SESSION_TIMEOUT;
ee12b079 279:9501ee30957d 105 CDMS_HEALTH_DATA[121] = COM_RSSI_MIN;
ee12b079 279:9501ee30957d 106 CDMS_HEALTH_DATA[122] = SD_LIB_BLK_CURRENT>>8;
ee12b079 279:9501ee30957d 107 CDMS_HEALTH_DATA[122] = SD_LIB_BLK_CURRENT;
chaithanyarss 257:7d404e9dc9e2 108
chaithanyarss 257:7d404e9dc9e2 109 uint64_t time = FCTN_CDMS_RD_RTC() >> 7; //Reading Time from RTC
chaithanyarss 257:7d404e9dc9e2 110 for(int i = 124; i<128; i++)
chaithanyarss 257:7d404e9dc9e2 111 CDMS_HEALTH_DATA[i] = time >> i*8;
chaithanyarss 282:74a04dec4b95 112 gPC.printf("0x%d\n",time);
chaithanyarss 224:3ac1f91e0ebc 113 FCTN_SD_MNGR(); //Adding FSC & TMID to TM frame
chaithanyarss 224:3ac1f91e0ebc 114 CDMS_HK_FRAME[0] = 0x20;
chaithanyarss 224:3ac1f91e0ebc 115 CDMS_HK_FRAME[1] = FSC_CURRENT[4]+1;
chaithanyarss 224:3ac1f91e0ebc 116 CDMS_HK_FRAME[2] = (FSC_CURRENT[4]+1) >> 8;
chaithanyarss 224:3ac1f91e0ebc 117 CDMS_HK_FRAME[3] = (FSC_CURRENT[4]+1) >> 16;
chaithanyarss 257:7d404e9dc9e2 118
chaithanyarss 224:3ac1f91e0ebc 119 for(int i = 0; i<128; i++) /*Adding actual CDMS Health data to TM frame*/
chaithanyarss 224:3ac1f91e0ebc 120 CDMS_HK_FRAME[4+i] = CDMS_HEALTH_DATA[i];
chaithanyarss 224:3ac1f91e0ebc 121
chaithanyarss 224:3ac1f91e0ebc 122 uint16_t crc = crc16_gen(CDMS_HK_FRAME,132); /*Adding CRC to TM frame*/
chaithanyarss 224:3ac1f91e0ebc 123 CDMS_HK_FRAME[133] = crc;
chaithanyarss 224:3ac1f91e0ebc 124 CDMS_HK_FRAME[132] = crc >> 8;
chaithanyarss 257:7d404e9dc9e2 125
chaithanyarss 251:c766afa330a3 126 exor(CDMS_HK_FRAME);
chaithanyarss 251:c766afa330a3 127 CDMS_HEALTH.convolutionEncode(CDMS_HK_FRAME , convoluted_CDMS_HK);
chaithanyarss 251:c766afa330a3 128 CDMS_HEALTH.convolutionEncode(CDMS_HK_FRAME + 67, convoluted_CDMS_HK + 135);
chaithanyarss 251:c766afa330a3 129 interleave(convoluted_CDMS_HK , interleave_CDMS_HK);
chaithanyarss 251:c766afa330a3 130 interleave(convoluted_CDMS_HK +135, interleave_CDMS_HK + 144);
ee12b079 247:d0be0773b951 131 for(int i=0; i<288; i++)
ee12b079 247:d0be0773b951 132 CDMS_HEALTH_FINAL[i] = interleave_CDMS_HK[i];
ee12b079 247:d0be0773b951 133
ee12b079 268:ded5306a1fd1 134 sd_stat = SD_WRITE(CDMS_HEALTH_FINAL,FSC_CURRENT[4]+1,4);
ee12b079 268:ded5306a1fd1 135 if(sd_stat)
ee12b079 268:ded5306a1fd1 136 {
ee12b079 268:ded5306a1fd1 137 gPC.puts("sd write failure");
ee12b079 268:ded5306a1fd1 138 break;
ee12b079 268:ded5306a1fd1 139 }
ee12b079 279:9501ee30957d 140 gPC.printf("Completed CDMS HK\t");
ee12b079 247:d0be0773b951 141
ee12b079 247:d0be0773b951 142 /*---------------------------------- BAE HK --------------------------------------------*/
ee12b079 247:d0be0773b951 143
chaithanyarss 224:3ac1f91e0ebc 144 BAE_HK_I2C = FCTN_I2C_READ(BAE_HK,134);
ee12b079 279:9501ee30957d 145 gPC.printf("Entering BAE HK\t");
chaithanyarss 224:3ac1f91e0ebc 146 if(BAE_HK_I2C == 0) {
ee12b079 245:da9d1bd999da 147 crc = crc16_gen((unsigned char *)BAE_HK,132);
ee12b079 245:da9d1bd999da 148 if(crc == ((uint16_t)BAE_HK[132] << 8) | (uint16_t)BAE_HK[133]){
chaithanyarss 283:5ea9ea429b55 149 gPC.printf("BAE HK data recieved through I2C\t");
ee12b079 245:da9d1bd999da 150 TIME_LATEST_I2C_BAE = FCTN_CDMS_RD_RTC() >> 7;
chaithanyarss 261:1e54415b34d3 151 /*for(int i = 0; i<15; i++)
chaithanyarss 261:1e54415b34d3 152 gPC.printf("\r 0x%02X\n",BAE_HK[i]);*/
ee12b079 245:da9d1bd999da 153 for(int i = 0; i<4; i++)
chaithanyarss 257:7d404e9dc9e2 154 BAE_HK[i] = time >> i;
ee12b079 245:da9d1bd999da 155 BAE_HK_FRAME[0] = 0x28;
ee12b079 245:da9d1bd999da 156 BAE_HK_FRAME[1] = FSC_CURRENT[5]+1;
ee12b079 245:da9d1bd999da 157 BAE_HK_FRAME[2] = (FSC_CURRENT[5]+1) >> 8;
ee12b079 245:da9d1bd999da 158 BAE_HK_FRAME[3] = (FSC_CURRENT[5]+1) >> 16;
ee12b079 245:da9d1bd999da 159 for(int i = 0; i<128; i++) /*Adding actual CDMS Health data to TM frame*/
ee12b079 245:da9d1bd999da 160 BAE_HK_FRAME[4+i] = BAE_HK[i];
ee12b079 245:da9d1bd999da 161 crc = crc16_gen(BAE_HK_FRAME,132); /*Adding CRC to TM frame*/
ee12b079 245:da9d1bd999da 162 BAE_HK_FRAME[133] = crc;
ee12b079 245:da9d1bd999da 163 BAE_HK_FRAME[132] = crc >> 8;
chaithanyarss 251:c766afa330a3 164 exor(BAE_HK_FRAME);
chaithanyarss 251:c766afa330a3 165 BAE_HEALTH.convolutionEncode(BAE_HK_FRAME , convoluted_BAE_HK);
chaithanyarss 251:c766afa330a3 166 BAE_HEALTH.convolutionEncode(BAE_HK_FRAME + 67, convoluted_BAE_HK + 135);
chaithanyarss 251:c766afa330a3 167 interleave(convoluted_BAE_HK , interleave_BAE_HK);
chaithanyarss 251:c766afa330a3 168 interleave(convoluted_BAE_HK +135, interleave_BAE_HK + 144);
ee12b079 247:d0be0773b951 169 for(int i=0; i<288; i++)
ee12b079 247:d0be0773b951 170 BAE_HEALTH_FINAL[i] = interleave_BAE_HK[i];
ee12b079 268:ded5306a1fd1 171 sd_stat = SD_WRITE(BAE_HEALTH_FINAL,FSC_CURRENT[5]+1,5);
ee12b079 268:ded5306a1fd1 172 if(sd_stat)
ee12b079 268:ded5306a1fd1 173 {
ee12b079 268:ded5306a1fd1 174 gPC.puts("sd write failure");
ee12b079 268:ded5306a1fd1 175 break;
ee12b079 268:ded5306a1fd1 176 }
ee12b079 245:da9d1bd999da 177 }
ee12b079 247:d0be0773b951 178
chaithanyarss 224:3ac1f91e0ebc 179 } else {
ee12b079 279:9501ee30957d 180 gPC.printf("BAE HK data not recieved through I2C\t");
ee12b079 245:da9d1bd999da 181 for(int i = 0; i<134; i++)
chaithanyarss 224:3ac1f91e0ebc 182 BAE_HK[i] = 0;
chaithanyarss 224:3ac1f91e0ebc 183 }
ee12b079 279:9501ee30957d 184 gPC.printf("Completed BAE HK\n");
chaithanyarss 224:3ac1f91e0ebc 185
chaithanyarss 224:3ac1f91e0ebc 186 /*----------------------------------Beacon message--------------------------------------*/
ee12b079 279:9501ee30957d 187
ee12b079 279:9501ee30957d 188
chaithanyarss 224:3ac1f91e0ebc 189 // Add HK bits
ee12b079 279:9501ee30957d 190 beacon_array[0] = 0x00;
ee12b079 279:9501ee30957d 191 beacon_array[1] = time >> 32;
ee12b079 279:9501ee30957d 192 beacon_array[2] = time >> 24;
ee12b079 279:9501ee30957d 193 beacon_array[3] = time >> 16;
ee12b079 279:9501ee30957d 194 beacon_array[4] = time >> 8;
ee12b079 279:9501ee30957d 195 beacon_array[5] = time;
ee12b079 279:9501ee30957d 196 beacon_array[6] = SD_FAULTCOUNT >> 8;
ee12b079 279:9501ee30957d 197 beacon_array[7] = SD_FAULTCOUNT;
ee12b079 279:9501ee30957d 198 beacon_array[8] = RTC_FAULTCOUNT >> 8;
ee12b079 279:9501ee30957d 199 beacon_array[9] = RTC_FAULTCOUNT;
ee12b079 279:9501ee30957d 200 beacon_array[10] = (((SD_STATUS == DEVICE_DISABLED || SD_STATUS == DEVICE_OC_FAULT)?1:0)<<7)|(RTC_STATUS <<6)|(COM_RX_STATUS<<3)|(V_C_PGOOD<<2)|(COMRX_OC_FAULT<<1)|(COMTX_OC_FAULT);
chaithanyarss 281:d1c9ae3605a3 201 beacon_array[11] = (COM_RX_CNTRL <<7)|(COM_TX_CNTRL);
ee12b079 279:9501ee30957d 202 beacon_array[12] = CDMS_HK_MAIN_COUNTER >>8;
ee12b079 279:9501ee30957d 203 beacon_array[13] = CDMS_HK_MAIN_COUNTER;
ee12b079 279:9501ee30957d 204 beacon_array[14] = PL_MAIN_COUNTER >>8;
ee12b079 279:9501ee30957d 205 beacon_array[15] = PL_MAIN_COUNTER;
ee12b079 279:9501ee30957d 206 beacon_array[16] = PL_RCV_SC_DATA_COUNTER >>8;
ee12b079 279:9501ee30957d 207 beacon_array[17] = PL_RCV_SC_DATA_COUNTER;
ee12b079 279:9501ee30957d 208 beacon_array[18] = TIME_LATEST_SPI_SPEED >>24;
ee12b079 279:9501ee30957d 209 beacon_array[19] = TIME_LATEST_SPI_SPEED >>16;
ee12b079 279:9501ee30957d 210 beacon_array[20] = TIME_LATEST_SPI_SPEED >>8;
ee12b079 279:9501ee30957d 211 beacon_array[21] = TIME_LATEST_SPI_SPEED;
ee12b079 279:9501ee30957d 212 beacon_array[22] = (uint8_t)RSSI_volatge;
ee12b079 279:9501ee30957d 213
chaithanyarss 224:3ac1f91e0ebc 214 // Add SC bits
ee12b079 279:9501ee30957d 215 crc = crc16_gen(beacon_array,132);
ee12b079 279:9501ee30957d 216 beacon_array[132] = crc;
ee12b079 279:9501ee30957d 217 beacon_array[133] = crc >> 8;
aniruddhv 264:f7d8f9f361e3 218 bool y;
ee12b079 279:9501ee30957d 219 y = FCTN_I2C_WRITE((char *)beacon_array,134);
aniruddhv 264:f7d8f9f361e3 220 if(y == 0)
ee12b079 279:9501ee30957d 221 gPC.printf("long Bcn sent\n\r");
aniruddhv 264:f7d8f9f361e3 222 else
aniruddhv 264:f7d8f9f361e3 223 gPC.printf("long Bcn not sent\r\n");
ee12b079 279:9501ee30957d 224 gPC.printf("\rCompleted Beacon\n");
chaithanyarss 251:c766afa330a3 225 gMutex.unlock();
ee12b079 245:da9d1bd999da 226 }
ee12b079 210:f4acf895b598 227 }
shreeshas95 103:b55559925dc1 228
shreeshas95 103:b55559925dc1 229 int quantiz(float start,float step,float x)
shreeshas95 103:b55559925dc1 230 {
shreeshas95 103:b55559925dc1 231 int y=(x-start)/step;
shreeshas95 103:b55559925dc1 232 if(y<=0)y=0;
shreeshas95 103:b55559925dc1 233 if(y>=255)y=255;
shreeshas95 103:b55559925dc1 234 return y;
shreeshas95 103:b55559925dc1 235 }
shreeshas95 103:b55559925dc1 236
ee12b079 210:f4acf895b598 237 char saveMin(char x,char y)
ee12b079 210:f4acf895b598 238 {
ee12b079 210:f4acf895b598 239 return (y<x)?y:x;
shreeshas95 103:b55559925dc1 240 }
ee12b079 210:f4acf895b598 241
ee12b079 210:f4acf895b598 242 char saveMax(char x,char y)
ee12b079 210:f4acf895b598 243 {
ee12b079 210:f4acf895b598 244 return (y>x)?y:x;
shreeshas95 103:b55559925dc1 245 }
ee12b079 210:f4acf895b598 246
ee12b079 210:f4acf895b598 247 void minMaxHkData()
chaithanyarss 224:3ac1f91e0ebc 248 {
chaithanyarss 224:3ac1f91e0ebc 249 if(firstCount==true) {
chaithanyarss 224:3ac1f91e0ebc 250 for (int i = 0; i < 16; ++i) {
chaithanyarss 224:3ac1f91e0ebc 251 min_max_data.temp_min[i] = quant_data.temp_quant[i];
chaithanyarss 224:3ac1f91e0ebc 252 min_max_data.temp_max[i] = quant_data.temp_quant[i];
shreeshas95 103:b55559925dc1 253 }
shreeshas95 103:b55559925dc1 254
shreeshas95 103:b55559925dc1 255 min_max_data.CDMS_temp_min=quant_data.CDMS_temp_quant;
shreeshas95 103:b55559925dc1 256 min_max_data.CDMS_temp_max=quant_data.CDMS_temp_quant;
chaithanyarss 224:3ac1f91e0ebc 257 } else {
chaithanyarss 224:3ac1f91e0ebc 258 for (int i = 0; i < 16; ++i) {
chaithanyarss 224:3ac1f91e0ebc 259 min_max_data.temp_min[i] = saveMin(min_max_data.temp_min[i],quant_data.temp_quant[i]);
chaithanyarss 224:3ac1f91e0ebc 260 min_max_data.temp_max[i] = saveMax(min_max_data.temp_max[i],quant_data.temp_quant[i]);
shreeshas95 103:b55559925dc1 261 }
chaithanyarss 224:3ac1f91e0ebc 262
ee12b079 210:f4acf895b598 263 min_max_data.CDMS_temp_min = saveMin(min_max_data.CDMS_temp_min,quant_data.CDMS_temp_quant);
ee12b079 210:f4acf895b598 264 min_max_data.CDMS_temp_max = saveMax(min_max_data.CDMS_temp_max,quant_data.CDMS_temp_quant);
chaithanyarss 224:3ac1f91e0ebc 265 }
shreeshas95 103:b55559925dc1 266 firstCount=false;
shreeshas95 103:b55559925dc1 267 }
shreeshas95 103:b55559925dc1 268
shreeshas95 103:b55559925dc1 269 void FCTN_CDMS_HK()
shreeshas95 103:b55559925dc1 270 {
chaithanyarss 224:3ac1f91e0ebc 271
shreeshas95 103:b55559925dc1 272 int Iteration=0;
chaithanyarss 282:74a04dec4b95 273 int resistance;
shreeshas95 103:b55559925dc1 274
shreeshas95 103:b55559925dc1 275 SelectLinec0=0;
shreeshas95 103:b55559925dc1 276 SelectLinec1=0;
shreeshas95 103:b55559925dc1 277 SelectLinec2=0;
shreeshas95 103:b55559925dc1 278 SelectLinec3=0;
shreeshas95 103:b55559925dc1 279
chaithanyarss 224:3ac1f91e0ebc 280 for(Iteration=0; Iteration<16; Iteration++) {
shreeshas95 103:b55559925dc1 281
shreeshas95 103:b55559925dc1 282 actual_data.temp_actual[Iteration]=TempInput.read();
shreeshas95 103:b55559925dc1 283
shreeshas95 103:b55559925dc1 284 SelectLinec0=!(SelectLinec0);
shreeshas95 103:b55559925dc1 285 if(Iteration%2==1)
shreeshas95 103:b55559925dc1 286 SelectLinec1=!(SelectLinec1);
shreeshas95 103:b55559925dc1 287 if(Iteration%4==3)
shreeshas95 103:b55559925dc1 288 SelectLinec2=!(SelectLinec2);
shreeshas95 103:b55559925dc1 289 if(Iteration%8==7)
chaithanyarss 224:3ac1f91e0ebc 290 SelectLinec3=!(SelectLinec3);
shreeshas95 103:b55559925dc1 291 }
shreeshas95 103:b55559925dc1 292
ee12b079 210:f4acf895b598 293 actual_data.CDMS_temp_actual=(-90.7*3.3*CDMS_temp_sensor.read())+190.1543;
shreeshas95 103:b55559925dc1 294
chaithanyarss 224:3ac1f91e0ebc 295 for(Iteration=0; Iteration<16; Iteration++) {
chaithanyarss 224:3ac1f91e0ebc 296
chaithanyarss 224:3ac1f91e0ebc 297 if(Iteration<14) {
shreeshas95 103:b55559925dc1 298 actual_data.temp_actual[Iteration]=actual_data.temp_actual[Iteration]*3.3;
shreeshas95 103:b55559925dc1 299 resistance=24000*actual_data.temp_actual[Iteration]/(3.3-actual_data.temp_actual[Iteration]);
chaithanyarss 282:74a04dec4b95 300
chaithanyarss 224:3ac1f91e0ebc 301 if(actual_data.temp_actual[Iteration]>1.47) {
shreeshas95 103:b55559925dc1 302 actual_data.temp_actual[Iteration]=3694/log(24.032242*resistance);
chaithanyarss 224:3ac1f91e0ebc 303 } else {
chaithanyarss 224:3ac1f91e0ebc 304
shreeshas95 103:b55559925dc1 305 actual_data.temp_actual[Iteration]=3365.4/log(7.60573*resistance);
shreeshas95 103:b55559925dc1 306 }
chaithanyarss 224:3ac1f91e0ebc 307 } else
shreeshas95 103:b55559925dc1 308 actual_data.temp_actual[Iteration]=(-90.7*3.3*actual_data.temp_actual[Iteration])+190.1543;
shreeshas95 103:b55559925dc1 309 }
shreeshas95 103:b55559925dc1 310
chaithanyarss 224:3ac1f91e0ebc 311 for(Iteration=0; Iteration<16; Iteration++) {
shreeshas95 103:b55559925dc1 312
chaithanyarss 224:3ac1f91e0ebc 313 if(Iteration<14) {
shreeshas95 103:b55559925dc1 314
shreeshas95 103:b55559925dc1 315 quant_data.temp_quant[Iteration]=quantiz(tstart_thermistor,tstep_thermistor,actual_data.temp_actual[Iteration]);
chaithanyarss 224:3ac1f91e0ebc 316 } else
shreeshas95 103:b55559925dc1 317 quant_data.temp_quant[Iteration]=quantiz(tstart,tstep,actual_data.temp_actual[Iteration]);
shreeshas95 103:b55559925dc1 318 }
shreeshas95 103:b55559925dc1 319
shreeshas95 103:b55559925dc1 320 quant_data.CDMS_temp_quant=quantiz(tstart,tstep,actual_data.CDMS_temp_actual);
shreeshas95 103:b55559925dc1 321
shreeshas95 103:b55559925dc1 322 minMaxHkData();
ee12b079 210:f4acf895b598 323 }
ee12b079 210:f4acf895b598 324
ee12b079 210:f4acf895b598 325 void FUNC_CDMS_GPIO_STATUS() //Polls the status of Input GPIO PINS
ee12b079 210:f4acf895b598 326 {
chaithanyarss 224:3ac1f91e0ebc 327 //V_A_PGOOD //TRZ EN
chaithanyarss 224:3ac1f91e0ebc 328 GPIO_STATUS=(V_A_PGOOD)?(GPIO_STATUS)||((uint16_t)(0x1<<15)):(GPIO_STATUS)&(~((uint16_t)(0x1<<15)));
chaithanyarss 224:3ac1f91e0ebc 329 //V_B_PGOOD_1 //3V3BPGOOD //$
chaithanyarss 224:3ac1f91e0ebc 330 GPIO_STATUS=(V_B_PGOOD_1)?(GPIO_STATUS)||((uint16_t)(0x1<<14)):(GPIO_STATUS)&(~((uint16_t)(0x1<<14)));
chaithanyarss 224:3ac1f91e0ebc 331 //V_B_PGOOD_2 //3V3BEN //$
chaithanyarss 224:3ac1f91e0ebc 332 GPIO_STATUS=(V_B_PGOOD_2)?(GPIO_STATUS)||((uint16_t)(0x1<<13)):(GPIO_STATUS)&(~((uint16_t)(0x1<<13)));
chaithanyarss 224:3ac1f91e0ebc 333 //V_C_PGOOD //3V3CPGOOD //$
chaithanyarss 224:3ac1f91e0ebc 334 GPIO_STATUS=(V_C_PGOOD)?(GPIO_STATUS)||((uint16_t)(0x1<<12)):(GPIO_STATUS)&(~((uint16_t)(0x1<<12)));
chaithanyarss 224:3ac1f91e0ebc 335 //COMRX_OC_FAULT //$
chaithanyarss 224:3ac1f91e0ebc 336 GPIO_STATUS=(COMRX_OC_FAULT)?(GPIO_STATUS)||((uint16_t)(0x1<<11)):(GPIO_STATUS)&(~((uint16_t)(0x1<<11)));
chaithanyarss 224:3ac1f91e0ebc 337 // COMTX_OC_FAULT //$
chaithanyarss 224:3ac1f91e0ebc 338 GPIO_STATUS=(COMTX_OC_FAULT)?(GPIO_STATUS)||((uint16_t)(0x1<<10)):(GPIO_STATUS)&(~((uint16_t)(0x1<<10)));
chaithanyarss 224:3ac1f91e0ebc 339 //BAE_OC_FAULT //$
chaithanyarss 224:3ac1f91e0ebc 340 GPIO_STATUS=(BAE_OC_FAULT)?(GPIO_STATUS)||((uint16_t)(0x1<<9)):(GPIO_STATUS)&(~((uint16_t)(0x1<<9)));
chaithanyarss 224:3ac1f91e0ebc 341 //PL_GPIO_1_STATUS //$
chaithanyarss 224:3ac1f91e0ebc 342 GPIO_STATUS=(PL_GPIO_1_STATUS)?(GPIO_STATUS)||((uint16_t)(0x1<<8)):(GPIO_STATUS)&(~((uint16_t)(0x1<<8)));
chaithanyarss 224:3ac1f91e0ebc 343 //PL_GPIO_2_STATUS //$
chaithanyarss 224:3ac1f91e0ebc 344 GPIO_STATUS=(PL_GPIO_2_STATUS)?(GPIO_STATUS)||((uint16_t)(0x1<<7)):(GPIO_STATUS)&(~((uint16_t)(0x1<<7)));
chaithanyarss 224:3ac1f91e0ebc 345 //PL_GPIO_3_STATUS //$
chaithanyarss 224:3ac1f91e0ebc 346 GPIO_STATUS=(PL_GPIO_3_STATUS)?(GPIO_STATUS)||((uint16_t)(0x1<<6)):(GPIO_STATUS)&(~((uint16_t)(0x1<<6)));
chaithanyarss 224:3ac1f91e0ebc 347 //PL_BEE_SW_OC_FAULT //to be verified
chaithanyarss 224:3ac1f91e0ebc 348 GPIO_STATUS=(PL_BEE_SW_OC_FAULT)?(GPIO_STATUS)||((uint16_t)(0x1<<5)):(GPIO_STATUS)&(~((uint16_t)(0x1<<5)));
chaithanyarss 224:3ac1f91e0ebc 349 //PL_EPS_LATCH_SW_OC_FAULT // to be verified
chaithanyarss 224:3ac1f91e0ebc 350 GPIO_STATUS=(PL_EPS_LATCH_SW_OC_FAULT)?(GPIO_STATUS)||((uint16_t)(0x1<<4)):(GPIO_STATUS)&(~((uint16_t)(0x1<<4)));
chaithanyarss 257:7d404e9dc9e2 351 //EPS_V_C_EN_STATUS
chaithanyarss 281:d1c9ae3605a3 352 GPIO_STATUS=(COM_RX_CNTRL)?(GPIO_STATUS)||((uint16_t)(0x1<<3)):(GPIO_STATUS)&(~((uint16_t)(0x1<<3)));
chaithanyarss 257:7d404e9dc9e2 353 //EPS_V_D_EN_STATUS
ee12b079 279:9501ee30957d 354 GPIO_STATUS=(COM_TX_CNTRL)?(GPIO_STATUS)||((uint16_t)(0x1<<2)):(GPIO_STATUS)&(~((uint16_t)(0x1<<2)));
ee12b079 245:da9d1bd999da 355
ee12b079 210:f4acf895b598 356 }
ee12b079 210:f4acf895b598 357
ee12b079 210:f4acf895b598 358 void VERIFY_COMRX()
ee12b079 210:f4acf895b598 359 {
chaithanyarss 224:3ac1f91e0ebc 360 //COMRX_OC_FAULT //$
chaithanyarss 282:74a04dec4b95 361 if(COMRX_OC_FAULT==0 && RSSI_volatge > 0.4) {
chaithanyarss 224:3ac1f91e0ebc 362 COMRX_STATUS = COMRX_ALIVE;
chaithanyarss 224:3ac1f91e0ebc 363 } else {
chaithanyarss 224:3ac1f91e0ebc 364 RESET_COMRX();
chaithanyarss 224:3ac1f91e0ebc 365 COMRX_RESET_COUNTER++;
chaithanyarss 282:74a04dec4b95 366 if(COMRX_OC_FAULT==0 && RSSI_volatge > 0.4)
chaithanyarss 224:3ac1f91e0ebc 367 COMRX_STATUS = COMRX_ALIVE;
chaithanyarss 224:3ac1f91e0ebc 368 else
chaithanyarss 224:3ac1f91e0ebc 369 COMRX_STATUS = COMRX_DEAD;
chaithanyarss 224:3ac1f91e0ebc 370 }
ee12b079 210:f4acf895b598 371 }
ee12b079 210:f4acf895b598 372
chaithanyarss 224:3ac1f91e0ebc 373 void VERIFY_RTC()
chaithanyarss 224:3ac1f91e0ebc 374 {
chaithanyarss 282:74a04dec4b95 375 uint8_t response;
chaithanyarss 282:74a04dec4b95 376 if(EN_RTC == 0x00)
chaithanyarss 282:74a04dec4b95 377 return;
chaithanyarss 224:3ac1f91e0ebc 378 gCS_RTC=1;
chaithanyarss 224:3ac1f91e0ebc 379 gCS_RTC=0;
chaithanyarss 224:3ac1f91e0ebc 380 spi.write(0x0F);
chaithanyarss 282:74a04dec4b95 381 response = spi.write(0x00);
chaithanyarss 282:74a04dec4b95 382 CDMS_RTC_BL = (response & 0x10) >>4;
chaithanyarss 282:74a04dec4b95 383 if(response & 0x04 == 0x04) {
chaithanyarss 282:74a04dec4b95 384 RESET_RTC();
ee12b079 279:9501ee30957d 385 RTC_STATUS = 0x01;
chaithanyarss 224:3ac1f91e0ebc 386 RTC_FAULTCOUNT++;
chaithanyarss 224:3ac1f91e0ebc 387 }
chaithanyarss 224:3ac1f91e0ebc 388 gCS_RTC=1;
ee12b079 210:f4acf895b598 389 }
ee12b079 210:f4acf895b598 390
ee12b079 210:f4acf895b598 391 void HANDLE_HW_FAULTS()
ee12b079 210:f4acf895b598 392 {
chaithanyarss 224:3ac1f91e0ebc 393 HANDLE_HW_FAULT_SD();
chaithanyarss 224:3ac1f91e0ebc 394 HANDLE_HW_FAULT_BAE();
chaithanyarss 224:3ac1f91e0ebc 395 HANDLE_HW_FAULT_PL();
ee12b079 210:f4acf895b598 396 }
ee12b079 210:f4acf895b598 397
ee12b079 210:f4acf895b598 398 void HANDLE_HW_FAULT_SD()
ee12b079 210:f4acf895b598 399 {
chaithanyarss 224:3ac1f91e0ebc 400 if(SD_STATUS != DEVICE_DISABLED) {
chaithanyarss 282:74a04dec4b95 401 if(SD_STATUS == DEVICE_OC_FAULT){
chaithanyarss 282:74a04dec4b95 402 gPC.printf("Switching on SD card");
chaithanyarss 281:d1c9ae3605a3 403 SD_SW_EN_DS = 1; //powering on SD
chaithanyarss 282:74a04dec4b95 404 wait_ms(10);
chaithanyarss 282:74a04dec4b95 405 }
chaithanyarss 282:74a04dec4b95 406
chaithanyarss 224:3ac1f91e0ebc 407 if(SD_OC_FAULT == 0) {
chaithanyarss 282:74a04dec4b95 408 gPC.printf("Switching off SD card");
chaithanyarss 281:d1c9ae3605a3 409 SD_SW_EN_DS = 0; //switching off SD card
chaithanyarss 224:3ac1f91e0ebc 410 SD_FAULTCOUNT++;
chaithanyarss 224:3ac1f91e0ebc 411 SD_STATUS = (SD_FAULTCOUNT == 3) ? DEVICE_DISABLED :DEVICE_OC_FAULT;
chaithanyarss 282:74a04dec4b95 412 if(SD_FAULTCOUNT == 3){
chaithanyarss 282:74a04dec4b95 413 FCTN_CDMS_WR_FLASH(2,DEVICE_DISABLED);
chaithanyarss 282:74a04dec4b95 414 gPC.printf("Declaring SD card permanantly Disabled");
chaithanyarss 282:74a04dec4b95 415 }
chaithanyarss 224:3ac1f91e0ebc 416 } else {
chaithanyarss 224:3ac1f91e0ebc 417 SD_STATUS = DEVICE_POWERED;
chaithanyarss 282:74a04dec4b95 418 if(SD_STATUS != DEVICE_POWERED)
chaithanyarss 282:74a04dec4b95 419 FCTN_CDMS_WR_FLASH(2,DEVICE_POWERED);
chaithanyarss 224:3ac1f91e0ebc 420 SD_FAULTCOUNT = 0;
chaithanyarss 224:3ac1f91e0ebc 421 }
ee12b079 210:f4acf895b598 422 }
ee12b079 210:f4acf895b598 423 }
ee12b079 210:f4acf895b598 424
ee12b079 210:f4acf895b598 425 void HANDLE_HW_FAULT_BAE()
ee12b079 210:f4acf895b598 426 {
chaithanyarss 224:3ac1f91e0ebc 427 if(BAE_STATUS != DEVICE_DISABLED) {
chaithanyarss 282:74a04dec4b95 428 if(BAE_STATUS == DEVICE_OC_FAULT){
chaithanyarss 282:74a04dec4b95 429 gPC.printf("Switching on BAE");
chaithanyarss 281:d1c9ae3605a3 430 BAE_SW_EN_DS = 1; //Power ON BAE
chaithanyarss 282:74a04dec4b95 431 wait_ms(10);
chaithanyarss 282:74a04dec4b95 432 }
chaithanyarss 282:74a04dec4b95 433
chaithanyarss 282:74a04dec4b95 434 if(BAE_OC_FAULT == 0) {
chaithanyarss 282:74a04dec4b95 435 gPC.printf("Switching off BAE");
chaithanyarss 281:d1c9ae3605a3 436 BAE_SW_EN_DS = 0; //Switch OFF BAE
chaithanyarss 224:3ac1f91e0ebc 437 BAE_FAULTCOUNT++;
chaithanyarss 224:3ac1f91e0ebc 438 BAE_STATUS = (BAE_FAULTCOUNT == 3)?DEVICE_DISABLED:DEVICE_OC_FAULT;
chaithanyarss 282:74a04dec4b95 439 if(BAE_FAULTCOUNT == 3){
chaithanyarss 282:74a04dec4b95 440 FCTN_CDMS_WR_FLASH(1,DEVICE_DISABLED);
chaithanyarss 282:74a04dec4b95 441 gPC.printf("Declaring BAE permanantly Disabled");
chaithanyarss 282:74a04dec4b95 442 }
chaithanyarss 224:3ac1f91e0ebc 443 } else {
chaithanyarss 224:3ac1f91e0ebc 444 BAE_STATUS = DEVICE_POWERED;
chaithanyarss 282:74a04dec4b95 445 if(SD_STATUS != DEVICE_POWERED);
chaithanyarss 282:74a04dec4b95 446 FCTN_CDMS_WR_FLASH(1,DEVICE_POWERED);
chaithanyarss 224:3ac1f91e0ebc 447 BAE_FAULTCOUNT = 0;
chaithanyarss 224:3ac1f91e0ebc 448 }
ee12b079 210:f4acf895b598 449 }
ee12b079 210:f4acf895b598 450 }
ee12b079 210:f4acf895b598 451
ee12b079 210:f4acf895b598 452 void HANDLE_HW_FAULT_PL()
ee12b079 210:f4acf895b598 453 {
chaithanyarss 224:3ac1f91e0ebc 454 if(PL_STATUS != DEVICE_DISABLED) {
ee12b079 245:da9d1bd999da 455 if(PL_STATUS == DEVICE_OC_FAULT){
chaithanyarss 282:74a04dec4b95 456 gPC.printf("Switching on PL_BEE");
ee12b079 245:da9d1bd999da 457 PYLD_DFF_CLK = 0;
ee12b079 245:da9d1bd999da 458 PYLD_DFF = 1; // Switching ON PL
ee12b079 245:da9d1bd999da 459 wait_us(1);
ee12b079 245:da9d1bd999da 460 PYLD_DFF_CLK = 1;
ee12b079 245:da9d1bd999da 461 wait_us(1);
ee12b079 245:da9d1bd999da 462 PYLD_DFF_CLK = 0;
ee12b079 245:da9d1bd999da 463 wait_us(1);
ee12b079 245:da9d1bd999da 464 }
chaithanyarss 224:3ac1f91e0ebc 465 if(PL_BEE_SW_OC_FAULT == 0) { // if OC Fault
chaithanyarss 282:74a04dec4b95 466 gPC.printf("Switching off PL_BEE");
ee12b079 245:da9d1bd999da 467 PYLD_DFF_CLK = 0;
ee12b079 245:da9d1bd999da 468 PYLD_DFF = 0; //Switching OFF PL
ee12b079 245:da9d1bd999da 469 wait_us(1);
ee12b079 245:da9d1bd999da 470 PYLD_DFF_CLK = 1;
ee12b079 245:da9d1bd999da 471 wait_us(1);
ee12b079 245:da9d1bd999da 472 PYLD_DFF_CLK = 0;
ee12b079 245:da9d1bd999da 473 wait_us(1);
chaithanyarss 224:3ac1f91e0ebc 474 PL_FAULTCOUNT++;
chaithanyarss 224:3ac1f91e0ebc 475 PL_STATUS = (PL_FAULTCOUNT == 3)?DEVICE_DISABLED:DEVICE_OC_FAULT;
chaithanyarss 282:74a04dec4b95 476 if(PL_FAULTCOUNT == 3){
chaithanyarss 282:74a04dec4b95 477 FCTN_CDMS_WR_FLASH(3,DEVICE_DISABLED);
chaithanyarss 282:74a04dec4b95 478 gPC.printf("Declaring PL_BEE permanantly Disabled");
chaithanyarss 282:74a04dec4b95 479 }
chaithanyarss 224:3ac1f91e0ebc 480 } else {
ee12b079 245:da9d1bd999da 481 if(PL_STATUS == DEVICE_OC_FAULT){
chaithanyarss 282:74a04dec4b95 482 gPC.printf("Switching off PL_BEE");
ee12b079 245:da9d1bd999da 483 PYLD_DFF_CLK = 0;
ee12b079 245:da9d1bd999da 484 PYLD_DFF = 0; //Switching OFF PL
ee12b079 245:da9d1bd999da 485 wait_us(1);
ee12b079 245:da9d1bd999da 486 PYLD_DFF_CLK = 1;
ee12b079 245:da9d1bd999da 487 wait_us(1);
ee12b079 245:da9d1bd999da 488 PYLD_DFF_CLK = 0;
ee12b079 245:da9d1bd999da 489 wait_us(1);
ee12b079 245:da9d1bd999da 490 }
chaithanyarss 224:3ac1f91e0ebc 491 PL_STATUS = DEVICE_ENABLED;
chaithanyarss 282:74a04dec4b95 492 if(PL_STATUS != DEVICE_ENABLED)
chaithanyarss 282:74a04dec4b95 493 FCTN_CDMS_WR_FLASH(3,DEVICE_ENABLED);
chaithanyarss 224:3ac1f91e0ebc 494 PL_FAULTCOUNT = 0;
chaithanyarss 224:3ac1f91e0ebc 495 }
ee12b079 210:f4acf895b598 496 }
ee12b079 210:f4acf895b598 497 }
chaithanyarss 224:3ac1f91e0ebc 498
ee12b079 210:f4acf895b598 499 void COLLECT_CDMS_RAM()
chaithanyarss 224:3ac1f91e0ebc 500 {
chaithanyarss 257:7d404e9dc9e2 501 CDMS_RAM[0] = ((PL_INIT_STATUS<<7)&0x80)|((PL_MAIN_STATUS<<6)&0x40)|((PL_LOW_POWER<<5)&0x20)|((PL_STATE<<3)&0x18)|(PL_STATUS&0x07);
chaithanyarss 257:7d404e9dc9e2 502 CDMS_RAM[1] = ((PL_RCV_SC_DATA_STATUS<<7)&0x80)|((COM_SESSION<<6)&0x40)|((COM_RX<<5)&0x20)|((RF_SW_STATUS<<4)&0x10)|((COM_TX<<3)&0x08)|((COM_TX_STATUS<<2)&0x04)|((COM_MNG_TMTC<<1)&0x02)|(EN_CDMS_HK&0x01);
chaithanyarss 257:7d404e9dc9e2 503 CDMS_RAM[2] = ((EN_PL<<7)&0x80)|((EN_RCV_SC<<6)&0x40)|((CDMS_INIT_STATUS<<5)&0x20)|((CDMS_HK_MAIN_STATUS<<4)&0x10)|((CDMS_HK_STATUS<<2)&0x0C)|((COM_RX_STATUS<<1)&0x02)|(CDMS_RTC_BL&0x01);
chaithanyarss 257:7d404e9dc9e2 504 CDMS_RAM[3] = CDMS_I2C_ERR_SPEED_COUNTER >> 8;
chaithanyarss 257:7d404e9dc9e2 505 CDMS_RAM[4] = CDMS_I2C_ERR_SPEED_COUNTER;
chaithanyarss 257:7d404e9dc9e2 506 CDMS_RAM[5] = CDMS_I2C_ERR_BAE_COUNTER >> 8;
chaithanyarss 257:7d404e9dc9e2 507 CDMS_RAM[6] = CDMS_I2C_ERR_BAE_COUNTER;
chaithanyarss 257:7d404e9dc9e2 508 CDMS_RAM[7] = CDMS_HK_MAIN_COUNTER >> 8;
chaithanyarss 257:7d404e9dc9e2 509 CDMS_RAM[8] = CDMS_HK_MAIN_COUNTER;
chaithanyarss 257:7d404e9dc9e2 510 CDMS_RAM[9] = PL_MAIN_COUNTER >> 8;
chaithanyarss 257:7d404e9dc9e2 511 CDMS_RAM[10] = PL_MAIN_COUNTER;
chaithanyarss 257:7d404e9dc9e2 512 CDMS_RAM[11] = PL_RCV_SC_DATA_COUNTER >> 8;
chaithanyarss 257:7d404e9dc9e2 513 CDMS_RAM[12] = PL_RCV_SC_DATA_COUNTER;
chaithanyarss 257:7d404e9dc9e2 514 CDMS_RAM[13] = COMRX_RESET_COUNTER >> 8;
chaithanyarss 257:7d404e9dc9e2 515 CDMS_RAM[14] = COMRX_RESET_COUNTER;
chaithanyarss 257:7d404e9dc9e2 516 CDMS_RAM[15] = CDMS_WR_SD_FAULT_COUNTER >> 8;
chaithanyarss 257:7d404e9dc9e2 517 CDMS_RAM[16] = CDMS_WR_SD_FAULT_COUNTER;
chaithanyarss 257:7d404e9dc9e2 518 CDMS_RAM[17] = SD_LIB_WRITES >> 8;
chaithanyarss 257:7d404e9dc9e2 519 CDMS_RAM[18] = SD_LIB_WRITES;
chaithanyarss 257:7d404e9dc9e2 520 for(int i = 0; i<4; i++)
chaithanyarss 257:7d404e9dc9e2 521 CDMS_RAM[19+i] = TIME_LATEST_RTC >> i*8;
chaithanyarss 257:7d404e9dc9e2 522 for(int i = 0; i<4; i++)
chaithanyarss 257:7d404e9dc9e2 523 CDMS_RAM[23+i] = TIME_LATEST_I2C_BAE >> i*8;
chaithanyarss 257:7d404e9dc9e2 524 for(int i = 0; i<4; i++)
chaithanyarss 257:7d404e9dc9e2 525 CDMS_RAM[27+i] = TIME_LATEST_I2C_SPEED >> i*8;
chaithanyarss 257:7d404e9dc9e2 526 for(int i = 0; i<4; i++)
chaithanyarss 257:7d404e9dc9e2 527 CDMS_RAM[31+i] = TIME_LATEST_SD_WR >> i*8;
chaithanyarss 257:7d404e9dc9e2 528 for(int i = 0; i<4; i++)
chaithanyarss 257:7d404e9dc9e2 529 CDMS_RAM[35+i] = TIME_LATEST_SD_RD >> i*8;
chaithanyarss 257:7d404e9dc9e2 530 for(int i = 0; i<4; i++)
chaithanyarss 257:7d404e9dc9e2 531 CDMS_RAM[39+i] = TIME_LATEST_SPI_SPEED >> i*8;
chaithanyarss 257:7d404e9dc9e2 532 for(int i = 0; i<4; i++)
chaithanyarss 257:7d404e9dc9e2 533 CDMS_RAM[43+i] = FSC_CURRENT[1] >> i*8;
chaithanyarss 257:7d404e9dc9e2 534 for(int i = 0; i<4; i++)
chaithanyarss 257:7d404e9dc9e2 535 CDMS_RAM[47+i] = FSC_LAST[1] >> i*8;
chaithanyarss 257:7d404e9dc9e2 536 for(int i = 0; i<4; i++)
chaithanyarss 257:7d404e9dc9e2 537 CDMS_RAM[51+i] = FSC_CURRENT[2] >> i*8;
chaithanyarss 257:7d404e9dc9e2 538 for(int i = 0; i<4; i++)
chaithanyarss 257:7d404e9dc9e2 539 CDMS_RAM[55+i] = FSC_LAST[2] >> i*8;
chaithanyarss 257:7d404e9dc9e2 540 for(int i = 0; i<4; i++)
chaithanyarss 257:7d404e9dc9e2 541 CDMS_RAM[59+i] = FSC_CURRENT[3] >> i*8;
chaithanyarss 257:7d404e9dc9e2 542 for(int i = 0; i<4; i++)
chaithanyarss 257:7d404e9dc9e2 543 CDMS_RAM[63+i] = FSC_LAST[3] >> i*8;
chaithanyarss 257:7d404e9dc9e2 544 for(int i = 0; i<4; i++)
chaithanyarss 257:7d404e9dc9e2 545 CDMS_RAM[67+i] = FSC_CURRENT[4] >> i*8;
chaithanyarss 257:7d404e9dc9e2 546 for(int i = 0; i<4; i++)
chaithanyarss 257:7d404e9dc9e2 547 CDMS_RAM[71+i] = FSC_LAST[4] >> i*8;
chaithanyarss 257:7d404e9dc9e2 548 for(int i = 0; i<4; i++)
chaithanyarss 257:7d404e9dc9e2 549 CDMS_RAM[75+i] = FSC_CURRENT[5] >> i*8;
chaithanyarss 257:7d404e9dc9e2 550 for(int i = 0; i<4; i++)
chaithanyarss 257:7d404e9dc9e2 551 CDMS_RAM[79+i] = FSC_LAST[5] >> i*8;
chaithanyarss 257:7d404e9dc9e2 552 CDMS_RAM[83] = 0x00;
shreeshas95 103:b55559925dc1 553 }