123
Fork of LG by
Diff: Command.c
- Revision:
- 124:9ae09249f842
- Parent:
- 122:fbacb932a30b
- Child:
- 125:9400e64d0636
--- a/Command.c Thu Apr 07 20:16:24 2016 +0000 +++ b/Command.c Fri Apr 08 14:20:35 2016 +0000 @@ -11,6 +11,7 @@ unsigned int Param4=0; unsigned int Consol=123; unsigned int TempParam=1; +unsigned int CountParam=0; /* void exec_CMD(void) //r. === процедура окончательной дешифрации и исполнения команды { @@ -25,34 +26,341 @@ { BuffTemp[0] = Gyro.SOC_Out; - BuffTemp[1] = Gyro .My_Addres; - BuffTemp[2] = Gyro .Firmware_Version; - BuffTemp[3] = Gyro .GLD_Serial; + 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_Rate3(void) -{ +void CMD_Delta_500Hz(void) +{ + Gyro.Delta500_Event=0; unsigned int Temp; - BuffTemp[ 0] = Gyro.SOC_Out; + 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; - Temp=0x00; - BuffTemp[ 2] =(Temp >> 8) & 0xff;// - BuffTemp[ 3] =(Temp >> 0) & 0xff;// - Temp=0x00; - BuffTemp[ 4] =(Temp >> 8) & 0xff;// - BuffTemp[ 5] =(Temp >> 0) & 0xff;// + break; + + case 11: + BuffTemp[5] = (Temp >> 0) & 0xff; + break; + + + + //темпкратурный канал 1 + 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, 6); + WriteConN (BuffTemp,6); + CountParam++; + + if(CountParam>21)CountParam=0;//зацикливания буфера от 0 до 21 + +} +void CMD_Delta_Ext(void) +{ + 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; - Check(BuffTemp, 44); - WriteConN (BuffTemp,44); + 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; + + + + //темпкратурный канал 1 + 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, 6); + WriteConN (BuffTemp,6); + CountParam++; + + if(CountParam>21)CountParam=0;//зацикливания буфера от 0 до 21 } + void CMD_Rate2(void) { - Rate2VibFlag=0; + Gyro.Rate2_Event=0; BuffTemp[ 0] = Gyro.SOC_Out; BuffTemp[ 1] = Gyro.My_Addres; @@ -62,17 +370,15 @@ 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; Gyro.Firmware_Version=0xff; /// промежуточная затычка @@ -353,7 +659,13 @@ lengf=6; CRC_N=44; break; - + + case 0xA0://Delta_PS + lengf=6; + CRC_N=8; + break; + + case 0xB0://DeviceMode lengf=6; @@ -441,12 +753,19 @@ switch(Gyro.CMD_In) { Rate_Flag=0; case 0x99: - Rate_Flag=0; + Gyro.ModeOut=0; CMD_Maintenance(); - + break; + case 0xA0: + TempParam=(BuffTemp[3]) & 0x90; + if (TempParam==Delta_500) CMD_Delta_500Hz(); + else if (TempParam==Delta_EXT) CMD_Delta_Ext(); + else if (TempParam==PDelta_500) { Gyro.ModeOut=3; Gyro.Delta500_Event=0; WriteCon("Delta500"); } + else if (TempParam==PDelta_EXT) { Gyro.ModeOut=4; Gyro.DeltaEXT_Event=0; WriteCon("deltaEXT"); } break; case 0xD8: CMD_M_Control_D8(); + break; case 0xD9: CMD_M_Control_D9(); break; @@ -454,13 +773,11 @@ CMD_M_Stymul(); break; case 0xDD: - Rate_Flag=0; - TempParam=(BuffTemp[3]) & 0x9f; - if (TempParam == 0x01) { Rate_Flag=0; CMD_Rate(); WriteCon("Rate11");} - else if (TempParam == 0x02) { Rate_Flag=0; CMD_Rate2(); WriteCon("Rate21");} - else if (TempParam == 0x81) { Rate_Flag=1; WriteCon("Rate12");} - else if (TempParam == 0x82) { Rate_Flag=2; Rate2VibFlag==0; WriteCon("Rate22");} - + TempParam=(BuffTemp[3]) & 0x9f; + if (TempParam == Rate1) { CMD_Rate(); WriteCon("Rate11");} + else if (TempParam == Rate2) { CMD_Rate2(); WriteCon("Rate21");} + else if (TempParam == PRate1) { Gyro.ModeOut=1; Gyro.Rate1_Event=0; WriteCon("Rate12");} + else if (TempParam == PRate2) { Gyro.ModeOut=2; Gyro.Rate2_Event=0; WriteCon("Rate22");} break; case 0xE4: CMD_M_vib();