working version

Dependencies:   mbed mbed-rtos SimpleDMA FreescaleIAP eeprom

Fork of CDMS_CODE_FM_28JAN2017 by samp Srinivasan

Committer:
chaithanyarss
Date:
Wed Jul 06 07:24:28 2016 +0000
Revision:
230:3d52da8826d3
Parent:
229:42624b9a08b4
BAE HK data is collected successfully through I2C

Who changed what in which revision?

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