Repository for CDMS code

Dependencies:   SimpleDMA mbed-rtos mbed eeprom

Fork of COM_MNG_TMTC_SIMPLE by Shreesha S

Committer:
chaithanyarss
Date:
Thu Jun 30 14:00:33 2016 +0000
Revision:
206:fba4aeebf004
For integrating PL_Main with rest of CDMS code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
chaithanyarss 206:fba4aeebf004 1 #include "CDMS_HK.h"
chaithanyarss 206:fba4aeebf004 2
chaithanyarss 206:fba4aeebf004 3 uint8_t ACK_CODE;
chaithanyarss 206:fba4aeebf004 4
chaithanyarss 206:fba4aeebf004 5 void CDMS_standby_prcs();
chaithanyarss 206:fba4aeebf004 6 void CDMS_run_prcs();
chaithanyarss 206:fba4aeebf004 7 void CDMS_rst_pwr();
chaithanyarss 206:fba4aeebf004 8 void CDMS_swch_pwr_on();
chaithanyarss 206:fba4aeebf004 9 void CDMS_swch_pwr_off();
chaithanyarss 206:fba4aeebf004 10 void CDMS_rst_hk_counter();
chaithanyarss 206:fba4aeebf004 11 void CDMS_rd_rtc();
chaithanyarss 206:fba4aeebf004 12 void CDMS_mng_rtc();
chaithanyarss 206:fba4aeebf004 13 void CDMS_rd_sd_hk();
chaithanyarss 206:fba4aeebf004 14
chaithanyarss 206:fba4aeebf004 15 extern uint8_t PL_STANDBY_STATE;
chaithanyarss 206:fba4aeebf004 16 extern bool STANDBY_PL;
chaithanyarss 206:fba4aeebf004 17 extern uint8_t CDMS_HK_STANDBY_STATE;
chaithanyarss 206:fba4aeebf004 18 extern bool STANDBY_CDMS_HK;
chaithanyarss 206:fba4aeebf004 19
chaithanyarss 206:fba4aeebf004 20 extern bool SD_RD_ERROR;
chaithanyarss 206:fba4aeebf004 21
chaithanyarss 206:fba4aeebf004 22 extern uint8_t BAE_STATUS;
chaithanyarss 206:fba4aeebf004 23 extern uint8_t PL_STATUS;
chaithanyarss 206:fba4aeebf004 24 extern uint8_t SD_STATUS;
chaithanyarss 206:fba4aeebf004 25
chaithanyarss 206:fba4aeebf004 26 // These are defined in CDMS_HK.h Please check
chaithanyarss 206:fba4aeebf004 27 #define DEVICE_ENABLED 0x00;
chaithanyarss 206:fba4aeebf004 28 #define DEVICE_POWERED 0x01;
chaithanyarss 206:fba4aeebf004 29 #define DEVICE_OC_FAULT 0x02;
chaithanyarss 206:fba4aeebf004 30 #define DEVICE_DISABLED 0x03;
chaithanyarss 206:fba4aeebf004 31 DigitalOut SD_SW_EN_DS (PIN97);
chaithanyarss 206:fba4aeebf004 32 DigitalOut BAE_SW_EN_DS (PIN47);
chaithanyarss 206:fba4aeebf004 33
chaithanyarss 206:fba4aeebf004 34
chaithanyarss 206:fba4aeebf004 35 void CDMS_standby_prcs() // FID = 0x40
chaithanyarss 206:fba4aeebf004 36 {
chaithanyarss 206:fba4aeebf004 37 if(PL_STANDBY_STATE = 0x00)
chaithanyarss 206:fba4aeebf004 38 STANDBY_PL = 0;
chaithanyarss 206:fba4aeebf004 39 if(PL_STANDBY_STATE = 0x01)
chaithanyarss 206:fba4aeebf004 40 STANDBY_PL = 1;
chaithanyarss 206:fba4aeebf004 41 if(CDMS_HK_STANDBY_STATE = 0x00)
chaithanyarss 206:fba4aeebf004 42 STANDBY_CDMS_HK = 0;
chaithanyarss 206:fba4aeebf004 43 if(CDMS_HK_STANDBY_STATE = 0x01)
chaithanyarss 206:fba4aeebf004 44 STANDBY_CDMS_HK = 1;
chaithanyarss 206:fba4aeebf004 45 if(RCV_SC_STANDBY_STATE = 0x00)
chaithanyarss 206:fba4aeebf004 46 RCV_SC = 0;
chaithanyarss 206:fba4aeebf004 47 if(RCV_SC_STANDBY_STATE = 0x01)
chaithanyarss 206:fba4aeebf004 48 RCV_SC = 1;
chaithanyarss 206:fba4aeebf004 49 ACK_CODE = 0xC0;
chaithanyarss 206:fba4aeebf004 50 // Generate the TM
chaithanyarss 206:fba4aeebf004 51 }
chaithanyarss 206:fba4aeebf004 52
chaithanyarss 206:fba4aeebf004 53 void CDMS_run_prcs() // FID = 0x0_
chaithanyarss 206:fba4aeebf004 54 {
chaithanyarss 206:fba4aeebf004 55
chaithanyarss 206:fba4aeebf004 56 }
chaithanyarss 206:fba4aeebf004 57
chaithanyarss 206:fba4aeebf004 58 void CDMS_rst_pwr(uint8_t FID) // FID = 0x3_
chaithanyarss 206:fba4aeebf004 59 {
chaithanyarss 206:fba4aeebf004 60 switch(FID){
chaithanyarss 206:fba4aeebf004 61 case 0x31 : //power reset SD
chaithanyarss 206:fba4aeebf004 62 SD_SW_EN_DS = 0; //switching OFF
chaithanyarss 206:fba4aeebf004 63 wait_ms(10);
chaithanyarss 206:fba4aeebf004 64 SD_SW_EN_DS = 1; //switching ON
chaithanyarss 206:fba4aeebf004 65 ACK_CODE = 0xA0;
chaithanyarss 206:fba4aeebf004 66 // Generate TM
chaithanyarss 206:fba4aeebf004 67 }
chaithanyarss 206:fba4aeebf004 68 }
chaithanyarss 206:fba4aeebf004 69
chaithanyarss 206:fba4aeebf004 70 void CDMS_swch_pwr_on(uint8_t FID) // FID = 0x1_
chaithanyarss 206:fba4aeebf004 71 {
chaithanyarss 206:fba4aeebf004 72 if(FID = 0x14)
chaithanyarss 206:fba4aeebf004 73 {
chaithanyarss 206:fba4aeebf004 74 PL_STATUS = DEVICE_ENABLED;
chaithanyarss 206:fba4aeebf004 75 ACK_CODE = 0xA0;
chaithanyarss 206:fba4aeebf004 76 // Generate TM
chaithanyarss 206:fba4aeebf004 77 }
chaithanyarss 206:fba4aeebf004 78 else if(FID = 0x13)
chaithanyarss 206:fba4aeebf004 79 {
chaithanyarss 206:fba4aeebf004 80 BAE_STATUS = DEVICE_POWERED;
chaithanyarss 206:fba4aeebf004 81 BAE_SW_EN_DS = 1; //Power ON BAE
chaithanyarss 206:fba4aeebf004 82 ACK_CODE = 0xA0;
chaithanyarss 206:fba4aeebf004 83 // Generate TM
chaithanyarss 206:fba4aeebf004 84 }
chaithanyarss 206:fba4aeebf004 85 else if(FID = 0x11)
chaithanyarss 206:fba4aeebf004 86 {
chaithanyarss 206:fba4aeebf004 87 SD_STATUS = DEVICE_POWERED;
chaithanyarss 206:fba4aeebf004 88 SD_SW_EN_DS = 1; //Power ON SD
chaithanyarss 206:fba4aeebf004 89 FCTN_CDMS_SD_INIT();
chaithanyarss 206:fba4aeebf004 90 ACK_CODE = 0xA0;
chaithanyarss 206:fba4aeebf004 91 // Generate TM
chaithanyarss 206:fba4aeebf004 92 }
chaithanyarss 206:fba4aeebf004 93 else
chaithanyarss 206:fba4aeebf004 94 {
chaithanyarss 206:fba4aeebf004 95 ACK_CODE = 0x02;
chaithanyarss 206:fba4aeebf004 96 // Generate TM
chaithanyarss 206:fba4aeebf004 97 }
chaithanyarss 206:fba4aeebf004 98 }
chaithanyarss 206:fba4aeebf004 99
chaithanyarss 206:fba4aeebf004 100 void CDMS_swch_pwr_off(uint8_t FID) // FID = 0x2_
chaithanyarss 206:fba4aeebf004 101 {
chaithanyarss 206:fba4aeebf004 102 if(FID = 0x24)
chaithanyarss 206:fba4aeebf004 103 {
chaithanyarss 206:fba4aeebf004 104 PL_SW_EN_DS = 0; //switching OFF PL
chaithanyarss 206:fba4aeebf004 105 PL_STATUS = DEVICE_DISABLED;
chaithanyarss 206:fba4aeebf004 106 ACK_CODE = 0xA0;
chaithanyarss 206:fba4aeebf004 107 // Generate TM
chaithanyarss 206:fba4aeebf004 108 }
chaithanyarss 206:fba4aeebf004 109 else if(FID = 0x23)
chaithanyarss 206:fba4aeebf004 110 {
chaithanyarss 206:fba4aeebf004 111 BAE_SW_EN_DS = 0; //Switching OFF BAE
chaithanyarss 206:fba4aeebf004 112 BAE_STATUS = DEVICE_DISABLED;
chaithanyarss 206:fba4aeebf004 113 ACK_CODE = 0xA0;
chaithanyarss 206:fba4aeebf004 114 // Generate TM
chaithanyarss 206:fba4aeebf004 115 }
chaithanyarss 206:fba4aeebf004 116 else if(FID = 0x21)
chaithanyarss 206:fba4aeebf004 117 {
chaithanyarss 206:fba4aeebf004 118 SD_SW_EN_DS = 0; //Switching OFF SD
chaithanyarss 206:fba4aeebf004 119 SD_STATUS = DEVICE_DISABLED;
chaithanyarss 206:fba4aeebf004 120 FCTN_CDMS_SD_INIT();
chaithanyarss 206:fba4aeebf004 121 ACK_CODE = 0xA0;
chaithanyarss 206:fba4aeebf004 122 // Generate TM
chaithanyarss 206:fba4aeebf004 123 }
chaithanyarss 206:fba4aeebf004 124 else
chaithanyarss 206:fba4aeebf004 125 {
chaithanyarss 206:fba4aeebf004 126 ACK_CODE = 0x02;
chaithanyarss 206:fba4aeebf004 127 // Generate TM
chaithanyarss 206:fba4aeebf004 128 }
chaithanyarss 206:fba4aeebf004 129 }
chaithanyarss 206:fba4aeebf004 130
chaithanyarss 206:fba4aeebf004 131 void CDMS_rst_hk_counter() // FID = 0x41
chaithanyarss 206:fba4aeebf004 132 {
chaithanyarss 206:fba4aeebf004 133
chaithanyarss 206:fba4aeebf004 134 }
chaithanyarss 206:fba4aeebf004 135
chaithanyarss 206:fba4aeebf004 136 void CDMS_rd_rtc() // FID = 0xF1
chaithanyarss 206:fba4aeebf004 137 {
chaithanyarss 206:fba4aeebf004 138 uint8_t time = FCTN_CDMS_RD_RTC();
chaithanyarss 206:fba4aeebf004 139 // Check if time is read properly
chaithanyarss 206:fba4aeebf004 140 if( /*if error in reading*/ )
chaithanyarss 206:fba4aeebf004 141 {
chaithanyarss 206:fba4aeebf004 142 ACK_CODE = 0x88;
chaithanyarss 206:fba4aeebf004 143 // Generate TM
chaithanyarss 206:fba4aeebf004 144 }
chaithanyarss 206:fba4aeebf004 145 else if( /*if Time is read properly*/ )
chaithanyarss 206:fba4aeebf004 146 {
chaithanyarss 206:fba4aeebf004 147 ACK_CODE = 0xA0;
chaithanyarss 206:fba4aeebf004 148 // Generate TM
chaithanyarss 206:fba4aeebf004 149 }
chaithanyarss 206:fba4aeebf004 150 }
chaithanyarss 206:fba4aeebf004 151
chaithanyarss 206:fba4aeebf004 152 void CDMS_mng_rtc(uint64_t time)
chaithanyarss 206:fba4aeebf004 153 {
chaithanyarss 206:fba4aeebf004 154
chaithanyarss 206:fba4aeebf004 155 }
chaithanyarss 206:fba4aeebf004 156
chaithanyarss 206:fba4aeebf004 157 void CDMS_rd_sd_hk()
chaithanyarss 206:fba4aeebf004 158 {
chaithanyarss 206:fba4aeebf004 159 uint8_t sd_statusbits[64];
chaithanyarss 206:fba4aeebf004 160 uint8_t *p;
chaithanyarss 206:fba4aeebf004 161 int i;
chaithanyarss 206:fba4aeebf004 162 if(SD_SW_EN_DS != DEVICE_POWERED)
chaithanyarss 206:fba4aeebf004 163 {
chaithanyarss 206:fba4aeebf004 164 ACK_CODE = 0x89;
chaithanyarss 206:fba4aeebf004 165 SD_RD_ERROR = 1;
chaithanyarss 206:fba4aeebf004 166 //Generate TM
chaithanyarss 206:fba4aeebf004 167 }
chaithanyarss 206:fba4aeebf004 168 else
chaithanyarss 206:fba4aeebf004 169 {
chaithanyarss 206:fba4aeebf004 170 p = disk_read_statusbits();
chaithanyarss 206:fba4aeebf004 171 if(p != NULL)
chaithanyarss 206:fba4aeebf004 172 {
chaithanyarss 206:fba4aeebf004 173 for(i = 0; i<64; i++)
chaithanyarss 206:fba4aeebf004 174 sd_statusbits[i] = *(p + i);
chaithanyarss 206:fba4aeebf004 175 SD_RD_ERROR = 0;
chaithanyarss 206:fba4aeebf004 176 ACK_CODE = 0xA0;
chaithanyarss 206:fba4aeebf004 177 // Generate TM
chaithanyarss 206:fba4aeebf004 178 }
chaithanyarss 206:fba4aeebf004 179 else
chaithanyarss 206:fba4aeebf004 180 {
chaithanyarss 206:fba4aeebf004 181 ACK_CODE = 0x89;
chaithanyarss 206:fba4aeebf004 182 SD_RD_ERROR = 1;
chaithanyarss 206:fba4aeebf004 183 //Generate TM
chaithanyarss 206:fba4aeebf004 184 }
chaithanyarss 206:fba4aeebf004 185 }
chaithanyarss 206:fba4aeebf004 186 }
chaithanyarss 206:fba4aeebf004 187