working version

Dependencies:   mbed mbed-rtos SimpleDMA FreescaleIAP eeprom

Fork of CDMS_CODE_FM_28JAN2017 by samp Srinivasan

Committer:
chaithanyarss
Date:
Fri Jul 08 12:53:24 2016 +0000
Revision:
248:407ab7e337cd
Parent:
235:c127b15409b2
Child:
249:1560c64adffb
Completed HK except Flash

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ee12b079 209:63e9c8f8b5d2 1
chaithanyarss 248:407ab7e337cd 2 /*===================================================FMS Functions=================================================*/
ee12b079 235:c127b15409b2 3 //Run processes
ee12b079 209:63e9c8f8b5d2 4 void P_PL_INIT();
ee12b079 209:63e9c8f8b5d2 5 void P_PL_MAIN();
ee12b079 209:63e9c8f8b5d2 6 void P_COM_INIT();
ee12b079 209:63e9c8f8b5d2 7 void P_CDMS_HK_MAIN();
ee12b079 209:63e9c8f8b5d2 8 void P_PL_RCV_SC_DATA();
ee12b079 209:63e9c8f8b5d2 9 void P_CDMS_INIT_SD();
ee12b079 235:c127b15409b2 10
ee12b079 235:c127b15409b2 11 // Switch ON/OFF functions
ee12b079 209:63e9c8f8b5d2 12 void CDMS_SD_SW_ON();
ee12b079 209:63e9c8f8b5d2 13 void CDMS_SD_SW_OFF();
ee12b079 235:c127b15409b2 14 void CDMS_RTC_ON();
ee12b079 235:c127b15409b2 15 void CDMS_RTC_OFF();
ee12b079 209:63e9c8f8b5d2 16 void SW_ON_BAE();
ee12b079 209:63e9c8f8b5d2 17 void SW_OFF_BAE();
ee12b079 209:63e9c8f8b5d2 18 void SW_ON_PL_BEE();
ee12b079 209:63e9c8f8b5d2 19 void SW_OFF_PL_BEE();
ee12b079 209:63e9c8f8b5d2 20 void SW_ON_PL_EPS();
ee12b079 209:63e9c8f8b5d2 21 void SW_OFF_PL_EPS();
ee12b079 209:63e9c8f8b5d2 22 void SW_ON_V_A_EN();
ee12b079 209:63e9c8f8b5d2 23 void SW_OFF_V_A_EN();
ee12b079 235:c127b15409b2 24
ee12b079 235:c127b15409b2 25 // RST functions
ee12b079 209:63e9c8f8b5d2 26 void RST_SD();
ee12b079 235:c127b15409b2 27 void SW_RST_BAE();
ee12b079 235:c127b15409b2 28 void SW_RST_PL_BEE();
ee12b079 209:63e9c8f8b5d2 29 void RST_BAE();
ee12b079 209:63e9c8f8b5d2 30 void RST_PL_BEE();
chaithanyarss 248:407ab7e337cd 31 void CDMS_RESET();
ee12b079 235:c127b15409b2 32 void SYS_PWR_RESET(); // Have to be decided with EPS team.
ee12b079 235:c127b15409b2 33 void EPS_V_A_EN();
ee12b079 235:c127b15409b2 34 void EPS_V_C_EN();
ee12b079 235:c127b15409b2 35
ee12b079 209:63e9c8f8b5d2 36 void RST_HK_COUNTER();
ee12b079 209:63e9c8f8b5d2 37 uint8_t CDMS_RD_SD_HK(uint8_t *);
ee12b079 235:c127b15409b2 38 void CDMS_RD_RTC(uint64_t *);
ee12b079 235:c127b15409b2 39 void CDMS_CALIB_RTC();
chaithanyarss 248:407ab7e337cd 40 void TOTAL_RESET_WITH_CDMS();
ee12b079 235:c127b15409b2 41
ee12b079 209:63e9c8f8b5d2 42
ee12b079 209:63e9c8f8b5d2 43 void P_PL_INIT()
ee12b079 209:63e9c8f8b5d2 44 {
ee12b079 209:63e9c8f8b5d2 45
ee12b079 209:63e9c8f8b5d2 46 }
ee12b079 209:63e9c8f8b5d2 47
ee12b079 209:63e9c8f8b5d2 48 void P_PL_MAIN()
ee12b079 209:63e9c8f8b5d2 49 {
chaithanyarss 248:407ab7e337cd 50 FCTN_CDMS_PL_MAIN((void *)NULL);
ee12b079 209:63e9c8f8b5d2 51 }
ee12b079 209:63e9c8f8b5d2 52
ee12b079 209:63e9c8f8b5d2 53 void P_COM_INIT()
ee12b079 209:63e9c8f8b5d2 54 {
ee12b079 235:c127b15409b2 55 P_COM_INIT;
ee12b079 209:63e9c8f8b5d2 56 }
ee12b079 209:63e9c8f8b5d2 57
ee12b079 209:63e9c8f8b5d2 58 void P_CDMS_HK_MAIN()
ee12b079 209:63e9c8f8b5d2 59 {
ee12b079 235:c127b15409b2 60 FCTN_CDMS_HK_MAIN((void *)NULL);
ee12b079 209:63e9c8f8b5d2 61 }
ee12b079 209:63e9c8f8b5d2 62
ee12b079 209:63e9c8f8b5d2 63 void P_PL_RCV_SC_DATA()
ee12b079 209:63e9c8f8b5d2 64 {
ee12b079 235:c127b15409b2 65
ee12b079 209:63e9c8f8b5d2 66 }
ee12b079 209:63e9c8f8b5d2 67
ee12b079 209:63e9c8f8b5d2 68 void P_CDMS_INIT_SD()
ee12b079 209:63e9c8f8b5d2 69 {
ee12b079 209:63e9c8f8b5d2 70 FCTN_CDMS_SD_INIT();
ee12b079 209:63e9c8f8b5d2 71 }
ee12b079 209:63e9c8f8b5d2 72
ee12b079 209:63e9c8f8b5d2 73 void CDMS_SD_SW_ON()
ee12b079 209:63e9c8f8b5d2 74 {
ee12b079 235:c127b15409b2 75 SD_SW_EN_DS = 0;
ee12b079 209:63e9c8f8b5d2 76 }
ee12b079 209:63e9c8f8b5d2 77
ee12b079 209:63e9c8f8b5d2 78 void CDMS_SD_SW_OFF()
ee12b079 209:63e9c8f8b5d2 79 {
ee12b079 235:c127b15409b2 80 SD_SW_EN_DS = 1;
ee12b079 209:63e9c8f8b5d2 81 }
ee12b079 209:63e9c8f8b5d2 82
ee12b079 235:c127b15409b2 83 void CDMS_RTC_ON()
ee12b079 209:63e9c8f8b5d2 84 {
chaithanyarss 248:407ab7e337cd 85 //FCTN_CDMS_INIT_RTC();
chaithanyarss 248:407ab7e337cd 86 SPI_mutex.lock();
chaithanyarss 248:407ab7e337cd 87 gCS_RTC=1;
chaithanyarss 248:407ab7e337cd 88 gCS_RTC=0;
chaithanyarss 248:407ab7e337cd 89 spi.write(0x81); //register address with write flag
chaithanyarss 248:407ab7e337cd 90 spi.write(0x00);//disabling stop bit in the seconds register
chaithanyarss 248:407ab7e337cd 91 SPI_mutex.unlock();
ee12b079 209:63e9c8f8b5d2 92 }
ee12b079 209:63e9c8f8b5d2 93
ee12b079 235:c127b15409b2 94 void CDMS_RTC_OFF()
ee12b079 209:63e9c8f8b5d2 95 {
chaithanyarss 248:407ab7e337cd 96 SPI_mutex.lock();
chaithanyarss 248:407ab7e337cd 97 gCS_RTC=1;
chaithanyarss 248:407ab7e337cd 98 gCS_RTC=0;
chaithanyarss 248:407ab7e337cd 99 spi.write(0x81); //register address with write flag
chaithanyarss 248:407ab7e337cd 100 spi.write(0x80);//enabling stop bit in the seconds register
chaithanyarss 248:407ab7e337cd 101 SPI_mutex.unlock();
ee12b079 209:63e9c8f8b5d2 102 }
ee12b079 209:63e9c8f8b5d2 103
ee12b079 235:c127b15409b2 104 void SW_ON_BAE()
ee12b079 235:c127b15409b2 105 {
ee12b079 235:c127b15409b2 106 BAE_SW_EN_DS = 0;
ee12b079 235:c127b15409b2 107 }
ee12b079 235:c127b15409b2 108
ee12b079 235:c127b15409b2 109 void SW_OFF_BAE()
ee12b079 235:c127b15409b2 110 {
ee12b079 235:c127b15409b2 111 BAE_SW_EN_DS = 1;
ee12b079 235:c127b15409b2 112 }
ee12b079 235:c127b15409b2 113
ee12b079 235:c127b15409b2 114 void SW_ON_PL_BEE()
ee12b079 235:c127b15409b2 115 {
ee12b079 235:c127b15409b2 116 PYLD_DFF_CLK = 0;\
ee12b079 235:c127b15409b2 117 PYLD_DFF = 1;\
ee12b079 235:c127b15409b2 118 wait_us(1);\
ee12b079 235:c127b15409b2 119 PYLD_DFF_CLK = 1;\
ee12b079 235:c127b15409b2 120 wait_us(1);\
ee12b079 235:c127b15409b2 121 PYLD_DFF_CLK = 0;\
ee12b079 235:c127b15409b2 122 wait_us(1);\
ee12b079 235:c127b15409b2 123 }
ee12b079 235:c127b15409b2 124
ee12b079 235:c127b15409b2 125 void SW_OFF_PL_BEE()
ee12b079 235:c127b15409b2 126 {
ee12b079 235:c127b15409b2 127 PYLD_DFF_CLK = 0;
ee12b079 235:c127b15409b2 128 PYLD_DFF = 0;
ee12b079 235:c127b15409b2 129 wait_us(1);
ee12b079 235:c127b15409b2 130 PYLD_DFF_CLK = 1;
ee12b079 235:c127b15409b2 131 wait_us(1);
ee12b079 235:c127b15409b2 132 PYLD_DFF_CLK = 0;
ee12b079 235:c127b15409b2 133 wait_us(1);
ee12b079 235:c127b15409b2 134 }
ee12b079 235:c127b15409b2 135
ee12b079 235:c127b15409b2 136 void SW_ON_PL_EPS()
ee12b079 235:c127b15409b2 137 {
ee12b079 235:c127b15409b2 138 PYLD_EPS_DFF_PWR_CLK = 0;\
ee12b079 235:c127b15409b2 139 PYLD_EPS_DFF_PWR = 1;\
ee12b079 235:c127b15409b2 140 wait_us(1);\
ee12b079 235:c127b15409b2 141 PYLD_EPS_DFF_PWR_CLK = 1;\
ee12b079 235:c127b15409b2 142 wait_us(1);\
ee12b079 235:c127b15409b2 143 PYLD_EPS_DFF_PWR_CLK = 0;\
ee12b079 235:c127b15409b2 144 wait_us(1);\
ee12b079 235:c127b15409b2 145 }
ee12b079 235:c127b15409b2 146
ee12b079 209:63e9c8f8b5d2 147 void SW_OFF_PL_EPS()
ee12b079 209:63e9c8f8b5d2 148 {
ee12b079 235:c127b15409b2 149 PYLD_EPS_DFF_PWR_CLK = 0;\
ee12b079 235:c127b15409b2 150 PYLD_EPS_DFF_PWR = 0;\
ee12b079 235:c127b15409b2 151 wait_us(1);\
ee12b079 235:c127b15409b2 152 PYLD_EPS_DFF_PWR_CLK = 1;\
ee12b079 235:c127b15409b2 153 wait_us(1);\
ee12b079 235:c127b15409b2 154 PYLD_EPS_DFF_PWR_CLK = 0;\
ee12b079 235:c127b15409b2 155 wait_us(1);\
ee12b079 209:63e9c8f8b5d2 156 }
ee12b079 209:63e9c8f8b5d2 157
ee12b079 209:63e9c8f8b5d2 158 void SW_ON_V_A_EN()
ee12b079 209:63e9c8f8b5d2 159 {
ee12b079 235:c127b15409b2 160 TRXY_PWR_CNTRL = 1;
ee12b079 235:c127b15409b2 161 TRZ_PWR_CNTRL = 1;
ee12b079 209:63e9c8f8b5d2 162 }
ee12b079 209:63e9c8f8b5d2 163
ee12b079 209:63e9c8f8b5d2 164 void SW_OFF_V_A_EN()
ee12b079 209:63e9c8f8b5d2 165 {
ee12b079 235:c127b15409b2 166 TRXY_PWR_CNTRL = 0;
ee12b079 235:c127b15409b2 167 TRZ_PWR_CNTRL = 0;
ee12b079 209:63e9c8f8b5d2 168 }
ee12b079 209:63e9c8f8b5d2 169
ee12b079 209:63e9c8f8b5d2 170 void RST_SD()
ee12b079 209:63e9c8f8b5d2 171 {
ee12b079 235:c127b15409b2 172 SD_SW_EN_DS = 1;
ee12b079 209:63e9c8f8b5d2 173 wait_ms(10);
ee12b079 209:63e9c8f8b5d2 174 SD_SW_EN_DS = 0;
ee12b079 235:c127b15409b2 175 }
ee12b079 235:c127b15409b2 176
ee12b079 235:c127b15409b2 177 void SW_RST_BAE()
ee12b079 235:c127b15409b2 178 {
ee12b079 235:c127b15409b2 179 BAE_SW_EN_DS = 1;
ee12b079 235:c127b15409b2 180 wait_ms(10);
ee12b079 235:c127b15409b2 181 BAE_SW_EN_DS = 0;
ee12b079 235:c127b15409b2 182 }
ee12b079 235:c127b15409b2 183
ee12b079 235:c127b15409b2 184 void SW_RST_PL_BEE()
ee12b079 235:c127b15409b2 185 {
ee12b079 235:c127b15409b2 186 PYLD_DFF = 1;
ee12b079 235:c127b15409b2 187 wait_ms(10);
ee12b079 235:c127b15409b2 188 PYLD_DFF = 0;
ee12b079 209:63e9c8f8b5d2 189 }
ee12b079 209:63e9c8f8b5d2 190
ee12b079 209:63e9c8f8b5d2 191 void RST_BAE()
ee12b079 209:63e9c8f8b5d2 192 {
ee12b079 235:c127b15409b2 193 RESET_TO_BAE = 1;
ee12b079 209:63e9c8f8b5d2 194 wait_ms(10);
ee12b079 235:c127b15409b2 195 RESET_TO_BAE = 0;
ee12b079 209:63e9c8f8b5d2 196 }
ee12b079 209:63e9c8f8b5d2 197
ee12b079 209:63e9c8f8b5d2 198 void RST_PL_BEE()
ee12b079 209:63e9c8f8b5d2 199 {
ee12b079 235:c127b15409b2 200 RESET_TO_PYLD = 1;
ee12b079 209:63e9c8f8b5d2 201 wait_ms(10);
ee12b079 235:c127b15409b2 202 RESET_TO_PYLD = 0;
ee12b079 235:c127b15409b2 203 }
ee12b079 235:c127b15409b2 204
ee12b079 235:c127b15409b2 205 void CDMS_INTERNAL_RESET()
ee12b079 235:c127b15409b2 206 {
ee12b079 235:c127b15409b2 207 NVIC_SystemReset();
ee12b079 235:c127b15409b2 208 }
ee12b079 235:c127b15409b2 209
ee12b079 235:c127b15409b2 210 void SYS_PWR_RESET() // Have to be decided with EPS team.
ee12b079 235:c127b15409b2 211 {
ee12b079 235:c127b15409b2 212
ee12b079 235:c127b15409b2 213 }
ee12b079 235:c127b15409b2 214
ee12b079 235:c127b15409b2 215 void EPS_V_A_EN() // This is a reset function
ee12b079 235:c127b15409b2 216 {
ee12b079 235:c127b15409b2 217 TRXY_PWR_CNTRL = 0;
ee12b079 235:c127b15409b2 218 TRZ_PWR_CNTRL = 0;
ee12b079 235:c127b15409b2 219 wait_ms(10);
ee12b079 235:c127b15409b2 220 TRXY_PWR_CNTRL = 1;
ee12b079 235:c127b15409b2 221 TRZ_PWR_CNTRL = 1;
ee12b079 235:c127b15409b2 222 }
ee12b079 235:c127b15409b2 223
ee12b079 235:c127b15409b2 224 void EPS_V_C_EN() // This is a reset function
ee12b079 235:c127b15409b2 225 {
ee12b079 235:c127b15409b2 226 COM_RX_CNTRL = 0;
ee12b079 235:c127b15409b2 227 wait_ms(10);
ee12b079 235:c127b15409b2 228 COM_RX_CNTRL = 1;
ee12b079 209:63e9c8f8b5d2 229 }
ee12b079 209:63e9c8f8b5d2 230
ee12b079 209:63e9c8f8b5d2 231 void RST_HK_COUNTER()
ee12b079 209:63e9c8f8b5d2 232 {
ee12b079 209:63e9c8f8b5d2 233 firstCount = true;
ee12b079 209:63e9c8f8b5d2 234 }
ee12b079 209:63e9c8f8b5d2 235
ee12b079 209:63e9c8f8b5d2 236 uint8_t CDMS_RD_SD_HK(uint8_t *sd_statusbits)
ee12b079 209:63e9c8f8b5d2 237 {
ee12b079 209:63e9c8f8b5d2 238 uint8_t p;
ee12b079 209:63e9c8f8b5d2 239 uint8_t ACK;
ee12b079 209:63e9c8f8b5d2 240 if(SD_SW_EN_DS != DEVICE_POWERED)
ee12b079 209:63e9c8f8b5d2 241 {
ee12b079 209:63e9c8f8b5d2 242 ACK = 0x89;
ee12b079 209:63e9c8f8b5d2 243 SD_RD_ERROR = 1;
ee12b079 209:63e9c8f8b5d2 244 //Generate TM
ee12b079 209:63e9c8f8b5d2 245 }
ee12b079 209:63e9c8f8b5d2 246 else
ee12b079 209:63e9c8f8b5d2 247 {
ee12b079 209:63e9c8f8b5d2 248 p = disk_read_statusbits(sd_statusbits);
ee12b079 209:63e9c8f8b5d2 249 if(p == 0)
ee12b079 209:63e9c8f8b5d2 250 ACK = 0xA0;
ee12b079 209:63e9c8f8b5d2 251 else
ee12b079 209:63e9c8f8b5d2 252 ACK = 0x89;
ee12b079 209:63e9c8f8b5d2 253 }
ee12b079 209:63e9c8f8b5d2 254 return ACK;
ee12b079 209:63e9c8f8b5d2 255 }
ee12b079 209:63e9c8f8b5d2 256
ee12b079 235:c127b15409b2 257 void CDMS_RD_RTC(uint64_t *time)
ee12b079 235:c127b15409b2 258 {
ee12b079 235:c127b15409b2 259 *time = FCTN_CDMS_RD_RTC();
ee12b079 235:c127b15409b2 260 }
ee12b079 235:c127b15409b2 261
ee12b079 235:c127b15409b2 262 void CDMS_CALIB_RTC()
ee12b079 235:c127b15409b2 263 {
ee12b079 235:c127b15409b2 264
ee12b079 235:c127b15409b2 265 }
ee12b079 235:c127b15409b2 266
chaithanyarss 224:3ac1f91e0ebc 267 void CDMS_RESET()
chaithanyarss 224:3ac1f91e0ebc 268 {
chaithanyarss 224:3ac1f91e0ebc 269 NVIC_SystemReset();
chaithanyarss 224:3ac1f91e0ebc 270 }
chaithanyarss 224:3ac1f91e0ebc 271
ee12b079 235:c127b15409b2 272 /*
ee12b079 235:c127b15409b2 273 //void CDMS_INTERNAL_RESET()
ee12b079 209:63e9c8f8b5d2 274 {
ee12b079 209:63e9c8f8b5d2 275
ee12b079 235:c127b15409b2 276 }
chaithanyarss 248:407ab7e337cd 277 */
chaithanyarss 248:407ab7e337cd 278
chaithanyarss 248:407ab7e337cd 279
chaithanyarss 248:407ab7e337cd 280 /*===================================================MMS Functions=================================================*/
chaithanyarss 248:407ab7e337cd 281
chaithanyarss 248:407ab7e337cd 282 void READ_RAM(uint8_t *);
chaithanyarss 248:407ab7e337cd 283 void WRITE_TO_FLASH();
chaithanyarss 248:407ab7e337cd 284 void READ_FLASH();
chaithanyarss 248:407ab7e337cd 285
chaithanyarss 248:407ab7e337cd 286 void READ_RAM(uint8_t *RAM)
chaithanyarss 248:407ab7e337cd 287 {
chaithanyarss 248:407ab7e337cd 288
chaithanyarss 248:407ab7e337cd 289 }