![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
fork
Fork of LG by
Command.c@208:19150d2b528f, 2017-02-07 (annotated)
- Committer:
- Kovalev_D
- Date:
- Tue Feb 07 10:11:35 2017 +0000
- Revision:
- 208:19150d2b528f
- Parent:
- 207:d1ce992f5d17
- Child:
- 209:224e7331a061
465
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
igor_v | 0:8ad47e2b6f00 | 1 | #include "stdlib.h" |
Kovalev_D | 197:7a05523bf588 | 2 | //#include "math.h" |
igor_v | 0:8ad47e2b6f00 | 3 | #include "LPC17xx.h" |
igor_v | 0:8ad47e2b6f00 | 4 | #include "Global.h" |
Kovalev_D | 106:250ddd8629c6 | 5 | int tempNH,tempNL; |
igor_v | 0:8ad47e2b6f00 | 6 | unsigned int Rate_Flag; |
igor_v | 0:8ad47e2b6f00 | 7 | unsigned int CountBuFFIn; |
igor_v | 21:bc8c1cec3da6 | 8 | unsigned int N=0,CRC_N; |
igor_v | 21:bc8c1cec3da6 | 9 | unsigned int Param1=0; |
igor_v | 21:bc8c1cec3da6 | 10 | unsigned int Param2=0; |
igor_v | 21:bc8c1cec3da6 | 11 | unsigned int Param3=0; |
igor_v | 21:bc8c1cec3da6 | 12 | unsigned int Param4=0; |
Kovalev_D | 102:4270092be987 | 13 | unsigned int Consol=123; |
Kovalev_D | 121:bbae560cdd43 | 14 | unsigned int TempParam=1; |
Kovalev_D | 124:9ae09249f842 | 15 | unsigned int CountParam=0; |
Kovalev_D | 208:19150d2b528f | 16 | int d8_anser=0,A=0,SA=0; |
Kovalev_D | 148:7ce8c1fd00f7 | 17 | int ttemp; |
Kovalev_D | 197:7a05523bf588 | 18 | int OLDDAC=0; |
Kovalev_D | 205:775d54fdf646 | 19 | int rr = 123; |
Kovalev_D | 136:19b9e6abb86f | 20 | unsigned int pDestT ; |
Kovalev_D | 136:19b9e6abb86f | 21 | GyroParam *Flash; |
Kovalev_D | 147:1aed74f19a8f | 22 | ///////////////flah and boot/////////// |
Kovalev_D | 147:1aed74f19a8f | 23 | void GoBoot(void) |
Kovalev_D | 147:1aed74f19a8f | 24 | { |
Kovalev_D | 147:1aed74f19a8f | 25 | /* Prepare Sectors to be flashed */ |
Kovalev_D | 147:1aed74f19a8f | 26 | NVIC_DisableIRQ(TIMER1_IRQn); |
Kovalev_D | 147:1aed74f19a8f | 27 | NVIC_DisableIRQ(TIMER2_IRQn); |
Kovalev_D | 147:1aed74f19a8f | 28 | NVIC_DisableIRQ(TIMER3_IRQn); |
Kovalev_D | 147:1aed74f19a8f | 29 | NVIC_DisableIRQ(EINT3_IRQn); |
Kovalev_D | 147:1aed74f19a8f | 30 | SystemInitDef(); |
Kovalev_D | 147:1aed74f19a8f | 31 | vIAP_ReinvokeISP(); |
Kovalev_D | 147:1aed74f19a8f | 32 | } |
Kovalev_D | 181:0b022246c43c | 33 | |
Kovalev_D | 181:0b022246c43c | 34 | void DropDelay(void) |
Kovalev_D | 181:0b022246c43c | 35 | { |
Kovalev_D | 181:0b022246c43c | 36 | Gyro.DropDelayGLD = DropDelayGLD_0; |
Kovalev_D | 194:8f3cb37a5541 | 37 | switch(Gyro.My_Addres) { |
Kovalev_D | 194:8f3cb37a5541 | 38 | case 1: Gyro.DropDelayGLD = DropDelayGLD_1; break; |
Kovalev_D | 194:8f3cb37a5541 | 39 | case 2: Gyro.DropDelayGLD = DropDelayGLD_2; break; |
Kovalev_D | 194:8f3cb37a5541 | 40 | case 3: Gyro.DropDelayGLD = DropDelayGLD_3; break; |
Kovalev_D | 194:8f3cb37a5541 | 41 | } |
Kovalev_D | 194:8f3cb37a5541 | 42 | |
Kovalev_D | 181:0b022246c43c | 43 | } |
Kovalev_D | 205:775d54fdf646 | 44 | /* |
Kovalev_D | 147:1aed74f19a8f | 45 | void WriteFlash(void) |
Kovalev_D | 147:1aed74f19a8f | 46 | { |
Kovalev_D | 205:775d54fdf646 | 47 | |
Kovalev_D | 147:1aed74f19a8f | 48 | SystemInitDef(); |
Kovalev_D | 147:1aed74f19a8f | 49 | WriteCon("\r\n Start Prepare Sectors"); |
Kovalev_D | 205:775d54fdf646 | 50 | if(u32IAP_PrepareSectors(5, 5) == IAP_STA_CMD_SUCCESS) |
Kovalev_D | 147:1aed74f19a8f | 51 | { |
Kovalev_D | 147:1aed74f19a8f | 52 | WriteCon("\r\nPrepare Sectors OK"); |
Kovalev_D | 147:1aed74f19a8f | 53 | WriteCon("\r\n Start Erase"); |
Kovalev_D | 147:1aed74f19a8f | 54 | u32IAP_EraseSectors(IMG_START_SECTOR, IMG_END_SECTOR); |
Kovalev_D | 147:1aed74f19a8f | 55 | WriteCon("\r\n AND Erase"); |
Kovalev_D | 147:1aed74f19a8f | 56 | } |
Kovalev_D | 205:775d54fdf646 | 57 | else WriteCon("\r\nPrepare Sectors ERROR "); |
Kovalev_D | 147:1aed74f19a8f | 58 | SystemInit1(); |
Kovalev_D | 147:1aed74f19a8f | 59 | Gyro.FlashMod = 0; |
Kovalev_D | 169:140743e3bb96 | 60 | } |
Kovalev_D | 205:775d54fdf646 | 61 | */ |
Kovalev_D | 205:775d54fdf646 | 62 | void EraseFlash(void) |
Kovalev_D | 205:775d54fdf646 | 63 | { |
Kovalev_D | 207:d1ce992f5d17 | 64 | rr = u32IAP_PrepareSectors(19, 21); |
Kovalev_D | 205:775d54fdf646 | 65 | sprintf((Time)," dffddfd <%07d> ",rr); |
Kovalev_D | 205:775d54fdf646 | 66 | WriteCon(Time); |
Kovalev_D | 207:d1ce992f5d17 | 67 | rr = u32IAP_EraseSectors(19, 21); |
Kovalev_D | 205:775d54fdf646 | 68 | sprintf((Time)," dffddfd <%07d> ",rr); |
Kovalev_D | 205:775d54fdf646 | 69 | WriteCon(Time); |
Kovalev_D | 205:775d54fdf646 | 70 | } |
Kovalev_D | 205:775d54fdf646 | 71 | |
Kovalev_D | 205:775d54fdf646 | 72 | void WriteFlash(void) |
Kovalev_D | 205:775d54fdf646 | 73 | |
Kovalev_D | 208:19150d2b528f | 74 | { |
Kovalev_D | 208:19150d2b528f | 75 | Gyro.FlashMod = 0; |
Kovalev_D | 205:775d54fdf646 | 76 | |
Kovalev_D | 205:775d54fdf646 | 77 | //SystemInitDef(); |
Kovalev_D | 205:775d54fdf646 | 78 | NVIC_DisableIRQ(TIMER1_IRQn); |
Kovalev_D | 205:775d54fdf646 | 79 | NVIC_DisableIRQ(TIMER2_IRQn); |
Kovalev_D | 205:775d54fdf646 | 80 | NVIC_DisableIRQ(TIMER3_IRQn); |
Kovalev_D | 205:775d54fdf646 | 81 | NVIC_DisableIRQ(EINT3_IRQn); |
Kovalev_D | 205:775d54fdf646 | 82 | |
Kovalev_D | 208:19150d2b528f | 83 | // unsigned int start_address = (unsigned int) & GyroP; |
Kovalev_D | 207:d1ce992f5d17 | 84 | rr = u32IAP_PrepareSectors(19, 21); |
Kovalev_D | 208:19150d2b528f | 85 | rr = u32IAP_EraseSectors (19, 21); |
Kovalev_D | 207:d1ce992f5d17 | 86 | rr = u32IAP_PrepareSectors(19, 21); |
Kovalev_D | 208:19150d2b528f | 87 | rr = u32IAP_CopyRAMToFlash(0x030000, &GyroP , 1024); |
Kovalev_D | 205:775d54fdf646 | 88 | // SystemInit1(); // Инициализация контроллера: установка тактовых частот |
Kovalev_D | 205:775d54fdf646 | 89 | //SystemCoreClockUpdate1(); // расчет тактовой частоты процессора перед инициализацией UART - 103MHz |
Kovalev_D | 205:775d54fdf646 | 90 | |
Kovalev_D | 205:775d54fdf646 | 91 | NVIC_EnableIRQ(TIMER1_IRQn); |
Kovalev_D | 205:775d54fdf646 | 92 | NVIC_EnableIRQ(TIMER2_IRQn); |
Kovalev_D | 205:775d54fdf646 | 93 | NVIC_EnableIRQ(TIMER3_IRQn); |
Kovalev_D | 205:775d54fdf646 | 94 | NVIC_EnableIRQ(EINT3_IRQn); |
Kovalev_D | 208:19150d2b528f | 95 | //SystemCoreClockUpdate1(); |
Kovalev_D | 205:775d54fdf646 | 96 | |
Kovalev_D | 205:775d54fdf646 | 97 | } |
Kovalev_D | 136:19b9e6abb86f | 98 | void ReadFlash ( void) |
Kovalev_D | 136:19b9e6abb86f | 99 | { |
Kovalev_D | 205:775d54fdf646 | 100 | NVIC_DisableIRQ(TIMER1_IRQn); |
Kovalev_D | 205:775d54fdf646 | 101 | NVIC_DisableIRQ(TIMER2_IRQn); |
Kovalev_D | 205:775d54fdf646 | 102 | NVIC_DisableIRQ(TIMER3_IRQn); |
Kovalev_D | 205:775d54fdf646 | 103 | NVIC_DisableIRQ(EINT3_IRQn); |
Kovalev_D | 147:1aed74f19a8f | 104 | Gyro.FlashMod = 0; |
Kovalev_D | 136:19b9e6abb86f | 105 | WriteCon("\r\n Pirivet Flash"); |
Kovalev_D | 205:775d54fdf646 | 106 | |
Kovalev_D | 207:d1ce992f5d17 | 107 | pDestT= (unsigned int) (0x030000); |
Kovalev_D | 136:19b9e6abb86f | 108 | Flash = (GyroParam*) pDestT; |
Kovalev_D | 136:19b9e6abb86f | 109 | GyroP = *(Flash); |
Kovalev_D | 205:775d54fdf646 | 110 | |
Kovalev_D | 205:775d54fdf646 | 111 | NVIC_EnableIRQ(TIMER1_IRQn); |
Kovalev_D | 205:775d54fdf646 | 112 | NVIC_EnableIRQ(TIMER2_IRQn); |
Kovalev_D | 205:775d54fdf646 | 113 | NVIC_EnableIRQ(TIMER3_IRQn); |
Kovalev_D | 205:775d54fdf646 | 114 | NVIC_EnableIRQ(EINT3_IRQn); |
Kovalev_D | 208:19150d2b528f | 115 | } |
Kovalev_D | 169:140743e3bb96 | 116 | ///////////////end flah and boot/////////// |
Kovalev_D | 191:40028201ddad | 117 | void M_RateA(void) |
Kovalev_D | 193:a0fe8bfc97e4 | 118 | { |
Kovalev_D | 191:40028201ddad | 119 | switch(Gyro.ModeOut) { |
Kovalev_D | 193:a0fe8bfc97e4 | 120 | case 1: if(Gyro.Rate1_Event ) CMD_Rate(); break; |
Kovalev_D | 208:19150d2b528f | 121 | case 2: if(Gyro.Reper_Event ) CMD_Rate2(); break; |
Kovalev_D | 196:f76dbc081e63 | 122 | case 3: if(Gyro.Event_500Hz ) CMD_Delta_PS(); break; |
Kovalev_D | 196:f76dbc081e63 | 123 | case 4: if(Gyro.EXT_Latch ) CMD_Delta_PS(); break; |
Kovalev_D | 196:f76dbc081e63 | 124 | case 5: if(Gyro.Event_500Hz ) CMD_Delta_Bins(); break; |
Kovalev_D | 205:775d54fdf646 | 125 | case 6: if(Gyro.EXT_Latch ) CMD_B_Delta(); break; |
Kovalev_D | 196:f76dbc081e63 | 126 | case 7: if(Gyro.Event_500Hz ) CMD_B_Delta(); break; |
Kovalev_D | 196:f76dbc081e63 | 127 | } |
Kovalev_D | 191:40028201ddad | 128 | } |
Kovalev_D | 136:19b9e6abb86f | 129 | |
Kovalev_D | 129:406995a91322 | 130 | void CMD_M_Param_R(void) |
igor_v | 0:8ad47e2b6f00 | 131 | { |
Kovalev_D | 208:19150d2b528f | 132 | |
Kovalev_D | 208:19150d2b528f | 133 | unsigned int NP=0; |
Kovalev_D | 129:406995a91322 | 134 | unsigned int Param; |
Kovalev_D | 208:19150d2b528f | 135 | |
Kovalev_D | 208:19150d2b528f | 136 | NP = BuffTemp[3]; |
Kovalev_D | 208:19150d2b528f | 137 | |
Kovalev_D | 208:19150d2b528f | 138 | |
Kovalev_D | 208:19150d2b528f | 139 | |
Kovalev_D | 208:19150d2b528f | 140 | |
Kovalev_D | 129:406995a91322 | 141 | BuffTemp[0] = Gyro.SOC_Out; |
Kovalev_D | 129:406995a91322 | 142 | BuffTemp[1] = Gyro.My_Addres; |
Kovalev_D | 129:406995a91322 | 143 | |
Kovalev_D | 208:19150d2b528f | 144 | |
Kovalev_D | 208:19150d2b528f | 145 | sprintf((Time),"%d = %d \r\n",NP, GyroP.Array[NP]); |
Kovalev_D | 208:19150d2b528f | 146 | WriteCon(Time); |
Kovalev_D | 129:406995a91322 | 147 | Param = GyroP.Array[NP]; |
Kovalev_D | 208:19150d2b528f | 148 | BuffTemp[2] =(GyroP.Array[NP] >> 8) & 0xff;//старший байт требуемого параметра |
Kovalev_D | 208:19150d2b528f | 149 | BuffTemp[3] =(GyroP.Array[NP] >> 0) & 0xff;//младший байт требуемого параметра |
Kovalev_D | 129:406995a91322 | 150 | |
Kovalev_D | 129:406995a91322 | 151 | Check(BuffTemp, 6); |
Kovalev_D | 129:406995a91322 | 152 | WriteConN (BuffTemp,6); |
Kovalev_D | 205:775d54fdf646 | 153 | /*sprintf((Time),"READ Param = <%07d> GyroP.Array[NP] = <%07d> NP= <%07d> Gyro.CaunPlus+Gyro.CaunMin-5000 <%07d> \r\n",Param, GyroP.Array[NP], NP, GyroP.Str.PLC_Lern); |
Kovalev_D | 205:775d54fdf646 | 154 | WriteCon(Time);*/ |
Kovalev_D | 208:19150d2b528f | 155 | NP=0; |
Kovalev_D | 129:406995a91322 | 156 | } |
Kovalev_D | 129:406995a91322 | 157 | void CMD_M_Param_W(void) |
Kovalev_D | 129:406995a91322 | 158 | { |
Kovalev_D | 208:19150d2b528f | 159 | unsigned int NP=0; |
Kovalev_D | 208:19150d2b528f | 160 | unsigned int Param,temp,flash; |
Kovalev_D | 129:406995a91322 | 161 | |
Kovalev_D | 129:406995a91322 | 162 | NP = BuffTemp[3]; |
Kovalev_D | 129:406995a91322 | 163 | Param = (BuffTemp[4]<<8); |
Kovalev_D | 129:406995a91322 | 164 | Param |= BuffTemp[5]; |
Kovalev_D | 129:406995a91322 | 165 | |
Kovalev_D | 208:19150d2b528f | 166 | GyroP.Array[NP] = Param; |
Kovalev_D | 208:19150d2b528f | 167 | flash=GyroP.Array[5]; |
Kovalev_D | 208:19150d2b528f | 168 | sprintf((Time),"%d\r\n",NP); |
Kovalev_D | 208:19150d2b528f | 169 | WriteCon(Time); |
Kovalev_D | 208:19150d2b528f | 170 | switch(NP) |
Kovalev_D | 208:19150d2b528f | 171 | { |
Kovalev_D | 208:19150d2b528f | 172 | case 0: Gyro.My_Addres = GyroP.Str.My_Addres; break; |
Kovalev_D | 208:19150d2b528f | 173 | case 3: Spi.DAC_A = GyroP.Str.DAC_current_Work; break; |
Kovalev_D | 208:19150d2b528f | 174 | case 7: Gyro.PLC_Phase = GyroP.Str.PLC_Phase; break; |
Kovalev_D | 208:19150d2b528f | 175 | case 8: Gyro.PLC_Gain = GyroP.Str.PLC_Gain; break; |
Kovalev_D | 208:19150d2b528f | 176 | case 12: Gyro.FrqPhase = GyroP.Str.FrqPhase; break; |
Kovalev_D | 208:19150d2b528f | 177 | case 13: Gyro.FrqChengSpeed = GyroP.Str.FrqChengSpeed; break; |
Kovalev_D | 208:19150d2b528f | 178 | |
Kovalev_D | 208:19150d2b528f | 179 | case 14: Gyro.FrqHZ = GyroP.Str.FrqHZ; |
Kovalev_D | 208:19150d2b528f | 180 | Gyro.Frq = GyroP.Str.FrqHZ<<16; |
Kovalev_D | 208:19150d2b528f | 181 | break; |
Kovalev_D | 208:19150d2b528f | 182 | |
Kovalev_D | 208:19150d2b528f | 183 | case 15: Gyro.FrqHZmin = GyroP.Str.FrqHZmin<<16; break; |
Kovalev_D | 208:19150d2b528f | 184 | case 16: Gyro.FrqHZmax = GyroP.Str.FrqHZmax<<16; break; |
Kovalev_D | 208:19150d2b528f | 185 | |
Kovalev_D | 208:19150d2b528f | 186 | case 18: temp=((GyroP.Str.VB_Fdf_Hi<<16) | GyroP.Str.VB_Fdf_Lo); |
Kovalev_D | 208:19150d2b528f | 187 | temp=temp/18.2; |
Kovalev_D | 208:19150d2b528f | 188 | Gyro.AmpTarget=(unsigned int)(temp); |
Kovalev_D | 208:19150d2b528f | 189 | break; |
Kovalev_D | 208:19150d2b528f | 190 | |
Kovalev_D | 208:19150d2b528f | 191 | case 19: Gyro.AmpSpeed = GyroP.Str.AmpSpeed; break; |
Kovalev_D | 208:19150d2b528f | 192 | case 20: Gyro.AmpPerMin = GyroP.Str.AmpPerMin; break; |
Kovalev_D | 208:19150d2b528f | 193 | case 21: Gyro.AmpPerMax = GyroP.Str.AmpPerMax; break; |
Kovalev_D | 208:19150d2b528f | 194 | |
Kovalev_D | 208:19150d2b528f | 195 | case 22: Gyro.AmpPer = GyroP.Str.AmpPer; |
Kovalev_D | 208:19150d2b528f | 196 | Gyro.Amp = GyroP.Str.AmpPer<<16; |
Kovalev_D | 208:19150d2b528f | 197 | break; |
Kovalev_D | 208:19150d2b528f | 198 | |
Kovalev_D | 208:19150d2b528f | 199 | case 23: Gyro.AmpMin = GyroP.Str.AmpMin; break; |
Kovalev_D | 208:19150d2b528f | 200 | case 24: Gyro.AmpTD = GyroP.Str.AmpTD; break; |
Kovalev_D | 208:19150d2b528f | 201 | case 25: Gyro.AmpPerDel = GyroP.Str.AmpPerDel; break; |
Kovalev_D | 208:19150d2b528f | 202 | case 34: Gyro.ModAmp = GyroP.Str.ModAmp; break; |
Kovalev_D | 208:19150d2b528f | 203 | case 56: Gyro.Gain_Sin = GyroP.Str.Gain_Sin; |
Kovalev_D | 208:19150d2b528f | 204 | Out_G_photo(Gyro.Gain_Sin, Gyro.Gain_Cos); |
Kovalev_D | 208:19150d2b528f | 205 | break; |
Kovalev_D | 208:19150d2b528f | 206 | case 57: Gyro.Gain_Cos = GyroP.Str.Gain_Cos; |
Kovalev_D | 208:19150d2b528f | 207 | Out_G_photo(Gyro.Gain_Sin, Gyro.Gain_Cos); |
Kovalev_D | 208:19150d2b528f | 208 | break; |
Kovalev_D | 208:19150d2b528f | 209 | case 60: Gyro.GLD_Serial = GyroP.Str.GLD_Serial; break; |
Kovalev_D | 208:19150d2b528f | 210 | } |
Kovalev_D | 208:19150d2b528f | 211 | |
Kovalev_D | 208:19150d2b528f | 212 | NP=0; |
Kovalev_D | 129:406995a91322 | 213 | |
Kovalev_D | 129:406995a91322 | 214 | BuffTemp[0] = Gyro.SOC_Out; |
Kovalev_D | 129:406995a91322 | 215 | BuffTemp[1] = Gyro.My_Addres; |
Kovalev_D | 129:406995a91322 | 216 | BuffTemp[2] = Gyro.CMD_In; |
Kovalev_D | 208:19150d2b528f | 217 | BuffTemp[3] =0; //(//GyroP.Array[NP]>> 8) & 0xff;//старший байт требуемого параметра |
Kovalev_D | 129:406995a91322 | 218 | |
Kovalev_D | 129:406995a91322 | 219 | Check(BuffTemp, 6); |
Kovalev_D | 129:406995a91322 | 220 | WriteConN (BuffTemp,6); |
Kovalev_D | 208:19150d2b528f | 221 | if(flash){GyroP.Array[5]=0; flash=0; WriteFlash(); ReadFlash ();} |
Kovalev_D | 208:19150d2b528f | 222 | |
Kovalev_D | 208:19150d2b528f | 223 | |
Kovalev_D | 129:406995a91322 | 224 | } |
igor_v | 0:8ad47e2b6f00 | 225 | void CMD_Maintenance(void) |
igor_v | 0:8ad47e2b6f00 | 226 | { |
Kovalev_D | 208:19150d2b528f | 227 | // Gyro.ModeOut=0; |
Kovalev_D | 208:19150d2b528f | 228 | //Gyro.DropDelayGLD = DropDelayGLD_0;//задержка на выдачу 45 микросекунд для любого адреса ГЛД |
Kovalev_D | 122:fbacb932a30b | 229 | BuffTemp[0] = Gyro.SOC_Out; |
Kovalev_D | 124:9ae09249f842 | 230 | BuffTemp[1] = Gyro.My_Addres; |
Kovalev_D | 124:9ae09249f842 | 231 | BuffTemp[2] = Gyro.Firmware_Version; |
Kovalev_D | 169:140743e3bb96 | 232 | BuffTemp[3] = Gyro.GLD_Serial; |
igor_v | 21:bc8c1cec3da6 | 233 | BuffTemp[4]=0x00; |
igor_v | 21:bc8c1cec3da6 | 234 | BuffTemp[5]=0x00; |
igor_v | 21:bc8c1cec3da6 | 235 | Check(BuffTemp, 8); |
igor_v | 21:bc8c1cec3da6 | 236 | WriteConN (BuffTemp,8); |
Kovalev_D | 121:bbae560cdd43 | 237 | |
igor_v | 0:8ad47e2b6f00 | 238 | } |
Kovalev_D | 193:a0fe8bfc97e4 | 239 | void CMD_B_Delta(void) |
Kovalev_D | 193:a0fe8bfc97e4 | 240 | { |
Kovalev_D | 196:f76dbc081e63 | 241 | Gyro.Event_500Hz=0; |
Kovalev_D | 205:775d54fdf646 | 242 | Gyro.EXT_Latch=0; |
Kovalev_D | 193:a0fe8bfc97e4 | 243 | unsigned int Temp; |
Kovalev_D | 193:a0fe8bfc97e4 | 244 | BuffTemp[ 0] = Gyro.SOC_Out; |
Kovalev_D | 193:a0fe8bfc97e4 | 245 | BuffTemp[ 1] = Gyro.My_Addres; |
Kovalev_D | 193:a0fe8bfc97e4 | 246 | |
Kovalev_D | 193:a0fe8bfc97e4 | 247 | Temp = Gyro.CuruAngle; |
Kovalev_D | 193:a0fe8bfc97e4 | 248 | Gyro.CuruAngle = 0; |
Kovalev_D | 193:a0fe8bfc97e4 | 249 | BuffTemp[ 2] =(Temp >> 16) & 0xff;//младший байт разности счетчиков |
Kovalev_D | 193:a0fe8bfc97e4 | 250 | BuffTemp[ 3] =(Temp >> 8) & 0xff;//младший байт разности счетчиков |
Kovalev_D | 193:a0fe8bfc97e4 | 251 | BuffTemp[ 4] =(Temp >> 0) & 0xff;//младший байт разности счетчиков |
Kovalev_D | 193:a0fe8bfc97e4 | 252 | BuffTemp[ 5] = 0x00000000; |
Kovalev_D | 193:a0fe8bfc97e4 | 253 | Check(BuffTemp, 8); |
Kovalev_D | 193:a0fe8bfc97e4 | 254 | WriteConN (BuffTemp,8); |
Kovalev_D | 208:19150d2b528f | 255 | |
Kovalev_D | 193:a0fe8bfc97e4 | 256 | } |
Kovalev_D | 165:b2bd0c810a4f | 257 | |
Kovalev_D | 193:a0fe8bfc97e4 | 258 | void CMD_Delta_Bins(void) |
Kovalev_D | 196:f76dbc081e63 | 259 | { Gyro.Event_500Hz=0; |
Kovalev_D | 193:a0fe8bfc97e4 | 260 | unsigned int Temp; |
Kovalev_D | 193:a0fe8bfc97e4 | 261 | BuffTemp[ 0] = Gyro.SOC_Out; |
Kovalev_D | 193:a0fe8bfc97e4 | 262 | BuffTemp[ 1] = Gyro.My_Addres; |
Kovalev_D | 193:a0fe8bfc97e4 | 263 | |
Kovalev_D | 193:a0fe8bfc97e4 | 264 | Temp = Gyro.CuruAngle; |
Kovalev_D | 193:a0fe8bfc97e4 | 265 | Gyro.CuruAngle = 0; |
Kovalev_D | 193:a0fe8bfc97e4 | 266 | |
Kovalev_D | 193:a0fe8bfc97e4 | 267 | BuffTemp[ 2] =(Temp >> 24) & 0xff;//старший байт разности счетчиков |
Kovalev_D | 193:a0fe8bfc97e4 | 268 | BuffTemp[ 3] =(Temp >> 16) & 0xff;//младший байт разности счетчиков |
Kovalev_D | 193:a0fe8bfc97e4 | 269 | BuffTemp[ 4] =(Temp >> 8) & 0xff;//младший байт разности счетчиков |
Kovalev_D | 193:a0fe8bfc97e4 | 270 | BuffTemp[ 5] =(Temp >> 0) & 0xff;//младший байт разности счетчиков |
Kovalev_D | 193:a0fe8bfc97e4 | 271 | BuffTemp[ 6] = 0x0000; |
Kovalev_D | 193:a0fe8bfc97e4 | 272 | Check(BuffTemp, 9); |
Kovalev_D | 193:a0fe8bfc97e4 | 273 | WriteConN (BuffTemp,9); |
Kovalev_D | 193:a0fe8bfc97e4 | 274 | } |
Kovalev_D | 193:a0fe8bfc97e4 | 275 | void CMD_Delta_PS(void) |
Kovalev_D | 124:9ae09249f842 | 276 | { |
Kovalev_D | 193:a0fe8bfc97e4 | 277 | Gyro.EXT_Latch=0; |
Kovalev_D | 196:f76dbc081e63 | 278 | Gyro.Event_500Hz=0; |
Kovalev_D | 122:fbacb932a30b | 279 | unsigned int Temp; |
Kovalev_D | 124:9ae09249f842 | 280 | BuffTemp[ 0] = Gyro.SOC_Out; |
Kovalev_D | 122:fbacb932a30b | 281 | BuffTemp[ 1] = Gyro.My_Addres; |
Kovalev_D | 208:19150d2b528f | 282 | |
Kovalev_D | 193:a0fe8bfc97e4 | 283 | Temp = Gyro.CuruAngle; |
Kovalev_D | 124:9ae09249f842 | 284 | Gyro.CuruAngle = 0; |
Kovalev_D | 124:9ae09249f842 | 285 | |
Kovalev_D | 124:9ae09249f842 | 286 | BuffTemp[ 2] =(Temp >> 8) & 0xff;//старший байт разности счетчиков |
Kovalev_D | 124:9ae09249f842 | 287 | BuffTemp[ 3] =(Temp >> 0) & 0xff;//младший байт разности счетчиков |
Kovalev_D | 124:9ae09249f842 | 288 | |
Kovalev_D | 124:9ae09249f842 | 289 | BuffTemp[ 4] = CountParam; |
Kovalev_D | 124:9ae09249f842 | 290 | switch(CountParam) { |
Kovalev_D | 182:ebcd2bc3be8f | 291 | |
Kovalev_D | 124:9ae09249f842 | 292 | //F_ras |
Kovalev_D | 124:9ae09249f842 | 293 | case 0: |
Kovalev_D | 124:9ae09249f842 | 294 | Temp = Gyro.F_ras; |
Kovalev_D | 124:9ae09249f842 | 295 | BuffTemp[5] = (Temp >> 8) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 296 | break; |
Kovalev_D | 124:9ae09249f842 | 297 | |
Kovalev_D | 124:9ae09249f842 | 298 | case 1: |
Kovalev_D | 124:9ae09249f842 | 299 | BuffTemp[5] = (Temp >> 0) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 300 | break; |
Kovalev_D | 208:19150d2b528f | 301 | |
Kovalev_D | 124:9ae09249f842 | 302 | |
Kovalev_D | 124:9ae09249f842 | 303 | //HFO |
Kovalev_D | 124:9ae09249f842 | 304 | case 2: |
Kovalev_D | 124:9ae09249f842 | 305 | Temp = 0;//HFO |
Kovalev_D | 124:9ae09249f842 | 306 | BuffTemp[5] = (Temp >> 8) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 307 | break; |
Kovalev_D | 124:9ae09249f842 | 308 | |
Kovalev_D | 124:9ae09249f842 | 309 | case 3: |
Kovalev_D | 124:9ae09249f842 | 310 | Temp = 0;//HFO |
Kovalev_D | 124:9ae09249f842 | 311 | BuffTemp[5] = (Temp >> 0) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 312 | break; |
Kovalev_D | 124:9ae09249f842 | 313 | |
Kovalev_D | 124:9ae09249f842 | 314 | |
Kovalev_D | 124:9ae09249f842 | 315 | |
Kovalev_D | 124:9ae09249f842 | 316 | //T_Vibro |
Kovalev_D | 124:9ae09249f842 | 317 | case 4: |
Kovalev_D | 124:9ae09249f842 | 318 | Temp = (unsigned int)((7680000*16/(Gyro.Frq>>12))); |
Kovalev_D | 124:9ae09249f842 | 319 | BuffTemp[5] = (Temp >> 8) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 320 | break; |
Kovalev_D | 124:9ae09249f842 | 321 | |
Kovalev_D | 124:9ae09249f842 | 322 | case 5: |
Kovalev_D | 124:9ae09249f842 | 323 | BuffTemp[5] = (Temp >> 0) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 324 | break; |
Kovalev_D | 124:9ae09249f842 | 325 | |
Kovalev_D | 124:9ae09249f842 | 326 | |
Kovalev_D | 124:9ae09249f842 | 327 | |
Kovalev_D | 124:9ae09249f842 | 328 | //L_Vibro |
Kovalev_D | 124:9ae09249f842 | 329 | case 6: |
Kovalev_D | 124:9ae09249f842 | 330 | Temp = (unsigned int)(((7680000*16/200) *Gyro.AmpPer /(Gyro.Frq>>12))); |
Kovalev_D | 124:9ae09249f842 | 331 | BuffTemp[5] = (Temp >> 8) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 332 | |
Kovalev_D | 124:9ae09249f842 | 333 | break; |
Kovalev_D | 124:9ae09249f842 | 334 | |
Kovalev_D | 124:9ae09249f842 | 335 | case 7: |
Kovalev_D | 124:9ae09249f842 | 336 | BuffTemp[5] = (Temp >> 0) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 337 | break; |
Kovalev_D | 124:9ae09249f842 | 338 | |
Kovalev_D | 124:9ae09249f842 | 339 | |
Kovalev_D | 124:9ae09249f842 | 340 | |
Kovalev_D | 124:9ae09249f842 | 341 | //Напряжение на регуляторе периметра |
Kovalev_D | 124:9ae09249f842 | 342 | case 8: |
Kovalev_D | 165:b2bd0c810a4f | 343 | Temp = Spi.DAC_B /*- 0x7fff*/; |
Kovalev_D | 124:9ae09249f842 | 344 | BuffTemp[5] = (Temp >> 8) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 345 | |
Kovalev_D | 124:9ae09249f842 | 346 | break; |
Kovalev_D | 124:9ae09249f842 | 347 | |
Kovalev_D | 124:9ae09249f842 | 348 | case 9: |
Kovalev_D | 124:9ae09249f842 | 349 | BuffTemp[5] = (Temp >> 0) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 350 | break; |
Kovalev_D | 124:9ae09249f842 | 351 | |
Kovalev_D | 124:9ae09249f842 | 352 | |
Kovalev_D | 124:9ae09249f842 | 353 | |
Kovalev_D | 124:9ae09249f842 | 354 | //темпкратурный канал 0 |
Kovalev_D | 124:9ae09249f842 | 355 | case 10: |
Kovalev_D | 124:9ae09249f842 | 356 | Temp = 100; |
Kovalev_D | 124:9ae09249f842 | 357 | BuffTemp[5] = (Temp >> 8) & 0xff; |
igor_v | 0:8ad47e2b6f00 | 358 | |
Kovalev_D | 124:9ae09249f842 | 359 | break; |
Kovalev_D | 124:9ae09249f842 | 360 | |
Kovalev_D | 124:9ae09249f842 | 361 | case 11: |
Kovalev_D | 124:9ae09249f842 | 362 | BuffTemp[5] = (Temp >> 0) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 363 | break; |
Kovalev_D | 124:9ae09249f842 | 364 | |
Kovalev_D | 124:9ae09249f842 | 365 | |
Kovalev_D | 124:9ae09249f842 | 366 | |
Kovalev_D | 177:1666a83d88a5 | 367 | //f |
Kovalev_D | 124:9ae09249f842 | 368 | case 12: |
Kovalev_D | 124:9ae09249f842 | 369 | Temp = Gyro.AD_Slow >> 16; |
Kovalev_D | 124:9ae09249f842 | 370 | BuffTemp[5] = (Temp >> 8) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 371 | |
Kovalev_D | 124:9ae09249f842 | 372 | break; |
Kovalev_D | 124:9ae09249f842 | 373 | |
Kovalev_D | 124:9ae09249f842 | 374 | case 13: |
Kovalev_D | 124:9ae09249f842 | 375 | BuffTemp[5] = (Temp >> 0) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 376 | break; |
Kovalev_D | 124:9ae09249f842 | 377 | |
Kovalev_D | 124:9ae09249f842 | 378 | |
Kovalev_D | 124:9ae09249f842 | 379 | |
Kovalev_D | 124:9ae09249f842 | 380 | //ток 1 |
Kovalev_D | 124:9ae09249f842 | 381 | case 14: |
Kovalev_D | 124:9ae09249f842 | 382 | Temp = Gyro.In1; |
Kovalev_D | 124:9ae09249f842 | 383 | BuffTemp[5] = (Temp >> 8) & 0xff;//in1//2 |
Kovalev_D | 124:9ae09249f842 | 384 | |
Kovalev_D | 124:9ae09249f842 | 385 | break; |
Kovalev_D | 124:9ae09249f842 | 386 | |
Kovalev_D | 124:9ae09249f842 | 387 | case 15: |
Kovalev_D | 124:9ae09249f842 | 388 | BuffTemp[5] = (Temp >> 0) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 389 | break; |
Kovalev_D | 124:9ae09249f842 | 390 | |
Kovalev_D | 124:9ae09249f842 | 391 | |
Kovalev_D | 124:9ae09249f842 | 392 | |
Kovalev_D | 124:9ae09249f842 | 393 | //ток 2 |
Kovalev_D | 124:9ae09249f842 | 394 | case 16: |
Kovalev_D | 124:9ae09249f842 | 395 | Temp = Gyro.In2; |
Kovalev_D | 124:9ae09249f842 | 396 | BuffTemp[5] = (Temp >> 8) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 397 | break; |
Kovalev_D | 124:9ae09249f842 | 398 | |
Kovalev_D | 124:9ae09249f842 | 399 | case 17: |
Kovalev_D | 124:9ae09249f842 | 400 | BuffTemp[5] = (Temp >> 0) & 0xff;//in2//3 |
Kovalev_D | 124:9ae09249f842 | 401 | break; |
Kovalev_D | 124:9ae09249f842 | 402 | |
Kovalev_D | 124:9ae09249f842 | 403 | |
Kovalev_D | 124:9ae09249f842 | 404 | |
Kovalev_D | 124:9ae09249f842 | 405 | //разностный температурный канал Delta Temp |
Kovalev_D | 124:9ae09249f842 | 406 | case 18: |
Kovalev_D | 124:9ae09249f842 | 407 | Temp = Gyro.DeltaT; |
Kovalev_D | 124:9ae09249f842 | 408 | BuffTemp[5] = (Temp >> 8) & 0xff;//дельта |
Kovalev_D | 124:9ae09249f842 | 409 | break; |
Kovalev_D | 124:9ae09249f842 | 410 | |
Kovalev_D | 124:9ae09249f842 | 411 | case 19: |
Kovalev_D | 124:9ae09249f842 | 412 | BuffTemp[5] = (Temp >> 0) & 0xff; |
Kovalev_D | 124:9ae09249f842 | 413 | break; |
Kovalev_D | 124:9ae09249f842 | 414 | |
Kovalev_D | 124:9ae09249f842 | 415 | |
Kovalev_D | 124:9ae09249f842 | 416 | |
Kovalev_D | 124:9ae09249f842 | 417 | //температурный канал 5 |
Kovalev_D | 124:9ae09249f842 | 418 | case 20: |
Kovalev_D | 124:9ae09249f842 | 419 | Temp = Gyro.Termo;//0xa4=164 |
Kovalev_D | 124:9ae09249f842 | 420 | BuffTemp[5] =(Temp >> 8) & 0xff;//температура |
Kovalev_D | 124:9ae09249f842 | 421 | |
Kovalev_D | 124:9ae09249f842 | 422 | break; |
Kovalev_D | 124:9ae09249f842 | 423 | |
Kovalev_D | 124:9ae09249f842 | 424 | case 21: |
Kovalev_D | 124:9ae09249f842 | 425 | BuffTemp[5] =(Temp >> 0) & 0xff;//ADC6 sesnsor 5 |
Kovalev_D | 124:9ae09249f842 | 426 | break; |
Kovalev_D | 124:9ae09249f842 | 427 | } |
Kovalev_D | 162:44e4ded32c6a | 428 | Check(BuffTemp, CRC_N); |
Kovalev_D | 162:44e4ded32c6a | 429 | WriteConN (BuffTemp,CRC_N); |
Kovalev_D | 128:1e4675a36c93 | 430 | |
Kovalev_D | 165:b2bd0c810a4f | 431 | |
Kovalev_D | 165:b2bd0c810a4f | 432 | if(CountParam>20)CountParam=0;//зацикливания буфера от 0 до 21 |
Kovalev_D | 165:b2bd0c810a4f | 433 | else CountParam++; |
Kovalev_D | 124:9ae09249f842 | 434 | |
Kovalev_D | 124:9ae09249f842 | 435 | } |
Kovalev_D | 124:9ae09249f842 | 436 | |
Kovalev_D | 121:bbae560cdd43 | 437 | void CMD_Rate2(void) |
Kovalev_D | 121:bbae560cdd43 | 438 | { |
Kovalev_D | 193:a0fe8bfc97e4 | 439 | Gyro.Reper_Event=0; |
Kovalev_D | 121:bbae560cdd43 | 440 | BuffTemp[ 0] = Gyro.SOC_Out; |
Kovalev_D | 121:bbae560cdd43 | 441 | BuffTemp[ 1] = Gyro.My_Addres; |
Kovalev_D | 121:bbae560cdd43 | 442 | |
Kovalev_D | 121:bbae560cdd43 | 443 | |
Kovalev_D | 121:bbae560cdd43 | 444 | BuffTemp[ 2] =(Gyro.CaunPlus >> 8) & 0xff;//старший байт счетчика +. |
Kovalev_D | 121:bbae560cdd43 | 445 | BuffTemp[ 3] =(Gyro.CaunPlus >> 0) & 0xff;//младший байт счетчика +. |
Kovalev_D | 121:bbae560cdd43 | 446 | |
Kovalev_D | 121:bbae560cdd43 | 447 | BuffTemp[ 4] =(Gyro.CaunMin >> 8) & 0xff;//старший байт счетчика -. |
Kovalev_D | 121:bbae560cdd43 | 448 | BuffTemp[ 5] =(Gyro.CaunMin >> 0) & 0xff;//младший байт счетчика -. |
Kovalev_D | 124:9ae09249f842 | 449 | |
Kovalev_D | 122:fbacb932a30b | 450 | Check(BuffTemp, 8); |
Kovalev_D | 122:fbacb932a30b | 451 | WriteConN (BuffTemp,8); |
Kovalev_D | 121:bbae560cdd43 | 452 | } |
Kovalev_D | 124:9ae09249f842 | 453 | |
igor_v | 0:8ad47e2b6f00 | 454 | void CMD_Rate(void) |
Kovalev_D | 190:289514f730ee | 455 | { |
Kovalev_D | 124:9ae09249f842 | 456 | Gyro.Rate1_Event=0; |
Kovalev_D | 108:030cdde08314 | 457 | unsigned int Temp; |
Kovalev_D | 208:19150d2b528f | 458 | int Temp1; |
Kovalev_D | 191:40028201ddad | 459 | unsigned int OldCuruAngle; |
Kovalev_D | 122:fbacb932a30b | 460 | |
Kovalev_D | 208:19150d2b528f | 461 | BuffTemp[ 0] = Gyro.SOC_Out; //1 --старт данных |
Kovalev_D | 208:19150d2b528f | 462 | BuffTemp[ 1] = Gyro.My_Addres; //2 --адрес отвечающего устройствва |
igor_v | 21:bc8c1cec3da6 | 463 | |
Kovalev_D | 208:19150d2b528f | 464 | BuffTemp[ 2] =(Gyro.CaunPlus >> 8) & 0xff;//старший байт счетчика +. 3 --сарший байт счентчика + |
Kovalev_D | 208:19150d2b528f | 465 | BuffTemp[ 3] =(Gyro.CaunPlus >> 0) & 0xff;//младший байт счетчика +. 4 --младший байт счетчика + |
Kovalev_D | 191:40028201ddad | 466 | |
Kovalev_D | 208:19150d2b528f | 467 | BuffTemp[ 4] =(Gyro.CaunMin >> 8) & 0xff;//старший байт счетчика -. 5 --сарший байт счентчика - |
Kovalev_D | 208:19150d2b528f | 468 | BuffTemp[ 5] =(Gyro.CaunMin >> 0) & 0xff;//младший байт счетчика -. 6 --младший байт счетчика - |
Kovalev_D | 208:19150d2b528f | 469 | |
Kovalev_D | 208:19150d2b528f | 470 | Temp=Gyro.CuruAngle; //(0,28/с) |
Kovalev_D | 208:19150d2b528f | 471 | //8 байт + 4 байта от прошлых измерений |
Kovalev_D | 208:19150d2b528f | 472 | //Gyro.CuruAngle = Gyro.CuruAngle + OldCuruAngle; //(72 град/с) |
Kovalev_D | 208:19150d2b528f | 473 | /* OldCuruAngle=Gyro.CuruAngle & 0xff; //сохраняем 4 байта для след измирений |
Kovalev_D | 208:19150d2b528f | 474 | Temp=Gyro.CuruAngle>>8; */ //приводим к форме вывода |
Kovalev_D | 208:19150d2b528f | 475 | |
Kovalev_D | 208:19150d2b528f | 476 | /* //(9 град/с) |
Kovalev_D | 208:19150d2b528f | 477 | OldCuruAngle=Gyro.CuruAngle & 0x1f; //сохраняем 5 бит для след измирений |
Kovalev_D | 208:19150d2b528f | 478 | Temp=Gyro.CuruAngle>>5; */ //приводим к форме вывода |
Kovalev_D | 208:19150d2b528f | 479 | |
Kovalev_D | 208:19150d2b528f | 480 | Gyro.CuruAngle = 0; |
Kovalev_D | 208:19150d2b528f | 481 | BuffTemp[ 6] =(Temp >> 8) & 0xff;//старший байт разности счетчиков 7 --младший байт разности счетчиков |
Kovalev_D | 208:19150d2b528f | 482 | BuffTemp[ 7] =(Temp >> 0) & 0xff;//младший байт разности счетчиков 8 --старший байт разности счетчиков |
Kovalev_D | 108:030cdde08314 | 483 | |
Kovalev_D | 108:030cdde08314 | 484 | |
Kovalev_D | 208:19150d2b528f | 485 | BuffTemp[38] =(Temp >> 24) & 0xff;; //39 приращение угла |
Kovalev_D | 208:19150d2b528f | 486 | BuffTemp[39] =(Temp >> 16) & 0xff;; //40 формат 22.10 |
Kovalev_D | 208:19150d2b528f | 487 | BuffTemp[40] =(Temp >> 8) & 0xff;; //41 1бит знак |
Kovalev_D | 208:19150d2b528f | 488 | BuffTemp[41] =(Temp >> 0) & 0xff;; //42 |
Kovalev_D | 208:19150d2b528f | 489 | |
Kovalev_D | 208:19150d2b528f | 490 | |
Kovalev_D | 208:19150d2b528f | 491 | |
Kovalev_D | 208:19150d2b528f | 492 | |
Kovalev_D | 208:19150d2b528f | 493 | |
Kovalev_D | 208:19150d2b528f | 494 | Temp = Gyro.F_ras; |
Kovalev_D | 208:19150d2b528f | 495 | BuffTemp[ 8] = (Temp >> 8) & 0xff;//расщипление частота 9 --частота расщипления |
Kovalev_D | 208:19150d2b528f | 496 | BuffTemp[ 9] = (Temp >> 0) & 0xff;// 10 --частота расщипления |
Kovalev_D | 208:19150d2b528f | 497 | |
Kovalev_D | 208:19150d2b528f | 498 | Temp = 0xffff;//HFO |
Kovalev_D | 208:19150d2b528f | 499 | BuffTemp[10] = (Temp >> 8) & 0xff;//выход регулятора гвч; 11 --выход регулятора ГВЧ |
Kovalev_D | 208:19150d2b528f | 500 | BuffTemp[11] = (Temp >> 0) & 0xff; //12 --выход регулятора ГВЧ |
igor_v | 21:bc8c1cec3da6 | 501 | |
Kovalev_D | 208:19150d2b528f | 502 | Temp =0xffff; |
Kovalev_D | 208:19150d2b528f | 503 | BuffTemp[12]=(Temp >> 8) & 0xff;//// HFO 13 --сигнал ошибки регулятора ГВЧ |
Kovalev_D | 208:19150d2b528f | 504 | BuffTemp[13]=(Temp >> 0) & 0xff;//// 14 --сигнал ошибки регулятора ГВЧ |
igor_v | 21:bc8c1cec3da6 | 505 | |
Kovalev_D | 108:030cdde08314 | 506 | |
Kovalev_D | 208:19150d2b528f | 507 | Temp = (unsigned int)((7675000*16/(Gyro.Frq>>12))); |
Kovalev_D | 208:19150d2b528f | 508 | BuffTemp[14] = (Temp >> 8) & 0xff; //15 период вибропривода.(частота) T_Vibro |
Kovalev_D | 208:19150d2b528f | 509 | BuffTemp[15] = (Temp >> 0) & 0xff; //16 период вибропривода. |
Kovalev_D | 208:19150d2b528f | 510 | |
Kovalev_D | 208:19150d2b528f | 511 | Temp =0xff; |
Kovalev_D | 208:19150d2b528f | 512 | BuffTemp[16] = 0x00; //17 старший байт ФД регулятора периода вибропривода |
Kovalev_D | 208:19150d2b528f | 513 | BuffTemp[17] = 0x00; //18 |
Kovalev_D | 108:030cdde08314 | 514 | |
igor_v | 21:bc8c1cec3da6 | 515 | |
Kovalev_D | 208:19150d2b528f | 516 | Temp = Gyro.L_vibro>>1;//(unsigned int)(((7675000*16/200) * Gyro.AmpPer /(Gyro.Frq>>12))); |
Kovalev_D | 208:19150d2b528f | 517 | BuffTemp[18] = (Temp >> 8) & 0xff; //19 длительность импулься вибропривода(амплитуда) |
Kovalev_D | 208:19150d2b528f | 518 | BuffTemp[19] = (Temp >> 0) & 0xff; //20 |
Kovalev_D | 208:19150d2b528f | 519 | |
Kovalev_D | 208:19150d2b528f | 520 | |
Kovalev_D | 208:19150d2b528f | 521 | Temp = 0x0;//Gyro.L_vibro<<2; |
Kovalev_D | 208:19150d2b528f | 522 | BuffTemp[20] = (Temp >> 8) & 0xff;//регулятор датчика угла поворота //21 старший байт регулятора датчика угла поворота |
Kovalev_D | 208:19150d2b528f | 523 | BuffTemp[21] = (Temp >> 0) & 0xff; //22 |
Kovalev_D | 208:19150d2b528f | 524 | |
Kovalev_D | 208:19150d2b528f | 525 | Temp = (Spi.DAC_B - 0x7fff); |
Kovalev_D | 208:19150d2b528f | 526 | BuffTemp[22] = (Temp >> 8) & 0xff; //23 Выход регулятора рабочего периметра |
Kovalev_D | 208:19150d2b528f | 527 | BuffTemp[23] = (Temp >> 0) & 0xff; //24 |
Kovalev_D | 120:9f446f1495e8 | 528 | |
Kovalev_D | 208:19150d2b528f | 529 | Temp =0x0; //Gyro.AD_Slow >> 16; |
Kovalev_D | 208:19150d2b528f | 530 | BuffTemp[24] = (Temp >> 8) & 0xff;// //25 ФД СРП |
Kovalev_D | 208:19150d2b528f | 531 | BuffTemp[25] = (Temp >> 0) & 0xff;// //26 ФД СРП |
Kovalev_D | 113:8be429494918 | 532 | |
Kovalev_D | 177:1666a83d88a5 | 533 | Temp = Gyro.AD_Slow >> 16; |
Kovalev_D | 208:19150d2b528f | 534 | BuffTemp[26] = (Temp >> 8) & 0xff; //27 ADC 0 |
Kovalev_D | 208:19150d2b528f | 535 | BuffTemp[27] = (Temp >> 0) & 0xff; //28 |
Kovalev_D | 113:8be429494918 | 536 | |
Kovalev_D | 208:19150d2b528f | 537 | Temp = Gyro.AD_Slow >> 16; |
Kovalev_D | 208:19150d2b528f | 538 | BuffTemp[28] = (Temp >> 8) & 0xff; //29 ADC 1 |
Kovalev_D | 208:19150d2b528f | 539 | BuffTemp[29] = (Temp >> 0) & 0xff; //30 |
Kovalev_D | 113:8be429494918 | 540 | |
Kovalev_D | 208:19150d2b528f | 541 | Temp = (Gyro.In1 - 0x7fff); |
Kovalev_D | 208:19150d2b528f | 542 | BuffTemp[30] = (Temp >> 8) & 0xff;//in1//2 //31 ADC 2 |
Kovalev_D | 208:19150d2b528f | 543 | BuffTemp[31] = (Temp >> 0) & 0xff; //32 |
Kovalev_D | 208:19150d2b528f | 544 | |
Kovalev_D | 208:19150d2b528f | 545 | Temp = (Gyro.In2 - 0x7fff); |
Kovalev_D | 208:19150d2b528f | 546 | BuffTemp[32] = (Temp >> 8) & 0xff; //33 ADC 3 |
Kovalev_D | 208:19150d2b528f | 547 | BuffTemp[33] = (Temp >> 0) & 0xff;//in2//3 //34 |
Kovalev_D | 208:19150d2b528f | 548 | |
Kovalev_D | 195:bcc769f5292b | 549 | |
Kovalev_D | 208:19150d2b528f | 550 | Temp = (Gyro.DeltaT); |
Kovalev_D | 208:19150d2b528f | 551 | BuffTemp[34] = (Temp >> 8) & 0xff;//дельта //35 ADC 4 |
Kovalev_D | 208:19150d2b528f | 552 | BuffTemp[35] = (Temp >> 0) & 0xff; //36 |
Kovalev_D | 208:19150d2b528f | 553 | // Temp = 000; |
Kovalev_D | 208:19150d2b528f | 554 | |
Kovalev_D | 208:19150d2b528f | 555 | Temp = Gyro.Termo; |
Kovalev_D | 208:19150d2b528f | 556 | BuffTemp[36] =(Temp >> 8) & 0xff;//температура //37 ADC 5 |
Kovalev_D | 208:19150d2b528f | 557 | BuffTemp[37] =(Temp >> 0) & 0xff;//ADC6 sesnsor 5 //38 |
igor_v | 21:bc8c1cec3da6 | 558 | |
igor_v | 21:bc8c1cec3da6 | 559 | |
igor_v | 21:bc8c1cec3da6 | 560 | |
igor_v | 21:bc8c1cec3da6 | 561 | Check(BuffTemp, 44); |
igor_v | 21:bc8c1cec3da6 | 562 | WriteConN (BuffTemp,44); |
Kovalev_D | 92:c892f0311aa7 | 563 | |
igor_v | 0:8ad47e2b6f00 | 564 | } |
Kovalev_D | 179:2b4e6bc277df | 565 | void CMD_M_vib() |
Kovalev_D | 179:2b4e6bc277df | 566 | { |
Kovalev_D | 179:2b4e6bc277df | 567 | unsigned int temp1,temp2; |
igor_v | 0:8ad47e2b6f00 | 568 | |
Kovalev_D | 179:2b4e6bc277df | 569 | temp1 =((BuffTemp[4]<<8) | BuffTemp[5]); |
Kovalev_D | 179:2b4e6bc277df | 570 | temp1=temp1&0xFFFF; |
Kovalev_D | 207:d1ce992f5d17 | 571 | |
Kovalev_D | 208:19150d2b528f | 572 | Gyro.Frq=(122780000/temp1)<<12; |
Kovalev_D | 179:2b4e6bc277df | 573 | |
Kovalev_D | 179:2b4e6bc277df | 574 | temp2 =((BuffTemp[6]<<8) | BuffTemp[7]); |
Kovalev_D | 179:2b4e6bc277df | 575 | temp2=temp2&0xFFFF; |
Kovalev_D | 179:2b4e6bc277df | 576 | |
Kovalev_D | 208:19150d2b528f | 577 | |
Kovalev_D | 208:19150d2b528f | 578 | Gyro.AmpPer=((((((Gyro.Frq>>12)*200)/16)*temp2)/7675000)/2); |
Kovalev_D | 179:2b4e6bc277df | 579 | } |
igor_v | 21:bc8c1cec3da6 | 580 | void CMD_M_Control_D8()///установка\сброс регистров управления |
igor_v | 21:bc8c1cec3da6 | 581 | { |
Kovalev_D | 207:d1ce992f5d17 | 582 | unsigned int bit,Pa; |
Kovalev_D | 208:19150d2b528f | 583 | unsigned int SR,V,Bit_num; |
Kovalev_D | 104:ab1cb4ff56b2 | 584 | SR=0; |
Kovalev_D | 104:ab1cb4ff56b2 | 585 | V=0; |
Kovalev_D | 104:ab1cb4ff56b2 | 586 | A=0; |
Kovalev_D | 104:ab1cb4ff56b2 | 587 | Bit_num=0; |
Kovalev_D | 104:ab1cb4ff56b2 | 588 | |
igor_v | 30:17c84ed091b3 | 589 | BuffTemp[0] = Gyro.SOC_Out; //DD |
igor_v | 30:17c84ed091b3 | 590 | BuffTemp[1] = Gyro.My_Addres; //00 |
igor_v | 30:17c84ed091b3 | 591 | BuffTemp[2] = Gyro.CMD_In; //D8 |
Kovalev_D | 208:19150d2b528f | 592 | // Gyro.CMD_In = BuffTemp[2]; |
Kovalev_D | 104:ab1cb4ff56b2 | 593 | Pa = BuffTemp[3]; |
Kovalev_D | 104:ab1cb4ff56b2 | 594 | SR = Pa >> 0x7; |
Kovalev_D | 104:ab1cb4ff56b2 | 595 | V = Pa >> 0x5; |
Kovalev_D | 104:ab1cb4ff56b2 | 596 | V = V & 0x3; |
Kovalev_D | 104:ab1cb4ff56b2 | 597 | A = Pa >> 0x4; |
Kovalev_D | 104:ab1cb4ff56b2 | 598 | A = A & 0x1; |
Kovalev_D | 104:ab1cb4ff56b2 | 599 | Bit_num = Pa & 0xf; |
Kovalev_D | 208:19150d2b528f | 600 | if(A) |
Kovalev_D | 208:19150d2b528f | 601 | { |
Kovalev_D | 208:19150d2b528f | 602 | if(SR) |
Kovalev_D | 208:19150d2b528f | 603 | { |
Kovalev_D | 208:19150d2b528f | 604 | switch (Bit_num) |
Kovalev_D | 208:19150d2b528f | 605 | { |
Kovalev_D | 208:19150d2b528f | 606 | case 0x00: Gyro.RgConB &= ~ 1<<0; break; |
Kovalev_D | 208:19150d2b528f | 607 | case 0x01: Gyro.RgConB &= ~ 1<<1; break; |
Kovalev_D | 208:19150d2b528f | 608 | case 0x02: Gyro.RgConB &= ~ 1<<2; break; |
Kovalev_D | 208:19150d2b528f | 609 | } |
Kovalev_D | 208:19150d2b528f | 610 | } |
Kovalev_D | 208:19150d2b528f | 611 | else |
Kovalev_D | 208:19150d2b528f | 612 | { |
Kovalev_D | 208:19150d2b528f | 613 | |
Kovalev_D | 208:19150d2b528f | 614 | switch (Bit_num) |
Kovalev_D | 208:19150d2b528f | 615 | { |
Kovalev_D | 208:19150d2b528f | 616 | |
Kovalev_D | 208:19150d2b528f | 617 | case 0x00: Gyro.RgConB = 0xfffe; break; |
Kovalev_D | 208:19150d2b528f | 618 | case 0x01: Gyro.RgConB |= 1<<1; break; |
Kovalev_D | 208:19150d2b528f | 619 | case 0x02: Gyro.RgConB |= 1<<2; break; |
Kovalev_D | 208:19150d2b528f | 620 | } |
Kovalev_D | 208:19150d2b528f | 621 | } |
Kovalev_D | 208:19150d2b528f | 622 | } |
Kovalev_D | 208:19150d2b528f | 623 | else |
Kovalev_D | 208:19150d2b528f | 624 | { |
Kovalev_D | 208:19150d2b528f | 625 | if(SR) |
Kovalev_D | 208:19150d2b528f | 626 | { |
Kovalev_D | 208:19150d2b528f | 627 | switch (Bit_num) |
Kovalev_D | 208:19150d2b528f | 628 | { |
Kovalev_D | 208:19150d2b528f | 629 | case 0x06: FrqON break; |
Kovalev_D | 208:19150d2b528f | 630 | case 0x05: AVibON break; |
Kovalev_D | 208:19150d2b528f | 631 | case 0x01: HFOON break; |
Kovalev_D | 208:19150d2b528f | 632 | case 0x03: PlcON break; |
Kovalev_D | 208:19150d2b528f | 633 | } |
Kovalev_D | 208:19150d2b528f | 634 | } |
Kovalev_D | 208:19150d2b528f | 635 | else |
Kovalev_D | 208:19150d2b528f | 636 | { |
Kovalev_D | 208:19150d2b528f | 637 | switch (Bit_num) |
Kovalev_D | 208:19150d2b528f | 638 | { |
Kovalev_D | 208:19150d2b528f | 639 | case 0x06: FrqOFF break; |
Kovalev_D | 208:19150d2b528f | 640 | case 0x05: AVibOFF break; |
Kovalev_D | 208:19150d2b528f | 641 | case 0x01: HFOOFF break; |
Kovalev_D | 208:19150d2b528f | 642 | case 0x03: PlcOFF break; |
Kovalev_D | 208:19150d2b528f | 643 | } |
Kovalev_D | 208:19150d2b528f | 644 | } |
Kovalev_D | 208:19150d2b528f | 645 | } |
Kovalev_D | 208:19150d2b528f | 646 | |
Kovalev_D | 208:19150d2b528f | 647 | } |
Kovalev_D | 208:19150d2b528f | 648 | void D8_Answer() |
Kovalev_D | 208:19150d2b528f | 649 | { |
Kovalev_D | 104:ab1cb4ff56b2 | 650 | |
Kovalev_D | 208:19150d2b528f | 651 | |
Kovalev_D | 208:19150d2b528f | 652 | |
Kovalev_D | 208:19150d2b528f | 653 | BuffTemp[0] = Gyro.SOC_Out; //DD |
Kovalev_D | 208:19150d2b528f | 654 | |
Kovalev_D | 208:19150d2b528f | 655 | BuffTemp[1] = Gyro.My_Addres; //00 |
Kovalev_D | 208:19150d2b528f | 656 | |
Kovalev_D | 208:19150d2b528f | 657 | BuffTemp[2] = 0xD8; //D8 |
Kovalev_D | 208:19150d2b528f | 658 | |
Kovalev_D | 208:19150d2b528f | 659 | BuffTemp[3] =A<<4; |
Kovalev_D | 208:19150d2b528f | 660 | |
Kovalev_D | 208:19150d2b528f | 661 | if(A) |
Kovalev_D | 208:19150d2b528f | 662 | { |
Kovalev_D | 208:19150d2b528f | 663 | BuffTemp[ 4] =(Gyro.RgConB >> 8) & 0xff; |
Kovalev_D | 208:19150d2b528f | 664 | BuffTemp[ 5] =(Gyro.RgConB >> 0) & 0xff; |
Kovalev_D | 208:19150d2b528f | 665 | |
Kovalev_D | 208:19150d2b528f | 666 | } |
Kovalev_D | 208:19150d2b528f | 667 | else |
Kovalev_D | 194:8f3cb37a5541 | 668 | { |
Kovalev_D | 208:19150d2b528f | 669 | BuffTemp[ 4] =(Gyro.RgConA >> 8) & 0xff; |
Kovalev_D | 208:19150d2b528f | 670 | BuffTemp[ 5] =(Gyro.RgConA >> 0) & 0xff; |
Kovalev_D | 208:19150d2b528f | 671 | } |
Kovalev_D | 129:406995a91322 | 672 | Check(BuffTemp, CRC_N); |
Kovalev_D | 129:406995a91322 | 673 | WriteConN (BuffTemp,CRC_N); |
Kovalev_D | 208:19150d2b528f | 674 | |
igor_v | 0:8ad47e2b6f00 | 675 | } |
igor_v | 21:bc8c1cec3da6 | 676 | void CMD_M_Control_D9()///чтение регистров управления |
igor_v | 21:bc8c1cec3da6 | 677 | { |
igor_v | 21:bc8c1cec3da6 | 678 | int bit,NReg; |
igor_v | 30:17c84ed091b3 | 679 | BuffTemp[0] = Gyro.SOC_Out; //DD |
igor_v | 30:17c84ed091b3 | 680 | BuffTemp[1] = Gyro.My_Addres; //00 |
igor_v | 30:17c84ed091b3 | 681 | BuffTemp[2] = Gyro.CMD_In; //D9 |
igor_v | 21:bc8c1cec3da6 | 682 | if ((Param1 & 0x10) == 0) { |
igor_v | 21:bc8c1cec3da6 | 683 | BuffTemp[3]=0<<4; |
igor_v | 30:17c84ed091b3 | 684 | BuffTemp[4] = (Gyro.RgConA>>8 )& 0xff; |
igor_v | 30:17c84ed091b3 | 685 | BuffTemp[5] = Gyro.RgConA & 0xff; |
igor_v | 21:bc8c1cec3da6 | 686 | } else { |
igor_v | 21:bc8c1cec3da6 | 687 | BuffTemp[3]=1<<4; |
igor_v | 30:17c84ed091b3 | 688 | BuffTemp[4] = (Gyro.RgConB>>8 ) & 0xff; |
igor_v | 30:17c84ed091b3 | 689 | BuffTemp[5] = Gyro.RgConB & 0xff; |
igor_v | 21:bc8c1cec3da6 | 690 | } |
igor_v | 21:bc8c1cec3da6 | 691 | Check(BuffTemp, CRC_N); |
igor_v | 21:bc8c1cec3da6 | 692 | WriteConN (BuffTemp,CRC_N); |
igor_v | 21:bc8c1cec3da6 | 693 | } |
igor_v | 21:bc8c1cec3da6 | 694 | // (номер (код) ЦАПа 0...3, старший байт требуемого ЦАПа, младший байт треб ЦАПа) |
Kovalev_D | 208:19150d2b528f | 695 | void CMD_M_Stymul_Answer() |
Kovalev_D | 208:19150d2b528f | 696 | { SA=0; |
Kovalev_D | 208:19150d2b528f | 697 | BuffTemp[ 0] =0xdd; |
Kovalev_D | 208:19150d2b528f | 698 | BuffTemp[ 1] = 0x00; |
Kovalev_D | 208:19150d2b528f | 699 | BuffTemp[ 2] = 0x0A; |
Kovalev_D | 208:19150d2b528f | 700 | BuffTemp[ 3] =0; |
Kovalev_D | 208:19150d2b528f | 701 | Check(BuffTemp, CRC_N); |
Kovalev_D | 208:19150d2b528f | 702 | WriteConN (BuffTemp,CRC_N); |
Kovalev_D | 208:19150d2b528f | 703 | } |
igor_v | 0:8ad47e2b6f00 | 704 | void CMD_M_Stymul() |
igor_v | 0:8ad47e2b6f00 | 705 | { |
igor_v | 21:bc8c1cec3da6 | 706 | int temp; |
Kovalev_D | 102:4270092be987 | 707 | int HFO; |
Kovalev_D | 208:19150d2b528f | 708 | int b4; |
Kovalev_D | 102:4270092be987 | 709 | temp=BuffTemp[3]; |
Kovalev_D | 208:19150d2b528f | 710 | b4=temp; |
Kovalev_D | 208:19150d2b528f | 711 | Consol = temp>>7; |
Kovalev_D | 208:19150d2b528f | 712 | if(Consol)SA=1; |
Kovalev_D | 103:e96f08947def | 713 | HFO = temp&0x3;// // (номер (код) ЦАПа 0...3, HFO - 3dac, PLC - 0DAC |
igor_v | 21:bc8c1cec3da6 | 714 | temp =((BuffTemp[4]<<8) | BuffTemp[5]); |
igor_v | 21:bc8c1cec3da6 | 715 | // temp=0; |
igor_v | 21:bc8c1cec3da6 | 716 | temp=temp&0xFFFF; |
Kovalev_D | 102:4270092be987 | 717 | |
Kovalev_D | 102:4270092be987 | 718 | if(HFO) |
Kovalev_D | 102:4270092be987 | 719 | { |
Kovalev_D | 102:4270092be987 | 720 | Spi.DAC_A=(unsigned int)temp; |
Kovalev_D | 102:4270092be987 | 721 | } |
Kovalev_D | 102:4270092be987 | 722 | else{ |
Kovalev_D | 208:19150d2b528f | 723 | DACF =/*(*/temp/*K_DAC)+deltaDAC;*/; |
igor_v | 21:bc8c1cec3da6 | 724 | Spi.DAC_B =(unsigned int)(DACF) /*(unsigned int)(temp*K_DAC+deltaDAC)*/; // K_DAC); |
igor_v | 21:bc8c1cec3da6 | 725 | } |
Kovalev_D | 208:19150d2b528f | 726 | |
igor_v | 0:8ad47e2b6f00 | 727 | } |
Kovalev_D | 194:8f3cb37a5541 | 728 | |
Kovalev_D | 194:8f3cb37a5541 | 729 | void GLDStartDischarg(void) |
Kovalev_D | 208:19150d2b528f | 730 | { TimeDischarg=0; |
Kovalev_D | 208:19150d2b528f | 731 | Try=0; |
Kovalev_D | 194:8f3cb37a5541 | 732 | switch(Gyro.My_Addres) |
Kovalev_D | 194:8f3cb37a5541 | 733 | {//смещение поджига и подсветки в зависимости от адреса ГЛД |
Kovalev_D | 194:8f3cb37a5541 | 734 | case 0: |
Kovalev_D | 194:8f3cb37a5541 | 735 | Gyro.Discharg = StartDischarg << ShiftStart0; |
Kovalev_D | 194:8f3cb37a5541 | 736 | Gyro.BackLight = StartBackLight << ShiftStart0; |
Kovalev_D | 194:8f3cb37a5541 | 737 | break; |
Kovalev_D | 194:8f3cb37a5541 | 738 | case 1: |
Kovalev_D | 194:8f3cb37a5541 | 739 | Gyro.Discharg = StartDischarg << ShiftStart1; |
Kovalev_D | 194:8f3cb37a5541 | 740 | Gyro.BackLight = StartBackLight << ShiftStart1; |
Kovalev_D | 194:8f3cb37a5541 | 741 | break; |
Kovalev_D | 194:8f3cb37a5541 | 742 | case 2: |
Kovalev_D | 194:8f3cb37a5541 | 743 | Gyro.Discharg = StartDischarg << ShiftStart2; |
Kovalev_D | 194:8f3cb37a5541 | 744 | Gyro.BackLight = StartBackLight << ShiftStart2; |
Kovalev_D | 194:8f3cb37a5541 | 745 | break; |
Kovalev_D | 194:8f3cb37a5541 | 746 | case 3: |
Kovalev_D | 194:8f3cb37a5541 | 747 | Gyro.Discharg = StartDischarg << ShiftStart3; |
Kovalev_D | 194:8f3cb37a5541 | 748 | Gyro.BackLight = StartBackLight << ShiftStart3; |
Kovalev_D | 194:8f3cb37a5541 | 749 | break; |
Kovalev_D | 194:8f3cb37a5541 | 750 | } |
Kovalev_D | 194:8f3cb37a5541 | 751 | } |
Kovalev_D | 194:8f3cb37a5541 | 752 | |
Kovalev_D | 103:e96f08947def | 753 | void Gph_W() |
Kovalev_D | 103:e96f08947def | 754 | { |
Kovalev_D | 205:775d54fdf646 | 755 | //Gyro.flagGph_W=3; |
Kovalev_D | 208:19150d2b528f | 756 | |
Kovalev_D | 172:ef7bf1663645 | 757 | Out_G_photo(BuffTemp[4],BuffTemp[5]); |
Kovalev_D | 172:ef7bf1663645 | 758 | |
Kovalev_D | 103:e96f08947def | 759 | } |
igor_v | 0:8ad47e2b6f00 | 760 | |
Kovalev_D | 102:4270092be987 | 761 | |
igor_v | 0:8ad47e2b6f00 | 762 | unsigned int Check(char *c, unsigned int Count) |
igor_v | 0:8ad47e2b6f00 | 763 | { |
igor_v | 21:bc8c1cec3da6 | 764 | int i=1; |
igor_v | 21:bc8c1cec3da6 | 765 | unsigned int temp,CRC; |
igor_v | 21:bc8c1cec3da6 | 766 | |
igor_v | 21:bc8c1cec3da6 | 767 | |
igor_v | 21:bc8c1cec3da6 | 768 | temp=1; |
igor_v | 21:bc8c1cec3da6 | 769 | CRC=0; |
igor_v | 21:bc8c1cec3da6 | 770 | |
igor_v | 21:bc8c1cec3da6 | 771 | |
igor_v | 21:bc8c1cec3da6 | 772 | for(; i<Count-2; i++) { |
igor_v | 21:bc8c1cec3da6 | 773 | CRC+=c[i]; |
igor_v | 21:bc8c1cec3da6 | 774 | } |
igor_v | 0:8ad47e2b6f00 | 775 | |
igor_v | 21:bc8c1cec3da6 | 776 | if(c[Count-2]!=((CRC>>8)&0xFF)) { |
igor_v | 21:bc8c1cec3da6 | 777 | temp=0; |
igor_v | 30:17c84ed091b3 | 778 | Gyro.RsErrLine = (Gyro.RsErrLine)&=0x2; |
igor_v | 21:bc8c1cec3da6 | 779 | } |
igor_v | 0:8ad47e2b6f00 | 780 | |
igor_v | 21:bc8c1cec3da6 | 781 | if(c[Count-1]!=((CRC>>0)&0xFF)) { |
igor_v | 21:bc8c1cec3da6 | 782 | temp=0; |
igor_v | 30:17c84ed091b3 | 783 | // Gyro.RsErrLine= (Gyro.RsErrLine)=0x2; |
igor_v | 21:bc8c1cec3da6 | 784 | } |
igor_v | 21:bc8c1cec3da6 | 785 | |
igor_v | 21:bc8c1cec3da6 | 786 | c[Count-2]=(CRC>>8)&0xFF; |
igor_v | 21:bc8c1cec3da6 | 787 | c[Count-1]=(CRC>>0)&0xFF; |
igor_v | 21:bc8c1cec3da6 | 788 | |
igor_v | 21:bc8c1cec3da6 | 789 | |
igor_v | 21:bc8c1cec3da6 | 790 | |
igor_v | 21:bc8c1cec3da6 | 791 | return temp; |
igor_v | 0:8ad47e2b6f00 | 792 | } |
igor_v | 0:8ad47e2b6f00 | 793 | |
igor_v | 0:8ad47e2b6f00 | 794 | int Getlengf(void) |
igor_v | 0:8ad47e2b6f00 | 795 | { |
Kovalev_D | 121:bbae560cdd43 | 796 | unsigned int lengf; |
Kovalev_D | 121:bbae560cdd43 | 797 | lengf = 1; |
Kovalev_D | 194:8f3cb37a5541 | 798 | switch(Gyro.CMD_In) |
Kovalev_D | 194:8f3cb37a5541 | 799 | { |
Kovalev_D | 194:8f3cb37a5541 | 800 | case 0x99: lengf=6; CRC_N=8; break; //Mintainance |
Kovalev_D | 194:8f3cb37a5541 | 801 | case 0xB0: lengf=6; CRC_N=9; break; //Delta_Bins |
Kovalev_D | 194:8f3cb37a5541 | 802 | case 0x0F: lengf=6; CRC_N=8; break; //Delta_Bins |
Kovalev_D | 194:8f3cb37a5541 | 803 | case 0xA0: lengf=6; CRC_N=8; break; //Delta_PS |
Kovalev_D | 194:8f3cb37a5541 | 804 | case 0xDD: lengf=6; CRC_N=44; break; //m_rate |
Kovalev_D | 208:19150d2b528f | 805 | case 0x0A: lengf=8; CRC_N=6; break; //m_stymul |
Kovalev_D | 194:8f3cb37a5541 | 806 | case 0xE9: lengf=6; CRC_N=8; break; //DeviceMode |
Kovalev_D | 194:8f3cb37a5541 | 807 | case 0xE8: lengf=6; CRC_N=8; break; //DeviceMode |
Kovalev_D | 194:8f3cb37a5541 | 808 | case 0xA5: lengf=6; CRC_N=8; break; //DeviceMode |
Kovalev_D | 194:8f3cb37a5541 | 809 | case 0xD8: lengf=6; CRC_N=6; break; //m_control |
Kovalev_D | 194:8f3cb37a5541 | 810 | case 0xD9: lengf=6; CRC_N=8; break; //m_control |
Kovalev_D | 194:8f3cb37a5541 | 811 | case 0xE4: lengf=8; break; //M_VIB_W |
Kovalev_D | 194:8f3cb37a5541 | 812 | case 0xE6: lengf=8; break; //M_Gph_W |
Kovalev_D | 194:8f3cb37a5541 | 813 | } return lengf; |
igor_v | 0:8ad47e2b6f00 | 814 | } |
igor_v | 0:8ad47e2b6f00 | 815 | |
igor_v | 0:8ad47e2b6f00 | 816 | void Read_CMD(void) |
igor_v | 21:bc8c1cec3da6 | 817 | { |
Kovalev_D | 188:4c523cc373cc | 818 | |
Kovalev_D | 147:1aed74f19a8f | 819 | Gyro.RsErrLine = (Gyro.RsErrLine)& 0xffff;//для сброса ошибки |
Kovalev_D | 188:4c523cc373cc | 820 | CountBuFFIn=ReadChekCon1(BuffTemp); |
Kovalev_D | 188:4c523cc373cc | 821 | // чтение данных из консоли |
Kovalev_D | 188:4c523cc373cc | 822 | if(CountBuFFIn==1) { |
Kovalev_D | 190:289514f730ee | 823 | // если есть первый байт |
Kovalev_D | 147:1aed74f19a8f | 824 | if (BuffTemp[0] != SOC_In) { |
Kovalev_D | 147:1aed74f19a8f | 825 | ReadCon1(BuffTemp); |
Kovalev_D | 194:8f3cb37a5541 | 826 | Gyro.RsErrLine += 0x100; |
Kovalev_D | 147:1aed74f19a8f | 827 | BuffTemp[99]=Gyro.RsErrLine; |
Kovalev_D | 147:1aed74f19a8f | 828 | } |
Kovalev_D | 147:1aed74f19a8f | 829 | } |
Kovalev_D | 190:289514f730ee | 830 | else if(CountBuFFIn==2) //если второй байт |
Kovalev_D | 194:8f3cb37a5541 | 831 | { // широковещаительный |
Kovalev_D | 194:8f3cb37a5541 | 832 | if (BuffTemp[1] != Gyro.My_Addres /*|| BuffTemp[1] !=0x1f*/) { |
Kovalev_D | 93:b3803774f110 | 833 | ReadCon1(BuffTemp); |
Kovalev_D | 194:8f3cb37a5541 | 834 | Gyro.RsErrLine += 0x1; |
Kovalev_D | 188:4c523cc373cc | 835 | } |
Kovalev_D | 147:1aed74f19a8f | 836 | } |
Kovalev_D | 190:289514f730ee | 837 | else if(CountBuFFIn==3) // если третий байт |
Kovalev_D | 147:1aed74f19a8f | 838 | { |
igor_v | 30:17c84ed091b3 | 839 | Gyro.CMD_In=BuffTemp[2]; |
Kovalev_D | 92:c892f0311aa7 | 840 | N=Getlengf(); |
Kovalev_D | 92:c892f0311aa7 | 841 | } |
Kovalev_D | 92:c892f0311aa7 | 842 | else if(CountBuFFIn==4 && (N==6)) |
Kovalev_D | 92:c892f0311aa7 | 843 | { // N - длина посылки аскглд(для записи параметров). определяется по коду команды в Getlengf(); |
igor_v | 21:bc8c1cec3da6 | 844 | Param1=BuffTemp[3]; |
Kovalev_D | 92:c892f0311aa7 | 845 | } |
Kovalev_D | 92:c892f0311aa7 | 846 | else if((CountBuFFIn==5)&&(N==7)) |
Kovalev_D | 92:c892f0311aa7 | 847 | { |
igor_v | 21:bc8c1cec3da6 | 848 | Param1=BuffTemp[3]; |
igor_v | 21:bc8c1cec3da6 | 849 | Param2=BuffTemp[4]; |
igor_v | 0:8ad47e2b6f00 | 850 | |
Kovalev_D | 92:c892f0311aa7 | 851 | } |
Kovalev_D | 92:c892f0311aa7 | 852 | else if((CountBuFFIn==6)&&(N==8)) |
Kovalev_D | 147:1aed74f19a8f | 853 | { |
igor_v | 21:bc8c1cec3da6 | 854 | Param1=BuffTemp[3]; |
igor_v | 21:bc8c1cec3da6 | 855 | Param2=BuffTemp[4]; |
igor_v | 21:bc8c1cec3da6 | 856 | Param3=BuffTemp[5]; |
Kovalev_D | 92:c892f0311aa7 | 857 | } |
Kovalev_D | 102:4270092be987 | 858 | else if((CountBuFFIn==8)&&(N==10)) |
Kovalev_D | 147:1aed74f19a8f | 859 | { |
Kovalev_D | 102:4270092be987 | 860 | Param1=BuffTemp[4]; |
Kovalev_D | 102:4270092be987 | 861 | Param2=BuffTemp[5]; |
Kovalev_D | 102:4270092be987 | 862 | Param3=BuffTemp[6]; |
Kovalev_D | 102:4270092be987 | 863 | Param4=BuffTemp[7]; |
Kovalev_D | 102:4270092be987 | 864 | } |
Kovalev_D | 98:95b8e79f13e1 | 865 | |
Kovalev_D | 92:c892f0311aa7 | 866 | else if(CountBuFFIn > (N-1)) |
Kovalev_D | 92:c892f0311aa7 | 867 | { |
Kovalev_D | 147:1aed74f19a8f | 868 | ReadCon1(BuffTemp); |
Kovalev_D | 208:19150d2b528f | 869 | |
Kovalev_D | 208:19150d2b528f | 870 | if(SA)CMD_M_Stymul_Answer(); |
Kovalev_D | 208:19150d2b528f | 871 | // if(d8_anser)D8_Answer(); |
Kovalev_D | 208:19150d2b528f | 872 | |
Kovalev_D | 147:1aed74f19a8f | 873 | switch(Gyro.CMD_In) { |
Kovalev_D | 194:8f3cb37a5541 | 874 | case 0x99: Gyro.ModeOut=0; CMD_Maintenance(); break; |
Kovalev_D | 208:19150d2b528f | 875 | case 0xD8: CMD_M_Control_D8(); D8_Answer(); break; |
Kovalev_D | 194:8f3cb37a5541 | 876 | case 0xE9: CMD_M_Param_R(); break; //чтение параметров |
Kovalev_D | 194:8f3cb37a5541 | 877 | case 0xE8: CMD_M_Param_W(); break; //запись параметра |
Kovalev_D | 194:8f3cb37a5541 | 878 | case 0xDA: GLDStartDischarg(); break; |
Kovalev_D | 194:8f3cb37a5541 | 879 | case 0xD9: CMD_M_Control_D9(); break; |
Kovalev_D | 208:19150d2b528f | 880 | case 0x0A: CMD_M_Stymul(); break; |
Kovalev_D | 194:8f3cb37a5541 | 881 | case 0xDD: TempParam=(BuffTemp[3]) & 0x9f; //Rate |
Kovalev_D | 193:a0fe8bfc97e4 | 882 | switch(TempParam) { |
Kovalev_D | 193:a0fe8bfc97e4 | 883 | case Rate1 : CMD_Rate(); break; |
Kovalev_D | 193:a0fe8bfc97e4 | 884 | case Rate2 : CMD_Rate2(); break; |
Kovalev_D | 194:8f3cb37a5541 | 885 | case PRate1 : Gyro.ModeOut=1; break; |
Kovalev_D | 194:8f3cb37a5541 | 886 | case PRate2 : Gyro.ModeOut=2; break; |
Kovalev_D | 193:a0fe8bfc97e4 | 887 | } |
Kovalev_D | 194:8f3cb37a5541 | 888 | break; //DropDelay(); выставка задержки для мультидропа сбрасывается в команде CMD_Maintenance() на () микросекунд; |
Kovalev_D | 194:8f3cb37a5541 | 889 | case 0xA0: DropDelay(); TempParam=(BuffTemp[3]) & 0x90; //Delta_PS |
Kovalev_D | 193:a0fe8bfc97e4 | 890 | switch(TempParam) { |
Kovalev_D | 193:a0fe8bfc97e4 | 891 | case Delta_500 : CMD_Delta_PS(); break; |
Kovalev_D | 193:a0fe8bfc97e4 | 892 | case Delta_EXT : CMD_Delta_PS(); break; |
Kovalev_D | 196:f76dbc081e63 | 893 | case PDelta_500 : Gyro.ModeOut=3; Gyro.Event_500Hz=0; break; |
Kovalev_D | 193:a0fe8bfc97e4 | 894 | case PDelta_EXT : Gyro.ModeOut=4; break; |
Kovalev_D | 193:a0fe8bfc97e4 | 895 | } |
Kovalev_D | 194:8f3cb37a5541 | 896 | break; |
Kovalev_D | 194:8f3cb37a5541 | 897 | case 0xB0: DropDelay(); TempParam = TempParam=(BuffTemp[3]>>7); //Delta_Bins |
Kovalev_D | 193:a0fe8bfc97e4 | 898 | switch(TempParam) { |
Kovalev_D | 196:f76dbc081e63 | 899 | case PDelta_Bins: Gyro.ModeOut=5; Gyro.Event_500Hz=0; break; |
Kovalev_D | 193:a0fe8bfc97e4 | 900 | case Delta_Bins : CMD_Delta_Bins(); break; |
Kovalev_D | 193:a0fe8bfc97e4 | 901 | } |
Kovalev_D | 194:8f3cb37a5541 | 902 | break; |
Kovalev_D | 194:8f3cb37a5541 | 903 | case 0x0F: DropDelay(); TempParam = (((BuffTemp[3])>>4) & 0x9); //B_Delta |
Kovalev_D | 193:a0fe8bfc97e4 | 904 | switch(TempParam) { |
Kovalev_D | 193:a0fe8bfc97e4 | 905 | case PB_Delta_EXT: Gyro.ModeOut=6; break; |
Kovalev_D | 196:f76dbc081e63 | 906 | case PB_Delta_INT: Gyro.ModeOut=7; Gyro.Event_500Hz=0; break; |
Kovalev_D | 193:a0fe8bfc97e4 | 907 | case B_Delta_EXT: CMD_B_Delta(); break; |
Kovalev_D | 193:a0fe8bfc97e4 | 908 | case B_Delta_INT: CMD_B_Delta(); break; |
Kovalev_D | 193:a0fe8bfc97e4 | 909 | } |
Kovalev_D | 194:8f3cb37a5541 | 910 | break; |
Kovalev_D | 194:8f3cb37a5541 | 911 | case 0xE4: CMD_M_vib(); break; |
Kovalev_D | 194:8f3cb37a5541 | 912 | case 0xE6: Gph_W(); break; |
Kovalev_D | 194:8f3cb37a5541 | 913 | Gyro.RsErrLine = 0; |
Kovalev_D | 194:8f3cb37a5541 | 914 | } |
Kovalev_D | 194:8f3cb37a5541 | 915 | } |
Kovalev_D | 147:1aed74f19a8f | 916 | } |
Kovalev_D | 193:a0fe8bfc97e4 | 917 | |
Kovalev_D | 193:a0fe8bfc97e4 | 918 | |
Kovalev_D | 147:1aed74f19a8f | 919 | void TechLog(void) |
Kovalev_D | 147:1aed74f19a8f | 920 | { |
Kovalev_D | 208:19150d2b528f | 921 | unsigned int temp=0; |
Kovalev_D | 208:19150d2b528f | 922 | if (ReadCon (Time)) |
Kovalev_D | 208:19150d2b528f | 923 | { |
Kovalev_D | 147:1aed74f19a8f | 924 | ///////////////////////////////////////////////////////////////// |
Kovalev_D | 147:1aed74f19a8f | 925 | //////////////////////////////////////////////////////////////// |
Kovalev_D | 147:1aed74f19a8f | 926 | //////////////////////Выбор FlashMod/////////////////////////// |
Kovalev_D | 147:1aed74f19a8f | 927 | //////////////////////////////////////////////////////////////// |
Kovalev_D | 121:bbae560cdd43 | 928 | |
Kovalev_D | 205:775d54fdf646 | 929 | if (Time[0] == 'B') Gyro.FlashMod=1; |
Kovalev_D | 147:1aed74f19a8f | 930 | if (Time[0] == 'R') {Gyro.FlashMod=3;} |
Kovalev_D | 205:775d54fdf646 | 931 | if (Time[0] == 'E') {Gyro.FlashMod=4;} |
Kovalev_D | 147:1aed74f19a8f | 932 | /////////////////////////////////////////////////////////////// |
Kovalev_D | 147:1aed74f19a8f | 933 | /////////////////////////////////////////////////////////////// |
Kovalev_D | 147:1aed74f19a8f | 934 | //////////////////////////////////////////////////////////////// |
Kovalev_D | 147:1aed74f19a8f | 935 | if (Time[0] == 'V') { // выдача технологическая |
Kovalev_D | 147:1aed74f19a8f | 936 | Spi.DAC_B += 200; |
Kovalev_D | 197:7a05523bf588 | 937 | /* sprintf(Time,"%d\r\n", Spi.DAC_B); |
Kovalev_D | 197:7a05523bf588 | 938 | WriteCon(Time);*/ |
Kovalev_D | 147:1aed74f19a8f | 939 | } |
Kovalev_D | 147:1aed74f19a8f | 940 | if (Time[0] == 'v') { // выдача технологическая |
Kovalev_D | 147:1aed74f19a8f | 941 | Spi.DAC_B -= 200; |
Kovalev_D | 197:7a05523bf588 | 942 | /* sprintf(Time,"%d\r\n", Spi.DAC_B); |
Kovalev_D | 197:7a05523bf588 | 943 | WriteCon(Time);*/ |
Kovalev_D | 206:00341a03e05c | 944 | } |
Kovalev_D | 208:19150d2b528f | 945 | if (Time[0] == 'l') |
Kovalev_D | 208:19150d2b528f | 946 | { // выдача технологическая |
Kovalev_D | 206:00341a03e05c | 947 | Gyro.My_Addres = GyroP.Str.My_Addres; // Gyro.My_Addres = 0; |
Kovalev_D | 208:19150d2b528f | 948 | Gyro.GLD_Serial = GyroP.Str.GLD_Serial; |
Kovalev_D | 208:19150d2b528f | 949 | Gyro.FrqHZ = GyroP.Str.FrqHZ; |
Kovalev_D | 206:00341a03e05c | 950 | Gyro.Frq = GyroP.Str.FrqHZ<<16; |
Kovalev_D | 206:00341a03e05c | 951 | Gyro.FrqHZmin = GyroP.Str.FrqHZmin<<16; |
Kovalev_D | 206:00341a03e05c | 952 | Gyro.FrqHZmax = GyroP.Str.FrqHZmax<<16; |
Kovalev_D | 206:00341a03e05c | 953 | Gyro.FrqChengSpeed = GyroP.Str.FrqChengSpeed; |
Kovalev_D | 208:19150d2b528f | 954 | Gyro.PLC_Gain = GyroP.Str.PLC_Gain; |
Kovalev_D | 208:19150d2b528f | 955 | Gyro.PLC_Phase = GyroP.Str.PLC_Phase; |
Kovalev_D | 206:00341a03e05c | 956 | Gyro.ModAmp = GyroP.Str.ModAmp; |
Kovalev_D | 208:19150d2b528f | 957 | Gyro.FrqPhase = GyroP.Str.FrqPhase; |
Kovalev_D | 206:00341a03e05c | 958 | Gyro.AmpPer = GyroP.Str.AmpPer; |
Kovalev_D | 206:00341a03e05c | 959 | Gyro.Amp = GyroP.Str.AmpPer<<16; |
Kovalev_D | 208:19150d2b528f | 960 | Gyro.AmpSpeed = GyroP.Str.AmpSpeed; |
Kovalev_D | 206:00341a03e05c | 961 | Gyro.AmpPerDel = GyroP.Str.AmpPerDel; |
Kovalev_D | 208:19150d2b528f | 962 | temp=((GyroP.Str.VB_Fdf_Hi<<16) | GyroP.Str.VB_Fdf_Lo); |
Kovalev_D | 208:19150d2b528f | 963 | temp=temp/18.2; |
Kovalev_D | 208:19150d2b528f | 964 | Gyro.AmpTarget=(unsigned int)(temp); |
Kovalev_D | 206:00341a03e05c | 965 | Gyro.AmpPerMin = GyroP.Str.AmpPerMin; |
Kovalev_D | 206:00341a03e05c | 966 | Gyro.AmpPerMax = GyroP.Str.AmpPerMax; |
Kovalev_D | 206:00341a03e05c | 967 | Gyro.AmpMin = GyroP.Str.AmpMin; |
Kovalev_D | 206:00341a03e05c | 968 | Gyro.AmpTD = GyroP.Str.AmpTD; |
Kovalev_D | 208:19150d2b528f | 969 | Spi.DAC_A = GyroP.Str.DAC_current_Work; |
Kovalev_D | 206:00341a03e05c | 970 | Gyro.Gain_Sin = GyroP.Str.Gain_Sin; |
Kovalev_D | 206:00341a03e05c | 971 | Gyro.Gain_Cos = GyroP.Str.Gain_Cos; |
Kovalev_D | 207:d1ce992f5d17 | 972 | Out_G_photo(Gyro.Gain_Sin, Gyro.Gain_Cos); |
Kovalev_D | 206:00341a03e05c | 973 | } |
Kovalev_D | 208:19150d2b528f | 974 | |
Kovalev_D | 208:19150d2b528f | 975 | |
Kovalev_D | 208:19150d2b528f | 976 | } |
igor_v | 0:8ad47e2b6f00 | 977 | } |
igor_v | 0:8ad47e2b6f00 | 978 | |
igor_v | 0:8ad47e2b6f00 | 979 |