123
Fork of LG by
Command.c@125:9400e64d0636, 2016-04-08 (annotated)
- Committer:
- Kovalev_D
- Date:
- Fri Apr 08 17:52:16 2016 +0000
- Revision:
- 125:9400e64d0636
- Parent:
- 124:9ae09249f842
- Child:
- 128:1e4675a36c93
11
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
igor_v | 0:8ad47e2b6f00 | 1 | #include "stdlib.h" |
igor_v | 0:8ad47e2b6f00 | 2 | #include "LPC17xx.h" |
igor_v | 0:8ad47e2b6f00 | 3 | #include "Global.h" |
Kovalev_D | 106:250ddd8629c6 | 4 | int tempNH,tempNL; |
igor_v | 0:8ad47e2b6f00 | 5 | unsigned int Rate_Flag; |
igor_v | 0:8ad47e2b6f00 | 6 | unsigned int CountBuFFIn; |
igor_v | 21:bc8c1cec3da6 | 7 | unsigned int N=0,CRC_N; |
igor_v | 21:bc8c1cec3da6 | 8 | unsigned int Param1=0; |
igor_v | 21:bc8c1cec3da6 | 9 | unsigned int Param2=0; |
igor_v | 21:bc8c1cec3da6 | 10 | unsigned int Param3=0; |
igor_v | 21:bc8c1cec3da6 | 11 | unsigned int Param4=0; |
Kovalev_D | 102:4270092be987 | 12 | unsigned int Consol=123; |
Kovalev_D | 121:bbae560cdd43 | 13 | unsigned int TempParam=1; |
Kovalev_D | 124:9ae09249f842 | 14 | unsigned int CountParam=0; |
igor_v | 0:8ad47e2b6f00 | 15 | /* |
igor_v | 21:bc8c1cec3da6 | 16 | void exec_CMD(void) //r. === процедура окончательной дешифрации и исполнения команды |
igor_v | 0:8ad47e2b6f00 | 17 | { |
igor_v | 0:8ad47e2b6f00 | 18 | unsigned int Comand_code; |
igor_v | 21:bc8c1cec3da6 | 19 | |
igor_v | 21:bc8c1cec3da6 | 20 | //rx_buf_copy = 1; //r. предустанов флага копирования приемного буфера |
igor_v | 0:8ad47e2b6f00 | 21 | |
igor_v | 0:8ad47e2b6f00 | 22 | Comand_code = (rcv_buf[2] & 0xFF) << 8; |
igor_v | 21:bc8c1cec3da6 | 23 | PC_Comand = Comand_code | (rcv_buf[3] & 0xFF); //e. save it in the memory for echo-transmission //r. сохранить его в памяти для обратной передачи |
igor_v | 0:8ad47e2b6f00 | 24 | }*/ |
igor_v | 0:8ad47e2b6f00 | 25 | void CMD_Maintenance(void) |
igor_v | 0:8ad47e2b6f00 | 26 | { |
Kovalev_D | 122:fbacb932a30b | 27 | |
Kovalev_D | 122:fbacb932a30b | 28 | BuffTemp[0] = Gyro.SOC_Out; |
Kovalev_D | 124:9ae09249f842 | 29 | BuffTemp[1] = Gyro.My_Addres; |
Kovalev_D | 124:9ae09249f842 | 30 | BuffTemp[2] = Gyro.Firmware_Version; |
Kovalev_D | 124:9ae09249f842 | 31 | BuffTemp[3] = Gyro.GLD_Serial; |
igor_v | 21:bc8c1cec3da6 | 32 | BuffTemp[4]=0x00; |
igor_v | 21:bc8c1cec3da6 | 33 | BuffTemp[5]=0x00; |
igor_v | 21:bc8c1cec3da6 | 34 | Check(BuffTemp, 8); |
igor_v | 21:bc8c1cec3da6 | 35 | WriteConN (BuffTemp,8); |
Kovalev_D | 121:bbae560cdd43 | 36 | |
igor_v | 0:8ad47e2b6f00 | 37 | } |
Kovalev_D | 124:9ae09249f842 | 38 | void CMD_Delta_500Hz(void) |
Kovalev_D | 124:9ae09249f842 | 39 | { |
Kovalev_D | 124:9ae09249f842 | 40 | Gyro.Delta500_Event=0; |
Kovalev_D | 122:fbacb932a30b | 41 | unsigned int Temp; |
Kovalev_D | 124:9ae09249f842 | 42 | BuffTemp[ 0] = Gyro.SOC_Out; |
Kovalev_D | 122:fbacb932a30b | 43 | BuffTemp[ 1] = Gyro.My_Addres; |
Kovalev_D | 124:9ae09249f842 | 44 | |
Kovalev_D | 124:9ae09249f842 | 45 | Temp = Gyro.CuruAngle; |
Kovalev_D | 124:9ae09249f842 | 46 | Gyro.CuruAngle = 0; |
Kovalev_D | 124:9ae09249f842 | 47 | |
Kovalev_D | 124:9ae09249f842 | 48 | BuffTemp[ 2] =(Temp >> 8) & 0xff;//старший байт разности счетчиков |
Kovalev_D | 124:9ae09249f842 | 49 | BuffTemp[ 3] =(Temp >> 0) & 0xff;//младший байт разности счетчиков |
Kovalev_D | 124:9ae09249f842 | 50 | |
Kovalev_D | 124:9ae09249f842 | 51 | BuffTemp[ 4] = CountParam; |
Kovalev_D | 124:9ae09249f842 | 52 | switch(CountParam) { |
Kovalev_D | 124:9ae09249f842 | 53 | |
Kovalev_D | 124:9ae09249f842 | 54 | |
Kovalev_D | 124:9ae09249f842 | 55 | |
Kovalev_D | 124:9ae09249f842 | 56 | //F_ras |
Kovalev_D | 124:9ae09249f842 | 57 | case 0: |
Kovalev_D | 124:9ae09249f842 | 58 | Temp = Gyro.F_ras; |
Kovalev_D | 124:9ae09249f842 | 59 | BuffTemp[5] = (Temp >> 8) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 60 | break; |
Kovalev_D | 124:9ae09249f842 | 61 | |
Kovalev_D | 124:9ae09249f842 | 62 | case 1: |
Kovalev_D | 124:9ae09249f842 | 63 | BuffTemp[5] = (Temp >> 0) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 64 | break; |
Kovalev_D | 124:9ae09249f842 | 65 | |
Kovalev_D | 124:9ae09249f842 | 66 | |
Kovalev_D | 124:9ae09249f842 | 67 | |
Kovalev_D | 124:9ae09249f842 | 68 | //HFO |
Kovalev_D | 124:9ae09249f842 | 69 | case 2: |
Kovalev_D | 124:9ae09249f842 | 70 | Temp = 0;//HFO |
Kovalev_D | 124:9ae09249f842 | 71 | BuffTemp[5] = (Temp >> 8) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 72 | break; |
Kovalev_D | 124:9ae09249f842 | 73 | |
Kovalev_D | 124:9ae09249f842 | 74 | case 3: |
Kovalev_D | 124:9ae09249f842 | 75 | Temp = 0;//HFO |
Kovalev_D | 124:9ae09249f842 | 76 | BuffTemp[5] = (Temp >> 0) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 77 | break; |
Kovalev_D | 124:9ae09249f842 | 78 | |
Kovalev_D | 124:9ae09249f842 | 79 | |
Kovalev_D | 124:9ae09249f842 | 80 | |
Kovalev_D | 124:9ae09249f842 | 81 | //T_Vibro |
Kovalev_D | 124:9ae09249f842 | 82 | case 4: |
Kovalev_D | 124:9ae09249f842 | 83 | Temp = (unsigned int)((7680000*16/(Gyro.Frq>>12))); |
Kovalev_D | 124:9ae09249f842 | 84 | BuffTemp[5] = (Temp >> 8) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 85 | break; |
Kovalev_D | 124:9ae09249f842 | 86 | |
Kovalev_D | 124:9ae09249f842 | 87 | case 5: |
Kovalev_D | 124:9ae09249f842 | 88 | BuffTemp[5] = (Temp >> 0) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 89 | break; |
Kovalev_D | 124:9ae09249f842 | 90 | |
Kovalev_D | 124:9ae09249f842 | 91 | |
Kovalev_D | 124:9ae09249f842 | 92 | |
Kovalev_D | 124:9ae09249f842 | 93 | //L_Vibro |
Kovalev_D | 124:9ae09249f842 | 94 | case 6: |
Kovalev_D | 124:9ae09249f842 | 95 | Temp = (unsigned int)(((7680000*16/200) *Gyro.AmpPer /(Gyro.Frq>>12))); |
Kovalev_D | 124:9ae09249f842 | 96 | BuffTemp[5] = (Temp >> 8) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 97 | |
Kovalev_D | 124:9ae09249f842 | 98 | break; |
Kovalev_D | 124:9ae09249f842 | 99 | |
Kovalev_D | 124:9ae09249f842 | 100 | case 7: |
Kovalev_D | 124:9ae09249f842 | 101 | BuffTemp[5] = (Temp >> 0) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 102 | break; |
Kovalev_D | 124:9ae09249f842 | 103 | |
Kovalev_D | 124:9ae09249f842 | 104 | |
Kovalev_D | 124:9ae09249f842 | 105 | |
Kovalev_D | 124:9ae09249f842 | 106 | //Напряжение на регуляторе периметра |
Kovalev_D | 124:9ae09249f842 | 107 | case 8: |
Kovalev_D | 124:9ae09249f842 | 108 | Temp = Spi.DAC_B - 0x7fff; |
Kovalev_D | 124:9ae09249f842 | 109 | BuffTemp[5] = (Temp >> 8) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 110 | |
Kovalev_D | 124:9ae09249f842 | 111 | break; |
Kovalev_D | 124:9ae09249f842 | 112 | |
Kovalev_D | 124:9ae09249f842 | 113 | case 9: |
Kovalev_D | 124:9ae09249f842 | 114 | BuffTemp[5] = (Temp >> 0) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 115 | break; |
Kovalev_D | 124:9ae09249f842 | 116 | |
Kovalev_D | 124:9ae09249f842 | 117 | |
Kovalev_D | 124:9ae09249f842 | 118 | |
Kovalev_D | 124:9ae09249f842 | 119 | //темпкратурный канал 0 |
Kovalev_D | 124:9ae09249f842 | 120 | case 10: |
Kovalev_D | 124:9ae09249f842 | 121 | Temp = 100; |
Kovalev_D | 124:9ae09249f842 | 122 | BuffTemp[5] = (Temp >> 8) & 0xff; |
igor_v | 0:8ad47e2b6f00 | 123 | |
Kovalev_D | 124:9ae09249f842 | 124 | break; |
Kovalev_D | 124:9ae09249f842 | 125 | |
Kovalev_D | 124:9ae09249f842 | 126 | case 11: |
Kovalev_D | 124:9ae09249f842 | 127 | BuffTemp[5] = (Temp >> 0) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 128 | break; |
Kovalev_D | 124:9ae09249f842 | 129 | |
Kovalev_D | 124:9ae09249f842 | 130 | |
Kovalev_D | 124:9ae09249f842 | 131 | |
Kovalev_D | 124:9ae09249f842 | 132 | //темпкратурный канал 1 |
Kovalev_D | 124:9ae09249f842 | 133 | case 12: |
Kovalev_D | 124:9ae09249f842 | 134 | Temp = Gyro.AD_Slow >> 16; |
Kovalev_D | 124:9ae09249f842 | 135 | BuffTemp[5] = (Temp >> 8) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 136 | |
Kovalev_D | 124:9ae09249f842 | 137 | break; |
Kovalev_D | 124:9ae09249f842 | 138 | |
Kovalev_D | 124:9ae09249f842 | 139 | case 13: |
Kovalev_D | 124:9ae09249f842 | 140 | BuffTemp[5] = (Temp >> 0) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 141 | break; |
Kovalev_D | 124:9ae09249f842 | 142 | |
Kovalev_D | 124:9ae09249f842 | 143 | |
Kovalev_D | 124:9ae09249f842 | 144 | |
Kovalev_D | 124:9ae09249f842 | 145 | //ток 1 |
Kovalev_D | 124:9ae09249f842 | 146 | case 14: |
Kovalev_D | 124:9ae09249f842 | 147 | Temp = Gyro.In1; |
Kovalev_D | 124:9ae09249f842 | 148 | BuffTemp[5] = (Temp >> 8) & 0xff;//in1//2 |
Kovalev_D | 124:9ae09249f842 | 149 | |
Kovalev_D | 124:9ae09249f842 | 150 | break; |
Kovalev_D | 124:9ae09249f842 | 151 | |
Kovalev_D | 124:9ae09249f842 | 152 | case 15: |
Kovalev_D | 124:9ae09249f842 | 153 | BuffTemp[5] = (Temp >> 0) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 154 | break; |
Kovalev_D | 124:9ae09249f842 | 155 | |
Kovalev_D | 124:9ae09249f842 | 156 | |
Kovalev_D | 124:9ae09249f842 | 157 | |
Kovalev_D | 124:9ae09249f842 | 158 | //ток 2 |
Kovalev_D | 124:9ae09249f842 | 159 | case 16: |
Kovalev_D | 124:9ae09249f842 | 160 | Temp = Gyro.In2; |
Kovalev_D | 124:9ae09249f842 | 161 | BuffTemp[5] = (Temp >> 8) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 162 | break; |
Kovalev_D | 124:9ae09249f842 | 163 | |
Kovalev_D | 124:9ae09249f842 | 164 | case 17: |
Kovalev_D | 124:9ae09249f842 | 165 | BuffTemp[5] = (Temp >> 0) & 0xff;//in2//3 |
Kovalev_D | 124:9ae09249f842 | 166 | break; |
Kovalev_D | 124:9ae09249f842 | 167 | |
Kovalev_D | 124:9ae09249f842 | 168 | |
Kovalev_D | 124:9ae09249f842 | 169 | |
Kovalev_D | 124:9ae09249f842 | 170 | //разностный температурный канал Delta Temp |
Kovalev_D | 124:9ae09249f842 | 171 | case 18: |
Kovalev_D | 124:9ae09249f842 | 172 | Temp = Gyro.DeltaT; |
Kovalev_D | 124:9ae09249f842 | 173 | BuffTemp[5] = (Temp >> 8) & 0xff;//дельта |
Kovalev_D | 124:9ae09249f842 | 174 | break; |
Kovalev_D | 124:9ae09249f842 | 175 | |
Kovalev_D | 124:9ae09249f842 | 176 | case 19: |
Kovalev_D | 124:9ae09249f842 | 177 | BuffTemp[5] = (Temp >> 0) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 178 | break; |
Kovalev_D | 124:9ae09249f842 | 179 | |
Kovalev_D | 124:9ae09249f842 | 180 | |
Kovalev_D | 124:9ae09249f842 | 181 | |
Kovalev_D | 124:9ae09249f842 | 182 | //температурный канал 5 |
Kovalev_D | 124:9ae09249f842 | 183 | case 20: |
Kovalev_D | 124:9ae09249f842 | 184 | Temp = Gyro.Termo;//0xa4=164 |
Kovalev_D | 124:9ae09249f842 | 185 | BuffTemp[5] =(Temp >> 8) & 0xff;//температура |
Kovalev_D | 124:9ae09249f842 | 186 | |
Kovalev_D | 124:9ae09249f842 | 187 | break; |
Kovalev_D | 124:9ae09249f842 | 188 | |
Kovalev_D | 124:9ae09249f842 | 189 | case 21: |
Kovalev_D | 124:9ae09249f842 | 190 | BuffTemp[5] =(Temp >> 0) & 0xff;//ADC6 sesnsor 5 |
Kovalev_D | 124:9ae09249f842 | 191 | break; |
Kovalev_D | 124:9ae09249f842 | 192 | } |
Kovalev_D | 124:9ae09249f842 | 193 | Check(BuffTemp, 6); |
Kovalev_D | 124:9ae09249f842 | 194 | WriteConN (BuffTemp,6); |
Kovalev_D | 124:9ae09249f842 | 195 | CountParam++; |
Kovalev_D | 124:9ae09249f842 | 196 | |
Kovalev_D | 124:9ae09249f842 | 197 | if(CountParam>21)CountParam=0;//зацикливания буфера от 0 до 21 |
Kovalev_D | 124:9ae09249f842 | 198 | |
Kovalev_D | 124:9ae09249f842 | 199 | } |
Kovalev_D | 124:9ae09249f842 | 200 | void CMD_Delta_Ext(void) |
Kovalev_D | 124:9ae09249f842 | 201 | { |
Kovalev_D | 124:9ae09249f842 | 202 | unsigned int Temp; |
Kovalev_D | 124:9ae09249f842 | 203 | BuffTemp[ 0] = Gyro.SOC_Out; |
Kovalev_D | 124:9ae09249f842 | 204 | BuffTemp[ 1] = Gyro.My_Addres; |
Kovalev_D | 124:9ae09249f842 | 205 | |
Kovalev_D | 124:9ae09249f842 | 206 | Temp = Gyro.CuruAngle; |
Kovalev_D | 124:9ae09249f842 | 207 | Gyro.CuruAngle = 0; |
Kovalev_D | 124:9ae09249f842 | 208 | |
Kovalev_D | 124:9ae09249f842 | 209 | BuffTemp[ 2] =(Temp >> 8) & 0xff;//старший байт разности счетчиков |
Kovalev_D | 124:9ae09249f842 | 210 | BuffTemp[ 3] =(Temp >> 0) & 0xff;//младший байт разности счетчиков |
Kovalev_D | 124:9ae09249f842 | 211 | |
Kovalev_D | 124:9ae09249f842 | 212 | BuffTemp[ 4] = CountParam; |
Kovalev_D | 124:9ae09249f842 | 213 | switch(CountParam) { |
Kovalev_D | 124:9ae09249f842 | 214 | |
Kovalev_D | 124:9ae09249f842 | 215 | |
Kovalev_D | 124:9ae09249f842 | 216 | |
Kovalev_D | 124:9ae09249f842 | 217 | //F_ras |
Kovalev_D | 124:9ae09249f842 | 218 | case 0: |
Kovalev_D | 124:9ae09249f842 | 219 | Temp = Gyro.F_ras; |
Kovalev_D | 124:9ae09249f842 | 220 | BuffTemp[5] = (Temp >> 8) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 221 | break; |
Kovalev_D | 124:9ae09249f842 | 222 | |
Kovalev_D | 124:9ae09249f842 | 223 | case 1: |
Kovalev_D | 124:9ae09249f842 | 224 | BuffTemp[5] = (Temp >> 0) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 225 | break; |
Kovalev_D | 124:9ae09249f842 | 226 | |
Kovalev_D | 124:9ae09249f842 | 227 | |
Kovalev_D | 124:9ae09249f842 | 228 | |
Kovalev_D | 124:9ae09249f842 | 229 | //HFO |
Kovalev_D | 124:9ae09249f842 | 230 | case 2: |
Kovalev_D | 124:9ae09249f842 | 231 | Temp = 0;//HFO |
Kovalev_D | 124:9ae09249f842 | 232 | BuffTemp[5] = (Temp >> 8) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 233 | break; |
Kovalev_D | 124:9ae09249f842 | 234 | |
Kovalev_D | 124:9ae09249f842 | 235 | case 3: |
Kovalev_D | 124:9ae09249f842 | 236 | Temp = 0;//HFO |
Kovalev_D | 124:9ae09249f842 | 237 | BuffTemp[5] = (Temp >> 0) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 238 | break; |
Kovalev_D | 124:9ae09249f842 | 239 | |
Kovalev_D | 124:9ae09249f842 | 240 | |
Kovalev_D | 124:9ae09249f842 | 241 | |
Kovalev_D | 124:9ae09249f842 | 242 | //T_Vibro |
Kovalev_D | 124:9ae09249f842 | 243 | case 4: |
Kovalev_D | 124:9ae09249f842 | 244 | Temp = (unsigned int)((7680000*16/(Gyro.Frq>>12))); |
Kovalev_D | 124:9ae09249f842 | 245 | BuffTemp[5] = (Temp >> 8) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 246 | break; |
Kovalev_D | 124:9ae09249f842 | 247 | |
Kovalev_D | 124:9ae09249f842 | 248 | case 5: |
Kovalev_D | 124:9ae09249f842 | 249 | BuffTemp[5] = (Temp >> 0) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 250 | break; |
Kovalev_D | 124:9ae09249f842 | 251 | |
Kovalev_D | 124:9ae09249f842 | 252 | |
Kovalev_D | 124:9ae09249f842 | 253 | |
Kovalev_D | 124:9ae09249f842 | 254 | //L_Vibro |
Kovalev_D | 124:9ae09249f842 | 255 | case 6: |
Kovalev_D | 124:9ae09249f842 | 256 | Temp = (unsigned int)(((7680000*16/200) *Gyro.AmpPer /(Gyro.Frq>>12))); |
Kovalev_D | 124:9ae09249f842 | 257 | BuffTemp[5] = (Temp >> 8) & 0xff; |
Kovalev_D | 122:fbacb932a30b | 258 | |
Kovalev_D | 124:9ae09249f842 | 259 | break; |
Kovalev_D | 124:9ae09249f842 | 260 | |
Kovalev_D | 124:9ae09249f842 | 261 | case 7: |
Kovalev_D | 124:9ae09249f842 | 262 | BuffTemp[5] = (Temp >> 0) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 263 | break; |
Kovalev_D | 124:9ae09249f842 | 264 | |
Kovalev_D | 124:9ae09249f842 | 265 | |
Kovalev_D | 124:9ae09249f842 | 266 | |
Kovalev_D | 124:9ae09249f842 | 267 | //Напряжение на регуляторе периметра |
Kovalev_D | 124:9ae09249f842 | 268 | case 8: |
Kovalev_D | 124:9ae09249f842 | 269 | Temp = Spi.DAC_B - 0x7fff; |
Kovalev_D | 124:9ae09249f842 | 270 | BuffTemp[5] = (Temp >> 8) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 271 | |
Kovalev_D | 124:9ae09249f842 | 272 | break; |
Kovalev_D | 124:9ae09249f842 | 273 | |
Kovalev_D | 124:9ae09249f842 | 274 | case 9: |
Kovalev_D | 124:9ae09249f842 | 275 | BuffTemp[5] = (Temp >> 0) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 276 | break; |
Kovalev_D | 124:9ae09249f842 | 277 | |
Kovalev_D | 124:9ae09249f842 | 278 | |
Kovalev_D | 124:9ae09249f842 | 279 | |
Kovalev_D | 124:9ae09249f842 | 280 | //темпкратурный канал 0 |
Kovalev_D | 124:9ae09249f842 | 281 | case 10: |
Kovalev_D | 124:9ae09249f842 | 282 | Temp = 100; |
Kovalev_D | 124:9ae09249f842 | 283 | BuffTemp[5] = (Temp >> 8) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 284 | |
Kovalev_D | 124:9ae09249f842 | 285 | break; |
Kovalev_D | 124:9ae09249f842 | 286 | |
Kovalev_D | 124:9ae09249f842 | 287 | case 11: |
Kovalev_D | 124:9ae09249f842 | 288 | BuffTemp[5] = (Temp >> 0) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 289 | break; |
Kovalev_D | 124:9ae09249f842 | 290 | |
Kovalev_D | 124:9ae09249f842 | 291 | |
Kovalev_D | 124:9ae09249f842 | 292 | |
Kovalev_D | 124:9ae09249f842 | 293 | //темпкратурный канал 1 |
Kovalev_D | 124:9ae09249f842 | 294 | case 12: |
Kovalev_D | 124:9ae09249f842 | 295 | Temp = Gyro.AD_Slow >> 16; |
Kovalev_D | 124:9ae09249f842 | 296 | BuffTemp[5] = (Temp >> 8) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 297 | |
Kovalev_D | 124:9ae09249f842 | 298 | break; |
Kovalev_D | 124:9ae09249f842 | 299 | |
Kovalev_D | 124:9ae09249f842 | 300 | case 13: |
Kovalev_D | 124:9ae09249f842 | 301 | BuffTemp[5] = (Temp >> 0) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 302 | break; |
Kovalev_D | 124:9ae09249f842 | 303 | |
Kovalev_D | 124:9ae09249f842 | 304 | |
Kovalev_D | 124:9ae09249f842 | 305 | |
Kovalev_D | 124:9ae09249f842 | 306 | //ток 1 |
Kovalev_D | 124:9ae09249f842 | 307 | case 14: |
Kovalev_D | 124:9ae09249f842 | 308 | Temp = Gyro.In1; |
Kovalev_D | 124:9ae09249f842 | 309 | BuffTemp[5] = (Temp >> 8) & 0xff;//in1//2 |
Kovalev_D | 124:9ae09249f842 | 310 | |
Kovalev_D | 124:9ae09249f842 | 311 | break; |
Kovalev_D | 124:9ae09249f842 | 312 | |
Kovalev_D | 124:9ae09249f842 | 313 | case 15: |
Kovalev_D | 124:9ae09249f842 | 314 | BuffTemp[5] = (Temp >> 0) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 315 | break; |
Kovalev_D | 124:9ae09249f842 | 316 | |
Kovalev_D | 124:9ae09249f842 | 317 | |
Kovalev_D | 124:9ae09249f842 | 318 | |
Kovalev_D | 124:9ae09249f842 | 319 | //ток 2 |
Kovalev_D | 124:9ae09249f842 | 320 | case 16: |
Kovalev_D | 124:9ae09249f842 | 321 | Temp = Gyro.In2; |
Kovalev_D | 124:9ae09249f842 | 322 | BuffTemp[5] = (Temp >> 8) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 323 | break; |
Kovalev_D | 124:9ae09249f842 | 324 | |
Kovalev_D | 124:9ae09249f842 | 325 | case 17: |
Kovalev_D | 124:9ae09249f842 | 326 | BuffTemp[5] = (Temp >> 0) & 0xff;//in2//3 |
Kovalev_D | 124:9ae09249f842 | 327 | break; |
Kovalev_D | 124:9ae09249f842 | 328 | |
Kovalev_D | 124:9ae09249f842 | 329 | |
Kovalev_D | 124:9ae09249f842 | 330 | |
Kovalev_D | 124:9ae09249f842 | 331 | //разностный температурный канал Delta Temp |
Kovalev_D | 124:9ae09249f842 | 332 | case 18: |
Kovalev_D | 124:9ae09249f842 | 333 | Temp = Gyro.DeltaT; |
Kovalev_D | 124:9ae09249f842 | 334 | BuffTemp[5] = (Temp >> 8) & 0xff;//дельта |
Kovalev_D | 124:9ae09249f842 | 335 | break; |
Kovalev_D | 124:9ae09249f842 | 336 | |
Kovalev_D | 124:9ae09249f842 | 337 | case 19: |
Kovalev_D | 124:9ae09249f842 | 338 | BuffTemp[5] = (Temp >> 0) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 339 | break; |
Kovalev_D | 124:9ae09249f842 | 340 | |
Kovalev_D | 124:9ae09249f842 | 341 | |
Kovalev_D | 124:9ae09249f842 | 342 | |
Kovalev_D | 124:9ae09249f842 | 343 | //температурный канал 5 |
Kovalev_D | 124:9ae09249f842 | 344 | case 20: |
Kovalev_D | 124:9ae09249f842 | 345 | Temp = Gyro.Termo;//0xa4=164 |
Kovalev_D | 124:9ae09249f842 | 346 | BuffTemp[5] =(Temp >> 8) & 0xff;//температура |
Kovalev_D | 124:9ae09249f842 | 347 | |
Kovalev_D | 124:9ae09249f842 | 348 | break; |
Kovalev_D | 124:9ae09249f842 | 349 | |
Kovalev_D | 124:9ae09249f842 | 350 | case 21: |
Kovalev_D | 124:9ae09249f842 | 351 | BuffTemp[5] =(Temp >> 0) & 0xff;//ADC6 sesnsor 5 |
Kovalev_D | 124:9ae09249f842 | 352 | break; |
Kovalev_D | 124:9ae09249f842 | 353 | } |
Kovalev_D | 124:9ae09249f842 | 354 | Check(BuffTemp, 6); |
Kovalev_D | 124:9ae09249f842 | 355 | WriteConN (BuffTemp,6); |
Kovalev_D | 124:9ae09249f842 | 356 | CountParam++; |
Kovalev_D | 124:9ae09249f842 | 357 | |
Kovalev_D | 124:9ae09249f842 | 358 | if(CountParam>21)CountParam=0;//зацикливания буфера от 0 до 21 |
Kovalev_D | 122:fbacb932a30b | 359 | } |
Kovalev_D | 124:9ae09249f842 | 360 | |
Kovalev_D | 121:bbae560cdd43 | 361 | void CMD_Rate2(void) |
Kovalev_D | 121:bbae560cdd43 | 362 | { |
Kovalev_D | 124:9ae09249f842 | 363 | Gyro.Rate2_Event=0; |
Kovalev_D | 121:bbae560cdd43 | 364 | BuffTemp[ 0] = Gyro.SOC_Out; |
Kovalev_D | 121:bbae560cdd43 | 365 | BuffTemp[ 1] = Gyro.My_Addres; |
Kovalev_D | 121:bbae560cdd43 | 366 | |
Kovalev_D | 121:bbae560cdd43 | 367 | |
Kovalev_D | 121:bbae560cdd43 | 368 | BuffTemp[ 2] =(Gyro.CaunPlus >> 8) & 0xff;//старший байт счетчика +. |
Kovalev_D | 121:bbae560cdd43 | 369 | BuffTemp[ 3] =(Gyro.CaunPlus >> 0) & 0xff;//младший байт счетчика +. |
Kovalev_D | 121:bbae560cdd43 | 370 | |
Kovalev_D | 121:bbae560cdd43 | 371 | BuffTemp[ 4] =(Gyro.CaunMin >> 8) & 0xff;//старший байт счетчика -. |
Kovalev_D | 121:bbae560cdd43 | 372 | BuffTemp[ 5] =(Gyro.CaunMin >> 0) & 0xff;//младший байт счетчика -. |
Kovalev_D | 124:9ae09249f842 | 373 | |
Kovalev_D | 122:fbacb932a30b | 374 | Check(BuffTemp, 8); |
Kovalev_D | 122:fbacb932a30b | 375 | WriteConN (BuffTemp,8); |
Kovalev_D | 121:bbae560cdd43 | 376 | } |
Kovalev_D | 124:9ae09249f842 | 377 | |
igor_v | 0:8ad47e2b6f00 | 378 | void CMD_Rate(void) |
igor_v | 21:bc8c1cec3da6 | 379 | { |
Kovalev_D | 124:9ae09249f842 | 380 | |
Kovalev_D | 124:9ae09249f842 | 381 | Gyro.Rate1_Event=0; |
Kovalev_D | 108:030cdde08314 | 382 | unsigned int Temp; |
Kovalev_D | 107:4d178bcc9d8a | 383 | |
igor_v | 28:17c84ed091b3 | 384 | Gyro.Firmware_Version=0xff; /// промежуточная затычка |
Kovalev_D | 122:fbacb932a30b | 385 | |
igor_v | 0:8ad47e2b6f00 | 386 | |
igor_v | 28:17c84ed091b3 | 387 | BuffTemp[ 0] = Gyro.SOC_Out; |
igor_v | 28:17c84ed091b3 | 388 | BuffTemp[ 1] = Gyro.My_Addres; |
igor_v | 21:bc8c1cec3da6 | 389 | |
Kovalev_D | 108:030cdde08314 | 390 | |
Kovalev_D | 112:4a96133a1311 | 391 | BuffTemp[ 2] =(Gyro.CaunPlus >> 8) & 0xff;//старший байт счетчика +. |
Kovalev_D | 112:4a96133a1311 | 392 | BuffTemp[ 3] =(Gyro.CaunPlus >> 0) & 0xff;//младший байт счетчика +. |
Kovalev_D | 108:030cdde08314 | 393 | |
Kovalev_D | 112:4a96133a1311 | 394 | BuffTemp[ 4] =(Gyro.CaunMin >> 8) & 0xff;//старший байт счетчика -. |
Kovalev_D | 112:4a96133a1311 | 395 | BuffTemp[ 5] =(Gyro.CaunMin >> 0) & 0xff;//младший байт счетчика -. |
Kovalev_D | 108:030cdde08314 | 396 | |
Kovalev_D | 113:8be429494918 | 397 | |
Kovalev_D | 108:030cdde08314 | 398 | Temp = Gyro.CuruAngle; |
Kovalev_D | 108:030cdde08314 | 399 | Gyro.CuruAngle = 0; |
Kovalev_D | 125:9400e64d0636 | 400 | Temp = Gyro.AD_Fast >> 16; |
Kovalev_D | 108:030cdde08314 | 401 | BuffTemp[ 6] =(Temp >> 8) & 0xff;//старший байт разности счетчиков |
Kovalev_D | 108:030cdde08314 | 402 | BuffTemp[ 7] =(Temp >> 0) & 0xff;//младший байт разности счетчиков |
Kovalev_D | 108:030cdde08314 | 403 | |
Kovalev_D | 108:030cdde08314 | 404 | |
Kovalev_D | 122:fbacb932a30b | 405 | Temp = Gyro.F_ras; |
Kovalev_D | 122:fbacb932a30b | 406 | BuffTemp[ 8] = (Temp >> 8) & 0xff;//расщипление частота |
Kovalev_D | 122:fbacb932a30b | 407 | BuffTemp[ 9] = (Temp >> 0) & 0xff;// |
igor_v | 21:bc8c1cec3da6 | 408 | |
Kovalev_D | 108:030cdde08314 | 409 | BuffTemp[10] = (Temp >> 8) & 0xff;//выход регулятора гвч; |
Kovalev_D | 122:fbacb932a30b | 410 | BuffTemp[11] = (Temp >> 0) & 0xff; |
igor_v | 21:bc8c1cec3da6 | 411 | |
Kovalev_D | 122:fbacb932a30b | 412 | Temp = (Gyro.AD_Slow >> 16)- 0x7fff; |
Kovalev_D | 108:030cdde08314 | 413 | BuffTemp[12]=(Temp >> 8) & 0xff;//// |
Kovalev_D | 108:030cdde08314 | 414 | BuffTemp[13]=(Temp >> 0) & 0xff;//// |
igor_v | 21:bc8c1cec3da6 | 415 | |
Kovalev_D | 108:030cdde08314 | 416 | |
Kovalev_D | 108:030cdde08314 | 417 | Temp = (unsigned int)((7680000*16/(Gyro.Frq>>12))); |
Kovalev_D | 108:030cdde08314 | 418 | BuffTemp[14] = (Temp >> 8) & 0xff; |
Kovalev_D | 108:030cdde08314 | 419 | BuffTemp[15] = (Temp >> 0) & 0xff; |
igor_v | 21:bc8c1cec3da6 | 420 | |
Kovalev_D | 107:4d178bcc9d8a | 421 | BuffTemp[16] = 0xf; |
Kovalev_D | 106:250ddd8629c6 | 422 | BuffTemp[17] = 0x02; |
Kovalev_D | 108:030cdde08314 | 423 | |
igor_v | 21:bc8c1cec3da6 | 424 | |
Kovalev_D | 108:030cdde08314 | 425 | Temp = (unsigned int)(((7680000*16/200) *Gyro.AmpPer /(Gyro.Frq>>12))); |
Kovalev_D | 108:030cdde08314 | 426 | BuffTemp[18] = (Temp >> 8) & 0xff; |
Kovalev_D | 108:030cdde08314 | 427 | BuffTemp[19] = (Temp >> 0) & 0xff; |
igor_v | 21:bc8c1cec3da6 | 428 | |
Kovalev_D | 106:250ddd8629c6 | 429 | BuffTemp[20] = 0x00; |
Kovalev_D | 106:250ddd8629c6 | 430 | BuffTemp[21] = 0x00; |
Kovalev_D | 120:9f446f1495e8 | 431 | |
Kovalev_D | 119:4d7fcece9e8e | 432 | |
Kovalev_D | 125:9400e64d0636 | 433 | |
Kovalev_D | 121:bbae560cdd43 | 434 | Temp = Spi.DAC_B - 0x7fff; |
Kovalev_D | 108:030cdde08314 | 435 | BuffTemp[22] = (Temp >> 8) & 0xff; |
Kovalev_D | 108:030cdde08314 | 436 | BuffTemp[23] = (Temp >> 0) & 0xff; |
igor_v | 21:bc8c1cec3da6 | 437 | |
Kovalev_D | 121:bbae560cdd43 | 438 | |
Kovalev_D | 121:bbae560cdd43 | 439 | Temp = Gyro.PLC_Delta >> 16; |
Kovalev_D | 121:bbae560cdd43 | 440 | BuffTemp[24] = (Temp >> 8) & 0xff; |
Kovalev_D | 121:bbae560cdd43 | 441 | BuffTemp[25] = (Temp >> 0) & 0xff;// ХЗ |
Kovalev_D | 113:8be429494918 | 442 | |
Kovalev_D | 125:9400e64d0636 | 443 | Temp = 100; |
Kovalev_D | 125:9400e64d0636 | 444 | Temp = Gyro.AD_Slow >> 16; |
Kovalev_D | 113:8be429494918 | 445 | BuffTemp[26] = (Temp >> 8) & 0xff; |
Kovalev_D | 113:8be429494918 | 446 | BuffTemp[27] = (Temp >> 0) & 0xff; |
Kovalev_D | 113:8be429494918 | 447 | |
Kovalev_D | 113:8be429494918 | 448 | Temp = Gyro.AD_Slow >> 16; |
Kovalev_D | 113:8be429494918 | 449 | BuffTemp[28] = (Temp >> 8) & 0xff; |
Kovalev_D | 113:8be429494918 | 450 | BuffTemp[29] = (Temp >> 0) & 0xff; |
Kovalev_D | 113:8be429494918 | 451 | |
Kovalev_D | 113:8be429494918 | 452 | Temp = Gyro.In1; |
Kovalev_D | 113:8be429494918 | 453 | BuffTemp[30] = (Temp >> 8) & 0xff;//in1//2 |
Kovalev_D | 113:8be429494918 | 454 | BuffTemp[31] = (Temp >> 0) & 0xff; |
Kovalev_D | 113:8be429494918 | 455 | |
Kovalev_D | 113:8be429494918 | 456 | Temp = Gyro.In2; |
Kovalev_D | 113:8be429494918 | 457 | BuffTemp[32] = (Temp >> 8) & 0xff; |
Kovalev_D | 113:8be429494918 | 458 | BuffTemp[33] = (Temp >> 0) & 0xff;//in2//3 |
Kovalev_D | 113:8be429494918 | 459 | |
Kovalev_D | 113:8be429494918 | 460 | Temp = Gyro.DeltaT; |
Kovalev_D | 113:8be429494918 | 461 | BuffTemp[34] = (Temp >> 8) & 0xff;//дельта |
Kovalev_D | 113:8be429494918 | 462 | BuffTemp[35] = (Temp >> 0) & 0xff; |
Kovalev_D | 115:e5a230e5af52 | 463 | |
Kovalev_D | 116:66f1f0ff2dab | 464 | Temp = Gyro.Termo;//0xa4=164 |
Kovalev_D | 115:e5a230e5af52 | 465 | |
Kovalev_D | 113:8be429494918 | 466 | BuffTemp[36] =(Temp >> 8) & 0xff;//температура |
Kovalev_D | 115:e5a230e5af52 | 467 | BuffTemp[37] =(Temp >> 0) & 0xff;//ADC6 sesnsor 5 |
igor_v | 21:bc8c1cec3da6 | 468 | |
Kovalev_D | 106:250ddd8629c6 | 469 | BuffTemp[38] =0x00; |
Kovalev_D | 106:250ddd8629c6 | 470 | BuffTemp[39] =0x00; |
Kovalev_D | 106:250ddd8629c6 | 471 | BuffTemp[40] =0x00; |
Kovalev_D | 106:250ddd8629c6 | 472 | BuffTemp[41] =0x00; |
igor_v | 21:bc8c1cec3da6 | 473 | |
igor_v | 21:bc8c1cec3da6 | 474 | |
igor_v | 21:bc8c1cec3da6 | 475 | Check(BuffTemp, 44); |
igor_v | 21:bc8c1cec3da6 | 476 | WriteConN (BuffTemp,44); |
Kovalev_D | 92:c892f0311aa7 | 477 | |
igor_v | 0:8ad47e2b6f00 | 478 | } |
igor_v | 0:8ad47e2b6f00 | 479 | |
igor_v | 21:bc8c1cec3da6 | 480 | void CMD_M_Control_D8()///установка\сброс регистров управления |
igor_v | 21:bc8c1cec3da6 | 481 | { |
Kovalev_D | 104:ab1cb4ff56b2 | 482 | unsigned int bit,NReg,Pa; |
Kovalev_D | 104:ab1cb4ff56b2 | 483 | unsigned int SR,V,A,Bit_num; |
Kovalev_D | 104:ab1cb4ff56b2 | 484 | SR=0; |
Kovalev_D | 104:ab1cb4ff56b2 | 485 | V=0; |
Kovalev_D | 104:ab1cb4ff56b2 | 486 | A=0; |
Kovalev_D | 104:ab1cb4ff56b2 | 487 | Bit_num=0; |
Kovalev_D | 104:ab1cb4ff56b2 | 488 | |
igor_v | 28:17c84ed091b3 | 489 | BuffTemp[0] = Gyro.SOC_Out; //DD |
igor_v | 28:17c84ed091b3 | 490 | BuffTemp[1] = Gyro.My_Addres; //00 |
igor_v | 28:17c84ed091b3 | 491 | BuffTemp[2] = Gyro.CMD_In; //D8 |
Kovalev_D | 104:ab1cb4ff56b2 | 492 | |
Kovalev_D | 104:ab1cb4ff56b2 | 493 | /* |
Kovalev_D | 104:ab1cb4ff56b2 | 494 | |
Kovalev_D | 104:ab1cb4ff56b2 | 495 | FrqON |
Kovalev_D | 104:ab1cb4ff56b2 | 496 | PlcON |
Kovalev_D | 104:ab1cb4ff56b2 | 497 | HFOOFF |
Kovalev_D | 104:ab1cb4ff56b2 | 498 | HFOON |
igor_v | 21:bc8c1cec3da6 | 499 | |
Kovalev_D | 104:ab1cb4ff56b2 | 500 | PlcOFF |
Kovalev_D | 104:ab1cb4ff56b2 | 501 | PlcON |
Kovalev_D | 104:ab1cb4ff56b2 | 502 | */ |
Kovalev_D | 104:ab1cb4ff56b2 | 503 | Pa = BuffTemp[3]; |
Kovalev_D | 104:ab1cb4ff56b2 | 504 | |
Kovalev_D | 104:ab1cb4ff56b2 | 505 | SR = Pa >> 0x7; |
Kovalev_D | 104:ab1cb4ff56b2 | 506 | |
Kovalev_D | 104:ab1cb4ff56b2 | 507 | V = Pa >> 0x5; |
Kovalev_D | 104:ab1cb4ff56b2 | 508 | V = V & 0x3; |
Kovalev_D | 104:ab1cb4ff56b2 | 509 | |
Kovalev_D | 104:ab1cb4ff56b2 | 510 | A = Pa >> 0x4; |
Kovalev_D | 104:ab1cb4ff56b2 | 511 | A = A & 0x1; |
Kovalev_D | 104:ab1cb4ff56b2 | 512 | |
Kovalev_D | 104:ab1cb4ff56b2 | 513 | Bit_num = Pa & 0xf; |
Kovalev_D | 104:ab1cb4ff56b2 | 514 | |
Kovalev_D | 104:ab1cb4ff56b2 | 515 | if(SR) { |
Kovalev_D | 104:ab1cb4ff56b2 | 516 | switch (Bit_num){ |
Kovalev_D | 105:bd01d8d20fb6 | 517 | |
Kovalev_D | 104:ab1cb4ff56b2 | 518 | case 0x06: |
Kovalev_D | 104:ab1cb4ff56b2 | 519 | FrqON |
Kovalev_D | 105:bd01d8d20fb6 | 520 | break; |
Kovalev_D | 105:bd01d8d20fb6 | 521 | |
Kovalev_D | 104:ab1cb4ff56b2 | 522 | case 0x03: |
Kovalev_D | 105:bd01d8d20fb6 | 523 | HFOON |
Kovalev_D | 105:bd01d8d20fb6 | 524 | break; |
Kovalev_D | 105:bd01d8d20fb6 | 525 | |
Kovalev_D | 105:bd01d8d20fb6 | 526 | case 0x01: |
Kovalev_D | 105:bd01d8d20fb6 | 527 | PlcON |
Kovalev_D | 105:bd01d8d20fb6 | 528 | break; |
Kovalev_D | 104:ab1cb4ff56b2 | 529 | } |
Kovalev_D | 104:ab1cb4ff56b2 | 530 | } |
Kovalev_D | 104:ab1cb4ff56b2 | 531 | else{ |
Kovalev_D | 104:ab1cb4ff56b2 | 532 | switch (Bit_num){ |
Kovalev_D | 105:bd01d8d20fb6 | 533 | |
Kovalev_D | 105:bd01d8d20fb6 | 534 | case 0x06: |
Kovalev_D | 104:ab1cb4ff56b2 | 535 | FrqOff |
Kovalev_D | 105:bd01d8d20fb6 | 536 | break; |
Kovalev_D | 105:bd01d8d20fb6 | 537 | |
Kovalev_D | 105:bd01d8d20fb6 | 538 | case 0x03: |
Kovalev_D | 105:bd01d8d20fb6 | 539 | HFOOFF |
Kovalev_D | 105:bd01d8d20fb6 | 540 | break; |
Kovalev_D | 105:bd01d8d20fb6 | 541 | |
Kovalev_D | 105:bd01d8d20fb6 | 542 | case 0x01: |
Kovalev_D | 105:bd01d8d20fb6 | 543 | PlcOFF |
Kovalev_D | 105:bd01d8d20fb6 | 544 | break; |
Kovalev_D | 104:ab1cb4ff56b2 | 545 | } |
Kovalev_D | 104:ab1cb4ff56b2 | 546 | } |
igor_v | 21:bc8c1cec3da6 | 547 | |
igor_v | 0:8ad47e2b6f00 | 548 | } |
igor_v | 0:8ad47e2b6f00 | 549 | |
igor_v | 21:bc8c1cec3da6 | 550 | void CMD_M_Control_D9()///чтение регистров управления |
igor_v | 21:bc8c1cec3da6 | 551 | { |
igor_v | 21:bc8c1cec3da6 | 552 | int bit,NReg; |
igor_v | 28:17c84ed091b3 | 553 | BuffTemp[0] = Gyro.SOC_Out; //DD |
igor_v | 28:17c84ed091b3 | 554 | BuffTemp[1] = Gyro.My_Addres; //00 |
igor_v | 28:17c84ed091b3 | 555 | BuffTemp[2] = Gyro.CMD_In; //D9 |
igor_v | 21:bc8c1cec3da6 | 556 | if ((Param1 & 0x10) == 0) { |
igor_v | 21:bc8c1cec3da6 | 557 | BuffTemp[3]=0<<4; |
igor_v | 28:17c84ed091b3 | 558 | BuffTemp[4] = (Gyro.RgConA>>8 )& 0xff; |
igor_v | 28:17c84ed091b3 | 559 | BuffTemp[5] = Gyro.RgConA & 0xff; |
igor_v | 21:bc8c1cec3da6 | 560 | } else { |
igor_v | 21:bc8c1cec3da6 | 561 | BuffTemp[3]=1<<4; |
igor_v | 28:17c84ed091b3 | 562 | BuffTemp[4] = (Gyro.RgConB>>8 ) & 0xff; |
igor_v | 28:17c84ed091b3 | 563 | BuffTemp[5] = Gyro.RgConB & 0xff; |
igor_v | 21:bc8c1cec3da6 | 564 | } |
igor_v | 21:bc8c1cec3da6 | 565 | Check(BuffTemp, CRC_N); |
igor_v | 21:bc8c1cec3da6 | 566 | WriteConN (BuffTemp,CRC_N); |
igor_v | 21:bc8c1cec3da6 | 567 | } |
igor_v | 21:bc8c1cec3da6 | 568 | // (номер (код) ЦАПа 0...3, старший байт требуемого ЦАПа, младший байт треб ЦАПа) |
igor_v | 0:8ad47e2b6f00 | 569 | void CMD_M_Stymul() |
igor_v | 0:8ad47e2b6f00 | 570 | { |
igor_v | 21:bc8c1cec3da6 | 571 | int temp; |
Kovalev_D | 102:4270092be987 | 572 | int HFO; |
Kovalev_D | 102:4270092be987 | 573 | temp=BuffTemp[3]; |
Kovalev_D | 102:4270092be987 | 574 | Consol = temp&0x3; |
Kovalev_D | 103:e96f08947def | 575 | HFO = temp&0x3;// // (номер (код) ЦАПа 0...3, HFO - 3dac, PLC - 0DAC |
igor_v | 21:bc8c1cec3da6 | 576 | temp =((BuffTemp[4]<<8) | BuffTemp[5]); |
igor_v | 21:bc8c1cec3da6 | 577 | // temp=0; |
igor_v | 21:bc8c1cec3da6 | 578 | temp=temp&0xFFFF; |
Kovalev_D | 102:4270092be987 | 579 | |
Kovalev_D | 102:4270092be987 | 580 | if(HFO) |
Kovalev_D | 102:4270092be987 | 581 | { |
Kovalev_D | 102:4270092be987 | 582 | Spi.DAC_A=(unsigned int)temp; |
Kovalev_D | 102:4270092be987 | 583 | } |
Kovalev_D | 102:4270092be987 | 584 | else{ |
igor_v | 21:bc8c1cec3da6 | 585 | DACF =(temp*K_DAC)+deltaDAC; |
igor_v | 21:bc8c1cec3da6 | 586 | Spi.DAC_B =(unsigned int)(DACF) /*(unsigned int)(temp*K_DAC+deltaDAC)*/; // K_DAC); |
igor_v | 21:bc8c1cec3da6 | 587 | } |
igor_v | 0:8ad47e2b6f00 | 588 | } |
Kovalev_D | 103:e96f08947def | 589 | void Gph_W() |
Kovalev_D | 103:e96f08947def | 590 | { |
Kovalev_D | 108:030cdde08314 | 591 | Out_G_photo(BuffTemp[4],BuffTemp[5]); |
Kovalev_D | 103:e96f08947def | 592 | } |
igor_v | 0:8ad47e2b6f00 | 593 | |
Kovalev_D | 98:95b8e79f13e1 | 594 | void CMD_M_vib() |
Kovalev_D | 115:e5a230e5af52 | 595 | { |
Kovalev_D | 102:4270092be987 | 596 | unsigned int temp1,temp2; |
Kovalev_D | 102:4270092be987 | 597 | |
Kovalev_D | 102:4270092be987 | 598 | temp1 =((BuffTemp[4]<<8) | BuffTemp[5]); |
Kovalev_D | 102:4270092be987 | 599 | temp1=temp1&0xFFFF; |
Kovalev_D | 102:4270092be987 | 600 | |
Kovalev_D | 102:4270092be987 | 601 | temp2 =((BuffTemp[6]<<8) | BuffTemp[7]); |
Kovalev_D | 102:4270092be987 | 602 | temp2=temp2&0xFFFF; |
Kovalev_D | 102:4270092be987 | 603 | Gyro.Frq = ((unsigned int) ((7680000*16/temp1)))*16*16*16; |
Kovalev_D | 102:4270092be987 | 604 | Consol=Gyro.Frq ; |
Kovalev_D | 98:95b8e79f13e1 | 605 | } |
igor_v | 0:8ad47e2b6f00 | 606 | unsigned int Check(char *c, unsigned int Count) |
igor_v | 0:8ad47e2b6f00 | 607 | { |
igor_v | 21:bc8c1cec3da6 | 608 | int i=1; |
igor_v | 21:bc8c1cec3da6 | 609 | unsigned int temp,CRC; |
igor_v | 21:bc8c1cec3da6 | 610 | |
igor_v | 21:bc8c1cec3da6 | 611 | |
igor_v | 21:bc8c1cec3da6 | 612 | temp=1; |
igor_v | 21:bc8c1cec3da6 | 613 | CRC=0; |
igor_v | 21:bc8c1cec3da6 | 614 | |
igor_v | 21:bc8c1cec3da6 | 615 | |
igor_v | 21:bc8c1cec3da6 | 616 | for(; i<Count-2; i++) { |
igor_v | 21:bc8c1cec3da6 | 617 | CRC+=c[i]; |
igor_v | 21:bc8c1cec3da6 | 618 | } |
igor_v | 0:8ad47e2b6f00 | 619 | |
igor_v | 21:bc8c1cec3da6 | 620 | if(c[Count-2]!=((CRC>>8)&0xFF)) { |
igor_v | 21:bc8c1cec3da6 | 621 | temp=0; |
igor_v | 28:17c84ed091b3 | 622 | Gyro.RsErrLine = (Gyro.RsErrLine)&=0x2; |
igor_v | 21:bc8c1cec3da6 | 623 | } |
igor_v | 0:8ad47e2b6f00 | 624 | |
igor_v | 21:bc8c1cec3da6 | 625 | if(c[Count-1]!=((CRC>>0)&0xFF)) { |
igor_v | 21:bc8c1cec3da6 | 626 | temp=0; |
igor_v | 28:17c84ed091b3 | 627 | // Gyro.RsErrLine= (Gyro.RsErrLine)=0x2; |
igor_v | 21:bc8c1cec3da6 | 628 | } |
igor_v | 21:bc8c1cec3da6 | 629 | |
igor_v | 21:bc8c1cec3da6 | 630 | c[Count-2]=(CRC>>8)&0xFF; |
igor_v | 21:bc8c1cec3da6 | 631 | c[Count-1]=(CRC>>0)&0xFF; |
igor_v | 21:bc8c1cec3da6 | 632 | |
igor_v | 21:bc8c1cec3da6 | 633 | |
igor_v | 21:bc8c1cec3da6 | 634 | |
igor_v | 21:bc8c1cec3da6 | 635 | return temp; |
igor_v | 0:8ad47e2b6f00 | 636 | } |
igor_v | 0:8ad47e2b6f00 | 637 | |
igor_v | 0:8ad47e2b6f00 | 638 | int Getlengf(void) |
igor_v | 0:8ad47e2b6f00 | 639 | { |
Kovalev_D | 121:bbae560cdd43 | 640 | unsigned int lengf; |
Kovalev_D | 121:bbae560cdd43 | 641 | lengf = 1; |
igor_v | 28:17c84ed091b3 | 642 | switch(Gyro.CMD_In) { |
igor_v | 28:17c84ed091b3 | 643 | case 0x99://Gyrotainance |
Kovalev_D | 92:c892f0311aa7 | 644 | |
igor_v | 21:bc8c1cec3da6 | 645 | lengf=6; |
igor_v | 21:bc8c1cec3da6 | 646 | CRC_N=8; |
igor_v | 21:bc8c1cec3da6 | 647 | break; |
igor_v | 0:8ad47e2b6f00 | 648 | |
igor_v | 21:bc8c1cec3da6 | 649 | case 0x0A: //m_stymul |
igor_v | 21:bc8c1cec3da6 | 650 | lengf=8; |
igor_v | 21:bc8c1cec3da6 | 651 | break; |
igor_v | 21:bc8c1cec3da6 | 652 | |
igor_v | 21:bc8c1cec3da6 | 653 | case 0xA5://DeviceMode |
igor_v | 21:bc8c1cec3da6 | 654 | |
igor_v | 21:bc8c1cec3da6 | 655 | lengf=6; |
igor_v | 21:bc8c1cec3da6 | 656 | CRC_N=8; |
igor_v | 21:bc8c1cec3da6 | 657 | break; |
igor_v | 21:bc8c1cec3da6 | 658 | |
igor_v | 21:bc8c1cec3da6 | 659 | case 0xDD://m_rate |
igor_v | 21:bc8c1cec3da6 | 660 | lengf=6; |
igor_v | 21:bc8c1cec3da6 | 661 | CRC_N=44; |
igor_v | 21:bc8c1cec3da6 | 662 | break; |
Kovalev_D | 124:9ae09249f842 | 663 | |
Kovalev_D | 124:9ae09249f842 | 664 | case 0xA0://Delta_PS |
Kovalev_D | 124:9ae09249f842 | 665 | lengf=6; |
Kovalev_D | 124:9ae09249f842 | 666 | CRC_N=8; |
Kovalev_D | 124:9ae09249f842 | 667 | break; |
Kovalev_D | 124:9ae09249f842 | 668 | |
Kovalev_D | 124:9ae09249f842 | 669 | |
igor_v | 21:bc8c1cec3da6 | 670 | case 0xB0://DeviceMode |
igor_v | 21:bc8c1cec3da6 | 671 | |
igor_v | 21:bc8c1cec3da6 | 672 | lengf=6; |
igor_v | 21:bc8c1cec3da6 | 673 | CRC_N=8; |
igor_v | 21:bc8c1cec3da6 | 674 | break; |
igor_v | 21:bc8c1cec3da6 | 675 | |
igor_v | 21:bc8c1cec3da6 | 676 | case 0xD8://m_control |
igor_v | 0:8ad47e2b6f00 | 677 | |
igor_v | 21:bc8c1cec3da6 | 678 | lengf=6; |
igor_v | 21:bc8c1cec3da6 | 679 | CRC_N=8; |
igor_v | 21:bc8c1cec3da6 | 680 | break; |
igor_v | 21:bc8c1cec3da6 | 681 | |
igor_v | 21:bc8c1cec3da6 | 682 | case 0xD9://m_control |
igor_v | 0:8ad47e2b6f00 | 683 | |
igor_v | 21:bc8c1cec3da6 | 684 | lengf=6; |
igor_v | 21:bc8c1cec3da6 | 685 | CRC_N=8; |
igor_v | 21:bc8c1cec3da6 | 686 | break; |
Kovalev_D | 102:4270092be987 | 687 | |
Kovalev_D | 102:4270092be987 | 688 | case 0xE4: |
Kovalev_D | 98:95b8e79f13e1 | 689 | lengf=8; |
Kovalev_D | 98:95b8e79f13e1 | 690 | break; |
Kovalev_D | 103:e96f08947def | 691 | |
Kovalev_D | 103:e96f08947def | 692 | |
Kovalev_D | 103:e96f08947def | 693 | case 0xE6: |
Kovalev_D | 103:e96f08947def | 694 | lengf=8; |
Kovalev_D | 103:e96f08947def | 695 | break; |
Kovalev_D | 103:e96f08947def | 696 | |
igor_v | 21:bc8c1cec3da6 | 697 | } |
Kovalev_D | 98:95b8e79f13e1 | 698 | |
igor_v | 21:bc8c1cec3da6 | 699 | return lengf; |
igor_v | 0:8ad47e2b6f00 | 700 | } |
igor_v | 0:8ad47e2b6f00 | 701 | |
igor_v | 0:8ad47e2b6f00 | 702 | void Read_CMD(void) |
igor_v | 21:bc8c1cec3da6 | 703 | { |
Kovalev_D | 92:c892f0311aa7 | 704 | |
Kovalev_D | 45:cbc955aecebe | 705 | |
Kovalev_D | 45:cbc955aecebe | 706 | Gyro.RsErrLine = (Gyro.RsErrLine)& 0xffff;//для сброса ошибки |
igor_v | 21:bc8c1cec3da6 | 707 | |
Kovalev_D | 93:b3803774f110 | 708 | CountBuFFIn=ReadChekCon1(BuffTemp); // чтение данных из консоли |
igor_v | 42:6fc307c4963e | 709 | |
Kovalev_D | 92:c892f0311aa7 | 710 | if(CountBuFFIn==1) { // если есть первый байт |
igor_v | 21:bc8c1cec3da6 | 711 | if (BuffTemp[0] != SOC_In) { |
Kovalev_D | 93:b3803774f110 | 712 | ReadCon1(BuffTemp); |
igor_v | 28:17c84ed091b3 | 713 | Gyro.RsErrLine += 0x100;//WriteCon("\n\r ...Error.... "); |
Kovalev_D | 93:b3803774f110 | 714 | BuffTemp[99]=Gyro.RsErrLine; |
Kovalev_D | 102:4270092be987 | 715 | |
igor_v | 21:bc8c1cec3da6 | 716 | } |
Kovalev_D | 92:c892f0311aa7 | 717 | } else if(CountBuFFIn==2) { //если второй ,fqn |
igor_v | 28:17c84ed091b3 | 718 | if (BuffTemp[1] != Gyro.My_Addres) { |
Kovalev_D | 93:b3803774f110 | 719 | ReadCon1(BuffTemp); |
igor_v | 28:17c84ed091b3 | 720 | Gyro.RsErrLine += 0x1;//WriteCon("\n\r ...Error_ADDRES.... "); |
igor_v | 21:bc8c1cec3da6 | 721 | } |
igor_v | 42:6fc307c4963e | 722 | } else if(CountBuFFIn==3) { // если ьоетий байт |
igor_v | 28:17c84ed091b3 | 723 | Gyro.CMD_In=BuffTemp[2]; |
Kovalev_D | 92:c892f0311aa7 | 724 | N=Getlengf(); |
Kovalev_D | 92:c892f0311aa7 | 725 | } |
Kovalev_D | 92:c892f0311aa7 | 726 | else if(CountBuFFIn==4 && (N==6)) |
Kovalev_D | 92:c892f0311aa7 | 727 | { // N - длина посылки аскглд(для записи параметров). определяется по коду команды в Getlengf(); |
igor_v | 21:bc8c1cec3da6 | 728 | Param1=BuffTemp[3]; |
Kovalev_D | 92:c892f0311aa7 | 729 | } |
Kovalev_D | 92:c892f0311aa7 | 730 | else if((CountBuFFIn==5)&&(N==7)) |
Kovalev_D | 92:c892f0311aa7 | 731 | { |
Kovalev_D | 92:c892f0311aa7 | 732 | |
igor_v | 21:bc8c1cec3da6 | 733 | Param1=BuffTemp[3]; |
igor_v | 21:bc8c1cec3da6 | 734 | Param2=BuffTemp[4]; |
igor_v | 0:8ad47e2b6f00 | 735 | |
Kovalev_D | 92:c892f0311aa7 | 736 | } |
Kovalev_D | 92:c892f0311aa7 | 737 | else if((CountBuFFIn==6)&&(N==8)) |
Kovalev_D | 92:c892f0311aa7 | 738 | { |
igor_v | 21:bc8c1cec3da6 | 739 | Param1=BuffTemp[3]; |
igor_v | 21:bc8c1cec3da6 | 740 | Param2=BuffTemp[4]; |
igor_v | 21:bc8c1cec3da6 | 741 | Param3=BuffTemp[5]; |
Kovalev_D | 92:c892f0311aa7 | 742 | } |
Kovalev_D | 102:4270092be987 | 743 | else if((CountBuFFIn==8)&&(N==10)) |
Kovalev_D | 102:4270092be987 | 744 | { |
Kovalev_D | 102:4270092be987 | 745 | Param1=BuffTemp[4]; |
Kovalev_D | 102:4270092be987 | 746 | Param2=BuffTemp[5]; |
Kovalev_D | 102:4270092be987 | 747 | Param3=BuffTemp[6]; |
Kovalev_D | 102:4270092be987 | 748 | Param4=BuffTemp[7]; |
Kovalev_D | 102:4270092be987 | 749 | } |
Kovalev_D | 98:95b8e79f13e1 | 750 | |
Kovalev_D | 92:c892f0311aa7 | 751 | else if(CountBuFFIn > (N-1)) |
Kovalev_D | 92:c892f0311aa7 | 752 | { |
Kovalev_D | 93:b3803774f110 | 753 | ReadCon1(BuffTemp); |
igor_v | 28:17c84ed091b3 | 754 | switch(Gyro.CMD_In) { |
Kovalev_D | 122:fbacb932a30b | 755 | Rate_Flag=0; |
Kovalev_D | 92:c892f0311aa7 | 756 | case 0x99: |
Kovalev_D | 124:9ae09249f842 | 757 | Gyro.ModeOut=0; |
igor_v | 21:bc8c1cec3da6 | 758 | CMD_Maintenance(); |
Kovalev_D | 124:9ae09249f842 | 759 | break; |
Kovalev_D | 124:9ae09249f842 | 760 | case 0xA0: |
Kovalev_D | 124:9ae09249f842 | 761 | TempParam=(BuffTemp[3]) & 0x90; |
Kovalev_D | 124:9ae09249f842 | 762 | if (TempParam==Delta_500) CMD_Delta_500Hz(); |
Kovalev_D | 124:9ae09249f842 | 763 | else if (TempParam==Delta_EXT) CMD_Delta_Ext(); |
Kovalev_D | 124:9ae09249f842 | 764 | else if (TempParam==PDelta_500) { Gyro.ModeOut=3; Gyro.Delta500_Event=0; WriteCon("Delta500"); } |
Kovalev_D | 124:9ae09249f842 | 765 | else if (TempParam==PDelta_EXT) { Gyro.ModeOut=4; Gyro.DeltaEXT_Event=0; WriteCon("deltaEXT"); } |
igor_v | 21:bc8c1cec3da6 | 766 | break; |
igor_v | 21:bc8c1cec3da6 | 767 | case 0xD8: |
igor_v | 21:bc8c1cec3da6 | 768 | CMD_M_Control_D8(); |
Kovalev_D | 124:9ae09249f842 | 769 | break; |
igor_v | 21:bc8c1cec3da6 | 770 | case 0xD9: |
igor_v | 21:bc8c1cec3da6 | 771 | CMD_M_Control_D9(); |
igor_v | 21:bc8c1cec3da6 | 772 | break; |
igor_v | 21:bc8c1cec3da6 | 773 | case 0x0A: |
Kovalev_D | 45:cbc955aecebe | 774 | CMD_M_Stymul(); |
igor_v | 21:bc8c1cec3da6 | 775 | break; |
igor_v | 21:bc8c1cec3da6 | 776 | case 0xDD: |
Kovalev_D | 124:9ae09249f842 | 777 | TempParam=(BuffTemp[3]) & 0x9f; |
Kovalev_D | 124:9ae09249f842 | 778 | if (TempParam == Rate1) { CMD_Rate(); WriteCon("Rate11");} |
Kovalev_D | 124:9ae09249f842 | 779 | else if (TempParam == Rate2) { CMD_Rate2(); WriteCon("Rate21");} |
Kovalev_D | 124:9ae09249f842 | 780 | else if (TempParam == PRate1) { Gyro.ModeOut=1; Gyro.Rate1_Event=0; WriteCon("Rate12");} |
Kovalev_D | 124:9ae09249f842 | 781 | else if (TempParam == PRate2) { Gyro.ModeOut=2; Gyro.Rate2_Event=0; WriteCon("Rate22");} |
Kovalev_D | 122:fbacb932a30b | 782 | break; |
Kovalev_D | 102:4270092be987 | 783 | case 0xE4: |
Kovalev_D | 102:4270092be987 | 784 | CMD_M_vib(); |
Kovalev_D | 102:4270092be987 | 785 | break; |
Kovalev_D | 103:e96f08947def | 786 | case 0xE6: |
Kovalev_D | 103:e96f08947def | 787 | Gph_W(); |
Kovalev_D | 103:e96f08947def | 788 | break; |
Kovalev_D | 108:030cdde08314 | 789 | |
Kovalev_D | 103:e96f08947def | 790 | |
igor_v | 28:17c84ed091b3 | 791 | Gyro.RsErrLine = 0; |
Kovalev_D | 103:e96f08947def | 792 | |
Kovalev_D | 103:e96f08947def | 793 | |
Kovalev_D | 102:4270092be987 | 794 | } |
Kovalev_D | 121:bbae560cdd43 | 795 | |
igor_v | 21:bc8c1cec3da6 | 796 | } |
Kovalev_D | 121:bbae560cdd43 | 797 | // else if(CountBuFFIn > 40 ) |
Kovalev_D | 121:bbae560cdd43 | 798 | // { |
Kovalev_D | 121:bbae560cdd43 | 799 | // ReadCon1(BuffTemp); |
Kovalev_D | 121:bbae560cdd43 | 800 | // } |
Kovalev_D | 121:bbae560cdd43 | 801 | |
igor_v | 0:8ad47e2b6f00 | 802 | } |
igor_v | 0:8ad47e2b6f00 | 803 | |
igor_v | 0:8ad47e2b6f00 | 804 | |
igor_v | 21:bc8c1cec3da6 | 805 |