📄 radio_1.c.bak
字号:
if ( ( u16h_ifdata >= 0x5380 ) && ( u16h_ifdata <= 0x53B0 ) )
{
u08h_tuner_scc = 0x0e; //send pll
}
else
{
u08h_tuner_scc &= B11111001;
}
}
else
{
// AM, compare it w/1C20 = 450KHz with 16ms gate time
// freq tol is +-2KHz from 01C0 to 01C4
if ( ( u16h_ifdata >= 0x01c0 ) && ( u16h_ifdata <= 0x01c4 ) )
{
u08h_tuner_scc = 0x0e;
}
else
{
u08h_tuner_scc &= B11111001;
}
}
return;
}
void TUCtrl_SendPll( void )
{
Valid_Freq( );
Freq_Cal( );
// Manual_Para( );
if ( gu16_timer_wait != 0 )
{
return;
}
Manual_Para( );
Send_Pll( );
u08h_tuner_scc = 0x0f;
if ( u08h_rmute == 0 )
{
gu16_timer_wait = 25;
}
else
{
gu16_timer_wait = 50;
}
u08h_rmute = 0x00;
return;
}
void TUCtrl_AmuteOff( void )
{
if ( gu16_timer_wait == 0 )
{
Save_Com_Mem( );
Radio_Amute_Sens_Off( );
u08h_tuner_scc = 0x00;
u08_lp_start = 0;
}
return;
}
void Step_Up( void )
{
u16_rdata++;
return;
}
void Step_Dn( void )
{
u16_rdata--;
return;
}
// AUTO TUNNING PARAMETER SETTING
void Auto_Para( void )
{
u08h_tu_stat[1] |= TU_STAT_CT; //set CT=1
u08h_tu_stat[1] &= ~TU_STAT_IFOFF; //active IF count
if ( ( u08h_tu_stat[1] & TU_STAT_AM1 ) == 0 )
{ // FM
u08h_tu_stat[0] = 0x40; //set GT=1, Gate time=32ms, Ref Freq=25KHz
}
else
{
if ( ( u08h_tuner_o & B00000100 ) == 0 )
{ // EUR
u08h_tu_stat[0] = 0x0d; //set GT=0, Gate Time=16ms, Ref Freq=3KHz
}
else
{ // USA
u08h_tu_stat[0] = 0x0e; //set GT=0, Gate Time=16ms, Ref Freq=5KHz
}
}
return;
}
// GET PLL DATA
void Get_Pll_Data( void )
{
CPU_PIOA |= CPU_PLL_CLK;
Common_Wait_us( 20 );
Read_Bit( 4 ); //by dividing 16, bit0 to bit3 no need to be stored
u16h_ifdata = Read_Bit( 16 );
return;
}
UINT16 Read_Bit( UINT08 count )
{
volatile UINT08 i;
volatile UINT16 j=0x0000;
for ( i = 0; i < count ; i++ )
{
CPU_PIOA &= ~CPU_PLL_CLK; //set CLK low
Common_Wait_us( 20 );
CPU_PIOA |= CPU_PLL_CLK; //set CLK high
Common_Wait_us( 20 );
j = j >> 1;
if ( CPU_PIOA & CPU_PLL_CD )
{
j |= 0x8000;
}
}
return j;
}
// LOAD COMMON SETTING FOR FM/AM
void Load_Com_Mem( void )
{
if ( ( u08h_tu_stat[1] & TU_STAT_AM1 ) == 0 )
{ // FM
u08h_dts_df = u08h_fm_dts_df;
u08_rno = u08_fm_no;
if ( ( u08h_tuner_o & B00000010 ) == 0 )
{ // EUR
u16_sd_init = FM_EUR_SD_FREQ;
u16h_ss_init = FM_EUR_SS_FREQ;
u08_sd_step = FM_EUR_SD_STEP;
u08h_ss_step = FM_EUR_SS_STEP;
u16_max = FM_EUR_MAX;
}
else
{ // USA
u16_sd_init = FM_USA_SD_FREQ;
u16h_ss_init = FM_USA_SS_FREQ;
u08_sd_step = FM_USA_SD_STEP;
u08h_ss_step = FM_USA_SS_STEP;
u16_max = FM_USA_MAX;
}
}
else
{ // AM
u08h_dts_df = u08h_am_dts_df;
u08_rno = u08_am_no;
if ( ( u08h_tuner_o & B00000100 ) == 0 )
{ // EUR
u16_sd_init = AM_EUR_SD_FREQ;
u16h_ss_init = AM_EUR_SS_FREQ;
u08_sd_step = AM_EUR_SD_STEP;
u08h_ss_step = AM_EUR_SS_STEP;
u16_max = AM_EUR_MAX;
}
else
{ // USA
u16_sd_init = AM_USA_SD_FREQ;
u16h_ss_init = AM_USA_SS_FREQ;
u08_sd_step = AM_USA_SD_STEP;
u08h_ss_step = AM_USA_SS_STEP;
u16_max = AM_USA_MAX;
}
}
return;
}
// SAVE COMMON SETTING
void Save_Com_Mem( void )
{
if ( ( u08h_tu_stat[1] & TU_STAT_AM1 ) == 0 )
{ // FM
u08h_fm_dts_df = u08h_dts_df;
u08_fm_no = u08_rno;
}
else
{ // AM
u08h_am_dts_df = u08h_dts_df;
u08_am_no = u08_rno;
}
return;
}
// MANUAL TUNNING PARAMETER SETTING
void Manual_Para( void )
{
u08h_tu_stat[1] &= B00001111;
u08h_tu_stat[1] |= B00000100; // clear IF count
if ( ( u08h_tu_stat[1] & TU_STAT_AM1 ) == 0 )
{ // FM
if ( u08_mono == 0 )
{ // STEREO
u08h_tu_stat[1] &= ~TU_STAT_MONO;
}
else
{ // MONO
u08h_tu_stat[1] |= TU_STAT_MONO;
}
u08h_tu_stat[0] = 0x00; // FM Ref = 25KHz
}
else
{
if ( ( u08h_tuner_o & B00000100 ) == 0 )
{ // EUR
u08h_tu_stat[0] = 0x0D; // EUR Ref = 3KHz
}
else
{
u08h_tu_stat[0] = 0x0E; // USA Ref = 5KHz
}
}
return;
}
// SEND COMMAND TO PLL (LSB FIRST)
void Send_Pll( void )
{
CPU_PIOA |= CPU_PLL_CLK; // make sure PLL_CLK is in high level
Common_Wait_us( 20 );
// CPU_PIO7 |= CPU_PLL_CE; // set PLL_CE to high level //AD
CPU_PIO3 |= CPU_PLL_CE; // set PLL_CE to high level //AP
Common_Wait_us( 20 );
if ( ( u08h_tu_stat[1] & TU_STAT_AM1 ) == 0 )
{ // FM
Send_Bit( u16h_ss_freq, 16 );
}
else
{ // AM
Send_Bit( u16h_ss_freq << 4, 16 );
}
Send_Bit( u08h_tu_stat[1], 8 );
Send_Bit( u08h_tu_stat[0], 8 );
Common_Wait_us( 10 );
// CPU_PIO7 &= ~CPU_PLL_CE; // set PLL_CE low //AD
CPU_PIO3 &= ~CPU_PLL_CE; // set PLL_CE low //AP
return;
}
void Send_Bit( UINT16 input_data, UINT08 count )
{
volatile UINT08 i;
for ( i = 0 ; i < count ; i++ )
{
if ( input_data & 0x0001 )
{
CPU_PIOA |= CPU_PLL_DA; //set PLL_DATA high
}
else
{
CPU_PIOA &= ~CPU_PLL_DA; //set PLL_DATA low
}
Common_Wait_us( 10 );
CPU_PIOA &= ~CPU_PLL_CLK; //set PLL_CLK low
Common_Wait_us( 20 );
CPU_PIOA |= CPU_PLL_CLK; //set PLL_CLK high
input_data = input_data >> 1;
Common_Wait_us( 10 );
}
return;
}
/*
void TUCtrl_InitWait( void )
{
// switch( u08_wait_sts )
// {
// case 0:
// if( gu16_timer_wait != 0 )
// return;
Valid_Freq( );
Freq_Cal( );
BD3871_Data1( B01000000 ); //Channel B
DrvLCD_Equalizer_Init( );
gu16_timer_wait = 200;
// gu16_timer_wait=300;
// u08_wait_sts = 1;
// break;
// case 1:
// if( gu16_timer_wait != 0 )
// return;
// Manual_Para( );
// Send_Pll( );
u08h_tuner_scc = 0x0f;
// gu16_timer_wait = 25;
// u08_wait_sts = 0;
// u08h_rmute = 0x00;
// break;
// default:
// ; //051228
// }
return;
}
*/
// ERASE STATION MEMORY FORM 00-2F, 40-6F
void Clr_Station( void )
{
Common_Ram_Clear( );
u08h_eeword = 0x00;
while( u08h_eeword < 0x30 )
{
Wr_Eeprom( 4 );
u08h_eeword += 0x04;
}
u08h_eeword = 0x40;
while( u08h_eeword < 0x70 )
{
Wr_Eeprom( 4 );
u08h_eeword += 0x04;
}
return;
}
void Common_Ram_Clear( void )
{
u08_workspace[0] =
u08_workspace[1] =
u08_workspace[2] =
u08_workspace[3] = 0xff;
u16_fm_preset =
u16_am_preset = 0xffff;
u08h_fm_dts_df =
u08h_am_dts_df=
u08h_dts_df = 0x00;
u08_fm_no =
u08_fm_no = 1;
return;
}
void Ram_Clear( void )
{
u08_workspace[0] =
u08_workspace[1] =
u08_workspace[2] =
u08_workspace[3] = 0xff;
/* u08_workspace[4] =
u08_workspace[5] =
u08_workspace[6] =
u08_workspace[7] =// 0xff;
u08_workspace[8] =
u08_workspace[9] =
u08_workspace[10] =
u08_workspace[11] = 0xff; */
gu08_num_Volume=12;
u16_fm_preset =
u16_am_preset = 0xffff;
u08h_fm_dts_df =
u08h_am_dts_df=
u08h_dts_df = 0x00;
u08_fm_no =
u08_fm_no = 1;
u08h_eeword = 0x00;
while( u08h_eeword < 0x80 )
{
Wr_Eeprom( 4 );
u08h_eeword += 0x04;
}
// return;
return;
}
void Erase_Eeprom( void )
{
Common_Ram_Clear( );
u08h_eeword = 0x00;
while( u08h_eeword < 0x80 )
{
Wr_Eeprom( 4 );
u08h_eeword += 0x04;
}
return;
}
void Load_Eeprom( void )
{
u08h_eeword = 0x30;
Rd_Eeprom( 8 );
u16_fm_preset = u08_workspace[1];
u16_fm_preset = ( u16_fm_preset << 8 ) | u08_workspace[0];
u16_am_preset = u08_workspace[3];
u16_am_preset = ( u16_am_preset << 8 ) | u08_workspace[2];
u08h_tu_stat[0] = u08_workspace[4];
u08h_tu_stat[1] = u08_workspace[5];
u08h_fm_dts_df = u08_workspace[6];
u08h_am_dts_df = u08_workspace[7];
u08h_eeword = 0x38;
Rd_Eeprom( 8 );
u08_fm_no = u08_workspace[0];
u08_am_no = u08_workspace[1];
u08h_to_bak = u08_workspace[2];
gu08_num_Volume = u08_workspace[4];
gu08_kind_Equalizer = u08_workspace[5];
gu08_now_mode = u08_workspace[6];
if( gu08_now_mode > 4 ) // AC800
{
// if( gu08_kind_VolCtrl & B00000001 ) //AD
if(gu08_kind_VolCtrl==VOL_DIG) //AP
// if(gu08_kind_tuner!=3)
{
gu08_num_Volume = VOLUME_INIT_TACT;
}
else //AD
{ //AD
gu08_num_Volume = 12; //AD
} //AD
gu08_kind_Equalizer =
gu08_now_mode = 0;
}
return;
}
void Save_Eeprom( void )
{
u08_workspace[0] = u16_fm_preset;
u08_workspace[1] = u16_fm_preset >> 8;
u08_workspace[2] = u16_am_preset;
u08_workspace[3] = u16_am_preset >> 8;
u08h_eeword = 0x30;
Wr_Eeprom( 4 );
u08_workspace[0] = u08h_tu_stat[0];
u08_workspace[1] = u08h_tu_stat[1];
u08_workspace[3] = u08h_fm_dts_df;
u08_workspace[4] = u08h_am_dts_df;
u08h_eeword = 0x34;
Wr_Eeprom( 4 );
Save_No( );
return;
}
void Save_No( void )
{
u08_workspace[0] = u08_fm_no;
u08_workspace[1] = u08_am_no;
u08_workspace[2] = u08h_to_bak;
u08_workspace[3] = 0xff;
u08h_eeword = 0x38;
Wr_Eeprom( 4 );
return;
}
void Save_Vol( void )
{
u08_workspace[0] = gu08_num_Volume;
u08_workspace[1] = gu08_kind_Equalizer;
u08_workspace[2] = gu08_now_mode;
u08_workspace[3] = 0xff;
u08h_eeword = 0x3c;
Wr_Eeprom( 4 );
return;
}
//==============================================
// TUNER DISPLAY ROUTINE
//==============================================
void Tuner_Disp( void )
{
// Common_Disp();
// if(gu08_kind_Display==DISP_LED)
if(gu08_kind_tuner==3)
{
Clk_Normal_Disp();
Common_Disp();
}
else
{
// DrvLCD_Equalizer_Init( );
if( gu08_timer_SetVolume == 0 )
{
if(gu08_sts_Volume != 0)
{
Preset_No_Off( );
}
UserCtrl_VolumePopup_cansel();
}
if( gu08_sts_Volume != 0 )
{
DrvLCD_Volume_On();
DrvLCD_TitleNumberCD_On( gu08_num_Volume ); //尰嵼EVR抣傪昞帵
DrvLCD_Freq_Off( );
return;
}
CPU_LCD_SDR1 |= B00000001; // On "TUNE" icon
Common_Freq_On( );
//-->060210 //preset no on as tuner on
// Tuner_PresetNo_On();
//<--
switch ( u08h_dts_df & B00001001 )
{
case TU_DISP_NORMAL: // u08h_dts_df = 0x00
Preset_No_Off( );
break;
case TU_DISP_PRESET: // u08h_dts_df = 0x01
Preset_No_On( );
break;
case TU_DISP_PROG: // u08h_dts_df = 0x09
if( gu16_prog_timer == 0 )
{
u08h_dts_df = 0x00; // if time out, clear PROG mode
Preset_No_Off( );
}
else
{
if( gu08_flg_Blink == 1 )
{
CPU_LCD_SDR1 |= B00100000; // PGM icon on
if( ( u08h_dts_df & B00000010 ) == 0 )
{
Prog_Preset_On( );
}
else
{
Preset_No_On( );
}
}
else
{
Preset_No_Off( );
}
}
break;
default:
break;
}
if(gu08_flg_pst)Preset_No_On();
else
{
Preset_No_Off();
}
}
return;
}
void DrvLCD_TunerMain_Disp(void)
{
// if(gu08_kind_Display==DISP_LCD)DrvLCD_AllNumber_Off( );
if(gu08_kind_tuner!=3)DrvLCD_AllNumber_Off();
if((gu08_alm1_df!=1)&&(gu08_alm2_df!=1)/*&&(gu08_sleep_df!=1)*/) //clk display
{
Tuner_Disp();
}
DrvLCD_Alm1_Disp();
DrvLCD_Alm2_Disp();
DrvLCD_Sleep_Display();
return;
}
void DrvLCD_Freq_Off( void )
{
CPU_LCD_SDR0 &= B00010000; // ST
CPU_LCD_SDR4 = //B00000000;
CPU_LCD_SDR5 = //B00000000;
CPU_LCD_SDR6 = //B00000000;
CPU_LCD_SDR7 = //B00000000;
CPU_LCD_SDR8 = //B00000000;
CPU_LCD_SDR9 = B00000000;
return;
}
void Common_Freq_On( void )
{
if ( u08h_tu_stat[1] & TU_STAT_AM1 )
{ // AM
AM_Freq_On( );
}
else
{ // FM
FM_Freq_On( );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -