![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
fork
Fork of LG by
Diff: Command.c
- Revision:
- 194:8f3cb37a5541
- Parent:
- 193:a0fe8bfc97e4
- Child:
- 195:bcc769f5292b
diff -r a0fe8bfc97e4 -r 8f3cb37a5541 Command.c --- a/Command.c Thu Sep 15 11:09:00 2016 +0000 +++ b/Command.c Thu Sep 15 14:00:43 2016 +0000 @@ -33,9 +33,12 @@ void DropDelay(void) { Gyro.DropDelayGLD = DropDelayGLD_0; - if (Gyro.My_Addres==1) Gyro.DropDelayGLD = DropDelayGLD_1; - else if(Gyro.My_Addres==2) Gyro.DropDelayGLD = DropDelayGLD_2; - else if(Gyro.My_Addres==3) Gyro.DropDelayGLD = DropDelayGLD_3; + 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) @@ -415,18 +418,14 @@ BuffTemp[20] = 0x00; BuffTemp[21] = 0x00; - - Temp = Spi.DAC_B - 0x7fff; BuffTemp[22] = (Temp >> 8) & 0xff; BuffTemp[23] = (Temp >> 0) & 0xff; - Temp = Gyro.PLC_Delta >> 16; BuffTemp[24] = (Temp >> 8) & 0xff; BuffTemp[25] = (Temp >> 0) & 0xff;// - Temp = Gyro.AD_Slow >> 16; BuffTemp[26] = (Temp >> 8) & 0xff; BuffTemp[27] = (Temp >> 0) & 0xff; @@ -446,10 +445,10 @@ Temp = Gyro.DeltaT; BuffTemp[34] = (Temp >> 8) & 0xff;//дельта BuffTemp[35] = (Temp >> 0) & 0xff; - + // Temp = 000; Temp = Gyro.Termo; - // Temp = (0x7fff + Temp)/164; - Temp = 0x7fff+Temp; + Temp = (0x7fff + Temp);///164 + Temp = /*0x7fff+*/Temp; BuffTemp[36] =(Temp >> 8) & 0xff;//температура BuffTemp[37] =(Temp >> 0) & 0xff;//ADC6 sesnsor 5 @@ -476,9 +475,6 @@ temp2=temp2&0xFFFF; Gyro.AmpPer=(((((Gyro.Frq>>12)*200)/16)*temp2)/7680000); - - // Gyro.AmpPer = ((unsigned int) ((7680000*16/temp1)))*16*16*16; - Consol=Gyro.Frq ; } void CMD_M_Control_D8()///установка\сброс регистров управления { @@ -493,66 +489,29 @@ BuffTemp[1] = Gyro.My_Addres; //00 BuffTemp[2] = Gyro.CMD_In; //D8 -/* - - FrqON -PlcON - HFOOFF -HFOON - - PlcOFF - PlcON - */ Pa = BuffTemp[3]; - SR = Pa >> 0x7; - V = Pa >> 0x5; V = V & 0x3; - A = Pa >> 0x4; A = A & 0x1; - Bit_num = Pa & 0xf; - if(SR) { + if(SR) + { switch (Bit_num){ - - case 0x06: - FrqON - break; - - case 0x05: - AVibON - break; - - case 0x01: - HFOON - break; - - case 0x03: - PlcON - break; + 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; + case 0x06: FrqOFF break; + case 0x05: AVibOFF break; + case 0x01: HFOOFF break; + case 0x03: PlcOFF break; } } BuffTemp[0] = Gyro.SOC_Out; //DD @@ -604,6 +563,30 @@ Spi.DAC_B =(unsigned int)(DACF) /*(unsigned int)(temp*K_DAC+deltaDAC)*/; // K_DAC); } } + +void GLDStartDischarg(void) +{ + 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; @@ -648,71 +631,22 @@ { unsigned int lengf; lengf = 1; - switch(Gyro.CMD_In) { - case 0x99://Mintainance - lengf=6; - CRC_N=8; - break; - - case 0xB0://Delta_Bins - lengf=6; - CRC_N=9; - break; - - case 0xA0://Delta_PS - lengf=6; - CRC_N=8; - break; - - case 0xDD://m_rate - lengf=6; - CRC_N=44; - break; - - case 0x0A: //m_stymul - lengf=8; - break; - - case 0xE9://DeviceMode - lengf=6; - CRC_N=8; - break; - case 0xE8://DeviceMode - - lengf=6; - CRC_N=8; - break; - - case 0xA5://DeviceMode - - lengf=6; - CRC_N=8; - break; - - case 0xD8://m_control - - lengf=6; - CRC_N=6; - break; - - case 0xD9://m_control - - lengf=6; - CRC_N=8; - break; - - case 0xE4: - lengf=8; - break; - - - case 0xE6: - lengf=8; - break; - - } - - return lengf; + 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; 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) @@ -725,15 +659,15 @@ // если есть первый байт if (BuffTemp[0] != SOC_In) { ReadCon1(BuffTemp); - Gyro.RsErrLine += 0x100;//WriteCon("\n\r ...Error.... "); + Gyro.RsErrLine += 0x100; BuffTemp[99]=Gyro.RsErrLine; } } else if(CountBuFFIn==2) //если второй байт - { - if (BuffTemp[1] != Gyro.My_Addres) { + { // широковещаительный + if (BuffTemp[1] != Gyro.My_Addres /*|| BuffTemp[1] !=0x1f*/) { ReadCon1(BuffTemp); - Gyro.RsErrLine += 0x1;WriteCon("\n\r ...Error_ADDRES.... "); + Gyro.RsErrLine += 0x1; } } else if(CountBuFFIn==3) // если третий байт @@ -769,103 +703,48 @@ { ReadCon1(BuffTemp); switch(Gyro.CMD_In) { - - case 0x99: - Gyro.ModeOut=0; - CMD_Maintenance(); - break; - - case 0xD8: - CMD_M_Control_D8(); - break; - - case 0xE9://чтение параметров - CMD_M_Param_R(); - break; - - case 0xE8://запись параметра - CMD_M_Param_W(); - break; - - case 0xDA: - 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; - } - break; - - case 0xD9: - CMD_M_Control_D9(); - break; - - case 0x0A: - CMD_M_Stymul(); - break; - - case 0xDD: //Rate - TempParam=(BuffTemp[3]) & 0x9f; + case 0x99: Gyro.ModeOut=0; CMD_Maintenance(); break; + case 0xD8: CMD_M_Control_D8(); 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; Gyro.Rate1_Event=0; break; - case PRate2 : Gyro.ModeOut=2; Gyro.Reper_Event=0; break; + case PRate1 : Gyro.ModeOut=1; break; + case PRate2 : Gyro.ModeOut=2; break; } - break; - - case 0xA0: //Delta_PS - DropDelay();//выставка задержки для мультидропа сбрасывается в команде CMD_Maintenance() на () микросекунд; - TempParam=(BuffTemp[3]) & 0x90; + 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; break; case PDelta_EXT : Gyro.ModeOut=4; break; } - break; - - case 0xB0://Delta_Bins - DropDelay();//выставка задержки для мультидропа сбрасывается в команде CMD_Maintenance() на () микросекунд; + break; + case 0xB0: DropDelay(); TempParam = TempParam=(BuffTemp[3]>>7); //Delta_Bins switch(TempParam) { case PDelta_Bins: Gyro.ModeOut=5; break; case Delta_Bins : CMD_Delta_Bins(); break; } - break; - - case 0x0F://B_Delta - TempParam = (((BuffTemp[3])>>4) & 0x9); + 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; 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; - } - } + break; + case 0xE4: CMD_M_vib(); break; + case 0xE6: Gph_W(); break; + Gyro.RsErrLine = 0; + } + } }