lnbbeio.c
来自「st7710的tuner标准驱动」· C语言 代码 · 共 989 行 · 第 1/3 页
C
989 行
/* ----------------------------------------------------------------------------
Name: lnb_backendIO_SetConfig()
Description:
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t lnb_backendIO_SetConfig(LNB_Handle_t Handle, LNB_Config_t *Config)
{
ST_ErrorCode_t Error = ST_NO_ERROR;
#ifndef STTUNER_MINIDRIVER
LNB_BackEndIO_InstanceData_t *Instance;
STTUNER_InstanceDbase_t *Inst;
Instance = (LNB_BackEndIO_InstanceData_t *)Handle;
Inst = STTUNER_GetDrvInst();
/* Select LNB band */
if(Instance->Config.ToneState != Config->ToneState)
{
switch (Config->ToneState)
{
case STTUNER_LNB_TONE_OFF: /* No tone */
LNB_BackEndIO_SetLnb(Instance, 0);
break;
case STTUNER_LNB_TONE_22KHZ: /* 22KHz tone */
LNB_BackEndIO_SetLnb(Instance, 1);
break;
case STTUNER_LNB_TONE_DEFAULT: /* no change */
break;
default:
return(ST_ERROR_BAD_PARAMETER);
}
Instance->Config.ToneState = Config->ToneState;
}
/* Select polarization */
if (Instance->Config.Polarization != Config->Polarization)
{
switch (Config->Polarization)
{
case STTUNER_PLR_VERTICAL: /* OP_2 controls -- 18V (high) */
LNB_BackEndIO_SetPolarization(Instance, VERTICAL);
break;
case STTUNER_PLR_HORIZONTAL: /* OP_2 controls -- 13V (low) */
LNB_BackEndIO_SetPolarization(Instance, HORIZONTAL);
break;
case STTUNER_LNB_OFF:
LNB_BackEndIO_SetPolarization(Instance, NOPOLARIZATION);
break;
default:
return(ST_ERROR_BAD_PARAMETER);
}
Instance->Config.Polarization = Config->Polarization;
}
/* Select power status */
if (Instance->Config.Status != Config->Status)
{
switch (Config->Status)
{
case LNB_STATUS_ON:
case LNB_STATUS_OFF:
LNB_BackEndIO_SetPower(Instance, Config->Status);
break;
default:
return(ST_ERROR_BAD_PARAMETER);
}
Instance->Config.Status = Config->Status;
}
UTIL_Delay(1000);
#endif
#ifdef STTUNER_MINIDRIVER
if(LNBInstance->Config.ToneState != Config->ToneState)
{
switch (Config->ToneState)
{
case STTUNER_LNB_TONE_OFF: /* No tone */
LNB_BackEndIO_SetLnb(0);
break;
case STTUNER_LNB_TONE_22KHZ: /* 22KHz tone */
LNB_BackEndIO_SetLnb(1);
break;
case STTUNER_LNB_TONE_DEFAULT: /* no change */
break;
default:
return(ST_ERROR_BAD_PARAMETER);
}
LNBInstance->Config.ToneState = Config->ToneState;
}
/* Select polarization */
if (LNBInstance->Config.Polarization != Config->Polarization)
{
switch (Config->Polarization)
{
case STTUNER_PLR_VERTICAL: /* OP_2 controls -- 18V (high) */
LNB_BackEndIO_SetPolarization(VERTICAL);
break;
case STTUNER_PLR_HORIZONTAL: /* OP_2 controls -- 13V (low) */
LNB_BackEndIO_SetPolarization(HORIZONTAL);
break;
case STTUNER_LNB_OFF:
break;
default:
return(ST_ERROR_BAD_PARAMETER);
}
LNBInstance->Config.Polarization = Config->Polarization;
}
/* Select power status */
if (LNBInstance->Config.Status != Config->Status)
{
switch (Config->Status)
{
case LNB_STATUS_ON:
case LNB_STATUS_OFF:
LNB_BackEndIO_SetPower(Config->Status);
break;
default:
return(ST_ERROR_BAD_PARAMETER);
}
LNBInstance->Config.Status = Config->Status;
}
UTIL_Delay(1000);
#endif
return(Error);
}
#ifndef STTUNER_MINIDRIVER
/* ----------------------------------------------------------------------------
Name: lnb_backendIO_ioctl()
Description:
access device specific low-level functions
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t lnb_backendIO_ioctl(LNB_BackEndIO_InstanceData_t *Instance, U32 Function, void *InParams, void *OutParams, STTUNER_Da_Status_t *Status)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_LNB_DEMODIO
const char *identity = "STTUNER lnb_backendIO.c lnb_backendIO_ioctl()";
#endif
ST_ErrorCode_t Error;
return(Error);
}
#endif
#ifndef STTUNER_MINIDRIVER
/* ----------------------------------------------------------------------------
Name: lnb_backendIO_ioaccess()
Description:
we get called with the instance of
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t lnb_backendIO_ioaccess(LNB_BackEndIO_InstanceData_t *Instance,STTUNER_IOARCH_Operation_t Operation, U16 SubAddr, U8 *Data, U32 TransferSize, U32 Timeout)
{
ST_ErrorCode_t Error = ST_NO_ERROR;
return(Error);
}
#endif
/*----------------------------------------------------
FUNCTION LNB_BackEndIO_SetLnb
ACTION set the Lnb
PARAMS IN Lnb -> true for LnbHigh, false for LnbLow
PARAMS OUT NONE
RETURN NONE
------------------------------------------------------*/
#ifndef STTUNER_MINIDRIVER
void LNB_BackEndIO_SetLnb(LNB_BackEndIO_InstanceData_t *Instance, int Lnb)
{
#ifdef STTUNER_LNB_TONE_THRU_DEMOD_DISEQC_PIN
STTUNER_demod_instance_t *DemodInstance;
STTUNER_InstanceDbase_t *Inst;
Inst = STTUNER_GetDrvInst();
DemodInstance = &Inst[Instance->TopLevelHandle].Sat.Demod;
if(DemodInstance->Driver->ID == STTUNER_DEMOD_STX0288)
{
if (Lnb == 0) STTUNER_IOREG_SetField(DemodInstance->DeviceMap, DemodInstance->IOHandle, DemodInstance->TEN_FieldIndex, 0x1);
/* High band -> 22KHz tone */
if (Lnb == 1) STTUNER_IOREG_SetField(DemodInstance->DeviceMap, DemodInstance->IOHandle, DemodInstance->TEN_FieldIndex, 0x0);
}
else
{
if (Lnb == 0) STTUNER_IOREG_SetField(DemodInstance->DeviceMap, DemodInstance->IOHandle, DemodInstance->TEN_FieldIndex, 0x0);
/* High band -> 22KHz tone */
if (Lnb == 1) STTUNER_IOREG_SetField(DemodInstance->DeviceMap, DemodInstance->IOHandle, DemodInstance->TEN_FieldIndex, 0x3);
}
#else
/* Low band -> no 22KHz tone */
if (Lnb == 0) STPIO_Clear(Instance->LNBTEN_PIOHandle, Instance->LnbIOPort->TEN_PIOPin);
/* High band -> 22KHz tone */
if (Lnb == 1) STPIO_Set(Instance->LNBTEN_PIOHandle, Instance->LnbIOPort->TEN_PIOPin);
#endif
}
#endif
#ifndef STTUNER_MINIDRIVER
/*----------------------------------------------------
FUNCTION LNB_BackEndIO_SetPolarization
ACTION set the polarization
PARAMS IN Polarization -> Polarization
PARAMS OUT NONE
RETURN NONE
------------------------------------------------------*/
void LNB_BackEndIO_SetPolarization(LNB_BackEndIO_InstanceData_t *Instance, LNB_Polarization_t Polarization)
{
if(Polarization == VERTICAL)
{
STPIO_Set(Instance->LNBVEN_PIOHandle, Instance->LnbIOPort->VEN_PIOPin);
STPIO_Clear(Instance->LNBVSEL_PIOHandle, Instance->LnbIOPort->VSEL_PIOPin);
}
else if(Polarization == NOPOLARIZATION)
{
STPIO_Clear(Instance->LNBVEN_PIOHandle, Instance->LnbIOPort->VEN_PIOPin);
}
else
{
STPIO_Set(Instance->LNBVEN_PIOHandle, Instance->LnbIOPort->VEN_PIOPin);
STPIO_Set(Instance->LNBVSEL_PIOHandle, Instance->LnbIOPort->VSEL_PIOPin);
}
}
#endif
#ifndef STTUNER_MINIDRIVER
/*----------------------------------------------------
FUNCTION LNB_BackEndIO_GetPower
ACTION get lnb power status
PARAMS IN
PARAMS OUT
RETURN
------------------------------------------------------*/
ST_ErrorCode_t LNB_BackEndIO_GetPower(LNB_BackEndIO_InstanceData_t *Instance, LNB_Status_t *Status)
{
*Status = LNB_STATUS_ON;
return(ST_NO_ERROR);
}
#endif
#ifndef STTUNER_MINIDRIVER
/*----------------------------------------------------
FUNCTION LNB_BackEndIO_SetPower
ACTION set lnb power
PARAMS IN
PARAMS OUT
RETURN
------------------------------------------------------*/
ST_ErrorCode_t LNB_BackEndIO_SetPower(LNB_BackEndIO_InstanceData_t *Instance, LNB_Status_t Status)
{
switch(Status)
{
case LNB_STATUS_ON:
STPIO_Set(Instance->LNBVEN_PIOHandle, Instance->LnbIOPort->VEN_PIOPin);
break;
case LNB_STATUS_OFF:
STPIO_Clear(Instance->LNBVEN_PIOHandle, Instance->LnbIOPort->VEN_PIOPin);
break;
default:
return(ST_ERROR_BAD_PARAMETER);
}
return(ST_NO_ERROR);
}
#endif
/* End of lnb_backendIO.c */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?