![](/media/cache/group/nine_tails_kurama_by_zubair43-d4zyf5s.jpg.50x50_q85.jpg)
FINAL ACS TO BE USED FOR TESTING. COMMISSIONING, ACS MAIN, DATA ACQ ALL DONE.
Dependencies: FreescaleIAP mbed-rtos mbed
Fork of ACS_FULL_Flowchart_BAE by
TCTM.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 "TCTM.h" |
sakthipriya | 3:07e15677a75c | 3 | #include "crc.h" |
sakthipriya | 4:39a4ae8c7ecd | 4 | #include "EPS.h" |
sakthipriya | 5:bb592f3185cc | 5 | #include "pin_config.h" |
sakthipriya | 5:bb592f3185cc | 6 | #include "FreescaleIAP.h" |
sakthipriya | 6:036d08b62785 | 7 | #include "inttypes.h" |
sakthipriya | 6:036d08b62785 | 8 | #include "iostream" |
sakthipriya | 6:036d08b62785 | 9 | #include "stdint.h" |
sakthipriya | 6:036d08b62785 | 10 | #include "cassert" |
lakshya | 10:f93407b97750 | 11 | #include"math.h" |
lakshya | 10:f93407b97750 | 12 | |
lakshya | 11:1fdb94ae6563 | 13 | /*define the pins for digital out*/ |
sakthipriya | 0:7b4c00e3912f | 14 | |
sakthipriya | 9:194afacf7449 | 15 | extern DigitalOut ATS1_SW_ENABLE; // enable of att sens2 switch |
sakthipriya | 9:194afacf7449 | 16 | extern DigitalOut ATS2_SW_ENABLE; // enable of att sens switch |
sakthipriya | 5:bb592f3185cc | 17 | |
Bragadeesh153 | 13:fb7facaf308b | 18 | extern DigitalOut TRXY_SW; //TR XY Switch if any TR_SW error arises then it is same as TR_SW_EN |
sakthipriya | 5:bb592f3185cc | 19 | extern DigitalOut TRZ_SW; //TR Z Switch |
sakthipriya | 5:bb592f3185cc | 20 | extern DigitalOut CDMS_RESET; // CDMS RESET |
sakthipriya | 5:bb592f3185cc | 21 | extern DigitalOut BCN_SW; //Beacon switch |
lakshya | 10:f93407b97750 | 22 | extern uint8_t BCN_TX_STATUS; |
lakshya | 10:f93407b97750 | 23 | extern uint8_t BCN_FEN; |
sakthipriya | 4:39a4ae8c7ecd | 24 | extern BAE_HK_actual actual_data; |
sakthipriya | 4:39a4ae8c7ecd | 25 | extern BAE_HK_min_max bae_HK_minmax; |
sakthipriya | 4:39a4ae8c7ecd | 26 | extern uint32_t BAE_STATUS; |
sakthipriya | 5:bb592f3185cc | 27 | extern float data[6]; |
sakthipriya | 5:bb592f3185cc | 28 | extern float moment[3]; |
lakshya | 10:f93407b97750 | 29 | extern uint8_t ACS_STATE; |
lakshya | 10:f93407b97750 | 30 | extern DigitalOut EN_BTRY_HT; |
lakshya | 10:f93407b97750 | 31 | extern DigitalOut phase_TR_x; |
lakshya | 10:f93407b97750 | 32 | extern DigitalOut phase_TR_y; |
lakshya | 10:f93407b97750 | 33 | extern DigitalOut phase_TR_z; |
lakshya | 10:f93407b97750 | 34 | extern BAE_HK_quant quant_data; |
Bragadeesh153 | 13:fb7facaf308b | 35 | //extern DigitalOut TRXY_SW; |
lakshya | 11:1fdb94ae6563 | 36 | //extern DigitalOut TRZ_SW_EN; //same as TRZ_SW |
lakshya | 11:1fdb94ae6563 | 37 | extern uint32_t BAE_ENABLE; |
lakshya | 11:1fdb94ae6563 | 38 | //extern DigitalOut ACS_ACQ_DATA_ENABLE; |
lakshya | 11:1fdb94ae6563 | 39 | |
lakshya | 11:1fdb94ae6563 | 40 | /*given a default value as of now shuld read value from flash and increment it write it back very time it starts(bae)*/ |
lakshya | 11:1fdb94ae6563 | 41 | extern uint8_t BAE_RESET_COUNTER=0; |
lakshya | 11:1fdb94ae6563 | 42 | |
lakshya | 11:1fdb94ae6563 | 43 | extern uint8_t BCN_FAIL_COUNT; |
lakshya | 11:1fdb94ae6563 | 44 | |
Bragadeesh153 | 13:fb7facaf308b | 45 | extern PwmOut PWM1; //x //Functions used to generate PWM signal |
lakshya | 11:1fdb94ae6563 | 46 | extern PwmOut PWM2; //y |
lakshya | 11:1fdb94ae6563 | 47 | extern PwmOut PWM3; //z //PWM output comes from pins p6 |
lakshya | 11:1fdb94ae6563 | 48 | |
lakshya | 11:1fdb94ae6563 | 49 | extern void F_ACS(); |
lakshya | 11:1fdb94ae6563 | 50 | extern void F_BCN(); |
lakshya | 11:1fdb94ae6563 | 51 | //extern void FCTN_ACS_GENPWM_MAIN(); |
lakshya | 11:1fdb94ae6563 | 52 | extern void F_EPS(); |
lakshya | 11:1fdb94ae6563 | 53 | extern void FCTN_ACS_GENPWM_MAIN(float Moment[3]); |
Bragadeesh153 | 13:fb7facaf308b | 54 | extern void FCTN_ACS_INIT(); |
lakshya | 11:1fdb94ae6563 | 55 | |
sakthipriya | 5:bb592f3185cc | 56 | |
sakthipriya | 5:bb592f3185cc | 57 | extern void FCTN_ATS_DATA_ACQ(); |
sakthipriya | 5:bb592f3185cc | 58 | extern void FCTN_ACS_CNTRLALGO(float*,float*); |
Bragadeesh153 | 13:fb7facaf308b | 59 | uint8_t telemetry[135]; |
lakshya | 11:1fdb94ae6563 | 60 | |
lakshya | 11:1fdb94ae6563 | 61 | void FCTN_CONVERT_UINT (uint8_t input[2], float* output) |
lakshya | 11:1fdb94ae6563 | 62 | { |
lakshya | 11:1fdb94ae6563 | 63 | |
lakshya | 11:1fdb94ae6563 | 64 | *output = (float) input[1]; |
lakshya | 11:1fdb94ae6563 | 65 | *output = *output/100.0; //input[0] integer part |
lakshya | 11:1fdb94ae6563 | 66 | *output = *output + (float) input[0]; //input[1] decimal part correct to two decimal places |
lakshya | 11:1fdb94ae6563 | 67 | } |
lakshya | 11:1fdb94ae6563 | 68 | |
lakshya | 10:f93407b97750 | 69 | float angle(float x,float y,float z) |
lakshya | 10:f93407b97750 | 70 | { |
lakshya | 10:f93407b97750 | 71 | float mag_total=sqrt(x*x + y*y + z*z); |
lakshya | 10:f93407b97750 | 72 | float cos_z = z/mag_total; |
lakshya | 10:f93407b97750 | 73 | float theta_z = acosf(cos_z); |
Bragadeesh153 | 13:fb7facaf308b | 74 | |
lakshya | 10:f93407b97750 | 75 | return theta_z; |
lakshya | 10:f93407b97750 | 76 | //printf("/n cos_zz= %f /t theta_z= %f /n",cos_z,theta_z); |
lakshya | 10:f93407b97750 | 77 | } |
lakshya | 10:f93407b97750 | 78 | |
Bragadeesh153 | 13:fb7facaf308b | 79 | //uint8_t tm1[134]; |
Bragadeesh153 | 13:fb7facaf308b | 80 | |
Bragadeesh153 | 13:fb7facaf308b | 81 | void FCTN_BAE_TM_TC (uint8_t* tc) |
sakthipriya | 0:7b4c00e3912f | 82 | |
sakthipriya | 3:07e15677a75c | 83 | { |
Bragadeesh153 | 13:fb7facaf308b | 84 | // tm1[0] = 1; |
sakthipriya | 3:07e15677a75c | 85 | uint8_t service_type=(tc[2]&0xF0); |
Bragadeesh153 | 13:fb7facaf308b | 86 | |
sakthipriya | 3:07e15677a75c | 87 | uint16_t crc16; |
Bragadeesh153 | 13:fb7facaf308b | 88 | |
Bragadeesh153 | 13:fb7facaf308b | 89 | |
sakthipriya | 3:07e15677a75c | 90 | switch(service_type) |
sakthipriya | 3:07e15677a75c | 91 | { |
sakthipriya | 3:07e15677a75c | 92 | case 0x60: |
sakthipriya | 3:07e15677a75c | 93 | { |
sakthipriya | 3:07e15677a75c | 94 | printf("Memory Management Service\r\n"); |
sakthipriya | 3:07e15677a75c | 95 | uint8_t service_subtype=(tc[2]&0x0F); |
Bragadeesh153 | 13:fb7facaf308b | 96 | |
sakthipriya | 3:07e15677a75c | 97 | switch(service_subtype) |
sakthipriya | 3:07e15677a75c | 98 | { |
sakthipriya | 3:07e15677a75c | 99 | case 0x01: |
sakthipriya | 3:07e15677a75c | 100 | { |
sakthipriya | 3:07e15677a75c | 101 | printf("Read from Flash\r\n"); |
Bragadeesh153 | 13:fb7facaf308b | 102 | break; |
sakthipriya | 3:07e15677a75c | 103 | } |
sakthipriya | 3:07e15677a75c | 104 | case 0x02: |
sakthipriya | 3:07e15677a75c | 105 | { |
Bragadeesh153 | 13:fb7facaf308b | 106 | uint16_t MID = ((uint16_t)tc[3] << 8) | tc[4]; |
Bragadeesh153 | 13:fb7facaf308b | 107 | switch(MID) |
Bragadeesh153 | 13:fb7facaf308b | 108 | { |
Bragadeesh153 | 13:fb7facaf308b | 109 | |
lakshya | 10:f93407b97750 | 110 | case 0x0001: |
Bragadeesh153 | 13:fb7facaf308b | 111 | { |
Bragadeesh153 | 13:fb7facaf308b | 112 | printf("Read from RAM\r\n"); |
Bragadeesh153 | 13:fb7facaf308b | 113 | |
Bragadeesh153 | 13:fb7facaf308b | 114 | /*taking some varible till we find some thing more useful*/ |
Bragadeesh153 | 13:fb7facaf308b | 115 | //uint8_t ref_val=0x01; |
Bragadeesh153 | 13:fb7facaf308b | 116 | telemetry[0] = 1; |
Bragadeesh153 | 13:fb7facaf308b | 117 | telemetry[1] = tc[0]; |
Bragadeesh153 | 13:fb7facaf308b | 118 | telemetry[2] = ACK_CODE; |
Bragadeesh153 | 13:fb7facaf308b | 119 | /*random or with bcn_tx_sw_enable assuming it is 1 bit in length |
Bragadeesh153 | 13:fb7facaf308b | 120 | how to get that we dont know, now we just assume it to be so*/ |
Bragadeesh153 | 13:fb7facaf308b | 121 | telemetry[3] = (BCN_SW); |
Bragadeesh153 | 13:fb7facaf308b | 122 | telemetry[3] = telemetry[3]|(TRXY_SW<<1); |
Bragadeesh153 | 13:fb7facaf308b | 123 | telemetry[3] = telemetry[3]|(TRZ_SW<<2); |
Bragadeesh153 | 13:fb7facaf308b | 124 | telemetry[3] = telemetry[3]|(ATS1_SW_ENABLE<<3); |
Bragadeesh153 | 13:fb7facaf308b | 125 | telemetry[3] = telemetry[3]|(ATS2_SW_ENABLE<<4); |
Bragadeesh153 | 13:fb7facaf308b | 126 | |
Bragadeesh153 | 13:fb7facaf308b | 127 | if(BCN_TX_STATUS==2) |
Bragadeesh153 | 13:fb7facaf308b | 128 | telemetry[3] = telemetry[3]|0x20; |
Bragadeesh153 | 13:fb7facaf308b | 129 | else |
Bragadeesh153 | 13:fb7facaf308b | 130 | telemetry[3] = telemetry[3] & 0xDF; |
Bragadeesh153 | 13:fb7facaf308b | 131 | |
Bragadeesh153 | 13:fb7facaf308b | 132 | telemetry[3] = telemetry[3]|(BCN_FEN<<6); |
Bragadeesh153 | 13:fb7facaf308b | 133 | uint8_t mask_val=BAE_ENABLE & 0x00000008; |
Bragadeesh153 | 13:fb7facaf308b | 134 | /*can be a problem see if any error occurs*/ |
Bragadeesh153 | 13:fb7facaf308b | 135 | telemetry[3] = telemetry[3]|(mask_val<<7); |
Bragadeesh153 | 13:fb7facaf308b | 136 | |
Bragadeesh153 | 13:fb7facaf308b | 137 | /*not included in the code yet*/ |
Bragadeesh153 | 13:fb7facaf308b | 138 | telemetry[4] = BAE_RESET_COUNTER; |
Bragadeesh153 | 13:fb7facaf308b | 139 | telemetry[5] = ACS_STATE; |
Bragadeesh153 | 13:fb7facaf308b | 140 | telemetry[5] = telemetry[5]|(EN_BTRY_HT<<3); |
Bragadeesh153 | 13:fb7facaf308b | 141 | telemetry[5] = telemetry[5]|(phase_TR_x<<4); |
Bragadeesh153 | 13:fb7facaf308b | 142 | telemetry[5] = telemetry[5]|(phase_TR_y<<5); |
Bragadeesh153 | 13:fb7facaf308b | 143 | telemetry[5] = telemetry[5]|(phase_TR_z<<6); |
Bragadeesh153 | 13:fb7facaf308b | 144 | /*spare to be fixed*/ |
Bragadeesh153 | 13:fb7facaf308b | 145 | //telemetry[5] = telemetry[5]|(Spare))<<7); |
Bragadeesh153 | 13:fb7facaf308b | 146 | /**/ |
Bragadeesh153 | 13:fb7facaf308b | 147 | uint8_t soc_powerlevel_2=50; |
Bragadeesh153 | 13:fb7facaf308b | 148 | uint8_t soc_powerlevel_3=65; |
Bragadeesh153 | 13:fb7facaf308b | 149 | |
Bragadeesh153 | 13:fb7facaf308b | 150 | telemetry[6] = soc_powerlevel_2; |
Bragadeesh153 | 13:fb7facaf308b | 151 | telemetry[7] = soc_powerlevel_3; |
lakshya | 10:f93407b97750 | 152 | |
Bragadeesh153 | 13:fb7facaf308b | 153 | /*to be fixed*/ |
Bragadeesh153 | 13:fb7facaf308b | 154 | telemetry[8] = 0; |
Bragadeesh153 | 13:fb7facaf308b | 155 | telemetry[9] = 0; |
Bragadeesh153 | 13:fb7facaf308b | 156 | telemetry[10] = 0; |
Bragadeesh153 | 13:fb7facaf308b | 157 | telemetry[11] = 0; |
Bragadeesh153 | 13:fb7facaf308b | 158 | //telemetry[8] = Torque Rod X Offset; |
Bragadeesh153 | 13:fb7facaf308b | 159 | //telemetry[9] = Torque Rod Y Offset; |
Bragadeesh153 | 13:fb7facaf308b | 160 | //telemetry[10] = Torque Rod Z Offset; |
Bragadeesh153 | 13:fb7facaf308b | 161 | //telemetry[11] = ACS_DEMAG_TIME_DELAY; |
Bragadeesh153 | 13:fb7facaf308b | 162 | telemetry[12] = (BAE_STATUS>>24) & 0xFF; |
Bragadeesh153 | 13:fb7facaf308b | 163 | telemetry[13] = (BAE_STATUS>>16) & 0xFF; |
Bragadeesh153 | 13:fb7facaf308b | 164 | telemetry[14] = (BAE_STATUS>>8) & 0xFF; |
Bragadeesh153 | 13:fb7facaf308b | 165 | telemetry[15] = BAE_STATUS & 0xFF; |
Bragadeesh153 | 13:fb7facaf308b | 166 | |
Bragadeesh153 | 13:fb7facaf308b | 167 | /*to be fixed*/ |
Bragadeesh153 | 13:fb7facaf308b | 168 | telemetry[16] = BCN_FAIL_COUNT; |
Bragadeesh153 | 13:fb7facaf308b | 169 | telemetry[17] = actual_data.power_mode; |
Bragadeesh153 | 13:fb7facaf308b | 170 | /*to be fixed*/ |
Bragadeesh153 | 13:fb7facaf308b | 171 | uint16_t P_BAE_I2CRX_COUNTER=0; |
Bragadeesh153 | 13:fb7facaf308b | 172 | uint16_t P_ACS_MAIN_COUNTER=0; |
Bragadeesh153 | 13:fb7facaf308b | 173 | uint16_t P_BCN_TX_MAIN_COUNTER=0; |
Bragadeesh153 | 13:fb7facaf308b | 174 | uint16_t P_EPS_MAIN_COUNTER=0; |
Bragadeesh153 | 13:fb7facaf308b | 175 | |
Bragadeesh153 | 13:fb7facaf308b | 176 | telemetry[18] = P_BAE_I2CRX_COUNTER>>8; |
Bragadeesh153 | 13:fb7facaf308b | 177 | telemetry[19] = P_BAE_I2CRX_COUNTER; |
Bragadeesh153 | 13:fb7facaf308b | 178 | telemetry[20] = P_ACS_MAIN_COUNTER>>8; |
Bragadeesh153 | 13:fb7facaf308b | 179 | telemetry[21] = P_ACS_MAIN_COUNTER; |
Bragadeesh153 | 13:fb7facaf308b | 180 | telemetry[22] = P_BCN_TX_MAIN_COUNTER>>8; |
Bragadeesh153 | 13:fb7facaf308b | 181 | telemetry[23] = P_BCN_TX_MAIN_COUNTER; |
Bragadeesh153 | 13:fb7facaf308b | 182 | telemetry[24] = P_EPS_MAIN_COUNTER>>8; |
Bragadeesh153 | 13:fb7facaf308b | 183 | telemetry[25] = P_EPS_MAIN_COUNTER; |
Bragadeesh153 | 13:fb7facaf308b | 184 | |
Bragadeesh153 | 13:fb7facaf308b | 185 | for(int i=0; i<3; i++) |
Bragadeesh153 | 13:fb7facaf308b | 186 | FCTN_CONVERT_FLOAT(actual_data.Bvalue_actual[i],&telemetry[26+ (i*4)]); |
Bragadeesh153 | 13:fb7facaf308b | 187 | for(int i=0; i<3; i++) |
Bragadeesh153 | 13:fb7facaf308b | 188 | FCTN_CONVERT_FLOAT(actual_data.AngularSpeed_actual[i],&telemetry[38+(i*4)]); |
Bragadeesh153 | 13:fb7facaf308b | 189 | |
Bragadeesh153 | 13:fb7facaf308b | 190 | //FAULT_FLAG(); |
Bragadeesh153 | 13:fb7facaf308b | 191 | telemetry[50] = actual_data.faultIr_status; |
Bragadeesh153 | 13:fb7facaf308b | 192 | telemetry[51] = actual_data.faultPoll_status; |
Bragadeesh153 | 13:fb7facaf308b | 193 | //Bdot Rotation Speed of Command telemetry[52-53] |
Bragadeesh153 | 13:fb7facaf308b | 194 | //Bdot Output Current telemetry[54] |
Bragadeesh153 | 13:fb7facaf308b | 195 | //float l_pmw1 = (PWM1); |
Bragadeesh153 | 13:fb7facaf308b | 196 | //float l_pmw2 = PWM2; |
Bragadeesh153 | 13:fb7facaf308b | 197 | //float l_pmw3 = PWM3; |
Bragadeesh153 | 13:fb7facaf308b | 198 | |
lakshya | 11:1fdb94ae6563 | 199 | /*__________________________________________________________________*/ |
Bragadeesh153 | 13:fb7facaf308b | 200 | |
lakshya | 11:1fdb94ae6563 | 201 | /*change and check if changing it to PWM1 causes problem*/ |
Bragadeesh153 | 13:fb7facaf308b | 202 | |
lakshya | 11:1fdb94ae6563 | 203 | /*___________________________________________________________________*/ |
Bragadeesh153 | 13:fb7facaf308b | 204 | |
lakshya | 11:1fdb94ae6563 | 205 | float PWM_measured[3]; |
Bragadeesh153 | 13:fb7facaf308b | 206 | |
Bragadeesh153 | 13:fb7facaf308b | 207 | PWM_measured[0] = PWM1.read(); |
Bragadeesh153 | 13:fb7facaf308b | 208 | PWM_measured[1] = PWM2.read(); |
Bragadeesh153 | 13:fb7facaf308b | 209 | PWM_measured[2] = PWM3.read(); |
Bragadeesh153 | 13:fb7facaf308b | 210 | |
Bragadeesh153 | 13:fb7facaf308b | 211 | FCTN_CONVERT_FLOAT(PWM_measured[0], &telemetry[55]); |
Bragadeesh153 | 13:fb7facaf308b | 212 | FCTN_CONVERT_FLOAT(PWM_measured[1], &telemetry[59]); |
Bragadeesh153 | 13:fb7facaf308b | 213 | FCTN_CONVERT_FLOAT(PWM_measured[2], &telemetry[63]); |
lakshya | 10:f93407b97750 | 214 | float attitude_ang = angle(actual_data.Bvalue_actual[0],actual_data.Bvalue_actual[1],actual_data.Bvalue_actual[2]); |
Bragadeesh153 | 13:fb7facaf308b | 215 | FCTN_CONVERT_FLOAT(attitude_ang, &telemetry[67]); |
lakshya | 10:f93407b97750 | 216 | |
lakshya | 10:f93407b97750 | 217 | for (int i=0; i<16; i++) |
Bragadeesh153 | 13:fb7facaf308b | 218 | telemetry[68+i] = quant_data.voltage_quant[i]; |
lakshya | 10:f93407b97750 | 219 | for (int i=0; i<12; i++) |
Bragadeesh153 | 13:fb7facaf308b | 220 | telemetry[84+i] = quant_data.current_quant[i]; |
Bragadeesh153 | 13:fb7facaf308b | 221 | //telemetry[96] |
Bragadeesh153 | 13:fb7facaf308b | 222 | //telemetry[97] |
Bragadeesh153 | 13:fb7facaf308b | 223 | //telemetry[98] |
Bragadeesh153 | 13:fb7facaf308b | 224 | //telemetry[99] |
Bragadeesh153 | 13:fb7facaf308b | 225 | telemetry[100] = quant_data.Batt_voltage_quant; |
Bragadeesh153 | 13:fb7facaf308b | 226 | telemetry[101] = quant_data.BAE_temp_quant; |
Bragadeesh153 | 13:fb7facaf308b | 227 | telemetry[102] = quant_data.Batt_gauge_quant[1]; |
Bragadeesh153 | 13:fb7facaf308b | 228 | telemetry[103] = quant_data.Batt_temp_quant[0]; |
Bragadeesh153 | 13:fb7facaf308b | 229 | telemetry[104] = quant_data.Batt_temp_quant[1]; |
Bragadeesh153 | 13:fb7facaf308b | 230 | |
Bragadeesh153 | 13:fb7facaf308b | 231 | //telemetry[105] = beacon temperature; |
Bragadeesh153 | 13:fb7facaf308b | 232 | |
lakshya | 10:f93407b97750 | 233 | for (int i=105; i<132;i++) |
sakthipriya | 8:82250e41da81 | 234 | { |
Bragadeesh153 | 13:fb7facaf308b | 235 | telemetry[i] = 0x00; |
sakthipriya | 5:bb592f3185cc | 236 | } |
Bragadeesh153 | 13:fb7facaf308b | 237 | crc16 = CRC::crc16_gen(telemetry,132); |
Bragadeesh153 | 13:fb7facaf308b | 238 | telemetry[132] = (uint8_t)((crc16&0xFF00)>>8); |
Bragadeesh153 | 13:fb7facaf308b | 239 | telemetry[133] = (uint8_t)(crc16&0x00FF); |
Bragadeesh153 | 13:fb7facaf308b | 240 | |
Bragadeesh153 | 13:fb7facaf308b | 241 | break; |
Bragadeesh153 | 13:fb7facaf308b | 242 | } |
Bragadeesh153 | 13:fb7facaf308b | 243 | case 0x0002: |
Bragadeesh153 | 13:fb7facaf308b | 244 | { |
Bragadeesh153 | 13:fb7facaf308b | 245 | telemetry[0] = 0x60; |
Bragadeesh153 | 13:fb7facaf308b | 246 | telemetry[1] = tc[0]; |
Bragadeesh153 | 13:fb7facaf308b | 247 | telemetry[2] = ACK_CODE; |
Bragadeesh153 | 13:fb7facaf308b | 248 | |
Bragadeesh153 | 13:fb7facaf308b | 249 | for(int i;i<16;i++) |
Bragadeesh153 | 13:fb7facaf308b | 250 | telemetry[i+3] = bae_HK_minmax.voltage_max[i]; |
Bragadeesh153 | 13:fb7facaf308b | 251 | |
Bragadeesh153 | 13:fb7facaf308b | 252 | for(int i;i<12;i++) |
Bragadeesh153 | 13:fb7facaf308b | 253 | telemetry[i+18] = bae_HK_minmax.current_max[i]; |
Bragadeesh153 | 13:fb7facaf308b | 254 | |
Bragadeesh153 | 13:fb7facaf308b | 255 | telemetry[29] = bae_HK_minmax.Batt_voltage_max;; |
Bragadeesh153 | 13:fb7facaf308b | 256 | telemetry[30] = bae_HK_minmax.BAE_temp_max; |
Bragadeesh153 | 13:fb7facaf308b | 257 | |
Bragadeesh153 | 13:fb7facaf308b | 258 | /*battery soc*/ |
Bragadeesh153 | 13:fb7facaf308b | 259 | //telemetry[31] = BAE_HK_min_max bae_HK_minmax.voltage_max; |
Bragadeesh153 | 13:fb7facaf308b | 260 | |
Bragadeesh153 | 13:fb7facaf308b | 261 | telemetry[32] = bae_HK_minmax.Batt_temp_max[0]; |
Bragadeesh153 | 13:fb7facaf308b | 262 | telemetry[33] = bae_HK_minmax.Batt_temp_max[1]; |
Bragadeesh153 | 13:fb7facaf308b | 263 | |
Bragadeesh153 | 13:fb7facaf308b | 264 | /*BCN temp not there*/ |
Bragadeesh153 | 13:fb7facaf308b | 265 | //telemetry[34] = BAE_HK_min_max bae_HK_minmax.; |
Bragadeesh153 | 13:fb7facaf308b | 266 | |
Bragadeesh153 | 13:fb7facaf308b | 267 | for(int i=0; i<3; i++) |
Bragadeesh153 | 13:fb7facaf308b | 268 | FCTN_CONVERT_FLOAT(bae_HK_minmax.Bvalue_max[i],&telemetry[35+(i*4)]); |
Bragadeesh153 | 13:fb7facaf308b | 269 | |
Bragadeesh153 | 13:fb7facaf308b | 270 | for(int i=0; i<3; i++) |
Bragadeesh153 | 13:fb7facaf308b | 271 | FCTN_CONVERT_FLOAT(bae_HK_minmax.AngularSpeed_max[i],&telemetry[47+(i*4)]); |
Bragadeesh153 | 13:fb7facaf308b | 272 | |
Bragadeesh153 | 13:fb7facaf308b | 273 | /*min data*/ |
Bragadeesh153 | 13:fb7facaf308b | 274 | |
Bragadeesh153 | 13:fb7facaf308b | 275 | for(int i;i<16;i++) |
Bragadeesh153 | 13:fb7facaf308b | 276 | telemetry[i+59] = bae_HK_minmax.voltage_min[i]; |
Bragadeesh153 | 13:fb7facaf308b | 277 | |
Bragadeesh153 | 13:fb7facaf308b | 278 | for(int i;i<12;i++) |
Bragadeesh153 | 13:fb7facaf308b | 279 | telemetry[i+74] = bae_HK_minmax.current_min[i]; |
Bragadeesh153 | 13:fb7facaf308b | 280 | |
Bragadeesh153 | 13:fb7facaf308b | 281 | telemetry[86] = bae_HK_minmax.Batt_voltage_min; |
Bragadeesh153 | 13:fb7facaf308b | 282 | telemetry[87] = bae_HK_minmax.BAE_temp_min; |
Bragadeesh153 | 13:fb7facaf308b | 283 | |
Bragadeesh153 | 13:fb7facaf308b | 284 | /*battery soc*/ |
Bragadeesh153 | 13:fb7facaf308b | 285 | //telemetry[88] = BAE_HK_min_max bae_HK_minmax.voltage_max; |
Bragadeesh153 | 13:fb7facaf308b | 286 | |
Bragadeesh153 | 13:fb7facaf308b | 287 | telemetry[89] = bae_HK_minmax.Batt_temp_min[0]; |
Bragadeesh153 | 13:fb7facaf308b | 288 | telemetry[90] = bae_HK_minmax.Batt_temp_min[1]; |
Bragadeesh153 | 13:fb7facaf308b | 289 | //huhu// |
Bragadeesh153 | 13:fb7facaf308b | 290 | |
Bragadeesh153 | 13:fb7facaf308b | 291 | /*BCN temp not there*/ |
Bragadeesh153 | 13:fb7facaf308b | 292 | //telemetry[91] = BAE_HK_min_max bae_HK_minmax.; |
Bragadeesh153 | 13:fb7facaf308b | 293 | |
Bragadeesh153 | 13:fb7facaf308b | 294 | for(int i=0; i<3; i++) |
Bragadeesh153 | 13:fb7facaf308b | 295 | FCTN_CONVERT_FLOAT(bae_HK_minmax.Bvalue_min[i],&telemetry[91+(i*4)]); |
Bragadeesh153 | 13:fb7facaf308b | 296 | |
Bragadeesh153 | 13:fb7facaf308b | 297 | for(int i=0; i<3; i++) |
Bragadeesh153 | 13:fb7facaf308b | 298 | FCTN_CONVERT_FLOAT(bae_HK_minmax.AngularSpeed_min[i],&telemetry[103+(i*4)]); |
Bragadeesh153 | 13:fb7facaf308b | 299 | |
Bragadeesh153 | 13:fb7facaf308b | 300 | |
Bragadeesh153 | 13:fb7facaf308b | 301 | for (int i=115; i<132;i++) |
Bragadeesh153 | 13:fb7facaf308b | 302 | { |
Bragadeesh153 | 13:fb7facaf308b | 303 | telemetry[i] = 0x00; |
Bragadeesh153 | 13:fb7facaf308b | 304 | } |
Bragadeesh153 | 13:fb7facaf308b | 305 | crc16 = CRC::crc16_gen(telemetry,132); |
Bragadeesh153 | 13:fb7facaf308b | 306 | telemetry[132] = (uint8_t)((crc16&0xFF00)>>8); |
Bragadeesh153 | 13:fb7facaf308b | 307 | telemetry[133] = (uint8_t)(crc16&0x00FF); |
Bragadeesh153 | 13:fb7facaf308b | 308 | break; |
Bragadeesh153 | 13:fb7facaf308b | 309 | } |
Bragadeesh153 | 13:fb7facaf308b | 310 | } |
Bragadeesh153 | 13:fb7facaf308b | 311 | break; |
Bragadeesh153 | 13:fb7facaf308b | 312 | } |
sakthipriya | 3:07e15677a75c | 313 | case 0x05: |
sakthipriya | 3:07e15677a75c | 314 | { |
sakthipriya | 3:07e15677a75c | 315 | printf("Write on Flash\r\n"); |
Bragadeesh153 | 13:fb7facaf308b | 316 | break; |
sakthipriya | 3:07e15677a75c | 317 | } |
sakthipriya | 3:07e15677a75c | 318 | default: |
sakthipriya | 3:07e15677a75c | 319 | { |
sakthipriya | 3:07e15677a75c | 320 | printf("Invalid TC"); |
Bragadeesh153 | 13:fb7facaf308b | 321 | //ACK_L234_telemetry |
Bragadeesh153 | 13:fb7facaf308b | 322 | telemetry[0]=0xB0; |
Bragadeesh153 | 13:fb7facaf308b | 323 | telemetry[1]=tc[0]; |
Bragadeesh153 | 13:fb7facaf308b | 324 | telemetry[2]=ACK_CODE; |
sakthipriya | 3:07e15677a75c | 325 | for(uint8_t i=3;i<11;i++) |
sakthipriya | 3:07e15677a75c | 326 | { |
Bragadeesh153 | 13:fb7facaf308b | 327 | telemetry[i]=0x00; |
sakthipriya | 0:7b4c00e3912f | 328 | } |
Bragadeesh153 | 13:fb7facaf308b | 329 | crc16 = CRC::crc16_gen(telemetry,11); |
Bragadeesh153 | 13:fb7facaf308b | 330 | telemetry[11] = (uint8_t)((crc16&0xFF00)>>8); |
Bragadeesh153 | 13:fb7facaf308b | 331 | telemetry[12] = (uint8_t)(crc16&0x00FF); |
sakthipriya | 3:07e15677a75c | 332 | for(uint8_t i=13;i<134;i++) |
sakthipriya | 3:07e15677a75c | 333 | { |
Bragadeesh153 | 13:fb7facaf308b | 334 | telemetry[i]=0x00; |
sakthipriya | 0:7b4c00e3912f | 335 | } |
Bragadeesh153 | 13:fb7facaf308b | 336 | break; |
sakthipriya | 3:07e15677a75c | 337 | } |
sakthipriya | 3:07e15677a75c | 338 | } |
Bragadeesh153 | 13:fb7facaf308b | 339 | break; |
sakthipriya | 0:7b4c00e3912f | 340 | } |
sakthipriya | 3:07e15677a75c | 341 | case 0x80: |
sakthipriya | 3:07e15677a75c | 342 | { |
Bragadeesh153 | 13:fb7facaf308b | 343 | //printf("Function Management Service\r\n"); |
sakthipriya | 3:07e15677a75c | 344 | uint8_t service_subtype=(tc[2]&0x0F); |
sakthipriya | 3:07e15677a75c | 345 | switch(service_subtype) |
sakthipriya | 3:07e15677a75c | 346 | { |
sakthipriya | 3:07e15677a75c | 347 | case 0x01: |
sakthipriya | 3:07e15677a75c | 348 | { |
sakthipriya | 3:07e15677a75c | 349 | printf("FMS Activated\r\n"); |
sakthipriya | 3:07e15677a75c | 350 | uint8_t pid=tc[3]; |
sakthipriya | 3:07e15677a75c | 351 | switch(pid) |
sakthipriya | 3:07e15677a75c | 352 | { |
sakthipriya | 5:bb592f3185cc | 353 | case 0xE0: |
sakthipriya | 3:07e15677a75c | 354 | { |
lakshya | 10:f93407b97750 | 355 | float B[3],W[3]; |
sakthipriya | 5:bb592f3185cc | 356 | printf("ACS_COMSN\r\n"); |
Bragadeesh153 | 13:fb7facaf308b | 357 | //ACK_L234_telemetry |
Bragadeesh153 | 13:fb7facaf308b | 358 | |
lakshya | 10:f93407b97750 | 359 | uint8_t B_x[2]; |
lakshya | 10:f93407b97750 | 360 | uint8_t B_y[2]; |
lakshya | 10:f93407b97750 | 361 | uint8_t B_z[2]; |
lakshya | 10:f93407b97750 | 362 | uint8_t W_x[2]; |
lakshya | 10:f93407b97750 | 363 | uint8_t W_y[2]; |
lakshya | 10:f93407b97750 | 364 | uint8_t W_z[2]; |
Bragadeesh153 | 13:fb7facaf308b | 365 | |
lakshya | 10:f93407b97750 | 366 | B_x[0]=tc[3]; |
lakshya | 10:f93407b97750 | 367 | B_x[1]=tc[4]; |
lakshya | 10:f93407b97750 | 368 | B_y[0]=tc[5]; |
lakshya | 10:f93407b97750 | 369 | B_y[1]=tc[6]; |
lakshya | 10:f93407b97750 | 370 | B_z[0]=tc[7]; |
lakshya | 10:f93407b97750 | 371 | B_z[1]=tc[8]; |
Bragadeesh153 | 13:fb7facaf308b | 372 | |
lakshya | 10:f93407b97750 | 373 | W_x[0]=tc[9]; |
lakshya | 10:f93407b97750 | 374 | W_x[1]=tc[10]; |
lakshya | 10:f93407b97750 | 375 | W_y[0]=tc[11]; |
lakshya | 10:f93407b97750 | 376 | W_y[1]=tc[12]; |
lakshya | 10:f93407b97750 | 377 | W_z[0]=tc[13]; |
lakshya | 10:f93407b97750 | 378 | W_z[1]=tc[14]; |
Bragadeesh153 | 13:fb7facaf308b | 379 | |
lakshya | 11:1fdb94ae6563 | 380 | FCTN_CONVERT_UINT(B_x,&B[0]); |
lakshya | 11:1fdb94ae6563 | 381 | FCTN_CONVERT_UINT(B_y,&B[1]); |
lakshya | 11:1fdb94ae6563 | 382 | FCTN_CONVERT_UINT(B_z,&B[2]); |
Bragadeesh153 | 13:fb7facaf308b | 383 | |
lakshya | 10:f93407b97750 | 384 | FCTN_CONVERT_UINT (W_x, &W[0]); |
lakshya | 10:f93407b97750 | 385 | FCTN_CONVERT_UINT (W_y, &W[1]); |
lakshya | 10:f93407b97750 | 386 | FCTN_CONVERT_UINT (W_z, &W[2]); |
Bragadeesh153 | 13:fb7facaf308b | 387 | |
Bragadeesh153 | 13:fb7facaf308b | 388 | telemetry[0]=0xB0; |
Bragadeesh153 | 13:fb7facaf308b | 389 | telemetry[1]=tc[0]; |
Bragadeesh153 | 13:fb7facaf308b | 390 | telemetry[2]=ACK_CODE; |
lakshya | 10:f93407b97750 | 391 | //FCTN_ATS_DATA_ACQ(); //get data |
Bragadeesh153 | 13:fb7facaf308b | 392 | printf("gyro values\n\r"); |
Bragadeesh153 | 13:fb7facaf308b | 393 | for(int i=0; i<3; i++) |
lakshya | 10:f93407b97750 | 394 | printf("%f\n\r",W[i]); |
sakthipriya | 5:bb592f3185cc | 395 | printf("mag values\n\r"); |
Bragadeesh153 | 13:fb7facaf308b | 396 | for(int i=0; i<3; i++) |
lakshya | 10:f93407b97750 | 397 | printf("%f\n\r",B[i]); |
Bragadeesh153 | 13:fb7facaf308b | 398 | /* FCTN_CONVERT_FLOAT(data[0],&telemetry[4]); //telemetry[4] - telemetry[7] |
Bragadeesh153 | 13:fb7facaf308b | 399 | FCTN_CONVERT_FLOAT(data[1],&telemetry[8]); //telemetry[8] - telemetry[11] |
Bragadeesh153 | 13:fb7facaf308b | 400 | FCTN_CONVERT_FLOAT(data[2],&telemetry[12]); //telemetry[12] - telemetry[15] |
Bragadeesh153 | 13:fb7facaf308b | 401 | FCTN_CONVERT_FLOAT(data[0],&telemetry[16]); //telemetry[16] - telemetry[19] |
Bragadeesh153 | 13:fb7facaf308b | 402 | FCTN_CONVERT_FLOAT(data[1],&telemetry[20]); //telemetry[20] - telemetry[23] |
Bragadeesh153 | 13:fb7facaf308b | 403 | FCTN_CONVERT_FLOAT(data[2],&telemetry[24]); //telemetry[24] - telemetry[27] |
sakthipriya | 5:bb592f3185cc | 404 | if((data[0]<8) && (data[1]<8) && (data[2] <8)) |
Bragadeesh153 | 13:fb7facaf308b | 405 | telemetry[28] = 1; // gyro values in correct range |
sakthipriya | 5:bb592f3185cc | 406 | else |
Bragadeesh153 | 13:fb7facaf308b | 407 | telemetry[28] = 0; |
sakthipriya | 5:bb592f3185cc | 408 | if ((data[3] > 20 ) && (data[4] >20) && (data[5]>20)&& (data[3] < 50 ) && (data[4] <50) && (data[5]<50)) |
Bragadeesh153 | 13:fb7facaf308b | 409 | telemetry[29] = 1; // mag values in correct range |
sakthipriya | 5:bb592f3185cc | 410 | else |
Bragadeesh153 | 13:fb7facaf308b | 411 | telemetry[29] = 0; |
Bragadeesh153 | 13:fb7facaf308b | 412 | */ |
Bragadeesh153 | 13:fb7facaf308b | 413 | // float B[3],W[3]; |
lakshya | 10:f93407b97750 | 414 | // B[0] = B0; |
Bragadeesh153 | 13:fb7facaf308b | 415 | // B[1] = B1; |
lakshya | 10:f93407b97750 | 416 | // B[2] = B2; |
lakshya | 10:f93407b97750 | 417 | // W[0] = W0; |
Bragadeesh153 | 13:fb7facaf308b | 418 | // W[1] = W1; |
Bragadeesh153 | 13:fb7facaf308b | 419 | // W[2] = W2; |
sakthipriya | 5:bb592f3185cc | 420 | // Control algo commissioning |
lakshya | 10:f93407b97750 | 421 | /* FCTN_ACS_CNTRLALGO(B,W); |
Bragadeesh153 | 13:fb7facaf308b | 422 | FCTN_CONVERT_FLOAT(moment[0],&telemetry[30]); //telemetry[30] - telemetry[33] |
Bragadeesh153 | 13:fb7facaf308b | 423 | FCTN_CONVERT_FLOAT(moment[1],&telemetry[34]); //telemetry[34] - telemetry[37] |
Bragadeesh153 | 13:fb7facaf308b | 424 | FCTN_CONVERT_FLOAT(moment[2],&telemetry[38]); //telemetry[38] - telemetry[41] |
sakthipriya | 5:bb592f3185cc | 425 | // to include commission TR as well |
sakthipriya | 5:bb592f3185cc | 426 | for(uint8_t i=42;i<132;i++) |
sakthipriya | 3:07e15677a75c | 427 | { |
Bragadeesh153 | 13:fb7facaf308b | 428 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 429 | } |
Bragadeesh153 | 13:fb7facaf308b | 430 | |
Bragadeesh153 | 13:fb7facaf308b | 431 | crc16 = CRC::crc16_gen(telemetry,132); |
Bragadeesh153 | 13:fb7facaf308b | 432 | telemetry[133] = (uint8_t)((crc16&0xFF00)>>8); |
Bragadeesh153 | 13:fb7facaf308b | 433 | telemetry[134] = (uint8_t)(crc16&0x00FF); |
Bragadeesh153 | 13:fb7facaf308b | 434 | break; |
Bragadeesh153 | 13:fb7facaf308b | 435 | */ |
Bragadeesh153 | 13:fb7facaf308b | 436 | |
lakshya | 10:f93407b97750 | 437 | // Control algo commissioning |
lakshya | 10:f93407b97750 | 438 | FCTN_ACS_CNTRLALGO(B,W); |
Bragadeesh153 | 13:fb7facaf308b | 439 | FCTN_CONVERT_FLOAT(moment[0],&telemetry[4]); //telemetry[4] - telemetry[7] |
Bragadeesh153 | 13:fb7facaf308b | 440 | FCTN_CONVERT_FLOAT(moment[1],&telemetry[8]); //telemetry[8] - telemetry[11] |
Bragadeesh153 | 13:fb7facaf308b | 441 | FCTN_CONVERT_FLOAT(moment[2],&telemetry[12]); //telemetry[12] - telemetry[15] |
lakshya | 10:f93407b97750 | 442 | // to include commission TR as well |
lakshya | 10:f93407b97750 | 443 | for(uint8_t i=16;i<132;i++) |
lakshya | 10:f93407b97750 | 444 | { |
Bragadeesh153 | 13:fb7facaf308b | 445 | telemetry[i]=0x00; |
lakshya | 10:f93407b97750 | 446 | } |
Bragadeesh153 | 13:fb7facaf308b | 447 | |
Bragadeesh153 | 13:fb7facaf308b | 448 | crc16 = CRC::crc16_gen(telemetry,132); |
Bragadeesh153 | 13:fb7facaf308b | 449 | telemetry[133] = (uint8_t)((crc16&0xFF00)>>8); |
Bragadeesh153 | 13:fb7facaf308b | 450 | telemetry[134] = (uint8_t)(crc16&0x00FF); |
Bragadeesh153 | 13:fb7facaf308b | 451 | break; |
sakthipriya | 3:07e15677a75c | 452 | } |
lakshya | 10:f93407b97750 | 453 | case 0xE1: |
sakthipriya | 3:07e15677a75c | 454 | { |
Bragadeesh153 | 13:fb7facaf308b | 455 | float moment_tc[3]; |
lakshya | 10:f93407b97750 | 456 | printf("HARDWARE_COMSN\r\n"); |
Bragadeesh153 | 13:fb7facaf308b | 457 | //ACK_L234_telemetry |
lakshya | 10:f93407b97750 | 458 | uint8_t M0[2]; |
lakshya | 10:f93407b97750 | 459 | uint8_t M1[2]; |
lakshya | 10:f93407b97750 | 460 | uint8_t M2[2]; |
Bragadeesh153 | 13:fb7facaf308b | 461 | |
lakshya | 10:f93407b97750 | 462 | M0[0]=tc[3]; |
lakshya | 10:f93407b97750 | 463 | M0[1]=tc[4]; |
lakshya | 10:f93407b97750 | 464 | M1[0]=tc[5]; |
lakshya | 10:f93407b97750 | 465 | M1[1]=tc[6]; |
lakshya | 10:f93407b97750 | 466 | M2[0]=tc[7]; |
lakshya | 10:f93407b97750 | 467 | M2[1]=tc[8]; |
Bragadeesh153 | 13:fb7facaf308b | 468 | |
Bragadeesh153 | 13:fb7facaf308b | 469 | |
Bragadeesh153 | 13:fb7facaf308b | 470 | telemetry[0]=0xB0; |
Bragadeesh153 | 13:fb7facaf308b | 471 | telemetry[1]=tc[0]; |
Bragadeesh153 | 13:fb7facaf308b | 472 | telemetry[2]=ACK_CODE; |
lakshya | 10:f93407b97750 | 473 | |
Bragadeesh153 | 13:fb7facaf308b | 474 | float PWM_measured[3]; |
lakshya | 10:f93407b97750 | 475 | |
lakshya | 10:f93407b97750 | 476 | |
Bragadeesh153 | 13:fb7facaf308b | 477 | FCTN_CONVERT_UINT(M0,&moment_tc[0]); |
Bragadeesh153 | 13:fb7facaf308b | 478 | moment_tc[1] = 0; |
Bragadeesh153 | 13:fb7facaf308b | 479 | moment_tc[2] = 0; |
Bragadeesh153 | 13:fb7facaf308b | 480 | FCTN_ACS_GENPWM_MAIN(moment_tc); |
Bragadeesh153 | 13:fb7facaf308b | 481 | PWM_measured[0] = PWM1.read(); |
Bragadeesh153 | 13:fb7facaf308b | 482 | FCTN_CONVERT_FLOAT(actual_data.current_actual[i],&telemetry[16 + (0*4)]); |
lakshya | 10:f93407b97750 | 483 | |
Bragadeesh153 | 13:fb7facaf308b | 484 | FCTN_CONVERT_UINT(M1, &moment_tc[1]); |
Bragadeesh153 | 13:fb7facaf308b | 485 | moment_tc[0] = 0; |
Bragadeesh153 | 13:fb7facaf308b | 486 | moment_tc[2] = 0; |
Bragadeesh153 | 13:fb7facaf308b | 487 | FCTN_ACS_GENPWM_MAIN(moment_tc); |
Bragadeesh153 | 13:fb7facaf308b | 488 | PWM_measured[1] = PWM2.read(); |
Bragadeesh153 | 13:fb7facaf308b | 489 | FCTN_CONVERT_FLOAT(actual_data.current_actual[i],&telemetry[16 + (1*4)]); |
Bragadeesh153 | 13:fb7facaf308b | 490 | |
Bragadeesh153 | 13:fb7facaf308b | 491 | FCTN_CONVERT_UINT(M2, &moment_tc[2]); |
Bragadeesh153 | 13:fb7facaf308b | 492 | moment_tc[0] = 0; |
Bragadeesh153 | 13:fb7facaf308b | 493 | moment_tc[1] = 0; |
Bragadeesh153 | 13:fb7facaf308b | 494 | FCTN_ACS_GENPWM_MAIN(moment_tc); |
Bragadeesh153 | 13:fb7facaf308b | 495 | PWM_measured[2] = PWM3.read(); |
Bragadeesh153 | 13:fb7facaf308b | 496 | FCTN_CONVERT_FLOAT(actual_data.current_actual[i],&telemetry[16 + (2*4)]); |
lakshya | 10:f93407b97750 | 497 | |
Bragadeesh153 | 13:fb7facaf308b | 498 | FCTN_CONVERT_FLOAT(PWM_measured[0],&telemetry[4]); //4-7 |
Bragadeesh153 | 13:fb7facaf308b | 499 | FCTN_CONVERT_FLOAT(PWM_measured[1],&telemetry[8]); //8-11 |
Bragadeesh153 | 13:fb7facaf308b | 500 | FCTN_CONVERT_FLOAT(PWM_measured[2],&telemetry[12]); //12-15 |
Bragadeesh153 | 13:fb7facaf308b | 501 | |
lakshya | 10:f93407b97750 | 502 | |
Bragadeesh153 | 13:fb7facaf308b | 503 | // for(int i=0; i<12; i++) |
Bragadeesh153 | 13:fb7facaf308b | 504 | // FCTN_CONVERT_FLOAT(actual_data.current_actual[i],&telemetry[16 + (i*4)]); |
lakshya | 10:f93407b97750 | 505 | |
Bragadeesh153 | 13:fb7facaf308b | 506 | |
Bragadeesh153 | 13:fb7facaf308b | 507 | // FCTN_ATS_DATA_ACQ(); //get data |
Bragadeesh153 | 13:fb7facaf308b | 508 | |
lakshya | 10:f93407b97750 | 509 | |
lakshya | 10:f93407b97750 | 510 | // to include commission TR as well |
Bragadeesh153 | 13:fb7facaf308b | 511 | for(uint8_t i=28;i<132;i++) |
lakshya | 10:f93407b97750 | 512 | { |
Bragadeesh153 | 13:fb7facaf308b | 513 | telemetry[i]=0x00; |
lakshya | 10:f93407b97750 | 514 | } |
Bragadeesh153 | 13:fb7facaf308b | 515 | |
Bragadeesh153 | 13:fb7facaf308b | 516 | crc16 = CRC::crc16_gen(telemetry,132); |
Bragadeesh153 | 13:fb7facaf308b | 517 | telemetry[133] = (uint8_t)((crc16&0xFF00)>>8); |
Bragadeesh153 | 13:fb7facaf308b | 518 | telemetry[134] = (uint8_t)(crc16&0x00FF); |
Bragadeesh153 | 13:fb7facaf308b | 519 | break; |
lakshya | 10:f93407b97750 | 520 | } |
Bragadeesh153 | 13:fb7facaf308b | 521 | case 0x02: |
lakshya | 10:f93407b97750 | 522 | { |
Bragadeesh153 | 13:fb7facaf308b | 523 | |
Bragadeesh153 | 13:fb7facaf308b | 524 | printf("Run P_EPS_MAIN\r\n"); |
Bragadeesh153 | 13:fb7facaf308b | 525 | F_EPS(); |
Bragadeesh153 | 13:fb7facaf308b | 526 | //ACK_L234_telemetry |
Bragadeesh153 | 13:fb7facaf308b | 527 | telemetry[0]=0xB0; |
Bragadeesh153 | 13:fb7facaf308b | 528 | telemetry[1]=tc[0]; |
Bragadeesh153 | 13:fb7facaf308b | 529 | telemetry[2]=ACK_CODE; |
lakshya | 10:f93407b97750 | 530 | for(uint8_t i=0;i<133;i++) |
sakthipriya | 3:07e15677a75c | 531 | { |
Bragadeesh153 | 13:fb7facaf308b | 532 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 533 | } |
Bragadeesh153 | 13:fb7facaf308b | 534 | crc16 = CRC::crc16_gen(telemetry,132); |
Bragadeesh153 | 13:fb7facaf308b | 535 | telemetry[132] = (uint8_t)((crc16&0xFF00)>>8); |
Bragadeesh153 | 13:fb7facaf308b | 536 | telemetry[133] = (uint8_t)(crc16&0x00FF); |
Bragadeesh153 | 13:fb7facaf308b | 537 | |
sakthipriya | 3:07e15677a75c | 538 | for(uint8_t i=13;i<134;i++) |
sakthipriya | 3:07e15677a75c | 539 | { |
Bragadeesh153 | 13:fb7facaf308b | 540 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 541 | } |
Bragadeesh153 | 13:fb7facaf308b | 542 | break; |
sakthipriya | 3:07e15677a75c | 543 | } |
Bragadeesh153 | 13:fb7facaf308b | 544 | case 0x03: |
sakthipriya | 3:07e15677a75c | 545 | { |
Bragadeesh153 | 13:fb7facaf308b | 546 | printf("Run P_ACS_INIT\r\n"); |
Bragadeesh153 | 13:fb7facaf308b | 547 | FCTN_ACS_INIT(); |
Bragadeesh153 | 13:fb7facaf308b | 548 | //ACK_L234_telemetry |
Bragadeesh153 | 13:fb7facaf308b | 549 | telemetry[0]=0xB0; |
Bragadeesh153 | 13:fb7facaf308b | 550 | telemetry[1]=tc[0]; |
Bragadeesh153 | 13:fb7facaf308b | 551 | telemetry[2]=ACK_CODE; |
sakthipriya | 3:07e15677a75c | 552 | for(uint8_t i=3;i<11;i++) |
sakthipriya | 3:07e15677a75c | 553 | { |
Bragadeesh153 | 13:fb7facaf308b | 554 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 555 | } |
Bragadeesh153 | 13:fb7facaf308b | 556 | crc16 = CRC::crc16_gen(telemetry,11); |
Bragadeesh153 | 13:fb7facaf308b | 557 | telemetry[11] = (uint8_t)((crc16&0xFF00)>>8); |
Bragadeesh153 | 13:fb7facaf308b | 558 | telemetry[12] = (uint8_t)(crc16&0x00FF); |
sakthipriya | 3:07e15677a75c | 559 | for(uint8_t i=13;i<134;i++) |
sakthipriya | 3:07e15677a75c | 560 | { |
Bragadeesh153 | 13:fb7facaf308b | 561 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 562 | } |
Bragadeesh153 | 13:fb7facaf308b | 563 | break; |
sakthipriya | 3:07e15677a75c | 564 | } |
sakthipriya | 3:07e15677a75c | 565 | case 0x04: |
sakthipriya | 3:07e15677a75c | 566 | { |
Bragadeesh153 | 13:fb7facaf308b | 567 | |
sakthipriya | 3:07e15677a75c | 568 | printf("Run P_ACS_ACQ_DATA\r\n"); |
Bragadeesh153 | 13:fb7facaf308b | 569 | FCTN_ATS_DATA_ACQ(); |
sakthipriya | 3:07e15677a75c | 570 | //ACK_L234_TM |
Bragadeesh153 | 13:fb7facaf308b | 571 | telemetry[0]=0xB0; |
Bragadeesh153 | 13:fb7facaf308b | 572 | telemetry[1]=tc[0]; |
Bragadeesh153 | 13:fb7facaf308b | 573 | telemetry[2]=ACK_CODE; |
sakthipriya | 3:07e15677a75c | 574 | for(uint8_t i=3;i<11;i++) |
sakthipriya | 3:07e15677a75c | 575 | { |
Bragadeesh153 | 13:fb7facaf308b | 576 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 577 | } |
Bragadeesh153 | 13:fb7facaf308b | 578 | crc16 = CRC::crc16_gen(telemetry,11); |
Bragadeesh153 | 13:fb7facaf308b | 579 | telemetry[11] = (uint8_t)((crc16&0xFF00)>>8); |
Bragadeesh153 | 13:fb7facaf308b | 580 | telemetry[12] = (uint8_t)(crc16&0x00FF); |
sakthipriya | 3:07e15677a75c | 581 | for(uint8_t i=13;i<134;i++) |
sakthipriya | 3:07e15677a75c | 582 | { |
Bragadeesh153 | 13:fb7facaf308b | 583 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 584 | } |
Bragadeesh153 | 13:fb7facaf308b | 585 | break; |
sakthipriya | 3:07e15677a75c | 586 | } |
sakthipriya | 3:07e15677a75c | 587 | case 0x05: |
sakthipriya | 3:07e15677a75c | 588 | { |
sakthipriya | 3:07e15677a75c | 589 | printf("Run P_ACS_MAIN\r\n"); |
lakshya | 10:f93407b97750 | 590 | F_ACS(); |
Bragadeesh153 | 13:fb7facaf308b | 591 | for(int i=0; i<3; i++) |
Bragadeesh153 | 13:fb7facaf308b | 592 | FCTN_CONVERT_FLOAT(actual_data.Bvalue_actual[i],&telemetry[(i*4)]); |
lakshya | 10:f93407b97750 | 593 | for(int i=0; i<3; i++) |
Bragadeesh153 | 13:fb7facaf308b | 594 | FCTN_CONVERT_FLOAT(actual_data.AngularSpeed_actual[i],&telemetry[12+(i*4)]); |
Bragadeesh153 | 13:fb7facaf308b | 595 | |
Bragadeesh153 | 13:fb7facaf308b | 596 | telemetry[24] = ACS_STATE; |
Bragadeesh153 | 13:fb7facaf308b | 597 | telemetry[24] = telemetry[5]|(EN_BTRY_HT<<3); |
Bragadeesh153 | 13:fb7facaf308b | 598 | telemetry[24] = telemetry[5]|(phase_TR_x<<4); |
Bragadeesh153 | 13:fb7facaf308b | 599 | telemetry[24] = telemetry[5]|(phase_TR_y<<5); |
Bragadeesh153 | 13:fb7facaf308b | 600 | telemetry[24] = telemetry[5]|(phase_TR_z<<6); |
Bragadeesh153 | 13:fb7facaf308b | 601 | |
lakshya | 11:1fdb94ae6563 | 602 | /*___________________change / check pwm working__________________________________*/ |
Bragadeesh153 | 13:fb7facaf308b | 603 | |
Bragadeesh153 | 13:fb7facaf308b | 604 | FCTN_CONVERT_FLOAT(PWM1,&telemetry[25]); |
Bragadeesh153 | 13:fb7facaf308b | 605 | FCTN_CONVERT_FLOAT(PWM2,&telemetry[29]); |
Bragadeesh153 | 13:fb7facaf308b | 606 | FCTN_CONVERT_FLOAT(PWM3,&telemetry[33]); |
Bragadeesh153 | 13:fb7facaf308b | 607 | |
lakshya | 10:f93407b97750 | 608 | //ACK_L234_TM |
Bragadeesh153 | 13:fb7facaf308b | 609 | telemetry[0]=0xB0; |
Bragadeesh153 | 13:fb7facaf308b | 610 | telemetry[1]=tc[0]; |
Bragadeesh153 | 13:fb7facaf308b | 611 | telemetry[2]=ACK_CODE; |
lakshya | 10:f93407b97750 | 612 | for(uint8_t i=3;i<11;i++) |
lakshya | 10:f93407b97750 | 613 | { |
Bragadeesh153 | 13:fb7facaf308b | 614 | telemetry[i]=0x00; |
lakshya | 10:f93407b97750 | 615 | } |
Bragadeesh153 | 13:fb7facaf308b | 616 | |
Bragadeesh153 | 13:fb7facaf308b | 617 | crc16 = CRC::crc16_gen(telemetry,37); |
Bragadeesh153 | 13:fb7facaf308b | 618 | telemetry[37] = (uint8_t)((crc16&0xFF00)>>8); |
Bragadeesh153 | 13:fb7facaf308b | 619 | telemetry[38] = (uint8_t)(crc16&0x00FF); |
lakshya | 10:f93407b97750 | 620 | for(uint8_t i=39;i<134;i++) |
lakshya | 10:f93407b97750 | 621 | { |
Bragadeesh153 | 13:fb7facaf308b | 622 | telemetry[i]=0x00; |
lakshya | 10:f93407b97750 | 623 | } |
Bragadeesh153 | 13:fb7facaf308b | 624 | break; |
lakshya | 10:f93407b97750 | 625 | } |
lakshya | 10:f93407b97750 | 626 | case 0x06: |
lakshya | 10:f93407b97750 | 627 | { |
lakshya | 10:f93407b97750 | 628 | F_BCN(); |
Bragadeesh153 | 13:fb7facaf308b | 629 | printf("Run P_BCN_INIT\r\n"); |
sakthipriya | 3:07e15677a75c | 630 | //ACK_L234_TM |
Bragadeesh153 | 13:fb7facaf308b | 631 | telemetry[0]=0xB0; |
Bragadeesh153 | 13:fb7facaf308b | 632 | telemetry[1]=tc[0]; |
Bragadeesh153 | 13:fb7facaf308b | 633 | telemetry[2]=ACK_CODE; |
sakthipriya | 3:07e15677a75c | 634 | for(uint8_t i=3;i<11;i++) |
sakthipriya | 3:07e15677a75c | 635 | { |
Bragadeesh153 | 13:fb7facaf308b | 636 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 637 | } |
Bragadeesh153 | 13:fb7facaf308b | 638 | crc16 = CRC::crc16_gen(telemetry,0); |
Bragadeesh153 | 13:fb7facaf308b | 639 | telemetry[0] = (uint8_t)((crc16&0xFF00)>>8); |
Bragadeesh153 | 13:fb7facaf308b | 640 | telemetry[1] = (uint8_t)(crc16&0x00FF); |
lakshya | 10:f93407b97750 | 641 | for(uint8_t i=2;i<134;i++) |
sakthipriya | 3:07e15677a75c | 642 | { |
Bragadeesh153 | 13:fb7facaf308b | 643 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 644 | } |
Bragadeesh153 | 13:fb7facaf308b | 645 | break; |
sakthipriya | 3:07e15677a75c | 646 | } |
sakthipriya | 3:07e15677a75c | 647 | case 0x07: |
sakthipriya | 3:07e15677a75c | 648 | { |
Bragadeesh153 | 13:fb7facaf308b | 649 | printf("Run P_BCN_TX_MAIN\r\n"); |
sakthipriya | 3:07e15677a75c | 650 | //ACK_L234_TM |
Bragadeesh153 | 13:fb7facaf308b | 651 | telemetry[0]=0xB0; |
Bragadeesh153 | 13:fb7facaf308b | 652 | telemetry[1]=tc[0]; |
Bragadeesh153 | 13:fb7facaf308b | 653 | telemetry[2]=ACK_CODE; |
sakthipriya | 3:07e15677a75c | 654 | for(uint8_t i=3;i<11;i++) |
sakthipriya | 3:07e15677a75c | 655 | { |
Bragadeesh153 | 13:fb7facaf308b | 656 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 657 | } |
Bragadeesh153 | 13:fb7facaf308b | 658 | crc16 = CRC::crc16_gen(telemetry,11); |
Bragadeesh153 | 13:fb7facaf308b | 659 | telemetry[11] = (uint8_t)((crc16&0xFF00)>>8); |
Bragadeesh153 | 13:fb7facaf308b | 660 | telemetry[12] = (uint8_t)(crc16&0x00FF); |
sakthipriya | 3:07e15677a75c | 661 | for(uint8_t i=13;i<134;i++) |
sakthipriya | 3:07e15677a75c | 662 | { |
Bragadeesh153 | 13:fb7facaf308b | 663 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 664 | } |
Bragadeesh153 | 13:fb7facaf308b | 665 | break; |
Bragadeesh153 | 13:fb7facaf308b | 666 | } |
Bragadeesh153 | 13:fb7facaf308b | 667 | case 0x11: |
sakthipriya | 3:07e15677a75c | 668 | { |
sakthipriya | 3:07e15677a75c | 669 | printf("SW_ON_ACS_ATS1_SW_ENABLE\r\n"); |
sakthipriya | 3:07e15677a75c | 670 | //ACK_L234_TM |
Bragadeesh153 | 13:fb7facaf308b | 671 | telemetry[0]=0xB0; |
Bragadeesh153 | 13:fb7facaf308b | 672 | telemetry[1]=tc[0]; |
Bragadeesh153 | 13:fb7facaf308b | 673 | telemetry[2]=1; |
lakshya | 10:f93407b97750 | 674 | ATS1_SW_ENABLE = 1; // making sure we switch off the other |
sakthipriya | 9:194afacf7449 | 675 | ATS1_SW_ENABLE = 0; |
sakthipriya | 3:07e15677a75c | 676 | for(uint8_t i=3;i<11;i++) |
sakthipriya | 3:07e15677a75c | 677 | { |
Bragadeesh153 | 13:fb7facaf308b | 678 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 679 | } |
Bragadeesh153 | 13:fb7facaf308b | 680 | crc16 = CRC::crc16_gen(telemetry,11); |
Bragadeesh153 | 13:fb7facaf308b | 681 | telemetry[11] = (uint8_t)((crc16&0xFF00)>>8); |
Bragadeesh153 | 13:fb7facaf308b | 682 | telemetry[12] = (uint8_t)(crc16&0x00FF); |
sakthipriya | 3:07e15677a75c | 683 | for(uint8_t i=13;i<134;i++) |
sakthipriya | 3:07e15677a75c | 684 | { |
Bragadeesh153 | 13:fb7facaf308b | 685 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 686 | } |
Bragadeesh153 | 13:fb7facaf308b | 687 | break; |
sakthipriya | 3:07e15677a75c | 688 | } |
sakthipriya | 3:07e15677a75c | 689 | case 0x12: |
sakthipriya | 3:07e15677a75c | 690 | { |
sakthipriya | 3:07e15677a75c | 691 | printf("SW_ON_ACS_ATS2_SW_ENABLE\r\n"); |
sakthipriya | 3:07e15677a75c | 692 | //ACK_L234_TM |
Bragadeesh153 | 13:fb7facaf308b | 693 | telemetry[0]=0xB0; |
Bragadeesh153 | 13:fb7facaf308b | 694 | telemetry[1]=tc[0]; |
lakshya | 10:f93407b97750 | 695 | ATS1_SW_ENABLE = 1; //make sure u switch off the other |
sakthipriya | 9:194afacf7449 | 696 | ATS2_SW_ENABLE = 0; |
Bragadeesh153 | 13:fb7facaf308b | 697 | telemetry[2]=1; |
sakthipriya | 3:07e15677a75c | 698 | for(uint8_t i=3;i<11;i++) |
sakthipriya | 3:07e15677a75c | 699 | { |
Bragadeesh153 | 13:fb7facaf308b | 700 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 701 | } |
Bragadeesh153 | 13:fb7facaf308b | 702 | crc16 = CRC::crc16_gen(telemetry,11); |
Bragadeesh153 | 13:fb7facaf308b | 703 | telemetry[11] = (uint8_t)((crc16&0xFF00)>>8); |
Bragadeesh153 | 13:fb7facaf308b | 704 | telemetry[12] = (uint8_t)(crc16&0x00FF); |
sakthipriya | 3:07e15677a75c | 705 | for(uint8_t i=13;i<134;i++) |
sakthipriya | 3:07e15677a75c | 706 | { |
Bragadeesh153 | 13:fb7facaf308b | 707 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 708 | } |
Bragadeesh153 | 13:fb7facaf308b | 709 | break; |
sakthipriya | 3:07e15677a75c | 710 | } |
sakthipriya | 3:07e15677a75c | 711 | case 0x13: |
sakthipriya | 3:07e15677a75c | 712 | { |
sakthipriya | 3:07e15677a75c | 713 | printf("SW_ON_ACS_TR_XY_ENABLE\r\n"); |
sakthipriya | 3:07e15677a75c | 714 | //ACK_L234_TM |
Bragadeesh153 | 13:fb7facaf308b | 715 | telemetry[0]=0xB0; |
Bragadeesh153 | 13:fb7facaf308b | 716 | telemetry[1]=tc[0]; |
Bragadeesh153 | 13:fb7facaf308b | 717 | TRXY_SW = 1; |
Bragadeesh153 | 13:fb7facaf308b | 718 | telemetry[2]=1; |
sakthipriya | 3:07e15677a75c | 719 | for(uint8_t i=3;i<11;i++) |
sakthipriya | 3:07e15677a75c | 720 | { |
Bragadeesh153 | 13:fb7facaf308b | 721 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 722 | } |
Bragadeesh153 | 13:fb7facaf308b | 723 | crc16 = CRC::crc16_gen(telemetry,11); |
Bragadeesh153 | 13:fb7facaf308b | 724 | telemetry[11] = (uint8_t)((crc16&0xFF00)>>8); |
Bragadeesh153 | 13:fb7facaf308b | 725 | telemetry[12] = (uint8_t)(crc16&0x00FF); |
sakthipriya | 3:07e15677a75c | 726 | for(uint8_t i=13;i<134;i++) |
sakthipriya | 3:07e15677a75c | 727 | { |
Bragadeesh153 | 13:fb7facaf308b | 728 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 729 | } |
Bragadeesh153 | 13:fb7facaf308b | 730 | break; |
sakthipriya | 3:07e15677a75c | 731 | } |
sakthipriya | 3:07e15677a75c | 732 | case 0x14: |
sakthipriya | 3:07e15677a75c | 733 | { |
sakthipriya | 3:07e15677a75c | 734 | printf("SW_ON_ACS_TR_Z_ENABLE\r\n"); |
sakthipriya | 3:07e15677a75c | 735 | //ACK_L234_TM |
Bragadeesh153 | 13:fb7facaf308b | 736 | telemetry[0]=0xB0; |
Bragadeesh153 | 13:fb7facaf308b | 737 | telemetry[1]=tc[0]; |
Bragadeesh153 | 13:fb7facaf308b | 738 | telemetry[2]=1; |
sakthipriya | 5:bb592f3185cc | 739 | TRZ_SW = 1; |
sakthipriya | 3:07e15677a75c | 740 | for(uint8_t i=3;i<11;i++) |
sakthipriya | 3:07e15677a75c | 741 | { |
Bragadeesh153 | 13:fb7facaf308b | 742 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 743 | } |
Bragadeesh153 | 13:fb7facaf308b | 744 | crc16 = CRC::crc16_gen(telemetry,11); |
Bragadeesh153 | 13:fb7facaf308b | 745 | telemetry[11] = (uint8_t)((crc16&0xFF00)>>8); |
Bragadeesh153 | 13:fb7facaf308b | 746 | telemetry[12] = (uint8_t)(crc16&0x00FF); |
sakthipriya | 3:07e15677a75c | 747 | for(uint8_t i=13;i<134;i++) |
sakthipriya | 3:07e15677a75c | 748 | { |
Bragadeesh153 | 13:fb7facaf308b | 749 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 750 | } |
Bragadeesh153 | 13:fb7facaf308b | 751 | break; |
sakthipriya | 3:07e15677a75c | 752 | } |
Bragadeesh153 | 13:fb7facaf308b | 753 | case 0x15: |
sakthipriya | 3:07e15677a75c | 754 | { |
sakthipriya | 3:07e15677a75c | 755 | printf("SW_ON_BCN_TX_SW_ENABLE\r\n"); |
sakthipriya | 3:07e15677a75c | 756 | //ACK_L234_TM |
Bragadeesh153 | 13:fb7facaf308b | 757 | telemetry[0]=0xB0; |
Bragadeesh153 | 13:fb7facaf308b | 758 | telemetry[1]=tc[0]; |
Bragadeesh153 | 13:fb7facaf308b | 759 | telemetry[2]=1; |
Bragadeesh153 | 13:fb7facaf308b | 760 | BCN_SW = 0; |
sakthipriya | 3:07e15677a75c | 761 | for(uint8_t i=3;i<11;i++) |
sakthipriya | 3:07e15677a75c | 762 | { |
Bragadeesh153 | 13:fb7facaf308b | 763 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 764 | } |
Bragadeesh153 | 13:fb7facaf308b | 765 | crc16 = CRC::crc16_gen(telemetry,11); |
Bragadeesh153 | 13:fb7facaf308b | 766 | telemetry[11] = (uint8_t)((crc16&0xFF00)>>8); |
Bragadeesh153 | 13:fb7facaf308b | 767 | telemetry[12] = (uint8_t)(crc16&0x00FF); |
sakthipriya | 3:07e15677a75c | 768 | for(uint8_t i=13;i<134;i++) |
sakthipriya | 3:07e15677a75c | 769 | { |
Bragadeesh153 | 13:fb7facaf308b | 770 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 771 | } |
Bragadeesh153 | 13:fb7facaf308b | 772 | break; |
sakthipriya | 3:07e15677a75c | 773 | } |
sakthipriya | 3:07e15677a75c | 774 | case 0x21: |
sakthipriya | 3:07e15677a75c | 775 | { |
sakthipriya | 3:07e15677a75c | 776 | printf("SW_OFF_ACS_ATS1_SW_ENABLE\r\n"); |
sakthipriya | 3:07e15677a75c | 777 | //ACK_L234_TM |
Bragadeesh153 | 13:fb7facaf308b | 778 | telemetry[0]=0xB0; |
Bragadeesh153 | 13:fb7facaf308b | 779 | telemetry[1]=tc[0]; |
Bragadeesh153 | 13:fb7facaf308b | 780 | telemetry[2]=1; |
sakthipriya | 9:194afacf7449 | 781 | ATS1_SW_ENABLE = 1; |
sakthipriya | 3:07e15677a75c | 782 | for(uint8_t i=3;i<11;i++) |
sakthipriya | 3:07e15677a75c | 783 | { |
Bragadeesh153 | 13:fb7facaf308b | 784 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 785 | } |
Bragadeesh153 | 13:fb7facaf308b | 786 | crc16 = CRC::crc16_gen(telemetry,11); |
Bragadeesh153 | 13:fb7facaf308b | 787 | telemetry[11] = (uint8_t)((crc16&0xFF00)>>8); |
Bragadeesh153 | 13:fb7facaf308b | 788 | telemetry[12] = (uint8_t)(crc16&0x00FF); |
sakthipriya | 3:07e15677a75c | 789 | for(uint8_t i=13;i<134;i++) |
sakthipriya | 3:07e15677a75c | 790 | { |
Bragadeesh153 | 13:fb7facaf308b | 791 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 792 | } |
Bragadeesh153 | 13:fb7facaf308b | 793 | break; |
sakthipriya | 3:07e15677a75c | 794 | } |
sakthipriya | 3:07e15677a75c | 795 | case 0x22: |
sakthipriya | 3:07e15677a75c | 796 | { |
sakthipriya | 3:07e15677a75c | 797 | printf("SW_OFF_ACS_ATS2_SW_ENABLE\r\n"); |
sakthipriya | 3:07e15677a75c | 798 | //ACK_L234_TM |
Bragadeesh153 | 13:fb7facaf308b | 799 | telemetry[0]=0xB0; |
Bragadeesh153 | 13:fb7facaf308b | 800 | telemetry[1]=tc[0]; |
Bragadeesh153 | 13:fb7facaf308b | 801 | telemetry[2]=1; |
sakthipriya | 9:194afacf7449 | 802 | ATS2_SW_ENABLE = 1; |
sakthipriya | 3:07e15677a75c | 803 | for(uint8_t i=3;i<11;i++) |
sakthipriya | 3:07e15677a75c | 804 | { |
Bragadeesh153 | 13:fb7facaf308b | 805 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 806 | } |
Bragadeesh153 | 13:fb7facaf308b | 807 | crc16 = CRC::crc16_gen(telemetry,11); |
Bragadeesh153 | 13:fb7facaf308b | 808 | telemetry[11] = (uint8_t)((crc16&0xFF00)>>8); |
Bragadeesh153 | 13:fb7facaf308b | 809 | telemetry[12] = (uint8_t)(crc16&0x00FF); |
sakthipriya | 3:07e15677a75c | 810 | for(uint8_t i=13;i<134;i++) |
sakthipriya | 3:07e15677a75c | 811 | { |
Bragadeesh153 | 13:fb7facaf308b | 812 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 813 | } |
Bragadeesh153 | 13:fb7facaf308b | 814 | break; |
sakthipriya | 3:07e15677a75c | 815 | } |
sakthipriya | 3:07e15677a75c | 816 | case 0x23: |
sakthipriya | 3:07e15677a75c | 817 | { |
sakthipriya | 3:07e15677a75c | 818 | printf("SW_OFF_ACS_TR_XY_ENABLE\r\n"); |
sakthipriya | 3:07e15677a75c | 819 | //ACK_L234_TM |
Bragadeesh153 | 13:fb7facaf308b | 820 | telemetry[0]=0xB0; |
Bragadeesh153 | 13:fb7facaf308b | 821 | telemetry[1]=tc[0]; |
Bragadeesh153 | 13:fb7facaf308b | 822 | telemetry[2]=1; |
Bragadeesh153 | 13:fb7facaf308b | 823 | TRXY_SW= 0; |
sakthipriya | 3:07e15677a75c | 824 | for(uint8_t i=3;i<11;i++) |
sakthipriya | 3:07e15677a75c | 825 | { |
Bragadeesh153 | 13:fb7facaf308b | 826 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 827 | } |
Bragadeesh153 | 13:fb7facaf308b | 828 | crc16 = CRC::crc16_gen(telemetry,11); |
Bragadeesh153 | 13:fb7facaf308b | 829 | telemetry[11] = (uint8_t)((crc16&0xFF00)>>8); |
Bragadeesh153 | 13:fb7facaf308b | 830 | telemetry[12] = (uint8_t)(crc16&0x00FF); |
sakthipriya | 3:07e15677a75c | 831 | for(uint8_t i=13;i<134;i++) |
sakthipriya | 3:07e15677a75c | 832 | { |
Bragadeesh153 | 13:fb7facaf308b | 833 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 834 | } |
Bragadeesh153 | 13:fb7facaf308b | 835 | break; |
sakthipriya | 3:07e15677a75c | 836 | } |
sakthipriya | 3:07e15677a75c | 837 | case 0x24: |
sakthipriya | 3:07e15677a75c | 838 | { |
sakthipriya | 3:07e15677a75c | 839 | printf("SW_OFF_ACS_TR_Z_ENABLE\r\n"); |
sakthipriya | 3:07e15677a75c | 840 | //ACK_L234_TM |
Bragadeesh153 | 13:fb7facaf308b | 841 | telemetry[0]=0xB0; |
Bragadeesh153 | 13:fb7facaf308b | 842 | telemetry[1]=tc[0]; |
Bragadeesh153 | 13:fb7facaf308b | 843 | telemetry[2]=1; |
sakthipriya | 5:bb592f3185cc | 844 | TRZ_SW = 0; |
sakthipriya | 3:07e15677a75c | 845 | for(uint8_t i=3;i<11;i++) |
sakthipriya | 3:07e15677a75c | 846 | { |
Bragadeesh153 | 13:fb7facaf308b | 847 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 848 | } |
Bragadeesh153 | 13:fb7facaf308b | 849 | crc16 = CRC::crc16_gen(telemetry,11); |
Bragadeesh153 | 13:fb7facaf308b | 850 | telemetry[11] = (uint8_t)((crc16&0xFF00)>>8); |
Bragadeesh153 | 13:fb7facaf308b | 851 | telemetry[12] = (uint8_t)(crc16&0x00FF); |
sakthipriya | 3:07e15677a75c | 852 | for(uint8_t i=13;i<134;i++) |
sakthipriya | 3:07e15677a75c | 853 | { |
Bragadeesh153 | 13:fb7facaf308b | 854 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 855 | } |
Bragadeesh153 | 13:fb7facaf308b | 856 | break; |
sakthipriya | 3:07e15677a75c | 857 | } |
Bragadeesh153 | 13:fb7facaf308b | 858 | case 0x25: |
sakthipriya | 3:07e15677a75c | 859 | { |
sakthipriya | 3:07e15677a75c | 860 | printf("SW_OFF_BCN_TX_SW_ENABLE\r\n"); |
sakthipriya | 3:07e15677a75c | 861 | //ACK_L234_TM |
Bragadeesh153 | 13:fb7facaf308b | 862 | telemetry[0]=0xB0; |
Bragadeesh153 | 13:fb7facaf308b | 863 | telemetry[1]=tc[0]; |
Bragadeesh153 | 13:fb7facaf308b | 864 | telemetry[2]=1; |
sakthipriya | 5:bb592f3185cc | 865 | BCN_SW = 1; |
sakthipriya | 3:07e15677a75c | 866 | for(uint8_t i=3;i<11;i++) |
sakthipriya | 3:07e15677a75c | 867 | { |
Bragadeesh153 | 13:fb7facaf308b | 868 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 869 | } |
Bragadeesh153 | 13:fb7facaf308b | 870 | crc16 = CRC::crc16_gen(telemetry,11); |
Bragadeesh153 | 13:fb7facaf308b | 871 | telemetry[11] = (uint8_t)((crc16&0xFF00)>>8); |
Bragadeesh153 | 13:fb7facaf308b | 872 | telemetry[12] = (uint8_t)(crc16&0x00FF); |
sakthipriya | 3:07e15677a75c | 873 | for(uint8_t i=13;i<134;i++) |
sakthipriya | 3:07e15677a75c | 874 | { |
Bragadeesh153 | 13:fb7facaf308b | 875 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 876 | } |
Bragadeesh153 | 13:fb7facaf308b | 877 | break; |
sakthipriya | 3:07e15677a75c | 878 | } |
sakthipriya | 3:07e15677a75c | 879 | case 0x31: |
sakthipriya | 3:07e15677a75c | 880 | { |
sakthipriya | 5:bb592f3185cc | 881 | printf("ACS_ATS1_SW_RESET\r\n"); |
sakthipriya | 3:07e15677a75c | 882 | //ACK_L234_TM |
Bragadeesh153 | 13:fb7facaf308b | 883 | telemetry[0]=0xB0; |
Bragadeesh153 | 13:fb7facaf308b | 884 | telemetry[1]=tc[0]; |
Bragadeesh153 | 13:fb7facaf308b | 885 | telemetry[2]=1; |
sakthipriya | 9:194afacf7449 | 886 | ATS1_SW_ENABLE = 1; |
sakthipriya | 5:bb592f3185cc | 887 | wait_us(1); |
sakthipriya | 9:194afacf7449 | 888 | ATS1_SW_ENABLE = 0; |
sakthipriya | 3:07e15677a75c | 889 | for(uint8_t i=3;i<11;i++) |
sakthipriya | 3:07e15677a75c | 890 | { |
Bragadeesh153 | 13:fb7facaf308b | 891 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 892 | } |
Bragadeesh153 | 13:fb7facaf308b | 893 | crc16 = CRC::crc16_gen(telemetry,11); |
Bragadeesh153 | 13:fb7facaf308b | 894 | telemetry[11] = (uint8_t)((crc16&0xFF00)>>8); |
Bragadeesh153 | 13:fb7facaf308b | 895 | telemetry[12] = (uint8_t)(crc16&0x00FF); |
sakthipriya | 3:07e15677a75c | 896 | for(uint8_t i=13;i<134;i++) |
sakthipriya | 3:07e15677a75c | 897 | { |
Bragadeesh153 | 13:fb7facaf308b | 898 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 899 | } |
Bragadeesh153 | 13:fb7facaf308b | 900 | break; |
sakthipriya | 3:07e15677a75c | 901 | } |
sakthipriya | 3:07e15677a75c | 902 | case 0x32: |
sakthipriya | 3:07e15677a75c | 903 | { |
sakthipriya | 3:07e15677a75c | 904 | printf("BCN_SW_RESET\r\n"); |
sakthipriya | 3:07e15677a75c | 905 | //ACK_L234_TM |
Bragadeesh153 | 13:fb7facaf308b | 906 | telemetry[0]=0xB0; |
Bragadeesh153 | 13:fb7facaf308b | 907 | telemetry[1]=tc[0]; |
Bragadeesh153 | 13:fb7facaf308b | 908 | telemetry[2]=1; |
sakthipriya | 5:bb592f3185cc | 909 | BCN_SW = 1; |
sakthipriya | 5:bb592f3185cc | 910 | wait_us(1); |
sakthipriya | 5:bb592f3185cc | 911 | BCN_SW = 0; |
sakthipriya | 3:07e15677a75c | 912 | for(uint8_t i=3;i<11;i++) |
sakthipriya | 3:07e15677a75c | 913 | { |
Bragadeesh153 | 13:fb7facaf308b | 914 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 915 | } |
Bragadeesh153 | 13:fb7facaf308b | 916 | crc16 = CRC::crc16_gen(telemetry,11); |
Bragadeesh153 | 13:fb7facaf308b | 917 | telemetry[11] = (uint8_t)((crc16&0xFF00)>>8); |
Bragadeesh153 | 13:fb7facaf308b | 918 | telemetry[12] = (uint8_t)(crc16&0x00FF); |
sakthipriya | 3:07e15677a75c | 919 | for(uint8_t i=13;i<134;i++) |
sakthipriya | 3:07e15677a75c | 920 | { |
Bragadeesh153 | 13:fb7facaf308b | 921 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 922 | } |
Bragadeesh153 | 13:fb7facaf308b | 923 | break; |
sakthipriya | 3:07e15677a75c | 924 | } |
sakthipriya | 3:07e15677a75c | 925 | case 0x33: |
sakthipriya | 3:07e15677a75c | 926 | { |
sakthipriya | 5:bb592f3185cc | 927 | printf("ACS_ATS2_SW_RESET\r\n"); |
sakthipriya | 3:07e15677a75c | 928 | //ACK_L234_TM |
Bragadeesh153 | 13:fb7facaf308b | 929 | telemetry[0]=0xB0; |
Bragadeesh153 | 13:fb7facaf308b | 930 | telemetry[1]=tc[0]; |
Bragadeesh153 | 13:fb7facaf308b | 931 | telemetry[2]=1; |
sakthipriya | 9:194afacf7449 | 932 | ATS1_SW_ENABLE = 1; |
sakthipriya | 5:bb592f3185cc | 933 | wait_us(1); |
sakthipriya | 9:194afacf7449 | 934 | ATS1_SW_ENABLE = 0; |
sakthipriya | 3:07e15677a75c | 935 | for(uint8_t i=3;i<11;i++) |
sakthipriya | 3:07e15677a75c | 936 | { |
Bragadeesh153 | 13:fb7facaf308b | 937 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 938 | } |
Bragadeesh153 | 13:fb7facaf308b | 939 | crc16 = CRC::crc16_gen(telemetry,11); |
Bragadeesh153 | 13:fb7facaf308b | 940 | telemetry[11] = (uint8_t)((crc16&0xFF00)>>8); |
Bragadeesh153 | 13:fb7facaf308b | 941 | telemetry[12] = (uint8_t)(crc16&0x00FF); |
sakthipriya | 3:07e15677a75c | 942 | for(uint8_t i=13;i<134;i++) |
sakthipriya | 3:07e15677a75c | 943 | { |
Bragadeesh153 | 13:fb7facaf308b | 944 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 945 | } |
Bragadeesh153 | 13:fb7facaf308b | 946 | break; |
sakthipriya | 3:07e15677a75c | 947 | } |
Bragadeesh153 | 13:fb7facaf308b | 948 | case 0x34: |
sakthipriya | 3:07e15677a75c | 949 | { |
sakthipriya | 3:07e15677a75c | 950 | printf("CDMS_SW_RESET\r\n"); |
sakthipriya | 3:07e15677a75c | 951 | //ACK_L234_TM |
Bragadeesh153 | 13:fb7facaf308b | 952 | telemetry[0]=0xB0; |
Bragadeesh153 | 13:fb7facaf308b | 953 | telemetry[1]=tc[0]; |
Bragadeesh153 | 13:fb7facaf308b | 954 | telemetry[2]=1; |
sakthipriya | 5:bb592f3185cc | 955 | CDMS_RESET = 0; |
sakthipriya | 5:bb592f3185cc | 956 | wait_us(1); |
sakthipriya | 5:bb592f3185cc | 957 | CDMS_RESET = 1; |
sakthipriya | 3:07e15677a75c | 958 | for(uint8_t i=3;i<11;i++) |
sakthipriya | 3:07e15677a75c | 959 | { |
Bragadeesh153 | 13:fb7facaf308b | 960 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 961 | } |
Bragadeesh153 | 13:fb7facaf308b | 962 | crc16 = CRC::crc16_gen(telemetry,11); |
Bragadeesh153 | 13:fb7facaf308b | 963 | telemetry[11] = (uint8_t)((crc16&0xFF00)>>8); |
Bragadeesh153 | 13:fb7facaf308b | 964 | telemetry[12] = (uint8_t)(crc16&0x00FF); |
sakthipriya | 3:07e15677a75c | 965 | for(uint8_t i=13;i<134;i++) |
sakthipriya | 3:07e15677a75c | 966 | { |
Bragadeesh153 | 13:fb7facaf308b | 967 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 968 | } |
Bragadeesh153 | 13:fb7facaf308b | 969 | break; |
sakthipriya | 3:07e15677a75c | 970 | } |
sakthipriya | 3:07e15677a75c | 971 | default: |
Bragadeesh153 | 13:fb7facaf308b | 972 | { |
sakthipriya | 3:07e15677a75c | 973 | printf("Invalid TC\r\n"); |
sakthipriya | 3:07e15677a75c | 974 | //ACK_L234_TM |
Bragadeesh153 | 13:fb7facaf308b | 975 | telemetry[0]=0xB0; |
Bragadeesh153 | 13:fb7facaf308b | 976 | telemetry[1]=tc[0]; |
Bragadeesh153 | 13:fb7facaf308b | 977 | telemetry[2]=ACK_CODE; |
sakthipriya | 3:07e15677a75c | 978 | for(uint8_t i=3;i<11;i++) |
sakthipriya | 3:07e15677a75c | 979 | { |
Bragadeesh153 | 13:fb7facaf308b | 980 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 981 | } |
Bragadeesh153 | 13:fb7facaf308b | 982 | crc16 = CRC::crc16_gen(telemetry,11); |
Bragadeesh153 | 13:fb7facaf308b | 983 | telemetry[11] = (uint8_t)((crc16&0xFF00)>>8); |
Bragadeesh153 | 13:fb7facaf308b | 984 | telemetry[12] = (uint8_t)(crc16&0x00FF); |
sakthipriya | 3:07e15677a75c | 985 | for(uint8_t i=13;i<134;i++) |
sakthipriya | 3:07e15677a75c | 986 | { |
Bragadeesh153 | 13:fb7facaf308b | 987 | telemetry[i]=0x00; |
sakthipriya | 3:07e15677a75c | 988 | } |
Bragadeesh153 | 13:fb7facaf308b | 989 | break; |
sakthipriya | 3:07e15677a75c | 990 | } |
sakthipriya | 3:07e15677a75c | 991 | } |
Bragadeesh153 | 13:fb7facaf308b | 992 | break; |
Bragadeesh153 | 13:fb7facaf308b | 993 | } |
sakthipriya | 3:07e15677a75c | 994 | default: |
Bragadeesh153 | 13:fb7facaf308b | 995 | { |
Bragadeesh153 | 13:fb7facaf308b | 996 | printf("Invalid TC\r\n"); |
Bragadeesh153 | 13:fb7facaf308b | 997 | //ACK_L234_TM |
Bragadeesh153 | 13:fb7facaf308b | 998 | telemetry[0]=0xB0; |
Bragadeesh153 | 13:fb7facaf308b | 999 | telemetry[1]=tc[0]; |
Bragadeesh153 | 13:fb7facaf308b | 1000 | telemetry[2]=ACK_CODE; |
Bragadeesh153 | 13:fb7facaf308b | 1001 | for(uint8_t i=3;i<11;i++) |
Bragadeesh153 | 13:fb7facaf308b | 1002 | { |
Bragadeesh153 | 13:fb7facaf308b | 1003 | telemetry[i]=0x00; |
Bragadeesh153 | 13:fb7facaf308b | 1004 | } |
Bragadeesh153 | 13:fb7facaf308b | 1005 | crc16 = CRC::crc16_gen(telemetry,11); |
Bragadeesh153 | 13:fb7facaf308b | 1006 | telemetry[11] = (uint8_t)((crc16&0xFF00)>>8); |
Bragadeesh153 | 13:fb7facaf308b | 1007 | telemetry[12] = (uint8_t)(crc16&0x00FF); |
Bragadeesh153 | 13:fb7facaf308b | 1008 | for(uint8_t i=13;i<134;i++) |
Bragadeesh153 | 13:fb7facaf308b | 1009 | { |
Bragadeesh153 | 13:fb7facaf308b | 1010 | telemetry[i]=0x00; |
Bragadeesh153 | 13:fb7facaf308b | 1011 | } |
Bragadeesh153 | 13:fb7facaf308b | 1012 | break; |
sakthipriya | 3:07e15677a75c | 1013 | } |
sakthipriya | 3:07e15677a75c | 1014 | } |
Bragadeesh153 | 13:fb7facaf308b | 1015 | break; |
Bragadeesh153 | 13:fb7facaf308b | 1016 | } |
Bragadeesh153 | 13:fb7facaf308b | 1017 | default: |
Bragadeesh153 | 13:fb7facaf308b | 1018 | { |
Bragadeesh153 | 13:fb7facaf308b | 1019 | printf("Invalid TC\r\n"); |
Bragadeesh153 | 13:fb7facaf308b | 1020 | //ACK_L234_TM |
Bragadeesh153 | 13:fb7facaf308b | 1021 | telemetry[0]=0xB0; |
Bragadeesh153 | 13:fb7facaf308b | 1022 | telemetry[1]=tc[0]; |
Bragadeesh153 | 13:fb7facaf308b | 1023 | telemetry[2]=ACK_CODE; |
Bragadeesh153 | 13:fb7facaf308b | 1024 | for(uint8_t i=3;i<11;i++) |
Bragadeesh153 | 13:fb7facaf308b | 1025 | { |
Bragadeesh153 | 13:fb7facaf308b | 1026 | telemetry[i]=0x00; |
Bragadeesh153 | 13:fb7facaf308b | 1027 | } |
Bragadeesh153 | 13:fb7facaf308b | 1028 | crc16 = CRC::crc16_gen(telemetry,11); |
Bragadeesh153 | 13:fb7facaf308b | 1029 | telemetry[11] = (uint8_t)((crc16&0xFF00)>>8); |
Bragadeesh153 | 13:fb7facaf308b | 1030 | telemetry[12] = (uint8_t)(crc16&0x00FF); |
Bragadeesh153 | 13:fb7facaf308b | 1031 | for(uint8_t i=13;i<134;i++) |
Bragadeesh153 | 13:fb7facaf308b | 1032 | { |
Bragadeesh153 | 13:fb7facaf308b | 1033 | telemetry[i]=0x00; |
Bragadeesh153 | 13:fb7facaf308b | 1034 | } |
Bragadeesh153 | 13:fb7facaf308b | 1035 | break; |
sakthipriya | 3:07e15677a75c | 1036 | } |
sakthipriya | 3:07e15677a75c | 1037 | } |
Bragadeesh153 | 13:fb7facaf308b | 1038 | } |
sakthipriya | 4:39a4ae8c7ecd | 1039 | |
sakthipriya | 4:39a4ae8c7ecd | 1040 | |
sakthipriya | 4:39a4ae8c7ecd | 1041 | |
sakthipriya | 4:39a4ae8c7ecd | 1042 | |
Bragadeesh153 | 13:fb7facaf308b | 1043 | int strt_add = flash_size() - (2*SECTOR_SIZE); |
sakthipriya | 4:39a4ae8c7ecd | 1044 | uint32_t flasharray[8]; //256+(3*1024) |
sakthipriya | 4:39a4ae8c7ecd | 1045 | char *nativeflash = (char*)strt_add; |
sakthipriya | 4:39a4ae8c7ecd | 1046 | |
sakthipriya | 4:39a4ae8c7ecd | 1047 | /*Writing to the Flash*/ |
sakthipriya | 4:39a4ae8c7ecd | 1048 | void FCTN_CDMS_WR_FLASH(uint16_t j,uint32_t fdata) //j-position to write address ; fdata - flash data to be written |
sakthipriya | 4:39a4ae8c7ecd | 1049 | { |
Bragadeesh153 | 13:fb7facaf308b | 1050 | for(int i=0;i<8;i++) |
sakthipriya | 4:39a4ae8c7ecd | 1051 | { |
sakthipriya | 4:39a4ae8c7ecd | 1052 | flasharray[i]=nativeflash[i]; |
sakthipriya | 4:39a4ae8c7ecd | 1053 | } |
sakthipriya | 4:39a4ae8c7ecd | 1054 | flasharray[j]=fdata; |
sakthipriya | 4:39a4ae8c7ecd | 1055 | erase_sector(strt_add); |
sakthipriya | 4:39a4ae8c7ecd | 1056 | program_flash(strt_add, (char*)&flasharray,4*8); |
sakthipriya | 4:39a4ae8c7ecd | 1057 | } |
sakthipriya | 4:39a4ae8c7ecd | 1058 | /*End*/ |
sakthipriya | 4:39a4ae8c7ecd | 1059 | |
sakthipriya | 4:39a4ae8c7ecd | 1060 | /*Reading from Flash*/ |
sakthipriya | 4:39a4ae8c7ecd | 1061 | uint32_t FCTN_CDMS_RD_FLASH(uint16_t j) |
sakthipriya | 4:39a4ae8c7ecd | 1062 | { |
sakthipriya | 4:39a4ae8c7ecd | 1063 | for(int i=0;i<8;i++) |
sakthipriya | 4:39a4ae8c7ecd | 1064 | { |
sakthipriya | 4:39a4ae8c7ecd | 1065 | flasharray[i]=nativeflash[i]; |
sakthipriya | 4:39a4ae8c7ecd | 1066 | } |
sakthipriya | 4:39a4ae8c7ecd | 1067 | return flasharray[j]; |
sakthipriya | 4:39a4ae8c7ecd | 1068 | } |
sakthipriya | 5:bb592f3185cc | 1069 | /*End*/ |
sakthipriya | 5:bb592f3185cc | 1070 | |
sakthipriya | 5:bb592f3185cc | 1071 | // Convert float to 4 uint8_t |
sakthipriya | 5:bb592f3185cc | 1072 | |
sakthipriya | 6:036d08b62785 | 1073 | void FCTN_CONVERT_FLOAT(float input, uint8_t output[4]) |
sakthipriya | 5:bb592f3185cc | 1074 | { |
sakthipriya | 6:036d08b62785 | 1075 | assert(sizeof(float) == sizeof(uint32_t)); |
sakthipriya | 6:036d08b62785 | 1076 | uint32_t* temp = reinterpret_cast<uint32_t*>(&input); |
sakthipriya | 6:036d08b62785 | 1077 | |
sakthipriya | 6:036d08b62785 | 1078 | //float* output1 = reinterpret_cast<float*>(temp); |
Bragadeesh153 | 13:fb7facaf308b | 1079 | |
sakthipriya | 6:036d08b62785 | 1080 | printf("\n\r %f ", input); |
sakthipriya | 6:036d08b62785 | 1081 | std::cout << "\n\r uint32"<<*temp << std::endl; |
sakthipriya | 6:036d08b62785 | 1082 | |
sakthipriya | 6:036d08b62785 | 1083 | output[0] =(uint8_t )(((*temp)>>24)&0xFF); |
sakthipriya | 6:036d08b62785 | 1084 | output[2] =(uint8_t ) (((*temp)>>16)&0xFF); |
Bragadeesh153 | 13:fb7facaf308b | 1085 | output[1] =(uint8_t ) (((*temp)>>8)&0xFF); |
Bragadeesh153 | 13:fb7facaf308b | 1086 | output[3] =(uint8_t ) ((*temp) & 0xFF); // verify the logic |
sakthipriya | 6:036d08b62785 | 1087 | //printf("\n\r inside %d %d %d %d", output[3],output[2],output[1],output[0]); |
Bragadeesh153 | 13:fb7facaf308b | 1088 | //std:: cout << "\n\r uint8 inside " << output[3] << '\t' << output[2] << '\t' << output[1] << '\t' << output[0] <<std::endl; |
Bragadeesh153 | 13:fb7facaf308b | 1089 | } |