Repository for CDMS code
Dependencies: SimpleDMA mbed-rtos mbed eeprom
Fork of COM_MNG_TMTC_SIMPLE by
FMS_all.h@245:da9d1bd999da, 2016-07-10 (annotated)
- Committer:
- ee12b079
- Date:
- Sun Jul 10 13:47:26 2016 +0000
- Revision:
- 245:da9d1bd999da
- Parent:
- 224:3ac1f91e0ebc
- Child:
- 248:407ab7e337cd
- Child:
- 255:642ea552ac77
- Child:
- 257:7d404e9dc9e2
Making integrated code of CDMS
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ee12b079 | 209:63e9c8f8b5d2 | 1 | |
ee12b079 | 245:da9d1bd999da | 2 | //Run processes |
ee12b079 | 209:63e9c8f8b5d2 | 3 | void P_PL_INIT(); |
ee12b079 | 209:63e9c8f8b5d2 | 4 | void P_PL_MAIN(); |
ee12b079 | 209:63e9c8f8b5d2 | 5 | void P_COM_INIT(); |
ee12b079 | 209:63e9c8f8b5d2 | 6 | void P_CDMS_HK_MAIN(); |
ee12b079 | 209:63e9c8f8b5d2 | 7 | void P_PL_RCV_SC_DATA(); |
ee12b079 | 209:63e9c8f8b5d2 | 8 | void P_CDMS_INIT_SD(); |
ee12b079 | 245:da9d1bd999da | 9 | |
ee12b079 | 245:da9d1bd999da | 10 | // Switch ON/OFF functions |
ee12b079 | 209:63e9c8f8b5d2 | 11 | void CDMS_SD_SW_ON(); |
ee12b079 | 209:63e9c8f8b5d2 | 12 | void CDMS_SD_SW_OFF(); |
ee12b079 | 245:da9d1bd999da | 13 | void CDMS_RTC_ON(); |
ee12b079 | 245:da9d1bd999da | 14 | void CDMS_RTC_OFF(); |
ee12b079 | 209:63e9c8f8b5d2 | 15 | void SW_ON_BAE(); |
ee12b079 | 209:63e9c8f8b5d2 | 16 | void SW_OFF_BAE(); |
ee12b079 | 209:63e9c8f8b5d2 | 17 | void SW_ON_PL_BEE(); |
ee12b079 | 209:63e9c8f8b5d2 | 18 | void SW_OFF_PL_BEE(); |
ee12b079 | 209:63e9c8f8b5d2 | 19 | void SW_ON_PL_EPS(); |
ee12b079 | 209:63e9c8f8b5d2 | 20 | void SW_OFF_PL_EPS(); |
ee12b079 | 209:63e9c8f8b5d2 | 21 | void SW_ON_V_A_EN(); |
ee12b079 | 209:63e9c8f8b5d2 | 22 | void SW_OFF_V_A_EN(); |
ee12b079 | 245:da9d1bd999da | 23 | |
ee12b079 | 245:da9d1bd999da | 24 | // RST functions |
ee12b079 | 209:63e9c8f8b5d2 | 25 | void RST_SD(); |
ee12b079 | 245:da9d1bd999da | 26 | void SW_RST_BAE(); |
ee12b079 | 245:da9d1bd999da | 27 | void SW_RST_PL_BEE(); |
ee12b079 | 209:63e9c8f8b5d2 | 28 | void RST_BAE(); |
ee12b079 | 209:63e9c8f8b5d2 | 29 | void RST_PL_BEE(); |
ee12b079 | 245:da9d1bd999da | 30 | void CDMS_INTERNAL_RESET(); |
ee12b079 | 245:da9d1bd999da | 31 | void SYS_PWR_RESET(); // Have to be decided with EPS team. |
ee12b079 | 245:da9d1bd999da | 32 | void EPS_V_A_EN(); |
ee12b079 | 245:da9d1bd999da | 33 | void EPS_V_C_EN(); |
ee12b079 | 245:da9d1bd999da | 34 | |
ee12b079 | 209:63e9c8f8b5d2 | 35 | void RST_HK_COUNTER(); |
ee12b079 | 209:63e9c8f8b5d2 | 36 | uint8_t CDMS_RD_SD_HK(uint8_t *); |
ee12b079 | 245:da9d1bd999da | 37 | void CDMS_RD_RTC(uint64_t *); |
ee12b079 | 245:da9d1bd999da | 38 | void CDMS_CALIB_RTC(); |
chaithanyarss | 224:3ac1f91e0ebc | 39 | void CDMS_RESET(); |
ee12b079 | 245:da9d1bd999da | 40 | |
ee12b079 | 209:63e9c8f8b5d2 | 41 | |
ee12b079 | 209:63e9c8f8b5d2 | 42 | void P_PL_INIT() |
ee12b079 | 209:63e9c8f8b5d2 | 43 | { |
ee12b079 | 209:63e9c8f8b5d2 | 44 | |
ee12b079 | 209:63e9c8f8b5d2 | 45 | } |
ee12b079 | 209:63e9c8f8b5d2 | 46 | |
ee12b079 | 209:63e9c8f8b5d2 | 47 | void P_PL_MAIN() |
ee12b079 | 209:63e9c8f8b5d2 | 48 | { |
ee12b079 | 245:da9d1bd999da | 49 | // FCTN_CDMS_PL_MAIN((void *)NULL); |
ee12b079 | 209:63e9c8f8b5d2 | 50 | } |
ee12b079 | 209:63e9c8f8b5d2 | 51 | |
ee12b079 | 209:63e9c8f8b5d2 | 52 | void P_COM_INIT() |
ee12b079 | 209:63e9c8f8b5d2 | 53 | { |
ee12b079 | 245:da9d1bd999da | 54 | P_COM_INIT; |
ee12b079 | 209:63e9c8f8b5d2 | 55 | } |
ee12b079 | 209:63e9c8f8b5d2 | 56 | |
ee12b079 | 209:63e9c8f8b5d2 | 57 | void P_CDMS_HK_MAIN() |
ee12b079 | 209:63e9c8f8b5d2 | 58 | { |
ee12b079 | 245:da9d1bd999da | 59 | FCTN_CDMS_HK_MAIN((void *)NULL); |
ee12b079 | 209:63e9c8f8b5d2 | 60 | } |
ee12b079 | 209:63e9c8f8b5d2 | 61 | |
ee12b079 | 209:63e9c8f8b5d2 | 62 | void P_PL_RCV_SC_DATA() |
ee12b079 | 209:63e9c8f8b5d2 | 63 | { |
ee12b079 | 245:da9d1bd999da | 64 | |
ee12b079 | 209:63e9c8f8b5d2 | 65 | } |
ee12b079 | 209:63e9c8f8b5d2 | 66 | |
ee12b079 | 209:63e9c8f8b5d2 | 67 | void P_CDMS_INIT_SD() |
ee12b079 | 209:63e9c8f8b5d2 | 68 | { |
ee12b079 | 209:63e9c8f8b5d2 | 69 | FCTN_CDMS_SD_INIT(); |
ee12b079 | 209:63e9c8f8b5d2 | 70 | } |
ee12b079 | 209:63e9c8f8b5d2 | 71 | |
ee12b079 | 209:63e9c8f8b5d2 | 72 | void CDMS_SD_SW_ON() |
ee12b079 | 209:63e9c8f8b5d2 | 73 | { |
ee12b079 | 245:da9d1bd999da | 74 | SD_SW_EN_DS = 0; |
ee12b079 | 209:63e9c8f8b5d2 | 75 | } |
ee12b079 | 209:63e9c8f8b5d2 | 76 | |
ee12b079 | 209:63e9c8f8b5d2 | 77 | void CDMS_SD_SW_OFF() |
ee12b079 | 209:63e9c8f8b5d2 | 78 | { |
ee12b079 | 245:da9d1bd999da | 79 | SD_SW_EN_DS = 1; |
ee12b079 | 209:63e9c8f8b5d2 | 80 | } |
ee12b079 | 209:63e9c8f8b5d2 | 81 | |
ee12b079 | 245:da9d1bd999da | 82 | void CDMS_RTC_ON() |
ee12b079 | 209:63e9c8f8b5d2 | 83 | { |
ee12b079 | 245:da9d1bd999da | 84 | |
ee12b079 | 209:63e9c8f8b5d2 | 85 | } |
ee12b079 | 209:63e9c8f8b5d2 | 86 | |
ee12b079 | 245:da9d1bd999da | 87 | void CDMS_RTC_OFF() |
ee12b079 | 209:63e9c8f8b5d2 | 88 | { |
ee12b079 | 209:63e9c8f8b5d2 | 89 | |
ee12b079 | 209:63e9c8f8b5d2 | 90 | } |
ee12b079 | 209:63e9c8f8b5d2 | 91 | |
ee12b079 | 245:da9d1bd999da | 92 | void SW_ON_BAE() |
ee12b079 | 245:da9d1bd999da | 93 | { |
ee12b079 | 245:da9d1bd999da | 94 | BAE_SW_EN_DS = 0; |
ee12b079 | 245:da9d1bd999da | 95 | } |
ee12b079 | 245:da9d1bd999da | 96 | |
ee12b079 | 245:da9d1bd999da | 97 | void SW_OFF_BAE() |
ee12b079 | 245:da9d1bd999da | 98 | { |
ee12b079 | 245:da9d1bd999da | 99 | BAE_SW_EN_DS = 1; |
ee12b079 | 245:da9d1bd999da | 100 | } |
ee12b079 | 245:da9d1bd999da | 101 | |
ee12b079 | 245:da9d1bd999da | 102 | void SW_ON_PL_BEE() |
ee12b079 | 245:da9d1bd999da | 103 | { |
ee12b079 | 245:da9d1bd999da | 104 | PYLD_DFF_CLK = 0;\ |
ee12b079 | 245:da9d1bd999da | 105 | PYLD_DFF = 1;\ |
ee12b079 | 245:da9d1bd999da | 106 | wait_us(1);\ |
ee12b079 | 245:da9d1bd999da | 107 | PYLD_DFF_CLK = 1;\ |
ee12b079 | 245:da9d1bd999da | 108 | wait_us(1);\ |
ee12b079 | 245:da9d1bd999da | 109 | PYLD_DFF_CLK = 0;\ |
ee12b079 | 245:da9d1bd999da | 110 | wait_us(1);\ |
ee12b079 | 245:da9d1bd999da | 111 | } |
ee12b079 | 245:da9d1bd999da | 112 | |
ee12b079 | 245:da9d1bd999da | 113 | void SW_OFF_PL_BEE() |
ee12b079 | 245:da9d1bd999da | 114 | { |
ee12b079 | 245:da9d1bd999da | 115 | PYLD_DFF_CLK = 0; |
ee12b079 | 245:da9d1bd999da | 116 | PYLD_DFF = 0; |
ee12b079 | 245:da9d1bd999da | 117 | wait_us(1); |
ee12b079 | 245:da9d1bd999da | 118 | PYLD_DFF_CLK = 1; |
ee12b079 | 245:da9d1bd999da | 119 | wait_us(1); |
ee12b079 | 245:da9d1bd999da | 120 | PYLD_DFF_CLK = 0; |
ee12b079 | 245:da9d1bd999da | 121 | wait_us(1); |
ee12b079 | 245:da9d1bd999da | 122 | } |
ee12b079 | 245:da9d1bd999da | 123 | |
ee12b079 | 245:da9d1bd999da | 124 | void SW_ON_PL_EPS() |
ee12b079 | 245:da9d1bd999da | 125 | { |
ee12b079 | 245:da9d1bd999da | 126 | PYLD_EPS_DFF_PWR_CLK = 0;\ |
ee12b079 | 245:da9d1bd999da | 127 | PYLD_EPS_DFF_PWR = 1;\ |
ee12b079 | 245:da9d1bd999da | 128 | wait_us(1);\ |
ee12b079 | 245:da9d1bd999da | 129 | PYLD_EPS_DFF_PWR_CLK = 1;\ |
ee12b079 | 245:da9d1bd999da | 130 | wait_us(1);\ |
ee12b079 | 245:da9d1bd999da | 131 | PYLD_EPS_DFF_PWR_CLK = 0;\ |
ee12b079 | 245:da9d1bd999da | 132 | wait_us(1);\ |
ee12b079 | 245:da9d1bd999da | 133 | } |
ee12b079 | 245:da9d1bd999da | 134 | |
ee12b079 | 209:63e9c8f8b5d2 | 135 | void SW_OFF_PL_EPS() |
ee12b079 | 209:63e9c8f8b5d2 | 136 | { |
ee12b079 | 245:da9d1bd999da | 137 | PYLD_EPS_DFF_PWR_CLK = 0;\ |
ee12b079 | 245:da9d1bd999da | 138 | PYLD_EPS_DFF_PWR = 0;\ |
ee12b079 | 245:da9d1bd999da | 139 | wait_us(1);\ |
ee12b079 | 245:da9d1bd999da | 140 | PYLD_EPS_DFF_PWR_CLK = 1;\ |
ee12b079 | 245:da9d1bd999da | 141 | wait_us(1);\ |
ee12b079 | 245:da9d1bd999da | 142 | PYLD_EPS_DFF_PWR_CLK = 0;\ |
ee12b079 | 245:da9d1bd999da | 143 | wait_us(1);\ |
ee12b079 | 209:63e9c8f8b5d2 | 144 | } |
ee12b079 | 209:63e9c8f8b5d2 | 145 | |
ee12b079 | 209:63e9c8f8b5d2 | 146 | void SW_ON_V_A_EN() |
ee12b079 | 209:63e9c8f8b5d2 | 147 | { |
ee12b079 | 245:da9d1bd999da | 148 | TRXY_PWR_CNTRL = 1; |
ee12b079 | 245:da9d1bd999da | 149 | TRZ_PWR_CNTRL = 1; |
ee12b079 | 209:63e9c8f8b5d2 | 150 | } |
ee12b079 | 209:63e9c8f8b5d2 | 151 | |
ee12b079 | 209:63e9c8f8b5d2 | 152 | void SW_OFF_V_A_EN() |
ee12b079 | 209:63e9c8f8b5d2 | 153 | { |
ee12b079 | 245:da9d1bd999da | 154 | TRXY_PWR_CNTRL = 0; |
ee12b079 | 245:da9d1bd999da | 155 | TRZ_PWR_CNTRL = 0; |
ee12b079 | 209:63e9c8f8b5d2 | 156 | } |
ee12b079 | 209:63e9c8f8b5d2 | 157 | |
ee12b079 | 209:63e9c8f8b5d2 | 158 | void RST_SD() |
ee12b079 | 209:63e9c8f8b5d2 | 159 | { |
ee12b079 | 245:da9d1bd999da | 160 | SD_SW_EN_DS = 1; |
ee12b079 | 209:63e9c8f8b5d2 | 161 | wait_ms(10); |
ee12b079 | 209:63e9c8f8b5d2 | 162 | SD_SW_EN_DS = 0; |
ee12b079 | 245:da9d1bd999da | 163 | } |
ee12b079 | 245:da9d1bd999da | 164 | |
ee12b079 | 245:da9d1bd999da | 165 | void SW_RST_BAE() |
ee12b079 | 245:da9d1bd999da | 166 | { |
ee12b079 | 245:da9d1bd999da | 167 | BAE_SW_EN_DS = 1; |
ee12b079 | 245:da9d1bd999da | 168 | wait_ms(10); |
ee12b079 | 245:da9d1bd999da | 169 | BAE_SW_EN_DS = 0; |
ee12b079 | 245:da9d1bd999da | 170 | } |
ee12b079 | 245:da9d1bd999da | 171 | |
ee12b079 | 245:da9d1bd999da | 172 | void SW_RST_PL_BEE() |
ee12b079 | 245:da9d1bd999da | 173 | { |
ee12b079 | 245:da9d1bd999da | 174 | PYLD_DFF = 1; |
ee12b079 | 245:da9d1bd999da | 175 | wait_ms(10); |
ee12b079 | 245:da9d1bd999da | 176 | PYLD_DFF = 0; |
ee12b079 | 209:63e9c8f8b5d2 | 177 | } |
ee12b079 | 209:63e9c8f8b5d2 | 178 | |
ee12b079 | 209:63e9c8f8b5d2 | 179 | void RST_BAE() |
ee12b079 | 209:63e9c8f8b5d2 | 180 | { |
ee12b079 | 245:da9d1bd999da | 181 | RESET_TO_BAE = 1; |
ee12b079 | 209:63e9c8f8b5d2 | 182 | wait_ms(10); |
ee12b079 | 245:da9d1bd999da | 183 | RESET_TO_BAE = 0; |
ee12b079 | 209:63e9c8f8b5d2 | 184 | } |
ee12b079 | 209:63e9c8f8b5d2 | 185 | |
ee12b079 | 209:63e9c8f8b5d2 | 186 | void RST_PL_BEE() |
ee12b079 | 209:63e9c8f8b5d2 | 187 | { |
ee12b079 | 245:da9d1bd999da | 188 | RESET_TO_PYLD = 1; |
ee12b079 | 209:63e9c8f8b5d2 | 189 | wait_ms(10); |
ee12b079 | 245:da9d1bd999da | 190 | RESET_TO_PYLD = 0; |
ee12b079 | 245:da9d1bd999da | 191 | } |
ee12b079 | 245:da9d1bd999da | 192 | |
ee12b079 | 245:da9d1bd999da | 193 | void CDMS_INTERNAL_RESET() |
ee12b079 | 245:da9d1bd999da | 194 | { |
ee12b079 | 245:da9d1bd999da | 195 | NVIC_SystemReset(); |
ee12b079 | 245:da9d1bd999da | 196 | } |
ee12b079 | 245:da9d1bd999da | 197 | |
ee12b079 | 245:da9d1bd999da | 198 | void SYS_PWR_RESET() // Have to be decided with EPS team. |
ee12b079 | 245:da9d1bd999da | 199 | { |
ee12b079 | 245:da9d1bd999da | 200 | |
ee12b079 | 245:da9d1bd999da | 201 | } |
ee12b079 | 245:da9d1bd999da | 202 | |
ee12b079 | 245:da9d1bd999da | 203 | void EPS_V_A_EN() // This is a reset function |
ee12b079 | 245:da9d1bd999da | 204 | { |
ee12b079 | 245:da9d1bd999da | 205 | TRXY_PWR_CNTRL = 0; |
ee12b079 | 245:da9d1bd999da | 206 | TRZ_PWR_CNTRL = 0; |
ee12b079 | 245:da9d1bd999da | 207 | wait_ms(10); |
ee12b079 | 245:da9d1bd999da | 208 | TRXY_PWR_CNTRL = 1; |
ee12b079 | 245:da9d1bd999da | 209 | TRZ_PWR_CNTRL = 1; |
ee12b079 | 245:da9d1bd999da | 210 | } |
ee12b079 | 245:da9d1bd999da | 211 | |
ee12b079 | 245:da9d1bd999da | 212 | void EPS_V_C_EN() // This is a reset function |
ee12b079 | 245:da9d1bd999da | 213 | { |
ee12b079 | 245:da9d1bd999da | 214 | COM_RX_CNTRL = 0; |
ee12b079 | 245:da9d1bd999da | 215 | wait_ms(10); |
ee12b079 | 245:da9d1bd999da | 216 | COM_RX_CNTRL = 1; |
ee12b079 | 209:63e9c8f8b5d2 | 217 | } |
ee12b079 | 209:63e9c8f8b5d2 | 218 | |
ee12b079 | 209:63e9c8f8b5d2 | 219 | void RST_HK_COUNTER() |
ee12b079 | 209:63e9c8f8b5d2 | 220 | { |
ee12b079 | 209:63e9c8f8b5d2 | 221 | firstCount = true; |
ee12b079 | 209:63e9c8f8b5d2 | 222 | } |
ee12b079 | 209:63e9c8f8b5d2 | 223 | |
ee12b079 | 209:63e9c8f8b5d2 | 224 | uint8_t CDMS_RD_SD_HK(uint8_t *sd_statusbits) |
ee12b079 | 209:63e9c8f8b5d2 | 225 | { |
ee12b079 | 209:63e9c8f8b5d2 | 226 | uint8_t p; |
ee12b079 | 209:63e9c8f8b5d2 | 227 | uint8_t ACK; |
ee12b079 | 209:63e9c8f8b5d2 | 228 | if(SD_SW_EN_DS != DEVICE_POWERED) |
ee12b079 | 209:63e9c8f8b5d2 | 229 | { |
ee12b079 | 209:63e9c8f8b5d2 | 230 | ACK = 0x89; |
ee12b079 | 209:63e9c8f8b5d2 | 231 | SD_RD_ERROR = 1; |
ee12b079 | 209:63e9c8f8b5d2 | 232 | //Generate TM |
ee12b079 | 209:63e9c8f8b5d2 | 233 | } |
ee12b079 | 209:63e9c8f8b5d2 | 234 | else |
ee12b079 | 209:63e9c8f8b5d2 | 235 | { |
ee12b079 | 209:63e9c8f8b5d2 | 236 | p = disk_read_statusbits(sd_statusbits); |
ee12b079 | 209:63e9c8f8b5d2 | 237 | if(p == 0) |
ee12b079 | 209:63e9c8f8b5d2 | 238 | ACK = 0xA0; |
ee12b079 | 209:63e9c8f8b5d2 | 239 | else |
ee12b079 | 209:63e9c8f8b5d2 | 240 | ACK = 0x89; |
ee12b079 | 209:63e9c8f8b5d2 | 241 | } |
ee12b079 | 209:63e9c8f8b5d2 | 242 | return ACK; |
ee12b079 | 209:63e9c8f8b5d2 | 243 | } |
ee12b079 | 209:63e9c8f8b5d2 | 244 | |
ee12b079 | 245:da9d1bd999da | 245 | void CDMS_RD_RTC(uint64_t *time) |
ee12b079 | 245:da9d1bd999da | 246 | { |
ee12b079 | 245:da9d1bd999da | 247 | *time = FCTN_CDMS_RD_RTC(); |
ee12b079 | 245:da9d1bd999da | 248 | } |
ee12b079 | 245:da9d1bd999da | 249 | |
ee12b079 | 245:da9d1bd999da | 250 | void CDMS_CALIB_RTC() |
ee12b079 | 245:da9d1bd999da | 251 | { |
ee12b079 | 245:da9d1bd999da | 252 | |
ee12b079 | 245:da9d1bd999da | 253 | } |
ee12b079 | 245:da9d1bd999da | 254 | |
chaithanyarss | 224:3ac1f91e0ebc | 255 | void CDMS_RESET() |
chaithanyarss | 224:3ac1f91e0ebc | 256 | { |
chaithanyarss | 224:3ac1f91e0ebc | 257 | NVIC_SystemReset(); |
chaithanyarss | 224:3ac1f91e0ebc | 258 | } |
chaithanyarss | 224:3ac1f91e0ebc | 259 | |
ee12b079 | 245:da9d1bd999da | 260 | /* |
ee12b079 | 245:da9d1bd999da | 261 | //void CDMS_INTERNAL_RESET() |
ee12b079 | 209:63e9c8f8b5d2 | 262 | { |
ee12b079 | 209:63e9c8f8b5d2 | 263 | |
ee12b079 | 245:da9d1bd999da | 264 | } |
ee12b079 | 245:da9d1bd999da | 265 | */ |