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

📄 stv199.c

📁 这是DVB tuner驱动部分和其它相关的源码和一些技术资料文档.
💻 C
📖 第 1 页 / 共 4 页
字号:
    U8 Value;    Error = STV0199A_GetProperty(Hw_p,                                 STV0199A_PUNCTURE_RATE,                                 &Value);    if (Error == STV0199A_NO_ERROR)        Hw_p->VENRate = Value;    return Error;} /* STV0199A_GetVENRate() *//*****************************************************************************Name: STV0199A_SetBetaTiming()Description:    Sets a new value for the beta timing on the STV0119A.Parameters:    Hw_p,   pointer to the STV0199A device.    Value,  new value for the beta timing.Return Value:    STV0199A_NO_ERROR,  the operation completed without error.    STV0199A_ERROR_BUS, there was a problem accessing the device.See Also:    STV0199A_GetBetaTiming()*****************************************************************************/STV0199A_ErrorCode_t STV0199A_SetBetaTiming(STV0199A_Device_t *Hw_p, U8 Value){    STV0199A_ErrorCode_t Error;    Error = STV0199A_SetProperty(Hw_p,                                 STV0199A_BETA_TIMING,                                 Value);    if (Error == STV0199A_NO_ERROR)        Hw_p->BetaTiming = Value;        return Error;} /* STV0199A_SetBetaTiming() *//*****************************************************************************Name: STV0199A_GetSignalQuality()Description:Parameters:Return Value:See Also:*****************************************************************************/STV0199A_ErrorCode_t STV0199A_GetSignalQuality(STV0199A_Device_t *Hw_p){    STV0199A_ErrorCode_t Error;    U32 M = 0;    U32 Ml, Mu, Bl, Bu, Su, Sl;    STV0199A_SignalQuality_t *Sq_p;    U8 Reg;    Error = STV0199A_Read(Hw_p,                          &Reg,                          STV0199A_ECNTM);    if (Error == STV0199A_NO_ERROR)    {        M = Reg;        M <<= 8;                      /* MSB */        Error = STV0199A_Read(Hw_p,                              &Reg,                              STV0199A_ECNTL);        if (Error == STV0199A_NO_ERROR)        {            M |= Reg;                 /* LSB */            /* Search through the look-up table until we             * find the nearest value.             */            for (Sq_p = SignalQualityLUT;                 M >= Sq_p->M && Sq_p->M != (U32)-1;                 Sq_p++) /* Do nothing */;            /* Check we didn't run off the end of the LUT -- should             * never happen.             */            if (Sq_p->M != (U32)-1)            {                /* Quick check to avoid interpolation */                if (M > 0)                {                    /* Obtain LUT values */                    Mu = Sq_p->M;                    Ml = (Sq_p-1)->M;                    Su = Sq_p->SignalQuality;                    Sl = (Sq_p-1)->SignalQuality;                    Bu = Sq_p->BitErrorRate;                    Bl = (Sq_p-1)->BitErrorRate;                    /* Perform interpolation */                    Hw_p->SignalQuality = Su + ((Mu - M) *                                                (Sl - Su)) / (Mu - Ml);                    Hw_p->BitErrorRate = Bu - ((Mu - M) *                                               (Bu - Bl)) / (Mu - Ml);                }                else                {                    /* M == 0 => perfect signal */                    Hw_p->SignalQuality = 100;                    Hw_p->BitErrorRate = 0;                }            }        }    }    return Error;} /* STV0199A_GetSignalQuality() */STV0199A_ErrorCode_t STV0199A_GetPowerOutput(STV0199A_Device_t *Hw_p){    STV0199A_ErrorCode_t Error;    S8 AGCl, AGCu;    U8 Pl, Pu;    STV0199A_AGCPower_t *Agc_p;    /* Update current AGC1 value */    Error = STV0199A_GetAGC1(Hw_p);    if (Error == STV0199A_NO_ERROR)    {        /* Search through the look-up table until we         * find the nearest value.         */        for (Agc_p = AGCPowerLUT;             Hw_p->AGC1 >= Agc_p->Agc && Agc_p->Agc != Agc_p->P != 0;             Agc_p++) /* Do nothing */;        /* Check we didn't run off the end of the LUT -- should         * never happen.         */        if (Agc_p->Agc != Agc_p->P != 0)        {            /* Quick check to avoid interpolation */            if (Hw_p->AGC1 != -128)            {                /* Obtain LUT values */                AGCu = Agc_p->Agc;                AGCl = (Agc_p-1)->Agc;                Pu = Agc_p->P;                Pl = (Agc_p-1)->P;                /* Perform interpolation */                Hw_p->PowerOutput = (U32)Pu - (U32)(((U32)(AGCu - Hw_p->AGC1) *                                         (U32)(Pu - Pl)) / (U32)(AGCu - AGCl));            }            else            {                /* Agc == -128 => -72 dBm */                Hw_p->PowerOutput = 111;            }        }    }    return Error;}/*****************************************************************************Name: STV0199A_SetIQ()Description:    Sets a new value for the IQ on the STV0119A.Parameters:    Hw_p,   pointer to the STV0199A device.    Value,  new value for the IQ.Return Value:    STV0199A_NO_ERROR,  the operation completed without error.    STV0199A_ERROR_BUS, there was a problem accessing the device.See Also:    STV0199A_GetIQ()*****************************************************************************/STV0199A_ErrorCode_t STV0199A_SetIQ(STV0199A_Device_t *Hw_p, U8 Value){    STV0199A_ErrorCode_t Error;    Error = STV0199A_SetProperty(Hw_p,                                 STV0199A_IQ,                                 Value);    if (Error == STV0199A_NO_ERROR)        Hw_p->IQ = Value;        return Error;} /* STV0199A_SetIQ() *//*****************************************************************************Name: STV0199A_SetCarrierLoopFrequency()Description:    Sets a new value for the carrier loop frequency on the STV0119A.Parameters:    Hw_p,   pointer to the STV0199A device.    Value,  new value for the carrier loop frequency.Return Value:    STV0199A_NO_ERROR,  the operation completed without error.    STV0199A_ERROR_BUS, there was a problem accessing the device.See Also:    STV0199A_GetCarrierLoopFrequency()*****************************************************************************/STV0199A_ErrorCode_t   STV0199A_SetCarrierLoopFrequency(STV0199A_Device_t *Hw_p,                                    S8 Value){    STV0199A_ErrorCode_t Error;    Error = STV0199A_SetProperty(Hw_p,                                 STV0199A_CLOOP_FREQUENCY,                                 Value);    if (Error == STV0199A_NO_ERROR)        Hw_p->CarrierLoopFrequency = Value;    return Error;} /* STV0199A_SetCarrierLoopFrequency() *//*****************************************************************************Name: STV0199A_SetTimingLoopFrequency()Description:Parameters:Return Value:See Also:*****************************************************************************/STV0199A_ErrorCode_t   STV0199A_SetTimingLoopFrequency(STV0199A_Device_t *Hw_p,                                   S8 Value){    STV0199A_ErrorCode_t Error;    Error = STV0199A_SetProperty(Hw_p,                                 STV0199A_TLOOP_FREQUENCY,                                 Value);    if (Error == STV0199A_NO_ERROR)        Hw_p->TimingLoopFrequency = Value;        return Error;} /* STV0199A_SetTimingLoopFrequency() *//*****************************************************************************Name: STV0199A_SetSymbolRate()Description:    Sets a new value for the symbol rate on the STV0119A.    NOTE: The master clock value must known before calling this routine.Parameters:    Hw_p,   pointer to the STV0199A device.    NewSymbolRate,  new value for the symbol rate.Return Value:    STV0199A_NO_ERROR,  the operation completed without error.    STV0199A_ERROR_BUS, there was a problem accessing the device.See Also:    STV0199A_GetSymbolRate()*****************************************************************************/STV0199A_ErrorCode_t STV0199A_SetSymbolRate(STV0199A_Device_t *Hw_p,                                            U32 NewSymbolRate){    STV0199A_ErrorCode_t Error = STV0199A_NO_ERROR;    S32 S2;    U32 S1, M1, L, i, SymbolRate = 0;    U16 I;    S1 = NewSymbolRate;    M1 = Hw_p->MasterClock;    L = 0;    for (i = 0; i < 18; i++)    {        S2 = S1 - Hw_p->MasterClock;        if (S2 >= 0)        {            L = 2*L + 1;            S1 = 2*S2;            SymbolRate += M1;        }        else        {            L *= 2;            S1 *= 2;        }        M1 /= 2;    }    L = (L+1)/2;    I = (U16)(L/256);    Error = STV0199A_SetProperty(Hw_p,                                 STV0199A_SYMBOL_MSB,                                 I);    if (Error == STV0199A_NO_ERROR)    {        L -= (256*I);        I = (U16)L;        Error = STV0199A_SetProperty(Hw_p,                                     STV0199A_SYMBOL_LSB,                                     I);        if (Error == STV0199A_NO_ERROR)            Hw_p->SymbolRate = SymbolRate;    }    return Error;} /* STV0199A_SetSymbolRate() *//*****************************************************************************Name: STV0199A_SetTrigger()Description:Parameters:Return Value:See Also:*****************************************************************************/STV0199A_ErrorCode_t STV0199A_SetTrigger(STV0199A_Device_t *Hw_p,                                         BOOL TriggerOn){    STV0199A_ErrorCode_t Error;    if (TriggerOn)    {        Hw_p->AuxENA = 0;        Hw_p->PAux = 1;    }    else    {        Hw_p->AuxENA = 0;        Hw_p->PAux = 0;    }    Error = STV0199A_SetProperty(Hw_p,                                 STV0199A_AUX_ENA,                                 Hw_p->AuxENA);    if (Error == STV0199A_NO_ERROR)    {        Error = STV0199A_SetProperty(Hw_p,                                     STV0199A_P_AUX,                                     Hw_p->PAux);    }    return Error;} /* STV0199A_SetTrigger() *//*****************************************************************************Name: STV0199A_SetVENRate()Description:Parameters:Return Value:See Also:*****************************************************************************/STV0199A_ErrorCode_t STV0199A_SetVENRate(STV0199A_Device_t *Hw_p,                                         U8 Value){    /* Enable requested puncture rates */    return STV0199A_Write(Hw_p,                          Value,                          STV0199A_VENRATE);} /* STV0199A_SetVENRate() *//*****************************************************************************Name: LongSqrt()Description:    Computes the square root of an unsigned long integer using integer    arithmetic alone.Parameters:    Value,      value to compute the square root of.Return Value:    Approximate integer square root of the value passed in.See Also:    Nothing.*****************************************************************************/static U32 LongSqrt(U32 Value){    S32 Factor, R, L;    U32 Root;    Factor = 1;    L = Value;    while (L > 0)    {        Factor <<= 2;        L >>= 2;    }    Factor >>= 2;    R = Value - Factor;    Root = 1;    Factor >>= 2;    while(Factor > 0)    {        Root <<= 1;        L = Root << 1;        L *= Factor;        L += Factor;        Factor >>= 2;        if((R - L) >= 0)        {            R -= L;            Root++;        }    }    return Root;} /* LongSqrt() *//* End of stv199.c */

⌨️ 快捷键说明

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