CDMS code for testing sbc

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of CDMS_CODE by shubham c

Committer:
ee12b079
Date:
Sun Jul 24 12:15:03 2016 +0000
Revision:
275:a2f1d544ab8b
Parent:
262:752c8689944a
Child:
272:9dacc1d8459a
CDMS code for testing sbc

Who changed what in which revision?

UserRevisionLine numberNew contents of line
chaithanyarss 258:7d404e9dc9e2 1
chaithanyarss 258:7d404e9dc9e2 2 // Includes MMS RAM functions also
chaithanyarss 258:7d404e9dc9e2 3
chaithanyarss 258:7d404e9dc9e2 4 /*===================================================FMS Functions=================================================*/
chaithanyarss 258:7d404e9dc9e2 5
chaithanyarss 258: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 258:7d404e9dc9e2 36 void CDMS_RESET();
ee12b079 245:da9d1bd999da 37 void SYS_PWR_RESET(); // Have to be decided with EPS team.
aniruddhv 262:752c8689944a 38 void sys_pwr_reset(void const *args);
ee12b079 245:da9d1bd999da 39 void EPS_V_A_EN();
ee12b079 245:da9d1bd999da 40 void EPS_V_C_EN();
ee12b079 245:da9d1bd999da 41
ee12b079 209:63e9c8f8b5d2 42 void RST_HK_COUNTER();
chaithanyarss 258:7d404e9dc9e2 43 int8_t CDMS_RD_SD_HK(uint8_t *);
chaithanyarss 258:7d404e9dc9e2 44 void CDMS_CALIB_RTC(uint8_t *);
chaithanyarss 258:7d404e9dc9e2 45 void TOTAL_RESET_WITH_CDMS();
chaithanyarss 258:7d404e9dc9e2 46
aniruddhv 262:752c8689944a 47 void sys_pwr_reset(void const *args){
aniruddhv 262:752c8689944a 48 SYS_PWR_RESET();
aniruddhv 262:752c8689944a 49 }
ee12b079 245:da9d1bd999da 50
chaithanyarss 258:7d404e9dc9e2 51 void STANDBY_PRCS()
chaithanyarss 258:7d404e9dc9e2 52 {
chaithanyarss 258:7d404e9dc9e2 53
chaithanyarss 258:7d404e9dc9e2 54 }
ee12b079 209:63e9c8f8b5d2 55
ee12b079 209:63e9c8f8b5d2 56 void P_PL_INIT()
ee12b079 209:63e9c8f8b5d2 57 {
ee12b079 209:63e9c8f8b5d2 58
ee12b079 209:63e9c8f8b5d2 59 }
ee12b079 209:63e9c8f8b5d2 60
ee12b079 209:63e9c8f8b5d2 61 void P_PL_MAIN()
ee12b079 209:63e9c8f8b5d2 62 {
chaithanyarss 258:7d404e9dc9e2 63 FCTN_CDMS_PL_MAIN((void *)NULL);
ee12b079 209:63e9c8f8b5d2 64 }
ee12b079 209:63e9c8f8b5d2 65
ee12b079 209:63e9c8f8b5d2 66 void P_COM_INIT()
ee12b079 209:63e9c8f8b5d2 67 {
ee12b079 245:da9d1bd999da 68 P_COM_INIT;
ee12b079 209:63e9c8f8b5d2 69 }
ee12b079 209:63e9c8f8b5d2 70
ee12b079 209:63e9c8f8b5d2 71 void P_CDMS_HK_MAIN()
ee12b079 209:63e9c8f8b5d2 72 {
ee12b079 245:da9d1bd999da 73 FCTN_CDMS_HK_MAIN((void *)NULL);
ee12b079 209:63e9c8f8b5d2 74 }
ee12b079 209:63e9c8f8b5d2 75
ee12b079 209:63e9c8f8b5d2 76 void P_PL_RCV_SC_DATA()
ee12b079 209:63e9c8f8b5d2 77 {
ee12b079 245:da9d1bd999da 78
ee12b079 209:63e9c8f8b5d2 79 }
ee12b079 209:63e9c8f8b5d2 80
ee12b079 209:63e9c8f8b5d2 81 void P_CDMS_INIT_SD()
ee12b079 209:63e9c8f8b5d2 82 {
ee12b079 209:63e9c8f8b5d2 83 FCTN_CDMS_SD_INIT();
ee12b079 209:63e9c8f8b5d2 84 }
ee12b079 209:63e9c8f8b5d2 85
ee12b079 209:63e9c8f8b5d2 86 void CDMS_SD_SW_ON()
ee12b079 209:63e9c8f8b5d2 87 {
ee12b079 245:da9d1bd999da 88 SD_SW_EN_DS = 0;
chaithanyarss 261:1e54415b34d3 89 SD_STATUS = DEVICE_POWERED;
chaithanyarss 261:1e54415b34d3 90 CDMS_SD_SW_STATUS = DEVICE_POWERED;
chaithanyarss 261:1e54415b34d3 91 FCTN_CDMS_WR_FLASH(2,DEVICE_POWERED);
chaithanyarss 261:1e54415b34d3 92 gPC.printf("sw on sd\n");
ee12b079 209:63e9c8f8b5d2 93 }
ee12b079 209:63e9c8f8b5d2 94
ee12b079 209:63e9c8f8b5d2 95 void CDMS_SD_SW_OFF()
ee12b079 209:63e9c8f8b5d2 96 {
ee12b079 245:da9d1bd999da 97 SD_SW_EN_DS = 1;
chaithanyarss 261:1e54415b34d3 98 SD_STATUS = DEVICE_DISABLED;
chaithanyarss 261:1e54415b34d3 99 CDMS_SD_SW_STATUS = DEVICE_DISABLED;
chaithanyarss 261:1e54415b34d3 100 FCTN_CDMS_WR_FLASH(2,DEVICE_DISABLED);
chaithanyarss 261:1e54415b34d3 101 gPC.printf("sw off sd\n");
ee12b079 209:63e9c8f8b5d2 102 }
ee12b079 209:63e9c8f8b5d2 103
ee12b079 245:da9d1bd999da 104 void CDMS_RTC_ON()
ee12b079 209:63e9c8f8b5d2 105 {
chaithanyarss 258:7d404e9dc9e2 106 //FCTN_CDMS_INIT_RTC();
chaithanyarss 258:7d404e9dc9e2 107 SPI_mutex.lock();
chaithanyarss 258:7d404e9dc9e2 108 gCS_RTC=1;
chaithanyarss 258:7d404e9dc9e2 109 gCS_RTC=0;
chaithanyarss 258:7d404e9dc9e2 110 spi.write(0x81); //register address with write flag
chaithanyarss 258:7d404e9dc9e2 111 spi.write(0x00);//disabling stop bit in the seconds register
chaithanyarss 258:7d404e9dc9e2 112 SPI_mutex.unlock();
chaithanyarss 261:1e54415b34d3 113 gPC.printf("sw on rtc\n");
ee12b079 209:63e9c8f8b5d2 114 }
ee12b079 209:63e9c8f8b5d2 115
ee12b079 245:da9d1bd999da 116 void CDMS_RTC_OFF()
ee12b079 209:63e9c8f8b5d2 117 {
chaithanyarss 258:7d404e9dc9e2 118 SPI_mutex.lock();
chaithanyarss 258:7d404e9dc9e2 119 gCS_RTC=1;
chaithanyarss 258:7d404e9dc9e2 120 gCS_RTC=0;
chaithanyarss 258:7d404e9dc9e2 121 spi.write(0x81); //register address with write flag
chaithanyarss 258:7d404e9dc9e2 122 spi.write(0x80);//enabling stop bit in the seconds register
chaithanyarss 258:7d404e9dc9e2 123 SPI_mutex.unlock();
chaithanyarss 261:1e54415b34d3 124 gPC.printf("sw off rtc\n");
ee12b079 209:63e9c8f8b5d2 125 }
ee12b079 209:63e9c8f8b5d2 126
ee12b079 245:da9d1bd999da 127 void SW_ON_BAE()
ee12b079 245:da9d1bd999da 128 {
ee12b079 245:da9d1bd999da 129 BAE_SW_EN_DS = 0;
chaithanyarss 261:1e54415b34d3 130 BAE_STATUS = DEVICE_POWERED;
chaithanyarss 261:1e54415b34d3 131 BAE_SW_STATUS = DEVICE_POWERED;
chaithanyarss 261:1e54415b34d3 132 FCTN_CDMS_WR_FLASH(1,DEVICE_POWERED);
chaithanyarss 261:1e54415b34d3 133 gPC.printf("sw on bae\n");
ee12b079 245:da9d1bd999da 134 }
ee12b079 245:da9d1bd999da 135
ee12b079 245:da9d1bd999da 136 void SW_OFF_BAE()
ee12b079 245:da9d1bd999da 137 {
ee12b079 245:da9d1bd999da 138 BAE_SW_EN_DS = 1;
chaithanyarss 261:1e54415b34d3 139 BAE_STATUS = DEVICE_DISABLED;
chaithanyarss 261:1e54415b34d3 140 BAE_SW_STATUS = DEVICE_DISABLED;
chaithanyarss 261:1e54415b34d3 141 FCTN_CDMS_WR_FLASH(1,DEVICE_DISABLED);
chaithanyarss 261:1e54415b34d3 142 gPC.printf("sw off bae\n");
ee12b079 245:da9d1bd999da 143 }
ee12b079 245:da9d1bd999da 144
ee12b079 245:da9d1bd999da 145 void SW_ON_PL_BEE()
ee12b079 245:da9d1bd999da 146 {
chaithanyarss 261:1e54415b34d3 147 PYLD_DFF_CLK = 0;
chaithanyarss 261:1e54415b34d3 148 PYLD_DFF = 1;
chaithanyarss 261:1e54415b34d3 149 wait_us(1);
chaithanyarss 261:1e54415b34d3 150 PYLD_DFF_CLK = 1;
chaithanyarss 261:1e54415b34d3 151 wait_us(1);
chaithanyarss 261:1e54415b34d3 152 PYLD_DFF_CLK = 0;
chaithanyarss 261:1e54415b34d3 153 wait_us(1);
chaithanyarss 261:1e54415b34d3 154 PL_STATUS = DEVICE_POWERED;
chaithanyarss 261:1e54415b34d3 155 PL_BEE_SW_STATUS = DEVICE_POWERED;
chaithanyarss 261:1e54415b34d3 156 FCTN_CDMS_WR_FLASH(3,DEVICE_POWERED);
ee12b079 245:da9d1bd999da 157 }
ee12b079 245:da9d1bd999da 158
ee12b079 245:da9d1bd999da 159 void SW_OFF_PL_BEE()
ee12b079 245:da9d1bd999da 160 {
ee12b079 245:da9d1bd999da 161 PYLD_DFF_CLK = 0;
ee12b079 245:da9d1bd999da 162 PYLD_DFF = 0;
ee12b079 245:da9d1bd999da 163 wait_us(1);
ee12b079 245:da9d1bd999da 164 PYLD_DFF_CLK = 1;
ee12b079 245:da9d1bd999da 165 wait_us(1);
ee12b079 245:da9d1bd999da 166 PYLD_DFF_CLK = 0;
ee12b079 245:da9d1bd999da 167 wait_us(1);
chaithanyarss 261:1e54415b34d3 168 PL_STATUS = DEVICE_DISABLED;
chaithanyarss 261:1e54415b34d3 169 PL_BEE_SW_STATUS = DEVICE_DISABLED;
chaithanyarss 261:1e54415b34d3 170 FCTN_CDMS_WR_FLASH(3,DEVICE_DISABLED);
ee12b079 245:da9d1bd999da 171 }
ee12b079 245:da9d1bd999da 172
ee12b079 245:da9d1bd999da 173 void SW_ON_PL_EPS()
ee12b079 245:da9d1bd999da 174 {
chaithanyarss 261:1e54415b34d3 175 PYLD_EPS_DFF_PWR_CLK = 0;
chaithanyarss 261:1e54415b34d3 176 PYLD_EPS_DFF_PWR = 1;
chaithanyarss 261:1e54415b34d3 177 wait_us(1);
chaithanyarss 261:1e54415b34d3 178 PYLD_EPS_DFF_PWR_CLK = 1;
chaithanyarss 261:1e54415b34d3 179 wait_us(1);
chaithanyarss 261:1e54415b34d3 180 PYLD_EPS_DFF_PWR_CLK = 0;
chaithanyarss 261:1e54415b34d3 181 wait_us(1);
chaithanyarss 261:1e54415b34d3 182 PL_EPS_LATCH_SW_EN = 1;
chaithanyarss 261:1e54415b34d3 183 FCTN_CDMS_WR_FLASH(4,1);
ee12b079 245:da9d1bd999da 184 }
ee12b079 245:da9d1bd999da 185
ee12b079 209:63e9c8f8b5d2 186 void SW_OFF_PL_EPS()
ee12b079 209:63e9c8f8b5d2 187 {
chaithanyarss 261:1e54415b34d3 188 PYLD_EPS_DFF_PWR_CLK = 0;
chaithanyarss 261:1e54415b34d3 189 PYLD_EPS_DFF_PWR = 0;
chaithanyarss 261:1e54415b34d3 190 wait_us(1);
chaithanyarss 261:1e54415b34d3 191 PYLD_EPS_DFF_PWR_CLK = 1;
chaithanyarss 261:1e54415b34d3 192 wait_us(1);
chaithanyarss 261:1e54415b34d3 193 PYLD_EPS_DFF_PWR_CLK = 0;
chaithanyarss 261:1e54415b34d3 194 wait_us(1);
chaithanyarss 261:1e54415b34d3 195 PL_EPS_LATCH_SW_EN = 0;
chaithanyarss 261:1e54415b34d3 196 FCTN_CDMS_WR_FLASH(4,0);
ee12b079 209:63e9c8f8b5d2 197 }
ee12b079 209:63e9c8f8b5d2 198
ee12b079 209:63e9c8f8b5d2 199 void SW_ON_V_A_EN()
ee12b079 209:63e9c8f8b5d2 200 {
chaithanyarss 258:7d404e9dc9e2 201 V_A_EN = 1;
chaithanyarss 261:1e54415b34d3 202 EPS_V_A_EN_STATUS = 1;
chaithanyarss 261:1e54415b34d3 203 FCTN_CDMS_WR_FLASH(0,1);
ee12b079 209:63e9c8f8b5d2 204 }
ee12b079 209:63e9c8f8b5d2 205
ee12b079 209:63e9c8f8b5d2 206 void SW_OFF_V_A_EN()
ee12b079 209:63e9c8f8b5d2 207 {
chaithanyarss 258:7d404e9dc9e2 208 V_A_EN = 0;
chaithanyarss 261:1e54415b34d3 209 EPS_V_A_EN_STATUS = 0;
chaithanyarss 261:1e54415b34d3 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 245:da9d1bd999da 215 SD_SW_EN_DS = 1;
ee12b079 209:63e9c8f8b5d2 216 wait_ms(10);
ee12b079 209:63e9c8f8b5d2 217 SD_SW_EN_DS = 0;
chaithanyarss 261:1e54415b34d3 218 gPC.printf("rst sd\n");
ee12b079 245:da9d1bd999da 219 }
ee12b079 245:da9d1bd999da 220
ee12b079 245:da9d1bd999da 221 void SW_RST_BAE()
ee12b079 245:da9d1bd999da 222 {
ee12b079 245:da9d1bd999da 223 BAE_SW_EN_DS = 1;
ee12b079 245:da9d1bd999da 224 wait_ms(10);
ee12b079 245:da9d1bd999da 225 BAE_SW_EN_DS = 0;
chaithanyarss 261:1e54415b34d3 226 gPC.printf("rst bae\n");
ee12b079 245:da9d1bd999da 227 }
ee12b079 245:da9d1bd999da 228
ee12b079 245:da9d1bd999da 229 void SW_RST_PL_BEE()
ee12b079 245:da9d1bd999da 230 {
ee12b079 245:da9d1bd999da 231 PYLD_DFF = 1;
ee12b079 245:da9d1bd999da 232 wait_ms(10);
ee12b079 245:da9d1bd999da 233 PYLD_DFF = 0;
ee12b079 209:63e9c8f8b5d2 234 }
ee12b079 209:63e9c8f8b5d2 235
ee12b079 209:63e9c8f8b5d2 236 void RST_BAE()
ee12b079 209:63e9c8f8b5d2 237 {
ee12b079 245:da9d1bd999da 238 RESET_TO_BAE = 1;
ee12b079 209:63e9c8f8b5d2 239 wait_ms(10);
ee12b079 245:da9d1bd999da 240 RESET_TO_BAE = 0;
ee12b079 209:63e9c8f8b5d2 241 }
ee12b079 209:63e9c8f8b5d2 242
ee12b079 209:63e9c8f8b5d2 243 void RST_PL_BEE()
ee12b079 209:63e9c8f8b5d2 244 {
ee12b079 245:da9d1bd999da 245 RESET_TO_PYLD = 1;
ee12b079 209:63e9c8f8b5d2 246 wait_ms(10);
ee12b079 245:da9d1bd999da 247 RESET_TO_PYLD = 0;
ee12b079 245:da9d1bd999da 248 }
ee12b079 245:da9d1bd999da 249
ee12b079 245:da9d1bd999da 250 void CDMS_INTERNAL_RESET()
ee12b079 245:da9d1bd999da 251 {
ee12b079 245:da9d1bd999da 252 NVIC_SystemReset();
ee12b079 245:da9d1bd999da 253 }
ee12b079 245:da9d1bd999da 254
ee12b079 245:da9d1bd999da 255 void SYS_PWR_RESET() // Have to be decided with EPS team.
ee12b079 245:da9d1bd999da 256 {
chaithanyarss 258:7d404e9dc9e2 257 sys_pwr_rst = 1;
ee12b079 245:da9d1bd999da 258 }
ee12b079 245:da9d1bd999da 259
ee12b079 245:da9d1bd999da 260 void EPS_V_A_EN() // This is a reset function
ee12b079 245:da9d1bd999da 261 {
chaithanyarss 258:7d404e9dc9e2 262 V_A_EN = 0;
ee12b079 245:da9d1bd999da 263 wait_ms(10);
chaithanyarss 258:7d404e9dc9e2 264 V_A_EN = 1;
ee12b079 245:da9d1bd999da 265 }
ee12b079 245:da9d1bd999da 266
ee12b079 245:da9d1bd999da 267 void EPS_V_C_EN() // This is a reset function
ee12b079 245:da9d1bd999da 268 {
ee12b079 245:da9d1bd999da 269 COM_RX_CNTRL = 0;
ee12b079 245:da9d1bd999da 270 wait_ms(10);
ee12b079 245:da9d1bd999da 271 COM_RX_CNTRL = 1;
ee12b079 209:63e9c8f8b5d2 272 }
ee12b079 209:63e9c8f8b5d2 273
ee12b079 209:63e9c8f8b5d2 274 void RST_HK_COUNTER()
ee12b079 209:63e9c8f8b5d2 275 {
ee12b079 209:63e9c8f8b5d2 276 firstCount = true;
ee12b079 209:63e9c8f8b5d2 277 }
ee12b079 209:63e9c8f8b5d2 278
chaithanyarss 258:7d404e9dc9e2 279 int8_t CDMS_RD_SD_HK(uint8_t *sd_statusbits)
ee12b079 209:63e9c8f8b5d2 280 {
chaithanyarss 258:7d404e9dc9e2 281 int8_t p;
ee12b079 209:63e9c8f8b5d2 282 if(SD_SW_EN_DS != DEVICE_POWERED)
ee12b079 209:63e9c8f8b5d2 283 {
ee12b079 209:63e9c8f8b5d2 284 SD_RD_ERROR = 1;
chaithanyarss 258:7d404e9dc9e2 285 p = 1;
ee12b079 209:63e9c8f8b5d2 286 }
ee12b079 209:63e9c8f8b5d2 287 else
ee12b079 209:63e9c8f8b5d2 288 {
ee12b079 209:63e9c8f8b5d2 289 p = disk_read_statusbits(sd_statusbits);
ee12b079 209:63e9c8f8b5d2 290 }
chaithanyarss 258:7d404e9dc9e2 291 return p;
ee12b079 209:63e9c8f8b5d2 292 }
ee12b079 209:63e9c8f8b5d2 293
chaithanyarss 261:1e54415b34d3 294 void CDMS_CALIB_RTC(uint64_t time)
ee12b079 245:da9d1bd999da 295 {
chaithanyarss 258:7d404e9dc9e2 296 SPI_mutex.lock();
chaithanyarss 258:7d404e9dc9e2 297 gCS_RTC=1;
chaithanyarss 258:7d404e9dc9e2 298 spi.format(8,0);
chaithanyarss 258:7d404e9dc9e2 299 spi.frequency(1000000);
chaithanyarss 258:7d404e9dc9e2 300
chaithanyarss 258:7d404e9dc9e2 301 gCS_RTC=0;
chaithanyarss 258:7d404e9dc9e2 302 spi.write(0x82);
chaithanyarss 261:1e54415b34d3 303 spi.write((uint8_t)time);//set minutes
chaithanyarss 258:7d404e9dc9e2 304 gCS_RTC=1;
chaithanyarss 258:7d404e9dc9e2 305
chaithanyarss 258:7d404e9dc9e2 306 gCS_RTC=0;
chaithanyarss 258:7d404e9dc9e2 307 spi.write(0x83);
chaithanyarss 261:1e54415b34d3 308 spi.write((uint8_t)(time>>8) & 0x3F); //set hours
chaithanyarss 258:7d404e9dc9e2 309 gCS_RTC=1;
ee12b079 245:da9d1bd999da 310
chaithanyarss 258:7d404e9dc9e2 311 gCS_RTC=0;
chaithanyarss 258:7d404e9dc9e2 312 spi.write(0x85);
chaithanyarss 261:1e54415b34d3 313 spi.write((uint8_t)(time>>16) & 0x3F); //set date
chaithanyarss 258:7d404e9dc9e2 314 gCS_RTC=1;
chaithanyarss 258:7d404e9dc9e2 315
chaithanyarss 258:7d404e9dc9e2 316 gCS_RTC=0;
chaithanyarss 258:7d404e9dc9e2 317 spi.write(0x86);
chaithanyarss 261:1e54415b34d3 318 spi.write((uint8_t)(time>>24) & 0x1F); //set month
chaithanyarss 258:7d404e9dc9e2 319 gCS_RTC=1;
chaithanyarss 258:7d404e9dc9e2 320
chaithanyarss 258:7d404e9dc9e2 321 gCS_RTC=0;
chaithanyarss 258:7d404e9dc9e2 322 spi.write(0x87);
chaithanyarss 261:1e54415b34d3 323 spi.write((uint8_t)(time>>32)); //set year to 00(2000)
chaithanyarss 258:7d404e9dc9e2 324 gCS_RTC=1;
chaithanyarss 258:7d404e9dc9e2 325 gPC.puts("\n\r rtc initalised \n");
chaithanyarss 258:7d404e9dc9e2 326 SPI_mutex.unlock();
ee12b079 245:da9d1bd999da 327 }
ee12b079 245:da9d1bd999da 328
chaithanyarss 224:3ac1f91e0ebc 329 void CDMS_RESET()
chaithanyarss 224:3ac1f91e0ebc 330 {
chaithanyarss 224:3ac1f91e0ebc 331 NVIC_SystemReset();
chaithanyarss 224:3ac1f91e0ebc 332 }
chaithanyarss 224:3ac1f91e0ebc 333
ee12b079 245:da9d1bd999da 334 /*
ee12b079 245:da9d1bd999da 335 //void CDMS_INTERNAL_RESET()
ee12b079 209:63e9c8f8b5d2 336 {
ee12b079 209:63e9c8f8b5d2 337
ee12b079 245:da9d1bd999da 338 }
chaithanyarss 258:7d404e9dc9e2 339 */
chaithanyarss 258:7d404e9dc9e2 340
chaithanyarss 258:7d404e9dc9e2 341 //===============================MMS RAM functions==================================
chaithanyarss 258:7d404e9dc9e2 342
chaithanyarss 258:7d404e9dc9e2 343 void FCTN_CDMS_RD_L_RAM(Base_tm *);
chaithanyarss 258:7d404e9dc9e2 344
chaithanyarss 258:7d404e9dc9e2 345 void FCTN_CDMS_RD_L_RAM(Base_tm *tm_pointer)
chaithanyarss 258:7d404e9dc9e2 346 {
chaithanyarss 258:7d404e9dc9e2 347 for(int i=4;i<132;i++)
chaithanyarss 258:7d404e9dc9e2 348 tm_pointer->TM_string[i] = CDMS_HK_FRAME[i-4];
chaithanyarss 258:7d404e9dc9e2 349 }
chaithanyarss 258:7d404e9dc9e2 350
chaithanyarss 258:7d404e9dc9e2 351