working version

Dependencies:   mbed mbed-rtos SimpleDMA FreescaleIAP eeprom

Fork of CDMS_CODE_FM_28JAN2017 by samp Srinivasan

Committer:
chaithanyarss
Date:
Mon Jul 11 14:33:02 2016 +0000
Revision:
255:642ea552ac77
Parent:
245:da9d1bd999da
Child:
256:0f9aeeaf5a1d
Integration and Testing is in progress

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ee12b079 209:63e9c8f8b5d2 1
chaithanyarss 255:642ea552ac77 2 /*===================================================FMS Functions=================================================*/
ee12b079 245:da9d1bd999da 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 245:da9d1bd999da 10
ee12b079 245:da9d1bd999da 11 // Switch ON/OFF functions
ee12b079 209:63e9c8f8b5d2 12 void CDMS_SD_SW_ON();
ee12b079 209:63e9c8f8b5d2 13 void CDMS_SD_SW_OFF();
ee12b079 245:da9d1bd999da 14 void CDMS_RTC_ON();
ee12b079 245:da9d1bd999da 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 245:da9d1bd999da 24
ee12b079 245:da9d1bd999da 25 // RST functions
ee12b079 209:63e9c8f8b5d2 26 void RST_SD();
ee12b079 245:da9d1bd999da 27 void SW_RST_BAE();
ee12b079 245:da9d1bd999da 28 void SW_RST_PL_BEE();
ee12b079 209:63e9c8f8b5d2 29 void RST_BAE();
ee12b079 209:63e9c8f8b5d2 30 void RST_PL_BEE();
chaithanyarss 255:642ea552ac77 31 void CDMS_RESET();
ee12b079 245:da9d1bd999da 32 void SYS_PWR_RESET(); // Have to be decided with EPS team.
ee12b079 245:da9d1bd999da 33 void EPS_V_A_EN();
ee12b079 245:da9d1bd999da 34 void EPS_V_C_EN();
ee12b079 245:da9d1bd999da 35
ee12b079 209:63e9c8f8b5d2 36 void RST_HK_COUNTER();
ee12b079 209:63e9c8f8b5d2 37 uint8_t CDMS_RD_SD_HK(uint8_t *);
ee12b079 245:da9d1bd999da 38 void CDMS_RD_RTC(uint64_t *);
ee12b079 245:da9d1bd999da 39 void CDMS_CALIB_RTC();
chaithanyarss 255:642ea552ac77 40 void TOTAL_RESET_WITH_CDMS();
ee12b079 245:da9d1bd999da 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 255:642ea552ac77 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 245:da9d1bd999da 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 245:da9d1bd999da 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 245:da9d1bd999da 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 245:da9d1bd999da 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 245:da9d1bd999da 80 SD_SW_EN_DS = 1;
ee12b079 209:63e9c8f8b5d2 81 }
ee12b079 209:63e9c8f8b5d2 82
ee12b079 245:da9d1bd999da 83 void CDMS_RTC_ON()
ee12b079 209:63e9c8f8b5d2 84 {
chaithanyarss 255:642ea552ac77 85 //FCTN_CDMS_INIT_RTC();
chaithanyarss 255:642ea552ac77 86 SPI_mutex.lock();
chaithanyarss 255:642ea552ac77 87 gCS_RTC=1;
chaithanyarss 255:642ea552ac77 88 gCS_RTC=0;
chaithanyarss 255:642ea552ac77 89 spi.write(0x81); //register address with write flag
chaithanyarss 255:642ea552ac77 90 spi.write(0x00);//disabling stop bit in the seconds register
chaithanyarss 255:642ea552ac77 91 SPI_mutex.unlock();
ee12b079 209:63e9c8f8b5d2 92 }
ee12b079 209:63e9c8f8b5d2 93
ee12b079 245:da9d1bd999da 94 void CDMS_RTC_OFF()
ee12b079 209:63e9c8f8b5d2 95 {
chaithanyarss 255:642ea552ac77 96 SPI_mutex.lock();
chaithanyarss 255:642ea552ac77 97 gCS_RTC=1;
chaithanyarss 255:642ea552ac77 98 gCS_RTC=0;
chaithanyarss 255:642ea552ac77 99 spi.write(0x81); //register address with write flag
chaithanyarss 255:642ea552ac77 100 spi.write(0x80);//enabling stop bit in the seconds register
chaithanyarss 255:642ea552ac77 101 SPI_mutex.unlock();
ee12b079 209:63e9c8f8b5d2 102 }
ee12b079 209:63e9c8f8b5d2 103
ee12b079 245:da9d1bd999da 104 void SW_ON_BAE()
ee12b079 245:da9d1bd999da 105 {
ee12b079 245:da9d1bd999da 106 BAE_SW_EN_DS = 0;
ee12b079 245:da9d1bd999da 107 }
ee12b079 245:da9d1bd999da 108
ee12b079 245:da9d1bd999da 109 void SW_OFF_BAE()
ee12b079 245:da9d1bd999da 110 {
ee12b079 245:da9d1bd999da 111 BAE_SW_EN_DS = 1;
ee12b079 245:da9d1bd999da 112 }
ee12b079 245:da9d1bd999da 113
ee12b079 245:da9d1bd999da 114 void SW_ON_PL_BEE()
ee12b079 245:da9d1bd999da 115 {
ee12b079 245:da9d1bd999da 116 PYLD_DFF_CLK = 0;\
ee12b079 245:da9d1bd999da 117 PYLD_DFF = 1;\
ee12b079 245:da9d1bd999da 118 wait_us(1);\
ee12b079 245:da9d1bd999da 119 PYLD_DFF_CLK = 1;\
ee12b079 245:da9d1bd999da 120 wait_us(1);\
ee12b079 245:da9d1bd999da 121 PYLD_DFF_CLK = 0;\
ee12b079 245:da9d1bd999da 122 wait_us(1);\
ee12b079 245:da9d1bd999da 123 }
ee12b079 245:da9d1bd999da 124
ee12b079 245:da9d1bd999da 125 void SW_OFF_PL_BEE()
ee12b079 245:da9d1bd999da 126 {
ee12b079 245:da9d1bd999da 127 PYLD_DFF_CLK = 0;
ee12b079 245:da9d1bd999da 128 PYLD_DFF = 0;
ee12b079 245:da9d1bd999da 129 wait_us(1);
ee12b079 245:da9d1bd999da 130 PYLD_DFF_CLK = 1;
ee12b079 245:da9d1bd999da 131 wait_us(1);
ee12b079 245:da9d1bd999da 132 PYLD_DFF_CLK = 0;
ee12b079 245:da9d1bd999da 133 wait_us(1);
ee12b079 245:da9d1bd999da 134 }
ee12b079 245:da9d1bd999da 135
ee12b079 245:da9d1bd999da 136 void SW_ON_PL_EPS()
ee12b079 245:da9d1bd999da 137 {
ee12b079 245:da9d1bd999da 138 PYLD_EPS_DFF_PWR_CLK = 0;\
ee12b079 245:da9d1bd999da 139 PYLD_EPS_DFF_PWR = 1;\
ee12b079 245:da9d1bd999da 140 wait_us(1);\
ee12b079 245:da9d1bd999da 141 PYLD_EPS_DFF_PWR_CLK = 1;\
ee12b079 245:da9d1bd999da 142 wait_us(1);\
ee12b079 245:da9d1bd999da 143 PYLD_EPS_DFF_PWR_CLK = 0;\
ee12b079 245:da9d1bd999da 144 wait_us(1);\
ee12b079 245:da9d1bd999da 145 }
ee12b079 245:da9d1bd999da 146
ee12b079 209:63e9c8f8b5d2 147 void SW_OFF_PL_EPS()
ee12b079 209:63e9c8f8b5d2 148 {
ee12b079 245:da9d1bd999da 149 PYLD_EPS_DFF_PWR_CLK = 0;\
ee12b079 245:da9d1bd999da 150 PYLD_EPS_DFF_PWR = 0;\
ee12b079 245:da9d1bd999da 151 wait_us(1);\
ee12b079 245:da9d1bd999da 152 PYLD_EPS_DFF_PWR_CLK = 1;\
ee12b079 245:da9d1bd999da 153 wait_us(1);\
ee12b079 245:da9d1bd999da 154 PYLD_EPS_DFF_PWR_CLK = 0;\
ee12b079 245:da9d1bd999da 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 {
chaithanyarss 255:642ea552ac77 160 V_A_EN = 1;
ee12b079 209:63e9c8f8b5d2 161 }
ee12b079 209:63e9c8f8b5d2 162
ee12b079 209:63e9c8f8b5d2 163 void SW_OFF_V_A_EN()
ee12b079 209:63e9c8f8b5d2 164 {
chaithanyarss 255:642ea552ac77 165 V_A_EN = 0;
ee12b079 209:63e9c8f8b5d2 166 }
ee12b079 209:63e9c8f8b5d2 167
ee12b079 209:63e9c8f8b5d2 168 void RST_SD()
ee12b079 209:63e9c8f8b5d2 169 {
ee12b079 245:da9d1bd999da 170 SD_SW_EN_DS = 1;
ee12b079 209:63e9c8f8b5d2 171 wait_ms(10);
ee12b079 209:63e9c8f8b5d2 172 SD_SW_EN_DS = 0;
ee12b079 245:da9d1bd999da 173 }
ee12b079 245:da9d1bd999da 174
ee12b079 245:da9d1bd999da 175 void SW_RST_BAE()
ee12b079 245:da9d1bd999da 176 {
ee12b079 245:da9d1bd999da 177 BAE_SW_EN_DS = 1;
ee12b079 245:da9d1bd999da 178 wait_ms(10);
ee12b079 245:da9d1bd999da 179 BAE_SW_EN_DS = 0;
ee12b079 245:da9d1bd999da 180 }
ee12b079 245:da9d1bd999da 181
ee12b079 245:da9d1bd999da 182 void SW_RST_PL_BEE()
ee12b079 245:da9d1bd999da 183 {
ee12b079 245:da9d1bd999da 184 PYLD_DFF = 1;
ee12b079 245:da9d1bd999da 185 wait_ms(10);
ee12b079 245:da9d1bd999da 186 PYLD_DFF = 0;
ee12b079 209:63e9c8f8b5d2 187 }
ee12b079 209:63e9c8f8b5d2 188
ee12b079 209:63e9c8f8b5d2 189 void RST_BAE()
ee12b079 209:63e9c8f8b5d2 190 {
ee12b079 245:da9d1bd999da 191 RESET_TO_BAE = 1;
ee12b079 209:63e9c8f8b5d2 192 wait_ms(10);
ee12b079 245:da9d1bd999da 193 RESET_TO_BAE = 0;
ee12b079 209:63e9c8f8b5d2 194 }
ee12b079 209:63e9c8f8b5d2 195
ee12b079 209:63e9c8f8b5d2 196 void RST_PL_BEE()
ee12b079 209:63e9c8f8b5d2 197 {
ee12b079 245:da9d1bd999da 198 RESET_TO_PYLD = 1;
ee12b079 209:63e9c8f8b5d2 199 wait_ms(10);
ee12b079 245:da9d1bd999da 200 RESET_TO_PYLD = 0;
ee12b079 245:da9d1bd999da 201 }
ee12b079 245:da9d1bd999da 202
ee12b079 245:da9d1bd999da 203 void CDMS_INTERNAL_RESET()
ee12b079 245:da9d1bd999da 204 {
ee12b079 245:da9d1bd999da 205 NVIC_SystemReset();
ee12b079 245:da9d1bd999da 206 }
ee12b079 245:da9d1bd999da 207
ee12b079 245:da9d1bd999da 208 void SYS_PWR_RESET() // Have to be decided with EPS team.
ee12b079 245:da9d1bd999da 209 {
chaithanyarss 255:642ea552ac77 210 /*sys_pwr_rst = 0;
chaithanyarss 255:642ea552ac77 211 wait_ms(10);
chaithanyarss 255:642ea552ac77 212 sys_pwr_rst = 1;*/
ee12b079 245:da9d1bd999da 213 }
ee12b079 245:da9d1bd999da 214
ee12b079 245:da9d1bd999da 215 void EPS_V_A_EN() // This is a reset function
ee12b079 245:da9d1bd999da 216 {
chaithanyarss 255:642ea552ac77 217 V_A_EN = 0;
ee12b079 245:da9d1bd999da 218 wait_ms(10);
chaithanyarss 255:642ea552ac77 219 V_A_EN = 1;
ee12b079 245:da9d1bd999da 220 }
ee12b079 245:da9d1bd999da 221
ee12b079 245:da9d1bd999da 222 void EPS_V_C_EN() // This is a reset function
ee12b079 245:da9d1bd999da 223 {
ee12b079 245:da9d1bd999da 224 COM_RX_CNTRL = 0;
ee12b079 245:da9d1bd999da 225 wait_ms(10);
ee12b079 245:da9d1bd999da 226 COM_RX_CNTRL = 1;
ee12b079 209:63e9c8f8b5d2 227 }
ee12b079 209:63e9c8f8b5d2 228
ee12b079 209:63e9c8f8b5d2 229 void RST_HK_COUNTER()
ee12b079 209:63e9c8f8b5d2 230 {
ee12b079 209:63e9c8f8b5d2 231 firstCount = true;
ee12b079 209:63e9c8f8b5d2 232 }
ee12b079 209:63e9c8f8b5d2 233
ee12b079 209:63e9c8f8b5d2 234 uint8_t CDMS_RD_SD_HK(uint8_t *sd_statusbits)
ee12b079 209:63e9c8f8b5d2 235 {
ee12b079 209:63e9c8f8b5d2 236 uint8_t p;
ee12b079 209:63e9c8f8b5d2 237 uint8_t ACK;
ee12b079 209:63e9c8f8b5d2 238 if(SD_SW_EN_DS != DEVICE_POWERED)
ee12b079 209:63e9c8f8b5d2 239 {
ee12b079 209:63e9c8f8b5d2 240 ACK = 0x89;
ee12b079 209:63e9c8f8b5d2 241 SD_RD_ERROR = 1;
ee12b079 209:63e9c8f8b5d2 242 //Generate TM
ee12b079 209:63e9c8f8b5d2 243 }
ee12b079 209:63e9c8f8b5d2 244 else
ee12b079 209:63e9c8f8b5d2 245 {
ee12b079 209:63e9c8f8b5d2 246 p = disk_read_statusbits(sd_statusbits);
ee12b079 209:63e9c8f8b5d2 247 if(p == 0)
ee12b079 209:63e9c8f8b5d2 248 ACK = 0xA0;
ee12b079 209:63e9c8f8b5d2 249 else
ee12b079 209:63e9c8f8b5d2 250 ACK = 0x89;
ee12b079 209:63e9c8f8b5d2 251 }
ee12b079 209:63e9c8f8b5d2 252 return ACK;
ee12b079 209:63e9c8f8b5d2 253 }
ee12b079 209:63e9c8f8b5d2 254
ee12b079 245:da9d1bd999da 255 void CDMS_RD_RTC(uint64_t *time)
ee12b079 245:da9d1bd999da 256 {
ee12b079 245:da9d1bd999da 257 *time = FCTN_CDMS_RD_RTC();
ee12b079 245:da9d1bd999da 258 }
ee12b079 245:da9d1bd999da 259
ee12b079 245:da9d1bd999da 260 void CDMS_CALIB_RTC()
ee12b079 245:da9d1bd999da 261 {
ee12b079 245:da9d1bd999da 262
ee12b079 245:da9d1bd999da 263 }
ee12b079 245:da9d1bd999da 264
chaithanyarss 224:3ac1f91e0ebc 265 void CDMS_RESET()
chaithanyarss 224:3ac1f91e0ebc 266 {
chaithanyarss 224:3ac1f91e0ebc 267 NVIC_SystemReset();
chaithanyarss 224:3ac1f91e0ebc 268 }
chaithanyarss 224:3ac1f91e0ebc 269
ee12b079 245:da9d1bd999da 270 /*
ee12b079 245:da9d1bd999da 271 //void CDMS_INTERNAL_RESET()
ee12b079 209:63e9c8f8b5d2 272 {
ee12b079 209:63e9c8f8b5d2 273
ee12b079 245:da9d1bd999da 274 }
chaithanyarss 255:642ea552ac77 275 */