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