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

📄 tmbsl10023.c

📁 三星一体化数字高频头DNQS221PH261A驱动程序
💻 C
📖 第 1 页 / 共 5 页
字号:
//-----------------------------------------------------------------------------
// $Header: 
// (C) Copyright 2002 Philips Semiconductors, All rights reserved
//
// This source code and any compilation or derivative thereof is the sole
// property of Philips Corporation and is provided pursuant to a Software
// License Agreement.  This code is the proprietary information of Philips
// Corporation and is confidential in nature.  Its use and dissemination by
// any party other than Philips Corporation is strictly limited by the
// confidential information provisions of the Agreement referenced above.
//-----------------------------------------------------------------------------
// FILE NAME:    tmbsl10023.c
//
// DESCRIPTION:  Function for the silicon demodulator TDA10023
//
// DOCUMENT REF: <References to specification or other documents related to
//               this module>
//
// NOTES:
//-----------------------------------------------------------------------------
//

//-----------------------------------------------------------------------------
// Standard include files:
//-----------------------------------------------------------------------------
//
#include "..\..\Include\tmbslDemodCab.h"

#include <stdlib.h>        // for malloc
#include <string.h>        // for memset

//-----------------------------------------------------------------------------
// Project include files:
//-----------------------------------------------------------------------------
//
#include "debug.h"
#include "tmbsl10023local.h"
#include <stdio.h>


//-----------------------------------------------------------------------------
// Types and defines:
//-----------------------------------------------------------------------------
//
//#define NO_FLOAT

//-----------------------------------------------------------------------------
// Global data:
//-----------------------------------------------------------------------------
//

//-----------------------------------------------------------------------------
// Internal Prototypes:
//-----------------------------------------------------------------------------
//
tmErrorCode_t tmbsl10023GetIQ (tmUnitSelect_t demodUnit, UInt32 *puIQ);
tmErrorCode_t tmbsl10023GetCOEF (tmUnitSelect_t demodUnit, Int32 *plCoef);

tmErrorCode_t Tda10023WriteInit(tm10023object_t *psObject);
Bool Tda10023WriteRF (tm10023object_t *psObject, UInt32 *puRF);
Bool Tda10023WriteSR (tm10023object_t *psObject, UInt32 *puSR);
Bool Tda10023WriteQAM (tm10023object_t *psObject, UInt32 uMod);
Bool Tda10023WriteNextScan (tm10023object_t *psObject);
Bool Tda10023ResetAll (tm10023object_t *psObject);
Bool Tda10023InitTick (tm10023object_t *psObject, UInt16 wTime);
Bool Tda10023WaitTick (tm10023object_t *psObject);
Bool Tda10023ReadAFC (tm10023object_t *psObject, Int32 *plAfc);
UInt16 Tda10023_AlgoCalcTimer( tm10023object_t *psObject, UInt32 uNbSymbol);
tmhalFEManagerStatus_t Tda10023_MainAlgo (tm10023object_t *psObject, UInt16 *pAlgoTimer);
tmhalFEManagerStatus_t Tda10023_AlgoGain(tm10023object_t *psObject, UInt16 *pAlgoTimer);
tmhalFEManagerStatus_t Tda10023_AlgoMod( tm10023object_t *psObject);
tmhalFEManagerStatus_t Tda10023_AlgoClkOffset( tm10023object_t *psObject);

#ifdef NO_FLOAT
void Tda10023Mul64(UInt32 uUp1, UInt32 uUp2, UInt32* uHighInt, UInt32* uLowInt);
UInt32 Tda10023Div64(UInt32 uHighInt, UInt32 uLowInt, UInt32 uDown);
UInt32 Tda10023MulDiv32(UInt32 uUp1, UInt32 uUp2, UInt32 uDown);
#endif

//-----------------------------------------------------------------------------
// Exported functions:
//-----------------------------------------------------------------------------
//

//-----------------------------------------------------------------------------
// Initialization functions:
//-----------------------------------------------------------------------------
//

//-----------------------------------------------------------------------------
// FUNCTION:    tmbsl10023Init:
//
// DESCRIPTION: create an instance of a TDA10023 demodulator
//
// RETURN:      TMBSL_ERR_DEMOD_BAD_UNIT_NUMBER
//              TM_OK
//  
// NOTES:       
//-----------------------------------------------------------------------------
//
tmErrorCode_t
tmbsl10023Init(
    tmUnitSelect_t  demodUnit,      //  I: Demodulator unit number
    tmbslDcParam_t  sParam          //  I: setup parameters
    )
{
    SEND_TRACEFCT1(DEBUG_INIT_ID, 0);

    //----------------------
    // test input parameters
    //----------------------
    // test the max number
	//	printf("check1");
    if (demodUnit > TDA10023_MAX_UNITS)
        return TMBSL_ERR_DEMOD_BAD_UNIT_NUMBER;
    //	printf("check2");
    // return if already initialized
    if(g10023Instance[demodUnit].sApiFlags.iInit == True)
        return TMBSL_ERR_DEMOD_BAD_UNIT_NUMBER;

    //----------------
    // init the object
    //----------------
    // initialize the object
    g10023Instance[demodUnit].sApiFlags.iInit = True;
    g10023Instance[demodUnit].uDemodHwAdd     = sParam.uHwAddress;
    g10023Instance[demodUnit].systemFunc      = sParam.systemFunc;
    g10023Instance[demodUnit].tunerFunc       = sParam.tunerFunc;
    g10023Instance[demodUnit].eTunerUnit      = sParam.eTunerUnit;
    //	printf("check3");    
    // call init function here to prevent calling SetConfig if the default values are OK
    return Tda10023WriteInit(&g10023Instance[demodUnit]);
}


//-----------------------------------------------------------------------------
// FUNCTION:    tmbsl10023DeInit:
//
// DESCRIPTION: destroy an instance of a TDA10023 tuner
//
// RETURN:      TMBSL_ERR_DEMOD_BAD_UNIT_NUMBER
//              TMBSL_ERR_DEMOD_NOT_INITIALIZED
//              TM_OK
//
// NOTES:       
//-----------------------------------------------------------------------------
//
tmErrorCode_t 
tmbsl10023DeInit (
    tmUnitSelect_t   demodUnit     //  I: Demod unit number
    )
{
    SEND_TRACEFCT1(DEBUG_DEINIT_ID, 0);

    //----------------------
    // test input parameters
    //----------------------
    // test the instance number
    if (demodUnit > TDA10023_MAX_UNITS)
        return TMBSL_ERR_DEMOD_BAD_UNIT_NUMBER;

    // test the object
    if (g10023Instance[demodUnit].sApiFlags.iInit == False)
        return TMBSL_ERR_DEMOD_NOT_INITIALIZED;

    //-------------------------
    // De-initialize the object
    //-------------------------
    g10023Instance[demodUnit].sApiFlags.iInit = False;

    return TM_OK;
}


//-----------------------------------------------------------------------------
// FUNCTION:    tmbsl10023GetSWVersion:
//
// DESCRIPTION: Return the version of this device
//
// RETURN:      TM_OK
//
// NOTES:       Values defined in the tm10023local.h file
//-----------------------------------------------------------------------------
//
tmErrorCode_t   
tmbsl10023GetSWVersion (
    ptmSWVersion_t   pSWVersion     //  I: Receives SW Version 
    )
{
    SEND_TRACEFCT1(DEBUG_GETSWVER_ID, 0);

    pSWVersion->compatibilityNr = TDA10023_BSL_COMP_NUM;
    pSWVersion->majorVersionNr  = TDA10023_BSL_MAJOR_VER;
    pSWVersion->minorVersionNr  = TDA10023_BSL_MINOR_VER;

    return TM_OK;
}

//-----------------------------------------------------------------------------
// Configuration functions:
//-----------------------------------------------------------------------------
//

//-----------------------------------------------------------------------------
// FUNCTION:    tmbsl10023SetPowerState:
//
// DESCRIPTION: Set the power state of the 10023
//
// RETURN:      TMBSL_ERR_DEMOD_BAD_UNIT_NUMBER
//              TMBSL_ERR_DEMOD_NOT_INITIALIZED
//              TM_ERR_IIC_ERR   
//              TM_OK
//
// NOTES:       
//-----------------------------------------------------------------------------
//
tmErrorCode_t
tmbsl10023SetPowerState(
        tmUnitSelect_t    demodUnit,      //  I: demodUnit number
        tmPowerState_t    ePowerState     //  I: Power state of the device
        )
{
    UInt32 uByte;

    SEND_TRACEFCT1(DEBUG_SETPOWERSTATE_ID, 0);

    //----------------------
    // test input parameters
    //----------------------
    // test the instance number
    if (demodUnit > TDA10023_MAX_UNITS)
        return TMBSL_ERR_DEMOD_BAD_UNIT_NUMBER;

    // test the object
    if (g10023Instance[demodUnit].sApiFlags.iInit == False)
        return TMBSL_ERR_DEMOD_NOT_INITIALIZED;

    //----------------------
    // Implementation
    //----------------------
    switch (ePowerState)
    {
        case tmPowerStandby:
            uByte = TDA10023_GPR_STDBY_BIT;
            break;
        case tmPowerOn:
            uByte = 0;
            break;
    }
    
    // program the chip
    if (g10023Instance[demodUnit].systemFunc.SY_WriteBit(
        g10023Instance[demodUnit].uDemodHwAdd,
        TDA10023_GPR_IND, TDA10023_GPR_STDBY_BIT, 
        uByte) != 1)
        return TM_ERR_IIC_ERR;

    return TM_OK;
}

//-----------------------------------------------------------------------------
// FUNCTION:    tmbsl10023GetPowerState:
//
// DESCRIPTION: Set the power state of the 10023
//
// RETURN:      TMBSL_ERR_DEMOD_BAD_UNIT_NUMBER
//              TMBSL_ERR_DEMOD_NOT_INITIALIZED
//              TM_ERR_IIC_ERR
//              TM_OK
//
// NOTES:       
//-----------------------------------------------------------------------------
//
tmErrorCode_t
tmbsl10023GetPowerState(
    tmUnitSelect_t     demodUnit,        //  I: demodUnit number
    ptmPowerState_t    pPowerState       //  O: Receives current power state
    )
{
    UInt32 uByte;
    
    SEND_TRACEFCT1(DEBUG_GETPOWERSTATE_ID, 0);

    //----------------------
    // test input parameters
    //----------------------
    // test the instance number
    if (demodUnit > TDA10023_MAX_UNITS)
        return TMBSL_ERR_DEMOD_BAD_UNIT_NUMBER;

    // test the object
    if (g10023Instance[demodUnit].sApiFlags.iInit == False)
        return TMBSL_ERR_DEMOD_NOT_INITIALIZED;

    //----------------------
    // Implementation
    //----------------------
    if (g10023Instance[demodUnit].systemFunc.SY_Read(
        g10023Instance[demodUnit].uDemodHwAdd,
        TDA10023_GPR_IND, 1,
        &uByte) != 1)
        return TM_ERR_IIC_ERR;

    if (uByte & TDA10023_GPR_STDBY_BIT)    
        *pPowerState = tmPowerStandby;
    else
        *pPowerState = tmPowerOn;

    return TM_OK;
}

//-----------------------------------------------------------------------------
// FUNCTION:    tmbsl10023SetConfig:
//
// DESCRIPTION: Set the config of the 10023
//
// RETURN:      TMBSL_ERR_DEMOD_BAD_UNIT_NUMBER
//              TMBSL_ERR_DEMOD_NOT_INITIALIZED
//              TM_ERR_BAD_PARAMETER
//              TM_OK
//
// NOTES:       This function can be removed if needed
//-----------------------------------------------------------------------------
//
tmErrorCode_t
tmbsl10023SetConfig(
    tmUnitSelect_t    demodUnit,   //  I: demodUnit number
    UInt32            uItemId,     //  I: Identifier of the item to modify
    UInt32            uValue       //  I: Value to set for the config item
    )
{
    UInt32 puBytes[2];

    SEND_TRACEFCT2(DEBUG_SETCONFIG_ID, 0);

    //----------------------
    // test input parameters
    //----------------------
    // test the instance number
    if (demodUnit > TDA10023_MAX_UNITS)
        return TMBSL_ERR_DEMOD_BAD_UNIT_NUMBER;

    // test the object
    if (g10023Instance[demodUnit].sApiFlags.iInit == False)
        return TMBSL_ERR_DEMOD_NOT_INITIALIZED;

    //--------------
    // set the value
    //--------------
    switch((tm10023cfgIndex_t)uItemId)
    {
        case BOARD: /* case 0 */
            // default hardware config
//            g10023Instance[demodUnit].sConfig.bModeDvbMcns      = OM57XX_MODE_MCNS_DEF;
            g10023Instance[demodUnit].sConfig.uXtalFreq         = OM57XX_XTALL_DEF;
//            g10023Instance[demodUnit].sConfig.bPLL_M_Factor     = OM57XX_PLLMFACTOR_MCNS_DEF;
//            g10023Instance[demodUnit].sConfig.bPLL_N_Factor     = OM57XX_PLLNFACTOR_MCNS_DEF;
//            g10023Instance[demodUnit].sConfig.bPLL_P_Factor     = OM57XX_PLLPFACTOR_MCNS_DEF;
//            g10023Instance[demodUnit].sConfig.bFsampling        = OM57XX_FSAMPLING_DEF;
            g10023Instance[demodUnit].sConfig.bIFMax            = OM57XX_IFMAX_DEF;
            g10023Instance[demodUnit].sConfig.bIFMin            = OM57XX_IFMIN_DEF;
            g10023Instance[demodUnit].sConfig.bTUNMax           = OM57XX_TUNMAX_DEF;
            g10023Instance[demodUnit].sConfig.bTUNMin           = OM57XX_TUNMIN_DEF;
            g10023Instance[demodUnit].sConfig.bAGCtreshold      = OM57XX_AGCTRESHOLD_DEF;
            g10023Instance[demodUnit].sConfig.bEqualType        = OM57XX_EQUALTYPE_DEF;

⌨️ 快捷键说明

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