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

📄 gx1101.c

📁 做STB的朋友接好了,国芯调协器软件包说明介绍.
💻 C
📖 第 1 页 / 共 4 页
字号:
	gx1101_Open_FD(TRUE);
	buffer[0] = 0x72;
	gx1101_Write_Registers(0x66, buffer, 1, FALSE);
	Baud = 45000; 
    	ChannelCount = 0;  
    	s32Process= 0;
	ScanTpProcessBar( (unsigned int)(s32Process));
	u8Step = 49;
	for(pol =0;pol<2;pol++)
	{ 
		bNeedFind[0] = 1;
		if(pol ==0)
		{
	      		gx1101_Set_Polar(POL_HORIZONTAL);
    			lnb_params.enPolar = POL_HORIZONTAL;
	       	ReChannel.lnb =  POL_HORIZONTAL;
			u8ProgressStart = 1;
		}
	 	else
	 	{
	       	gx1101_Set_Polar(POL_VERTICAL);
    			lnb_params.enPolar = POL_VERTICAL;
	       	ReChannel.lnb =  POL_VERTICAL;  
			u8ProgressStart = 50;
	     	}
		local_frequency = (u16)(Local_Frequency);//MHz
		if(speed == 1)
		{
			khz_new_scan_step   = (u32)KHZ_SCAN_STEP_QUICK; 
			KHz_tuner_freq_max  = (u32)TUNER_FREQ_HIGH_LIM_KHZ_QUICK;
			KHz_tuner_freq_min  = (u32)TUNER_FREQ_LOW_LIM_KHZ_QUICK;
			
		}
		else
		{
			khz_new_scan_step   = (u32)KHZ_SCAN_STEP_DETAIL;   
			KHz_tuner_freq_max  = (u32)TUNER_FREQ_HIGH_LIM_KHZ_DETAIL;
			KHz_tuner_freq_min  = (u32)TUNER_FREQ_LOW_LIM_KHZ_DETAIL;
		}
		KHz_tuner_freq = KHz_tuner_freq_max;
    		scan_complete = FALSE;
		while(scan_complete == FALSE)
		{
			 ReChannel.baud = 40000;
			lnb_params.KHz_tuner_freq = KHz_tuner_freq+500;
			status = gx1101_Frontend(lnb_params);
		#if SUPER_SEARCH
			if(status != GX1101_LOCK)
			{
				if((KHz_tuner_freq <= 1677000L) && (bNeedFind[0]  == 1))
				{//当频率接近1677MHz时,用非盲扫直接单个搜来代替盲扫	
					gx1101_super_search(1677000L,8000,local_frequency,ReChannel);
					bNeedFind[0] = 0;
				}
			}
		#endif
			if ((status == GX1101_LOCK) || (status == GX1101_NO_FEC_LOCK))
			{
				lnb_params.KHz_tuner_freq = (lnb_params.KHz_tuner_freq/1000)*1000;
				gx1101_Get_Channel_Status(lnb_params.KHz_tuner_freq,&channel_params);

				if(status == GX1101_NO_FEC_LOCK)
				{
					gx1101_Set_Blind_Enable(GX1101_SET_BLIND_DISABLE);
					
					if(gx1101_Try_Find_FEC_OK(&channel_params) == FALSE)
					{	
						KHz_tuner_freq = KHz_tuner_freq - khz_new_scan_step;
						gx1101_Set_Blind_Enable(GX1101_SET_BLIND_ENABLE);
					
						gx1101_Open_FD(TRUE);
						s32Process = (KHz_tuner_freq_max - KHz_tuner_freq)*u8Step/(KHz_tuner_freq_max-KHz_tuner_freq_min);
						s32Process+=u8ProgressStart;
						if ( s32Process> (u8ProgressStart+u8Step) )
						{
							s32Process=u8ProgressStart+u8Step;
						}
						if ( s32Process<(s32)u8ProgressStart )
						{
							s32Process=u8ProgressStart;
						}
						ScanTpProcessBar( (unsigned int)(s32Process));
						continue;
					}
					else
					{
						gx1101_Set_Blind_Enable(GX1101_SET_BLIND_ENABLE);
						gx1101_Open_FD(TRUE);
					
					}
				}
				ReChannel.benzhen = (unsigned int)local_frequency;
    				ReChannel.baud = (unsigned int)channel_params.KBd_rate;
				if_frequency = (u16)((channel_params.KHz_center_freq+500)/1000);
				ReChannel.Fre = (unsigned int)if_frequency;
			#ifdef SUPER_SEARCH
				if(check_gx1101_tpItem(ReChannel.Fre,ReChannel.baud) == FALSE)
			#endif
				{
					result[ChannelCount] = ReChannel;//save transponder's parameter
					ChannelCount++;
				}
				/*set next freq*/
				if(channel_params.KBd_rate < 4000L)
				{
					u32Offset = 24000L;
				}
				else
				{
					u32Offset = 21000L;
				}
				KHz_tuner_freq = channel_params.KHz_center_freq - (u32)((channel_params.KBd_rate)*27)/40 - u32Offset;
			}
			else if (status == GX1101_NO_LOCK) 
			{ 
				KHz_tuner_freq = KHz_tuner_freq - khz_new_scan_step;
			}
			else
			{
				return;
			}

			if ( (KHz_tuner_freq < (KHz_tuner_freq_min - 1000)) || (KHz_tuner_freq > (KHz_tuner_freq_max + 1000)) )
			{
				scan_complete = TRUE;
				break;
			}
		
	    		s32Process = (KHz_tuner_freq_max - KHz_tuner_freq)*u8Step/(KHz_tuner_freq_max-KHz_tuner_freq_min);
			s32Process+=u8ProgressStart;
			if ( s32Process> (u8ProgressStart+u8Step) )
			{
				s32Process=u8ProgressStart+u8Step;
			}
			if ( s32Process<(s32)u8ProgressStart )
			{
				s32Process=u8ProgressStart;
			}
		
			ScanTpProcessBar( (unsigned int)(s32Process));
		}
    	}
	gx1101_Set_Blind_Enable(GX1101_SET_BLIND_DISABLE);
}

/*******************************************************************************************/
#else
#ifdef USER_DEFINE
DVB_TPInfo stScantpItem;
bool8 gx1101_super_search(u32 u32KHz_tuner_freq,u32 u32KBd_rate,
							GX1101_LNB_PARAMS	*pstLNB_params,
							DVB_AutoScanParameter *pstAutoScanParameter)
{
	u16		if_frequency;		
 	u16		local_frequency;
	u8		buffer[2];
	GX1101_LNB_PARAMS		lnb_params;	

	local_frequency		= pstAutoScanParameter->u16LocalFrequency;
	gx1101_Set_Blind_Enable(GX1101_SET_BLIND_DISABLE);
	lnb_params.KHz_tuner_freq = u32KHz_tuner_freq;
	lnb_params.KBd_rate = u32KBd_rate;
	//pstLNB_params->KHz_tuner_freq = lnb_params.KHz_tuner_freq;
	Baud = lnb_params.KBd_rate;
	if(gx1101_Set_Program(&lnb_params) == TRUE)
	{//如果TP能锁定,则保存TP
		memset(&stScantpItem,0,sizeof(DVB_TPInfo));    		
    		if_frequency = (u16)((lnb_params.KHz_tuner_freq+500)/1000);
    		if(local_frequency < 7000)
    		{
       	 	if(local_frequency > if_frequency)
       	 		stScantpItem.u16TPFrequency = local_frequency - if_frequency;
       	 	else
       	 		stScantpItem.u16TPFrequency = local_frequency + if_frequency;
    		}
		else
    		{
    			stScantpItem.u16TPFrequency = local_frequency + if_frequency;
    		}
    		stScantpItem.u16LocalFrequency = (u16)local_frequency;
		stScantpItem.u16SymbolRate = (u16)lnb_params.KBd_rate;
		if ( pstLNB_params->enPolar==POL_HORIZONTAL )
    			stScantpItem.b8Polar_H = TRUE;
		else
    			stScantpItem.b8Polar_H = FALSE;
	    	stScantpItem.b8Tone22K = pstLNB_params->enTone;
	    	stScantpItem.u8DiSEqC= pstAutoScanParameter->u8DiSEqC;
		stScantpItem.b8Control12V=pstAutoScanParameter->b8Control12V;
			
		printf("\n**************super search*******************");
		printf("\n>> Frequency = %ld",(unsigned long)stScantpItem.u16TPFrequency);
		printf("\n>> SymbolRate = %ld\n",(unsigned long)stScantpItem.u16SymbolRate);
		gx1101_Set_Program(&lnb_params);
		if(check_gx1101_tpItem(stScantpItem.u16TPFrequency,stScantpItem.u16SymbolRate) == FALSE)
		{//如果检测到TP参数相同,则不保存当前TP
			if(CHECK_GOT_KEY) return FALSE;		
			if(ScanLocked_Callback (&stScantpItem)==FALSE)
				return FALSE;
		}
	}
	else
	{	
		printf("super search failed\n");
	}

	buffer[0] = 0x72;
	gx1101_Write_Registers(0x66, buffer, 1, FALSE);
	buffer[0] = 0;
	buffer[1] = 0;
   	if(gx1101_Write_Registers(GX1101_ERR1_L, buffer, 2, FALSE) != GX1101_NO_ERROR )
		return FALSE;
	if( gx1101_Set_Blind_Enable(GX1101_SET_BLIND_ENABLE) != GX1101_NO_ERROR)
		return FALSE;
	if(gx1101_Open_FD(TRUE) != GX1101_NO_ERROR)
		return FALSE;
	Baud = 45000;
	return TRUE;
}
/*******************************************************************************************
Function    : Frontend_ScanCarry()
Description	: Search all of the transponder
Input       : auto scan parameter
Return      : SUCCESS           : TRUE 
              FAIL              : FALSE
*******************************************************************************************/
bool8 Frontend_ScanCarry(GX1101_LNB_PARAMS	*pstLNB_params,
							   DVB_AutoScanParameter *pstAutoScanParameter
							   , u8 u8ProgressStart, u8 u8Step)
{
	u16		if_frequency;		
	u16		local_frequency;
	u32		KHz_tuner_freq_min;
	u32		KHz_tuner_freq_max;	
	u32		KHz_tuner_freq, khz_new_scan_step;
	GX1101_STATUS			status;
	bool8					scan_complete;
	s32						s32Process;
	GX1101_CHANNEL_PARAMS	channel_params;
	GX1101_LNB_PARAMS		lnb_params;	
	u8						buffer[2];
	u32						u32Offset;
	bool8	bNeedFind[NEEDFIND_NUM]={1,1,1,1};


	s32Process= 0;
	local_frequency		  = pstAutoScanParameter->u16LocalFrequency;
	channel_params.lnb_polar = pstLNB_params->enPolar;

	if(pstAutoScanParameter->b8QuickSearch == 1)
	{
		khz_new_scan_step   = (u32)KHZ_SCAN_STEP_QUICK; 
		KHz_tuner_freq_max  = (u32)TUNER_FREQ_HIGH_LIM_KHZ_QUICK;	
	}
	else
	{
		khz_new_scan_step   = (u32)KHZ_SCAN_STEP_DETAIL;   
		KHz_tuner_freq_max  = (u32)TUNER_FREQ_HIGH_LIM_KHZ_DETAIL;	
	}
	KHz_tuner_freq_min  = (u32)TUNER_FREQ_LOW_LIM_KHZ_DETAIL;

	KHz_tuner_freq = KHz_tuner_freq_max;			
     
    scan_complete = FALSE;
	while (scan_complete == FALSE)
	{
	#if USER_DEFINE
		if(CHECK_GOT_KEY) return FALSE;
	#endif
		pstLNB_params->KHz_tuner_freq = KHz_tuner_freq+500;
		status = gx1101_Frontend(*pstLNB_params);
	#ifdef SUPER_SEARCH
		if(status != GX1101_LOCK)
		{
			if((KHz_tuner_freq <= 1677000L) && (bNeedFind[0]  == 1))
			{
				gx1101_super_search(1677000L,8000,pstLNB_params,pstAutoScanParameter);
				bNeedFind[0]  = 0;
			}
		}
	#endif
	#if USER_DEFINE
		if(CHECK_GOT_KEY) return FALSE;
	#endif
		if ((status == GX1101_LOCK) || (status == GX1101_NO_FEC_LOCK))
		{
			pstLNB_params->KHz_tuner_freq = (pstLNB_params->KHz_tuner_freq/1000)*1000;
			gx1101_Get_Channel_Status(pstLNB_params->KHz_tuner_freq,&channel_params);

			if(status == GX1101_NO_FEC_LOCK)
			{
					gx1101_Set_Blind_Enable(GX1101_SET_BLIND_DISABLE);
					
					if(gx1101_Try_Find_FEC_OK(&channel_params) == FALSE)
					{	
						KHz_tuner_freq = KHz_tuner_freq - khz_new_scan_step;
						gx1101_Set_Blind_Enable(GX1101_SET_BLIND_ENABLE);
					
						gx1101_Open_FD(TRUE);
						s32Process = (KHz_tuner_freq_max - KHz_tuner_freq)*u8Step/(KHz_tuner_freq_max-KHz_tuner_freq_min);
						s32Process+=u8ProgressStart;
						if ( s32Process> (u8ProgressStart+u8Step) )
						{
							s32Process=u8ProgressStart+u8Step;
						}
						if ( s32Process<(s32)u8ProgressStart )
						{
							s32Process=u8ProgressStart;
						}
		
						ScanTpProcessBar( (unsigned int)(s32Process));
						continue;
					}
					else
					{
						gx1101_Set_Blind_Enable(GX1101_SET_BLIND_ENABLE);
						gx1101_Open_FD(TRUE);
					
					}
			}
			
			memset(&stScantpItem,0,sizeof(DVB_TPInfo));    		
    		if_frequency = (u16)((channel_params.KHz_center_freq+500)/1000);	
    		if(local_frequency < 7000)
    		{
        		if(local_frequency > if_frequency)
        		    stScantpItem.u16TPFrequency = local_frequency - if_frequency;
        		else
        		    stScantpItem.u16TPFrequency = local_frequency + if_frequency;
    		}
			else
    		{
    		    stScantpItem.u16TPFrequency = local_frequency + if_frequency;
    		}
    		stScantpItem.u16LocalFrequency = (u16)local_frequency;
    		stScantpItem.u16SymbolRate = (u16)channel_params.KBd_rate;
			if ( pstLNB_params->enPolar==POL_HORIZONTAL )
    			stScantpItem.b8Polar_H = TRUE;
			else
    			stScantpItem.b8Polar_H = FALSE;
    		printf("\n>> Frequency = %ld",(unsigned long)stScantpItem.u16TPFrequency);
			printf("\n>> SymbolRate = %ld\n",(unsigned long)stScantpItem.u16SymbolRate);
		#if USER_DEFINE
			if( gx1101_Set_Blind_Enable(GX1101_SET_BLIND_DISABLE) != GX1101_NO_ERROR)
				return FALSE;
			
			lnb_params.KHz_tuner_freq = channel_params.KHz_center_freq;
			lnb_params.KBd_rate = channel_params.KBd_rate;
			if(gx1101_Set_Program(&lnb_params) == FALSE)
				return FALSE;
		#ifdef SUPER_SEARCH
			if(check_gx1101_tpItem(stScantpItem.u16TPFrequency,stScantpItem.u16SymbolRate) == FALSE)
		#endif
			{//如果检测到TP参数相同,则不保存当前TP
				if(CHECK_GOT_KEY) return FALSE;		
	
				if(ScanLocked_Callback (&stScantpItem)==FALSE)
					return FALSE;
				/* lock a frequency and call the other fucntion to receive the table
				and add the transponder information and service */
				if(CHECK_GOT_KEY) return FALSE;
			}
		#endif

			/*set next freq*/
			if(channel_params.KBd_rate < 4000L)
			{
				u32Offset = 24000L;
			}
			else
			{
				u32Offset = 21000L;
			}
			KHz_tuner_freq = channel_params.KHz_center_freq - (u32)((channel_params.KBd_rate)*27)/40 - u32Offset;
		#if USER_DEFINE	
			buffer[0] = 0;
			buffer[1] = 0;
   			if(gx1101_Write_Registers(GX1101_ERR1_L, buffer, 2, FALSE) != GX1101_NO_ERROR )
				return FALSE;
			if( gx1101_Set_Blind_Enable(GX1101_SET_BLIND_ENABLE) != GX1101_NO_ERROR)
				return FALSE;
			if(gx1101_Open_FD(TRUE) != GX1101_NO_ERROR)
				return FALSE;
			Baud = 45000; 
		#endif
		
		}
		else if (status == GX1101_NO_LOCK) 
		{ 
			    KHz_tuner_freq = KHz_tuner_freq - khz_new_scan_step;
		}
		else
		{
			return FALSE;
		}

		if ( (KHz_tuner_freq < (KHz_tuner_freq_min - 1000)) || (KHz_tuner_freq > (KHz_tuner_freq_max + 1000)) )
		{
			scan_complete = TRUE;
			break;
		}
		
	#if USER_DEFINE
	    s32Process = (KHz_tuner_freq_max - KHz_tuner_freq)*u8Step/(KHz_tuner_freq_max-KHz_tuner_freq_min);
		s32Process+=u8ProgressStart;
		if ( s32Process> (u8ProgressStart+u8Step) )
		{
			s32Process=u8ProgressStart+u8Step;
		}
		if ( s32Process<(s32)u8ProgressStart )
		{
			s32Process=u8ProgressStart;
		}
		ScanProgress_Callback( (u8)(s32Process&0xFF));
	#endif
		
	}
	return TRUE;
}
/*******************************************************************************************
Function    : Frontend_Autoscan()
Description	: Frontend autoscan full	
Input       : auto scan parameter
Return      : SUCCESS           : TRUE 
              FAIL              : FALSE
*******************************************************************************************/
bool8 Frontend_Autoscan(DVB_AutoScanParameter *pstAutoScanParameter)//盲扫过程中解节目的方式
{
	GX1101_LNB_PARAMS	stLNB_params;
	u8			buffer[2];
	Baud = 40000; 
	
	if( gx1101_Set_Blind_Enable(GX1101_SET_BLIND_ENABLE) != GX1101_NO_ERROR)
		return FALSE;
	if(gx1101_Open_FD(TRUE) != GX1101_NO_ERROR)
		return FALSE;
	buffer[0] = 0x72;
	gx1101_Write_Registers(0x66, buffer, 1, FALSE);
	
    gx1101_Set_Polar(POL_HORIZONTAL);
    stLNB_params.enPolar = POL_HORIZONTAL;

	if ( Frontend_ScanCarry(&stLNB_params, pstAutoScanParameter, 1, 49)==FALSE )
		return FALSE;
		
	gx1101_Set_Polar(POL_VERTICAL);
    stLNB_params.enPolar = POL_VERTICAL;

	if ( Frontend_ScanCarry(&stLNB_params, pstAutoScanParameter, 50, 49)==FALSE )
		return FALSE;
	
	if( gx1101_Set_Blind_Enable(GX1101_SET_BLIND_DISABLE) != GX1101_NO_ERROR)
		return FALSE;
	
	return TRUE;
}
#endif
#endif
/*******************************************************************************************
Function    : gx1101_Frontend()
Description	: Change Channel
Input       : lnb_params
Return      : GX1101_STATUS code
*******************************************************************************************/
GX1101_STATUS gx1101_Frontend(GX1101_LNB_PARAMS lnb_params)
{

⌨️ 快捷键说明

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