⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 autosrch.c

📁 以ST公司CPU为核心的彩色电视机的完整源程序。
💻 C
字号:
/********************** SGS-THOMSON MICROELECTRONICS ************************
FILENAME     : AUTOSRCH.C
VERSION      : V1.0
DATE         : JAN 1999
AUTHOR(s)    : ASHISH RUDOLA / DEEPAK DOSHI
PROCESSOR    : ST92195
DESCRIPTION  : This module contains functions which implement the
               autosearch process.
MODIFICATIONS:	
  	- 
*****************************************************************************/

#include "st92196.h"
#include "autosrch.h"
#include "macro.h"
#include "channel.h"
#include "i2c_bus.h"
#include "menuctrl.h"
#include "register.h"
#include "timer.h"
#include "tuning.h"
#include "utility.h"
#include "video.h"
#include "channel.h"
#include "eeprom.h"
#include "keyboard.h"
#include "source.h"
#include "tv_glob.h"
#include "osdchar.h"
#include "service.h"
#include "power.h"
#include "display.h"
#include "audio.h"
#include "io.h"

/*****************************************************************************
INPUTS     : none
OUTPUTS    : 
DESCRIPTION: This function initializes autosearch to its nominal state.
*****************************************************************************/
void init_autosearch(void)
{
	/* Make sure autosearch is disabled */
		  command_flags = command_flags | AUTO_SEARCH_DIRECTION;

   	tuning_flags = tuning_flags & ~(AUTOPROG_REQUEST );
}

/*****************************************************************************
INPUTS     : none
OUTPUTS    : STANDARD_SELECTION - Enable automatic color recognition
		     MUTE_DISPLAY - Disable mute display
		     MUTE - Enable user mute
		     ENABLE_AFC - Disable AFC while searching
		     autosearch_state - Point the first module to start with
		     see write_video
DESCRIPTION: This function enable the autosearch process.
*****************************************************************************/

void start_autosearch(void)
{
    tuning_flags = tuning_flags | AUTOSEARCH_REQUEST;

				band_number = 0;

	  write_video_ram_data(STANDARD_SELECTION, 0x18);
  
    display_request_flags = display_request_flags & ~MUTE_DISPLAY;
    tuning_flags = tuning_flags & ~ENABLE_AFC;  
    mute_audio();
}




/*****************************************************************************
INPUTS     : 
OUTPUTS    : 
		  MUTE - Disable user mute
	     see write_video
DESCRIPTION: If an autosearch procedure is on going, then stop it.
*****************************************************************************/
void stop_autosearch(void)
{
    if (tuning_flags & AUTOSEARCH_REQUEST)
    {
        /* Reset autosearch flag */
   	  command_flags = command_flags | AUTO_SEARCH_DIRECTION;
      tuning_flags &= ~(AUTOSEARCH_REQUEST|AUTOPROG_REQUEST);
	  display_request_flags = display_request_flags & ~MUTE_DISPLAY;

      fine_tune = 31;
      tuning_flags = tuning_flags | ENABLE_AFC;  

      unmute_audio();
    }
}


/*****************************************************************************
INPUTS     : VS increment value (fast, slow...)
OUTPUTS    : ST9 Voltage Synthesis registers
	     autosearch_state - next autosearch process
	     see next_band
DESCRIPTION: This function increments the Voltage Synthesis register. If the
	     whole band has been scanned, then set the next band.
*****************************************************************************/
void increment_VS(unsigned char step_value)
{
    spp (VS_PG);
    if (VS_R >= (VS_MAXIMUM + step_value))
    {
        VS_R = VS_R - step_value;
    }
    else
    {
        VS_R = VS_MINIMUM;
        next_band();

    }
}

/*****************************************************************************
INPUTS     : VS decrement value (fast, slow...)
OUTPUTS    : ST9 Voltage Synthesis registers
	     autosearch_state - next autosearch process
	     see previous_band
DESCRIPTION: This function decrements the Voltage Synthesis register. If the
	     whole band has been scanned, then set the previous band.
*****************************************************************************/
void decrement_VS(unsigned char step_value)
{
    spp (VS_PG);
    if (VS_R <= (VS_MINIMUM - step_value))
    {
        VS_R = VS_R + step_value;
    }
    else
    {
      VS_R = VS_MAXIMUM;
      previous_band();
	 }
}

/*****************************************************************************
INPUTS     : ST9 IO registers
OUTPUTS    : ST9 IO registers 
	     see set_band
DESCRIPTION: This function selects the next band (VHF_L, VHF_H and UHF).
*****************************************************************************/
void next_band(void)
{
    unsigned char i;        

    i = P3DR & BAND_MASK;
    if(i==BAND_VL) i= VHF_H;
	 else
		{
			if(i==BAND_VH) i = UHF;
			else 
				{
				 i= VHF_L;
				}
		}
	set_band(i);

    if (tuning_flags & AUTOSEARCH_REQUEST)
	  {	

	    if (tuning_flags & AUTOPROG_REQUEST)
		  {	
			    i = P3DR & BAND_MASK;            //FEMAN :DEBUG REMOVE OPTION

			   if(i == BAND_VL)  //FEMAN :VHF_H -> BAND_VL
				         stop_autoprog();//feman add
		  }
		 else
		  {

			  if(band_number < 3)
				band_number++;
				
			  else
	 			{
					band_number = 0;
					stop_autosearch();
				}	
		  }
	  }

}

/*****************************************************************************
INPUTS     : ST9 IO registers
OUTPUTS    : ST9 IO registers
	     see set_band
DESCRIPTION: This function selects the previous band (VHF1, VHF3 and UHF).
*****************************************************************************/
void previous_band(void)
{
    unsigned char i;                                                /* Temporary storage */

    i = P3DR & BAND_MASK;
    if(i==BAND_VL) i= UHF;
	 else
		{
			if(i==BAND_VH) i = VHF_L;
			else 
				{
					i=VHF_H;
				}
		}
	set_band(i);

}


/*****************************************************************************
INPUTS     : none
OUTPUTS    : AUTOPROG_REQUEST - Set to enable autosearch
             STANDARD_SELECTION - Enable automatic color recognition
             MUTE_DISPLAY - Disable mute display
             MUTE - Enable user mute
             ENABLE_AFC - Disable AFC while searching
             autosearch_state - Point the first module to start with
             see write_video
DESCRIPTION: This function enable the auto program process.
*****************************************************************************/

void start_autoprog(void)
{

    /* Set autosearch flag */
    tuning_flags |= (AUTOPROG_REQUEST | AUTOSEARCH_REQUEST);
    /* init channel no */
    channel = 1;
    /* Set automatic color recognition while searching and disable
    AFC while searching */
    write_video_ram_data(STANDARD_SELECTION, 0x18);


    tuning_flags = tuning_flags & ~ENABLE_AFC;

    /* Disable user mute flag and mute audio while searching */
    display_request_flags = display_request_flags & ~MUTE_DISPLAY;
    mute_audio();

    set_band(VHF_L);  //FEMAN : VHF_H -> VHF_L

    /* Initialize VS in any cases */
    spp (VS_PG);
    VS_R = VS_MINIMUM;

}
/*****************************************************************************
INPUTS     : AUTOPROG_REQUEST - Set if autoporg on going
OUTPUTS    : AUTOPROG_REQUEST - Reset to disable autoprog
             MUTE - Disable user mute
             see write_video
DESCRIPTION: If an autoprog procedure is on going, then stop it.
*****************************************************************************/

void stop_autoprog(void)
{
unsigned char tmp;
	 	/* Reset autoprog flag */
   	tuning_flags &= ~(AUTOPROG_REQUEST | AUTOSEARCH_REQUEST);

for(tmp=channel;tmp<=CHANNEL_NUMBER;tmp++)
    {
    store_skip_nonecolor_label_info(tmp);    
    }
    	/* select the first channel, no matter found or not found */
    channel = 1;

//		enable_menu_mode();
//		menu_item = ITEM_ORGANIZE;
//		next_menu();
//		show_menu();

 	select_channel();
	
}


/********************************************************************************/

void update_autosearch(void)
{
    unsigned char i;                                                        

    if (tuning_flags & AUTOSEARCH_REQUEST)
    {

        display_request_flags = display_request_flags & ~(STATUS_DISPLAY|PROGRAM_DISPLAY);
        display_request_flags = display_request_flags | REFRESH_DISPLAY;

			set_pos_neg_modulation();

			read_video_new();
			i = read_data[0] & 0x0C;/* STV2238 Version2.1 */
			if (i == 0x0C) /* STV2238 Version2.1 */
			{
				if (first_autosearch ==1 )
				{
						if(command_flags & AUTO_SEARCH_DIRECTION)
						{
							increment_VS(COARSE_STEP);
						}
						else
						{
							decrement_VS(COARSE_STEP) ;
						}
					return ;
				}
				else
				{
	  
					read_video_new();
					i = read_data[2] & 0x07;
					switch (i)
					{
						case 3 : /* fo -fpll <-300 Khz */
							
							increment_VS ( MEDIUM_STEP) ;

							break ;

						case 2 : /* fo -fpll between -300 Khz to -60 Khz*/
							
							increment_VS ( SLOW_STEP) ;
							break ;
	
	 						case 0 : /* fo -fpll between -60 to +60 Khz */
								fine_tune = 31 ;
       		                    store_program_info(channel);
							    init_label();
							    store_nicam_info(channel);	
							    store_autocolor_sound();	

							  if((tuning_flags & AUTOPROG_REQUEST) && (tuning_flags & AUTOSEARCH_REQUEST))
								{
           		                tuning_flags = tuning_flags & ~ENABLE_AFC;
								first_autosearch =1 ;
            		            channel++;
                  		        if ( channel > CHANNEL_NUMBER )
                        	        stop_autoprog();
								}
							  else
								{
									write_video_ram_data(AM_FM_SELECTION, 0x00);
									set_audio_standard();
									stop_autosearch() ;
								}
							  break ;
								                                                      

						case 4 : /* fo -fpll between 60  Khz to 300 Khz */
							
							decrement_VS ( SLOW_STEP) ;
							break ;

						case 5 : /* fo -fpll > 300 Khz */
							
							decrement_VS ( MEDIUM_STEP) ;
							break ;
					}
				}
			}
		 	
			else
			{
				first_autosearch = 0 ;
				i = P3DR & BAND_MASK ; //FEMAN P4DR -> P3DR
				if (i == BAND_U )  //FEMAN 3-> BAND_U
            	    i = FAST_STEP_UHF;
				else            
					i = FAST_STEP_VHF;

				if(command_flags & AUTO_SEARCH_DIRECTION)
				{
					increment_VS(i) ;
				}
				else
				{
					decrement_VS(i) ;
				}
			}
	 
	 }
}		

/********************************************************************************/
void set_pos_neg_modulation(void)
{
	     millisecond_delay(25);
		  write_video_ram_data(LL_SELECTION,0x00 );
		  write_video_ram_data(NEG_POS_MOD, 0x00);
} 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -