Repository for CDMS code
Dependencies: SimpleDMA mbed-rtos mbed eeprom
Fork of COM_MNG_TMTC_SIMPLE by
FMS_all.h@235:c127b15409b2, 2016-07-06 (annotated)
- Committer:
- ee12b079
- Date:
- Wed Jul 06 08:09:22 2016 +0000
- Revision:
- 235:c127b15409b2
- Parent:
- 224:3ac1f91e0ebc
- Child:
- 248:407ab7e337cd
- Child:
- 255:642ea552ac77
- Child:
- 257:7d404e9dc9e2
Integrated Chaitanya's changes for HK thread and FMS TCs
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ee12b079 | 209:63e9c8f8b5d2 | 1 | |
ee12b079 | 235:c127b15409b2 | 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 | 235:c127b15409b2 | 9 | |
ee12b079 | 235:c127b15409b2 | 10 | // Switch ON/OFF functions |
ee12b079 | 209:63e9c8f8b5d2 | 11 | void CDMS_SD_SW_ON(); |
ee12b079 | 209:63e9c8f8b5d2 | 12 | void CDMS_SD_SW_OFF(); |
ee12b079 | 235:c127b15409b2 | 13 | void CDMS_RTC_ON(); |
ee12b079 | 235:c127b15409b2 | 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 | 235:c127b15409b2 | 23 | |
ee12b079 | 235:c127b15409b2 | 24 | // RST functions |
ee12b079 | 209:63e9c8f8b5d2 | 25 | void RST_SD(); |
ee12b079 | 235:c127b15409b2 | 26 | void SW_RST_BAE(); |
ee12b079 | 235:c127b15409b2 | 27 | void SW_RST_PL_BEE(); |
ee12b079 | 209:63e9c8f8b5d2 | 28 | void RST_BAE(); |
ee12b079 | 209:63e9c8f8b5d2 | 29 | void RST_PL_BEE(); |
ee12b079 | 235:c127b15409b2 | 30 | void CDMS_INTERNAL_RESET(); |
ee12b079 | 235:c127b15409b2 | 31 | void SYS_PWR_RESET(); // Have to be decided with EPS team. |
ee12b079 | 235:c127b15409b2 | 32 | void EPS_V_A_EN(); |
ee12b079 | 235:c127b15409b2 | 33 | void EPS_V_C_EN(); |
ee12b079 | 235:c127b15409b2 | 34 | |
ee12b079 | 209:63e9c8f8b5d2 | 35 | void RST_HK_COUNTER(); |
ee12b079 | 209:63e9c8f8b5d2 | 36 | uint8_t CDMS_RD_SD_HK(uint8_t *); |
ee12b079 | 235:c127b15409b2 | 37 | void CDMS_RD_RTC(uint64_t *); |
ee12b079 | 235:c127b15409b2 | 38 | void CDMS_CALIB_RTC(); |
chaithanyarss | 224:3ac1f91e0ebc | 39 | void CDMS_RESET(); |
ee12b079 | 235:c127b15409b2 | 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 | 235:c127b15409b2 | 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 | 235:c127b15409b2 | 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 | 235:c127b15409b2 | 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 | 235:c127b15409b2 | 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 | 235:c127b15409b2 | 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 | 235:c127b15409b2 | 79 | SD_SW_EN_DS = 1; |
ee12b079 | 209:63e9c8f8b5d2 | 80 | } |
ee12b079 | 209:63e9c8f8b5d2 | 81 | |
ee12b079 | 235:c127b15409b2 | 82 | void CDMS_RTC_ON() |
ee12b079 | 209:63e9c8f8b5d2 | 83 | { |
ee12b079 | 235:c127b15409b2 | 84 | |
ee12b079 | 209:63e9c8f8b5d2 | 85 | } |
ee12b079 | 209:63e9c8f8b5d2 | 86 | |
ee12b079 | 235:c127b15409b2 | 87 | void CDMS_RTC_OFF() |
ee12b079 | 209:63e9c8f8b5d2 | 88 | { |
ee12b079 | 209:63e9c8f8b5d2 | 89 | |
ee12b079 | 209:63e9c8f8b5d2 | 90 | } |
ee12b079 | 209:63e9c8f8b5d2 | 91 | |
ee12b079 | 235:c127b15409b2 | 92 | void SW_ON_BAE() |
ee12b079 | 235:c127b15409b2 | 93 | { |
ee12b079 | 235:c127b15409b2 | 94 | BAE_SW_EN_DS = 0; |
ee12b079 | 235:c127b15409b2 | 95 | } |
ee12b079 | 235:c127b15409b2 | 96 | |
ee12b079 | 235:c127b15409b2 | 97 | void SW_OFF_BAE() |
ee12b079 | 235:c127b15409b2 | 98 | { |
ee12b079 | 235:c127b15409b2 | 99 | BAE_SW_EN_DS = 1; |
ee12b079 | 235:c127b15409b2 | 100 | } |
ee12b079 | 235:c127b15409b2 | 101 | |
ee12b079 | 235:c127b15409b2 | 102 | void SW_ON_PL_BEE() |
ee12b079 | 235:c127b15409b2 | 103 | { |
ee12b079 | 235:c127b15409b2 | 104 | PYLD_DFF_CLK = 0;\ |
ee12b079 | 235:c127b15409b2 | 105 | PYLD_DFF = 1;\ |
ee12b079 | 235:c127b15409b2 | 106 | wait_us(1);\ |
ee12b079 | 235:c127b15409b2 | 107 | PYLD_DFF_CLK = 1;\ |
ee12b079 | 235:c127b15409b2 | 108 | wait_us(1);\ |
ee12b079 | 235:c127b15409b2 | 109 | PYLD_DFF_CLK = 0;\ |
ee12b079 | 235:c127b15409b2 | 110 | wait_us(1);\ |
ee12b079 | 235:c127b15409b2 | 111 | } |
ee12b079 | 235:c127b15409b2 | 112 | |
ee12b079 | 235:c127b15409b2 | 113 | void SW_OFF_PL_BEE() |
ee12b079 | 235:c127b15409b2 | 114 | { |
ee12b079 | 235:c127b15409b2 | 115 | PYLD_DFF_CLK = 0; |
ee12b079 | 235:c127b15409b2 | 116 | PYLD_DFF = 0; |
ee12b079 | 235:c127b15409b2 | 117 | wait_us(1); |
ee12b079 | 235:c127b15409b2 | 118 | PYLD_DFF_CLK = 1; |
ee12b079 | 235:c127b15409b2 | 119 | wait_us(1); |
ee12b079 | 235:c127b15409b2 | 120 | PYLD_DFF_CLK = 0; |
ee12b079 | 235:c127b15409b2 | 121 | wait_us(1); |
ee12b079 | 235:c127b15409b2 | 122 | } |
ee12b079 | 235:c127b15409b2 | 123 | |
ee12b079 | 235:c127b15409b2 | 124 | void SW_ON_PL_EPS() |
ee12b079 | 235:c127b15409b2 | 125 | { |
ee12b079 | 235:c127b15409b2 | 126 | PYLD_EPS_DFF_PWR_CLK = 0;\ |
ee12b079 | 235:c127b15409b2 | 127 | PYLD_EPS_DFF_PWR = 1;\ |
ee12b079 | 235:c127b15409b2 | 128 | wait_us(1);\ |
ee12b079 | 235:c127b15409b2 | 129 | PYLD_EPS_DFF_PWR_CLK = 1;\ |
ee12b079 | 235:c127b15409b2 | 130 | wait_us(1);\ |
ee12b079 | 235:c127b15409b2 | 131 | PYLD_EPS_DFF_PWR_CLK = 0;\ |
ee12b079 | 235:c127b15409b2 | 132 | wait_us(1);\ |
ee12b079 | 235:c127b15409b2 | 133 | } |
ee12b079 | 235:c127b15409b2 | 134 | |
ee12b079 | 209:63e9c8f8b5d2 | 135 | void SW_OFF_PL_EPS() |
ee12b079 | 209:63e9c8f8b5d2 | 136 | { |
ee12b079 | 235:c127b15409b2 | 137 | PYLD_EPS_DFF_PWR_CLK = 0;\ |
ee12b079 | 235:c127b15409b2 | 138 | PYLD_EPS_DFF_PWR = 0;\ |
ee12b079 | 235:c127b15409b2 | 139 | wait_us(1);\ |
ee12b079 | 235:c127b15409b2 | 140 | PYLD_EPS_DFF_PWR_CLK = 1;\ |
ee12b079 | 235:c127b15409b2 | 141 | wait_us(1);\ |
ee12b079 | 235:c127b15409b2 | 142 | PYLD_EPS_DFF_PWR_CLK = 0;\ |
ee12b079 | 235:c127b15409b2 | 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 | 235:c127b15409b2 | 148 | TRXY_PWR_CNTRL = 1; |
ee12b079 | 235:c127b15409b2 | 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 | 235:c127b15409b2 | 154 | TRXY_PWR_CNTRL = 0; |
ee12b079 | 235:c127b15409b2 | 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 | 235:c127b15409b2 | 160 | SD_SW_EN_DS = 1; |
ee12b079 | 209:63e9c8f8b5d2 | 161 | wait_ms(10); |
ee12b079 | 209:63e9c8f8b5d2 | 162 | SD_SW_EN_DS = 0; |
ee12b079 | 235:c127b15409b2 | 163 | } |
ee12b079 | 235:c127b15409b2 | 164 | |
ee12b079 | 235:c127b15409b2 | 165 | void SW_RST_BAE() |
ee12b079 | 235:c127b15409b2 | 166 | { |
ee12b079 | 235:c127b15409b2 | 167 | BAE_SW_EN_DS = 1; |
ee12b079 | 235:c127b15409b2 | 168 | wait_ms(10); |
ee12b079 | 235:c127b15409b2 | 169 | BAE_SW_EN_DS = 0; |
ee12b079 | 235:c127b15409b2 | 170 | } |
ee12b079 | 235:c127b15409b2 | 171 | |
ee12b079 | 235:c127b15409b2 | 172 | void SW_RST_PL_BEE() |
ee12b079 | 235:c127b15409b2 | 173 | { |
ee12b079 | 235:c127b15409b2 | 174 | PYLD_DFF = 1; |
ee12b079 | 235:c127b15409b2 | 175 | wait_ms(10); |
ee12b079 | 235:c127b15409b2 | 176 | PYLD_DFF = 0; |
ee12b079 | 209:63e9c8f8b5d2 | 177 | } |
ee12b079 | 209:63e9c8f8b5d2 | 178 | |
ee12b079 | 209:63e9c8f8b5d2 | 179 | void RST_BAE() |
ee12b079 | 209:63e9c8f8b5d2 | 180 | { |
ee12b079 | 235:c127b15409b2 | 181 | RESET_TO_BAE = 1; |
ee12b079 | 209:63e9c8f8b5d2 | 182 | wait_ms(10); |
ee12b079 | 235:c127b15409b2 | 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 | 235:c127b15409b2 | 188 | RESET_TO_PYLD = 1; |
ee12b079 | 209:63e9c8f8b5d2 | 189 | wait_ms(10); |
ee12b079 | 235:c127b15409b2 | 190 | RESET_TO_PYLD = 0; |
ee12b079 | 235:c127b15409b2 | 191 | } |
ee12b079 | 235:c127b15409b2 | 192 | |
ee12b079 | 235:c127b15409b2 | 193 | void CDMS_INTERNAL_RESET() |
ee12b079 | 235:c127b15409b2 | 194 | { |
ee12b079 | 235:c127b15409b2 | 195 | NVIC_SystemReset(); |
ee12b079 | 235:c127b15409b2 | 196 | } |
ee12b079 | 235:c127b15409b2 | 197 | |
ee12b079 | 235:c127b15409b2 | 198 | void SYS_PWR_RESET() // Have to be decided with EPS team. |
ee12b079 | 235:c127b15409b2 | 199 | { |
ee12b079 | 235:c127b15409b2 | 200 | |
ee12b079 | 235:c127b15409b2 | 201 | } |
ee12b079 | 235:c127b15409b2 | 202 | |
ee12b079 | 235:c127b15409b2 | 203 | void EPS_V_A_EN() // This is a reset function |
ee12b079 | 235:c127b15409b2 | 204 | { |
ee12b079 | 235:c127b15409b2 | 205 | TRXY_PWR_CNTRL = 0; |
ee12b079 | 235:c127b15409b2 | 206 | TRZ_PWR_CNTRL = 0; |
ee12b079 | 235:c127b15409b2 | 207 | wait_ms(10); |
ee12b079 | 235:c127b15409b2 | 208 | TRXY_PWR_CNTRL = 1; |
ee12b079 | 235:c127b15409b2 | 209 | TRZ_PWR_CNTRL = 1; |
ee12b079 | 235:c127b15409b2 | 210 | } |
ee12b079 | 235:c127b15409b2 | 211 | |
ee12b079 | 235:c127b15409b2 | 212 | void EPS_V_C_EN() // This is a reset function |
ee12b079 | 235:c127b15409b2 | 213 | { |
ee12b079 | 235:c127b15409b2 | 214 | COM_RX_CNTRL = 0; |
ee12b079 | 235:c127b15409b2 | 215 | wait_ms(10); |
ee12b079 | 235:c127b15409b2 | 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 | 235:c127b15409b2 | 245 | void CDMS_RD_RTC(uint64_t *time) |
ee12b079 | 235:c127b15409b2 | 246 | { |
ee12b079 | 235:c127b15409b2 | 247 | *time = FCTN_CDMS_RD_RTC(); |
ee12b079 | 235:c127b15409b2 | 248 | } |
ee12b079 | 235:c127b15409b2 | 249 | |
ee12b079 | 235:c127b15409b2 | 250 | void CDMS_CALIB_RTC() |
ee12b079 | 235:c127b15409b2 | 251 | { |
ee12b079 | 235:c127b15409b2 | 252 | |
ee12b079 | 235:c127b15409b2 | 253 | } |
ee12b079 | 235:c127b15409b2 | 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 | 235:c127b15409b2 | 260 | /* |
ee12b079 | 235:c127b15409b2 | 261 | //void CDMS_INTERNAL_RESET() |
ee12b079 | 209:63e9c8f8b5d2 | 262 | { |
ee12b079 | 209:63e9c8f8b5d2 | 263 | |
ee12b079 | 235:c127b15409b2 | 264 | } |
ee12b079 | 235:c127b15409b2 | 265 | */ |