📄 tmbsltda18271.c
字号:
//-----------------------------------------------------------------------------
// $Header:
// (C) Copyright 2007 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: tmbslTDA18271.c
//
// %version: 17 %
//
// DESCRIPTION: Function for the Hybrid silicon tuner TDA18271
//
// DOCUMENT REF:
//
// NOTES:
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
// Standard include files:
//-----------------------------------------------------------------------------
//
#include "tmNxTypes.h"
#include "tmFrontEnd.h"
#include "tmbslFrontEndTypes.h"
//-----------------------------------------------------------------------------
// Project include files:
//-----------------------------------------------------------------------------
//
#include "tmbslTDA18271local.h"
#include "tmbslTDA18271Instance.h"
//-----------------------------------------------------------------------------
// Types and defines:
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
// Global data:
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
// Internal Prototypes:
//-----------------------------------------------------------------------------
//
tmErrorCode_t
TDA18271Init
(
tmUnitSelect_t tUnit /* I: Unit number */
);
tmErrorCode_t
TDA18271Write
(
ptmTDA18271Object_t pObj, /* I: Driver object */
UInt8 uSubAddress, /* I: sub address */
UInt8 uNbData /* I: nb of data */
);
tmErrorCode_t
TDA18271Read
(
ptmTDA18271Object_t pObj, /* I: Driver object */
UInt8 uSubAddress, /* I: sub address */
UInt8 uNbData /* I: nb of data */
);
tmErrorCode_t
TDA18271Wait
(
ptmTDA18271Object_t pObj, /* I: Driver object */
UInt16 wTime /* I: time to wait for */
);
tmErrorCode_t
TDA18271SetStandardMode
(
ptmTDA18271Object_t pObj, /* I: Driver object */
tmTDA18271StandardMode_t StandardMode /* I: Standard mode of this device */
);
tmErrorCode_t
TDA18271GetStandardMode
(
ptmTDA18271Object_t pObj, /* I: Driver object */
tmTDA18271StandardMode_t *pStandardMode /* I: Standard mode of this device */
);
tmErrorCode_t
TDA18271SetPowerState
(
ptmTDA18271Object_t pObj, /* I: Driver object */
tmTDA18271PowerState_t powerState /* I: Power state of this device */
);
tmErrorCode_t
TDA18271GetPowerState
(
ptmTDA18271Object_t pObj, /* I: Driver object */
tmTDA18271PowerState_t *pPowerState /* I: Power state of this device */
);
tmErrorCode_t
TDA18271CalcMAINPLL
(
ptmTDA18271Object_t pObj, /* I: Driver object */
UInt32 uLO /* I: local oscillator frequency in hertz */
);
tmErrorCode_t
TDA18271CalcCALPLL
(
ptmTDA18271Object_t pObj, /* I: Driver object */
UInt32 uLO /* I: local oscillator frequency in hertz */
);
tmErrorCode_t
TDA18271PowerScanInit
(
ptmTDA18271Object_t pObj /* I: Driver object */
);
tmErrorCode_t
TDA18271PowerScan
(
ptmTDA18271Object_t pObj, /* I: Unit number */
UInt32* puRF, /* I/O: RF frequency in hertz */
Bool* pCal /* O: Calibration allowed if pCal = True */
);
tmErrorCode_t
TDA18271CalibrateRF
(
ptmTDA18271Object_t pObj, /* I: Driver object */
UInt32 uRF, /* I: RF frequency in hertz */
UInt8* puCprog /* I: Address of the variable to output the Cprog value */
);
tmErrorCode_t
TDA18271RFTrackingFiltersInit
(
ptmTDA18271Object_t pObj, /* I: Driver object */
ptmTDA18271_RF_BAND_Map_t pRF_BAND_Map /* I: address of RF band map */
);
tmErrorCode_t
TDA18271CalcRFFilterCurve
(
ptmTDA18271Object_t pObj /* I: Driver object */
);
tmErrorCode_t
TDA18271ThermometerRead
(
ptmTDA18271Object_t pObj, /* I: Driver object */
UInt32* puValue /* O: Read thermometer value */
);
#define TMBSL_TDA18271_FREEZE_AGC (1)
//-----------------------------------------------------------------------------
// Exported functions:
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
// FUNCTION: tmbslTDA18211Init:
//
// DESCRIPTION: create an instance of a TDA18271 Tuner
//
// RETURN: TMBSL_ERR_TUNER_BAD_UNIT_NUMBER
// TM_OK
//
// NOTES:
//-----------------------------------------------------------------------------
//
tmErrorCode_t
tmbslTDA18271Init
(
tmUnitSelect_t tUnit, /* I: Unit number */
tmbslFrontEndDependency_t* psSrvFunc /* I: setup parameters */
)
{
ptmTDA18271Object_t pObj = Null;
tmErrorCode_t err = TM_OK;
if (psSrvFunc == Null)
{
return TDA18271_ERR_BAD_PARAMETER;
}
//----------------------
// initialize the Object
//----------------------
// pObj initialization
err = TDA18271GetInstance(tUnit, &pObj);
/* check driver state */
if (err == TM_OK || err == TDA18271_ERR_NOT_INITIALIZED)
{
if (pObj != Null && pObj->init == True)
{
err = TDA18271_ERR_NOT_INITIALIZED;
}
else
{
/* initialize the Object */
if (pObj == Null)
{
err = TDA18271AllocInstance(tUnit, &pObj);
if (err != TM_OK || pObj == Null)
{
err = TDA18271_ERR_NOT_INITIALIZED;
}
}
if (err == TM_OK)
{
pObj->tUnit = tUnit;
// initialize the Object by default values
pObj->sRWFunc = psSrvFunc->sIo;
pObj->sTime = psSrvFunc->sTime;
pObj->sDebug = psSrvFunc->sDebug;
pObj->init = True;
err = TM_OK;
}
}
}
return err;
}
//-----------------------------------------------------------------------------
// FUNCTION: tmbslTDA18271DeInit:
//
// DESCRIPTION: destroy an instance of a TDA18271 Tuner
//
// RETURN: TMBSL_ERR_TUNER_BAD_UNIT_NUMBER
// TDA18271_ERR_NOT_INITIALIZED
// TM_OK
//
// NOTES:
//-----------------------------------------------------------------------------
//
tmErrorCode_t
tmbslTDA18271DeInit
(
tmUnitSelect_t tUnit /* I: Unit number */
)
{
tmErrorCode_t err = TDA18271_ERR_NOT_INITIALIZED;
err = TDA18271DeAllocInstance(tUnit);
return err;
}
//-----------------------------------------------------------------------------
// FUNCTION: tmbslTDA18271GetSWVersion:
//
// DESCRIPTION: Return the version of this device
//
// RETURN: TM_OK
//
// NOTES: Values defined in the tmTDA18271local.h file
//-----------------------------------------------------------------------------
//
tmErrorCode_t
tmbslTDA18271GetSWVersion
(
ptmSWVersion_t pSWVersion /* I: Receives SW Version */
)
{
pSWVersion->compatibilityNr = TDA18271_BSL_COMP_NUM;
pSWVersion->majorVersionNr = TDA18271_BSL_MAJOR_VER;
pSWVersion->minorVersionNr = TDA18271_BSL_MINOR_VER;
return TM_OK;
}
//-------------------------------------------------------------------------------------
// FUNCTION: tmbslTDA18271SetPowerState:
//
// DESCRIPTION: Set the power state of this device.
//
// RETURN: TMBSL_ERR_TUNER_BAD_UNIT_NUMBER
// TDA18271_ERR_NOT_INITIALIZED
// TM_OK
//
// NOTES:
//-------------------------------------------------------------------------------------
//
tmErrorCode_t
tmbslTDA18271SetPowerState
(
tmUnitSelect_t tUnit, /* I: Unit number */
tmTDA18271PowerState_t powerState /* I: Power state of this device */
)
{
ptmTDA18271Object_t pObj = Null;
tmErrorCode_t err = TM_OK;
// pObj initialization
err = TDA18271GetInstance(tUnit, &pObj);
tmASSERTExTR(err, TM_OK, (DEBUGLVL_ERROR, "TDA18271GetInstance(0x%08X) failed.", tUnit));
// test the Object
if (pObj == Null || pObj->init == False)
{
tmDBGPRINTEx(DEBUGLVL_ERROR, "TDA18271 Instance not initialized.");
return TDA18271_ERR_NOT_INITIALIZED;
}
// set power state
err = TDA18271SetPowerState(pObj, powerState);
tmASSERTExT(err, TM_OK, (DEBUGLVL_ERROR, "TDA18271SetPowerState(0x%08X) failed.", tUnit));
return err;
}
//-------------------------------------------------------------------------------------
// FUNCTION: TDA18271SetPowerState:
//
// DESCRIPTION: Set the power state of this device.
//
// RETURN: TMBSL_ERR_TUNER_BAD_UNIT_NUMBER
// TDA18271_ERR_NOT_INITIALIZED
// TM_OK
//
// NOTES:
//-------------------------------------------------------------------------------------
//
tmErrorCode_t
TDA18271SetPowerState
(
ptmTDA18271Object_t pObj, /* I: tuner Object */
tmTDA18271PowerState_t powerState /* I: Power state of this device */
)
{
tmErrorCode_t err = TM_OK;
// test the Object
if (pObj == Null || pObj->init == False)
{
tmDBGPRINTEx(DEBUGLVL_ERROR, "TDA18271 Instance not initialized.");
return TDA18271_ERR_NOT_INITIALIZED;
}
switch (powerState)
{
case tmTDA18271_PowerNormalMode:
// 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 tmTDA18271_PowerSleepMode:
// 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 tmTDA18271_PowerStandbyWith16MHz:
// 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 tmTDA18271_PowerStandbyWith16MHzAndLoopThrough:
// set SM bits
pObj->I2CMap.uBx05.bF.SM = 0x01;
pObj->I2CMap.uBx05.bF.SM_LT = 0x00;
pObj->I2CMap.uBx05.bF.SM_XT = 0x00;
break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -