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

📄 tmhpidemod_hpi.c

📁 卫星接收机器卫星 自动搜索, 包括优化处理
💻 C
📖 第 1 页 / 共 5 页
字号:
    // update config
    pDriverCfg_S->Specific.HwConfig.DemodType   = FrontEndSetUp_S.HwCfg_S.FeType_E;
    pDriverCfg_S->Specific.HwConfig.DemodName   = FrontEndSetUp_S.HwCfg_S.DemodName_U;
    pDriverCfg_S->Specific.HwConfig.TunerName   = FrontEndSetUp_S.HwCfg_S.TunerName_U;
    pDriverCfg_S->Specific.HwConfig.DemodI2CAdd = FrontEndSetUp_S.HwCfg_S.DemodI2CAdd_BY;
    pDriverCfg_S->Specific.HwConfig.TunerI2CAdd = FrontEndSetUp_S.HwCfg_S.TunerI2CAdd_BY;
    pDriverCfg_S->Specific.HwConfig.I2CUnit     = (HPIv2_UCHAR)FrontEndSetUp_S.HwCfg_S.I2CUnit_BY;
    pDriverCfg_S->Specific.HwConfig.BoardType   = FrontEndSetUp_S.HwCfg_S.BoardType_U;
    pDriverCfg_S->Specific.HwConfig.PioCtl      = FrontEndSetUp_S.HwCfg_S.PioCtl;
    
    
	// update SR config
    // not implemented in Devlib
	
    // release the mutex
    ErrorCode = tmosalMutexExit(pDemodCtx->DemodMutex_H);
    DV_DBG_ASSERT(ErrorCode == TM_OK);

    return HPIv2_eDEMOD_OK;
}


//-----------------------------------------------------------------------------
// FUNCTION     : HPIv2_DemodTune
//
// DESCRIPTION  : This function performs to tune the demod on the frequency 
//                specified in the structure passed as input.
//
// RETURN       : HPIv2_tDEMOD_REPORT
//
// NOTES        : reentrant
//-----------------------------------------------------------------------------
HPIv2_tDEMOD_REPORT HPIv2_DemodTune(
                                        HPIv2_uiDemodInstance	    DemodInstance_U,
                                        HPIv2_tDemodTuningConfig*   pTunCfg_S
                                      )
{
    HPIv2_tDEMOD_REPORT retVal_E = HPIv2_eDEMOD_OK;
    tmErrorCode_t       ErrorCode;
    Int32               timeOut_L = 1000;
    tmhpiDemodCtx_t*    pDemodCtx = (tmhpiDemodCtx_t*)DemodInstance_U;
    UInt32              uiBandKuFreqMid, uiLFreqLowMax, uiLFreqHighMin;
    UInt32              uiLFreqCurrent = 0;
    
    
    // test if initialized
    if ( DemodInstance_U != pDemodCtx->Instance_U )
        return HPIv2_eDEMOD_NOT_INITIALIZED;
        
    // take the mutex
    ErrorCode = tmosalMutexEnter(pDemodCtx->DemodMutex_H, &timeOut_L);
    DV_DBG_ASSERT(ErrorCode == TM_OK);
    if(ErrorCode != TM_OK)
    {
        retVal_E = HPIv2_eDEMOD_COMMAND_FAILED;
    }
    else  // Parameters control
    {
        switch(pDemodCtx->DemodType_E)
        {
            case HPIv2_eDemodSatellite:
                // FIRST IT IS NEEDED TO REALIZE THE CONFIGURATION OF THE DEVICE LIBRARY
                if( pDemodCtx->DriverCfgCall_F )
                { 
                    // Check that the parameters provided by the caller are supported
                    if ( pTunCfg_S->Fsymb_BW <  TMDL_FE_CFG_FS_BW_MIN_SAT
                        || pTunCfg_S->Fsymb_BW > TMDL_FE_CFG_FS_BW_MAX_SAT)
                    {
                             retVal_E = HPIv2_eDEMOD_BAD_PARAMETER;                
                    }
                    else
                    {
                        if( pTunCfg_S->SpecInv < HPIv2_eDemodSpectrumAuto
                            || pTunCfg_S->SpecInv >= HPIv2_eDemodSpectralInvMax )
                        {
                            retVal_E = HPIv2_eDEMOD_BAD_PARAMETER;                
                        }
                        else
                        {
                            if( pTunCfg_S->Const != HPIv2_eDemodConstellationBpsk
                                && pTunCfg_S->Const != HPIv2_eDemodConstellationQpsk )
                            {
                                retVal_E = HPIv2_eDEMOD_BAD_PARAMETER;                
                            }
                            else
                            {
                                if( pTunCfg_S->Specific.Sat.ViterbiRate < HPIv2_eDemodSatRate12
                                    || pTunCfg_S->Specific.Sat.ViterbiRate >= HPIv2_eDemodSatRateMax )
                                {
                                    retVal_E = HPIv2_eDEMOD_BAD_PARAMETER;
                                }
                                else
                                {
                                    if( pTunCfg_S->Specific.Sat.Polar < HPIv2_eDemodSatVertical
                                        || pTunCfg_S->Specific.Sat.Polar > HPIv2_eDemodSatHorizontal )
                                    {
                                        retVal_E = HPIv2_eDEMOD_BAD_PARAMETER;
                                    }
                                }
                            }
                        }
                    }
		   } 
                    
                // Check that the frequency is supported with the default configuration of the Device Library
                if (pTunCfg_S->Const == HPIv2_eDemodConstellationQpsk)
                {
                       HPIv2_eDemodSatTone tone ;
                       retVal_E = tmGetSatelliteBISFrequency( pTunCfg_S->Frequency, &tone, &uiLFreqCurrent, pDemodCtx);
                       // If in mannuel switch mode, enable/disable 22k tone depend on TunCfg_S setting
                       if(pDemodCtx->DriverConfig_S.Specific.uDrvCfg.Sat.Switch.SwitchType != HPIv2_eDemodSatSwitchManual)
                       {
                            pTunCfg_S->Specific.Sat.Tone = tone;
                       }
                }
                else
                {
                    retVal_E = HPIv2_eDEMOD_COMMAND_FAILED;
                }
                
                // In case the parameters are supported
                if (retVal_E == HPIv2_eDEMOD_OK)
                {   
                    // Only frequencies in the BIS (950-2150Mhz) are supported by the Device Library
                    pTunCfg_S->Frequency = uiLFreqCurrent;
                    
                    // Set the switch frequency if Tone ON
                    if( pTunCfg_S->Specific.Sat.Tone == HPIv2_eDemodToneOn )
                    {
                        pTunCfg_S->Specific.Sat.Tone = pDemodCtx->DriverConfig_S.Specific.uDrvCfg.Sat.LnbDefinition.SwitchFrequency;
                    }

                    // Set the voltage of the polar
                    if( pTunCfg_S->Specific.Sat.Polar == HPIv2_eDemodSatVertical )
                    {
                        pTunCfg_S->Specific.Sat.Polar = pDemodCtx->DriverConfig_S.Specific.uDrvCfg.Sat.LnbDefinition.vertical;
                    }
                    else
                    {
                        if( pTunCfg_S->Specific.Sat.Polar == HPIv2_eDemodSatHorizontal )
                        {
                            pTunCfg_S->Specific.Sat.Polar = pDemodCtx->DriverConfig_S.Specific.uDrvCfg.Sat.LnbDefinition.horizontal;
                        }
                    }
                }
                break;
                
            case HPIv2_eDemodCable:
                if (pTunCfg_S->Frequency <  TMDL_FE_CFG_FREQ_TUNER_MIN_CAB
                    ||
                    pTunCfg_S->Frequency > TMDL_FE_CFG_FREQ_TUNER_MAX_CAB)    
                    retVal_E = HPIv2_eDEMOD_BAD_PARAMETER;           
    
                else if (pTunCfg_S->Fsymb_BW <  TMDL_FE_CFG_FS_BW_MIN_CAB
                         ||
                         pTunCfg_S->Fsymb_BW > TMDL_FE_CFG_FS_BW_MAX_CAB)    
                         retVal_E = HPIv2_eDEMOD_BAD_PARAMETER;           
    
                else if (pTunCfg_S->SpecInv <  HPIv2_eDemodSpectrumAuto
                         ||
                         pTunCfg_S->SpecInv > HPIv2_eDemodSpectrumInverted)    
                         retVal_E = HPIv2_eDEMOD_BAD_PARAMETER;           
    
                else if (pTunCfg_S->Const <  HPIv2_eDemodConstellationQam16
                         ||
                         pTunCfg_S->Const > HPIv2_eDemodConstellationAuto)    
                         retVal_E = HPIv2_eDEMOD_BAD_PARAMETER;           
    
                break;
                
            case HPIv2_eDemodTerrestrial:
                if (pTunCfg_S->Frequency <  TMDL_FE_CFG_FREQ_TUNER_MIN_TER
                    ||
                    pTunCfg_S->Frequency > TMDL_FE_CFG_FREQ_TUNER_MAX_TER)    
                    retVal_E = HPIv2_eDEMOD_BAD_PARAMETER;           
    
                else if (pTunCfg_S->Fsymb_BW <  TMDL_FE_CFG_FS_BW_MIN_TER
                         ||
                         pTunCfg_S->Fsymb_BW > TMDL_FE_CFG_FS_BW_MAX_TER)    
                         retVal_E = HPIv2_eDEMOD_BAD_PARAMETER;           
    
                else if (pTunCfg_S->SpecInv < HPIv2_eDemodSpectrumNormal
                         ||
                         pTunCfg_S->SpecInv > HPIv2_eDemodSpectrumInverted)    
                         retVal_E = HPIv2_eDEMOD_BAD_PARAMETER;
    
                else if (pTunCfg_S->Const != HPIv2_eDemodConstellationQpsk
                         &&
                         pTunCfg_S->Const != HPIv2_eDemodConstellationQam16
                         &&
                         pTunCfg_S->Const != HPIv2_eDemodConstellationQam64
                         &&
                         pTunCfg_S->Const != HPIv2_eDemodConstellationAuto)    
                         retVal_E = HPIv2_eDEMOD_BAD_PARAMETER;           
    
                else if (pTunCfg_S->Specific.Ter.Standard <  HPIv2_eDemodTerDVB
                         ||
                         pTunCfg_S->Specific.Ter.Standard >= HPIv2_eDemodTerStandardMax)    
                         retVal_E = HPIv2_eDEMOD_BAD_PARAMETER;           
                
                else
                {
                    switch (pTunCfg_S->Specific.Ter.Standard)
                    {
                        case HPIv2_eDemodTerDVB:
                            if (pTunCfg_S->Specific.Ter.uStd.DvbT.TransmissionMode <  HPIv2_eDemodTerTransmissionMode2K
                                ||
                                pTunCfg_S->Specific.Ter.uStd.DvbT.TransmissionMode >= HPIv2_eDemodTerTransmissionModeMax)    
                                retVal_E = HPIv2_eDEMOD_BAD_PARAMETER;
                                
                            else if (pTunCfg_S->Specific.Ter.uStd.DvbT.GuardInterval <  HPIv2_eDemodTerGuardInterval32
                                     ||
                                     pTunCfg_S->Specific.Ter.uStd.DvbT.GuardInterval >= HPIv2_eDemodTerGuardIntervalMax )
                                     retVal_E = HPIv2_eDEMOD_BAD_PARAMETER;
                         
                            else if (pTunCfg_S->Specific.Ter.uStd.DvbT.Priority <  HPIv2_eDemodTerPriorityHigh
                                     ||
                                     pTunCfg_S->Specific.Ter.uStd.DvbT.Priority >= HPIv2_eDemodTerPriorityMax )
                                     retVal_E = HPIv2_eDEMOD_BAD_PARAMETER;
                         
                            else if (pTunCfg_S->Specific.Ter.uStd.DvbT.Hierarchy <  HPIv2_eDemodTerHierarchyNonHierarchy
                                     ||
                                     pTunCfg_S->Specific.Ter.uStd.DvbT.Hierarchy >= HPIv2_eDemodTerHierarchyMax )
                                     retVal_E = HPIv2_eDEMOD_BAD_PARAMETER;
                         
                            else if (pTunCfg_S->Specific.Ter.uStd.DvbT.ViterbiRateHP <  HPIv2_eDemodTerRate12
                                     ||
                                     pTunCfg_S->Specific.Ter.uStd.DvbT.ViterbiRateHP >= HPIv2_eDemodTerRateMax )
                                     retVal_E = HPIv2_eDEMOD_BAD_PARAMETER;
                         
                            else if (pTunCfg_S->Specific.Ter.uStd.DvbT.ViterbiRateLP <  HPIv2_eDemodTerRate12
                                     ||
                                     pTunCfg_S->Specific.Ter.uStd.DvbT.ViterbiRateLP >= HPIv2_eDemodTerRateMax )
                                     retVal_E = HPIv2_eDEMOD_BAD_PARAMETER;
                            
                            break;
                            
                        case HPIv2_eDemodTerATSC:
                            if (pTunCfg_S->Specific.Ter.uStd.Vsb.ViterbiRate !=  HPIv2_eDemodTerRate23)
                                retVal_E = HPIv2_eDEMOD_BAD_PARAMETER;                
                            
                            break;
                    } //switch (pTunCfg_S->Specific.Ter.Standard)
                }
                break;
                
            default:
                    retVal_E = HPIv2_eDEMOD_BAD_PARAMETER;        
        } //switch(pDemodCtx->DemodType_E)
    }
    
    if (retVal_E != HPIv2_eDEMOD_OK)
    {
        // release the mutex
        ErrorCode = tmosalMutexExit(pDemodCtx->DemodMutex_H);
        DV_DBG_ASSERT(ErrorCode == TM_OK);
        return retVal_E;
    }
    
    
    // call front-end function
    ErrorCode = tmdlFeStartRelock( pDemodCtx->dlFeInstance_U);
    DV_DBG_ASSERT(ErrorCode == TM_OK);
    if (ErrorCode != TM_OK)
    {
        // release the mutex
        ErrorCode = tmosalMutexExit(pDemodCtx->DemodMutex_H);
        DV_DBG_ASSERT(ErrorCode == TM_OK);
        return HPIv2_eDEMOD_COMMAND_FAILED;
    }
    ErrorCode = tmdlFeTune(pDemodCtx->dlFeInstance_U, (tmdlFeTuningConfig_t*)pTunCfg_S);
    DV_DBG_ASSERT(ErrorCode == TM_OK);
    if (ErrorCode != TM_OK)
    {
        // release the mutex
        ErrorCode = tmosalMutexExit(pDemodCtx->DemodMutex_H);
        DV_DBG_ASSERT(ErrorCode == TM_OK);
        return HPIv2_eDEMOD_COMMAND_FAILED;
    }
    
    // release the mutex
    ErrorCode = tmosalMutexExit(pDemodCtx->DemodMutex_H);
    DV_DBG_ASSERT(ErrorCode == TM_OK);
    
    return HPIv2_eDEMOD_OK;
}


//-----------------------------------------------------------------------------
// FUNCTION     : HPIv2_DemodScan
//
// DESCRIPTION  : This function performs a scan as  specified in the structure 
//                passed as input.
//
// RETURN       : HPIv2_tDEMOD_REPORT
//
// NOTES        : reentrant
//-----------------------------------------------------------------------------
HPIv2_tDEMOD_REPORT HPIv2_DemodScan(
                                         HPIv2_uiDemodInstance      DemodInstance_U,
                                         HPIv2_tDemodSearchConfig*  pInSearchCfg_S
                                      )
{
    HPIv2_tDEMOD_REPORT retVal_E = HPIv2_eDEMOD_OK;
    tmErrorCode_t       ErrorCode;
    Int32               timeOut_L = 1000;
    tmhpiDemodCtx_t*    pDemodCtx = (tmhpiDemodCtx_t*)DemodInstance_U;
    UInt32              uiLStartFreq, uiLStopFreq, uiLFreqTemp;


    memcpy(pgSearchCfg_S, pInSearchCfg_S, sizeof(HPIv2_tDemodSearchConfig));

⌨️ 快捷键说明

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