To fix the hang problem
Dependencies: FreescaleIAP SimpleDMA mbed-rtos mbed
Fork of CDMS_CODE by
Diff: CDMS_HK.h
- Revision:
- 245:da9d1bd999da
- Parent:
- 224:3ac1f91e0ebc
- Child:
- 246:565458eefd94
--- a/CDMS_HK.h Sat Jul 09 13:11:25 2016 +0000 +++ b/CDMS_HK.h Sun Jul 10 13:47:26 2016 +0000 @@ -25,9 +25,12 @@ void FCTN_CDMS_HK_MAIN(void const *args) { + while(1) + { gPC.printf("Entering HK thread"); + gHK_THREAD->signal_wait(HK_SIGNAL); unsigned char CDMS_HK_FRAME[134] = {0}; - char BAE_HK[128] = {0}; + char BAE_HK[134] = {0}; uint8_t convoluted_CDMS_HK[270]; uint8_t interleave_CDMS_HK[288]; uint8_t CDMS_HEALTH_FINAL[512] = {0}; @@ -92,38 +95,45 @@ CDMS_HEALTH_FINAL[i] = interleave_CDMS_HK[i]; SD_WRITE(CDMS_HEALTH_FINAL,FSC_CURRENT[4]+1,4); - gPC.printf("Completed CDMS HK\n"); + gPC.printf("\rCompleted CDMS HK\n"); /*---------------------------------- BAE HK --------------------------------------------*/ BAE_HK_I2C = FCTN_I2C_READ(BAE_HK,134); - gPC.printf("Entering BAE thread\n"); + gPC.printf("\rEntering BAE HK\n"); if(BAE_HK_I2C == 0) { - TIME_LATEST_I2C_BAE = FCTN_CDMS_RD_RTC() >> 7; + crc = crc16_gen((unsigned char *)BAE_HK,132); + if(crc == ((uint16_t)BAE_HK[132] << 8) | (uint16_t)BAE_HK[133]){ + TIME_LATEST_I2C_BAE = FCTN_CDMS_RD_RTC() >> 7; + for(int i = 0; i<15; i++) + gPC.printf("\r 0x%02X\n",BAE_HK[i]); + for(int i = 0; i<4; i++) + BAE_HK[i] = HK_time >> i; + BAE_HK_FRAME[0] = 0x28; + BAE_HK_FRAME[1] = FSC_CURRENT[5]+1; + BAE_HK_FRAME[2] = (FSC_CURRENT[5]+1) >> 8; + BAE_HK_FRAME[3] = (FSC_CURRENT[5]+1) >> 16; + for(int i = 0; i<128; i++) /*Adding actual CDMS Health data to TM frame*/ + BAE_HK_FRAME[4+i] = BAE_HK[i]; + crc = crc16_gen(BAE_HK_FRAME,132); /*Adding CRC to TM frame*/ + BAE_HK_FRAME[133] = crc; + BAE_HK_FRAME[132] = crc >> 8; + BAE_HEALTH.convolutionEncode(BAE_HK_FRAME , convoluted_BAE_HK); + BAE_HEALTH.convolutionEncode(BAE_HK_FRAME + 67, convoluted_BAE_HK + 135); + interleave(convoluted_BAE_HK , interleave_BAE_HK); + interleave(convoluted_BAE_HK +135, interleave_BAE_HK + 144); + for(int i=0; i<288; i++) + BAE_HEALTH_FINAL[i] = interleave_BAE_HK[i]; + SD_WRITE(BAE_HEALTH_FINAL,FSC_CURRENT[5]+1,5); + } + } else { - for(int i = 0; i<128; i++) + gPC.printf("\rBAE HK data not recieved through I2C\n"); + for(int i = 0; i<134; i++) BAE_HK[i] = 0; } - for(int i = 0; i<4; i++) - BAE_HK[i] = HK_time >> i; - BAE_HK_FRAME[0] = 0x28; - BAE_HK_FRAME[1] = FSC_CURRENT[5]+1; - BAE_HK_FRAME[2] = (FSC_CURRENT[5]+1) >> 8; - BAE_HK_FRAME[3] = (FSC_CURRENT[5]+1) >> 16; - for(int i = 0; i<128; i++) /*Adding actual CDMS Health data to TM frame*/ - BAE_HK_FRAME[4+i] = BAE_HK[i]; - crc = crc16_gen(BAE_HK_FRAME,132); /*Adding CRC to TM frame*/ - BAE_HK_FRAME[133] = crc; - BAE_HK_FRAME[132] = crc >> 8; - BAE_HEALTH.convolutionEncode(BAE_HK_FRAME , convoluted_BAE_HK); - BAE_HEALTH.convolutionEncode(BAE_HK_FRAME + 67, convoluted_BAE_HK + 135); - interleave(convoluted_BAE_HK , interleave_BAE_HK); - interleave(convoluted_BAE_HK +135, interleave_BAE_HK + 144); - for(int i=0; i<288; i++) - BAE_HEALTH_FINAL[i] = interleave_BAE_HK[i]; - SD_WRITE(BAE_HEALTH_FINAL,FSC_CURRENT[5]+1,5); - gPC.printf("Completed BAE HK\n"); + gPC.printf("\rCompleted BAE HK\n"); /*----------------------------------Beacon message--------------------------------------*/ unsigned char SC_HK_LBM_0[135]; @@ -135,7 +145,8 @@ SC_HK_LBM_0[132] = crc; SC_HK_LBM_0[133] = crc >> 8; FCTN_I2C_WRITE((char *)SC_HK_LBM_0,135); - gPC.printf("Completed Beacon\n"); + gPC.printf("\rCompleted Beacon\n"); + } } int quantiz(float start,float step,float x) @@ -261,7 +272,7 @@ 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))); - + } void VERIFY_COMRX() @@ -342,16 +353,35 @@ void HANDLE_HW_FAULT_PL() { if(PL_STATUS != DEVICE_DISABLED) { - if(PL_STATUS == DEVICE_OC_FAULT) - PL_SW_EN_DS = 0; //Power ON PL - + if(PL_STATUS == DEVICE_OC_FAULT){ + PYLD_DFF_CLK = 0; + PYLD_DFF = 1; // Switching ON PL + wait_us(1); + PYLD_DFF_CLK = 1; + wait_us(1); + PYLD_DFF_CLK = 0; + wait_us(1); + } if(PL_BEE_SW_OC_FAULT == 0) { // if OC Fault - PL_SW_EN_DS = 1; // switching OFF PL + PYLD_DFF_CLK = 0; + PYLD_DFF = 0; //Switching OFF PL + wait_us(1); + PYLD_DFF_CLK = 1; + wait_us(1); + PYLD_DFF_CLK = 0; + wait_us(1); PL_FAULTCOUNT++; PL_STATUS = (PL_FAULTCOUNT == 3)?DEVICE_DISABLED:DEVICE_OC_FAULT; } else { - if(PL_STATUS == DEVICE_OC_FAULT) - PL_SW_EN_DS = 0; //Switching OFF PL + if(PL_STATUS == DEVICE_OC_FAULT){ + PYLD_DFF_CLK = 0; + PYLD_DFF = 0; //Switching OFF PL + wait_us(1); + PYLD_DFF_CLK = 1; + wait_us(1); + PYLD_DFF_CLK = 0; + wait_us(1); + } PL_STATUS = DEVICE_ENABLED; PL_FAULTCOUNT = 0; }