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