![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
forkd
Fork of LGstaandart by
Diff: Command.c
- Revision:
- 30:17c84ed091b3
- Parent:
- 25:1a6798ccd3cd
- Child:
- 38:716472a4492e
diff -r f9174eac3dee -r 17c84ed091b3 Command.c --- a/Command.c Fri Feb 05 08:02:55 2016 +0000 +++ b/Command.c Fri Feb 05 23:21:54 2016 +0000 @@ -29,10 +29,10 @@ }*/ void CMD_Maintenance(void) { - BuffTemp[0] = Main.SOC_Out; - BuffTemp[1] = Main.My_Addres; - BuffTemp[2] = Main.Firmware_Version; - BuffTemp[3] = Main.GLD_Serial; + 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); @@ -58,24 +58,24 @@ LoopOn -// Main.T_Vib=(unsigned int)((7680000*16/Main.Frq)*4096); - Main.T_Vib=(unsigned int)((7680000*16/(Main.Frq>>12))); - Main.Firmware_Version=0xff; /// промежуточная затычка +// Gyro .T_Vib=(unsigned int)((7680000*16/Gyro.Frq)*4096); + Gyro.T_Vib=(unsigned int)((7680000*16/(Gyro.Frq>>12))); + Gyro.Firmware_Version=0xff; /// промежуточная затычка - T_VibH = ( Main.T_Vib>>8 ) TakeByte; - T_VibL = ( Main.T_Vib ) TakeByte; + T_VibH = ( Gyro.T_Vib>>8 ) TakeByte; + T_VibL = ( Gyro.T_Vib ) TakeByte; - Cnt_PlsH = ( Main.Cnt_Pls>>8) TakeByte; - Cnt_PlsL = ( Main.Cnt_Pls ) TakeByte; + Cnt_PlsH = ( Gyro.Cnt_Pls>>8) TakeByte; + Cnt_PlsL = ( Gyro.Cnt_Pls ) TakeByte; - Cnt_MnsH = ( Main.Cnt_Mns>>8) TakeByte; - Cnt_MnsL = ( Main.Cnt_Mns ) TakeByte; + Cnt_MnsH = ( Gyro.Cnt_Mns>>8) TakeByte; + Cnt_MnsL = ( Gyro.Cnt_Mns ) TakeByte; - Cnt_DifH = ( Main.Cnt_Dif>>8) TakeByte; - Cnt_DifL = ( Main.Cnt_Dif ) TakeByte; + Cnt_DifH = ( Gyro.Cnt_Dif>>8) TakeByte; + Cnt_DifL = ( Gyro.Cnt_Dif ) TakeByte; - F_rasH = ( Main.F_ras>>8 ) TakeByte; - F_rasL = ( Main.F_ras ) TakeByte; + F_rasH = ( Gyro.F_ras>>8 ) TakeByte; + F_rasL = ( Gyro.F_ras ) TakeByte; ADC1H = ( Spi.ADC1>>8 ) TakeByte; ADC1L = ( Spi.ADC1 ) TakeByte; @@ -102,8 +102,8 @@ HF_difL=0xff; - BuffTemp[ 0] = Main.SOC_Out; - BuffTemp[ 1] = Main.My_Addres; + BuffTemp[ 0] = Gyro.SOC_Out; + BuffTemp[ 1] = Gyro.My_Addres; BuffTemp[ 2] = Cnt_PlsH;//старший байт счетчика +. BuffTemp[ 3] = Cnt_PlsL;//младший байт счетчика +. @@ -126,20 +126,20 @@ BuffTemp[14] = T_VibH ;// BuffTemp[15] = T_VibL; //? - BuffTemp[16] = Main.Firmware_Version;//ХЗ - BuffTemp[17] = Main.Firmware_Version;//ХЗ + BuffTemp[16] = Gyro.Firmware_Version;//ХЗ + BuffTemp[17] = Gyro.Firmware_Version;//ХЗ BuffTemp[18] = T_VibH>>1; BuffTemp[19] = T_VibL; - BuffTemp[20] = Main.Firmware_Version;//ХЗ - BuffTemp[21] = Main.Firmware_Version;//ХЗ + BuffTemp[20] = Gyro.Firmware_Version;//ХЗ + BuffTemp[21] = Gyro.Firmware_Version;//ХЗ BuffTemp[22] = WP_regH; //СРП Spi.DAC_B BuffTemp[23] = WP_regL; //СРП - BuffTemp[24] = Main.Firmware_Version;// ХЗ - BuffTemp[25] = Main.Firmware_Version;// ХЗ + BuffTemp[24] = Gyro.Firmware_Version;// ХЗ + BuffTemp[25] = Gyro.Firmware_Version;// ХЗ BuffTemp[26] = ADC1H; BuffTemp[27] = ADC1L; @@ -159,10 +159,10 @@ BuffTemp[36] = 0x00;//ADC6 BuffTemp[37] = 0x00;//ADC6 - BuffTemp[38] = Main.Firmware_Version; - BuffTemp[39] = Main.Firmware_Version; - BuffTemp[40] = Main.Firmware_Version; - BuffTemp[41] = Main.Firmware_Version; + BuffTemp[38] = Gyro.Firmware_Version; + BuffTemp[39] = Gyro.Firmware_Version; + BuffTemp[40] = Gyro.Firmware_Version; + BuffTemp[41] = Gyro.Firmware_Version; Check(BuffTemp, 44); @@ -173,9 +173,9 @@ void CMD_M_Control_D8()///установка\сброс регистров управления { int bit,NReg; - BuffTemp[0] = Main.SOC_Out; //DD - BuffTemp[1] = Main.My_Addres; //00 - BuffTemp[2] = Main.CMD_In; //D8 + BuffTemp[0] = Gyro.SOC_Out; //DD + BuffTemp[1] = Gyro.My_Addres; //00 + BuffTemp[2] = Gyro.CMD_In; //D8 //10? if((Param1&0x80)) { bit=1; @@ -185,58 +185,58 @@ if ((Param1 & 0x10) == 0) { NReg=0; - switch(Param1&0xf) { // Main.RgConA + switch(Param1&0xf) { // Gyro.RgConA case 0x0: - Main.RgConA|=bit; + Gyro.RgConA|=bit; break; case 0x1: - Main.RgConA|=bit<<0x1; + Gyro.RgConA|=bit<<0x1; break; case 0x2: - Main.RgConA|=bit<<0x2; + Gyro.RgConA|=bit<<0x2; break; case 0x3: - Main.RgConA|=bit<<0x3; + Gyro.RgConA|=bit<<0x3; break; case 0x4: - Main.RgConA|=bit<<0x4; + Gyro.RgConA|=bit<<0x4; break; case 0x5: - Main.RgConA|=bit<<0x5; + Gyro.RgConA|=bit<<0x5; break; case 0x6: - Main.RgConA|=bit<<0x6; + Gyro.RgConA|=bit<<0x6; break; case 0x7: - Main.RgConA|=bit<<0x7; + Gyro.RgConA|=bit<<0x7; break; } BuffTemp[3] = NReg<<4; - BuffTemp[4] = (Main.RgConA>>8 )& 0xff; - BuffTemp[5] = Main.RgConA & 0xff; + BuffTemp[4] = (Gyro.RgConA>>8 )& 0xff; + BuffTemp[5] = Gyro.RgConA & 0xff; } else { - NReg=1; // Main.RgConB - switch(Param1&0xf) { // Main.RgConB + NReg=1; // Gyro.RgConB + switch(Param1&0xf) { // Gyro.RgConB case 0x0: - Main.RgConB|=bit; + Gyro.RgConB|=bit; break; case 0x1: - Main.RgConB|=bit<1; + Gyro.RgConB|=bit<1; break; case 0x2: - Main.RgConB|=bit<2; + Gyro.RgConB|=bit<2; break; } BuffTemp[3] = NReg<<4; - BuffTemp[4] = (Main.RgConB>>8 ) & 0xff; - BuffTemp[5] = Main.RgConB & 0xff; + BuffTemp[4] = (Gyro.RgConB>>8 ) & 0xff; + BuffTemp[5] = Gyro.RgConB & 0xff; } Check(BuffTemp, CRC_N); @@ -246,17 +246,17 @@ void CMD_M_Control_D9()///чтение регистров управления { int bit,NReg; - BuffTemp[0] = Main.SOC_Out; //DD - BuffTemp[1] = Main.My_Addres; //00 - BuffTemp[2] = Main.CMD_In; //D9 + 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] = (Main.RgConA>>8 )& 0xff; - BuffTemp[5] = Main.RgConA & 0xff; + BuffTemp[4] = (Gyro.RgConA>>8 )& 0xff; + BuffTemp[5] = Gyro.RgConA & 0xff; } else { BuffTemp[3]=1<<4; - BuffTemp[4] = (Main.RgConB>>8 ) & 0xff; - BuffTemp[5] = Main.RgConB & 0xff; + BuffTemp[4] = (Gyro.RgConB>>8 ) & 0xff; + BuffTemp[5] = Gyro.RgConB & 0xff; } Check(BuffTemp, CRC_N); WriteConN (BuffTemp,CRC_N); @@ -303,12 +303,12 @@ if(c[Count-2]!=((CRC>>8)&0xFF)) { temp=0; - Main.RsErrLine = (Main.RsErrLine)&=0x2; + Gyro.RsErrLine = (Gyro.RsErrLine)&=0x2; } if(c[Count-1]!=((CRC>>0)&0xFF)) { temp=0; -// Main.RsErrLine= (Main.RsErrLine)=0x2; +// Gyro.RsErrLine= (Gyro.RsErrLine)=0x2; } c[Count-2]=(CRC>>8)&0xFF; @@ -322,8 +322,8 @@ int Getlengf(void) { unsigned int lengf=0; - switch(Main.CMD_In) { - case 0x99://maintainance + switch(Gyro.CMD_In) { + case 0x99://Gyrotainance lengf=6; CRC_N=8; break; @@ -367,24 +367,24 @@ void Read_CMD(void) { - Main.SOC_Out=0xDD; - Main.RsErrLine = (Main.RsErrLine)& 0xffff; + Gyro.SOC_Out=0xDD; + Gyro.RsErrLine = (Gyro.RsErrLine)& 0xffff; CountBuFFIn=ReadChekCon(BuffTemp); if(CountBuFFIn==1) { if (BuffTemp[0] != SOC_In) { ReadCon(BuffTemp); - Main.RsErrLine += 0x100;//WriteCon("\n\r ...Error.... "); - BuffTemp[99]=Main.RsErrLine; + Gyro.RsErrLine += 0x100;//WriteCon("\n\r ...Error.... "); + BuffTemp[99]=Gyro.RsErrLine; } } else if(CountBuFFIn==2) { - if (BuffTemp[1] != Main.My_Addres) { + if (BuffTemp[1] != Gyro.My_Addres) { ReadCon(BuffTemp); - Main.RsErrLine += 0x1;//WriteCon("\n\r ...Error_ADDRES.... "); + Gyro.RsErrLine += 0x1;//WriteCon("\n\r ...Error_ADDRES.... "); } } else if(CountBuFFIn==3) { - Main.CMD_In=BuffTemp[2]; + Gyro.CMD_In=BuffTemp[2]; N=Getlengf(); } else if(CountBuFFIn==4 && N==6) { Param1=BuffTemp[3]; @@ -400,7 +400,7 @@ } else if(CountBuFFIn > (N-1)) { ReadCon(BuffTemp); if(Check(BuffTemp, CountBuFFIn)) { - switch(Main.CMD_In) { + switch(Gyro.CMD_In) { case CMD_MAINT: CMD_Maintenance(); break; @@ -415,7 +415,7 @@ case 0xDD: Rate_Flag=1; break; - Main.RsErrLine = 0; + Gyro.RsErrLine = 0; } }