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

📄 tmdlfe.c

📁 卫星接收机器卫星 自动搜索, 包括优化处理
💻 C
📖 第 1 页 / 共 5 页
字号:
                    Priority_E = tmhalFEPriorityLow;
                    break;
                case tmdlFeTerPriorityMax_E:
                    return tmdlFeInvalidValue_E;
                default:
                    return tmdlFeInvalidValue_E;
            }


            switch (pTunCfg_S->Specific_S.Ter_S.uStd.DvbT_S.Hierarchy_E)
            {
                case tmdlFeTerHierarchyNonHierarchy_E:
                    Hierarchy_E = tmhalFEHierarchyNo;
                    break;
                case tmdlFeTerHierarchyAlpha1_E:
                    Hierarchy_E = tmhalFEHierarchyAlpha1;
                    break;
                case tmdlFeTerHierarchyAlpha2_E:
                    Hierarchy_E = tmhalFEHierarchyAlpha2;
                    break;
                case tmdlFeTerHierarchyAlpha4_E:
                    Hierarchy_E = tmhalFEHierarchyAlpha4;
                    break;
                case tmdlFeTerHierarchyAutoDetect_E:
                    Hierarchy_E = tmhalFEHierarchyAuto;
                    break;
                case tmdlFeTerHierarchyMax_E:
                default:
                    return tmdlFeInvalidValue_E;
		    
            }

            ///////////////////////////////////////////////////////////////////////
            // END Adaptation Layer between DevLib structures and BSL structures //
            ///////////////////////////////////////////////////////////////////////

            // saving for GetStatus
            pCtx->DTT_Standard_S = pTunCfg_S->Specific_S.Ter_S.Standard_S;

            switch (pTunCfg_S->Specific_S.Ter_S.Standard_S)
            {

                // DVB-T (EUROPEAN STANDARD)
                case tmdlFeTerDVB_E:

                    // terrestrial - CS must be set before RF
	                RetVal_E = pCtx->uDemodCfg.Ter_S.setCsFunc    (pCtx->FeUnit, pTunCfg_S->Fsymb_BW_U);
                    if (RetVal_E != TM_OK)
		    	return (tmdlFeCallFailed_E);                     

                    // offset must be modified -> tmdlFeTerOffset_t must be the third argument
                    RetVal_E = pCtx->uDemodCfg.Ter_S.setRfFunc    (pCtx->FeUnit, pTunCfg_S->Frequency_U,tmhalFERfOffsetAuto);
                    if (RetVal_E != TM_OK)
                        return (tmdlFeCallFailed_E);

                    // Automatic Spectral Inversion forbidden
                    RetVal_E = pCtx->uDemodCfg.Ter_S.setSiFunc    (pCtx->FeUnit, SpecInv_E);
                    if (RetVal_E != TM_OK)
                        return (tmdlFeCallFailed_E);

                    RetVal_E = pCtx->uDemodCfg.Ter_S.setModFunc   (pCtx->FeUnit, Modulation_E);
                    if (RetVal_E != TM_OK)
                        return (tmdlFeCallFailed_E);

                    RetVal_E = pCtx->uDemodCfg.Ter_S.setVrHpFunc  (pCtx->FeUnit, ViterbiRateHP_E);
                    if (RetVal_E != TM_OK)
                        return (tmdlFeCallFailed_E);

                    RetVal_E = pCtx->uDemodCfg.Ter_S.setVrLpFunc  (pCtx->FeUnit, ViterbiRateLP_E);
                    if (RetVal_E != TM_OK)
                        return (tmdlFeCallFailed_E);

                    RetVal_E = pCtx->uDemodCfg.Ter_S.setGiFunc    (pCtx->FeUnit, GuardInterval_E);
                    if (RetVal_E != TM_OK)
                        return (tmdlFeCallFailed_E);

                    RetVal_E = pCtx->uDemodCfg.Ter_S.setFftFunc   (pCtx->FeUnit, TransmissionMode_E);
                    if (RetVal_E != TM_OK)
                        return (tmdlFeCallFailed_E);

                    RetVal_E = pCtx->uDemodCfg.Ter_S.setHrchFunc  (pCtx->FeUnit, Hierarchy_E);
                    if (RetVal_E != TM_OK)
                        return (tmdlFeCallFailed_E);

                    // Automatic Priority forbidden
                    RetVal_E = pCtx->uDemodCfg.Ter_S.setHpLpFunc  (pCtx->FeUnit, Priority_E);
                    if (RetVal_E != TM_OK)
                        return (tmdlFeCallFailed_E);
                    break;

                // ATSC (US STANDARD)
                case tmdlFeTerATSC_E:
                    break;

                default:
                    return tmdlFeInvalidValue_E;
            }
            break;


		//---------------------
		case tmdlFeSatellite_E:
		//---------------------

		    if (pCtx->Configured_F != True)
		        return tmdlFeInvalidValue_E;

            // LNB programming with internal power supply
            if (pCtx->Config_S.Sat_S.LnbPower_E == tmdlFeSatInternalSupply_E)
    	    {
        		if (pTunCfg_S->Specific_S.Sat_S.Polar_E == tmdlFeSat18V_E)
        		{
#ifdef WITH_LNBP21        			
        			// Write the msg in the LNB bloc (LNBP21) to have 18V
		        	//OLF bit = 0
		        	//OTF bit = 0
		        	//EN bit = 1
		        	//VSEL bit = 1
		        	//LLC bit = 0
		        	//TEN bit = 0
		        	//ISEL bit = 1
		        	//PCL bit = 1		        	
		        	LNBByte = 0x000000CC;
		        	SY_WriteTuner(
		            	0x10, // addr
		            	0, // index
		            	1, // nb byte
		            	&LNBByte);
#endif // WITH_LNBP21	
	            	
        		    RetVal_E = pCtx->uDemodCfg.Sat_S.setLnbFunc ( pCtx->FeUnit,
                            						  (UInt8)18,
                            						  (UInt16) pTunCfg_S->Specific_S.Sat_S.ToneState);
                    Cpt_BY=0;
                    while (RetVal_E != tmdlFeNoError_E && Cpt_BY<10)
                    {
                        tmosalTaskSleep(10);

                        RetVal_E = pCtx->uDemodCfg.Sat_S.setLnbFunc ( pCtx->FeUnit,
                                                                    (UInt8)18,
                                                                    (UInt16) pTunCfg_S->Specific_S.Sat_S.ToneState);
                        Cpt_BY++;
                    }
                  	    if (pCtx->Setup_S.HwCfg_S.PioCtl == TMDL_FE_NO_PIO_CTL)
                  	    {
                  	    	//Update only for the SAC/TCL Board
                    	    ErrorCode = tmdlPioWrite(pCtx->IoInstance_U, (0x0001000 |0x0010000), (0x0001000|0x0010000));
                    	}

                    if (RetVal_E != TM_OK)
                    {
                    	return (tmdlFeCallFailed_E);
                    }
        		}
        		else if (pTunCfg_S->Specific_S.Sat_S.Polar_E == tmdlFeSat14V_E)
        		{
#ifdef WITH_LNBP21        			
        			// Write the msg in the LNB bloc (LNBP21) to have 13V
		        	//OLF bit = 0
		        	//OTF bit = 0
		        	//EN bit = 1
		        	//VSEL bit = 0
		        	//LLC bit = 0
		        	//TEN bit = 0
		        	//ISEL bit = 1
		        	//PCL bit = 1		        	        			
		        	LNBByte = 0x000000C4;
		        	SY_WriteTuner(
		            	0x10, // addr
		            	0, // index
		            	1, // nb byte
		            	&LNBByte);
#endif // WITH_LNBP21		
            	
        		    RetVal_E = pCtx->uDemodCfg.Sat_S.setLnbFunc ( pCtx->FeUnit,
                            						  (UInt8) 14,
                            						  (UInt16) pTunCfg_S->Specific_S.Sat_S.ToneState);
                    Cpt_BY=0;
                    while (RetVal_E != tmdlFeNoError_E && Cpt_BY<10)
                    {
                        tmosalTaskSleep(10);

                        RetVal_E = pCtx->uDemodCfg.Sat_S.setLnbFunc ( pCtx->FeUnit,
                                                                    (UInt8)14,
                                                                    (UInt16) pTunCfg_S->Specific_S.Sat_S.ToneState);
                        Cpt_BY++;
                    }
                    if (pCtx->Setup_S.HwCfg_S.PioCtl == TMDL_FE_NO_PIO_CTL)
          	        {
                        //Update only for the SAC/TCL Board
                	    ErrorCode = tmdlPioWrite(pCtx->IoInstance_U, (0x0001000 |0x0010000), (0x0001000|0x0000000));
                    }
                    if (RetVal_E != TM_OK)
                    {
                    	return (tmdlFeCallFailed_E);
                    }
        		}
    	    }

            // LNB programming with external power supply
    	    if (pCtx->Config_S.Sat_S.LnbPower_E == tmdlFeSatExternalSupply_E)
    	    {
#ifdef LNBP21    	    	
    	    	// Write the msg in the LNB bloc (LNBP21) to have 0V
	        	//OLF bit = 0
	        	//OTF bit = 0
	        	//EN bit = 0
	        	//VSEL bit = 0
	        	//LLC bit = 0
	        	//TEN bit = 0
	        	//ISEL bit = 1
	        	//PCL bit = 1	        	    	    	
	        	LNBByte = 0x000000C0;
	        	SY_WriteTuner(
	            	0x10, // addr
	            	0, // index
	            	1, // nb byte
	            	&LNBByte);
#endif // WITH_LNBP21	     
       	
    	    	RetVal_E = pCtx->uDemodCfg.Sat_S.setLnbFunc ( pCtx->FeUnit,
                						      (UInt8) 0,
                						      (UInt16) pTunCfg_S->Specific_S.Sat_S.ToneState);
                if (pCtx->Setup_S.HwCfg_S.PioCtl == TMDL_FE_NO_PIO_CTL)
                {
                    //Update only for the SAC/TCL Board
            	    ErrorCode = tmdlPioWrite(pCtx->IoInstance_U, (0x0001000 |0x0010000), 0X0);
            	}
            	if (RetVal_E != TM_OK)
            	    return (tmdlFeCallFailed_E);
    	    }

            // Program downstream symbol rate in baud
            // must be set before the setRfFunc
    	    RetVal_E = pCtx->uDemodCfg.Sat_S.setSrFunc  (pCtx->FeUnit, pTunCfg_S->Fsymb_BW_U);
            if (RetVal_E != TM_OK)
                return (tmdlFeCallFailed_E);

            //Program downstream frequency in hertz
    	    RetVal_E = pCtx->uDemodCfg.Sat_S.setRfFunc  (pCtx->FeUnit, pTunCfg_S->Frequency_U);
            if (RetVal_E != TM_OK)
                return (tmdlFeCallFailed_E);

            //Program the spectral inversion of the downstream signal
    	    RetVal_E = pCtx->uDemodCfg.Sat_S.setSiFunc  (pCtx->FeUnit, SpecInv_E);
            if (RetVal_E != TM_OK)
                return (tmdlFeCallFailed_E);

            //Program the modulation of the downstream signal
    	    RetVal_E = pCtx->uDemodCfg.Sat_S.setModFunc (pCtx->FeUnit, Modulation_E);
            if (RetVal_E != TM_OK)
                return (tmdlFeCallFailed_E);

            switch (pTunCfg_S->Specific_S.Sat_S.ViterbiRate_E)
            {
                case tmdlFeSatRate12_E:
                    ViterbiRate_E = tmhalFEDepuncRate12;
                    break;
                case tmdlFeSatRate23_E:
                    ViterbiRate_E = tmhalFEDepuncRate23;
                    break;
                case tmdlFeSatRate34_E:
                    ViterbiRate_E= tmhalFEDepuncRate34;
                    break;
                case tmdlFeSatRate56_E:
                    ViterbiRate_E = tmhalFEDepuncRate56;
                    break;
                case tmdlFeSatRate67_E:
                    ViterbiRate_E = tmhalFEDepuncRate67;
                    break;
                case tmdlFeSatRate78_E:
                    ViterbiRate_E= tmhalFEDepuncRate78;
                    break;
                case tmdlFeSatRateAutoDetect_E:
                    ViterbiRate_E = tmhalFEDepuncRateAuto;
                    break;
                case tmdlFeSatRateMax_E:
                default:
                    return tmdlFeInvalidValue_E;
            }

            //Program the viterbi rate of the downstream signal
    	    RetVal_E = pCtx->uDemodCfg.Sat_S.setVrFunc  (pCtx->FeUnit, ViterbiRate_E);
            if (RetVal_E != TM_OK)
                return (tmdlFeCallFailed_E);

            break;


		//-----------------
		case tmdlFeCable_E:
		//-----------------

            RetVal_E = pCtx->uDemodCfg.Cab_S.setRfFunc  (pCtx->FeUnit, pTunCfg_S->Frequency_U);
            if (RetVal_E != TM_OK)
                return (tmdlFeCallFailed_E);

	        RetVal_E = pCtx->uDemodCfg.Cab_S.setSrFunc  (pCtx->FeUnit, pTunCfg_S->Fsymb_BW_U);
            if (RetVal_E != TM_OK)
                return (tmdlFeCallFailed_E);

            RetVal_E = pCtx->uDemodCfg.Cab_S.setSiFunc  (pCtx->FeUnit, SpecInv_E);
            if (RetVal_E != TM_OK)
                return (tmdlFeCallFailed_E);

            RetVal_E = pCtx->uDemodCfg.Cab_S.setModFunc (pCtx->FeUnit, Modulation_E);
            if (RetVal_E != TM_OK)
                return (tmdlFeCallFailed_E);

            break;

            default:
                return tmdlFeInvalidValue_E;
    }

    return tmdlFeNoError_E;
}


//-----------------------------------------------------------------------------
// FUNCTION     : FeStartScan
//
// DESCRIPTION  : Starts the scanning
//
// RETURN       : tmdlFeErr_t

⌨️ 快捷键说明

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