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

📄 lnb21.c

📁 st7710的tuner标准驱动
💻 C
📖 第 1 页 / 共 5 页
字号:
    /* LNB low current threshold*/
    LNB21_SetCurrentThreshold(LNB21Instance->Config.CurrentThresholdSelection);
    
    /*LNB circuit protection mode*/
    LNB21_SetProtectionMode(LNB21Instance->Config.ShortCircuitProtectionMode);
    
    /* LNB cable loss compenation off */
    LNB21_SetLossCompensation(LNB21Instance->Config.CableLossCompensation);

    Error = LNB21_UpdateLNB();
    
    LNB21_Delay_uS(500);
    
    /*Checking whether shortcircuit has ocurred i.e. whether OLF bit is high */
    Error |= LNB21_GetStatus(&LNB21Instance->Config.Status);

    /* Check to ensure there is no problem with the LNB circuit */

    if (Error == ST_NO_ERROR)   /* last i/o (above) operation was good */
    {
        if (LNB21Instance->Config.Status == LNB_STATUS_SHORT_CIRCUIT || LNB21Instance->Config.Status == LNB_STATUS_OVER_TEMPERATURE  || LNB21Instance->Config.Status == LNB_STATUS_SHORTCIRCUIT_OVERTEMPERATURE)
        {
#ifdef STTUNER_DEBUG_MODULE_SATDRV_LNB21
            STTBX_Print(("%s fail LNB_STATUS_SHORT_CIRCUIT or LNB_STATUS_OVER_TEMPERATURE\n", identity));
#endif
            return(STTUNER_ERROR_HWFAIL);
        }
    }
    else
    {

    return(Error);
    }
  
#endif
    return(Error);
}   



/* ----------------------------------------------------------------------------
Name: lnb_lnb21_Close()

Description:
    
Parameters:
    
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t lnb_lnb21_Close(LNB_Handle_t Handle, LNB_CloseParams_t *CloseParams)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_LNB21
   const char *identity = "STTUNER lnb21.c lnb_lnb21_Close()";
#endif
    ST_ErrorCode_t Error = ST_NO_ERROR;
    
    #ifndef STTUNER_MINIDRIVER
    LNB21_InstanceData_t     *Instance;

    Instance = (LNB21_InstanceData_t *)Handle;

    if(Installed == FALSE)
    {
#ifdef STTUNER_DEBUG_MODULE_SATDRV_LNB21
        STTBX_Print(("%s fail driver not installed\n", identity));
#endif
        return(STTUNER_ERROR_INITSTATE);
    }

    SEM_LOCK(Lock_InitTermOpenClose);

    /* ---------- check that at least one init has taken place ---------- */
    if(InstanceChainTop == NULL)
    {
#ifdef STTUNER_DEBUG_MODULE_SATDRV_LNB21
        STTBX_Print(("%s fail nothing initalized\n", identity));
#endif
        SEM_UNLOCK(Lock_InitTermOpenClose);
        return(STTUNER_ERROR_INITSTATE);
    }

    if(Instance->TopLevelHandle == STTUNER_MAX_HANDLES)
    {
#ifdef STTUNER_DEBUG_MODULE_SATDRV_LNB21
        STTBX_Print(("%s fail driver instance not open\n", identity));
#endif
        SEM_UNLOCK(Lock_InitTermOpenClose);
        return(ST_ERROR_OPEN_HANDLE);
    }

    Instance->TopLevelHandle = STTUNER_MAX_HANDLES;

#ifdef STTUNER_DEBUG_MODULE_SATDRV_LNB21
    STTBX_Print(("%s closed\n", identity));
#endif

    SEM_UNLOCK(Lock_InitTermOpenClose);
    
    #endif
    
#ifdef STTUNER_MINIDRIVER
LNB21Instance->TopLevelHandle = STTUNER_MAX_HANDLES;
#endif
    
    return(Error);
}   

#ifndef STTUNER_MINIDRIVER


#if defined(STTUNER_DRV_SAT_LNB21)
/* ----------------------------------------------------------------------------
Name: lnb_lnb21_setttxmode()

Description:
    Dummy Function
    
Parameters:
    
Return Value:
---------------------------------------------------------------------------- */

ST_ErrorCode_t lnb_lnb21_setttxmode(LNB_Handle_t Handle, STTUNER_LnbTTxMode_t Ttxmode)
{
    ST_ErrorCode_t Error = ST_NO_ERROR;
    return(Error);
}
#endif


/* ----------------------------------------------------------------------------
Name: lnb_lnb21_GetConfig()

Description:
    
Parameters:
    
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t lnb_lnb21_GetConfig(LNB_Handle_t Handle, LNB_Config_t *Config)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_LNB21
   const char *identity = "STTUNER lnb21.c lnb_lnb21_GetConfig()";
#endif
    ST_ErrorCode_t Error = ST_NO_ERROR;
    LNB21_InstanceData_t     *Instance;

    Instance = (LNB21_InstanceData_t *)Handle;

    Config->Status       = Instance->Config.Status;
    Config->Polarization = Instance->Config.Polarization;
    Config->ToneState    = Instance->Config.ToneState;
    Config->CurrentThresholdSelection    = Instance->Config.CurrentThresholdSelection;
    Config->ShortCircuitProtectionMode    = Instance->Config.ShortCircuitProtectionMode;
    Config->CableLossCompensation    = Instance->Config.CableLossCompensation;

#ifdef STTUNER_DEBUG_MODULE_SATDRV_LNB21
    STTBX_Print(("%s called\n", identity));
#endif
    return(Error);
}   
#endif



#ifdef STTUNER_MINIDRIVER

/* ----------------------------------------------------------------------------
Name: lnb_lnb21_GetConfig()

Description:
    
Parameters:
    
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t lnb_lnb21_GetConfig(LNB_Config_t *Config)
{

    ST_ErrorCode_t Error = ST_NO_ERROR;
    
    Config->Status       = LNB21Instance->Config.Status;
    Config->Polarization = LNB21Instance->Config.Polarization;
    Config->ToneState    = LNB21Instance->Config.ToneState;
    Config->CurrentThresholdSelection    = LNB21Instance->Config.CurrentThresholdSelection;
    Config->ShortCircuitProtectionMode    = LNB21Instance->Config.ShortCircuitProtectionMode;
    Config->CableLossCompensation    = LNB21Instance->Config.CableLossCompensation;


    return(Error);
}   
#endif
#ifndef STTUNER_MINIDRIVER
/* ----------------------------------------------------------------------------
Name: lnb_lnb21_SetConfig()

Description:
    
Parameters:
    
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t lnb_lnb21_SetConfig(LNB_Handle_t Handle, LNB_Config_t *Config)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_LNB21
   const char *identity = "STTUNER lnb21.c lnb_lnb21_SetConfig()";
#endif
    ST_ErrorCode_t Error = ST_NO_ERROR;
    LNB21_InstanceData_t     *Instance;

    Instance = (LNB21_InstanceData_t *)Handle;
    Instance->TopLevelHandle = Config->TopLevelHandle;
    Instance->DeviceMap.Mode = IOREG_MODE_SUBADR_8;

    /* Select LNB band */
    if (Instance->Config.ToneState != Config->ToneState)
    {
        switch (Config->ToneState)
        {
            case STTUNER_LNB_TONE_OFF:      /* No tone */
                LNB21_SetLnb(Instance, Config->ToneState);
                break;

            case STTUNER_LNB_TONE_22KHZ:    /* 22KHz tone */
                LNB21_SetLnb(Instance, Config->ToneState);
                break;

            case STTUNER_LNB_TONE_DEFAULT:  /* no change */
                break;

            default:
#ifdef STTUNER_DEBUG_MODULE_SATDRV_LNB21
                STTBX_Print(("%s fail tone state not default, off or 22KHz\n", identity));
#endif
                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) */
                LNB21_SetPolarization(Instance, VERTICAL);
                break;

            case STTUNER_PLR_HORIZONTAL:    /* OP_2 controls -- 13V (low) */
                LNB21_SetPolarization(Instance, HORIZONTAL);
                break;

            case STTUNER_LNB_OFF:    /* Turn LNB off */
                LNB21_SetPolarization(Instance, NOPOLARIZATION);
                break;

            default:
#ifdef STTUNER_DEBUG_MODULE_SATDRV_LNB21
                STTBX_Print(("%s fail polarity not V or H\n", identity));
#endif
                return(ST_ERROR_BAD_PARAMETER);
        }
       Instance->Config.Polarization = Config->Polarization;
    }
    
    /* Select CurrentSelection*/
    if (Instance->Config.CurrentThresholdSelection != Config->CurrentThresholdSelection)
    {
        switch (Config->CurrentThresholdSelection)
        {
            /* The below two cases are for future use*/
            /*case STTUNER_LNB_CURRENT_THRESHOLD_HIGH:*/ /*ISEL=0*/
                /*LNB21_SetCurrentThreshold(&Instance->DeviceMap, 0);*/
                /*break;*/

            /*case STTUNER_LNB_CURRENT_THRESHOLD_LOW:*/ /*ISEL=1*/
                /*LNB21_SetCurrentThreshold(&Instance->DeviceMap, 1);*/
                /*break;*/

            default:/* Currently above both cases will not be entered, for future use*/
                LNB21_SetCurrentThreshold(Instance, 1);/* always set ISEL=1 for default setting of LNB21*/
            	break;
         }
         /* Below statement is for future use */
       /*Instance->Config.CurrentThresholdSelection = Config->CurrentThresholdSelection;*/
    }
    
    /* Select CableLossCompensation*/
    if (Instance->Config.CableLossCompensation != Config->CableLossCompensation)
    {
        /* Below statement is for future use */
        /*LNB21_SetLossCompensation(&Instance->DeviceMap, Config->CableLossCompensation);*/
        /*Instance->Config.CableLossCompensation = Config->CableLossCompensation;*/
        
        /* Set cable loss compensation off as default*/
        LNB21_SetLossCompensation(Instance, FALSE);
    }
    
    
    /* Select ShortCircuitProtection*/
    if (Instance->Config.ShortCircuitProtectionMode != Config->ShortCircuitProtectionMode)
    {
        switch (Config->ShortCircuitProtectionMode)
        {
        	/* The below two cases are for future use*/
            /*case STTUNER_LNB_PROTECTION_DYNAMIC:*/ /*PCL=0*/
                /*LNB21_SetProtectionMode(&Instance->DeviceMap, Config->ShortCircuitProtectionMode);*/
                /*break;*/

            /*case STTUNER_LNB_PROTECTION_STATIC:*/ /*PCL=1*/
                /*LNB21_SetProtectionMode(&Instance->DeviceMap, Config->ShortCircuitProtectionMode);*/
                /*break;*/

            default:
                LNB21_SetProtectionMode(Instance, 1); /* set lnb protection mode static as default*/
            	break;
         }
        
        /* Below statement is for future use */
        /*Instance->Config.ShortCircuitProtectionMode = Config->ShortCircuitProtectionMode;*/
    }


    /* Select power status */
        switch (Config->Status)
        {
            case LNB_STATUS_ON:
            case LNB_STATUS_OFF:
                LNB21_SetPower(Instance, Config->Status);
                break;

            default:
#ifdef STTUNER_DEBUG_MODULE_SATDRV_LNB21
                STTBX_Print(("%s fail status not ON or OFF\n", identity));
#endif
                return(ST_ERROR_BAD_PARAMETER);
        }
       Instance->Config.Status = Config->Status;
    
    /* now write in LNBP21 to update the status*/
    Error = LNB21_UpdateLNB(Instance);

#ifdef STTUNER_DEBUG_MODULE_SATDRV_LNB21
    STTBX_Print(("%s ok\n", identity));
#endif
    return(Error);
}   
#endif

#ifdef STTUNER_MINIDRIVER
/* ----------------------------------------------------------------------------
Name: lnb_lnb21_SetConfig()

Description:
    
Parameters:
    
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t lnb_lnb21_SetConfig(LNB_Config_t *Config)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_LNB21
   const char *identity = "STTUNER lnb21.c lnb_lnb21_SetConfig()";
#endif
    ST_ErrorCode_t Error = ST_NO_ERROR;
    
    /* Select LNB band */
    if (LNB21Instance->Config.ToneState != Config->ToneState)
    {
        switch (Config->ToneState)
        {
            case STTUNER_LNB_TONE_OFF:      /* No tone */
                LNB21_SetLnb(Config->ToneState);
                break;

            case STTUNER_LNB_TONE_22KHZ:    /* 22KHz tone */
                LNB21_SetLnb(Config->ToneState);
                break;

            case STTUNER_LNB_TONE_DEFAULT:  /* no change */
                break;

            default:
#ifdef STTUNER_DEBUG_MODULE_SATDRV_LNB21
                STTBX_Print(("%s fail tone state not default, off or 22KHz\n", identity));
#endif

⌨️ 快捷键说明

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