![](/media/cache/group/nine_tails_kurama_by_zubair43-d4zyf5s.jpg.50x50_q85.jpg)
ACS completed fully. All cases to be tested
Dependencies: FreescaleIAP mbed-rtos mbed
Fork of ACS_Flowchart_BAE by
main.cpp@12:af1d7e18b868, 2016-04-13 (annotated)
- Committer:
- Bragadeesh153
- Date:
- Wed Apr 13 18:34:28 2016 +0000
- Revision:
- 12:af1d7e18b868
- Parent:
- 9:194afacf7449
- Child:
- 13:fb7facaf308b
Working
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sakthipriya | 0:7b4c00e3912f | 1 | #include "mbed.h" |
sakthipriya | 0:7b4c00e3912f | 2 | #include "rtos.h" |
sakthipriya | 0:7b4c00e3912f | 3 | #include "pin_config.h" |
sakthipriya | 0:7b4c00e3912f | 4 | #include "ACS.h" |
sakthipriya | 0:7b4c00e3912f | 5 | #include "EPS.h" |
sakthipriya | 0:7b4c00e3912f | 6 | #include "BCN.h" |
sakthipriya | 0:7b4c00e3912f | 7 | #include "TCTM.h" |
sakthipriya | 0:7b4c00e3912f | 8 | |
sakthipriya | 0:7b4c00e3912f | 9 | #define tm_len 134 |
sakthipriya | 0:7b4c00e3912f | 10 | #define tc_len 135 |
sakthipriya | 0:7b4c00e3912f | 11 | #define batt_heat_low 20 |
sakthipriya | 9:194afacf7449 | 12 | |
sakthipriya | 0:7b4c00e3912f | 13 | //***************************************************** flags *************************************************************// |
sakthipriya | 0:7b4c00e3912f | 14 | uint32_t BAE_STATUS = 0x00000000; |
sakthipriya | 0:7b4c00e3912f | 15 | uint32_t BAE_ENABLE = 0xFFFFFFFF; |
sakthipriya | 0:7b4c00e3912f | 16 | |
sakthipriya | 5:bb592f3185cc | 17 | //i2c// |
sakthipriya | 5:bb592f3185cc | 18 | char data_send_flag = 'h'; |
sakthipriya | 5:bb592f3185cc | 19 | |
sakthipriya | 0:7b4c00e3912f | 20 | //.........acs...............// |
sakthipriya | 9:194afacf7449 | 21 | /* char ACS_INIT_STATUS = 'q'; |
sakthipriya | 0:7b4c00e3912f | 22 | char ACS_DATA_ACQ_STATUS = 'q'; |
sakthipriya | 0:7b4c00e3912f | 23 | char ACS_ATS_STATUS = 'q'; |
sakthipriya | 0:7b4c00e3912f | 24 | char ACS_MAIN_STATUS = 'q'; |
sakthipriya | 0:7b4c00e3912f | 25 | char ACS_STATUS = 'q'; |
sakthipriya | 0:7b4c00e3912f | 26 | |
sakthipriya | 0:7b4c00e3912f | 27 | char ACS_ATS_ENABLE = 'q'; |
sakthipriya | 0:7b4c00e3912f | 28 | char ACS_DATA_ACQ_ENABLE = 'q'; |
sakthipriya | 9:194afacf7449 | 29 | char ACS_STATE = 'q';*/ |
sakthipriya | 9:194afacf7449 | 30 | |
sakthipriya | 9:194afacf7449 | 31 | uint8_t ACS_INIT_STATUS = 0; |
sakthipriya | 9:194afacf7449 | 32 | uint8_t ACS_DATA_ACQ_STATUS = 0; |
sakthipriya | 9:194afacf7449 | 33 | uint8_t ACS_ATS_STATUS = 0; |
sakthipriya | 9:194afacf7449 | 34 | uint8_t ACS_MAIN_STATUS = 0; |
sakthipriya | 9:194afacf7449 | 35 | uint8_t ACS_STATUS = 0; |
sakthipriya | 9:194afacf7449 | 36 | |
sakthipriya | 9:194afacf7449 | 37 | uint8_t ACS_ATS_ENABLE = 1; |
sakthipriya | 9:194afacf7449 | 38 | uint8_t ACS_DATA_ACQ_ENABLE = 1; |
sakthipriya | 9:194afacf7449 | 39 | uint8_t ACS_STATE = 4; |
sakthipriya | 0:7b4c00e3912f | 40 | |
sakthipriya | 0:7b4c00e3912f | 41 | //.....................eps...................// |
sakthipriya | 0:7b4c00e3912f | 42 | //eps init |
sakthipriya | 9:194afacf7449 | 43 | /*char EPS_INIT_STATUS = 'q'; |
sakthipriya | 0:7b4c00e3912f | 44 | char EPS_BATTERY_GAUGE_STATUS = 'q'; |
sakthipriya | 0:7b4c00e3912f | 45 | //eps main |
sakthipriya | 0:7b4c00e3912f | 46 | char EPS_MAIN_STATUS = 'q'; |
sakthipriya | 0:7b4c00e3912f | 47 | char EPS_BATTERY_TEMP_STATUS = 'q'; |
sakthipriya | 0:7b4c00e3912f | 48 | char EPS_STATUS = 'q'; |
sakthipriya | 0:7b4c00e3912f | 49 | |
sakthipriya | 0:7b4c00e3912f | 50 | char EPS_BATTERY_HEAT_ENABLE = 'q'; |
sakthipriya | 9:194afacf7449 | 51 | */ |
sakthipriya | 9:194afacf7449 | 52 | |
sakthipriya | 9:194afacf7449 | 53 | uint8_t EPS_INIT_STATUS = 0; |
sakthipriya | 9:194afacf7449 | 54 | uint8_t EPS_BATTERY_GAUGE_STATUS = 0; |
sakthipriya | 9:194afacf7449 | 55 | //eps main |
sakthipriya | 9:194afacf7449 | 56 | uint8_t EPS_MAIN_STATUS = 0; |
sakthipriya | 9:194afacf7449 | 57 | uint8_t EPS_BATTERY_TEMP_STATUS = 0; |
sakthipriya | 9:194afacf7449 | 58 | uint8_t EPS_STATUS = 7; //invalid status |
sakthipriya | 9:194afacf7449 | 59 | |
sakthipriya | 9:194afacf7449 | 60 | uint8_t EPS_BATTERY_HEAT_ENABLE = 0; |
sakthipriya | 0:7b4c00e3912f | 61 | |
sakthipriya | 0:7b4c00e3912f | 62 | //.......................global variables..................................................................// new hk structure- everything has to changed based on this |
sakthipriya | 6:036d08b62785 | 63 | uint8_t BAE_data[74]; |
sakthipriya | 6:036d08b62785 | 64 | char BAE_chardata[74]; |
sakthipriya | 0:7b4c00e3912f | 65 | |
sakthipriya | 0:7b4c00e3912f | 66 | |
sakthipriya | 0:7b4c00e3912f | 67 | //*************************************Global declarations************************************************// |
sakthipriya | 0:7b4c00e3912f | 68 | const int addr = 0x20; //slave address |
sakthipriya | 0:7b4c00e3912f | 69 | |
sakthipriya | 0:7b4c00e3912f | 70 | Timer t_rfsilence; |
sakthipriya | 0:7b4c00e3912f | 71 | Timer t_start; |
sakthipriya | 7:a46a1dee4497 | 72 | Timer t_tc; |
sakthipriya | 7:a46a1dee4497 | 73 | Timer t_tm; |
sakthipriya | 0:7b4c00e3912f | 74 | Serial pc(USBTX, USBRX); |
sakthipriya | 0:7b4c00e3912f | 75 | int power_flag_dummy=2; |
sakthipriya | 0:7b4c00e3912f | 76 | float data[6]; |
sakthipriya | 0:7b4c00e3912f | 77 | |
sakthipriya | 0:7b4c00e3912f | 78 | extern float moment[3]; |
sakthipriya | 0:7b4c00e3912f | 79 | extern uint8_t BCN_FEN; |
sakthipriya | 1:446a959e36ce | 80 | extern BAE_HK_actual actual_data; |
sakthipriya | 1:446a959e36ce | 81 | extern BAE_HK_quant quant_data; |
sakthipriya | 1:446a959e36ce | 82 | extern BAE_HK_min_max bae_HK_minmax; |
sakthipriya | 1:446a959e36ce | 83 | extern BAE_HK_arch arch_data; |
sakthipriya | 0:7b4c00e3912f | 84 | |
sakthipriya | 5:bb592f3185cc | 85 | int write_ack = 1; |
sakthipriya | 5:bb592f3185cc | 86 | int read_ack = 1; |
sakthipriya | 0:7b4c00e3912f | 87 | char telecommand[tc_len]; |
sakthipriya | 3:07e15677a75c | 88 | char* telemetry; |
sakthipriya | 5:bb592f3185cc | 89 | |
sakthipriya | 5:bb592f3185cc | 90 | bool pf1check = 0; |
sakthipriya | 5:bb592f3185cc | 91 | bool pf2check = 0; |
sakthipriya | 5:bb592f3185cc | 92 | bool if1check = 0; |
sakthipriya | 5:bb592f3185cc | 93 | bool if2check = 1; |
sakthipriya | 0:7b4c00e3912f | 94 | |
sakthipriya | 0:7b4c00e3912f | 95 | //*****************************************************Assigning pins******************************************************// |
sakthipriya | 9:194afacf7449 | 96 | DigitalOut ATS1_SW_ENABLE(PTC0); // enable of att sens2 switch |
sakthipriya | 9:194afacf7449 | 97 | DigitalOut ATS2_SW_ENABLE(PTC16); // enable of att sens switch |
sakthipriya | 0:7b4c00e3912f | 98 | InterruptIn irpt_4m_mstr(PIN38); //I2c interrupt from CDMS |
sakthipriya | 0:7b4c00e3912f | 99 | DigitalOut irpt_2_mstr(PIN4); //I2C interrupt to CDMS |
sakthipriya | 0:7b4c00e3912f | 100 | I2CSlave slave (PIN1,PIN2); |
sakthipriya | 0:7b4c00e3912f | 101 | DigitalOut batt_heat(PIN96); |
sakthipriya | 0:7b4c00e3912f | 102 | |
sakthipriya | 9:194afacf7449 | 103 | //ATS1_SW_ENABLE = 0; |
sakthipriya | 0:7b4c00e3912f | 104 | PwmOut PWM1(PIN93); //x //Functions used to generate PWM signal |
sakthipriya | 0:7b4c00e3912f | 105 | PwmOut PWM2(PIN94); //y |
sakthipriya | 0:7b4c00e3912f | 106 | PwmOut PWM3(PIN95); //z //PWM output comes from pins p6 |
sakthipriya | 0:7b4c00e3912f | 107 | |
sakthipriya | 5:bb592f3185cc | 108 | //........faults |
sakthipriya | 5:bb592f3185cc | 109 | //Polled Faults |
sakthipriya | 5:bb592f3185cc | 110 | DigitalIn pf1(PIN5);//Attitude Sensor 1 OC bar fault signal |
sakthipriya | 5:bb592f3185cc | 111 | DigitalIn pf2(PIN97);//Attitude Sensor 2 OC bar fault signal |
sakthipriya | 5:bb592f3185cc | 112 | DigitalIn pf3(PIN83);//Fault Bar for TRXY driver |
sakthipriya | 5:bb592f3185cc | 113 | |
sakthipriya | 5:bb592f3185cc | 114 | //Interrupt based faults |
sakthipriya | 9:194afacf7449 | 115 | InterruptIn ir1(PIN73);//Battery Gauge - Alert Bar Signal |
sakthipriya | 5:bb592f3185cc | 116 | InterruptIn ir2(PIN72);//TRXY Driver TR switch Fault |
sakthipriya | 5:bb592f3185cc | 117 | InterruptIn ir3(PIN89);//TRZ Driver Fault Bar |
sakthipriya | 5:bb592f3185cc | 118 | InterruptIn ir4(PIN91);//TRZ Driver TR switch Fault |
sakthipriya | 5:bb592f3185cc | 119 | InterruptIn ir5(PIN79);//CDMS - Switch Fault |
sakthipriya | 5:bb592f3185cc | 120 | InterruptIn ir6(PIN80);//Beacon- Switch OC bar |
sakthipriya | 5:bb592f3185cc | 121 | InterruptIn ir7(PIN42);//Charger IC - Fault Bar |
sakthipriya | 5:bb592f3185cc | 122 | |
sakthipriya | 9:194afacf7449 | 123 | DigitalOut TRXY_SW_EN(PIN71); //TR XY Switch |
sakthipriya | 5:bb592f3185cc | 124 | DigitalOut DRV_Z_SLP(PIN88); //Sleep pin of driver z |
sakthipriya | 5:bb592f3185cc | 125 | DigitalOut TRZ_SW(PIN40); //TR Z Switch |
sakthipriya | 5:bb592f3185cc | 126 | DigitalOut CDMS_RESET(PIN7); // CDMS RESET |
sakthipriya | 5:bb592f3185cc | 127 | DigitalOut BCN_SW(PIN14); //Beacon switch |
sakthipriya | 5:bb592f3185cc | 128 | DigitalOut DRV_XY_SLP(PIN82); |
sakthipriya | 5:bb592f3185cc | 129 | |
sakthipriya | 5:bb592f3185cc | 130 | |
sakthipriya | 5:bb592f3185cc | 131 | |
sakthipriya | 0:7b4c00e3912f | 132 | |
sakthipriya | 0:7b4c00e3912f | 133 | /*****************************************************************Threads USed***********************************************************************************/ |
sakthipriya | 3:07e15677a75c | 134 | |
sakthipriya | 0:7b4c00e3912f | 135 | Thread *ptr_t_i2c; |
sakthipriya | 0:7b4c00e3912f | 136 | |
sakthipriya | 0:7b4c00e3912f | 137 | /*********************************************************FCTN HEADERS***********************************************************************************/ |
sakthipriya | 0:7b4c00e3912f | 138 | |
sakthipriya | 0:7b4c00e3912f | 139 | void FCTN_ISR_I2C(); |
sakthipriya | 0:7b4c00e3912f | 140 | void FCTN_TM(); |
sakthipriya | 3:07e15677a75c | 141 | void F_ACS(); |
sakthipriya | 3:07e15677a75c | 142 | void F_EPS(); |
sakthipriya | 3:07e15677a75c | 143 | void F_BCN(); |
sakthipriya | 0:7b4c00e3912f | 144 | |
sakthipriya | 0:7b4c00e3912f | 145 | //*******************************************ACS THREAD**************************************************// |
sakthipriya | 5:bb592f3185cc | 146 | uint8_t iterP1; |
sakthipriya | 5:bb592f3185cc | 147 | uint8_t iterP2; |
sakthipriya | 5:bb592f3185cc | 148 | uint8_t iterI1; |
sakthipriya | 5:bb592f3185cc | 149 | uint8_t iterI2; |
sakthipriya | 0:7b4c00e3912f | 150 | |
sakthipriya | 5:bb592f3185cc | 151 | |
sakthipriya | 3:07e15677a75c | 152 | void F_ACS() |
sakthipriya | 0:7b4c00e3912f | 153 | { |
sakthipriya | 8:82250e41da81 | 154 | |
sakthipriya | 9:194afacf7449 | 155 | |
sakthipriya | 8:82250e41da81 | 156 | //...................// |
sakthipriya | 8:82250e41da81 | 157 | |
sakthipriya | 5:bb592f3185cc | 158 | if(pf1check == 1) |
sakthipriya | 5:bb592f3185cc | 159 | { |
sakthipriya | 5:bb592f3185cc | 160 | if(iterP1 >= 3) |
sakthipriya | 5:bb592f3185cc | 161 | { |
sakthipriya | 9:194afacf7449 | 162 | ATS1_SW_ENABLE = 1; // turn off ats1 permanently |
sakthipriya | 5:bb592f3185cc | 163 | //FCTN_SWITCH_ATS(0); // switch on ATS2 |
sakthipriya | 5:bb592f3185cc | 164 | } |
sakthipriya | 5:bb592f3185cc | 165 | else |
sakthipriya | 5:bb592f3185cc | 166 | { |
sakthipriya | 9:194afacf7449 | 167 | ATS1_SW_ENABLE = 0; |
sakthipriya | 5:bb592f3185cc | 168 | iterP1++; |
sakthipriya | 5:bb592f3185cc | 169 | } |
sakthipriya | 9:194afacf7449 | 170 | pf1check = 0; |
sakthipriya | 5:bb592f3185cc | 171 | } |
sakthipriya | 5:bb592f3185cc | 172 | if(pf2check == 1) |
sakthipriya | 5:bb592f3185cc | 173 | { |
sakthipriya | 5:bb592f3185cc | 174 | if(iterP1 >= 3) |
sakthipriya | 5:bb592f3185cc | 175 | { |
sakthipriya | 9:194afacf7449 | 176 | ATS2_SW_ENABLE = 1; // turn off ats2 permanently |
sakthipriya | 9:194afacf7449 | 177 | ACS_DATA_ACQ_ENABLE == 0; |
sakthipriya | 9:194afacf7449 | 178 | ACS_STATE == 2 ; // check ACS_STATE = ACS_ZAXIS_MOMENT_ONLY |
sakthipriya | 5:bb592f3185cc | 179 | } |
sakthipriya | 5:bb592f3185cc | 180 | else |
sakthipriya | 5:bb592f3185cc | 181 | { |
sakthipriya | 9:194afacf7449 | 182 | ATS2_SW_ENABLE = 0; |
sakthipriya | 5:bb592f3185cc | 183 | iterP2++; |
sakthipriya | 5:bb592f3185cc | 184 | } |
sakthipriya | 9:194afacf7449 | 185 | pf2check = 0; |
sakthipriya | 5:bb592f3185cc | 186 | } |
sakthipriya | 5:bb592f3185cc | 187 | if(if1check == 1) |
sakthipriya | 5:bb592f3185cc | 188 | { |
sakthipriya | 5:bb592f3185cc | 189 | if(iterI1 >= 3) |
sakthipriya | 5:bb592f3185cc | 190 | { |
sakthipriya | 9:194afacf7449 | 191 | TRXY_SW_EN = 0; // turn off TRXY permanently |
sakthipriya | 5:bb592f3185cc | 192 | } |
sakthipriya | 5:bb592f3185cc | 193 | else |
sakthipriya | 5:bb592f3185cc | 194 | { |
sakthipriya | 9:194afacf7449 | 195 | TRXY_SW_EN = 1; //switch on TRXY |
sakthipriya | 5:bb592f3185cc | 196 | iterI1++; |
sakthipriya | 5:bb592f3185cc | 197 | } |
sakthipriya | 5:bb592f3185cc | 198 | } |
sakthipriya | 5:bb592f3185cc | 199 | if(if2check == 1) |
sakthipriya | 5:bb592f3185cc | 200 | { |
sakthipriya | 5:bb592f3185cc | 201 | if(iterI2 >= 3) |
sakthipriya | 5:bb592f3185cc | 202 | { |
sakthipriya | 5:bb592f3185cc | 203 | TRZ_SW = 0; // turn off TRZ permanently |
sakthipriya | 9:194afacf7449 | 204 | ACS_STATE == 2 ; // check ACS_STATE = ACS_ZAXIS_MOMENT_ONLY |
sakthipriya | 5:bb592f3185cc | 205 | } |
sakthipriya | 5:bb592f3185cc | 206 | else |
sakthipriya | 5:bb592f3185cc | 207 | { |
sakthipriya | 5:bb592f3185cc | 208 | TRZ_SW = 1; //switch on Z |
sakthipriya | 5:bb592f3185cc | 209 | iterI2++; |
sakthipriya | 5:bb592f3185cc | 210 | } |
sakthipriya | 5:bb592f3185cc | 211 | } |
sakthipriya | 5:bb592f3185cc | 212 | |
sakthipriya | 6:036d08b62785 | 213 | //float b1[3]={-23.376,-37.56,14.739}, omega1[3]={-1.52,2.746,0.7629}, moment1[3]= {1.0498,-1.0535,1.3246}; |
sakthipriya | 0:7b4c00e3912f | 214 | //b1[3] = {22, 22,10}; |
sakthipriya | 0:7b4c00e3912f | 215 | //omega1[3] = {2.1,3.0,1.5}; |
sakthipriya | 9:194afacf7449 | 216 | // ATS1_SW_ENABLE = 0; // att sens2 switch is disabled |
sakthipriya | 9:194afacf7449 | 217 | // ATS2_SW_ENABLE = 0; // att sens switch is disabled |
sakthipriya | 0:7b4c00e3912f | 218 | |
sakthipriya | 3:07e15677a75c | 219 | |
sakthipriya | 0:7b4c00e3912f | 220 | |
sakthipriya | 3:07e15677a75c | 221 | //Thread::signal_wait(0x1); |
sakthipriya | 9:194afacf7449 | 222 | ACS_MAIN_STATUS = 1; //set ACS_MAIN_STATUS flag |
sakthipriya | 0:7b4c00e3912f | 223 | PWM1 = 0; //clear pwm pins |
sakthipriya | 0:7b4c00e3912f | 224 | PWM2 = 0; //clear pwm pins |
sakthipriya | 0:7b4c00e3912f | 225 | PWM3 = 0; //clear pwm pins |
sakthipriya | 0:7b4c00e3912f | 226 | pc.printf("\n\rEntered ACS %f\n",t_start.read()); |
sakthipriya | 0:7b4c00e3912f | 227 | |
sakthipriya | 9:194afacf7449 | 228 | if(ACS_DATA_ACQ_ENABLE == 1)// check if ACS_DATA_ACQ_ENABLE = 1? |
sakthipriya | 0:7b4c00e3912f | 229 | { |
sakthipriya | 0:7b4c00e3912f | 230 | FLAG(); |
sakthipriya | 0:7b4c00e3912f | 231 | FCTN_ATS_DATA_ACQ(); //the angular velocity is stored in the first 3 values and magnetic field values in next 3 |
sakthipriya | 0:7b4c00e3912f | 232 | pc.printf("gyro values\n\r"); //printing the angular velocity and magnetic field values |
sakthipriya | 0:7b4c00e3912f | 233 | for(int i=0; i<3; i++) |
sakthipriya | 0:7b4c00e3912f | 234 | { |
sakthipriya | 6:036d08b62785 | 235 | pc.printf("%f\n\r",actual_data.AngularSpeed_actual[i]); |
sakthipriya | 0:7b4c00e3912f | 236 | } |
sakthipriya | 0:7b4c00e3912f | 237 | pc.printf("mag values\n\r"); |
sakthipriya | 6:036d08b62785 | 238 | for(int i=0; i<3; i++) |
sakthipriya | 0:7b4c00e3912f | 239 | { |
sakthipriya | 6:036d08b62785 | 240 | pc.printf("%f\n\r",actual_data.Bvalue_actual[i]); |
sakthipriya | 5:bb592f3185cc | 241 | } |
sakthipriya | 6:036d08b62785 | 242 | // for(int i=0;i<3;i++) |
sakthipriya | 6:036d08b62785 | 243 | // { |
sakthipriya | 6:036d08b62785 | 244 | // omega1[i]= data[i]; |
sakthipriya | 6:036d08b62785 | 245 | // b1[i] = data[i+3]; |
sakthipriya | 6:036d08b62785 | 246 | // } |
sakthipriya | 0:7b4c00e3912f | 247 | }//if ACS_DATA_ACQ_ENABLE = 1 |
sakthipriya | 0:7b4c00e3912f | 248 | else |
sakthipriya | 0:7b4c00e3912f | 249 | { |
sakthipriya | 0:7b4c00e3912f | 250 | // Z axis actuation is the only final solution, |
sakthipriya | 0:7b4c00e3912f | 251 | } |
sakthipriya | 9:194afacf7449 | 252 | if(ACS_STATE == 0) // check ACS_STATE = ACS_CONTROL_OFF? |
sakthipriya | 0:7b4c00e3912f | 253 | { |
sakthipriya | 0:7b4c00e3912f | 254 | printf("\n\r acs control off\n"); |
sakthipriya | 0:7b4c00e3912f | 255 | FLAG(); |
sakthipriya | 9:194afacf7449 | 256 | ACS_STATUS = 0; // set ACS_STATUS = ACS_CONTROL_OFF |
sakthipriya | 0:7b4c00e3912f | 257 | PWM1 = 0; //clear pwm pins |
sakthipriya | 0:7b4c00e3912f | 258 | PWM2 = 0; //clear pwm pins |
sakthipriya | 0:7b4c00e3912f | 259 | PWM3 = 0; //clear pwm pins |
sakthipriya | 0:7b4c00e3912f | 260 | } |
sakthipriya | 0:7b4c00e3912f | 261 | else |
sakthipriya | 0:7b4c00e3912f | 262 | { |
sakthipriya | 1:446a959e36ce | 263 | if(actual_data.power_mode>1) |
sakthipriya | 0:7b4c00e3912f | 264 | |
sakthipriya | 0:7b4c00e3912f | 265 | { |
sakthipriya | 9:194afacf7449 | 266 | if(ACS_STATE == 2) // check ACS_STATE = ACS_ZAXIS_MOMENT_ONLY |
sakthipriya | 0:7b4c00e3912f | 267 | { |
sakthipriya | 0:7b4c00e3912f | 268 | FLAG(); |
sakthipriya | 0:7b4c00e3912f | 269 | printf("\n\r z axis moment only\n"); |
sakthipriya | 9:194afacf7449 | 270 | ACS_STATUS = 2; // set ACS_STATUS = ACS_ZAXIS_MOMENT_ONLY |
sakthipriya | 0:7b4c00e3912f | 271 | // FCTN_ACS_CNTRLALGO(b1, omega1); |
sakthipriya | 0:7b4c00e3912f | 272 | moment[0] = 0; |
sakthipriya | 0:7b4c00e3912f | 273 | moment[1] = 0; |
sakthipriya | 0:7b4c00e3912f | 274 | moment[2] =1.3;// is a dummy value |
sakthipriya | 0:7b4c00e3912f | 275 | FCTN_ACS_GENPWM_MAIN(moment) ; |
sakthipriya | 0:7b4c00e3912f | 276 | } |
sakthipriya | 0:7b4c00e3912f | 277 | else |
sakthipriya | 0:7b4c00e3912f | 278 | { |
sakthipriya | 9:194afacf7449 | 279 | if(ACS_STATE == 3) // check ACS_STATE = ACS_DATA_ACQ_FAILURE |
sakthipriya | 0:7b4c00e3912f | 280 | { |
sakthipriya | 0:7b4c00e3912f | 281 | FLAG(); |
sakthipriya | 0:7b4c00e3912f | 282 | printf("\n\r acs data failure "); |
sakthipriya | 9:194afacf7449 | 283 | ACS_STATUS = 3; // set ACS_STATUS = ACS_DATA_ACQ_FAILURE |
sakthipriya | 0:7b4c00e3912f | 284 | PWM1 = 0; //clear pwm pins |
sakthipriya | 0:7b4c00e3912f | 285 | PWM2 = 0; //clear pwm pins |
sakthipriya | 0:7b4c00e3912f | 286 | PWM3 = 0; //clear pwm pins |
sakthipriya | 0:7b4c00e3912f | 287 | } |
sakthipriya | 0:7b4c00e3912f | 288 | else |
sakthipriya | 0:7b4c00e3912f | 289 | { |
sakthipriya | 9:194afacf7449 | 290 | if(ACS_STATE == 4) // check ACS_STATE = ACS_NOMINAL_ONLY |
sakthipriya | 0:7b4c00e3912f | 291 | { |
sakthipriya | 0:7b4c00e3912f | 292 | FLAG(); |
sakthipriya | 0:7b4c00e3912f | 293 | printf("\n\r nominal"); |
sakthipriya | 9:194afacf7449 | 294 | ACS_STATUS = 4; // set ACS_STATUS = ACS_NOMINAL_ONLY |
sakthipriya | 6:036d08b62785 | 295 | FCTN_ACS_CNTRLALGO(actual_data.Bvalue_actual,actual_data.AngularSpeed_actual); |
sakthipriya | 0:7b4c00e3912f | 296 | printf("\n\r moment values returned by control algo \n"); |
sakthipriya | 0:7b4c00e3912f | 297 | for(int i=0; i<3; i++) |
sakthipriya | 0:7b4c00e3912f | 298 | { |
sakthipriya | 0:7b4c00e3912f | 299 | printf("%f\t",moment[i]); |
sakthipriya | 0:7b4c00e3912f | 300 | } |
sakthipriya | 0:7b4c00e3912f | 301 | FCTN_ACS_GENPWM_MAIN(moment) ; |
sakthipriya | 0:7b4c00e3912f | 302 | } |
sakthipriya | 0:7b4c00e3912f | 303 | else |
sakthipriya | 0:7b4c00e3912f | 304 | { |
sakthipriya | 9:194afacf7449 | 305 | if(ACS_STATE == 5) // check ACS_STATE = ACS_AUTO_CONTROL |
sakthipriya | 0:7b4c00e3912f | 306 | { |
sakthipriya | 0:7b4c00e3912f | 307 | FLAG(); |
sakthipriya | 0:7b4c00e3912f | 308 | printf("\n\r auto control"); |
sakthipriya | 9:194afacf7449 | 309 | ACS_STATUS = 5; // set ACS_STATUS = ACS_AUTO_CONTROL |
sakthipriya | 0:7b4c00e3912f | 310 | //FCTN_ACS_AUTOCTRL_LOGIC // gotta include this code |
sakthipriya | 0:7b4c00e3912f | 311 | } |
sakthipriya | 0:7b4c00e3912f | 312 | else |
sakthipriya | 0:7b4c00e3912f | 313 | { |
sakthipriya | 9:194afacf7449 | 314 | if(ACS_STATE == 6) // check ACS_STATE = ACS_DETUMBLING_ONLY |
sakthipriya | 0:7b4c00e3912f | 315 | { |
sakthipriya | 0:7b4c00e3912f | 316 | FLAG(); |
sakthipriya | 0:7b4c00e3912f | 317 | printf("\n\r Entered detumbling \n"); |
sakthipriya | 9:194afacf7449 | 318 | ACS_STATUS = 6; // set ACS_STATUS = ACS_DETUMBLING_ONLY |
sakthipriya | 6:036d08b62785 | 319 | FCTN_ACS_CNTRLALGO(actual_data.Bvalue_actual,actual_data.AngularSpeed_actual); // detumbling code has to be included |
sakthipriya | 0:7b4c00e3912f | 320 | FCTN_ACS_GENPWM_MAIN(moment) ; |
sakthipriya | 0:7b4c00e3912f | 321 | } |
sakthipriya | 0:7b4c00e3912f | 322 | else |
sakthipriya | 0:7b4c00e3912f | 323 | { |
sakthipriya | 0:7b4c00e3912f | 324 | FLAG(); |
sakthipriya | 0:7b4c00e3912f | 325 | printf("\n\r invalid state"); |
sakthipriya | 9:194afacf7449 | 326 | ACS_STATUS = 7 ; // set ACS_STATUS = INVALID STATE |
sakthipriya | 0:7b4c00e3912f | 327 | PWM1 = 0; //clear pwm pins |
sakthipriya | 0:7b4c00e3912f | 328 | PWM2 = 0; //clear pwm pins |
sakthipriya | 0:7b4c00e3912f | 329 | PWM3 = 0; //clear pwm pins |
sakthipriya | 0:7b4c00e3912f | 330 | }//else of invalid |
sakthipriya | 0:7b4c00e3912f | 331 | }//else of autocontrol |
sakthipriya | 0:7b4c00e3912f | 332 | }//else of nominal |
sakthipriya | 0:7b4c00e3912f | 333 | }//else of data acg failure |
sakthipriya | 0:7b4c00e3912f | 334 | |
sakthipriya | 0:7b4c00e3912f | 335 | }//else fo z axis moment only |
sakthipriya | 0:7b4c00e3912f | 336 | }//if power >2 |
sakthipriya | 0:7b4c00e3912f | 337 | else |
sakthipriya | 0:7b4c00e3912f | 338 | { |
sakthipriya | 0:7b4c00e3912f | 339 | FLAG(); |
sakthipriya | 0:7b4c00e3912f | 340 | printf("\n\r low power"); |
sakthipriya | 9:194afacf7449 | 341 | ACS_STATUS = 1; // set ACS_STATUS = ACS_LOW_POWER |
sakthipriya | 0:7b4c00e3912f | 342 | PWM1 = 0; //clear pwm pins |
sakthipriya | 0:7b4c00e3912f | 343 | PWM2 = 0; //clear pwm pins |
sakthipriya | 0:7b4c00e3912f | 344 | PWM3 = 0; //clear pwm pins |
sakthipriya | 0:7b4c00e3912f | 345 | } |
sakthipriya | 0:7b4c00e3912f | 346 | } //else for acs control off |
sakthipriya | 9:194afacf7449 | 347 | ACS_MAIN_STATUS = 0; //clear ACS_MAIN_STATUS flag |
sakthipriya | 3:07e15677a75c | 348 | |
sakthipriya | 0:7b4c00e3912f | 349 | } |
sakthipriya | 0:7b4c00e3912f | 350 | //***************************************************EPS THREAD***********************************************// |
sakthipriya | 0:7b4c00e3912f | 351 | |
sakthipriya | 3:07e15677a75c | 352 | void F_EPS() |
sakthipriya | 0:7b4c00e3912f | 353 | { |
sakthipriya | 3:07e15677a75c | 354 | |
sakthipriya | 0:7b4c00e3912f | 355 | pc.printf("\n\rEntered EPS %f\n",t_start.read()); |
sakthipriya | 9:194afacf7449 | 356 | EPS_MAIN_STATUS = 1; // Set EPS main status |
sakthipriya | 3:07e15677a75c | 357 | FCTN_BATT_TEMP_SENSOR_MAIN(actual_data.Batt_temp_actual); |
sakthipriya | 3:07e15677a75c | 358 | pc.printf("\n\r Battery temperature %f %f" ,actual_data.Batt_temp_actual[0], actual_data.Batt_temp_actual[1]); |
sakthipriya | 9:194afacf7449 | 359 | EPS_BATTERY_TEMP_STATUS = 1; //set EPS_BATTERY_TEMP_STATUS |
sakthipriya | 9:194afacf7449 | 360 | if(EPS_BATTERY_HEAT_ENABLE == 1) |
sakthipriya | 3:07e15677a75c | 361 | { |
sakthipriya | 5:bb592f3185cc | 362 | if((actual_data.Batt_temp_actual[0] < batt_heat_low) && (actual_data.Batt_temp_actual[1] < batt_heat_low)) // to confirm |
sakthipriya | 3:07e15677a75c | 363 | { |
sakthipriya | 3:07e15677a75c | 364 | batt_heat = 1; //turn on battery heater |
sakthipriya | 3:07e15677a75c | 365 | } |
sakthipriya | 3:07e15677a75c | 366 | else |
sakthipriya | 3:07e15677a75c | 367 | { |
sakthipriya | 3:07e15677a75c | 368 | batt_heat = 0; //turn off battery heater |
sakthipriya | 3:07e15677a75c | 369 | } |
sakthipriya | 3:07e15677a75c | 370 | |
sakthipriya | 3:07e15677a75c | 371 | } |
sakthipriya | 9:194afacf7449 | 372 | else if(EPS_BATTERY_HEAT_ENABLE == 0) |
sakthipriya | 3:07e15677a75c | 373 | { |
sakthipriya | 3:07e15677a75c | 374 | EPS_STATUS = 1;//EPS_STATUS = EPS_BATTERY_HEATER_DISABLED |
sakthipriya | 3:07e15677a75c | 375 | } |
sakthipriya | 0:7b4c00e3912f | 376 | FCTN_BATTERYGAUGE_MAIN(actual_data.Batt_gauge_actual); |
sakthipriya | 1:446a959e36ce | 377 | if (actual_data.Batt_gauge_actual[1] == 200) //data not received |
sakthipriya | 0:7b4c00e3912f | 378 | { |
sakthipriya | 0:7b4c00e3912f | 379 | actual_data.power_mode = 1; |
sakthipriya | 9:194afacf7449 | 380 | EPS_BATTERY_GAUGE_STATUS = 0; //clear EPS_BATTERY_GAUGE_STATUS |
sakthipriya | 0:7b4c00e3912f | 381 | |
sakthipriya | 0:7b4c00e3912f | 382 | } |
sakthipriya | 0:7b4c00e3912f | 383 | else |
sakthipriya | 0:7b4c00e3912f | 384 | { |
sakthipriya | 1:446a959e36ce | 385 | FCTN_EPS_POWERMODE(actual_data.Batt_gauge_actual[1]); //updating power level |
sakthipriya | 9:194afacf7449 | 386 | EPS_BATTERY_GAUGE_STATUS = 1; //set EPS_BATTERY_GAUGE_STATUS |
sakthipriya | 0:7b4c00e3912f | 387 | } |
sakthipriya | 3:07e15677a75c | 388 | // if( Temperature data received) |
sakthipriya | 3:07e15677a75c | 389 | //{ |
sakthipriya | 3:07e15677a75c | 390 | |
sakthipriya | 0:7b4c00e3912f | 391 | |
sakthipriya | 3:07e15677a75c | 392 | // } |
sakthipriya | 3:07e15677a75c | 393 | // else |
sakthipriya | 3:07e15677a75c | 394 | // { |
sakthipriya | 3:07e15677a75c | 395 | // Set battery temp to XX |
sakthipriya | 9:194afacf7449 | 396 | // EPS_BATTERY_TEMP_STATUS = 0; //clear EPS_BATTERY_TEMP_STATUS |
sakthipriya | 3:07e15677a75c | 397 | // EPS_STATUS = EPS_ERR_BATTERY_TEMP; |
sakthipriya | 3:07e15677a75c | 398 | // } |
sakthipriya | 3:07e15677a75c | 399 | FCTN_HK_MAIN(); |
sakthipriya | 6:036d08b62785 | 400 | // printf("\n\r here"); |
sakthipriya | 5:bb592f3185cc | 401 | FCTN_APPEND_HKDATA(); |
sakthipriya | 5:bb592f3185cc | 402 | minMaxHkData(); |
sakthipriya | 6:036d08b62785 | 403 | //printf("\n\r here"); |
sakthipriya | 9:194afacf7449 | 404 | EPS_MAIN_STATUS = 0; // clear EPS main status |
sakthipriya | 3:07e15677a75c | 405 | |
sakthipriya | 0:7b4c00e3912f | 406 | } |
sakthipriya | 0:7b4c00e3912f | 407 | |
sakthipriya | 0:7b4c00e3912f | 408 | //**************************************************BCN THREAD*******************************************************************// |
sakthipriya | 0:7b4c00e3912f | 409 | |
sakthipriya | 3:07e15677a75c | 410 | void F_BCN() |
sakthipriya | 0:7b4c00e3912f | 411 | { |
sakthipriya | 3:07e15677a75c | 412 | |
sakthipriya | 0:7b4c00e3912f | 413 | pc.printf("\n\rEntered BCN %f\n",t_start.read()); |
sakthipriya | 0:7b4c00e3912f | 414 | |
Bragadeesh153 | 12:af1d7e18b868 | 415 | FCTN_BCN_TX_MAIN(); |
sakthipriya | 0:7b4c00e3912f | 416 | |
sakthipriya | 0:7b4c00e3912f | 417 | } |
sakthipriya | 0:7b4c00e3912f | 418 | |
sakthipriya | 0:7b4c00e3912f | 419 | //**************************************************TCTM THREAD*******************************************************************// |
sakthipriya | 0:7b4c00e3912f | 420 | |
sakthipriya | 0:7b4c00e3912f | 421 | void T_TC(void const * args) |
sakthipriya | 0:7b4c00e3912f | 422 | { |
sakthipriya | 0:7b4c00e3912f | 423 | while(1) |
sakthipriya | 0:7b4c00e3912f | 424 | { |
sakthipriya | 0:7b4c00e3912f | 425 | Thread::signal_wait(0x4); |
sakthipriya | 0:7b4c00e3912f | 426 | wait_us(200); // can be between 38 to 15700 |
sakthipriya | 0:7b4c00e3912f | 427 | if( slave.receive() == 0) |
sakthipriya | 0:7b4c00e3912f | 428 | slave.stop(); |
sakthipriya | 0:7b4c00e3912f | 429 | else if( slave.receive() == 1) // slave writes to master |
sakthipriya | 0:7b4c00e3912f | 430 | { |
sakthipriya | 5:bb592f3185cc | 431 | if(data_send_flag == 'h') |
sakthipriya | 6:036d08b62785 | 432 | { |
sakthipriya | 6:036d08b62785 | 433 | //FCTN_APPEND_HKDATA(); |
sakthipriya | 6:036d08b62785 | 434 | // pc.printf("\n\r here"); |
sakthipriya | 6:036d08b62785 | 435 | write_ack=slave.write(BAE_chardata,74); |
sakthipriya | 6:036d08b62785 | 436 | } |
sakthipriya | 5:bb592f3185cc | 437 | else if(data_send_flag == 't') |
sakthipriya | 5:bb592f3185cc | 438 | { |
sakthipriya | 5:bb592f3185cc | 439 | write_ack=slave.write(telemetry,tm_len); |
sakthipriya | 5:bb592f3185cc | 440 | data_send_flag = 'h'; |
sakthipriya | 5:bb592f3185cc | 441 | irpt_2_mstr = 0; |
sakthipriya | 5:bb592f3185cc | 442 | } |
sakthipriya | 0:7b4c00e3912f | 443 | } |
sakthipriya | 0:7b4c00e3912f | 444 | else if( slave.receive()==3 || slave.receive()==2) // slave read |
sakthipriya | 0:7b4c00e3912f | 445 | { |
sakthipriya | 5:bb592f3185cc | 446 | read_ack=slave.read(telecommand,tc_len); |
sakthipriya | 7:a46a1dee4497 | 447 | t_tc.start(); |
sakthipriya | 6:036d08b62785 | 448 | //pc.printf("\n\rTELECOMMAND received from CDMS is %s \n",telecommand); |
sakthipriya | 7:a46a1dee4497 | 449 | pc.printf("\n\r Executing Telecommand \n"); |
sakthipriya | 3:07e15677a75c | 450 | // FCTN_TC_DECODE((uint8_t*) telecommand); |
sakthipriya | 7:a46a1dee4497 | 451 | |
sakthipriya | 3:07e15677a75c | 452 | uint8_t* temp = FCTN_BAE_TM_TC((uint8_t*) telecommand); |
sakthipriya | 3:07e15677a75c | 453 | telemetry = (char*)temp; |
sakthipriya | 7:a46a1dee4497 | 454 | |
sakthipriya | 5:bb592f3185cc | 455 | FCTN_TM(); |
sakthipriya | 7:a46a1dee4497 | 456 | t_tc.stop(); |
sakthipriya | 7:a46a1dee4497 | 457 | printf("\n\r time taken %d",t_tc.read_us()); |
sakthipriya | 7:a46a1dee4497 | 458 | t_tc.reset(); |
sakthipriya | 3:07e15677a75c | 459 | // for(int i = 0; i<134; i++) |
sakthipriya | 3:07e15677a75c | 460 | //pc.printf("%c", telemetry[i]); |
sakthipriya | 0:7b4c00e3912f | 461 | } |
sakthipriya | 0:7b4c00e3912f | 462 | |
sakthipriya | 6:036d08b62785 | 463 | |
sakthipriya | 0:7b4c00e3912f | 464 | } |
sakthipriya | 0:7b4c00e3912f | 465 | } |
sakthipriya | 0:7b4c00e3912f | 466 | |
sakthipriya | 0:7b4c00e3912f | 467 | void FCTN_TM() |
sakthipriya | 0:7b4c00e3912f | 468 | { |
sakthipriya | 4:39a4ae8c7ecd | 469 | //irpt_2_mstr = 0; |
sakthipriya | 5:bb592f3185cc | 470 | data_send_flag = 't'; |
sakthipriya | 0:7b4c00e3912f | 471 | pc.printf("\n\r Telemetry Generation \n"); |
sakthipriya | 0:7b4c00e3912f | 472 | irpt_2_mstr = 1; |
sakthipriya | 0:7b4c00e3912f | 473 | } |
sakthipriya | 0:7b4c00e3912f | 474 | |
sakthipriya | 0:7b4c00e3912f | 475 | |
sakthipriya | 0:7b4c00e3912f | 476 | //******************************************************* I2C *******************************************************************// |
sakthipriya | 0:7b4c00e3912f | 477 | |
sakthipriya | 0:7b4c00e3912f | 478 | void FCTN_I2C_ISR() |
sakthipriya | 0:7b4c00e3912f | 479 | { |
sakthipriya | 0:7b4c00e3912f | 480 | ptr_t_i2c->signal_set(0x4); |
sakthipriya | 0:7b4c00e3912f | 481 | } |
sakthipriya | 0:7b4c00e3912f | 482 | |
sakthipriya | 0:7b4c00e3912f | 483 | |
sakthipriya | 5:bb592f3185cc | 484 | //***********************************************************FAULTS***************************************************************// |
sakthipriya | 5:bb592f3185cc | 485 | /*void ir1clear() |
sakthipriya | 5:bb592f3185cc | 486 | { |
sakthipriya | 5:bb592f3185cc | 487 | actual_data.faultIr_status |= 0x01; // alert |
sakthipriya | 5:bb592f3185cc | 488 | |
sakthipriya | 5:bb592f3185cc | 489 | }*/ |
sakthipriya | 5:bb592f3185cc | 490 | |
sakthipriya | 5:bb592f3185cc | 491 | |
sakthipriya | 5:bb592f3185cc | 492 | |
sakthipriya | 5:bb592f3185cc | 493 | void ir2clear() |
sakthipriya | 5:bb592f3185cc | 494 | { |
sakthipriya | 5:bb592f3185cc | 495 | actual_data.faultIr_status |= 0x02; |
sakthipriya | 9:194afacf7449 | 496 | TRXY_SW_EN = 0; // Switch off TR XY |
sakthipriya | 5:bb592f3185cc | 497 | if1check = 1; |
sakthipriya | 5:bb592f3185cc | 498 | } |
sakthipriya | 5:bb592f3185cc | 499 | |
sakthipriya | 5:bb592f3185cc | 500 | void ir3clear() |
sakthipriya | 5:bb592f3185cc | 501 | { |
sakthipriya | 5:bb592f3185cc | 502 | actual_data.faultIr_status |= 0x04; |
sakthipriya | 5:bb592f3185cc | 503 | DRV_Z_SLP = 0; |
sakthipriya | 5:bb592f3185cc | 504 | wait_us(1); |
sakthipriya | 5:bb592f3185cc | 505 | DRV_Z_SLP = 1; |
sakthipriya | 5:bb592f3185cc | 506 | |
sakthipriya | 5:bb592f3185cc | 507 | } |
sakthipriya | 5:bb592f3185cc | 508 | |
sakthipriya | 5:bb592f3185cc | 509 | void ir4clear() |
sakthipriya | 5:bb592f3185cc | 510 | { |
sakthipriya | 5:bb592f3185cc | 511 | if2check = 1; |
sakthipriya | 5:bb592f3185cc | 512 | actual_data.faultIr_status |= 0x08; |
sakthipriya | 5:bb592f3185cc | 513 | TRZ_SW = 0; |
sakthipriya | 5:bb592f3185cc | 514 | } |
sakthipriya | 5:bb592f3185cc | 515 | |
sakthipriya | 5:bb592f3185cc | 516 | void ir5clear() |
sakthipriya | 5:bb592f3185cc | 517 | { |
sakthipriya | 5:bb592f3185cc | 518 | actual_data.faultIr_status |= 0x10; |
sakthipriya | 5:bb592f3185cc | 519 | CDMS_RESET = 0; |
sakthipriya | 5:bb592f3185cc | 520 | wait_us(1); |
sakthipriya | 5:bb592f3185cc | 521 | CDMS_RESET = 1; |
sakthipriya | 5:bb592f3185cc | 522 | } |
sakthipriya | 5:bb592f3185cc | 523 | |
sakthipriya | 5:bb592f3185cc | 524 | void ir6clear() |
sakthipriya | 5:bb592f3185cc | 525 | { |
sakthipriya | 5:bb592f3185cc | 526 | actual_data.faultIr_status |= 0x20; |
sakthipriya | 5:bb592f3185cc | 527 | BCN_SW = 0; |
sakthipriya | 5:bb592f3185cc | 528 | wait_us(1); |
sakthipriya | 5:bb592f3185cc | 529 | BCN_SW = 1; |
sakthipriya | 5:bb592f3185cc | 530 | } |
sakthipriya | 5:bb592f3185cc | 531 | |
sakthipriya | 5:bb592f3185cc | 532 | void ir7clear() |
sakthipriya | 5:bb592f3185cc | 533 | { |
sakthipriya | 5:bb592f3185cc | 534 | actual_data.faultIr_status |= 0x40; |
sakthipriya | 5:bb592f3185cc | 535 | } |
sakthipriya | 5:bb592f3185cc | 536 | uint8_t iter2=0,iter4 = 0; |
sakthipriya | 5:bb592f3185cc | 537 | |
sakthipriya | 5:bb592f3185cc | 538 | |
sakthipriya | 5:bb592f3185cc | 539 | |
sakthipriya | 5:bb592f3185cc | 540 | void pollfault() |
sakthipriya | 5:bb592f3185cc | 541 | { |
sakthipriya | 5:bb592f3185cc | 542 | |
sakthipriya | 5:bb592f3185cc | 543 | |
sakthipriya | 5:bb592f3185cc | 544 | |
sakthipriya | 5:bb592f3185cc | 545 | if (pf1==0) // OC_ATS1 |
sakthipriya | 5:bb592f3185cc | 546 | { |
sakthipriya | 5:bb592f3185cc | 547 | pf1check=1; |
sakthipriya | 5:bb592f3185cc | 548 | actual_data.faultPoll_status |=0x01 ; |
sakthipriya | 9:194afacf7449 | 549 | ATS1_SW_ENABLE = 1; // turn off ats1 // to be turned on next cycle in ACS |
sakthipriya | 5:bb592f3185cc | 550 | } |
sakthipriya | 5:bb592f3185cc | 551 | else actual_data.faultPoll_status &= 0xFE; |
sakthipriya | 5:bb592f3185cc | 552 | |
sakthipriya | 5:bb592f3185cc | 553 | if (pf2==0) |
sakthipriya | 5:bb592f3185cc | 554 | { |
sakthipriya | 5:bb592f3185cc | 555 | pf2check=1; |
sakthipriya | 5:bb592f3185cc | 556 | actual_data.faultPoll_status |=0x02 ; |
sakthipriya | 9:194afacf7449 | 557 | ATS2_SW_ENABLE = 1; // turn off ats2 // turn on in ACS |
sakthipriya | 5:bb592f3185cc | 558 | } |
sakthipriya | 5:bb592f3185cc | 559 | else actual_data.faultPoll_status &= 0xFD; |
sakthipriya | 5:bb592f3185cc | 560 | |
sakthipriya | 5:bb592f3185cc | 561 | if (pf3==0) |
sakthipriya | 5:bb592f3185cc | 562 | { actual_data.faultPoll_status |=0x04 ; |
sakthipriya | 5:bb592f3185cc | 563 | DRV_XY_SLP = 0; |
sakthipriya | 5:bb592f3185cc | 564 | wait_us(1); |
sakthipriya | 5:bb592f3185cc | 565 | DRV_XY_SLP = 1; |
sakthipriya | 5:bb592f3185cc | 566 | } |
sakthipriya | 5:bb592f3185cc | 567 | else actual_data.faultPoll_status &= 0xFB; |
sakthipriya | 5:bb592f3185cc | 568 | |
sakthipriya | 5:bb592f3185cc | 569 | |
sakthipriya | 5:bb592f3185cc | 570 | |
sakthipriya | 5:bb592f3185cc | 571 | |
sakthipriya | 5:bb592f3185cc | 572 | /*if (ir1==1) |
sakthipriya | 5:bb592f3185cc | 573 | { |
sakthipriya | 5:bb592f3185cc | 574 | actual_data.faultIr_status &=0xFE; |
sakthipriya | 5:bb592f3185cc | 575 | }*/ |
sakthipriya | 5:bb592f3185cc | 576 | if (ir2==1) |
sakthipriya | 5:bb592f3185cc | 577 | { |
sakthipriya | 5:bb592f3185cc | 578 | actual_data.faultIr_status &=0xFD; |
sakthipriya | 5:bb592f3185cc | 579 | } |
sakthipriya | 5:bb592f3185cc | 580 | if (ir3==1) |
sakthipriya | 5:bb592f3185cc | 581 | { |
sakthipriya | 5:bb592f3185cc | 582 | actual_data.faultIr_status &=0xFB; |
sakthipriya | 5:bb592f3185cc | 583 | } |
sakthipriya | 5:bb592f3185cc | 584 | if (ir4==1) |
sakthipriya | 5:bb592f3185cc | 585 | { |
sakthipriya | 5:bb592f3185cc | 586 | actual_data.faultIr_status &=0xF7; |
sakthipriya | 5:bb592f3185cc | 587 | } |
sakthipriya | 5:bb592f3185cc | 588 | if (ir5==1) |
sakthipriya | 5:bb592f3185cc | 589 | { |
sakthipriya | 5:bb592f3185cc | 590 | actual_data.faultIr_status &=0xEF; |
sakthipriya | 5:bb592f3185cc | 591 | } |
sakthipriya | 5:bb592f3185cc | 592 | if (ir6==1) |
sakthipriya | 5:bb592f3185cc | 593 | { |
sakthipriya | 5:bb592f3185cc | 594 | actual_data.faultIr_status &=0xDF; |
sakthipriya | 5:bb592f3185cc | 595 | }if (ir7==1) |
sakthipriya | 5:bb592f3185cc | 596 | { |
sakthipriya | 5:bb592f3185cc | 597 | actual_data.faultIr_status &=0xBF; |
sakthipriya | 5:bb592f3185cc | 598 | } |
sakthipriya | 5:bb592f3185cc | 599 | |
sakthipriya | 5:bb592f3185cc | 600 | } |
sakthipriya | 5:bb592f3185cc | 601 | |
sakthipriya | 5:bb592f3185cc | 602 | |
sakthipriya | 0:7b4c00e3912f | 603 | //------------------------------------------------------------------------------------------------------------------------------------------------ |
sakthipriya | 0:7b4c00e3912f | 604 | //SCHEDULER |
sakthipriya | 0:7b4c00e3912f | 605 | //------------------------------------------------------------------------------------------------------------------------------------------------ |
sakthipriya | 0:7b4c00e3912f | 606 | uint8_t schedcount=1; |
sakthipriya | 0:7b4c00e3912f | 607 | void T_SC(void const *args) |
sakthipriya | 0:7b4c00e3912f | 608 | { |
sakthipriya | 0:7b4c00e3912f | 609 | printf("\n\r in scheduler"); |
sakthipriya | 0:7b4c00e3912f | 610 | |
sakthipriya | 0:7b4c00e3912f | 611 | if(schedcount == 7) //to reset the counter |
sakthipriya | 0:7b4c00e3912f | 612 | { |
sakthipriya | 0:7b4c00e3912f | 613 | schedcount = 1; |
sakthipriya | 0:7b4c00e3912f | 614 | } |
sakthipriya | 0:7b4c00e3912f | 615 | if(schedcount%1==0) |
sakthipriya | 0:7b4c00e3912f | 616 | { |
sakthipriya | 3:07e15677a75c | 617 | F_ACS(); |
sakthipriya | 0:7b4c00e3912f | 618 | } |
sakthipriya | 0:7b4c00e3912f | 619 | |
sakthipriya | 0:7b4c00e3912f | 620 | if(schedcount%2==0) |
sakthipriya | 0:7b4c00e3912f | 621 | { |
sakthipriya | 3:07e15677a75c | 622 | F_EPS(); |
sakthipriya | 0:7b4c00e3912f | 623 | } |
sakthipriya | 0:7b4c00e3912f | 624 | if(schedcount%3==0) |
sakthipriya | 0:7b4c00e3912f | 625 | { |
Bragadeesh153 | 12:af1d7e18b868 | 626 | F_BCN(); |
sakthipriya | 0:7b4c00e3912f | 627 | } |
sakthipriya | 0:7b4c00e3912f | 628 | schedcount++; |
sakthipriya | 0:7b4c00e3912f | 629 | printf("\n\r exited scheduler"); |
sakthipriya | 0:7b4c00e3912f | 630 | } |
sakthipriya | 0:7b4c00e3912f | 631 | |
sakthipriya | 0:7b4c00e3912f | 632 | Timer t_flag; |
sakthipriya | 0:7b4c00e3912f | 633 | void FLAG() |
sakthipriya | 0:7b4c00e3912f | 634 | { |
sakthipriya | 0:7b4c00e3912f | 635 | |
sakthipriya | 0:7b4c00e3912f | 636 | //.............acs..................// |
sakthipriya | 9:194afacf7449 | 637 | if(ACS_INIT_STATUS == 1) |
sakthipriya | 0:7b4c00e3912f | 638 | BAE_STATUS = BAE_STATUS | 0x00000080; //set ACS_INIT_STATUS flag |
sakthipriya | 9:194afacf7449 | 639 | else if(ACS_INIT_STATUS == 0) |
sakthipriya | 0:7b4c00e3912f | 640 | BAE_STATUS &= 0xFFFFFF7F; //clear ACS_INIT_STATUS flag |
sakthipriya | 0:7b4c00e3912f | 641 | |
sakthipriya | 9:194afacf7449 | 642 | if(ACS_DATA_ACQ_STATUS == 1) |
sakthipriya | 0:7b4c00e3912f | 643 | BAE_STATUS =BAE_STATUS | 0x00000100; //set ACS_DATA_ACQ_STATUS flag |
sakthipriya | 9:194afacf7449 | 644 | else if(ACS_DATA_ACQ_STATUS == 0) |
sakthipriya | 0:7b4c00e3912f | 645 | BAE_STATUS &= 0xFFFFFEFF; //clear ACS_DATA_ACQ_STATUS flag |
sakthipriya | 0:7b4c00e3912f | 646 | |
sakthipriya | 9:194afacf7449 | 647 | if(ACS_ATS_ENABLE == 1) |
sakthipriya | 0:7b4c00e3912f | 648 | BAE_ENABLE |= 0x00000004; |
sakthipriya | 9:194afacf7449 | 649 | else if(ACS_ATS_ENABLE == 0) |
sakthipriya | 0:7b4c00e3912f | 650 | BAE_ENABLE = BAE_ENABLE &0xFFFFFFFB | 0x00000004; |
sakthipriya | 0:7b4c00e3912f | 651 | |
sakthipriya | 0:7b4c00e3912f | 652 | if(ACS_DATA_ACQ_STATUS == 'f') |
sakthipriya | 0:7b4c00e3912f | 653 | BAE_STATUS |= 0x00000200; |
sakthipriya | 0:7b4c00e3912f | 654 | |
sakthipriya | 9:194afacf7449 | 655 | if(ACS_MAIN_STATUS == 1) |
sakthipriya | 0:7b4c00e3912f | 656 | BAE_STATUS = (BAE_STATUS | 0x00001000); //set ACS_MAIN_STATUS flag |
sakthipriya | 9:194afacf7449 | 657 | else if(ACS_MAIN_STATUS == 0) |
sakthipriya | 0:7b4c00e3912f | 658 | BAE_STATUS &= 0xFFFFEFFF; //clear ACS_MAIN_STATUS flag |
sakthipriya | 0:7b4c00e3912f | 659 | |
sakthipriya | 0:7b4c00e3912f | 660 | if(ACS_STATUS == '0') |
sakthipriya | 0:7b4c00e3912f | 661 | BAE_STATUS = (BAE_STATUS & 0xFFFF1FFF); // set ACS_STATUS = ACS_CONTROL_OFF |
sakthipriya | 0:7b4c00e3912f | 662 | else if(ACS_STATUS == '1') |
sakthipriya | 0:7b4c00e3912f | 663 | BAE_STATUS =(BAE_STATUS & 0xFFFF1FFF) | 0x00002000; // set ACS_STATUS = ACS_LOW_POWER |
sakthipriya | 0:7b4c00e3912f | 664 | else if(ACS_STATUS == '2') |
sakthipriya | 0:7b4c00e3912f | 665 | BAE_STATUS = (BAE_STATUS & 0xFFFF1FFF)| 0x00004000; // set ACS_STATUS = ACS_ZAXIS_MOMENT_ONLY |
sakthipriya | 0:7b4c00e3912f | 666 | else if(ACS_STATUS == '3') |
sakthipriya | 0:7b4c00e3912f | 667 | BAE_STATUS = (BAE_STATUS & 0xFFFF1FFF) | 0x00006000; // set ACS_STATUS = ACS_DATA_ACQ_FAILURE |
sakthipriya | 0:7b4c00e3912f | 668 | else if(ACS_STATUS == '4') |
sakthipriya | 0:7b4c00e3912f | 669 | BAE_STATUS = (BAE_STATUS & 0xFFFF1FFF) | 0x00008000; // set ACS_STATUS = ACS_NOMINAL_ONLY |
sakthipriya | 0:7b4c00e3912f | 670 | else if(ACS_STATUS == '5') |
sakthipriya | 0:7b4c00e3912f | 671 | BAE_STATUS =(BAE_STATUS & 0xFFFF1FFF) | 0x0000A000; // set ACS_STATUS = ACS_AUTO_CONTROL |
sakthipriya | 0:7b4c00e3912f | 672 | else if(ACS_STATUS == '6') |
sakthipriya | 0:7b4c00e3912f | 673 | BAE_STATUS =(BAE_STATUS & 0xFFFF1FFF) | 0x0000C000; // set ACS_STATUS = ACS_DETUMBLING_ONLY |
sakthipriya | 0:7b4c00e3912f | 674 | else |
sakthipriya | 0:7b4c00e3912f | 675 | BAE_STATUS =(BAE_STATUS & 0xFFFF1FFF) | 0x0000E000; // set ACS_STATUS = INVALID STATE |
sakthipriya | 0:7b4c00e3912f | 676 | |
sakthipriya | 0:7b4c00e3912f | 677 | if(ACS_STATE == '0') |
sakthipriya | 0:7b4c00e3912f | 678 | BAE_ENABLE = (BAE_ENABLE & 0xFFFFFF8F); //ACS_STATE = ACS_CONTROL_OFF |
sakthipriya | 0:7b4c00e3912f | 679 | else if(ACS_STATE == '2') |
sakthipriya | 0:7b4c00e3912f | 680 | BAE_ENABLE = ((BAE_ENABLE & 0xFFFFFF8F)| 0x00000020); // ACS_STATE = ACS_ZAXIS_MOMENT_ONLY |
sakthipriya | 0:7b4c00e3912f | 681 | else if(ACS_STATE == '3') |
sakthipriya | 0:7b4c00e3912f | 682 | BAE_ENABLE = ((BAE_ENABLE & 0xFFFFFF8F)| 0x00000030); // set ACS_STATUS = ACS_DATA_ACQ_FAILURE |
sakthipriya | 0:7b4c00e3912f | 683 | else if(ACS_STATE == '4') |
sakthipriya | 0:7b4c00e3912f | 684 | BAE_ENABLE = ((BAE_ENABLE & 0xFFFFFF8F)| 0x00000040); // ACS_STATE = ACS_NOMINAL_ONLY |
sakthipriya | 0:7b4c00e3912f | 685 | else if(ACS_STATE == '5') |
sakthipriya | 0:7b4c00e3912f | 686 | BAE_ENABLE = ((BAE_ENABLE & 0xFFFFFF8F)| 0x00000050); // ACS_STATE = ACS_AUTO_CONTROL |
sakthipriya | 0:7b4c00e3912f | 687 | else if(ACS_STATE == '6') |
sakthipriya | 0:7b4c00e3912f | 688 | BAE_ENABLE = ((BAE_ENABLE & 0xFFFFFF8F)| 0x00000060); //ACS_STATE = ACS_DETUMBLING_CONTROL |
sakthipriya | 0:7b4c00e3912f | 689 | |
sakthipriya | 0:7b4c00e3912f | 690 | //...............eps......................// |
sakthipriya | 5:bb592f3185cc | 691 | |
sakthipriya | 5:bb592f3185cc | 692 | |
sakthipriya | 9:194afacf7449 | 693 | if (EPS_INIT_STATUS==1) // Set EPS_INIT_STATUS |
sakthipriya | 5:bb592f3185cc | 694 | BAE_STATUS |= 0x00010000; |
sakthipriya | 9:194afacf7449 | 695 | else if(EPS_INIT_STATUS==0) // Clear |
sakthipriya | 5:bb592f3185cc | 696 | BAE_STATUS &= 0xFFFEFFFF; |
sakthipriya | 5:bb592f3185cc | 697 | |
sakthipriya | 5:bb592f3185cc | 698 | |
sakthipriya | 9:194afacf7449 | 699 | if (EPS_MAIN_STATUS==1) // Set EPS_MAIIN_STATUS |
sakthipriya | 5:bb592f3185cc | 700 | BAE_STATUS |= 0x00040000; |
sakthipriya | 9:194afacf7449 | 701 | else if(EPS_MAIN_STATUS==0) // Clear |
sakthipriya | 5:bb592f3185cc | 702 | BAE_STATUS &= 0xFFFBFFFF; |
sakthipriya | 5:bb592f3185cc | 703 | |
sakthipriya | 5:bb592f3185cc | 704 | |
sakthipriya | 9:194afacf7449 | 705 | if (EPS_BATTERY_GAUGE_STATUS==1) // Set EPS_BATTERY_GAUGE_STATUS |
sakthipriya | 5:bb592f3185cc | 706 | BAE_STATUS |= 0x00020000; |
sakthipriya | 9:194afacf7449 | 707 | else if(EPS_BATTERY_GAUGE_STATUS==0) // Clear |
sakthipriya | 5:bb592f3185cc | 708 | BAE_STATUS &= 0xFFFDFFFF; |
sakthipriya | 5:bb592f3185cc | 709 | |
sakthipriya | 5:bb592f3185cc | 710 | |
sakthipriya | 9:194afacf7449 | 711 | if (EPS_BATTERY_TEMP_STATUS==1) // Set EPS_BATTERY_TEMP_STATUS |
sakthipriya | 5:bb592f3185cc | 712 | BAE_STATUS |= 0x00080000; |
sakthipriya | 9:194afacf7449 | 713 | else if(EPS_BATTERY_TEMP_STATUS==0) // Clear |
sakthipriya | 5:bb592f3185cc | 714 | BAE_STATUS &= 0xFFF7FFFF; |
sakthipriya | 5:bb592f3185cc | 715 | |
sakthipriya | 5:bb592f3185cc | 716 | if (EPS_STATUS==0) |
sakthipriya | 5:bb592f3185cc | 717 | BAE_STATUS = (BAE_STATUS & 0xFF8FFFFF); // Set EPS_ERR_BATTERY_TEMP |
sakthipriya | 5:bb592f3185cc | 718 | else if (EPS_STATUS==1) |
sakthipriya | 5:bb592f3185cc | 719 | BAE_STATUS = (BAE_STATUS & 0xFF8FFFFF)|0x00010000; // Set EPS_BATTERY_HEATER_DISABLED |
sakthipriya | 5:bb592f3185cc | 720 | else if (EPS_STATUS==2) |
sakthipriya | 5:bb592f3185cc | 721 | BAE_STATUS = (BAE_STATUS & 0xFF8FFFFF)|0x00020000; // Set EPS_ERR_HEATER_SWITCH_OFF |
sakthipriya | 5:bb592f3185cc | 722 | else if (EPS_STATUS==3) |
sakthipriya | 5:bb592f3185cc | 723 | BAE_STATUS = (BAE_STATUS & 0xFF8FFFFF)|0x00030000; // Set EPS_ERR_HEATER_SWITCH_ON |
sakthipriya | 5:bb592f3185cc | 724 | else if (EPS_STATUS==4) |
sakthipriya | 5:bb592f3185cc | 725 | BAE_STATUS = (BAE_STATUS & 0xFF8FFFFF)|0x00040000; // Set EPS_BATTERY_HEATER_OFF |
sakthipriya | 5:bb592f3185cc | 726 | else if (EPS_STATUS==5) |
sakthipriya | 5:bb592f3185cc | 727 | BAE_STATUS = (BAE_STATUS & 0xFF8FFFFF)|0x00050000; // Set EPS_BATTERY_HEATER_ON |
sakthipriya | 5:bb592f3185cc | 728 | |
sakthipriya | 5:bb592f3185cc | 729 | |
sakthipriya | 9:194afacf7449 | 730 | if(EPS_BATTERY_HEAT_ENABLE == 1) |
sakthipriya | 5:bb592f3185cc | 731 | BAE_ENABLE |= 0x00000080; |
sakthipriya | 9:194afacf7449 | 732 | else if(EPS_BATTERY_HEAT_ENABLE == 0) |
sakthipriya | 5:bb592f3185cc | 733 | BAE_ENABLE = BAE_ENABLE &0xFFFFFF7; |
sakthipriya | 3:07e15677a75c | 734 | |
sakthipriya | 0:7b4c00e3912f | 735 | |
sakthipriya | 0:7b4c00e3912f | 736 | |
sakthipriya | 0:7b4c00e3912f | 737 | pc.printf("\n\r BAE status %x BAE ENABLE %x ",BAE_STATUS,BAE_ENABLE); |
sakthipriya | 0:7b4c00e3912f | 738 | } |
sakthipriya | 0:7b4c00e3912f | 739 | |
sakthipriya | 0:7b4c00e3912f | 740 | void FCTN_BAE_INIT() |
sakthipriya | 0:7b4c00e3912f | 741 | { |
sakthipriya | 0:7b4c00e3912f | 742 | printf("\n\r Initialising BAE "); |
sakthipriya | 3:07e15677a75c | 743 | //..........intial status....// |
sakthipriya | 3:07e15677a75c | 744 | ACS_STATE = '4'; |
sakthipriya | 9:194afacf7449 | 745 | ACS_ATS_ENABLE = 1; |
sakthipriya | 9:194afacf7449 | 746 | ACS_DATA_ACQ_ENABLE = 1; |
sakthipriya | 9:194afacf7449 | 747 | EPS_BATTERY_HEAT_ENABLE = 1; |
sakthipriya | 9:194afacf7449 | 748 | //............intializing pins................// |
sakthipriya | 9:194afacf7449 | 749 | ATS1_SW_ENABLE = 0; |
sakthipriya | 9:194afacf7449 | 750 | ATS2_SW_ENABLE = 1; |
sakthipriya | 9:194afacf7449 | 751 | |
sakthipriya | 3:07e15677a75c | 752 | //............................// |
sakthipriya | 3:07e15677a75c | 753 | FCTN_ACS_INIT(); |
sakthipriya | 0:7b4c00e3912f | 754 | FCTN_EPS_INIT(); |
Bragadeesh153 | 12:af1d7e18b868 | 755 | FCTN_BCN_INIT(); |
sakthipriya | 3:07e15677a75c | 756 | |
sakthipriya | 3:07e15677a75c | 757 | |
sakthipriya | 0:7b4c00e3912f | 758 | FLAG(); |
sakthipriya | 0:7b4c00e3912f | 759 | } |
sakthipriya | 0:7b4c00e3912f | 760 | |
sakthipriya | 0:7b4c00e3912f | 761 | int main() |
sakthipriya | 0:7b4c00e3912f | 762 | { |
sakthipriya | 0:7b4c00e3912f | 763 | pc.printf("\n\r BAE Activated. Testing Version 1.1 \n"); |
sakthipriya | 0:7b4c00e3912f | 764 | |
sakthipriya | 0:7b4c00e3912f | 765 | /* if (BCN_FEN == 0) //dummy implementation |
sakthipriya | 0:7b4c00e3912f | 766 | { |
sakthipriya | 0:7b4c00e3912f | 767 | pc.printf("\n\r RF silence "); |
Bragadeesh153 | 12:af1d7e18b868 | 768 | FCTN_BCN_FEN(); |
sakthipriya | 0:7b4c00e3912f | 769 | t_rfsilence.start();//Start the timer for RF_Silence |
sakthipriya | 0:7b4c00e3912f | 770 | while(t_rfsilence.read() < RF_SILENCE_TIME); |
sakthipriya | 0:7b4c00e3912f | 771 | } |
sakthipriya | 0:7b4c00e3912f | 772 | */ |
sakthipriya | 3:07e15677a75c | 773 | |
sakthipriya | 9:194afacf7449 | 774 | //ACS_INIT_STATUS = 0; |
sakthipriya | 9:194afacf7449 | 775 | //ACS_DATA_ACQ_STATUS = 0; |
sakthipriya | 9:194afacf7449 | 776 | |
sakthipriya | 0:7b4c00e3912f | 777 | FLAG(); |
sakthipriya | 0:7b4c00e3912f | 778 | FCTN_BAE_INIT(); |
sakthipriya | 3:07e15677a75c | 779 | |
sakthipriya | 0:7b4c00e3912f | 780 | |
sakthipriya | 0:7b4c00e3912f | 781 | //...i2c.. |
sakthipriya | 3:07e15677a75c | 782 | //strcpy(telemetry,"This is telemetry THis is sample telemetry. ffffffffffffffffffffffffffffff end"); |
sakthipriya | 0:7b4c00e3912f | 783 | slave.address(addr); |
sakthipriya | 0:7b4c00e3912f | 784 | irpt_2_mstr = 0; |
sakthipriya | 0:7b4c00e3912f | 785 | |
sakthipriya | 0:7b4c00e3912f | 786 | ptr_t_i2c = new Thread(T_TC); |
sakthipriya | 0:7b4c00e3912f | 787 | ptr_t_i2c->set_priority(osPriorityHigh); |
sakthipriya | 5:bb592f3185cc | 788 | |
sakthipriya | 0:7b4c00e3912f | 789 | irpt_4m_mstr.enable_irq(); |
sakthipriya | 0:7b4c00e3912f | 790 | irpt_4m_mstr.rise(&FCTN_I2C_ISR); |
sakthipriya | 5:bb592f3185cc | 791 | // ir1.fall(&ir1clear); //Battery Gauge - Alert Bar Signal |
sakthipriya | 5:bb592f3185cc | 792 | ir2.fall(&ir2clear); //TRXY Driver TR switch Fault |
sakthipriya | 5:bb592f3185cc | 793 | ir3.fall(&ir3clear); //TRZ Driver Fault Bar |
sakthipriya | 5:bb592f3185cc | 794 | ir4.fall(&ir4clear); //TRZ Driver TR switch Fault |
sakthipriya | 5:bb592f3185cc | 795 | ir5.fall(&ir5clear); //CDMS - Switch Fault |
sakthipriya | 5:bb592f3185cc | 796 | ir6.fall(&ir6clear); //Beacon- Switch OC bar |
sakthipriya | 5:bb592f3185cc | 797 | ir7.fall(&ir7clear); //Charger IC - Fault Bar |
sakthipriya | 0:7b4c00e3912f | 798 | RtosTimer t_sc_timer(T_SC,osTimerPeriodic); // Initiating the scheduler thread |
sakthipriya | 0:7b4c00e3912f | 799 | t_sc_timer.start(10000); |
sakthipriya | 0:7b4c00e3912f | 800 | t_start.start(); |
sakthipriya | 0:7b4c00e3912f | 801 | pc.printf("\n\rStarted scheduler %f\n\r",t_start.read()); |
sakthipriya | 0:7b4c00e3912f | 802 | |
sakthipriya | 9:194afacf7449 | 803 | ATS1_SW_ENABLE = 0; // att sens2 switch is enabled |
sakthipriya | 0:7b4c00e3912f | 804 | //FCTN_BAE_INIT(); |
sakthipriya | 0:7b4c00e3912f | 805 | while(1); //required to prevent main from terminating |
sakthipriya | 3:07e15677a75c | 806 | } |
sakthipriya | 3:07e15677a75c | 807 |