📄 tmbsl8260.c
字号:
//-----------------------------------------------------------------------------
// $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: tmbsl8260.c
//
// DESCRIPTION: Function for the silicon tuner TDA8260
//
// DOCUMENT REF: <References to specification or other documents related to
// this module>
//
// NOTES: 2.7 03/29/02 14:57:52
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
// Standard include files:
//-----------------------------------------------------------------------------
//
#include "..\..\Include\tmhalFEtypes.h"
//-----------------------------------------------------------------------------
// Project include files:
//-----------------------------------------------------------------------------
//
#include "..\..\Include\tmbslTuner.h"
#include "tmbsl8260local.h"
//-----------------------------------------------------------------------------
// Types and defines:
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
// Global data:
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
// Internal Prototypes:
//-----------------------------------------------------------------------------
//
Bool
tda8260Init (
ptm8260object_t p8260object // I: tuner object
);
Bool
tda8260CalcReg (
ptm8260object_t p8260object, // I: tuner object
UInt32 uRf // I: frequency in hertz
);
//-----------------------------------------------------------------------------
// Exported functions:
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
// FUNCTION: tmbsl8260Init:
//
// DESCRIPTION: create an instance of a TDA8260 tuner
//
// RETURN: TMBSL_ERR_TUNER_BAD_UNIT_NUMBER
// TM_OK
//
// NOTES:
//-----------------------------------------------------------------------------
//
tmErrorCode_t
tmbsl8260Init(
tmUnitSelect_t TunerUnit, // I: Tuner unit number
tmbslTuParam_t Param // I: setup parameters
)
{
//----------------------
// test input parameters
//----------------------
// test the max number
if (TunerUnit > TDA8260_MAX_UNITS)
return TMBSL_ERR_TUNER_BAD_UNIT_NUMBER;
//----------------------
// initialize the object
//----------------------
// return if already initialized
if(g8260Instance[TunerUnit].init == True)
return TM_OK;
//----------------
// init the object
//----------------
// initialize the object by default values
g8260Instance[TunerUnit].uHwAddress = Param.uHwAddress;
g8260Instance[TunerUnit].systemFunc = Param.systemFunc;
g8260Instance[TunerUnit].init = True;
// init
tda8260Init(&g8260Instance[TunerUnit]);
return TM_OK;
}
//-----------------------------------------------------------------------------
// FUNCTION: tmbsl8260DeInit:
//
// DESCRIPTION: destroy an instance of a TDA8260 tuner
//
// RETURN: TMBSL_ERR_TUNER_BAD_UNIT_NUMBER
// TMBSL_ERR_TUNER_NOT_INITIALIZED
// TM_OK
//
// NOTES:
//-----------------------------------------------------------------------------
//
tmErrorCode_t
tmbsl8260DeInit (
tmUnitSelect_t TunerUnit // I: Tuner unit number
)
{
//----------------------
// test input parameters
//----------------------
// test the instance number
if (TunerUnit > TDA8260_MAX_UNITS)
return TMBSL_ERR_TUNER_BAD_UNIT_NUMBER;
// test the object
if (g8260Instance[TunerUnit].init == False)
return TMBSL_ERR_TUNER_NOT_INITIALIZED;
//-------------------------
// De-initialize the object
//-------------------------
g8260Instance[TunerUnit].init = False;
return TM_OK;
}
//-----------------------------------------------------------------------------
// FUNCTION: tmbsl8260GetSWVersion:
//
// DESCRIPTION: Return the version of this device
//
// RETURN: TM_OK
//
// NOTES: Values defined in the tm8260local.h file
//-----------------------------------------------------------------------------
//
tmErrorCode_t
tmbsl8260GetSWVersion (
ptmSWVersion_t pSWVersion // I: Receives SW Version
)
{
pSWVersion->compatibilityNr = TDA8260_BSL_COMP_NUM;
pSWVersion->majorVersionNr = TDA8260_BSL_MAJOR_VER;
pSWVersion->minorVersionNr = TDA8260_BSL_MINOR_VER;
return TM_OK;
}
//-----------------------------------------------------------------------------
// FUNCTION: tmbsl8260SetPowerState:
//
// 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 - inputs from stephane needed
//-----------------------------------------------------------------------------
//
tmErrorCode_t
tmbsl8260SetPowerState (
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 > TDA8260_MAX_UNITS)
return TMBSL_ERR_TUNER_BAD_UNIT_NUMBER;
// test the object
if (g8260Instance[TunerUnit].init == False)
return TMBSL_ERR_TUNER_NOT_INITIALIZED;
//--------------
// set the value
//--------------
// TO DO : power on off standy suspend
// store the value
g8260Instance[TunerUnit].curPowerState = powerState;
return TM_OK;
}
//-----------------------------------------------------------------------------
// FUNCTION: tmbsl8260GetPowerState:
//
// 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
tmbsl8260GetPowerState (
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 > TDA8260_MAX_UNITS)
return TMBSL_ERR_TUNER_BAD_UNIT_NUMBER;
// test the object
if (g8260Instance[TunerUnit].init == False)
return TMBSL_ERR_TUNER_NOT_INITIALIZED;
//--------------
// get the value
//--------------
*pPowerState = g8260Instance[TunerUnit].curPowerState;
return TM_OK;
}
//-----------------------------------------------------------------------------
// FUNCTION: tmbsl8260Write:
//
// DESCRIPTION: Write in the tuner.
//
// RETURN: TMBSL_ERR_TUNER_BAD_UNIT_NUMBER
// TMBSL_ERR_TUNER_NOT_INITIALIZED
// TMBSL_ERR_IIC_ERR
// TM_OK
//
// NOTES:
//-----------------------------------------------------------------------------
//
tmErrorCode_t
tmbsl8260Write (
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 > TDA8260_MAX_UNITS)
return TMBSL_ERR_TUNER_BAD_UNIT_NUMBER;
// test the object
if (g8260Instance[TunerUnit].init == False)
return TMBSL_ERR_TUNER_NOT_INITIALIZED;
// test the object
if (uIndex > 3 || uNbBytes > 4)
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++)
g8260Instance[TunerUnit].pTunerReg[uCounter+uIndex] = puBytes[uCounter];
// write in the tuner
if (g8260Instance[TunerUnit].systemFunc.SY_Write(
g8260Instance[TunerUnit].uHwAddress,
0,4, g8260Instance[TunerUnit].pTunerReg) != 1)
return TMBSL_ERR_IIC_ERR;
return TM_OK;
}
//-----------------------------------------------------------------------------
// FUNCTION: tmbsl8260WriteBit:
//
// DESCRIPTION: Write in the tuner.
//
// RETURN: TM_ERR_NOT_SUPPORTED
//
// NOTES:
//-----------------------------------------------------------------------------
//
tmErrorCode_t
tmbsl8260WriteBit (
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: tmbsl8260Read:
//
// 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
tmbsl8260Read (
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 > TDA8260_MAX_UNITS)
return TMBSL_ERR_TUNER_BAD_UNIT_NUMBER;
// test the object
if (g8260Instance[TunerUnit].init == False)
return TMBSL_ERR_TUNER_NOT_INITIALIZED;
// test the object
if (uNbBytes > 4)
return TMBSL_ERR_TUNER_BAD_PARAMETER;
//--------------
// get the value
//--------------
if (uIndex == -1)
{
// read the status byte if index is -1
if (g8260Instance[TunerUnit].systemFunc.SY_Read(
g8260Instance[TunerUnit].uHwAddress,
0, 1, puBytes) != 1)
return TMBSL_ERR_IIC_ERR;
}
else
{
UInt32 uCounter;
// return value previously written
for (uCounter = uIndex; uCounter < uNbBytes; uCounter++)
puBytes[uCounter-uIndex] = g8260Instance[TunerUnit].pTunerReg[uCounter];
}
return TM_OK;
}
//-----------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -