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

📄 stv199_i.c

📁 这是DVB tuner驱动部分和其它相关的源码和一些技术资料文档.
💻 C
📖 第 1 页 / 共 5 页
字号:
    if (Error == DEMOD_NO_ERROR)    {        /* Take four AGC2 samples */        for (i = 0; i < 4; i++)        {            Error = STV0199A_GetAGC2(STV0199A_HANDLE(Handle));            if (Error != DEMOD_NO_ERROR)                break;            Agc2 += STV0199A_HANDLE(Handle)->AGC2;        }        Agc2 /= 4;                          /* Average AGC2 values */        /* Test for good signal strength -- centre of analog carrier */        *IsAnalog_p = (Agc2 < ANALOG_CARRIER_DETECT_AGC2_VALUE) ? TRUE : FALSE;    }    return Error;} /* DEMOD_IsAnalogCarrier() *//*****************************************************************************Name: DEMOD_GetSignalQuality()Description:    Obtains a signal quality setting for the current lock.Parameters:    Demod_p,            pointer to the DEMOD device.    SignalQuality_p,    pointer to area to store the signal quality value.    Ber_p,              pointer to area to store the bit error rate.Return Value:    DEMOD_NO_ERROR,     the operation completed without error.    STI2C_xxx,          there was a problem accessing the device.See Also:    Nothing.*****************************************************************************/static DEMOD_ErrorCode_t DEMOD_GetSignalQuality(DEMOD_Handle_t Handle,                                                U32 *SignalQuality_p,                                                U32 *Ber_p){    DEMOD_ErrorCode_t Error = DEMOD_NO_ERROR;    Error = STV0199A_GetSignalQuality(STV0199A_HANDLE(Handle));    if (Error == DEMOD_NO_ERROR)    {        *SignalQuality_p = STV0199A_HANDLE(Handle)->SignalQuality;        *Ber_p = STV0199A_HANDLE(Handle)->BitErrorRate;    }    return Error;} /* DEMOD_GetSignalQuality() *//*****************************************************************************Name: DEMOD_IsLocked()Description:    Checks the LK register i.e., are we demodulating a digital carrier.Parameters:    Demod_p,        pointer to the DEMOD device.    IsLocked_p,     pointer to area to store result (bool):                    TRUE -- we are locked.                    FALSE -- no lock.Return Value:    DEMOD_NO_ERROR,     the operation completed without error.    STI2C_xxx,          there was a problem accessing the device.See Also:    Nothing.*****************************************************************************/static DEMOD_ErrorCode_t DEMOD_IsLocked(DEMOD_Handle_t Handle,                                        BOOL *IsLocked_p){    DEMOD_ErrorCode_t Error = DEMOD_NO_ERROR;    Error = STV0199A_GetLK(STV0199A_HANDLE(Handle));    if (Error == DEMOD_NO_ERROR)        *IsLocked_p = (STV0199A_HANDLE(Handle)->LK == 1) ? TRUE : FALSE;    return Error;} /* DEMOD_IsLocked() *//*****************************************************************************Name: DEMOD_Tracking()Description:    This routine checks the carrier against a certain threshold value and will    perform derotator centering, if necessary -- using the ForceTracking    option ensures that derotator centering is always performed when    this routine is called.    This routine should be periodically called once a lock has been    established in order to maintain the lock.Parameters:    Demod_p,        pointer to the DEMOD device.    ForceTracking,  boolean to control whether to always perform                    derotator centering, regardless of the carrier.    NewFrequency_p, pointer to area where to store the new frequency                    value -- it may be changed when trying to optimize                    the derotator.    SignalFound_p,  indicates that whether or not we're still locked                    after optimization.Return Value:    DEMOD_NO_ERROR,     the operation completed without error.    STI2C_xxx,          there was a problem accessing the device.See Also:    Nothing.*****************************************************************************/static DEMOD_ErrorCode_t DEMOD_Tracking(DEMOD_Handle_t Handle,                                        BOOL ForceTracking,                                        U32 *NewFrequency_p,                                        BOOL *SignalFound_p){    DEMOD_ErrorCode_t Error = DEMOD_NO_ERROR;    TNR_Status_t TunerStatus;    /* Assume optimization succeeds */    *SignalFound_p = TRUE;    Error = STV0199A_GetCarrierLoopFrequency(STV0199A_HANDLE(Handle));    /* Get current tuner status */    TNR_GetStatus(TNR_HANDLE(Handle), &TunerStatus);        if (Error == DEMOD_NO_ERROR)    {        if ((STV0199A_HANDLE(Handle)->CarrierLoopFrequency >= 110) ||            (STV0199A_HANDLE(Handle)->CarrierLoopFrequency <= -110) ||            ForceTracking)        {            Error = Optimization(Handle,                                 TunerStatus.Frequency,                                 0,     /* Use last delay value */                                 TunerStatus.IQSense,                                 TunerStatus.TunerStep,                                 SignalFound_p,                                 NewFrequency_p);        }        else            *NewFrequency_p = TunerStatus.Frequency;    }    return Error;} /* DEMOD_Tracking() *//*****************************************************************************Name: DEMOD_ScanFrequency()Description:    This routine will attempt to scan and find a QPSK signal based on the    passed in parameters.Parameters:    Demod_p,                pointer to the DEMOD device.    InitialFrequency,       IF value to commence scan (in kHz).    SymbolRate,             required symbol bit rate (in Hz).    MaxLNBOffset,           maximum allowed LNB offset (in Hz).    TunerStep,              Tuner's step value -- enables override of                            TNR device's internal setting.    DerotatorStep,          derotator step (usually 6).    ScanSuccess_p,          boolean that indicates QPSK search success.    NewFrequency_p,         pointer to area to store locked frequency.Return Value:    DEMOD_NO_ERROR,             the operation completed without error.    STI2C_xxx,                  there was a problem accessing the device.    DEMOD_ERROR_BAD_PARAMETER,  one or more params were invalid during                                computation.See Also:    Nothing.*****************************************************************************/static DEMOD_ErrorCode_t DEMOD_ScanFrequency(DEMOD_Handle_t Handle,                                             U32 InitialFrequency,                                             U32 SymbolRate,                                             U32 MaxLNBOffset,                                             U32 TunerStep,                                             U8 DerotatorStep,                                             BOOL *ScanSuccess_p,                                             U32 *NewFrequency_p){    DEMOD_ErrorCode_t Error = DEMOD_NO_ERROR;    DEMOD_ScanParams_t ScanParams;    BOOL QPSKOk = FALSE;    TNR_Status_t TunerStatus;    /* Initialize the scan parameters -------------------------------------  */    ScanParams.InitialFrequency = InitialFrequency;    ScanParams.DerotatorParams.DerotatorStep = DerotatorStep;    TNR_GetStatus(TNR_HANDLE(Handle), &TunerStatus);    ScanParams.IQSense = TunerStatus.IQSense;    ScanParams.TunerStep = TunerStatus.TunerStep;#if 0    /* Set the tuner step used to set the frequency on the tuner device -     * note that this is very different from frequency step, which is     * a step increment used for varying the next frequency in the scan     * algorithm.     */    TNR_HANDLE(Handle)->TunerStep = TunerStep;#endif    /* 5% is added to MaxLNBOffset in order to guarantee     * the full range scanning.     */    ScanParams.MaxLNBOffset = MaxLNBOffset + (5*MaxLNBOffset) / 100;    Error = STV0199A_GetMasterClock(STV0199A_HANDLE(Handle));    if (Error != DEMOD_NO_ERROR)        goto scan_end;    Error = STV0199A_SetSymbolRate(STV0199A_HANDLE(Handle),                                   SymbolRate);    if (Error != DEMOD_NO_ERROR)        goto scan_end;    /* Read hardware settings */    if (STV0199A_GetAlphaCarrier(STV0199A_HANDLE(Handle)) == DEMOD_NO_ERROR &&        STV0199A_GetBetaCarrier(STV0199A_HANDLE(Handle)) == DEMOD_NO_ERROR &&        STV0199A_GetAlphaTiming(STV0199A_HANDLE(Handle)) == DEMOD_NO_ERROR &&        STV0199A_GetBetaTiming(STV0199A_HANDLE(Handle)) == DEMOD_NO_ERROR &&        STV0199A_GetNaturalFrequency2(STV0199A_HANDLE(Handle)) == DEMOD_NO_ERROR &&        STV0199A_GetNaturalFrequency1(STV0199A_HANDLE(Handle)) == DEMOD_NO_ERROR &&        STV0199A_GetDampingFactor2(STV0199A_HANDLE(Handle)) == DEMOD_NO_ERROR &&        STV0199A_GetDampingFactor1(STV0199A_HANDLE(Handle)) == DEMOD_NO_ERROR)    {        BOOL ScanOk;        BOOL FastSearchOk;#if 0        printf("**** F = %d\n", InitialFrequency);#endif        /* Computation of the waiting times needed for the timing lock,         * the QPSK capture and DATA found.         */        Error = InitializeSearchTimers(Handle,                                       &ScanParams);        if (Error != DEMOD_NO_ERROR)            goto scan_end;        /* Check of M_CLK value and comparison of the symbol rate to the allowed         * maximum LNB offset. The structure of the search algorithm depends on         * this test.         */        if (STV0199A_HANDLE(Handle)->SymbolRate /            (STV0199A_HANDLE(Handle)->MasterClock / 1000) > 570)        {            /* MasterClock too low */            Error = DEMOD_ERROR_BAD_PARAMETER;            goto scan_end;        }        /* Initialisation of the timing loop step */        ScanParams.TimingLoopParams.TimingLoopStep =            (U16)((4 * STV0199A_HANDLE(Handle)->MasterClock) /                  STV0199A_HANDLE(Handle)->SymbolRate) + 1;        Error = FastSearch((DEMOD_ControlBlock_t *)Handle,                           ScanParams.InitialFrequency,                           &ScanParams.ScannedFrequency,                           &FastSearchOk);        if (Error != DEMOD_NO_ERROR || !FastSearchOk)            goto scan_end;        /* There is signal in the band */        if (STV0199A_HANDLE(Handle)->SymbolRate >=            (BANDWIDTH*1000L)/2L)        {            /* MCPC case */            ScanParams.CurrentFrequency = ScanParams.ScannedFrequency;        }        else        {            /* SCPC case */            Error = Scan((DEMOD_ControlBlock_t *)Handle,                         ScanParams.InitialFrequency,                         &ScanParams,                         &ScanOk);            if (Error != DEMOD_NO_ERROR || !ScanOk)                goto scan_end;        }        /* Scan has successfully ended */        Error = SearchQPSK((DEMOD_ControlBlock_t *)Handle,                           &ScanParams,                           &QPSKOk);        if (Error == DEMOD_NO_ERROR && QPSKOk)        {            /* Pass new frequency to caller */            *NewFrequency_p = ScanParams.QPSKParams.QPSKFrequency;        }    }scan_end:    *ScanSuccess_p = QPSKOk;    return Error;} /* DEMOD_ScanFrequency() *//*****************************************************************************Name: DEMOD_GetModulation()Description:    This routine returns the modulation scheme in use by this device.    ** Currently only QPSK is supported.Parameters:    Demod_p,            pointer to the DEMOD device.    Modulation_p,       pointer to area to store modulation scheme.Return Value:    DEMOD_NO_ERROR,     the operation completed without error.See Also:    Nothing.*****************************************************************************/static DEMOD_ErrorCode_t DEMOD_GetModulation(DEMOD_Handle_t Handle,                                             DEMOD_Modulation_t *Modulation_p){    DEMOD_ErrorCode_t Error = DEMOD_NO_ERROR;    /* This implementation of the DEMOD device only supports one type     * of modulation.     */    *Modulation_p = DEMOD_MOD_QPSK;    return Error;} /* DEMOD_GetModulation() *//*****************************************************************************Name: DEMOD_GetAGC()Description:    Obtains the current value from the AGC integrator register and computes    a look-up of power output.Parameters:    Demod_p,            pointer to the DEMOD device.    AGC_p,              pointer to area to store power output value.Return Value:    DEMOD_NO_ERROR,     the operation completed without error.    STI2C_xxx,          there was a problem accessing the device.See Also:    Nothing.*****************************************************************************/static DEMOD_ErrorCode_t DEMOD_GetAGC(DEMOD_Handle_t Handle,                                      U32 *AGC_p){    DEMOD_ErrorCode_t Error = DEMOD_NO_ERROR;    Error = STV0199A_GetPowerOutput(STV0199A_HANDLE(Handle));    if (Error == DEMOD_NO_ERROR)    {        /* Convert to valid range */        *AGC_p = (STV0199A_HANDLE(Handle))->PowerOutput;    }    return Error;

⌨️ 快捷键说明

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