working version
Dependencies: mbed mbed-rtos SimpleDMA FreescaleIAP eeprom
Fork of CDMS_CODE_FM_28JAN2017 by
FMS_all.h@257:7d404e9dc9e2, 2016-07-12 (annotated)
- Committer:
- chaithanyarss
- Date:
- Tue Jul 12 17:07:17 2016 +0000
- Revision:
- 257:7d404e9dc9e2
- Parent:
- 245:da9d1bd999da
- Child:
- 261:1e54415b34d3
pipi;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
chaithanyarss | 257:7d404e9dc9e2 | 1 | |
chaithanyarss | 257:7d404e9dc9e2 | 2 | // Includes MMS RAM functions also |
chaithanyarss | 257:7d404e9dc9e2 | 3 | |
chaithanyarss | 257:7d404e9dc9e2 | 4 | /*===================================================FMS Functions=================================================*/ |
chaithanyarss | 257:7d404e9dc9e2 | 5 | |
chaithanyarss | 257:7d404e9dc9e2 | 6 | void STANDBY_PRCS(); |
ee12b079 | 209:63e9c8f8b5d2 | 7 | |
ee12b079 | 245:da9d1bd999da | 8 | //Run processes |
ee12b079 | 209:63e9c8f8b5d2 | 9 | void P_PL_INIT(); |
ee12b079 | 209:63e9c8f8b5d2 | 10 | void P_PL_MAIN(); |
ee12b079 | 209:63e9c8f8b5d2 | 11 | void P_COM_INIT(); |
ee12b079 | 209:63e9c8f8b5d2 | 12 | void P_CDMS_HK_MAIN(); |
ee12b079 | 209:63e9c8f8b5d2 | 13 | void P_PL_RCV_SC_DATA(); |
ee12b079 | 209:63e9c8f8b5d2 | 14 | void P_CDMS_INIT_SD(); |
ee12b079 | 245:da9d1bd999da | 15 | |
ee12b079 | 245:da9d1bd999da | 16 | // Switch ON/OFF functions |
ee12b079 | 209:63e9c8f8b5d2 | 17 | void CDMS_SD_SW_ON(); |
ee12b079 | 209:63e9c8f8b5d2 | 18 | void CDMS_SD_SW_OFF(); |
ee12b079 | 245:da9d1bd999da | 19 | void CDMS_RTC_ON(); |
ee12b079 | 245:da9d1bd999da | 20 | void CDMS_RTC_OFF(); |
ee12b079 | 209:63e9c8f8b5d2 | 21 | void SW_ON_BAE(); |
ee12b079 | 209:63e9c8f8b5d2 | 22 | void SW_OFF_BAE(); |
ee12b079 | 209:63e9c8f8b5d2 | 23 | void SW_ON_PL_BEE(); |
ee12b079 | 209:63e9c8f8b5d2 | 24 | void SW_OFF_PL_BEE(); |
ee12b079 | 209:63e9c8f8b5d2 | 25 | void SW_ON_PL_EPS(); |
ee12b079 | 209:63e9c8f8b5d2 | 26 | void SW_OFF_PL_EPS(); |
ee12b079 | 209:63e9c8f8b5d2 | 27 | void SW_ON_V_A_EN(); |
ee12b079 | 209:63e9c8f8b5d2 | 28 | void SW_OFF_V_A_EN(); |
ee12b079 | 245:da9d1bd999da | 29 | |
ee12b079 | 245:da9d1bd999da | 30 | // RST functions |
ee12b079 | 209:63e9c8f8b5d2 | 31 | void RST_SD(); |
ee12b079 | 245:da9d1bd999da | 32 | void SW_RST_BAE(); |
ee12b079 | 245:da9d1bd999da | 33 | void SW_RST_PL_BEE(); |
ee12b079 | 209:63e9c8f8b5d2 | 34 | void RST_BAE(); |
ee12b079 | 209:63e9c8f8b5d2 | 35 | void RST_PL_BEE(); |
chaithanyarss | 257:7d404e9dc9e2 | 36 | void CDMS_RESET(); |
ee12b079 | 245:da9d1bd999da | 37 | void SYS_PWR_RESET(); // Have to be decided with EPS team. |
ee12b079 | 245:da9d1bd999da | 38 | void EPS_V_A_EN(); |
ee12b079 | 245:da9d1bd999da | 39 | void EPS_V_C_EN(); |
ee12b079 | 245:da9d1bd999da | 40 | |
ee12b079 | 209:63e9c8f8b5d2 | 41 | void RST_HK_COUNTER(); |
chaithanyarss | 257:7d404e9dc9e2 | 42 | int8_t CDMS_RD_SD_HK(uint8_t *); |
ee12b079 | 245:da9d1bd999da | 43 | void CDMS_RD_RTC(uint64_t *); |
chaithanyarss | 257:7d404e9dc9e2 | 44 | void CDMS_CALIB_RTC(uint8_t *); |
chaithanyarss | 257:7d404e9dc9e2 | 45 | void TOTAL_RESET_WITH_CDMS(); |
chaithanyarss | 257:7d404e9dc9e2 | 46 | |
ee12b079 | 245:da9d1bd999da | 47 | |
chaithanyarss | 257:7d404e9dc9e2 | 48 | void STANDBY_PRCS() |
chaithanyarss | 257:7d404e9dc9e2 | 49 | { |
chaithanyarss | 257:7d404e9dc9e2 | 50 | |
chaithanyarss | 257:7d404e9dc9e2 | 51 | } |
ee12b079 | 209:63e9c8f8b5d2 | 52 | |
ee12b079 | 209:63e9c8f8b5d2 | 53 | void P_PL_INIT() |
ee12b079 | 209:63e9c8f8b5d2 | 54 | { |
ee12b079 | 209:63e9c8f8b5d2 | 55 | |
ee12b079 | 209:63e9c8f8b5d2 | 56 | } |
ee12b079 | 209:63e9c8f8b5d2 | 57 | |
ee12b079 | 209:63e9c8f8b5d2 | 58 | void P_PL_MAIN() |
ee12b079 | 209:63e9c8f8b5d2 | 59 | { |
chaithanyarss | 257:7d404e9dc9e2 | 60 | FCTN_CDMS_PL_MAIN((void *)NULL); |
ee12b079 | 209:63e9c8f8b5d2 | 61 | } |
ee12b079 | 209:63e9c8f8b5d2 | 62 | |
ee12b079 | 209:63e9c8f8b5d2 | 63 | void P_COM_INIT() |
ee12b079 | 209:63e9c8f8b5d2 | 64 | { |
ee12b079 | 245:da9d1bd999da | 65 | P_COM_INIT; |
ee12b079 | 209:63e9c8f8b5d2 | 66 | } |
ee12b079 | 209:63e9c8f8b5d2 | 67 | |
ee12b079 | 209:63e9c8f8b5d2 | 68 | void P_CDMS_HK_MAIN() |
ee12b079 | 209:63e9c8f8b5d2 | 69 | { |
ee12b079 | 245:da9d1bd999da | 70 | FCTN_CDMS_HK_MAIN((void *)NULL); |
ee12b079 | 209:63e9c8f8b5d2 | 71 | } |
ee12b079 | 209:63e9c8f8b5d2 | 72 | |
ee12b079 | 209:63e9c8f8b5d2 | 73 | void P_PL_RCV_SC_DATA() |
ee12b079 | 209:63e9c8f8b5d2 | 74 | { |
ee12b079 | 245:da9d1bd999da | 75 | |
ee12b079 | 209:63e9c8f8b5d2 | 76 | } |
ee12b079 | 209:63e9c8f8b5d2 | 77 | |
ee12b079 | 209:63e9c8f8b5d2 | 78 | void P_CDMS_INIT_SD() |
ee12b079 | 209:63e9c8f8b5d2 | 79 | { |
ee12b079 | 209:63e9c8f8b5d2 | 80 | FCTN_CDMS_SD_INIT(); |
ee12b079 | 209:63e9c8f8b5d2 | 81 | } |
ee12b079 | 209:63e9c8f8b5d2 | 82 | |
ee12b079 | 209:63e9c8f8b5d2 | 83 | void CDMS_SD_SW_ON() |
ee12b079 | 209:63e9c8f8b5d2 | 84 | { |
ee12b079 | 245:da9d1bd999da | 85 | SD_SW_EN_DS = 0; |
ee12b079 | 209:63e9c8f8b5d2 | 86 | } |
ee12b079 | 209:63e9c8f8b5d2 | 87 | |
ee12b079 | 209:63e9c8f8b5d2 | 88 | void CDMS_SD_SW_OFF() |
ee12b079 | 209:63e9c8f8b5d2 | 89 | { |
ee12b079 | 245:da9d1bd999da | 90 | SD_SW_EN_DS = 1; |
ee12b079 | 209:63e9c8f8b5d2 | 91 | } |
ee12b079 | 209:63e9c8f8b5d2 | 92 | |
ee12b079 | 245:da9d1bd999da | 93 | void CDMS_RTC_ON() |
ee12b079 | 209:63e9c8f8b5d2 | 94 | { |
chaithanyarss | 257:7d404e9dc9e2 | 95 | //FCTN_CDMS_INIT_RTC(); |
chaithanyarss | 257:7d404e9dc9e2 | 96 | SPI_mutex.lock(); |
chaithanyarss | 257:7d404e9dc9e2 | 97 | gCS_RTC=1; |
chaithanyarss | 257:7d404e9dc9e2 | 98 | gCS_RTC=0; |
chaithanyarss | 257:7d404e9dc9e2 | 99 | spi.write(0x81); //register address with write flag |
chaithanyarss | 257:7d404e9dc9e2 | 100 | spi.write(0x00);//disabling stop bit in the seconds register |
chaithanyarss | 257:7d404e9dc9e2 | 101 | SPI_mutex.unlock(); |
ee12b079 | 209:63e9c8f8b5d2 | 102 | } |
ee12b079 | 209:63e9c8f8b5d2 | 103 | |
ee12b079 | 245:da9d1bd999da | 104 | void CDMS_RTC_OFF() |
ee12b079 | 209:63e9c8f8b5d2 | 105 | { |
chaithanyarss | 257:7d404e9dc9e2 | 106 | SPI_mutex.lock(); |
chaithanyarss | 257:7d404e9dc9e2 | 107 | gCS_RTC=1; |
chaithanyarss | 257:7d404e9dc9e2 | 108 | gCS_RTC=0; |
chaithanyarss | 257:7d404e9dc9e2 | 109 | spi.write(0x81); //register address with write flag |
chaithanyarss | 257:7d404e9dc9e2 | 110 | spi.write(0x80);//enabling stop bit in the seconds register |
chaithanyarss | 257:7d404e9dc9e2 | 111 | SPI_mutex.unlock(); |
ee12b079 | 209:63e9c8f8b5d2 | 112 | } |
ee12b079 | 209:63e9c8f8b5d2 | 113 | |
ee12b079 | 245:da9d1bd999da | 114 | void SW_ON_BAE() |
ee12b079 | 245:da9d1bd999da | 115 | { |
ee12b079 | 245:da9d1bd999da | 116 | BAE_SW_EN_DS = 0; |
ee12b079 | 245:da9d1bd999da | 117 | } |
ee12b079 | 245:da9d1bd999da | 118 | |
ee12b079 | 245:da9d1bd999da | 119 | void SW_OFF_BAE() |
ee12b079 | 245:da9d1bd999da | 120 | { |
ee12b079 | 245:da9d1bd999da | 121 | BAE_SW_EN_DS = 1; |
ee12b079 | 245:da9d1bd999da | 122 | } |
ee12b079 | 245:da9d1bd999da | 123 | |
ee12b079 | 245:da9d1bd999da | 124 | void SW_ON_PL_BEE() |
ee12b079 | 245:da9d1bd999da | 125 | { |
ee12b079 | 245:da9d1bd999da | 126 | PYLD_DFF_CLK = 0;\ |
ee12b079 | 245:da9d1bd999da | 127 | PYLD_DFF = 1;\ |
ee12b079 | 245:da9d1bd999da | 128 | wait_us(1);\ |
ee12b079 | 245:da9d1bd999da | 129 | PYLD_DFF_CLK = 1;\ |
ee12b079 | 245:da9d1bd999da | 130 | wait_us(1);\ |
ee12b079 | 245:da9d1bd999da | 131 | PYLD_DFF_CLK = 0;\ |
ee12b079 | 245:da9d1bd999da | 132 | wait_us(1);\ |
ee12b079 | 245:da9d1bd999da | 133 | } |
ee12b079 | 245:da9d1bd999da | 134 | |
ee12b079 | 245:da9d1bd999da | 135 | void SW_OFF_PL_BEE() |
ee12b079 | 245:da9d1bd999da | 136 | { |
ee12b079 | 245:da9d1bd999da | 137 | PYLD_DFF_CLK = 0; |
ee12b079 | 245:da9d1bd999da | 138 | PYLD_DFF = 0; |
ee12b079 | 245:da9d1bd999da | 139 | wait_us(1); |
ee12b079 | 245:da9d1bd999da | 140 | PYLD_DFF_CLK = 1; |
ee12b079 | 245:da9d1bd999da | 141 | wait_us(1); |
ee12b079 | 245:da9d1bd999da | 142 | PYLD_DFF_CLK = 0; |
ee12b079 | 245:da9d1bd999da | 143 | wait_us(1); |
ee12b079 | 245:da9d1bd999da | 144 | } |
ee12b079 | 245:da9d1bd999da | 145 | |
ee12b079 | 245:da9d1bd999da | 146 | void SW_ON_PL_EPS() |
ee12b079 | 245:da9d1bd999da | 147 | { |
ee12b079 | 245:da9d1bd999da | 148 | PYLD_EPS_DFF_PWR_CLK = 0;\ |
ee12b079 | 245:da9d1bd999da | 149 | PYLD_EPS_DFF_PWR = 1;\ |
ee12b079 | 245:da9d1bd999da | 150 | wait_us(1);\ |
ee12b079 | 245:da9d1bd999da | 151 | PYLD_EPS_DFF_PWR_CLK = 1;\ |
ee12b079 | 245:da9d1bd999da | 152 | wait_us(1);\ |
ee12b079 | 245:da9d1bd999da | 153 | PYLD_EPS_DFF_PWR_CLK = 0;\ |
ee12b079 | 245:da9d1bd999da | 154 | wait_us(1);\ |
ee12b079 | 245:da9d1bd999da | 155 | } |
ee12b079 | 245:da9d1bd999da | 156 | |
ee12b079 | 209:63e9c8f8b5d2 | 157 | void SW_OFF_PL_EPS() |
ee12b079 | 209:63e9c8f8b5d2 | 158 | { |
ee12b079 | 245:da9d1bd999da | 159 | PYLD_EPS_DFF_PWR_CLK = 0;\ |
ee12b079 | 245:da9d1bd999da | 160 | PYLD_EPS_DFF_PWR = 0;\ |
ee12b079 | 245:da9d1bd999da | 161 | wait_us(1);\ |
ee12b079 | 245:da9d1bd999da | 162 | PYLD_EPS_DFF_PWR_CLK = 1;\ |
ee12b079 | 245:da9d1bd999da | 163 | wait_us(1);\ |
ee12b079 | 245:da9d1bd999da | 164 | PYLD_EPS_DFF_PWR_CLK = 0;\ |
ee12b079 | 245:da9d1bd999da | 165 | wait_us(1);\ |
ee12b079 | 209:63e9c8f8b5d2 | 166 | } |
ee12b079 | 209:63e9c8f8b5d2 | 167 | |
ee12b079 | 209:63e9c8f8b5d2 | 168 | void SW_ON_V_A_EN() |
ee12b079 | 209:63e9c8f8b5d2 | 169 | { |
chaithanyarss | 257:7d404e9dc9e2 | 170 | V_A_EN = 1; |
ee12b079 | 209:63e9c8f8b5d2 | 171 | } |
ee12b079 | 209:63e9c8f8b5d2 | 172 | |
ee12b079 | 209:63e9c8f8b5d2 | 173 | void SW_OFF_V_A_EN() |
ee12b079 | 209:63e9c8f8b5d2 | 174 | { |
chaithanyarss | 257:7d404e9dc9e2 | 175 | V_A_EN = 0; |
ee12b079 | 209:63e9c8f8b5d2 | 176 | } |
ee12b079 | 209:63e9c8f8b5d2 | 177 | |
ee12b079 | 209:63e9c8f8b5d2 | 178 | void RST_SD() |
ee12b079 | 209:63e9c8f8b5d2 | 179 | { |
ee12b079 | 245:da9d1bd999da | 180 | SD_SW_EN_DS = 1; |
ee12b079 | 209:63e9c8f8b5d2 | 181 | wait_ms(10); |
ee12b079 | 209:63e9c8f8b5d2 | 182 | SD_SW_EN_DS = 0; |
ee12b079 | 245:da9d1bd999da | 183 | } |
ee12b079 | 245:da9d1bd999da | 184 | |
ee12b079 | 245:da9d1bd999da | 185 | void SW_RST_BAE() |
ee12b079 | 245:da9d1bd999da | 186 | { |
ee12b079 | 245:da9d1bd999da | 187 | BAE_SW_EN_DS = 1; |
ee12b079 | 245:da9d1bd999da | 188 | wait_ms(10); |
ee12b079 | 245:da9d1bd999da | 189 | BAE_SW_EN_DS = 0; |
ee12b079 | 245:da9d1bd999da | 190 | } |
ee12b079 | 245:da9d1bd999da | 191 | |
ee12b079 | 245:da9d1bd999da | 192 | void SW_RST_PL_BEE() |
ee12b079 | 245:da9d1bd999da | 193 | { |
ee12b079 | 245:da9d1bd999da | 194 | PYLD_DFF = 1; |
ee12b079 | 245:da9d1bd999da | 195 | wait_ms(10); |
ee12b079 | 245:da9d1bd999da | 196 | PYLD_DFF = 0; |
ee12b079 | 209:63e9c8f8b5d2 | 197 | } |
ee12b079 | 209:63e9c8f8b5d2 | 198 | |
ee12b079 | 209:63e9c8f8b5d2 | 199 | void RST_BAE() |
ee12b079 | 209:63e9c8f8b5d2 | 200 | { |
ee12b079 | 245:da9d1bd999da | 201 | RESET_TO_BAE = 1; |
ee12b079 | 209:63e9c8f8b5d2 | 202 | wait_ms(10); |
ee12b079 | 245:da9d1bd999da | 203 | RESET_TO_BAE = 0; |
ee12b079 | 209:63e9c8f8b5d2 | 204 | } |
ee12b079 | 209:63e9c8f8b5d2 | 205 | |
ee12b079 | 209:63e9c8f8b5d2 | 206 | void RST_PL_BEE() |
ee12b079 | 209:63e9c8f8b5d2 | 207 | { |
ee12b079 | 245:da9d1bd999da | 208 | RESET_TO_PYLD = 1; |
ee12b079 | 209:63e9c8f8b5d2 | 209 | wait_ms(10); |
ee12b079 | 245:da9d1bd999da | 210 | RESET_TO_PYLD = 0; |
ee12b079 | 245:da9d1bd999da | 211 | } |
ee12b079 | 245:da9d1bd999da | 212 | |
ee12b079 | 245:da9d1bd999da | 213 | void CDMS_INTERNAL_RESET() |
ee12b079 | 245:da9d1bd999da | 214 | { |
ee12b079 | 245:da9d1bd999da | 215 | NVIC_SystemReset(); |
ee12b079 | 245:da9d1bd999da | 216 | } |
ee12b079 | 245:da9d1bd999da | 217 | |
ee12b079 | 245:da9d1bd999da | 218 | void SYS_PWR_RESET() // Have to be decided with EPS team. |
ee12b079 | 245:da9d1bd999da | 219 | { |
chaithanyarss | 257:7d404e9dc9e2 | 220 | sys_pwr_rst = 1; |
ee12b079 | 245:da9d1bd999da | 221 | } |
ee12b079 | 245:da9d1bd999da | 222 | |
ee12b079 | 245:da9d1bd999da | 223 | void EPS_V_A_EN() // This is a reset function |
ee12b079 | 245:da9d1bd999da | 224 | { |
chaithanyarss | 257:7d404e9dc9e2 | 225 | V_A_EN = 0; |
ee12b079 | 245:da9d1bd999da | 226 | wait_ms(10); |
chaithanyarss | 257:7d404e9dc9e2 | 227 | V_A_EN = 1; |
ee12b079 | 245:da9d1bd999da | 228 | } |
ee12b079 | 245:da9d1bd999da | 229 | |
ee12b079 | 245:da9d1bd999da | 230 | void EPS_V_C_EN() // This is a reset function |
ee12b079 | 245:da9d1bd999da | 231 | { |
ee12b079 | 245:da9d1bd999da | 232 | COM_RX_CNTRL = 0; |
ee12b079 | 245:da9d1bd999da | 233 | wait_ms(10); |
ee12b079 | 245:da9d1bd999da | 234 | COM_RX_CNTRL = 1; |
ee12b079 | 209:63e9c8f8b5d2 | 235 | } |
ee12b079 | 209:63e9c8f8b5d2 | 236 | |
ee12b079 | 209:63e9c8f8b5d2 | 237 | void RST_HK_COUNTER() |
ee12b079 | 209:63e9c8f8b5d2 | 238 | { |
ee12b079 | 209:63e9c8f8b5d2 | 239 | firstCount = true; |
ee12b079 | 209:63e9c8f8b5d2 | 240 | } |
ee12b079 | 209:63e9c8f8b5d2 | 241 | |
chaithanyarss | 257:7d404e9dc9e2 | 242 | int8_t CDMS_RD_SD_HK(uint8_t *sd_statusbits) |
ee12b079 | 209:63e9c8f8b5d2 | 243 | { |
chaithanyarss | 257:7d404e9dc9e2 | 244 | int8_t p; |
ee12b079 | 209:63e9c8f8b5d2 | 245 | if(SD_SW_EN_DS != DEVICE_POWERED) |
ee12b079 | 209:63e9c8f8b5d2 | 246 | { |
ee12b079 | 209:63e9c8f8b5d2 | 247 | SD_RD_ERROR = 1; |
chaithanyarss | 257:7d404e9dc9e2 | 248 | p = 1; |
ee12b079 | 209:63e9c8f8b5d2 | 249 | } |
ee12b079 | 209:63e9c8f8b5d2 | 250 | else |
ee12b079 | 209:63e9c8f8b5d2 | 251 | { |
ee12b079 | 209:63e9c8f8b5d2 | 252 | p = disk_read_statusbits(sd_statusbits); |
ee12b079 | 209:63e9c8f8b5d2 | 253 | } |
chaithanyarss | 257:7d404e9dc9e2 | 254 | return p; |
ee12b079 | 209:63e9c8f8b5d2 | 255 | } |
ee12b079 | 209:63e9c8f8b5d2 | 256 | |
ee12b079 | 245:da9d1bd999da | 257 | void CDMS_RD_RTC(uint64_t *time) |
ee12b079 | 245:da9d1bd999da | 258 | { |
ee12b079 | 245:da9d1bd999da | 259 | *time = FCTN_CDMS_RD_RTC(); |
ee12b079 | 245:da9d1bd999da | 260 | } |
ee12b079 | 245:da9d1bd999da | 261 | |
chaithanyarss | 257:7d404e9dc9e2 | 262 | void CDMS_CALIB_RTC(uint64_t *time) |
ee12b079 | 245:da9d1bd999da | 263 | { |
chaithanyarss | 257:7d404e9dc9e2 | 264 | SPI_mutex.lock(); |
chaithanyarss | 257:7d404e9dc9e2 | 265 | gCS_RTC=1; |
chaithanyarss | 257:7d404e9dc9e2 | 266 | spi.format(8,0); |
chaithanyarss | 257:7d404e9dc9e2 | 267 | spi.frequency(1000000); |
chaithanyarss | 257:7d404e9dc9e2 | 268 | |
chaithanyarss | 257:7d404e9dc9e2 | 269 | gCS_RTC=0; |
chaithanyarss | 257:7d404e9dc9e2 | 270 | spi.write(0x82); |
chaithanyarss | 257:7d404e9dc9e2 | 271 | spi.write(time[0]);//set minutes |
chaithanyarss | 257:7d404e9dc9e2 | 272 | gCS_RTC=1; |
chaithanyarss | 257:7d404e9dc9e2 | 273 | |
chaithanyarss | 257:7d404e9dc9e2 | 274 | gCS_RTC=0; |
chaithanyarss | 257:7d404e9dc9e2 | 275 | spi.write(0x83); |
chaithanyarss | 257:7d404e9dc9e2 | 276 | spi.write(time[1] & 0x3F); //set hours |
chaithanyarss | 257:7d404e9dc9e2 | 277 | gCS_RTC=1; |
ee12b079 | 245:da9d1bd999da | 278 | |
chaithanyarss | 257:7d404e9dc9e2 | 279 | gCS_RTC=0; |
chaithanyarss | 257:7d404e9dc9e2 | 280 | spi.write(0x85); |
chaithanyarss | 257:7d404e9dc9e2 | 281 | spi.write(time[2] & 0x3F); //set date |
chaithanyarss | 257:7d404e9dc9e2 | 282 | gCS_RTC=1; |
chaithanyarss | 257:7d404e9dc9e2 | 283 | |
chaithanyarss | 257:7d404e9dc9e2 | 284 | gCS_RTC=0; |
chaithanyarss | 257:7d404e9dc9e2 | 285 | spi.write(0x86); |
chaithanyarss | 257:7d404e9dc9e2 | 286 | spi.write(time[3] & 0x1F); //set month |
chaithanyarss | 257:7d404e9dc9e2 | 287 | gCS_RTC=1; |
chaithanyarss | 257:7d404e9dc9e2 | 288 | |
chaithanyarss | 257:7d404e9dc9e2 | 289 | gCS_RTC=0; |
chaithanyarss | 257:7d404e9dc9e2 | 290 | spi.write(0x87); |
chaithanyarss | 257:7d404e9dc9e2 | 291 | spi.write(time[4]); //set year to 00(2000) |
chaithanyarss | 257:7d404e9dc9e2 | 292 | gCS_RTC=1; |
chaithanyarss | 257:7d404e9dc9e2 | 293 | gPC.puts("\n\r rtc initalised \n"); |
chaithanyarss | 257:7d404e9dc9e2 | 294 | SPI_mutex.unlock(); |
ee12b079 | 245:da9d1bd999da | 295 | } |
ee12b079 | 245:da9d1bd999da | 296 | |
chaithanyarss | 224:3ac1f91e0ebc | 297 | void CDMS_RESET() |
chaithanyarss | 224:3ac1f91e0ebc | 298 | { |
chaithanyarss | 224:3ac1f91e0ebc | 299 | NVIC_SystemReset(); |
chaithanyarss | 224:3ac1f91e0ebc | 300 | } |
chaithanyarss | 224:3ac1f91e0ebc | 301 | |
ee12b079 | 245:da9d1bd999da | 302 | /* |
ee12b079 | 245:da9d1bd999da | 303 | //void CDMS_INTERNAL_RESET() |
ee12b079 | 209:63e9c8f8b5d2 | 304 | { |
ee12b079 | 209:63e9c8f8b5d2 | 305 | |
ee12b079 | 245:da9d1bd999da | 306 | } |
chaithanyarss | 257:7d404e9dc9e2 | 307 | */ |
chaithanyarss | 257:7d404e9dc9e2 | 308 | |
chaithanyarss | 257:7d404e9dc9e2 | 309 | //===============================MMS RAM functions================================== |
chaithanyarss | 257:7d404e9dc9e2 | 310 | |
chaithanyarss | 257:7d404e9dc9e2 | 311 | void FCTN_CDMS_RD_L_RAM(Base_tm *); |
chaithanyarss | 257:7d404e9dc9e2 | 312 | |
chaithanyarss | 257:7d404e9dc9e2 | 313 | void FCTN_CDMS_RD_L_RAM(Base_tm *tm_pointer) |
chaithanyarss | 257:7d404e9dc9e2 | 314 | { |
chaithanyarss | 257:7d404e9dc9e2 | 315 | for(int i=4;i<132;i++) |
chaithanyarss | 257:7d404e9dc9e2 | 316 | tm_pointer->TM_string[i] = CDMS_HK_FRAME[i-4]; |
chaithanyarss | 257:7d404e9dc9e2 | 317 | } |
chaithanyarss | 257:7d404e9dc9e2 | 318 | |
chaithanyarss | 257:7d404e9dc9e2 | 319 |