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

📄 tmbsltuner.c

📁 Cu1216 解调器驱动
💻 C
📖 第 1 页 / 共 2 页
字号:
//-----------------------------------------------------------------------------
// $Header: 
// (C) Copyright 2001 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:    %M%
//
// DESCRIPTION:  Function for the Null tuner 
//
// DOCUMENT REF: <References to specification or other documents related to
//               this module>
//
// NOTES:        %I% %G% %U%
//-----------------------------------------------------------------------------
//

//-----------------------------------------------------------------------------
// Standard include files:
//-----------------------------------------------------------------------------
//

#include "tmhalFEtypes.h"

//-----------------------------------------------------------------------------
// Project include files:
//-----------------------------------------------------------------------------
//
#include "tmbslTuner.h"
#include "tmbslTunerlocal.h"

//-----------------------------------------------------------------------------
// Types and defines:
//-----------------------------------------------------------------------------
//

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

//-----------------------------------------------------------------------------
// Internal Prototypes:
//-----------------------------------------------------------------------------
//

Bool
tTunerCalcReg (
    ptmTunerobject_t 	pTunerobject,    	// I: tuner object
    UInt32*         		puRf            		// IO: frequency in hertz
    );

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

//-----------------------------------------------------------------------------
// FUNCTION:    tmbslTunerInit:
//
// DESCRIPTION: create an instance of a Tuner tuner
//
// RETURN:      TMBSL_ERR_TUNER_BAD_UNIT_NUMBER
//              TM_OK
//  
// NOTES:
//-----------------------------------------------------------------------------
//
tmErrorCode_t
tmbslTunerInit(
    tmUnitSelect_t     TunerUnit,    //  I: Tuner unit number
    tmbslTuParam_t     sParam        //  I: setup parameters
    )
{
    //----------------------
    // test input parameters
    //----------------------
    // test the max number
    if (TunerUnit > MAX_UNITS)
        return TMBSL_ERR_TUNER_BAD_UNIT_NUMBER;

    //----------------------
    // initialize the object
    //----------------------
    // return if already initialized
    if(gTunerInstance[TunerUnit].init == True)
        return TM_OK;

    //----------------
    // init the object
    //----------------
    // initialize the object by default values
    gTunerInstance[TunerUnit].uHwAddress = sParam.uHwAddress;
    gTunerInstance[TunerUnit].systemFunc = sParam.systemFunc;
    gTunerInstance[TunerUnit].init = True;

    return TM_OK;
}


//-----------------------------------------------------------------------------
// FUNCTION:    tmbslTunerDeInit:
//
// DESCRIPTION: destroy an instance of a Tuner tuner
//
// RETURN:      TMBSL_ERR_TUNER_BAD_UNIT_NUMBER
//              TMBSL_ERR_TUNER_NOT_INITIALIZED
//              TM_OK
//
// NOTES:
//-----------------------------------------------------------------------------
//
tmErrorCode_t 
tmbslTunerDeInit (
    tmUnitSelect_t TunerUnit     //  I: Tuner unit number
    )
{
    //----------------------
    // test input parameters
    //----------------------
    // test the instance number
    if (TunerUnit > MAX_UNITS)
        return TMBSL_ERR_TUNER_BAD_UNIT_NUMBER;

    // test the object
    if (gTunerInstance[TunerUnit].init == False)
        return TMBSL_ERR_TUNER_NOT_INITIALIZED;

    //-------------------------
    // De-initialize the object
    //-------------------------
    gTunerInstance[TunerUnit].init = False;

    return TM_OK;
}


//-----------------------------------------------------------------------------
// FUNCTION:    tmbslTunerGetSWVersion:
//
// DESCRIPTION: Return the version of this device
//
// RETURN:      TM_OK
//
// NOTES:       Values defined in the tmbslTunerlocal.h file
//-----------------------------------------------------------------------------
//
tmErrorCode_t   
tmbslTunerGetSWVersion (
    ptmSWVersion_t     pSWVersion        //  I: Receives SW Version 
    )
{
    pSWVersion->compatibilityNr = BSL_COMP_NUM;
    pSWVersion->majorVersionNr  = BSL_MAJOR_VER;
    pSWVersion->minorVersionNr  = BSL_MINOR_VER;

    return TM_OK;
}


//-----------------------------------------------------------------------------
// FUNCTION:    tmbslTunerSetPowerState:
//
// DESCRIPTION: Set the power state of this device.
//
// RETURN:      TMBSL_ERR_TUNER_BAD_UNIT_NUMBER
//              TMBSL_ERR_TUNER_NOT_INITIALIZED
//              TM_OK
//
// NOTES:       NOT implemented
//-----------------------------------------------------------------------------
//
tmErrorCode_t
tmbslTunerSetPowerState (
    tmUnitSelect_t      TunerUnit,      //  I: Tuner unit number
    tmPowerState_t      powerState      //  I: Power state of this device
)
{
    //----------------------
    // test input parameters
    //----------------------
    // test the instance number
    if (TunerUnit > MAX_UNITS)
        return TMBSL_ERR_TUNER_BAD_UNIT_NUMBER;

    // test the object
    if (gTunerInstance[TunerUnit].init == False)
        return TMBSL_ERR_TUNER_NOT_INITIALIZED;

    //--------------
    // set the value
    //--------------
    // TO DO : power on off standy suspend

    // store the value
    gTunerInstance[TunerUnit].curPowerState = powerState;

    return TM_OK;
}


//-----------------------------------------------------------------------------
// FUNCTION:    tmbslTunerGetPowerState:
//
// DESCRIPTION: Get the power state of this device.
//
// RETURN:      TMBSL_ERR_TUNER_BAD_UNIT_NUMBER
//              TMBSL_ERR_TUNER_NOT_INITIALIZED
//              TM_OK
//
// NOTES:
//-----------------------------------------------------------------------------
//
tmErrorCode_t
tmbslTunerGetPowerState (
    tmUnitSelect_t      TunerUnit,      //  I: Tuner unit number
    tmPowerState_t     *pPowerState     //  O: Power state of this device
)
{
    //----------------------
    // test input parameters
    //----------------------
    // test the instance number
    if (TunerUnit > MAX_UNITS)
        return TMBSL_ERR_TUNER_BAD_UNIT_NUMBER;

    // test the object
    if (gTunerInstance[TunerUnit].init == False)
        return TMBSL_ERR_TUNER_NOT_INITIALIZED;

    //--------------
    // get the value
    //--------------
    *pPowerState = gTunerInstance[TunerUnit].curPowerState;

    return TM_OK;
}


//-----------------------------------------------------------------------------
// FUNCTION:    tmbslTunerWrite:
//
// DESCRIPTION: Write in the tuner.
//
// RETURN:      TMBSL_ERR_TUNER_BAD_UNIT_NUMBER
//              TMBSL_ERR_TUNER_NOT_INITIALIZED
//              TMBSL_ERR_TUNER_BAD_PARAMETER
//              TMBSL_ERR_IIC_ERR
//              TM_OK
//
// NOTES:       
//-----------------------------------------------------------------------------
//
tmErrorCode_t
tmbslTunerWrite (
    tmUnitSelect_t      TunerUnit,      //  I: Tuner unit number
    UInt32              uIndex,         //  I: Start index to write
    UInt32              uNbBytes,       //  I: Number of bytes to write
    UInt32*             puBytes         //  I: Pointer on an array of bytes
)
{
    UInt32   uCounter;

    //----------------------
    // test input parameters
    //----------------------
    // test the instance number
    if (TunerUnit > MAX_UNITS)
        return TMBSL_ERR_TUNER_BAD_UNIT_NUMBER;

    // test the object
    if (gTunerInstance[TunerUnit].init == False)
        return TMBSL_ERR_TUNER_NOT_INITIALIZED;

    // test the object
    if (uIndex > NB_REGISTERS-1 || uNbBytes > NB_REGISTERS)
        return TMBSL_ERR_TUNER_BAD_PARAMETER;

    //--------------
    // set the value
    //--------------
    // the four registers must be written in the same time
    for (uCounter = 0; uCounter < uNbBytes; uCounter++)
        gTunerInstance[TunerUnit].pTunerReg[uCounter+uIndex] = puBytes[uCounter];
/*
    // write in the tuner
    if (gTunerInstance[TunerUnit].systemFunc.SY_Write(
        	gTunerInstance[TunerUnit].uHwAddress,
        	0,NB_REGISTERS, gTunerInstance[TunerUnit].pTunerReg) != 1)
       return TMBSL_ERR_IIC_ERR;
*/
    //Xiaohai
    // write in the tuner
	// first, CB + AB bytes
	if (gTunerInstance[TunerUnit].systemFunc.SY_Write(
        gTunerInstance[TunerUnit].uHwAddress,
        0, 2, &gTunerInstance[TunerUnit].pTunerReg[4]) != 1)
        return TMBSL_ERR_IIC_ERR;

	// then all the other bytes, DB1, DB2, CB and BB
	if (gTunerInstance[TunerUnit].systemFunc.SY_Write(
        gTunerInstance[TunerUnit].uHwAddress,
        0, 4, gTunerInstance[TunerUnit].pTunerReg) != 1)
        return TMBSL_ERR_IIC_ERR;
    //Xiaohai

    return TM_OK;
}


//-----------------------------------------------------------------------------
// FUNCTION:    tmbslTunerWriteBit:
//
// DESCRIPTION: Write bits in the tuner.
//
// RETURN:      TM_ERR_NOT_SUPPORTED
//
// NOTES:
//-----------------------------------------------------------------------------
//
tmErrorCode_t
tmbslTunerWriteBit (
    tmUnitSelect_t      TunerUnit,      //  I: Tuner unit number
    UInt32              uIndex,         //  I: Start index to write
    UInt32              uBitMask,       //  I: bit mask
    UInt32              uBitValue       //  I: bit value
)
{
    return TM_ERR_NOT_SUPPORTED;
}


//-----------------------------------------------------------------------------
// FUNCTION:    tmbslTunerRead:
//
// DESCRIPTION: Read in the tuner.
//
// RETURN:      TMBSL_ERR_TUNER_BAD_UNIT_NUMBER
//              TMBSL_ERR_TUNER_NOT_INITIALIZED
//              TMBSL_ERR_TUNER_BAD_PARAMETER
//              TMBSL_ERR_IIC_ERR
//              TM_OK
//
// NOTES:       
//-----------------------------------------------------------------------------
//
tmErrorCode_t
tmbslTunerRead (
    tmUnitSelect_t      TunerUnit,      //  I: Tuner unit number
    UInt32              uIndex,         //  I: Start index to read
    UInt32              uNbBytes,       //  I: Number of bytes to read
    UInt32*             puBytes         //  I: Pointer on an array of bytes
)
{
    //----------------------
    // test input parameters
    //----------------------
    // test the instance number
    if (TunerUnit > MAX_UNITS)
        return TMBSL_ERR_TUNER_BAD_UNIT_NUMBER;

⌨️ 快捷键说明

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