![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
forkd
Fork of LGstaandart by
Command.c
- Committer:
- Kovalev_D
- Date:
- 2017-02-07
- Revision:
- 208:19150d2b528f
- Parent:
- 207:d1ce992f5d17
- Child:
- 209:224e7331a061
File content as of revision 208:19150d2b528f:
#include "stdlib.h" //#include "math.h" #include "LPC17xx.h" #include "Global.h" int tempNH,tempNL; unsigned int Rate_Flag; unsigned int CountBuFFIn; unsigned int N=0,CRC_N; unsigned int Param1=0; unsigned int Param2=0; unsigned int Param3=0; unsigned int Param4=0; unsigned int Consol=123; unsigned int TempParam=1; unsigned int CountParam=0; int d8_anser=0,A=0,SA=0; int ttemp; int OLDDAC=0; int rr = 123; unsigned int pDestT ; GyroParam *Flash; ///////////////flah and boot/////////// void GoBoot(void) { /* Prepare Sectors to be flashed */ NVIC_DisableIRQ(TIMER1_IRQn); NVIC_DisableIRQ(TIMER2_IRQn); NVIC_DisableIRQ(TIMER3_IRQn); NVIC_DisableIRQ(EINT3_IRQn); SystemInitDef(); vIAP_ReinvokeISP(); } void DropDelay(void) { Gyro.DropDelayGLD = DropDelayGLD_0; switch(Gyro.My_Addres) { case 1: Gyro.DropDelayGLD = DropDelayGLD_1; break; case 2: Gyro.DropDelayGLD = DropDelayGLD_2; break; case 3: Gyro.DropDelayGLD = DropDelayGLD_3; break; } } /* void WriteFlash(void) { SystemInitDef(); WriteCon("\r\n Start Prepare Sectors"); if(u32IAP_PrepareSectors(5, 5) == IAP_STA_CMD_SUCCESS) { WriteCon("\r\nPrepare Sectors OK"); WriteCon("\r\n Start Erase"); u32IAP_EraseSectors(IMG_START_SECTOR, IMG_END_SECTOR); WriteCon("\r\n AND Erase"); } else WriteCon("\r\nPrepare Sectors ERROR "); SystemInit1(); Gyro.FlashMod = 0; } */ void EraseFlash(void) { rr = u32IAP_PrepareSectors(19, 21); sprintf((Time)," dffddfd <%07d> ",rr); WriteCon(Time); rr = u32IAP_EraseSectors(19, 21); sprintf((Time)," dffddfd <%07d> ",rr); WriteCon(Time); } void WriteFlash(void) { Gyro.FlashMod = 0; //SystemInitDef(); NVIC_DisableIRQ(TIMER1_IRQn); NVIC_DisableIRQ(TIMER2_IRQn); NVIC_DisableIRQ(TIMER3_IRQn); NVIC_DisableIRQ(EINT3_IRQn); // unsigned int start_address = (unsigned int) & GyroP; rr = u32IAP_PrepareSectors(19, 21); rr = u32IAP_EraseSectors (19, 21); rr = u32IAP_PrepareSectors(19, 21); rr = u32IAP_CopyRAMToFlash(0x030000, &GyroP , 1024); // SystemInit1(); // Инициализация контроллера: установка тактовых частот //SystemCoreClockUpdate1(); // расчет тактовой частоты процессора перед инициализацией UART - 103MHz NVIC_EnableIRQ(TIMER1_IRQn); NVIC_EnableIRQ(TIMER2_IRQn); NVIC_EnableIRQ(TIMER3_IRQn); NVIC_EnableIRQ(EINT3_IRQn); //SystemCoreClockUpdate1(); } void ReadFlash ( void) { NVIC_DisableIRQ(TIMER1_IRQn); NVIC_DisableIRQ(TIMER2_IRQn); NVIC_DisableIRQ(TIMER3_IRQn); NVIC_DisableIRQ(EINT3_IRQn); Gyro.FlashMod = 0; WriteCon("\r\n Pirivet Flash"); pDestT= (unsigned int) (0x030000); Flash = (GyroParam*) pDestT; GyroP = *(Flash); NVIC_EnableIRQ(TIMER1_IRQn); NVIC_EnableIRQ(TIMER2_IRQn); NVIC_EnableIRQ(TIMER3_IRQn); NVIC_EnableIRQ(EINT3_IRQn); } ///////////////end flah and boot/////////// void M_RateA(void) { switch(Gyro.ModeOut) { case 1: if(Gyro.Rate1_Event ) CMD_Rate(); break; case 2: if(Gyro.Reper_Event ) CMD_Rate2(); break; case 3: if(Gyro.Event_500Hz ) CMD_Delta_PS(); break; case 4: if(Gyro.EXT_Latch ) CMD_Delta_PS(); break; case 5: if(Gyro.Event_500Hz ) CMD_Delta_Bins(); break; case 6: if(Gyro.EXT_Latch ) CMD_B_Delta(); break; case 7: if(Gyro.Event_500Hz ) CMD_B_Delta(); break; } } void CMD_M_Param_R(void) { unsigned int NP=0; unsigned int Param; NP = BuffTemp[3]; BuffTemp[0] = Gyro.SOC_Out; BuffTemp[1] = Gyro.My_Addres; sprintf((Time),"%d = %d \r\n",NP, GyroP.Array[NP]); WriteCon(Time); Param = GyroP.Array[NP]; BuffTemp[2] =(GyroP.Array[NP] >> 8) & 0xff;//старший байт требуемого параметра BuffTemp[3] =(GyroP.Array[NP] >> 0) & 0xff;//младший байт требуемого параметра Check(BuffTemp, 6); WriteConN (BuffTemp,6); /*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); WriteCon(Time);*/ NP=0; } void CMD_M_Param_W(void) { unsigned int NP=0; unsigned int Param,temp,flash; NP = BuffTemp[3]; Param = (BuffTemp[4]<<8); Param |= BuffTemp[5]; GyroP.Array[NP] = Param; flash=GyroP.Array[5]; sprintf((Time),"%d\r\n",NP); WriteCon(Time); switch(NP) { case 0: Gyro.My_Addres = GyroP.Str.My_Addres; break; case 3: Spi.DAC_A = GyroP.Str.DAC_current_Work; break; case 7: Gyro.PLC_Phase = GyroP.Str.PLC_Phase; break; case 8: Gyro.PLC_Gain = GyroP.Str.PLC_Gain; break; case 12: Gyro.FrqPhase = GyroP.Str.FrqPhase; break; case 13: Gyro.FrqChengSpeed = GyroP.Str.FrqChengSpeed; break; case 14: Gyro.FrqHZ = GyroP.Str.FrqHZ; Gyro.Frq = GyroP.Str.FrqHZ<<16; break; case 15: Gyro.FrqHZmin = GyroP.Str.FrqHZmin<<16; break; case 16: Gyro.FrqHZmax = GyroP.Str.FrqHZmax<<16; break; case 18: temp=((GyroP.Str.VB_Fdf_Hi<<16) | GyroP.Str.VB_Fdf_Lo); temp=temp/18.2; Gyro.AmpTarget=(unsigned int)(temp); break; case 19: Gyro.AmpSpeed = GyroP.Str.AmpSpeed; break; case 20: Gyro.AmpPerMin = GyroP.Str.AmpPerMin; break; case 21: Gyro.AmpPerMax = GyroP.Str.AmpPerMax; break; case 22: Gyro.AmpPer = GyroP.Str.AmpPer; Gyro.Amp = GyroP.Str.AmpPer<<16; break; case 23: Gyro.AmpMin = GyroP.Str.AmpMin; break; case 24: Gyro.AmpTD = GyroP.Str.AmpTD; break; case 25: Gyro.AmpPerDel = GyroP.Str.AmpPerDel; break; case 34: Gyro.ModAmp = GyroP.Str.ModAmp; break; case 56: Gyro.Gain_Sin = GyroP.Str.Gain_Sin; Out_G_photo(Gyro.Gain_Sin, Gyro.Gain_Cos); break; case 57: Gyro.Gain_Cos = GyroP.Str.Gain_Cos; Out_G_photo(Gyro.Gain_Sin, Gyro.Gain_Cos); break; case 60: Gyro.GLD_Serial = GyroP.Str.GLD_Serial; break; } NP=0; BuffTemp[0] = Gyro.SOC_Out; BuffTemp[1] = Gyro.My_Addres; BuffTemp[2] = Gyro.CMD_In; BuffTemp[3] =0; //(//GyroP.Array[NP]>> 8) & 0xff;//старший байт требуемого параметра Check(BuffTemp, 6); WriteConN (BuffTemp,6); if(flash){GyroP.Array[5]=0; flash=0; WriteFlash(); ReadFlash ();} } void CMD_Maintenance(void) { // Gyro.ModeOut=0; //Gyro.DropDelayGLD = DropDelayGLD_0;//задержка на выдачу 45 микросекунд для любого адреса ГЛД BuffTemp[0] = Gyro.SOC_Out; BuffTemp[1] = Gyro.My_Addres; BuffTemp[2] = Gyro.Firmware_Version; BuffTemp[3] = Gyro.GLD_Serial; BuffTemp[4]=0x00; BuffTemp[5]=0x00; Check(BuffTemp, 8); WriteConN (BuffTemp,8); } void CMD_B_Delta(void) { Gyro.Event_500Hz=0; Gyro.EXT_Latch=0; unsigned int Temp; BuffTemp[ 0] = Gyro.SOC_Out; BuffTemp[ 1] = Gyro.My_Addres; Temp = Gyro.CuruAngle; Gyro.CuruAngle = 0; BuffTemp[ 2] =(Temp >> 16) & 0xff;//младший байт разности счетчиков BuffTemp[ 3] =(Temp >> 8) & 0xff;//младший байт разности счетчиков BuffTemp[ 4] =(Temp >> 0) & 0xff;//младший байт разности счетчиков BuffTemp[ 5] = 0x00000000; Check(BuffTemp, 8); WriteConN (BuffTemp,8); } void CMD_Delta_Bins(void) { Gyro.Event_500Hz=0; unsigned int Temp; BuffTemp[ 0] = Gyro.SOC_Out; BuffTemp[ 1] = Gyro.My_Addres; Temp = Gyro.CuruAngle; Gyro.CuruAngle = 0; BuffTemp[ 2] =(Temp >> 24) & 0xff;//старший байт разности счетчиков BuffTemp[ 3] =(Temp >> 16) & 0xff;//младший байт разности счетчиков BuffTemp[ 4] =(Temp >> 8) & 0xff;//младший байт разности счетчиков BuffTemp[ 5] =(Temp >> 0) & 0xff;//младший байт разности счетчиков BuffTemp[ 6] = 0x0000; Check(BuffTemp, 9); WriteConN (BuffTemp,9); } void CMD_Delta_PS(void) { Gyro.EXT_Latch=0; Gyro.Event_500Hz=0; unsigned int Temp; BuffTemp[ 0] = Gyro.SOC_Out; BuffTemp[ 1] = Gyro.My_Addres; Temp = Gyro.CuruAngle; Gyro.CuruAngle = 0; BuffTemp[ 2] =(Temp >> 8) & 0xff;//старший байт разности счетчиков BuffTemp[ 3] =(Temp >> 0) & 0xff;//младший байт разности счетчиков BuffTemp[ 4] = CountParam; switch(CountParam) { //F_ras case 0: Temp = Gyro.F_ras; BuffTemp[5] = (Temp >> 8) & 0xff; break; case 1: BuffTemp[5] = (Temp >> 0) & 0xff; break; //HFO case 2: Temp = 0;//HFO BuffTemp[5] = (Temp >> 8) & 0xff; break; case 3: Temp = 0;//HFO BuffTemp[5] = (Temp >> 0) & 0xff; break; //T_Vibro case 4: Temp = (unsigned int)((7680000*16/(Gyro.Frq>>12))); BuffTemp[5] = (Temp >> 8) & 0xff; break; case 5: BuffTemp[5] = (Temp >> 0) & 0xff; break; //L_Vibro case 6: Temp = (unsigned int)(((7680000*16/200) *Gyro.AmpPer /(Gyro.Frq>>12))); BuffTemp[5] = (Temp >> 8) & 0xff; break; case 7: BuffTemp[5] = (Temp >> 0) & 0xff; break; //Напряжение на регуляторе периметра case 8: Temp = Spi.DAC_B /*- 0x7fff*/; BuffTemp[5] = (Temp >> 8) & 0xff; break; case 9: BuffTemp[5] = (Temp >> 0) & 0xff; break; //темпкратурный канал 0 case 10: Temp = 100; BuffTemp[5] = (Temp >> 8) & 0xff; break; case 11: BuffTemp[5] = (Temp >> 0) & 0xff; break; //f case 12: Temp = Gyro.AD_Slow >> 16; BuffTemp[5] = (Temp >> 8) & 0xff; break; case 13: BuffTemp[5] = (Temp >> 0) & 0xff; break; //ток 1 case 14: Temp = Gyro.In1; BuffTemp[5] = (Temp >> 8) & 0xff;//in1//2 break; case 15: BuffTemp[5] = (Temp >> 0) & 0xff; break; //ток 2 case 16: Temp = Gyro.In2; BuffTemp[5] = (Temp >> 8) & 0xff; break; case 17: BuffTemp[5] = (Temp >> 0) & 0xff;//in2//3 break; //разностный температурный канал Delta Temp case 18: Temp = Gyro.DeltaT; BuffTemp[5] = (Temp >> 8) & 0xff;//дельта break; case 19: BuffTemp[5] = (Temp >> 0) & 0xff; break; //температурный канал 5 case 20: Temp = Gyro.Termo;//0xa4=164 BuffTemp[5] =(Temp >> 8) & 0xff;//температура break; case 21: BuffTemp[5] =(Temp >> 0) & 0xff;//ADC6 sesnsor 5 break; } Check(BuffTemp, CRC_N); WriteConN (BuffTemp,CRC_N); if(CountParam>20)CountParam=0;//зацикливания буфера от 0 до 21 else CountParam++; } void CMD_Rate2(void) { Gyro.Reper_Event=0; BuffTemp[ 0] = Gyro.SOC_Out; BuffTemp[ 1] = Gyro.My_Addres; BuffTemp[ 2] =(Gyro.CaunPlus >> 8) & 0xff;//старший байт счетчика +. BuffTemp[ 3] =(Gyro.CaunPlus >> 0) & 0xff;//младший байт счетчика +. BuffTemp[ 4] =(Gyro.CaunMin >> 8) & 0xff;//старший байт счетчика -. BuffTemp[ 5] =(Gyro.CaunMin >> 0) & 0xff;//младший байт счетчика -. Check(BuffTemp, 8); WriteConN (BuffTemp,8); } void CMD_Rate(void) { Gyro.Rate1_Event=0; unsigned int Temp; int Temp1; unsigned int OldCuruAngle; BuffTemp[ 0] = Gyro.SOC_Out; //1 --старт данных BuffTemp[ 1] = Gyro.My_Addres; //2 --адрес отвечающего устройствва BuffTemp[ 2] =(Gyro.CaunPlus >> 8) & 0xff;//старший байт счетчика +. 3 --сарший байт счентчика + BuffTemp[ 3] =(Gyro.CaunPlus >> 0) & 0xff;//младший байт счетчика +. 4 --младший байт счетчика + BuffTemp[ 4] =(Gyro.CaunMin >> 8) & 0xff;//старший байт счетчика -. 5 --сарший байт счентчика - BuffTemp[ 5] =(Gyro.CaunMin >> 0) & 0xff;//младший байт счетчика -. 6 --младший байт счетчика - Temp=Gyro.CuruAngle; //(0,28/с) //8 байт + 4 байта от прошлых измерений //Gyro.CuruAngle = Gyro.CuruAngle + OldCuruAngle; //(72 град/с) /* OldCuruAngle=Gyro.CuruAngle & 0xff; //сохраняем 4 байта для след измирений Temp=Gyro.CuruAngle>>8; */ //приводим к форме вывода /* //(9 град/с) OldCuruAngle=Gyro.CuruAngle & 0x1f; //сохраняем 5 бит для след измирений Temp=Gyro.CuruAngle>>5; */ //приводим к форме вывода Gyro.CuruAngle = 0; BuffTemp[ 6] =(Temp >> 8) & 0xff;//старший байт разности счетчиков 7 --младший байт разности счетчиков BuffTemp[ 7] =(Temp >> 0) & 0xff;//младший байт разности счетчиков 8 --старший байт разности счетчиков BuffTemp[38] =(Temp >> 24) & 0xff;; //39 приращение угла BuffTemp[39] =(Temp >> 16) & 0xff;; //40 формат 22.10 BuffTemp[40] =(Temp >> 8) & 0xff;; //41 1бит знак BuffTemp[41] =(Temp >> 0) & 0xff;; //42 Temp = Gyro.F_ras; BuffTemp[ 8] = (Temp >> 8) & 0xff;//расщипление частота 9 --частота расщипления BuffTemp[ 9] = (Temp >> 0) & 0xff;// 10 --частота расщипления Temp = 0xffff;//HFO BuffTemp[10] = (Temp >> 8) & 0xff;//выход регулятора гвч; 11 --выход регулятора ГВЧ BuffTemp[11] = (Temp >> 0) & 0xff; //12 --выход регулятора ГВЧ Temp =0xffff; BuffTemp[12]=(Temp >> 8) & 0xff;//// HFO 13 --сигнал ошибки регулятора ГВЧ BuffTemp[13]=(Temp >> 0) & 0xff;//// 14 --сигнал ошибки регулятора ГВЧ Temp = (unsigned int)((7675000*16/(Gyro.Frq>>12))); BuffTemp[14] = (Temp >> 8) & 0xff; //15 период вибропривода.(частота) T_Vibro BuffTemp[15] = (Temp >> 0) & 0xff; //16 период вибропривода. Temp =0xff; BuffTemp[16] = 0x00; //17 старший байт ФД регулятора периода вибропривода BuffTemp[17] = 0x00; //18 Temp = Gyro.L_vibro>>1;//(unsigned int)(((7675000*16/200) * Gyro.AmpPer /(Gyro.Frq>>12))); BuffTemp[18] = (Temp >> 8) & 0xff; //19 длительность импулься вибропривода(амплитуда) BuffTemp[19] = (Temp >> 0) & 0xff; //20 Temp = 0x0;//Gyro.L_vibro<<2; BuffTemp[20] = (Temp >> 8) & 0xff;//регулятор датчика угла поворота //21 старший байт регулятора датчика угла поворота BuffTemp[21] = (Temp >> 0) & 0xff; //22 Temp = (Spi.DAC_B - 0x7fff); BuffTemp[22] = (Temp >> 8) & 0xff; //23 Выход регулятора рабочего периметра BuffTemp[23] = (Temp >> 0) & 0xff; //24 Temp =0x0; //Gyro.AD_Slow >> 16; BuffTemp[24] = (Temp >> 8) & 0xff;// //25 ФД СРП BuffTemp[25] = (Temp >> 0) & 0xff;// //26 ФД СРП Temp = Gyro.AD_Slow >> 16; BuffTemp[26] = (Temp >> 8) & 0xff; //27 ADC 0 BuffTemp[27] = (Temp >> 0) & 0xff; //28 Temp = Gyro.AD_Slow >> 16; BuffTemp[28] = (Temp >> 8) & 0xff; //29 ADC 1 BuffTemp[29] = (Temp >> 0) & 0xff; //30 Temp = (Gyro.In1 - 0x7fff); BuffTemp[30] = (Temp >> 8) & 0xff;//in1//2 //31 ADC 2 BuffTemp[31] = (Temp >> 0) & 0xff; //32 Temp = (Gyro.In2 - 0x7fff); BuffTemp[32] = (Temp >> 8) & 0xff; //33 ADC 3 BuffTemp[33] = (Temp >> 0) & 0xff;//in2//3 //34 Temp = (Gyro.DeltaT); BuffTemp[34] = (Temp >> 8) & 0xff;//дельта //35 ADC 4 BuffTemp[35] = (Temp >> 0) & 0xff; //36 // Temp = 000; Temp = Gyro.Termo; BuffTemp[36] =(Temp >> 8) & 0xff;//температура //37 ADC 5 BuffTemp[37] =(Temp >> 0) & 0xff;//ADC6 sesnsor 5 //38 Check(BuffTemp, 44); WriteConN (BuffTemp,44); } void CMD_M_vib() { unsigned int temp1,temp2; temp1 =((BuffTemp[4]<<8) | BuffTemp[5]); temp1=temp1&0xFFFF; Gyro.Frq=(122780000/temp1)<<12; temp2 =((BuffTemp[6]<<8) | BuffTemp[7]); temp2=temp2&0xFFFF; Gyro.AmpPer=((((((Gyro.Frq>>12)*200)/16)*temp2)/7675000)/2); } void CMD_M_Control_D8()///установка\сброс регистров управления { unsigned int bit,Pa; unsigned int SR,V,Bit_num; SR=0; V=0; A=0; Bit_num=0; BuffTemp[0] = Gyro.SOC_Out; //DD BuffTemp[1] = Gyro.My_Addres; //00 BuffTemp[2] = Gyro.CMD_In; //D8 // Gyro.CMD_In = BuffTemp[2]; Pa = BuffTemp[3]; SR = Pa >> 0x7; V = Pa >> 0x5; V = V & 0x3; A = Pa >> 0x4; A = A & 0x1; Bit_num = Pa & 0xf; if(A) { if(SR) { switch (Bit_num) { case 0x00: Gyro.RgConB &= ~ 1<<0; break; case 0x01: Gyro.RgConB &= ~ 1<<1; break; case 0x02: Gyro.RgConB &= ~ 1<<2; break; } } else { switch (Bit_num) { case 0x00: Gyro.RgConB = 0xfffe; break; case 0x01: Gyro.RgConB |= 1<<1; break; case 0x02: Gyro.RgConB |= 1<<2; break; } } } else { if(SR) { switch (Bit_num) { case 0x06: FrqON break; case 0x05: AVibON break; case 0x01: HFOON break; case 0x03: PlcON break; } } else { switch (Bit_num) { case 0x06: FrqOFF break; case 0x05: AVibOFF break; case 0x01: HFOOFF break; case 0x03: PlcOFF break; } } } } void D8_Answer() { BuffTemp[0] = Gyro.SOC_Out; //DD BuffTemp[1] = Gyro.My_Addres; //00 BuffTemp[2] = 0xD8; //D8 BuffTemp[3] =A<<4; if(A) { BuffTemp[ 4] =(Gyro.RgConB >> 8) & 0xff; BuffTemp[ 5] =(Gyro.RgConB >> 0) & 0xff; } else { BuffTemp[ 4] =(Gyro.RgConA >> 8) & 0xff; BuffTemp[ 5] =(Gyro.RgConA >> 0) & 0xff; } Check(BuffTemp, CRC_N); WriteConN (BuffTemp,CRC_N); } void CMD_M_Control_D9()///чтение регистров управления { int bit,NReg; BuffTemp[0] = Gyro.SOC_Out; //DD BuffTemp[1] = Gyro.My_Addres; //00 BuffTemp[2] = Gyro.CMD_In; //D9 if ((Param1 & 0x10) == 0) { BuffTemp[3]=0<<4; BuffTemp[4] = (Gyro.RgConA>>8 )& 0xff; BuffTemp[5] = Gyro.RgConA & 0xff; } else { BuffTemp[3]=1<<4; BuffTemp[4] = (Gyro.RgConB>>8 ) & 0xff; BuffTemp[5] = Gyro.RgConB & 0xff; } Check(BuffTemp, CRC_N); WriteConN (BuffTemp,CRC_N); } // (номер (код) ЦАПа 0...3, старший байт требуемого ЦАПа, младший байт треб ЦАПа) void CMD_M_Stymul_Answer() { SA=0; BuffTemp[ 0] =0xdd; BuffTemp[ 1] = 0x00; BuffTemp[ 2] = 0x0A; BuffTemp[ 3] =0; Check(BuffTemp, CRC_N); WriteConN (BuffTemp,CRC_N); } void CMD_M_Stymul() { int temp; int HFO; int b4; temp=BuffTemp[3]; b4=temp; Consol = temp>>7; if(Consol)SA=1; HFO = temp&0x3;// // (номер (код) ЦАПа 0...3, HFO - 3dac, PLC - 0DAC temp =((BuffTemp[4]<<8) | BuffTemp[5]); // temp=0; temp=temp&0xFFFF; if(HFO) { Spi.DAC_A=(unsigned int)temp; } else{ DACF =/*(*/temp/*K_DAC)+deltaDAC;*/; Spi.DAC_B =(unsigned int)(DACF) /*(unsigned int)(temp*K_DAC+deltaDAC)*/; // K_DAC); } } void GLDStartDischarg(void) { TimeDischarg=0; Try=0; switch(Gyro.My_Addres) {//смещение поджига и подсветки в зависимости от адреса ГЛД case 0: Gyro.Discharg = StartDischarg << ShiftStart0; Gyro.BackLight = StartBackLight << ShiftStart0; break; case 1: Gyro.Discharg = StartDischarg << ShiftStart1; Gyro.BackLight = StartBackLight << ShiftStart1; break; case 2: Gyro.Discharg = StartDischarg << ShiftStart2; Gyro.BackLight = StartBackLight << ShiftStart2; break; case 3: Gyro.Discharg = StartDischarg << ShiftStart3; Gyro.BackLight = StartBackLight << ShiftStart3; break; } } void Gph_W() { //Gyro.flagGph_W=3; Out_G_photo(BuffTemp[4],BuffTemp[5]); } unsigned int Check(char *c, unsigned int Count) { int i=1; unsigned int temp,CRC; temp=1; CRC=0; for(; i<Count-2; i++) { CRC+=c[i]; } if(c[Count-2]!=((CRC>>8)&0xFF)) { temp=0; Gyro.RsErrLine = (Gyro.RsErrLine)&=0x2; } if(c[Count-1]!=((CRC>>0)&0xFF)) { temp=0; // Gyro.RsErrLine= (Gyro.RsErrLine)=0x2; } c[Count-2]=(CRC>>8)&0xFF; c[Count-1]=(CRC>>0)&0xFF; return temp; } int Getlengf(void) { unsigned int lengf; lengf = 1; switch(Gyro.CMD_In) { case 0x99: lengf=6; CRC_N=8; break; //Mintainance case 0xB0: lengf=6; CRC_N=9; break; //Delta_Bins case 0x0F: lengf=6; CRC_N=8; break; //Delta_Bins case 0xA0: lengf=6; CRC_N=8; break; //Delta_PS case 0xDD: lengf=6; CRC_N=44; break; //m_rate case 0x0A: lengf=8; CRC_N=6; break; //m_stymul case 0xE9: lengf=6; CRC_N=8; break; //DeviceMode case 0xE8: lengf=6; CRC_N=8; break; //DeviceMode case 0xA5: lengf=6; CRC_N=8; break; //DeviceMode case 0xD8: lengf=6; CRC_N=6; break; //m_control case 0xD9: lengf=6; CRC_N=8; break; //m_control case 0xE4: lengf=8; break; //M_VIB_W case 0xE6: lengf=8; break; //M_Gph_W } return lengf; } void Read_CMD(void) { Gyro.RsErrLine = (Gyro.RsErrLine)& 0xffff;//для сброса ошибки CountBuFFIn=ReadChekCon1(BuffTemp); // чтение данных из консоли if(CountBuFFIn==1) { // если есть первый байт if (BuffTemp[0] != SOC_In) { ReadCon1(BuffTemp); Gyro.RsErrLine += 0x100; BuffTemp[99]=Gyro.RsErrLine; } } else if(CountBuFFIn==2) //если второй байт { // широковещаительный if (BuffTemp[1] != Gyro.My_Addres /*|| BuffTemp[1] !=0x1f*/) { ReadCon1(BuffTemp); Gyro.RsErrLine += 0x1; } } else if(CountBuFFIn==3) // если третий байт { Gyro.CMD_In=BuffTemp[2]; N=Getlengf(); } else if(CountBuFFIn==4 && (N==6)) { // N - длина посылки аскглд(для записи параметров). определяется по коду команды в Getlengf(); Param1=BuffTemp[3]; } else if((CountBuFFIn==5)&&(N==7)) { Param1=BuffTemp[3]; Param2=BuffTemp[4]; } else if((CountBuFFIn==6)&&(N==8)) { Param1=BuffTemp[3]; Param2=BuffTemp[4]; Param3=BuffTemp[5]; } else if((CountBuFFIn==8)&&(N==10)) { Param1=BuffTemp[4]; Param2=BuffTemp[5]; Param3=BuffTemp[6]; Param4=BuffTemp[7]; } else if(CountBuFFIn > (N-1)) { ReadCon1(BuffTemp); if(SA)CMD_M_Stymul_Answer(); // if(d8_anser)D8_Answer(); switch(Gyro.CMD_In) { case 0x99: Gyro.ModeOut=0; CMD_Maintenance(); break; case 0xD8: CMD_M_Control_D8(); D8_Answer(); break; case 0xE9: CMD_M_Param_R(); break; //чтение параметров case 0xE8: CMD_M_Param_W(); break; //запись параметра case 0xDA: GLDStartDischarg(); break; case 0xD9: CMD_M_Control_D9(); break; case 0x0A: CMD_M_Stymul(); break; case 0xDD: TempParam=(BuffTemp[3]) & 0x9f; //Rate switch(TempParam) { case Rate1 : CMD_Rate(); break; case Rate2 : CMD_Rate2(); break; case PRate1 : Gyro.ModeOut=1; break; case PRate2 : Gyro.ModeOut=2; break; } break; //DropDelay(); выставка задержки для мультидропа сбрасывается в команде CMD_Maintenance() на () микросекунд; case 0xA0: DropDelay(); TempParam=(BuffTemp[3]) & 0x90; //Delta_PS switch(TempParam) { case Delta_500 : CMD_Delta_PS(); break; case Delta_EXT : CMD_Delta_PS(); break; case PDelta_500 : Gyro.ModeOut=3; Gyro.Event_500Hz=0; break; case PDelta_EXT : Gyro.ModeOut=4; break; } break; case 0xB0: DropDelay(); TempParam = TempParam=(BuffTemp[3]>>7); //Delta_Bins switch(TempParam) { case PDelta_Bins: Gyro.ModeOut=5; Gyro.Event_500Hz=0; break; case Delta_Bins : CMD_Delta_Bins(); break; } break; case 0x0F: DropDelay(); TempParam = (((BuffTemp[3])>>4) & 0x9); //B_Delta switch(TempParam) { case PB_Delta_EXT: Gyro.ModeOut=6; break; case PB_Delta_INT: Gyro.ModeOut=7; Gyro.Event_500Hz=0; break; case B_Delta_EXT: CMD_B_Delta(); break; case B_Delta_INT: CMD_B_Delta(); break; } break; case 0xE4: CMD_M_vib(); break; case 0xE6: Gph_W(); break; Gyro.RsErrLine = 0; } } } void TechLog(void) { unsigned int temp=0; if (ReadCon (Time)) { ///////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////// //////////////////////Выбор FlashMod/////////////////////////// //////////////////////////////////////////////////////////////// if (Time[0] == 'B') Gyro.FlashMod=1; if (Time[0] == 'R') {Gyro.FlashMod=3;} if (Time[0] == 'E') {Gyro.FlashMod=4;} /////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////// if (Time[0] == 'V') { // выдача технологическая Spi.DAC_B += 200; /* sprintf(Time,"%d\r\n", Spi.DAC_B); WriteCon(Time);*/ } if (Time[0] == 'v') { // выдача технологическая Spi.DAC_B -= 200; /* sprintf(Time,"%d\r\n", Spi.DAC_B); WriteCon(Time);*/ } if (Time[0] == 'l') { // выдача технологическая Gyro.My_Addres = GyroP.Str.My_Addres; // Gyro.My_Addres = 0; Gyro.GLD_Serial = GyroP.Str.GLD_Serial; Gyro.FrqHZ = GyroP.Str.FrqHZ; Gyro.Frq = GyroP.Str.FrqHZ<<16; Gyro.FrqHZmin = GyroP.Str.FrqHZmin<<16; Gyro.FrqHZmax = GyroP.Str.FrqHZmax<<16; Gyro.FrqChengSpeed = GyroP.Str.FrqChengSpeed; Gyro.PLC_Gain = GyroP.Str.PLC_Gain; Gyro.PLC_Phase = GyroP.Str.PLC_Phase; Gyro.ModAmp = GyroP.Str.ModAmp; Gyro.FrqPhase = GyroP.Str.FrqPhase; Gyro.AmpPer = GyroP.Str.AmpPer; Gyro.Amp = GyroP.Str.AmpPer<<16; Gyro.AmpSpeed = GyroP.Str.AmpSpeed; Gyro.AmpPerDel = GyroP.Str.AmpPerDel; temp=((GyroP.Str.VB_Fdf_Hi<<16) | GyroP.Str.VB_Fdf_Lo); temp=temp/18.2; Gyro.AmpTarget=(unsigned int)(temp); Gyro.AmpPerMin = GyroP.Str.AmpPerMin; Gyro.AmpPerMax = GyroP.Str.AmpPerMax; Gyro.AmpMin = GyroP.Str.AmpMin; Gyro.AmpTD = GyroP.Str.AmpTD; Spi.DAC_A = GyroP.Str.DAC_current_Work; Gyro.Gain_Sin = GyroP.Str.Gain_Sin; Gyro.Gain_Cos = GyroP.Str.Gain_Cos; Out_G_photo(Gyro.Gain_Sin, Gyro.Gain_Cos); } } }