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

📄 tmbsltda18211.c

📁 TDA8211芯片驱动程序
💻 C
📖 第 1 页 / 共 5 页
字号:
//-----------------------------------------------------------------------------
// $Header: 
// (C) Copyright 2001 NXP Semiconductors, All rights reserved
//
// This source code and any compilation or derivative thereof is the sole
// property of NXP Corporation and is provided pursuant to a Software
// License Agreement.  This code is the proprietary information of NXP
// Corporation and is confidential in nature.  Its use and dissemination by
// any party other than NXP Corporation is strictly limited by the
// confidential information provisions of the Agreement referenced above.
//-----------------------------------------------------------------------------
// FILE NAME:    tmbslTDA18211.c
//
// DESCRIPTION:  Function for the Hybrid silicon tuner TDA18211
//
// DOCUMENT REF: 
//
// NOTES:
//-----------------------------------------------------------------------------
//

//-----------------------------------------------------------------------------
// Standard include files:
//-----------------------------------------------------------------------------
//
#ifdef _WIN32
#include "math.h"
#include "OAIDL.h"
#include "stdlib.h"
#include "tmtypes.h"
#include "SystemFuncURT.h"
#endif

#include "tmhalFEtypes.h"

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

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

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

//-----------------------------------------------------------------------------
// Internal Prototypes:
//-----------------------------------------------------------------------------
//
tmErrorCode_t
TDA18211Init (
			  tmUnitSelect_t			TunerUnit	// I: Tuner Object
			  );
Bool 
TDA18211InitTick(
				 ptmTDA18211Object_t		pObj,		// I: Tuner unit number
				 UInt16					wTime		// I: time to wait for
				 );
Bool 
TDA18211WaitTick(
				 ptmTDA18211Object_t	pObj		// I: Tuner unit number
				 );
Bool 
TDA18211Write(
			  ptmTDA18211Object_t		pObj,		// I: Tuner unit number
			  UInt8					uSubAddress,// I: sub address
			  UInt8					uNbData		// I: nb of data
			  );
Bool 
TDA18211Read(
			 ptmTDA18211Object_t		pObj,		// I: Tuner unit number
			 UInt8					uSubAddress,// I: sub address
			 UInt8					uNbData		// I: nb of data
			 );
Bool 
TDA18211Wait(
			 ptmTDA18211Object_t		pObj,		//  I: Tuner unit number
			 UInt16					wTime		//  I: time to wait for
			 );
Bool 
TDA18211ShiftLog(
				 ptmTDA18211Object_t	pObj,	// I: Tuner unit number
				 UInt32					uNbRows	// I: nb of lines
				 );
tmErrorCode_t
TDA18211SetStandardMode(
						ptmTDA18211Object_t			pObj,		// I: tuner Object
						tmTDA18211StandardMode_t	StandardMode// I: Standard mode of this device
						);
tmErrorCode_t
TDA18211GetStandardMode(
						ptmTDA18211Object_t			pObj,			// I: tuner Object
						tmTDA18211StandardMode_t	*pStandardMode	// I: Standard mode of this device
						);
tmErrorCode_t
TDA18211SetPowerState(
					  ptmTDA18211Object_t		pObj,		// I: tuner Object
					  tmTDA18211PowerState_t	powerState	// I: Power state of this device
					  );
tmErrorCode_t
TDA18211GetPowerState(
					  ptmTDA18211Object_t		pObj,		// I: tuner Object
					  tmTDA18211PowerState_t	*pPowerState// I: Power state of this device
					  );
Bool
TDA18211CalcMAINPLL (
					 ptmTDA18211Object_t		pObj,		// I: tuner Object
					 UInt32					uLO			// I: local oscillator frequency in hertz
					 );
Bool
TDA18211CalcCALPLL (
					ptmTDA18211Object_t		pObj,		// I: tuner Object
					UInt32					uLO			// I: local oscillator frequency in hertz
					);
tmErrorCode_t
TDA18211CalcRFFilterCurve (
						   ptmTDA18211Object_t			pObj			// I: tuner Object
						   );
tmErrorCode_t
TDA18211RFTrackingFiltersInit (
							   ptmTDA18211Object_t			pObj,			// I: tuner Object
							   ptmTDA18211_RF_BAND_Map_t	pRF_BAND_Map	// I: address of RF band map
							   );
tmErrorCode_t
TDA18211CalibrateRF (
					 ptmTDA18211Object_t		pObj,		// I: tuner Object
					 UInt32					uRF,		// I: RF frequency in hertz
					 UInt8*					puCprog     // I: Address of the variable to output the Cprog value
					 );
tmErrorCode_t
TDA18211PowerScan (
				   ptmTDA18211Object_t		pObj,		// I: Tuner unit number
				   UInt32*					puRF,		// I/O: RF frequency in hertz
				   Bool*					pCal		// O: Calibration allowed if pCal = True
				   );
tmErrorCode_t
TDA18211PowerScanInit (
					   ptmTDA18211Object_t		pObj		// I: Tuner unit number
					   );
tmErrorCode_t
TDA18211ThermometerRead (
						 ptmTDA18211Object_t		pObj,		// I: Tuner unit number
						 Int8*					puValue		// O: Read thermometer value
						 );
//-----------------------------------------------------------------------------
// Exported functions:
//-----------------------------------------------------------------------------
//

//-----------------------------------------------------------------------------
// FUNCTION:    tmbslTDA18211Init:
//
// DESCRIPTION: create an instance of a TDA18211 Tuner
//
// RETURN:      TMBSL_ERR_TUNER_BAD_UNIT_NUMBER
//              TM_OK
//  
// NOTES:
//-----------------------------------------------------------------------------
//
tmErrorCode_t
TMBSL_FUNC(Init)
(
 tmUnitSelect_t     TunerUnit,    //  I: Tuner unit number
 tmbslTuParam_t     Param         //  I: setup parameters
 )
{
	ptmTDA18211Object_t		pObj;

	//----------------------
	// test input parameters
	//----------------------
	// test the max number
	if (TunerUnit > TDA18211_MAX_UNITS)
		return TMBSL_ERR_TUNER_BAD_UNIT_NUMBER;

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

	// pObj initialization
	pObj = &gTDA18211Instance[TunerUnit];

	//----------------
	// init the Object
	//----------------
	// initialize the Object by default values
	pObj->uHwAddress = Param.uHwAddress;
	pObj->SystemFunc = Param.systemFunc;
	pObj->init = True;

	return TM_OK;
}


//-----------------------------------------------------------------------------
// FUNCTION:    tmbslTDA18211DeInit:
//
// DESCRIPTION: destroy an instance of a TDA18211 Tuner
//
// RETURN:      TMBSL_ERR_TUNER_BAD_UNIT_NUMBER
//              TMBSL_ERR_TUNER_NOT_INITIALIZED
//              TM_OK
//
// NOTES:
//-----------------------------------------------------------------------------
//
tmErrorCode_t 
TMBSL_FUNC(DeInit)
(
 tmUnitSelect_t  TunerUnit     //  I: Tuner unit number
 )
{
	ptmTDA18211Object_t		pObj;

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

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

	// pObj initialization
	pObj = &gTDA18211Instance[TunerUnit];

	//-------------------------
	// De-initialize the Object
	//-------------------------
	pObj->init = False;

	return TM_OK;
}


//-----------------------------------------------------------------------------
// FUNCTION:    tmbslTDA18211GetSWVersion:
//
// DESCRIPTION: Return the version of this device
//
// RETURN:      TM_OK
//
// NOTES:       Values defined in the tmTDA18211loCAL.h file
//-----------------------------------------------------------------------------
//
tmErrorCode_t
TMBSL_FUNC(GetSWVersion)
(
 ptmSWVersion_t     pSWVersion        //  I: Receives SW Version 
 )
{
	pSWVersion->compatibilityNr = TDA18211_BSL_COMP_NUM;
	pSWVersion->majorVersionNr  = TDA18211_BSL_MAJOR_VER;
	pSWVersion->minorVersionNr  = TDA18211_BSL_MINOR_VER;

	return TM_OK;
}


//-------------------------------------------------------------------------------------
// FUNCTION:    tmbslTDA18211SetPowerState:
//
// DESCRIPTION: Set the power state of this device.
//
// RETURN:      TMBSL_ERR_TUNER_BAD_UNIT_NUMBER
//              TMBSL_ERR_TUNER_NOT_INITIALIZED
//              TM_OK
//
// NOTES:       
//-------------------------------------------------------------------------------------
//
tmErrorCode_t
TMBSL_FUNC(SetPowerState)
(
 tmUnitSelect_t			TunerUnit,		//  I: Tuner unit number
 tmTDA18211PowerState_t	powerState		//  I: Power state of this device
 )
{
	ptmTDA18211Object_t		pObj;

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

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

	// pObj initialization
	pObj = &gTDA18211Instance[TunerUnit];

	return TDA18211SetPowerState(pObj, powerState);
}

//-------------------------------------------------------------------------------------
// FUNCTION:    TDA18211SetPowerState:
//
// DESCRIPTION: Set the power state of this device.
//
// RETURN:      TMBSL_ERR_TUNER_BAD_UNIT_NUMBER
//              TMBSL_ERR_TUNER_NOT_INITIALIZED
//              TM_OK
//
// NOTES:       
//-------------------------------------------------------------------------------------
//
tmErrorCode_t
TDA18211SetPowerState(
					  ptmTDA18211Object_t		pObj,		// I: tuner Object
					  tmTDA18211PowerState_t	powerState	// I: Power state of this device
					  )
{
	switch (powerState)
	{
	case tmPowerNormalMode:					
		// set SM bits
		pObj->I2CMap.uBx05.bF.SM = 0x00;
		pObj->I2CMap.uBx05.bF.SM_LT = 0x00;
		pObj->I2CMap.uBx05.bF.SM_XT = 0x00;
		break;

	case tmPowerSleepMode:
		// set SM bits
		pObj->I2CMap.uBx05.bF.SM = 0x01;
		pObj->I2CMap.uBx05.bF.SM_LT = 0x01;
		pObj->I2CMap.uBx05.bF.SM_XT = 0x01;
		break;

	case tmPowerStandbyWith16MHz:
		// set SM bits
		pObj->I2CMap.uBx05.bF.SM = 0x01;
		pObj->I2CMap.uBx05.bF.SM_LT = 0x01;
		pObj->I2CMap.uBx05.bF.SM_XT = 0x00;
		break;

	case tmPowerStandbyWith16MHzAndLoopThrough:
		// set SM bits
		pObj->I2CMap.uBx05.bF.SM = 0x01;
		pObj->I2CMap.uBx05.bF.SM_LT = 0x00;
		pObj->I2CMap.uBx05.bF.SM_XT = 0x00;
		break;

	case tmPowerStandbyWithLoopThrough:
		// set SM bits
		pObj->I2CMap.uBx05.bF.SM = 0x01;
		pObj->I2CMap.uBx05.bF.SM_LT = 0x00;
		pObj->I2CMap.uBx05.bF.SM_XT = 0x01;
		break;

	default:
		// power state not supported
		return TM_ERR_NOT_SUPPORTED;
	}

	// store powerstate 
	pObj->curPowerState = powerState;

	return TM_OK;
}

//-------------------------------------------------------------------------------------
// FUNCTION:    tmbslTDA18211GetPowerState:
//
// 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
TMBSL_FUNC(GetPowerState)
(
 tmUnitSelect_t				TunerUnit,		//  I: Tuner unit number
 tmTDA18211PowerState_t	*pPowerState	//  O: Power state of this device
 )
{
	ptmTDA18211Object_t		pObj;

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

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

	// pObj initialization
	pObj = &gTDA18211Instance[TunerUnit];


	return TDA18211GetPowerState(pObj, pPowerState);
}

//-------------------------------------------------------------------------------------
// FUNCTION:    TDA18211GetPowerState:
//
// 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
TDA18211GetPowerState(
					  ptmTDA18211Object_t		pObj,		// I: tuner Object
					  tmTDA18211PowerState_t	*pPowerState// I: Power state of this device
					  )
{
	//----------------------

⌨️ 快捷键说明

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