📄 align.c
字号:
#include "public.h"
/*static const unsigned char BoardDefaultSetting[]=
{
0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xd1,0x60,0x08,0x80,0x1a,0x98,0x8f,0x00,0x61,0xd0,
0x20,0x4a,0x93,0x35,0x25,0x20,0x00,0xc0,0x36,0xc6,
0x00,0x07,0x04,0x60,0x46,0x9e,0xe7,0x79,0x7c,0xdc,
0x14,0x7d,0x79,0x00,0x00,0x00,0x00,0x00,0xfe,0xfe,
0xaf,0x94,0x8d,0x48,0x48,0x48,0xa6,0x9d,0x92,0x90,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00
};*/
#if TDA7540Tuner
static const unsigned char BoardDefaultSetting[]=
{
0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x51,0x60,0x08,0x00,0x8b,0x9d,0x61,0x00,0xa0,0xf2,
0x00,0x6b,0xa5,0x63,0x25,0x20,0x00,0xc0,0xf4,0xf7,
0x2a,0xc7,0x04,0x35,0xc6,0x5e,0xe7,0x19,0x7f,0x8c,
0x17,0x7d,0x74,0x00,0x00,0x00,0x00,0x00,0xfe,0xfe,
0xb5,0x8a,0x20,0x00,0x00,0x00,0xab,0x9b,0x08,0x18,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00
};
#endif
#if TDA7541Tuner
static const unsigned char BoardDefaultSetting[]=
{
0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x0b,0x60,0x08,0x00,0xdc,0x3d,0x06,0x50,0x7a,0x49,
0x0e,0x49,0xa9,0x40,0xd8,0xe7,0x1d,0x77,0x0d,0x2f,
0x97,0xfa,0x05,0xe2,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,
0xfe,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
#endif
void CheckGUI(void)
{
PO_I2CData=0;
PD_I2CData=0;
Pin_I2CData=0;
Wait10us(10);
if(Pin_I2CData)
{
if(GUIExistTimer<255)
GUIExistTimer++;
}
else
{
if(GUIExistTimer>0)
GUIExistTimer--;
}
if(GUIExistTimer==255)
{
F_GUIExist=1;
PO_I2CData=0;
PD_I2CData=0;
PD_I2CClk=0;
}
else if(GUIExistTimer==0)
{
F_GUIExist=0;
PO_I2CData=1;
PD_I2CData=1;
PD_I2CClk=1;
}
}
void AlignInit(void)
{
unsigned char i,j,k;
Pin_POWER=1;
Wait1ms(250);
EepromRead(BoardEepromAddress,0,1,&BoardEepromBuff[0]);
#if TDA7540Tuner
if(BoardEepromBuff[0]!=0x0C)
{
TRAP;
for(i=0;i<72;i++)
BoardEepromBuff[i]=BoardDefaultSetting[i];
for(i=0;i<9;i++)
{
EepromWrite(BoardEepromAddress, i*8, 8, &BoardEepromBuff[i*8]);
Wait1ms(25);
}
}
else
{
TRAP;
EepromRead(BoardEepromAddress,0,72,&BoardEepromBuff[0]);
}
TRAP;
#endif
#if TDA7541Tuner
if(BoardEepromBuff[0]!=0x0B)
{
TRAP;
for(i=0;i<100;i++)
BoardEepromBuff[i]=BoardDefaultSetting[i];
//display empty and load defaut setting
for(i=0;i<12;i++)
{
EepromWrite(BoardEepromAddress, i*8, 8, &BoardEepromBuff[i*8]);
Wait1ms(25);
}
EepromWrite(BoardEepromAddress, 96, 4, &BoardEepromBuff[96]);
Radio.F_Board_Empty=1;
}
else
{
TRAP;
EepromRead(BoardEepromAddress,0,100,&BoardEepromBuff[0]);
Radio.F_Board_Empty=0;
}
TRAP;
#endif
Pin_POWER=0;
}
void AlignMain(void)
{
if(System.FWorkMode.Next==WORKMODE_ALIGN)
{
EepromRead(BoardEepromAddress,0,1,&BoardEepromBuff[0]);
Wait1ms(10);
#if TDA7540Tuner
if(BoardEepromBuff[0]!=0x0c)
#endif
#if TDA7541Tuner
if(BoardEepromBuff[0]!=0x0b)
#endif
{
Radio.F_Board_Empty=1;
RadioBoardEepromTimer=10;
}
else
{
Radio.F_Board_Empty=0;
}
Align.Mode=ALIGN_STANDBY;
Align.SubMode=ALIGN_SELECT_AUTO;
AudioMute(SOFTOFF);
}
if(System.FWorkMode.Last==WORKMODE_ALIGN)
{
}
AlignKey();
AlignDisplay();
AlignWork();
//CheckGUI();
}
void AlignKey(void)
{
unsigned char temp,temp2;
char dirc;
if(System.FWorkMode.Current!=WORKMODE_ALIGN)return;
switch(KeyCode)
{
case P_AD_UP:
case P_AD_DOWN:
if(KeyCode==P_AD_UP)
dirc=1;
else
dirc=-1;
switch(Align.Mode)
{
case ALIGN_STANDBY:
Align.SubMode=MaxMinChangeProtect(Align.SubMode, -dirc, 4, 0, 0);
break;
case ALIGN_MANUALIGN:
switch(Align.SubMode)
{
#if TDA7540Tuner
case ALIGN_MANU_STANDBY:
Align.SubStep=MaxMinChangeProtect(Align.SubStep, -dirc, 12, 0, 0);
break;
case ALIGN_MANU_XTAL:
temp=(Radio.TunerBuff[19]>>3);
temp=MaxMinChangeProtect(temp, dirc, 31, 0, 0);
Radio.TunerBuff[19]=(Radio.TunerBuff[19]&y00000111)+(temp<<3);
RadioTunerSend(19,19);
break;
case ALIGN_MANU_FMSLIDER:
temp=(Radio.TunerBuff[18]&y00011111);
temp=MaxMinChangeProtect(temp, dirc, 31, 0, 0);
Radio.TunerBuff[18]=(Radio.TunerBuff[18]&y11100000)+temp;
RadioTunerSend(18,18);
break;
case ALIGN_MANU_FMSTOP:
temp=(Radio.TunerBuff[23]>>4);
temp=MaxMinChangeProtect(temp, dirc, 15, 0, 0);
Radio.TunerBuff[23]=(Radio.TunerBuff[23]&y00001111)+(temp<<4);
RadioTunerSend(23,23);
break;
case ALIGN_MANU_FMMUTE:
temp=((Radio.TunerBuff[12]&y01111000)>>3);
temp=MaxMinChangeProtect(temp, dirc, 15, 0, 0);
Radio.TunerBuff[12]=(Radio.TunerBuff[12]&y10000111)+(temp<<3);
RadioTunerSend(12,12);
break;
case ALIGN_MANU_FMDEMOD:
temp=(Radio.TunerBuff[17]&y00111111);
temp=MaxMinChangeProtect(temp, dirc, 63, 0, 0);
Radio.TunerBuff[17]=(Radio.TunerBuff[17]&y11000000)+temp;
RadioTunerSend(17,17);
break;
case ALIGN_MANU_ROLLOFF:
temp=(Radio.TunerBuff[30]&y00001111);
temp=MaxMinChangeProtect(temp, dirc, 15, 0, 0);
Radio.TunerBuff[30]=(Radio.TunerBuff[30]&y11110000)+temp;
RadioTunerSend(30,30);
break;
case ALIGN_MANU_STBLEND:
temp=(Radio.TunerBuff[28]&y00000111);
temp=MaxMinChangeProtect(temp, dirc, 7, 0, 0);
Radio.TunerBuff[28]=(Radio.TunerBuff[28]&y11111000)+temp;
RadioTunerSend(28,28);
break;
case ALIGN_MANU_VHCL:
temp=((Radio.TunerBuff[27]&y00011000)>>3);
temp=MaxMinChangeProtect(temp, dirc, 3, 0, 0);
Radio.TunerBuff[27]=(Radio.TunerBuff[27]&y11100111)+(temp<<3);
RadioTunerSend(27,27);
break;
case ALIGN_MANU_VHCH:
temp=((Radio.TunerBuff[27]&y01100000)>>5);
temp=MaxMinChangeProtect(temp, dirc, 3, 0, 0);
Radio.TunerBuff[27]=(Radio.TunerBuff[27]&y10011111)+(temp<<5);
RadioTunerSend(27,27);
break;
case ALIGN_MANU_IFGAIN:
temp=((Radio.TunerBuff[19]&y00000110)>>1);
temp=MaxMinChangeProtect(temp, dirc, 3, 0, 0);
Radio.TunerBuff[19]=(Radio.TunerBuff[19]&y11111001)+(temp<<1);
RadioTunerSend(19,19);
break;
case ALIGN_MANU_AMAGC:
temp=(Radio.TunerBuff[16]&y00001111);
temp=MaxMinChangeProtect(temp, dirc, 15, 0, 0);
Radio.TunerBuff[16]=(Radio.TunerBuff[16]&y11110000)+temp;
RadioTunerSend(16,16);
break;
case ALIGN_MANU_HIGHCUT:
temp=((Radio.TunerBuff[27]&y00000110)>>1);
temp=MaxMinChangeProtect(temp, dirc, 3, 0, 0);
Radio.TunerBuff[27]=(Radio.TunerBuff[27]&y11111001)+(temp<<1);
RadioTunerSend(27,27);
break;
case ALIGN_MANU_IFCOUNT:
temp=(Radio.TunerBuff[5]&y00000111);
temp=MaxMinChangeProtect(temp, dirc, 7, 0, 0);
Radio.TunerBuff[5]=(Radio.TunerBuff[5]&y11111000)+temp;
RadioTunerSend(5,5);
break;
#endif
#if TDA7541Tuner
case TDA7541_ALIGN_MANU_STANDBY:
Align.SubStep=MaxMinChangeProtect(Align.SubStep, -dirc, 8, 0, 0);
break;
case TDA7541_ALIGN_MANU_XTAL:
temp=Radio.TunerBuff[13]& y00011111;
temp=MaxMinChangeProtect(temp, dirc, 31, 0, 0);
Radio.TunerBuff[13]=(Radio.TunerBuff[13]&y11100000)+temp;
RadioTunerSend(13,13);
break;
case TDA7541_ALIGN_MANU_FMSLIDER:
temp=Radio.TunerBuff[13]>>5;
temp=MaxMinChangeProtect(temp, dirc, 7, 0, 0);
Radio.TunerBuff[13]=(Radio.TunerBuff[13]&y00011111)+temp<<5;
RadioTunerSend(13,13);
break;
case TDA7541_ALIGN_MANU_FMSTOP:
temp=Radio.TunerBuff[10]>>4;
temp=MaxMinChangeProtect(temp, dirc, 15, 0, 0);
Radio.TunerBuff[10]=(Radio.TunerBuff[10]&y00001111)+(temp<<4);
RadioTunerSend(10,10);
break;
case TDA7541_ALIGN_MANU_FMMUTE:
temp=(Radio.TunerBuff[11])>>5;
temp=MaxMinChangeProtect(temp, dirc, 7, 0, 0);
Radio.TunerBuff[11]=(Radio.TunerBuff[11]&y00011111)+(temp<<5);
RadioTunerSend(11,11);
break;
//case ALIGN_MANU_FMDEMOD:
// temp=(Radio.TunerBuff[17]&y00111111);
// temp=MaxMinChangeProtect(temp, dirc, 63, 0, 0);
// Radio.TunerBuff[17]=(Radio.TunerBuff[17]&y11000000)+temp;
// RadioTunerSend(17,17);
// break;
case TDA7541_ALIGN_MANU_ROLLOFF:
temp=(Radio.TunerBuff[17]&y00001111);
temp=MaxMinChangeProtect(temp, dirc, 15, 0, 0);
Radio.TunerBuff[17]=(Radio.TunerBuff[17]&y11110000)+temp;
RadioTunerSend(17,17);
break;
case TDA7541_ALIGN_MANU_STBLEND:
temp=(Radio.TunerBuff[18]&y00000111);
temp=MaxMinChangeProtect(temp, dirc, 7, 0, 0);
Radio.TunerBuff[18]=(Radio.TunerBuff[18]&y11111000)+temp;
RadioTunerSend(18,18);
break;
case TDA7541_ALIGN_MANU_VHCL:
temp=((Radio.TunerBuff[19]&y00011000)>>3);
temp=MaxMinChangeProtect(temp, dirc, 3, 0, 0);
Radio.TunerBuff[19]=(Radio.TunerBuff[19]&y11100111)+(temp<<3);
RadioTunerSend(19,19);
break;
case TDA7541_ALIGN_MANU_VHCH:
temp=((Radio.TunerBuff[19]&y01100000)>>5);
temp=MaxMinChangeProtect(temp, dirc, 3, 0, 0);
Radio.TunerBuff[19]=(Radio.TunerBuff[19]&y10011111)+(temp<<5);
RadioTunerSend(19,19);
break;
//case ALIGN_MANU_IFGAIN:
// temp=((Radio.TunerBuff[19]&y00000110)>>1);
// temp=MaxMinChangeProtect(temp, dirc, 3, 0, 0);
// Radio.TunerBuff[19]=(Radio.TunerBuff[19]&y11111001)+(temp<<1);
// RadioTunerSend(19,19);
// break;
//case ALIGN_MANU_AMAGC:
// temp=(Radio.TunerBuff[16]&y00001111);
// temp=MaxMinChangeProtect(temp, dirc, 15, 0, 0);
// Radio.TunerBuff[16]=(Radio.TunerBuff[16]&y11110000)+temp;
// RadioTunerSend(16,16);
// break;
case TDA7541_ALIGN_MANU_HIGHCUT:
temp=((Radio.TunerBuff[19]&y00000110)>>1);
temp=MaxMinChangeProtect(temp, dirc, 3, 0, 0);
Radio.TunerBuff[19]=(Radio.TunerBuff[19]&y11111001)+(temp<<1);
RadioTunerSend(19,19);
break;
//case ALIGN_MANU_IFCOUNT:
// temp=(Radio.TunerBuff[5]&y00000111);
// temp=MaxMinChangeProtect(temp, dirc, 7, 0, 0);
// Radio.TunerBuff[5]=(Radio.TunerBuff[5]&y11111000)+temp;
// RadioTunerSend(5,5);
// break;
#endif
}
break;
case ALIGN_EEPROM:
switch(Align.SubMode)
{
case ALIGN_EEPROM_STANDBY:
Align.SubStep=MaxMinChangeProtect(Align.SubStep, -dirc, 1, 0, 0);
break;
case ALIGN_EEPROM_TUNER:
switch(Align.EditPos)
{
case 0:
#if TDA7540Tuner
//Align.SubStep=MaxMinChangeProtect(Align.SubStep, 10*dirc, 59, 0, 0);
Align.SubStep=MaxMinChangeProtect(Align.SubStep, 10*dirc, 69, 0, 0);
#endif
#if TDA7541Tuner
//Align.SubStep=MaxMinChangeProtect(Align.SubStep, 10*dirc, 59, 0, 0);
//Align.SubStep=MaxMinChangeProtect(Align.SubStep, 10*dirc, 69, 0, 0);
Align.SubStep=MaxMinChangeProtect(Align.SubStep, 10*dirc, 100, 0, 0);
#endif
break;
case 1:
#if TDA7540Tuner
//Align.SubStep=MaxMinChangeProtect(Align.SubStep, dirc, 59, 0, 0);
Align.SubStep=MaxMinChangeProtect(Align.SubStep, dirc, 69, 0, 0);
#endif
#if TDA7541Tuner
//Align.SubStep=MaxMinChangeProtect(Align.SubStep, dirc, 59, 0, 0);
Align.SubStep=MaxMinChangeProtect(Align.SubStep, dirc, 100, 0, 0);
#endif
break;
case 2:
temp=TunerEepromBuff[Align.SubStep]/16;
temp2=TunerEepromBuff[Align.SubStep]%16;
temp=MaxMinChangeProtect(temp, dirc, 15, 0, 0);
TunerEepromBuff[Align.SubStep]=temp*16+temp2;
break;
case 3:
temp=TunerEepromBuff[Align.SubStep]/16;
temp2=TunerEepromBuff[Align.SubStep]%16;
temp2=MaxMinChangeProtect(temp2, dirc, 15, 0, 0);
TunerEepromBuff[Align.SubStep]=temp*16+temp2;
break;
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case 11:
temp=11-Align.EditPos;
if(TunerEepromBuff[Align.SubStep]&(1<<temp))
TunerEepromBuff[Align.SubStep]&=~(1<<temp);
else
TunerEepromBuff[Align.SubStep]|=(1<<temp);
break;
}
if(Align.EditPos>1)
EepromWrite(TunerEepromAddress, Align.SubStep, 1, &TunerEepromBuff[Align.SubStep]);
break;
case ALIGN_EEPROM_BOARD:
switch(Align.EditPos)
{
case 0:
#if TDA7540Tuner
//Align.SubStep=MaxMinChangeProtect(Align.SubStep, 10*dirc, 59, 0, 0);
Align.SubStep=MaxMinChangeProtect(Align.SubStep, 10*dirc, 69, 0, 0);
#endif
#if TDA7541Tuner
//Align.SubStep=MaxMinChangeProtect(Align.SubStep, 10*dirc, 59, 0, 0);
Align.SubStep=MaxMinChangeProtect(Align.SubStep, 10*dirc, 100, 0, 0);
#endif
break;
case 1:
#if TDA7540Tuner
//Align.SubStep=MaxMinChangeProtect(Align.SubStep, dirc, 59, 0, 0);
Align.SubStep=MaxMinChangeProtect(Align.SubStep, dirc, 69, 0, 0);
#endif
#if TDA7541Tuner
//Align.SubStep=MaxMinChangeProtect(Align.SubStep, dirc, 59, 0, 0);
Align.SubStep=MaxMinChangeProtect(Align.SubStep, dirc, 100, 0, 0);
#endif
break;
case 2:
temp=BoardEepromBuff[Align.SubStep]/16;
temp2=BoardEepromBuff[Align.SubStep]%16;
temp=MaxMinChangeProtect(temp, dirc, 15, 0, 0);
BoardEepromBuff[Align.SubStep]=temp*16+temp2;
break;
case 3:
temp=BoardEepromBuff[Align.SubStep]/16;
temp2=BoardEepromBuff[Align.SubStep]%16;
temp2=MaxMinChangeProtect(temp2, dirc, 15, 0, 0);
BoardEepromBuff[Align.SubStep]=temp*16+temp2;
break;
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case 11:
temp=11-Align.EditPos;
if(BoardEepromBuff[Align.SubStep]&(1<<temp))
BoardEepromBuff[Align.SubStep]&=~(1<<temp);
else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -