Repository for CDMS code
Dependencies: SimpleDMA mbed-rtos mbed eeprom
Fork of COM_MNG_TMTC_SIMPLE by
FMS_all.h@343:cd7b1734f7a0, 2017-01-04 (annotated)
- Committer:
- chaithanyarss
- Date:
- Wed Jan 04 10:55:22 2017 +0000
- Revision:
- 343:cd7b1734f7a0
- Parent:
- 333:cddef120cae3
- Child:
- 345:cdde554477cd
Testing EEPROM
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
chaithanyarss | 328:2242ebc71be8 | 1 | #ifndef FMS_ALL_INCLUDED |
chaithanyarss | 328:2242ebc71be8 | 2 | #define FMS_ALL_INCLUDED |
chaithanyarss | 257:7d404e9dc9e2 | 3 | |
chaithanyarss | 257:7d404e9dc9e2 | 4 | // Includes MMS RAM functions also |
chaithanyarss | 257:7d404e9dc9e2 | 5 | |
chaithanyarss | 257:7d404e9dc9e2 | 6 | /*===================================================FMS Functions=================================================*/ |
chaithanyarss | 257:7d404e9dc9e2 | 7 | |
ee12b079 | 209:63e9c8f8b5d2 | 8 | |
ee12b079 | 245:da9d1bd999da | 9 | //Run processes |
ee12b079 | 209:63e9c8f8b5d2 | 10 | void P_PL_INIT(); |
ee12b079 | 209:63e9c8f8b5d2 | 11 | void P_PL_MAIN(); |
ee12b079 | 209:63e9c8f8b5d2 | 12 | void P_COM_INIT(); |
ee12b079 | 209:63e9c8f8b5d2 | 13 | void P_CDMS_HK_MAIN(); |
ee12b079 | 209:63e9c8f8b5d2 | 14 | void P_PL_RCV_SC_DATA(); |
ee12b079 | 209:63e9c8f8b5d2 | 15 | void P_CDMS_INIT_SD(); |
ee12b079 | 245:da9d1bd999da | 16 | |
ee12b079 | 245:da9d1bd999da | 17 | // Switch ON/OFF functions |
ee12b079 | 209:63e9c8f8b5d2 | 18 | void CDMS_SD_SW_ON(); |
ee12b079 | 209:63e9c8f8b5d2 | 19 | void CDMS_SD_SW_OFF(); |
ee12b079 | 245:da9d1bd999da | 20 | void CDMS_RTC_ON(); |
ee12b079 | 245:da9d1bd999da | 21 | void CDMS_RTC_OFF(); |
ee12b079 | 209:63e9c8f8b5d2 | 22 | void SW_ON_BAE(); |
ee12b079 | 209:63e9c8f8b5d2 | 23 | void SW_OFF_BAE(); |
ee12b079 | 209:63e9c8f8b5d2 | 24 | void SW_ON_PL_BEE(); |
ee12b079 | 209:63e9c8f8b5d2 | 25 | void SW_OFF_PL_BEE(); |
ee12b079 | 209:63e9c8f8b5d2 | 26 | void SW_ON_PL_EPS(); |
ee12b079 | 209:63e9c8f8b5d2 | 27 | void SW_OFF_PL_EPS(); |
ee12b079 | 209:63e9c8f8b5d2 | 28 | void SW_ON_V_A_EN(); |
ee12b079 | 209:63e9c8f8b5d2 | 29 | void SW_OFF_V_A_EN(); |
ee12b079 | 245:da9d1bd999da | 30 | |
ee12b079 | 245:da9d1bd999da | 31 | // RST functions |
ee12b079 | 209:63e9c8f8b5d2 | 32 | void RST_SD(); |
ee12b079 | 245:da9d1bd999da | 33 | void SW_RST_BAE(); |
ee12b079 | 245:da9d1bd999da | 34 | void SW_RST_PL_BEE(); |
ee12b079 | 209:63e9c8f8b5d2 | 35 | void RST_BAE(); |
ee12b079 | 209:63e9c8f8b5d2 | 36 | void RST_PL_BEE(); |
chaithanyarss | 257:7d404e9dc9e2 | 37 | void CDMS_RESET(); |
ee12b079 | 245:da9d1bd999da | 38 | void SYS_PWR_RESET(); // Have to be decided with EPS team. |
aniruddhv | 262:752c8689944a | 39 | void sys_pwr_reset(void const *args); |
ee12b079 | 245:da9d1bd999da | 40 | void EPS_V_A_EN(); |
ee12b079 | 245:da9d1bd999da | 41 | void EPS_V_C_EN(); |
ee12b079 | 245:da9d1bd999da | 42 | |
ee12b079 | 209:63e9c8f8b5d2 | 43 | void RST_HK_COUNTER(); |
chaithanyarss | 257:7d404e9dc9e2 | 44 | int8_t CDMS_RD_SD_HK(uint8_t *); |
chaithanyarss | 257:7d404e9dc9e2 | 45 | void CDMS_CALIB_RTC(uint8_t *); |
chaithanyarss | 257:7d404e9dc9e2 | 46 | void TOTAL_RESET_WITH_CDMS(); |
chaithanyarss | 257:7d404e9dc9e2 | 47 | |
aniruddhv | 262:752c8689944a | 48 | void sys_pwr_reset(void const *args){ |
aniruddhv | 262:752c8689944a | 49 | SYS_PWR_RESET(); |
aniruddhv | 262:752c8689944a | 50 | } |
ee12b079 | 245:da9d1bd999da | 51 | |
ee12b079 | 209:63e9c8f8b5d2 | 52 | void P_PL_INIT() |
ee12b079 | 209:63e9c8f8b5d2 | 53 | { |
ee12b079 | 209:63e9c8f8b5d2 | 54 | |
ee12b079 | 209:63e9c8f8b5d2 | 55 | } |
ee12b079 | 209:63e9c8f8b5d2 | 56 | |
ee12b079 | 209:63e9c8f8b5d2 | 57 | void P_PL_MAIN() |
ee12b079 | 209:63e9c8f8b5d2 | 58 | { |
chaithanyarss | 257:7d404e9dc9e2 | 59 | FCTN_CDMS_PL_MAIN((void *)NULL); |
ee12b079 | 209:63e9c8f8b5d2 | 60 | } |
ee12b079 | 209:63e9c8f8b5d2 | 61 | |
ee12b079 | 209:63e9c8f8b5d2 | 62 | void P_COM_INIT() |
ee12b079 | 209:63e9c8f8b5d2 | 63 | { |
ee12b079 | 245:da9d1bd999da | 64 | P_COM_INIT; |
ee12b079 | 209:63e9c8f8b5d2 | 65 | } |
ee12b079 | 209:63e9c8f8b5d2 | 66 | |
ee12b079 | 209:63e9c8f8b5d2 | 67 | void P_CDMS_HK_MAIN() |
ee12b079 | 209:63e9c8f8b5d2 | 68 | { |
ee12b079 | 245:da9d1bd999da | 69 | FCTN_CDMS_HK_MAIN((void *)NULL); |
ee12b079 | 209:63e9c8f8b5d2 | 70 | } |
ee12b079 | 209:63e9c8f8b5d2 | 71 | |
ee12b079 | 209:63e9c8f8b5d2 | 72 | void P_PL_RCV_SC_DATA() |
ee12b079 | 209:63e9c8f8b5d2 | 73 | { |
ee12b079 | 245:da9d1bd999da | 74 | |
ee12b079 | 209:63e9c8f8b5d2 | 75 | } |
ee12b079 | 209:63e9c8f8b5d2 | 76 | |
ee12b079 | 209:63e9c8f8b5d2 | 77 | void P_CDMS_INIT_SD() |
ee12b079 | 209:63e9c8f8b5d2 | 78 | { |
ee12b079 | 209:63e9c8f8b5d2 | 79 | FCTN_CDMS_SD_INIT(); |
ee12b079 | 209:63e9c8f8b5d2 | 80 | } |
ee12b079 | 209:63e9c8f8b5d2 | 81 | |
ee12b079 | 209:63e9c8f8b5d2 | 82 | void CDMS_SD_SW_ON() |
ee12b079 | 209:63e9c8f8b5d2 | 83 | { |
ee12b079 | 289:9bd62b69874c | 84 | SD_SW_EN_DS = 1; |
chaithanyarss | 261:1e54415b34d3 | 85 | SD_STATUS = DEVICE_POWERED; |
chaithanyarss | 343:cd7b1734f7a0 | 86 | WRITE_TO_EEPROM(2,(int32_t)DEVICE_POWERED); |
chaithanyarss | 343:cd7b1734f7a0 | 87 | //FCTN_CDMS_WR_FLASH(2,DEVICE_POWERED); |
chaithanyarss | 261:1e54415b34d3 | 88 | gPC.printf("sw on sd\n"); |
ee12b079 | 209:63e9c8f8b5d2 | 89 | } |
ee12b079 | 209:63e9c8f8b5d2 | 90 | |
ee12b079 | 209:63e9c8f8b5d2 | 91 | void CDMS_SD_SW_OFF() |
ee12b079 | 209:63e9c8f8b5d2 | 92 | { |
ee12b079 | 289:9bd62b69874c | 93 | SD_SW_EN_DS = 0; |
chaithanyarss | 261:1e54415b34d3 | 94 | SD_STATUS = DEVICE_DISABLED; |
chaithanyarss | 343:cd7b1734f7a0 | 95 | WRITE_TO_EEPROM(2,(int32_t)DEVICE_DISABLED); |
chaithanyarss | 343:cd7b1734f7a0 | 96 | //FCTN_CDMS_WR_FLASH(2,DEVICE_DISABLED); |
chaithanyarss | 261:1e54415b34d3 | 97 | gPC.printf("sw off sd\n"); |
ee12b079 | 209:63e9c8f8b5d2 | 98 | } |
ee12b079 | 209:63e9c8f8b5d2 | 99 | |
ee12b079 | 245:da9d1bd999da | 100 | void CDMS_RTC_ON() |
ee12b079 | 209:63e9c8f8b5d2 | 101 | { |
chaithanyarss | 257:7d404e9dc9e2 | 102 | //FCTN_CDMS_INIT_RTC(); |
chaithanyarss | 257:7d404e9dc9e2 | 103 | SPI_mutex.lock(); |
chaithanyarss | 257:7d404e9dc9e2 | 104 | gCS_RTC=1; |
chaithanyarss | 257:7d404e9dc9e2 | 105 | gCS_RTC=0; |
chaithanyarss | 257:7d404e9dc9e2 | 106 | spi.write(0x81); //register address with write flag |
chaithanyarss | 257:7d404e9dc9e2 | 107 | spi.write(0x00);//disabling stop bit in the seconds register |
chaithanyarss | 257:7d404e9dc9e2 | 108 | SPI_mutex.unlock(); |
chaithanyarss | 261:1e54415b34d3 | 109 | gPC.printf("sw on rtc\n"); |
ee12b079 | 209:63e9c8f8b5d2 | 110 | } |
ee12b079 | 209:63e9c8f8b5d2 | 111 | |
ee12b079 | 245:da9d1bd999da | 112 | void CDMS_RTC_OFF() |
ee12b079 | 209:63e9c8f8b5d2 | 113 | { |
chaithanyarss | 257:7d404e9dc9e2 | 114 | SPI_mutex.lock(); |
chaithanyarss | 257:7d404e9dc9e2 | 115 | gCS_RTC=1; |
chaithanyarss | 257:7d404e9dc9e2 | 116 | gCS_RTC=0; |
chaithanyarss | 257:7d404e9dc9e2 | 117 | spi.write(0x81); //register address with write flag |
chaithanyarss | 257:7d404e9dc9e2 | 118 | spi.write(0x80);//enabling stop bit in the seconds register |
chaithanyarss | 257:7d404e9dc9e2 | 119 | SPI_mutex.unlock(); |
chaithanyarss | 261:1e54415b34d3 | 120 | gPC.printf("sw off rtc\n"); |
ee12b079 | 209:63e9c8f8b5d2 | 121 | } |
ee12b079 | 209:63e9c8f8b5d2 | 122 | |
ee12b079 | 245:da9d1bd999da | 123 | void SW_ON_BAE() |
ee12b079 | 245:da9d1bd999da | 124 | { |
ee12b079 | 289:9bd62b69874c | 125 | BAE_SW_EN_DS = 1; |
chaithanyarss | 261:1e54415b34d3 | 126 | BAE_STATUS = DEVICE_POWERED; |
chaithanyarss | 343:cd7b1734f7a0 | 127 | WRITE_TO_EEPROM(1,(int32_t)DEVICE_POWERED); |
chaithanyarss | 343:cd7b1734f7a0 | 128 | //FCTN_CDMS_WR_FLASH(1,DEVICE_POWERED); |
chaithanyarss | 261:1e54415b34d3 | 129 | gPC.printf("sw on bae\n"); |
ee12b079 | 245:da9d1bd999da | 130 | } |
ee12b079 | 245:da9d1bd999da | 131 | |
ee12b079 | 245:da9d1bd999da | 132 | void SW_OFF_BAE() |
ee12b079 | 245:da9d1bd999da | 133 | { |
ee12b079 | 289:9bd62b69874c | 134 | BAE_SW_EN_DS = 0; |
chaithanyarss | 261:1e54415b34d3 | 135 | BAE_STATUS = DEVICE_DISABLED; |
chaithanyarss | 343:cd7b1734f7a0 | 136 | WRITE_TO_EEPROM(1,(int32_t)DEVICE_DISABLED); |
chaithanyarss | 343:cd7b1734f7a0 | 137 | //FCTN_CDMS_WR_FLASH(1,DEVICE_DISABLED); |
chaithanyarss | 261:1e54415b34d3 | 138 | gPC.printf("sw off bae\n"); |
ee12b079 | 245:da9d1bd999da | 139 | } |
ee12b079 | 245:da9d1bd999da | 140 | |
ee12b079 | 245:da9d1bd999da | 141 | void SW_ON_PL_BEE() |
ee12b079 | 245:da9d1bd999da | 142 | { |
chaithanyarss | 261:1e54415b34d3 | 143 | PYLD_DFF_CLK = 0; |
chaithanyarss | 261:1e54415b34d3 | 144 | PYLD_DFF = 1; |
chaithanyarss | 261:1e54415b34d3 | 145 | wait_us(1); |
chaithanyarss | 261:1e54415b34d3 | 146 | PYLD_DFF_CLK = 1; |
chaithanyarss | 261:1e54415b34d3 | 147 | wait_us(1); |
chaithanyarss | 261:1e54415b34d3 | 148 | PYLD_DFF_CLK = 0; |
chaithanyarss | 261:1e54415b34d3 | 149 | wait_us(1); |
chaithanyarss | 261:1e54415b34d3 | 150 | PL_STATUS = DEVICE_POWERED; |
chaithanyarss | 343:cd7b1734f7a0 | 151 | WRITE_TO_EEPROM(3,(int32_t)DEVICE_POWERED); |
chaithanyarss | 343:cd7b1734f7a0 | 152 | //FCTN_CDMS_WR_FLASH(3,DEVICE_POWERED); |
ee12b079 | 245:da9d1bd999da | 153 | } |
ee12b079 | 245:da9d1bd999da | 154 | |
ee12b079 | 245:da9d1bd999da | 155 | void SW_OFF_PL_BEE() |
ee12b079 | 245:da9d1bd999da | 156 | { |
ee12b079 | 245:da9d1bd999da | 157 | PYLD_DFF_CLK = 0; |
ee12b079 | 245:da9d1bd999da | 158 | PYLD_DFF = 0; |
ee12b079 | 245:da9d1bd999da | 159 | wait_us(1); |
ee12b079 | 245:da9d1bd999da | 160 | PYLD_DFF_CLK = 1; |
ee12b079 | 245:da9d1bd999da | 161 | wait_us(1); |
ee12b079 | 245:da9d1bd999da | 162 | PYLD_DFF_CLK = 0; |
ee12b079 | 245:da9d1bd999da | 163 | wait_us(1); |
chaithanyarss | 261:1e54415b34d3 | 164 | PL_STATUS = DEVICE_DISABLED; |
chaithanyarss | 343:cd7b1734f7a0 | 165 | WRITE_TO_EEPROM(3,(int32_t)DEVICE_DISABLED); |
chaithanyarss | 343:cd7b1734f7a0 | 166 | //FCTN_CDMS_WR_FLASH(3,DEVICE_DISABLED); |
ee12b079 | 245:da9d1bd999da | 167 | } |
ee12b079 | 245:da9d1bd999da | 168 | |
ee12b079 | 245:da9d1bd999da | 169 | void SW_ON_PL_EPS() |
ee12b079 | 245:da9d1bd999da | 170 | { |
chaithanyarss | 261:1e54415b34d3 | 171 | PYLD_EPS_DFF_PWR_CLK = 0; |
chaithanyarss | 261:1e54415b34d3 | 172 | PYLD_EPS_DFF_PWR = 1; |
chaithanyarss | 261:1e54415b34d3 | 173 | wait_us(1); |
chaithanyarss | 261:1e54415b34d3 | 174 | PYLD_EPS_DFF_PWR_CLK = 1; |
chaithanyarss | 261:1e54415b34d3 | 175 | wait_us(1); |
chaithanyarss | 261:1e54415b34d3 | 176 | PYLD_EPS_DFF_PWR_CLK = 0; |
chaithanyarss | 261:1e54415b34d3 | 177 | wait_us(1); |
chaithanyarss | 261:1e54415b34d3 | 178 | PL_EPS_LATCH_SW_EN = 1; |
chaithanyarss | 343:cd7b1734f7a0 | 179 | WRITE_TO_EEPROM(4,(int32_t)1); |
chaithanyarss | 343:cd7b1734f7a0 | 180 | //FCTN_CDMS_WR_FLASH(4,1); |
ee12b079 | 245:da9d1bd999da | 181 | } |
ee12b079 | 245:da9d1bd999da | 182 | |
ee12b079 | 209:63e9c8f8b5d2 | 183 | void SW_OFF_PL_EPS() |
ee12b079 | 209:63e9c8f8b5d2 | 184 | { |
chaithanyarss | 261:1e54415b34d3 | 185 | PYLD_EPS_DFF_PWR_CLK = 0; |
chaithanyarss | 261:1e54415b34d3 | 186 | PYLD_EPS_DFF_PWR = 0; |
chaithanyarss | 261:1e54415b34d3 | 187 | wait_us(1); |
chaithanyarss | 261:1e54415b34d3 | 188 | PYLD_EPS_DFF_PWR_CLK = 1; |
chaithanyarss | 261:1e54415b34d3 | 189 | wait_us(1); |
chaithanyarss | 261:1e54415b34d3 | 190 | PYLD_EPS_DFF_PWR_CLK = 0; |
chaithanyarss | 261:1e54415b34d3 | 191 | wait_us(1); |
chaithanyarss | 261:1e54415b34d3 | 192 | PL_EPS_LATCH_SW_EN = 0; |
chaithanyarss | 343:cd7b1734f7a0 | 193 | WRITE_TO_EEPROM(4,(int32_t)0); |
chaithanyarss | 343:cd7b1734f7a0 | 194 | //FCTN_CDMS_WR_FLASH(4,0); |
ee12b079 | 209:63e9c8f8b5d2 | 195 | } |
ee12b079 | 209:63e9c8f8b5d2 | 196 | |
ee12b079 | 209:63e9c8f8b5d2 | 197 | void SW_ON_V_A_EN() |
ee12b079 | 209:63e9c8f8b5d2 | 198 | { |
chaithanyarss | 257:7d404e9dc9e2 | 199 | V_A_EN = 1; |
chaithanyarss | 261:1e54415b34d3 | 200 | EPS_V_A_EN_STATUS = 1; |
chaithanyarss | 343:cd7b1734f7a0 | 201 | WRITE_TO_EEPROM(0,(int32_t)1); |
chaithanyarss | 343:cd7b1734f7a0 | 202 | //FCTN_CDMS_WR_FLASH(0,1); |
ee12b079 | 209:63e9c8f8b5d2 | 203 | } |
ee12b079 | 209:63e9c8f8b5d2 | 204 | |
ee12b079 | 209:63e9c8f8b5d2 | 205 | void SW_OFF_V_A_EN() |
ee12b079 | 209:63e9c8f8b5d2 | 206 | { |
chaithanyarss | 257:7d404e9dc9e2 | 207 | V_A_EN = 0; |
chaithanyarss | 261:1e54415b34d3 | 208 | EPS_V_A_EN_STATUS = 0; |
chaithanyarss | 343:cd7b1734f7a0 | 209 | WRITE_TO_EEPROM(0,(int32_t)0); |
chaithanyarss | 343:cd7b1734f7a0 | 210 | //FCTN_CDMS_WR_FLASH(0,0); |
ee12b079 | 209:63e9c8f8b5d2 | 211 | } |
ee12b079 | 209:63e9c8f8b5d2 | 212 | |
ee12b079 | 209:63e9c8f8b5d2 | 213 | void RST_SD() |
ee12b079 | 209:63e9c8f8b5d2 | 214 | { |
ee12b079 | 289:9bd62b69874c | 215 | SD_SW_EN_DS = 0; |
ee12b079 | 209:63e9c8f8b5d2 | 216 | wait_ms(10); |
ee12b079 | 289:9bd62b69874c | 217 | SD_SW_EN_DS = 1; |
ee12b079 | 289:9bd62b69874c | 218 | SD_STATUS = DEVICE_POWERED; |
chaithanyarss | 343:cd7b1734f7a0 | 219 | WRITE_TO_EEPROM(2,(int32_t)DEVICE_POWERED); |
chaithanyarss | 343:cd7b1734f7a0 | 220 | //FCTN_CDMS_WR_FLASH(2,DEVICE_POWERED); |
chaithanyarss | 261:1e54415b34d3 | 221 | gPC.printf("rst sd\n"); |
ee12b079 | 245:da9d1bd999da | 222 | } |
ee12b079 | 245:da9d1bd999da | 223 | |
ee12b079 | 245:da9d1bd999da | 224 | void SW_RST_BAE() |
ee12b079 | 245:da9d1bd999da | 225 | { |
ee12b079 | 289:9bd62b69874c | 226 | BAE_SW_EN_DS = 0; |
ee12b079 | 245:da9d1bd999da | 227 | wait_ms(10); |
ee12b079 | 289:9bd62b69874c | 228 | BAE_SW_EN_DS = 1; |
chaithanyarss | 333:cddef120cae3 | 229 | wait_ms(100); |
ee12b079 | 289:9bd62b69874c | 230 | BAE_STATUS = DEVICE_POWERED; |
chaithanyarss | 343:cd7b1734f7a0 | 231 | WRITE_TO_EEPROM(1,(int32_t)DEVICE_POWERED); |
chaithanyarss | 343:cd7b1734f7a0 | 232 | //FCTN_CDMS_WR_FLASH(1,DEVICE_POWERED); |
chaithanyarss | 261:1e54415b34d3 | 233 | gPC.printf("rst bae\n"); |
ee12b079 | 245:da9d1bd999da | 234 | } |
ee12b079 | 245:da9d1bd999da | 235 | |
ee12b079 | 245:da9d1bd999da | 236 | void SW_RST_PL_BEE() |
ee12b079 | 245:da9d1bd999da | 237 | { |
ee12b079 | 289:9bd62b69874c | 238 | PYLD_DFF = 0; |
ee12b079 | 245:da9d1bd999da | 239 | wait_ms(10); |
ee12b079 | 289:9bd62b69874c | 240 | PYLD_DFF = 1; |
ee12b079 | 289:9bd62b69874c | 241 | PL_STATUS = DEVICE_POWERED; |
chaithanyarss | 343:cd7b1734f7a0 | 242 | WRITE_TO_EEPROM(3,(int32_t)DEVICE_POWERED); |
chaithanyarss | 343:cd7b1734f7a0 | 243 | //FCTN_CDMS_WR_FLASH(3,DEVICE_POWERED); |
ee12b079 | 209:63e9c8f8b5d2 | 244 | } |
ee12b079 | 209:63e9c8f8b5d2 | 245 | |
ee12b079 | 209:63e9c8f8b5d2 | 246 | void RST_BAE() |
ee12b079 | 209:63e9c8f8b5d2 | 247 | { |
ee12b079 | 289:9bd62b69874c | 248 | RESET_TO_BAE = 0; |
ee12b079 | 209:63e9c8f8b5d2 | 249 | wait_ms(10); |
ee12b079 | 289:9bd62b69874c | 250 | RESET_TO_BAE = 1; |
ee12b079 | 209:63e9c8f8b5d2 | 251 | } |
ee12b079 | 209:63e9c8f8b5d2 | 252 | |
ee12b079 | 209:63e9c8f8b5d2 | 253 | void RST_PL_BEE() |
ee12b079 | 209:63e9c8f8b5d2 | 254 | { |
ee12b079 | 289:9bd62b69874c | 255 | RESET_TO_PYLD = 0; |
ee12b079 | 209:63e9c8f8b5d2 | 256 | wait_ms(10); |
ee12b079 | 289:9bd62b69874c | 257 | RESET_TO_PYLD = 1; |
ee12b079 | 245:da9d1bd999da | 258 | } |
ee12b079 | 245:da9d1bd999da | 259 | |
ee12b079 | 245:da9d1bd999da | 260 | void CDMS_INTERNAL_RESET() |
ee12b079 | 245:da9d1bd999da | 261 | { |
ee12b079 | 245:da9d1bd999da | 262 | NVIC_SystemReset(); |
ee12b079 | 245:da9d1bd999da | 263 | } |
ee12b079 | 245:da9d1bd999da | 264 | |
ee12b079 | 245:da9d1bd999da | 265 | void SYS_PWR_RESET() // Have to be decided with EPS team. |
ee12b079 | 245:da9d1bd999da | 266 | { |
ee12b079 | 287:a387337491f7 | 267 | //sys_pwr_rst = 1; |
ee12b079 | 245:da9d1bd999da | 268 | } |
ee12b079 | 245:da9d1bd999da | 269 | |
ee12b079 | 245:da9d1bd999da | 270 | void EPS_V_A_EN() // This is a reset function |
ee12b079 | 245:da9d1bd999da | 271 | { |
chaithanyarss | 257:7d404e9dc9e2 | 272 | V_A_EN = 0; |
ee12b079 | 245:da9d1bd999da | 273 | wait_ms(10); |
chaithanyarss | 257:7d404e9dc9e2 | 274 | V_A_EN = 1; |
ee12b079 | 245:da9d1bd999da | 275 | } |
ee12b079 | 245:da9d1bd999da | 276 | |
ee12b079 | 245:da9d1bd999da | 277 | void EPS_V_C_EN() // This is a reset function |
ee12b079 | 245:da9d1bd999da | 278 | { |
ee12b079 | 245:da9d1bd999da | 279 | COM_RX_CNTRL = 0; |
ee12b079 | 245:da9d1bd999da | 280 | wait_ms(10); |
ee12b079 | 245:da9d1bd999da | 281 | COM_RX_CNTRL = 1; |
ee12b079 | 209:63e9c8f8b5d2 | 282 | } |
ee12b079 | 209:63e9c8f8b5d2 | 283 | |
ee12b079 | 209:63e9c8f8b5d2 | 284 | void RST_HK_COUNTER() |
ee12b079 | 209:63e9c8f8b5d2 | 285 | { |
ee12b079 | 209:63e9c8f8b5d2 | 286 | firstCount = true; |
ee12b079 | 209:63e9c8f8b5d2 | 287 | } |
ee12b079 | 209:63e9c8f8b5d2 | 288 | |
chaithanyarss | 257:7d404e9dc9e2 | 289 | int8_t CDMS_RD_SD_HK(uint8_t *sd_statusbits) |
ee12b079 | 209:63e9c8f8b5d2 | 290 | { |
chaithanyarss | 257:7d404e9dc9e2 | 291 | int8_t p; |
ee12b079 | 209:63e9c8f8b5d2 | 292 | if(SD_SW_EN_DS != DEVICE_POWERED) |
ee12b079 | 209:63e9c8f8b5d2 | 293 | { |
ee12b079 | 209:63e9c8f8b5d2 | 294 | SD_RD_ERROR = 1; |
chaithanyarss | 257:7d404e9dc9e2 | 295 | p = 1; |
ee12b079 | 209:63e9c8f8b5d2 | 296 | } |
ee12b079 | 209:63e9c8f8b5d2 | 297 | else |
ee12b079 | 209:63e9c8f8b5d2 | 298 | { |
ee12b079 | 209:63e9c8f8b5d2 | 299 | p = disk_read_statusbits(sd_statusbits); |
ee12b079 | 209:63e9c8f8b5d2 | 300 | } |
chaithanyarss | 257:7d404e9dc9e2 | 301 | return p; |
ee12b079 | 209:63e9c8f8b5d2 | 302 | } |
ee12b079 | 209:63e9c8f8b5d2 | 303 | |
chaithanyarss | 261:1e54415b34d3 | 304 | void CDMS_CALIB_RTC(uint64_t time) |
ee12b079 | 245:da9d1bd999da | 305 | { |
chaithanyarss | 257:7d404e9dc9e2 | 306 | SPI_mutex.lock(); |
chaithanyarss | 257:7d404e9dc9e2 | 307 | gCS_RTC=1; |
chaithanyarss | 257:7d404e9dc9e2 | 308 | spi.format(8,0); |
chaithanyarss | 257:7d404e9dc9e2 | 309 | spi.frequency(1000000); |
chaithanyarss | 257:7d404e9dc9e2 | 310 | |
chaithanyarss | 257:7d404e9dc9e2 | 311 | gCS_RTC=0; |
chaithanyarss | 257:7d404e9dc9e2 | 312 | spi.write(0x82); |
chaithanyarss | 261:1e54415b34d3 | 313 | spi.write((uint8_t)time);//set minutes |
chaithanyarss | 257:7d404e9dc9e2 | 314 | gCS_RTC=1; |
chaithanyarss | 257:7d404e9dc9e2 | 315 | |
chaithanyarss | 257:7d404e9dc9e2 | 316 | gCS_RTC=0; |
chaithanyarss | 257:7d404e9dc9e2 | 317 | spi.write(0x83); |
chaithanyarss | 261:1e54415b34d3 | 318 | spi.write((uint8_t)(time>>8) & 0x3F); //set hours |
chaithanyarss | 257:7d404e9dc9e2 | 319 | gCS_RTC=1; |
ee12b079 | 245:da9d1bd999da | 320 | |
chaithanyarss | 257:7d404e9dc9e2 | 321 | gCS_RTC=0; |
chaithanyarss | 257:7d404e9dc9e2 | 322 | spi.write(0x85); |
chaithanyarss | 261:1e54415b34d3 | 323 | spi.write((uint8_t)(time>>16) & 0x3F); //set date |
chaithanyarss | 257:7d404e9dc9e2 | 324 | gCS_RTC=1; |
chaithanyarss | 257:7d404e9dc9e2 | 325 | |
chaithanyarss | 257:7d404e9dc9e2 | 326 | gCS_RTC=0; |
chaithanyarss | 257:7d404e9dc9e2 | 327 | spi.write(0x86); |
chaithanyarss | 261:1e54415b34d3 | 328 | spi.write((uint8_t)(time>>24) & 0x1F); //set month |
chaithanyarss | 257:7d404e9dc9e2 | 329 | gCS_RTC=1; |
chaithanyarss | 257:7d404e9dc9e2 | 330 | |
chaithanyarss | 257:7d404e9dc9e2 | 331 | gCS_RTC=0; |
chaithanyarss | 257:7d404e9dc9e2 | 332 | spi.write(0x87); |
chaithanyarss | 261:1e54415b34d3 | 333 | spi.write((uint8_t)(time>>32)); //set year to 00(2000) |
chaithanyarss | 257:7d404e9dc9e2 | 334 | gCS_RTC=1; |
chaithanyarss | 257:7d404e9dc9e2 | 335 | gPC.puts("\n\r rtc initalised \n"); |
chaithanyarss | 257:7d404e9dc9e2 | 336 | SPI_mutex.unlock(); |
ee12b079 | 245:da9d1bd999da | 337 | } |
ee12b079 | 245:da9d1bd999da | 338 | |
chaithanyarss | 224:3ac1f91e0ebc | 339 | void CDMS_RESET() |
chaithanyarss | 224:3ac1f91e0ebc | 340 | { |
chaithanyarss | 224:3ac1f91e0ebc | 341 | NVIC_SystemReset(); |
chaithanyarss | 224:3ac1f91e0ebc | 342 | } |
chaithanyarss | 224:3ac1f91e0ebc | 343 | |
ee12b079 | 245:da9d1bd999da | 344 | /* |
ee12b079 | 245:da9d1bd999da | 345 | //void CDMS_INTERNAL_RESET() |
ee12b079 | 209:63e9c8f8b5d2 | 346 | { |
ee12b079 | 209:63e9c8f8b5d2 | 347 | |
ee12b079 | 245:da9d1bd999da | 348 | } |
chaithanyarss | 257:7d404e9dc9e2 | 349 | */ |
chaithanyarss | 257:7d404e9dc9e2 | 350 | |
chaithanyarss | 257:7d404e9dc9e2 | 351 | //===============================MMS RAM functions================================== |
chaithanyarss | 257:7d404e9dc9e2 | 352 | |
chaithanyarss | 257:7d404e9dc9e2 | 353 | void FCTN_CDMS_RD_L_RAM(Base_tm *); |
chaithanyarss | 257:7d404e9dc9e2 | 354 | |
chaithanyarss | 257:7d404e9dc9e2 | 355 | void FCTN_CDMS_RD_L_RAM(Base_tm *tm_pointer) |
chaithanyarss | 257:7d404e9dc9e2 | 356 | { |
spacelab | 330:6ac9661f2e10 | 357 | uint32_t time = FCTN_CDMS_RD_RTC() >> 7; //Reading Time from RTC |
spacelab | 330:6ac9661f2e10 | 358 | for(int i = 124; i<128; i++) |
spacelab | 330:6ac9661f2e10 | 359 | CDMS_HEALTH_DATA[i] = time >> (127-i)*8; |
ee12b079 | 301:701ac67649b7 | 360 | for(int i=0;i<128;i++) |
chaithanyarss | 303:b49b486a7107 | 361 | { |
chaithanyarss | 303:b49b486a7107 | 362 | //tm_pointer->TM_string[i] = 0; |
chaithanyarss | 303:b49b486a7107 | 363 | tm_pointer->TM_string[i+4] = CDMS_HEALTH_DATA[i]; |
chaithanyarss | 303:b49b486a7107 | 364 | } |
spacelab | 330:6ac9661f2e10 | 365 | |
ee12b079 | 322:7d906d34aaff | 366 | } |
ee12b079 | 322:7d906d34aaff | 367 | |
ee12b079 | 322:7d906d34aaff | 368 | void FCTN_CDMS_MAX_MIN(Base_tm *tm_pointer) |
ee12b079 | 322:7d906d34aaff | 369 | { |
chaithanyarss | 333:cddef120cae3 | 370 | tm_pointer->TM_string[4] = MAX_COM_ADF_TMP+40; |
chaithanyarss | 333:cddef120cae3 | 371 | tm_pointer->TM_string[6] = (uint8_t)(MAX_RSSI_VOLTAGE*10); |
ee12b079 | 322:7d906d34aaff | 372 | |
ee12b079 | 322:7d906d34aaff | 373 | for(int i=0;i<16;i++) |
ee12b079 | 322:7d906d34aaff | 374 | { |
ee12b079 | 322:7d906d34aaff | 375 | //tm_pointer->TM_string[i] = 0; |
chaithanyarss | 333:cddef120cae3 | 376 | tm_pointer->TM_string[i+7] = (uint8_t)(min_max_data.temp_max[i]); |
chaithanyarss | 333:cddef120cae3 | 377 | } |
chaithanyarss | 333:cddef120cae3 | 378 | |
chaithanyarss | 333:cddef120cae3 | 379 | tm_pointer->TM_string[23] = MIN_COM_ADF_TMP+40; |
chaithanyarss | 333:cddef120cae3 | 380 | tm_pointer->TM_string[25] = (uint8_t)(MIN_RSSI_VOLTAGE*10); |
chaithanyarss | 333:cddef120cae3 | 381 | |
chaithanyarss | 333:cddef120cae3 | 382 | for(int i=0;i<16;i++) |
chaithanyarss | 333:cddef120cae3 | 383 | { |
chaithanyarss | 333:cddef120cae3 | 384 | //tm_pointer->TM_string[i] = 0; |
chaithanyarss | 333:cddef120cae3 | 385 | tm_pointer->TM_string[i+26] = (uint8_t)(min_max_data.temp_min[i]); |
ee12b079 | 322:7d906d34aaff | 386 | } |
ee12b079 | 322:7d906d34aaff | 387 | |
chaithanyarss | 328:2242ebc71be8 | 388 | tm_pointer->TM_string[42] = GPIO_STATUS>>8; |
chaithanyarss | 328:2242ebc71be8 | 389 | tm_pointer->TM_string[43] = (GPIO_STATUS<<3) & 0x00FF; |
ee12b079 | 322:7d906d34aaff | 390 | |
ee12b079 | 322:7d906d34aaff | 391 | TIME_LATEST_RTC= FCTN_CDMS_RD_RTC() >> 7; |
ee12b079 | 322:7d906d34aaff | 392 | for(int i = 0; i<4; i++) |
chaithanyarss | 328:2242ebc71be8 | 393 | tm_pointer->TM_string[44+i] = TIME_LATEST_RTC >> (3-i)*8; |
chaithanyarss | 328:2242ebc71be8 | 394 | } |
chaithanyarss | 328:2242ebc71be8 | 395 | |
chaithanyarss | 328:2242ebc71be8 | 396 | #endif |