Repository for CDMS code
Dependencies: SimpleDMA mbed-rtos mbed eeprom
Fork of COM_MNG_TMTC_SIMPLE by
Diff: CDMS_HK.h
- Revision:
- 297:7cc868888d56
- Parent:
- 296:ec1317ab9c50
- Child:
- 302:5ff4b9ce185e
diff -r ec1317ab9c50 -r 7cc868888d56 CDMS_HK.h --- a/CDMS_HK.h Sun Aug 28 14:47:38 2016 +0000 +++ b/CDMS_HK.h Mon Sep 05 06:25:57 2016 +0000 @@ -63,7 +63,7 @@ FCTN_CDMS_PL_MAIN((void const *)NULL); hk_count = 2; } - gPC.printf("\n\nEntering HK thread\n"); + gPC.printf("\n\rEntering HK thread\n"); if(EN_CDMS_HK == 0x00) continue; @@ -122,10 +122,12 @@ CDMS_HK_FRAME[1] = FSC_CURRENT[4]+1; CDMS_HK_FRAME[2] = (FSC_CURRENT[4]+1) >> 8; CDMS_HK_FRAME[3] = (FSC_CURRENT[4]+1) >> 16; - - for(int i = 0; i<128; i++) /*Adding actual CDMS Health data to TM frame*/ - CDMS_HK_FRAME[4+i] = CDMS_HEALTH_DATA[i]; - + gPC.printf("\n"); + for(int i = 0; i<128; i++){ /*Adding actual CDMS Health data to TM frame*/ + CDMS_HK_FRAME[i+4] = CDMS_HEALTH_DATA[i]; + gPC.printf("%02x",CDMS_HEALTH_DATA[i]); + } + gPC.printf("\n"); uint16_t crc = crc16_gen(CDMS_HK_FRAME,132); /*Adding CRC to TM frame*/ CDMS_HK_FRAME[133] = crc; CDMS_HK_FRAME[132] = crc >> 8; @@ -254,7 +256,7 @@ void minMaxHkData() { if(firstCount==true) { - for (int i = 0; i < 16; ++i) { + for (int i = 4; i < 16; ++i) { min_max_data.temp_min[i] = quant_data.temp_quant[i]; min_max_data.temp_max[i] = quant_data.temp_quant[i]; } @@ -262,7 +264,7 @@ min_max_data.CDMS_temp_min=quant_data.CDMS_temp_quant; min_max_data.CDMS_temp_max=quant_data.CDMS_temp_quant; } else { - for (int i = 0; i < 16; ++i) { + for (int i = 4; i < 16; ++i) { min_max_data.temp_min[i] = saveMin(min_max_data.temp_min[i],quant_data.temp_quant[i]); min_max_data.temp_max[i] = saveMax(min_max_data.temp_max[i],quant_data.temp_quant[i]); } @@ -283,7 +285,7 @@ SelectLinec1=0; SelectLinec2=0; SelectLinec3=0; - + gPC.printf("\r%d %d %d %d\n",SelectLinec3.read(),SelectLinec2.read(),SelectLinec1.read(),SelectLinec0.read()); for(Iteration=0; Iteration<16; Iteration++) { actual_data.temp_actual[Iteration]=TempInput.read(); @@ -295,35 +297,38 @@ SelectLinec2=!(SelectLinec2); if(Iteration%8==7) SelectLinec3=!(SelectLinec3); + gPC.printf("\r%d %d %d %d\n",SelectLinec3.read(),SelectLinec2.read(),SelectLinec1.read(),SelectLinec0.read()); } actual_data.CDMS_temp_actual=(-90.7*3.3*CDMS_temp_sensor.read())+190.1543; - + + gPC.printf("\rRaw Temp = %f\n",actual_data.temp_actual[15]*3.3); + for(Iteration=0; Iteration<16; Iteration++) { - if(Iteration<4) { - actual_data.temp_actual[Iteration]=actual_data.temp_actual[Iteration]*3.3; - resistance=24000*actual_data.temp_actual[Iteration]/(3.3-actual_data.temp_actual[Iteration]); + if(Iteration<4) + actual_data.temp_actual[Iteration]=actual_data.temp_actual[Iteration]*3.3*2; - if(actual_data.temp_actual[Iteration]>1.47) { + else if(Iteration<14){ + resistance=10000*actual_data.temp_actual[Iteration]*3.3/(3.3-actual_data.temp_actual[Iteration]*3.3); + + if(actual_data.temp_actual[Iteration]*3.3<1.47) //Document says 1.378 .Pls Check actual_data.temp_actual[Iteration]=3694/log(24.032242*resistance); - } else { - + else actual_data.temp_actual[Iteration]=3365.4/log(7.60573*resistance); - } - } else + } + else actual_data.temp_actual[Iteration]=(-90.7*3.3*actual_data.temp_actual[Iteration])+190.1543; } - for(Iteration=0; Iteration<16; Iteration++) { - if(Iteration<14) { - + if(Iteration<4) + quant_data.temp_quant[Iteration]=actual_data.temp_actual[Iteration] * 10; + else if(Iteration<14) quant_data.temp_quant[Iteration]=quantiz(tstart_thermistor,tstep_thermistor,actual_data.temp_actual[Iteration]); - } else + else quant_data.temp_quant[Iteration]=quantiz(tstart,tstep,actual_data.temp_actual[Iteration]); } - quant_data.CDMS_temp_quant=quantiz(tstart,tstep,actual_data.CDMS_temp_actual); minMaxHkData(); @@ -332,34 +337,34 @@ void FUNC_CDMS_GPIO_STATUS() //Polls the status of Input GPIO PINS { //V_A_PGOOD //TRZ EN - GPIO_STATUS=(V_A_PGOOD)?(GPIO_STATUS)||((uint16_t)(0x1<<15)):(GPIO_STATUS)&(~((uint16_t)(0x1<<15))); + GPIO_STATUS=(V_A_PGOOD)?(GPIO_STATUS)|((uint16_t)(0x1<<15)):(GPIO_STATUS)&(~((uint16_t)(0x1<<15))); //V_B_PGOOD_1 //3V3BPGOOD //$ - GPIO_STATUS=(V_B_PGOOD_1)?(GPIO_STATUS)||((uint16_t)(0x1<<14)):(GPIO_STATUS)&(~((uint16_t)(0x1<<14))); + GPIO_STATUS=(V_B_PGOOD_1)?(GPIO_STATUS)|((uint16_t)(0x1<<14)):(GPIO_STATUS)&(~((uint16_t)(0x1<<14))); //V_B_PGOOD_2 //3V3BEN //$ - GPIO_STATUS=(V_B_PGOOD_2)?(GPIO_STATUS)||((uint16_t)(0x1<<13)):(GPIO_STATUS)&(~((uint16_t)(0x1<<13))); + GPIO_STATUS=(V_B_PGOOD_2)?(GPIO_STATUS)|((uint16_t)(0x1<<13)):(GPIO_STATUS)&(~((uint16_t)(0x1<<13))); //V_C_PGOOD //3V3CPGOOD //$ - GPIO_STATUS=(V_C_PGOOD)?(GPIO_STATUS)||((uint16_t)(0x1<<12)):(GPIO_STATUS)&(~((uint16_t)(0x1<<12))); + GPIO_STATUS=(V_C_PGOOD)?(GPIO_STATUS)|((uint16_t)(0x1<<12)):(GPIO_STATUS)&(~((uint16_t)(0x1<<12))); //COMRX_OC_FAULT //$ - GPIO_STATUS=(COMRX_OC_FAULT)?(GPIO_STATUS)||((uint16_t)(0x1<<11)):(GPIO_STATUS)&(~((uint16_t)(0x1<<11))); + GPIO_STATUS=(COMRX_OC_FAULT)?(GPIO_STATUS)|((uint16_t)(0x1<<11)):(GPIO_STATUS)&(~((uint16_t)(0x1<<11))); // COMTX_OC_FAULT //$ - GPIO_STATUS=(COM_TX_OC_FAULT)?(GPIO_STATUS)||((uint16_t)(0x1<<10)):(GPIO_STATUS)&(~((uint16_t)(0x1<<10))); + GPIO_STATUS=(COM_TX_OC_FAULT)?(GPIO_STATUS)|((uint16_t)(0x1<<10)):(GPIO_STATUS)&(~((uint16_t)(0x1<<10))); //BAE_OC_FAULT //$ - GPIO_STATUS=(BAE_OC_FAULT)?(GPIO_STATUS)||((uint16_t)(0x1<<9)):(GPIO_STATUS)&(~((uint16_t)(0x1<<9))); + GPIO_STATUS=(BAE_OC_FAULT)?(GPIO_STATUS)|((uint16_t)(0x1<<9)):(GPIO_STATUS)&(~((uint16_t)(0x1<<9))); //PL_GPIO_1_STATUS //$ - GPIO_STATUS=(PL_GPIO_1_STATUS)?(GPIO_STATUS)||((uint16_t)(0x1<<8)):(GPIO_STATUS)&(~((uint16_t)(0x1<<8))); + GPIO_STATUS=(PL_GPIO_1_STATUS)?(GPIO_STATUS)|((uint16_t)(0x1<<8)):(GPIO_STATUS)&(~((uint16_t)(0x1<<8))); //PL_GPIO_2_STATUS //$ - GPIO_STATUS=(PL_GPIO_2_STATUS)?(GPIO_STATUS)||((uint16_t)(0x1<<7)):(GPIO_STATUS)&(~((uint16_t)(0x1<<7))); + GPIO_STATUS=(PL_GPIO_2_STATUS)?(GPIO_STATUS)|((uint16_t)(0x1<<7)):(GPIO_STATUS)&(~((uint16_t)(0x1<<7))); //PL_GPIO_3_STATUS //$ - GPIO_STATUS=(PL_GPIO_3_STATUS)?(GPIO_STATUS)||((uint16_t)(0x1<<6)):(GPIO_STATUS)&(~((uint16_t)(0x1<<6))); + GPIO_STATUS=(PL_GPIO_3_STATUS)?(GPIO_STATUS)|((uint16_t)(0x1<<6)):(GPIO_STATUS)&(~((uint16_t)(0x1<<6))); //PL_BEE_SW_OC_FAULT //to be verified - GPIO_STATUS=(PL_BEE_SW_OC_FAULT)?(GPIO_STATUS)||((uint16_t)(0x1<<5)):(GPIO_STATUS)&(~((uint16_t)(0x1<<5))); + GPIO_STATUS=(PL_BEE_SW_OC_FAULT)?(GPIO_STATUS)|((uint16_t)(0x1<<5)):(GPIO_STATUS)&(~((uint16_t)(0x1<<5))); //PL_EPS_LATCH_SW_OC_FAULT // to be verified - GPIO_STATUS=(PL_EPS_LATCH_SW_OC_FAULT)?(GPIO_STATUS)||((uint16_t)(0x1<<4)):(GPIO_STATUS)&(~((uint16_t)(0x1<<4))); + GPIO_STATUS=(PL_EPS_LATCH_SW_OC_FAULT)?(GPIO_STATUS)|((uint16_t)(0x1<<4)):(GPIO_STATUS)&(~((uint16_t)(0x1<<4))); //EPS_V_C_EN_STATUS - GPIO_STATUS=(COM_RX_CNTRL)?(GPIO_STATUS)||((uint16_t)(0x1<<3)):(GPIO_STATUS)&(~((uint16_t)(0x1<<3))); + GPIO_STATUS=(COM_RX_CNTRL)?(GPIO_STATUS)|((uint16_t)(0x1<<3)):(GPIO_STATUS)&(~((uint16_t)(0x1<<3))); //EPS_V_D_EN_STATUS - GPIO_STATUS=(COM_TX_CNTRL)?(GPIO_STATUS)||((uint16_t)(0x1<<2)):(GPIO_STATUS)&(~((uint16_t)(0x1<<2))); - + GPIO_STATUS=(COM_TX_CNTRL)?(GPIO_STATUS)|((uint16_t)(0x1<<2)):(GPIO_STATUS)&(~((uint16_t)(0x1<<2))); + gPC.printf("%04x\n",GPIO_STATUS); } void VERIFY_COMRX() @@ -525,37 +530,36 @@ CDMS_RAM[17] = SD_LIB_WRITES >> 8; CDMS_RAM[18] = SD_LIB_WRITES; for(int i = 0; i<4; i++) - CDMS_RAM[19+i] = TIME_LATEST_RTC >> i*8; + CDMS_RAM[19+i] = TIME_LATEST_RTC >> (3-i)*8; for(int i = 0; i<4; i++) - CDMS_RAM[23+i] = TIME_LATEST_I2C_BAE >> i*8; + CDMS_RAM[23+i] = TIME_LATEST_I2C_BAE >> (3-i)*8; for(int i = 0; i<4; i++) - CDMS_RAM[27+i] = TIME_LATEST_I2C_SPEED >> i*8; + CDMS_RAM[27+i] = TIME_LATEST_I2C_SPEED >> (3-i)*8; for(int i = 0; i<4; i++) - CDMS_RAM[31+i] = TIME_LATEST_SD_WR >> i*8; + CDMS_RAM[31+i] = TIME_LATEST_SD_WR >> (3-i)*8; for(int i = 0; i<4; i++) - CDMS_RAM[35+i] = TIME_LATEST_SD_RD >> i*8; + CDMS_RAM[35+i] = TIME_LATEST_SD_RD >> (3-i)*8; for(int i = 0; i<4; i++) - CDMS_RAM[39+i] = TIME_LATEST_SPI_SPEED >> i*8; + CDMS_RAM[39+i] = TIME_LATEST_SPI_SPEED >> (3-i)*8; for(int i = 0; i<4; i++) - CDMS_RAM[43+i] = FSC_CURRENT[1] >> i*8; + CDMS_RAM[43+i] = FSC_CURRENT[1] >> (3-i)*8; for(int i = 0; i<4; i++) - CDMS_RAM[47+i] = FSC_LAST[1] >> i*8; + CDMS_RAM[47+i] = FSC_LAST[1] >> (3-i)*8; for(int i = 0; i<4; i++) - CDMS_RAM[51+i] = FSC_CURRENT[2] >> i*8; + CDMS_RAM[51+i] = FSC_CURRENT[2] >> (3-i)*8; for(int i = 0; i<4; i++) - CDMS_RAM[55+i] = FSC_LAST[2] >> i*8; + CDMS_RAM[55+i] = FSC_LAST[2] >> (3-i)*8; for(int i = 0; i<4; i++) - CDMS_RAM[59+i] = FSC_CURRENT[3] >> i*8; + CDMS_RAM[59+i] = FSC_CURRENT[3] >> (3-i)*8; for(int i = 0; i<4; i++) - CDMS_RAM[63+i] = FSC_LAST[3] >> i*8; + CDMS_RAM[63+i] = FSC_LAST[3] >> (3-i)*8; for(int i = 0; i<4; i++) - CDMS_RAM[67+i] = FSC_CURRENT[4] >> i*8; + CDMS_RAM[67+i] = FSC_CURRENT[4] >> (3-i)*8; for(int i = 0; i<4; i++) - CDMS_RAM[71+i] = FSC_LAST[4] >> i*8; + CDMS_RAM[71+i] = FSC_LAST[4] >> (3-i)*8; for(int i = 0; i<4; i++) - CDMS_RAM[75+i] = FSC_CURRENT[5] >> i*8; + CDMS_RAM[75+i] = FSC_CURRENT[5] >> (3-i)*8; for(int i = 0; i<4; i++) - CDMS_RAM[79+i] = FSC_LAST[5] >> i*8; + CDMS_RAM[79+i] = FSC_LAST[5] >> (3-i)*8; CDMS_RAM[83] = 0x00; - gPC.printf("%d %d %d %d %d\n",FSC_CURRENT[1],FSC_CURRENT[2],FSC_CURRENT[3],FSC_CURRENT[4],FSC_CURRENT[5]); } \ No newline at end of file