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
Revision 235:c127b15409b2, committed 2016-07-06
- Comitter:
- ee12b079
- Date:
- Wed Jul 06 08:09:22 2016 +0000
- Parent:
- 233:bfce738e43e8
- Child:
- 236:ccbd1a7778b1
- Child:
- 237:12061b714e47
- Child:
- 248:407ab7e337cd
- Commit message:
- Integrated Chaitanya's changes for HK thread and FMS TCs
Changed in this revision
--- a/CDMS_HK.h Tue Jul 05 16:04:31 2016 +0000
+++ b/CDMS_HK.h Wed Jul 06 08:09:22 2016 +0000
@@ -27,7 +27,7 @@
{
gPC.printf("Entering HK thread");
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 +92,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 +142,7 @@
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 +268,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 +349,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;
}
--- a/CDMS_PL.h Tue Jul 05 16:04:31 2016 +0000 +++ b/CDMS_PL.h Wed Jul 06 08:09:22 2016 +0000 @@ -29,10 +29,6 @@ #define UNEXECUTED 0x00000003 //also used as mask for EXEC_STATUS -DigitalOut PYLD_DFF(PIN73); -DigitalOut PYLD_DFF_CLK(PIN65); -DigitalOut PYLD_EPS_DFF_PWR(PIN64); -DigitalOut PYLD_EPS_DFF_PWR_CLK(PIN40); Base_tm* FCTN_CDMS_RLY_TMTC(Base_tc *tc_ptr); // waiting 1us for setup time,hold time and propagation delay
--- a/DefinitionsAndGlobals.h Tue Jul 05 16:04:31 2016 +0000
+++ b/DefinitionsAndGlobals.h Wed Jul 06 08:09:22 2016 +0000
@@ -31,8 +31,8 @@
DigitalOut PL_I2C_GPIO(PTC1);
//I2C - CDMS to BAE
- DigitalIn BAE_I2C_GPIO(PIN67);
- DigitalOut CDMS_I2C_GPIO(PIN39);
+ DigitalIn BAE_I2C_GPIO(PIN67);//PTB21 from bae to cdms
+ DigitalOut CDMS_I2C_GPIO(PIN39);//PTA5 from cdms to bae
// TC LIST
#define TCL_STATE_INCOMPLETE 0x00
@@ -258,14 +258,22 @@
DigitalIn PL_GPIO_3_STATUS (PIN80);
DigitalIn PL_BEE_SW_OC_FAULT (PIN91);
DigitalIn PL_EPS_LATCH_SW_OC_FAULT (PIN5);
-DigitalIn V_C_EN_STATUS (PIN72);
DigitalIn V_D_EN_STATUS (PIN56);
DigitalIn SD_OC_FAULT (PIN90);
DigitalOut SD_SW_EN_DS (PIN97);
DigitalOut BAE_SW_EN_DS (PIN47);
-DigitalOut PL_SW_EN_DS (PIN73);
+DigitalOut TRXY_PWR_CNTRL (PIN84);
+DigitalOut TRZ_PWR_CNTRL (PIN88);
+
+DigitalOut PYLD_DFF (PIN73);
+DigitalOut PYLD_DFF_CLK (PIN65);
+DigitalOut PYLD_EPS_DFF_PWR (PIN64);
+DigitalOut PYLD_EPS_DFF_PWR_CLK (PIN40);
+
+DigitalOut RESET_TO_BAE(PIN93,1);
+DigitalOut RESET_TO_PYLD(PIN21);
//SD HK
uint32_t FSC_CURRENT[6];
--- a/FMS_all.h Tue Jul 05 16:04:31 2016 +0000
+++ b/FMS_all.h Wed Jul 06 08:09:22 2016 +0000
@@ -1,12 +1,17 @@
+//Run processes
void P_PL_INIT();
void P_PL_MAIN();
void P_COM_INIT();
void P_CDMS_HK_MAIN();
void P_PL_RCV_SC_DATA();
void P_CDMS_INIT_SD();
+
+// Switch ON/OFF functions
void CDMS_SD_SW_ON();
void CDMS_SD_SW_OFF();
+void CDMS_RTC_ON();
+void CDMS_RTC_OFF();
void SW_ON_BAE();
void SW_OFF_BAE();
void SW_ON_PL_BEE();
@@ -15,13 +20,24 @@
void SW_OFF_PL_EPS();
void SW_ON_V_A_EN();
void SW_OFF_V_A_EN();
+
+// RST functions
void RST_SD();
+void SW_RST_BAE();
+void SW_RST_PL_BEE();
void RST_BAE();
void RST_PL_BEE();
+void CDMS_INTERNAL_RESET();
+void SYS_PWR_RESET(); // Have to be decided with EPS team.
+void EPS_V_A_EN();
+void EPS_V_C_EN();
+
void RST_HK_COUNTER();
uint8_t CDMS_RD_SD_HK(uint8_t *);
+void CDMS_RD_RTC(uint64_t *);
+void CDMS_CALIB_RTC();
void CDMS_RESET();
-void CDMS_INTERNAL_RESET();
+
void P_PL_INIT()
{
@@ -30,22 +46,22 @@
void P_PL_MAIN()
{
-
+ // FCTN_CDMS_PL_MAIN((void *)NULL);
}
void P_COM_INIT()
{
-
+ P_COM_INIT;
}
void P_CDMS_HK_MAIN()
{
- //FCTN_CDMS_HK_MAIN();
+ FCTN_CDMS_HK_MAIN((void *)NULL);
}
void P_PL_RCV_SC_DATA()
{
-
+
}
void P_CDMS_INIT_SD()
@@ -55,74 +71,149 @@
void CDMS_SD_SW_ON()
{
- SD_SW_EN_DS = 0; //powering on SD
+ SD_SW_EN_DS = 0;
}
void CDMS_SD_SW_OFF()
{
- SD_SW_EN_DS = 0; //powering on SD
-}
-
-void SW_ON_BAE()
-{
- BAE_SW_EN_DS = 0; //Power ON BAE
+ SD_SW_EN_DS = 1;
}
-void SW_OFF_BAE()
+void CDMS_RTC_ON()
{
- BAE_SW_EN_DS = 1; //Switch OFF BAE
+
}
-void SW_ON_PL_BEE()
-{
- PL_SW_EN_DS = 0; //Power ON PL
-}
-
-void SW_OFF_PL_BEE()
-{
- PL_SW_EN_DS = 1; // switching OFF PL
-}
-
-void SW_ON_PL_EPS()
+void CDMS_RTC_OFF()
{
}
+void SW_ON_BAE()
+{
+ BAE_SW_EN_DS = 0;
+}
+
+void SW_OFF_BAE()
+{
+ BAE_SW_EN_DS = 1;
+}
+
+void SW_ON_PL_BEE()
+{
+ PYLD_DFF_CLK = 0;\
+ PYLD_DFF = 1;\
+ wait_us(1);\
+ PYLD_DFF_CLK = 1;\
+ wait_us(1);\
+ PYLD_DFF_CLK = 0;\
+ wait_us(1);\
+}
+
+void SW_OFF_PL_BEE()
+{
+ PYLD_DFF_CLK = 0;
+ PYLD_DFF = 0;
+ wait_us(1);
+ PYLD_DFF_CLK = 1;
+ wait_us(1);
+ PYLD_DFF_CLK = 0;
+ wait_us(1);
+}
+
+void SW_ON_PL_EPS()
+{
+ PYLD_EPS_DFF_PWR_CLK = 0;\
+ PYLD_EPS_DFF_PWR = 1;\
+ wait_us(1);\
+ PYLD_EPS_DFF_PWR_CLK = 1;\
+ wait_us(1);\
+ PYLD_EPS_DFF_PWR_CLK = 0;\
+ wait_us(1);\
+}
+
void SW_OFF_PL_EPS()
{
-
+ PYLD_EPS_DFF_PWR_CLK = 0;\
+ PYLD_EPS_DFF_PWR = 0;\
+ wait_us(1);\
+ PYLD_EPS_DFF_PWR_CLK = 1;\
+ wait_us(1);\
+ PYLD_EPS_DFF_PWR_CLK = 0;\
+ wait_us(1);\
}
void SW_ON_V_A_EN()
{
-
+ TRXY_PWR_CNTRL = 1;
+ TRZ_PWR_CNTRL = 1;
}
void SW_OFF_V_A_EN()
{
-
+ TRXY_PWR_CNTRL = 0;
+ TRZ_PWR_CNTRL = 0;
}
void RST_SD()
{
- SD_SW_EN_DS = 1; //switching off SD card
+ SD_SW_EN_DS = 1;
wait_ms(10);
SD_SW_EN_DS = 0;
- FCTN_CDMS_SD_INIT();
+}
+
+void SW_RST_BAE()
+{
+ BAE_SW_EN_DS = 1;
+ wait_ms(10);
+ BAE_SW_EN_DS = 0;
+}
+
+void SW_RST_PL_BEE()
+{
+ PYLD_DFF = 1;
+ wait_ms(10);
+ PYLD_DFF = 0;
}
void RST_BAE()
{
- BAE_SW_EN_DS = 1; //Switch OFF BAE
+ RESET_TO_BAE = 1;
wait_ms(10);
- BAE_SW_EN_DS = 0; //Switch ON BAE
+ RESET_TO_BAE = 0;
}
void RST_PL_BEE()
{
- PL_SW_EN_DS = 1; // switching OFF PL
+ RESET_TO_PYLD = 1;
wait_ms(10);
- PL_SW_EN_DS = 0; // Switch ON PL
+ RESET_TO_PYLD = 0;
+}
+
+void CDMS_INTERNAL_RESET()
+{
+ NVIC_SystemReset();
+}
+
+void SYS_PWR_RESET() // Have to be decided with EPS team.
+{
+
+}
+
+void EPS_V_A_EN() // This is a reset function
+{
+ TRXY_PWR_CNTRL = 0;
+ TRZ_PWR_CNTRL = 0;
+ wait_ms(10);
+ TRXY_PWR_CNTRL = 1;
+ TRZ_PWR_CNTRL = 1;
+}
+
+void EPS_V_C_EN() // This is a reset function
+{
+ COM_RX_CNTRL = 0;
+ wait_ms(10);
+ COM_RX_CNTRL = 1;
}
void RST_HK_COUNTER()
@@ -151,12 +242,24 @@
return ACK;
}
+void CDMS_RD_RTC(uint64_t *time)
+{
+ *time = FCTN_CDMS_RD_RTC();
+}
+
+void CDMS_CALIB_RTC()
+{
+
+}
+
void CDMS_RESET()
{
NVIC_SystemReset();
}
-void CDMS_INTERNAL_RESET()
+/*
+//void CDMS_INTERNAL_RESET()
{
-}
\ No newline at end of file
+}
+*/
\ No newline at end of file
--- a/RESET_functions.h Tue Jul 05 16:04:31 2016 +0000
+++ b/RESET_functions.h Wed Jul 06 08:09:22 2016 +0000
@@ -1,13 +1,12 @@
-DigitalOut pwr_comrx (PIN72);
void RESET_COMRX();
void RESET_RTC();
void RESET_COMRX()
{
- pwr_comrx = 0;
+ COM_RX_CNTRL = 0;
wait_ms(10);
- pwr_comrx =1;
+ COM_RX_CNTRL =1;
}
void RESET_RTC()
