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

📄 snimdriv.c

📁 ST5100 driver files for ST chipset
💻 C
📖 第 1 页 / 共 5 页
字号:
					Snim_NewDemodState(hSnim,SNIM_DEMODFSM_SCANNEW);
				}

				break;

			case SNIM_DEMODFSM_SCANFOUND:
				/*TODO fix hereChannel found - Get the Frequency and symbol rate*/
				lBuffer =Snim_GetFrequencyOffset(hSnim);
				hSnim->Channel.kRs=Snim_GetSymbolRate(hSnim);

				hSnim->Channel.MHz =(Uint16T)(hSnim->Channel.MHz+(lBuffer +((lBuffer>0)?500:-500)) /1000);
				hSnim->ScanStatus|=SNIM_SCANSTAT_FOUND;
				Snim_NewDemodState(hSnim,SNIM_DEMODFSM_SCANSTOP);
				printSnimDrv(("@@@ SNIM_DEMODFSM_SCANFOUND : SNIM_DEMODFSM_SCANSTOP @@@\n"));
				SNIM_ADD_EVENT_FLAG(SNIM_EVENT_FOUND);
				bRepeat=FALSE;
				printSnimDrv(("############################################################\n"));
				printSnimDrv(("[Snim_DemodMain] @@@ Snim_DemodMain(): SNIM_DEMODFSM_SCANFOUND @@@\n"));
				printSnimDrv(("[Snim_DemodMain] hSnim->Channel.kRs : %d \n",hSnim->Channel.kRs));
				printSnimDrv(("[Snim_DemodMain] hSnim->Channel.MHz : %d \n",hSnim->Channel.MHz));
				printSnimDrv(("[Snim_DemodMain] hSnim->ScanStatus : %d \n",hSnim->ScanStatus));
				printSnimDrv(("############################################################\n"));
				break;
			case SNIM_DEMODFSM_SCANSTOP:
				/* wait for command to move on */
				if (hSnim->DemodFsmCommand== SNIM_FSMCOMMAND_PROCEED)
				{
					printSnimDrv(("[Snim_DemodMain] SNIM_FSMCOMMAND_PROCEED >>  SNIM_DEMODFSM_SCANNEW @@@\n"));
					Snim_NewDemodState(hSnim,SNIM_DEMODFSM_SCANNEW);
				}
				break;


			default:  
				Snim_NewDemodState(hSnim,SNIM_DEMODFSM_IDLE);
		}
		hSnim->DemodFsmCommand = SNIM_FSMCOMMAND_NULL;
		if (hSnim->dwEvents & SNIM_ERROR_MASKALL) bRepeat=FALSE;
	}while ((hSnim->DemodFsmState!=entryState) && bRepeat);
	//printSnimDrv((">>>>>> Snim_DemodMain Start --\n"));
}



#if defined (_INCLUDE_DISEQC)
#include "CmpOpt.h"
/***************************************************************************************************************************\
*                                                                                                                           *
*                                              DISEQC EXPORTED FUNCTIONS                                                    *
*                                                                                                                           *
\***************************************************************************************************************************/

/************************Zarlink Semiconductor*********************************
*   Name:SnimSetDiSEqCMode()
*   Purpose:Set a Diseqc mode .
*   Remarks:
*   Inputs:
*
*   Outputs:FALSE if message mode set failed
*			TRUE message mode set successfully
*
********************************************************************************/
BOOL  SnimSetDiSEqCPolarisation(HANDLE hSnim, Sint32T iVerHor)
{
	Uint8T count,buffer;
	BOOL status;
	int timeout = 10;

	ENTER_SNIM_CONTENTION_LOCK;

	status = TRUE;

	while( (PSSNIM->DiSEqCFsmState != SNIM_DISEQCFSM_IDLE) && (timeout) )
	{/* system is busy */
		timeout--;
		FE_Wait(20);
		if (PSSNIM->DiSEqCFsmState == SNIM_DISEQCFSM_IDLE) 
		{/* system is also busy */
			status = TRUE; 
			break;
		}
		status = FALSE; 
	}

	if (!Snim_RegisterRead(hSnim,SNIM_DISEQC_MODE,&buffer,1))
	{/* failed to read the Diseqc Register*/
		status = FALSE;
	}


	if (status) 
	{ /* write Hor to the Diseqc Register*/
		buffer  &= 0xBF;
		buffer  |= iVerHor;//0x40: Hor, 0x00:Ver
		if (!Snim_RegisterWrite(hSnim,SNIM_DISEQC_MODE,&buffer,1))
		{/* failed to write to Diseqc Register*/
			status = FALSE;
		}
		else 
		{
			//SNIM_DISEQCFSM_NEWSTATE(SNIM_DISEQCFSM_START); /* start the FSM going */
		}

	}

	EXIT_SNIM_CONTENTION_LOCK;
	return status;
}
/************************Zarlink Semiconductor*********************************
*   Name:SnimSetDiSEqCMode()
*   Purpose:Set a Diseqc mode .
*   Remarks:
*   Inputs:
*
*   Outputs:FALSE if message mode set failed
*			TRUE message mode set successfully
*
********************************************************************************/
BOOL  SnimSetDiSEqCMode(HANDLE hSnim, Sint32T iMode)
{
	Uint8T count,buffer;
	BOOL status;
	int timeout = 10;

	ENTER_SNIM_CONTENTION_LOCK;

	status = TRUE;
	//SSS_DBG(OS,_INFO_,("SnimSetDiSEqCMode():: iMode[%d]\n",iMode));

	while( (PSSNIM->DiSEqCFsmState != SNIM_DISEQCFSM_IDLE) && (timeout) )
	{/* system is busy */
		timeout--;
		FE_Wait(20);
		//SSS_DBG(OS,_INFO_,("SnimSetDiSEqCMode():: wait PSSNIM->DiSEqCFsmState[%d]\n",PSSNIM->DiSEqCFsmState));
		if (PSSNIM->DiSEqCFsmState == SNIM_DISEQCFSM_IDLE) 
		{/* system is also busy */
			status = TRUE; 
			break;
		}
		status = FALSE; 
	}
	FE_Wait(50); //   20060911

	//SSS_DBG(OS,_INFO_,("SnimSetDiSEqCMode():: check status[%d]\n",status));

	if (!((iMode>=SNIM_DISEQC_MODE_LOBAND)&&(iMode<SNIM_DISEQC_MODE_TONEMASK)))
	{/* failed to check input mode value */
		status = FALSE;
	}

	//SSS_DBG(OS,_INFO_,("SnimSetDiSEqCMode():: Read Register status[%d]\n",status));

	if (!Snim_RegisterRead(hSnim,SNIM_DISEQC_MODE,&buffer,1))
	{/* failed to read the Diseqc Register*/
		status = FALSE;
	}

	//SSS_DBG(OS,_INFO_,("SnimSetDiSEqCMode():: Set Mode status[%d]\n",status));

	if (status) 
	{ /* write byte count to the Diseqc Register*/
		
		buffer  &= 0xF8;
		buffer  |= (iMode&SNIM_DISEQC_MODE_TONEMASK);//DISEQC COMMAND MODE //start transmission		
		if (!Snim_RegisterWrite(hSnim,SNIM_DISEQC_MODE,&buffer,1))
		{/* failed to write to Diseqc Register*/
			status = FALSE;
		}
		else 
		{
			//SNIM_DISEQCFSM_NEWSTATE(SNIM_DISEQCFSM_START); /* start the FSM going */
		}

	}
	EXIT_SNIM_CONTENTION_LOCK;
	return status;
}
/************************Zarlink Semiconductor*********************************
*   Name:SnimGetDiSEqCMode()
*   Purpose:Get a Diseqc mode .
*   Remarks:
*   Inputs:
*
*   Outputs:FALSE if message mode set failed
*			TRUE message mode set successfully
*
********************************************************************************/
Sint32T  SnimGetDiSEqCMode(HANDLE hSnim)
{
	Uint8T count;
	Uint8T buffer;
	BOOL status = TRUE;

	ENTER_SNIM_CONTENTION_LOCK;

	status = TRUE;

	if (!Snim_RegisterRead(hSnim,SNIM_DISEQC_MODE,&buffer,1))
	{/* failed to read the Diseqc Register*/
		status = FALSE;
	}

	if (status) 
	{ /* Read mode byte from the Diseqc Register*/
		buffer  &= SNIM_DISEQC_MODE_TONEMASK;
		EXIT_SNIM_CONTENTION_LOCK;
		return buffer;
	}
	else
	{
		EXIT_SNIM_CONTENTION_LOCK;
		return SNIM_DISEQC_MODE_TONEMASK;
	}
}
/************************Zarlink Semiconductor*********************************
*   Name:SnimReadDiSEqC()
*   Purpose:Recovers a Diseqc message from the Diseqc Receiver
*   Remarks:
*   Inputs:
*
*   Outputs:FALSE if message not ready/receive fault/overflow
*			TRUE message recovered (may still contain parity errors)
*
********************************************************************************/
BOOL  SnimReadDiSEqC(HANDLE hSnim, SSnimDiSEqCMessage * psMessage)
{
	Uint8T count,buffer[2];
	BOOL status;

	ENTER_SNIM_CONTENTION_LOCK;

	status = TRUE;
	if (!Snim_CheckPointers(PSSNIM) || psMessage==NULL)
	{
		status = FALSE;
	}
	else if (PSSNIM->DiSEqC2Int & 0x04)
	{/* fault in system */
		status = FALSE;
	}
	else
	{ /* read in the message */
		psMessage->parity=0;
		psMessage->count= (Uint8T)(PSSNIM->DiSEqC2Int >> 4);

		if (psMessage->count >8)
		{/*a receiver overflow has occured */
			psMessage->count=8;
			status = FALSE;
		}

		/* now get the body of the message */		
		for (count=0;(count<(psMessage->count));count++)
		{
			/*read the data and parity in two separate swipes*/
			if (!Snim_RegisterRead(hSnim,SNIM_DISEQC2_FIFO,&buffer[0],1)) 
			{
				status = FALSE;
				break;
			}
			else if (!Snim_RegisterRead(hSnim,SNIM_DISEQC2_FIFO,&buffer[1],1))
			{
				status = FALSE;
				break;
			}
			else
			{/* read both bytes ok */
				psMessage->data[count] = buffer[0]; /*data*/
				if (buffer[1] & 0x02) psMessage->parity |= (0x01<<count);/* parity*/
			}

		}
	}
	EXIT_SNIM_CONTENTION_LOCK;
	return status;

}
/************************Zarlink Semiconductor*********************************
*   Name:SnimSendDiSEqC()
*   Purpose:Sends a diseqc message.
*   Remarks:
*   Inputs:pointer to a message
*
*   Outputs:
*
********************************************************************************/

BOOL  SnimSendDiSEqC(HANDLE hSnim, SSnimDiSEqCMessage * psMessage)
{
    Uint8T buffer;
	BOOL ret;

	ENTER_SNIM_CONTENTION_LOCK;
	ret=TRUE;
    if (!Snim_CheckPointers(PSSNIM)) 
	{
		ret= FALSE;
	}
	else if (psMessage->count==0 || psMessage->count>8 )
	{
		ret = FALSE;
	}
	else if (PSSNIM->DiSEqCFsmState) 
	{/* system is busy */
		ret = FALSE; 
	}
	else if (!Snim_RegisterWrite(hSnim,SNIM_DISEQC_INSTR,psMessage->data, psMessage->count))
	{/* failed to write message */
		ret = FALSE;
	}
	else if (!Snim_RegisterRead(hSnim,SNIM_DISEQC_MODE,&buffer,1))
	{/* failed to read the Diseqc Register*/
		ret = FALSE;
	}
	else
	{ /* write byte count to the Diseqc Register*/
		buffer  &= 0xC7;
		buffer |= (psMessage->count-1)<<3;// minus 1
		if (!Snim_RegisterWrite(hSnim,SNIM_DISEQC_MODE,&buffer,1))
		{/* failed to write to Diseqc Register*/
			ret = FALSE;
		}
		else 
		{
			
            if (psMessage->count>0 && (psMessage->data[0] & 0x02) && 0== PSSNIM->NoDiSEqC2Input)
            { 
               PSSNIM->DiSEqCReplyExpected=1;
            }
			else
            {
				PSSNIM->DiSEqCReplyExpected=0;
            }
			/*set time to wait for tx complete = 16 * message.count*9*1.5 +16 msec + safety margin*/
			PSSNIM->DiSEqCTimeout = (Uint16T) (110 + 14*psMessage->count);
			//SNIM_DISEQCFSM_NEWSTATE(SNIM_DISEQCFSM_START); /* start the FSM going */// blocked by   20060911
		}

	}
	EXIT_SNIM_CONTENTION_LOCK;
	return ret;
    
}

/************************Zarlink Semiconductor*********************************
*   Name:Snim_GetDemodState()
*   Purpose:determines state of demodulator
*   Remarks: 
*   Inputs:
*
*   Outputs:
*
********************************************************************************/

ESnimDiSEqCState SnimGetDiSEqCState(PSSNIMCTL hSnim)
{
	ESnimDiSEqCState sReturn = SNIM_DISEQC_STATE_ERROR;
    switch (hSnim->DiSEqCFsmState)
    {
    case SNIM_DISEQCFSM_IDLE:             
            sReturn = SNIM_DISEQC_STATE_IDLE;
            break;
    case SNIM_DISEQCFSM_START:         
            sReturn = SNIM_DISE

⌨️ 快捷键说明

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