📄 tmbsl10086.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: %M%
//
// DESCRIPTION: Function for the silicon demodulator TDA10086
//
// DOCUMENT REF: <References to specification or other documents related to
// this module>
//
// NOTES: %I% %G% %U%
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
// Standard include files:
//-----------------------------------------------------------------------------
//
#include "..\..\Include\tmbslDemodSat.h"
//-----------------------------------------------------------------------------
// Project include files:
//-----------------------------------------------------------------------------
//
#include "debug.h"
#include "tmbsl10086local.h"
//-----------------------------------------------------------------------------
// Types and defines:
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
// Global data:
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
// Internal Prototypes:
//-----------------------------------------------------------------------------
//
tmErrorCode_t Tda10086WriteInit (tm10086object_t *psObject);
Bool Tda10086WriteNextScan (tm10086object_t *psObject);
Bool Tda10086WriteNCO (tm10086object_t *psObject);
Bool Tda10086WriteRF (tm10086object_t *psObject, UInt32 *puRF);
Bool Tda10086ReadVR (tm10086object_t *psObject, tmhalFEDepuncRate_t *peVR);
Bool Tda10086ReadAFC (tm10086object_t *psObject, Int32 *plAFC);
Bool Tda10086ReadSync (tm10086object_t *psObject);
Bool Tda10086RfAlgo (tm10086object_t *psObject);
tmErrorCode_t Tda10086MainAlgo (tm10086object_t *psObject, UInt16 *pAlgoTimer);
UInt16 Tda10086CalcTimerAlgo (tm10086object_t *psObject, Bool isViterbiNeeded, UInt32 uNbSymbol);
Bool Tda10086InitTick (tm10086object_t *psObject, UInt16 wTime);
Bool Tda10086WaitTick (tm10086object_t *psObject);
//-----------------------------------------------------------------------------
// Exported functions:
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
// Initialization functions:
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
// FUNCTION: tmbsl10086Init:
//
// DESCRIPTION: create an instance of a TDA10086 demodulator
//
// RETURN: TMBSL_ERR_DEMOD_BAD_UNIT_NUMBER
// TMBSL_ERR_DEMOD_NOT_INITIALIZED
// TM_OK
//
// NOTES:
//-----------------------------------------------------------------------------
//
tmErrorCode_t
tmbsl10086Init(
tmUnitSelect_t demodUnit, // I: Demodulator unit number
tmbslDsParam_t sParam // I: setup parameters
)
{
//----------------------
// test input parameters
//----------------------
// test the max number
if (demodUnit > TDA10086_MAX_UNITS)
return TMBSL_ERR_DEMOD_BAD_UNIT_NUMBER;
// return if already initialized
if(g10086Instance[demodUnit].Init == True)
return TMBSL_ERR_DEMOD_NOT_INITIALIZED;
//----------------
// init the object
//----------------
// initialize the object
g10086Instance[demodUnit].Init = True;
g10086Instance[demodUnit].uDemodHwAdd = sParam.uHwAddress;
g10086Instance[demodUnit].systemFunc = sParam.systemFunc;
g10086Instance[demodUnit].tunerFunc = sParam.tunerFunc;
g10086Instance[demodUnit].eTunerUnit = sParam.eTunerUnit;
// call init function here to prevent calling SetConfig if the default values are OK
return Tda10086WriteInit(&g10086Instance[demodUnit]);
}
//-----------------------------------------------------------------------------
// FUNCTION: tmbsl10086DeInit:
//
// DESCRIPTION: destroy an instance of a TDA10086 tuner
//
// RETURN: TMBSL_ERR_DEMOD_BAD_UNIT_NUMBER
// TMBSL_ERR_DEMOD_NOT_INITIALIZED
// TM_OK
//
// NOTES:
//-----------------------------------------------------------------------------
//
tmErrorCode_t
tmbsl10086DeInit (
tmUnitSelect_t demodUnit // I: Demod unit number
)
{
//----------------------
// test input parameters
//----------------------
// test the instance number
if (demodUnit > TDA10086_MAX_UNITS)
return TMBSL_ERR_DEMOD_BAD_UNIT_NUMBER;
// test the object
if (g10086Instance[demodUnit].Init == False)
return TMBSL_ERR_DEMOD_NOT_INITIALIZED;
//-------------------------
// De-initialize the object
//-------------------------
g10086Instance[demodUnit].Init = False;
return TM_OK;
}
//-----------------------------------------------------------------------------
// FUNCTION: tmbsl10086GetSWVersion:
//
// DESCRIPTION: Return the version of this device
//
// RETURN: TM_OK
//
// NOTES: Values defined in the tmbsl10086local.h file
//-----------------------------------------------------------------------------
//
tmErrorCode_t
tmbsl10086GetSWVersion (
ptmSWVersion_t pSWVersion // O: Receives SW Version
)
{
pSWVersion->compatibilityNr = TDA10086_BSL_COMP_NUM;
pSWVersion->majorVersionNr = TDA10086_BSL_MAJOR_VER;
pSWVersion->minorVersionNr = TDA10086_BSL_MINOR_VER;
return TM_OK;
}
//-----------------------------------------------------------------------------
// Configuration functions:
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
// FUNCTION: tmbsl10086SetPowerState:
//
// DESCRIPTION: Set the power state of the 10086
//
// RETURN: TMBSL_ERR_DEMOD_BAD_UNIT_NUMBER
// TMBSL_ERR_DEMOD_NOT_INITIALIZED
// TM_ERR_IIC_ERR
// TM_OK
//
// NOTES:
//-----------------------------------------------------------------------------
//
tmErrorCode_t
tmbsl10086SetPowerState(
tmUnitSelect_t demodUnit, // I: demodUnit number
tmPowerState_t ePowerState // I: Power state of the device
)
{
UInt32 uByte;
//----------------------
// test input parameters
//----------------------
// test the instance number
if (demodUnit > TDA10086_MAX_UNITS)
return TMBSL_ERR_DEMOD_BAD_UNIT_NUMBER;
// test the object
if (g10086Instance[demodUnit].Init == False)
return TMBSL_ERR_DEMOD_NOT_INITIALIZED;
//----------------------
// Core function
//----------------------
switch (ePowerState)
{
case tmPowerStandby:
uByte = TDA10086_CLEAR_STDBY_MSK;
break;
case tmPowerOn:
uByte = 0;
break;
}
if (g10086Instance[demodUnit].systemFunc.SY_WriteBit(
g10086Instance[demodUnit].uDemodHwAdd,
TDA10086_CLEAR_IND,
TDA10086_CLEAR_STDBY_MSK,
uByte) != 1)
return TM_ERR_IIC_ERR;
return TM_OK;
}
//-----------------------------------------------------------------------------
// FUNCTION: tmbsl10086GetPowerState:
//
// DESCRIPTION: Get the power state of the 10086
//
// RETURN: TMBSL_ERR_DEMOD_BAD_UNIT_NUMBER
// TMBSL_ERR_DEMOD_NOT_INITIALIZED
// TM_ERR_IIC_ERR
// TM_OK
//
// NOTES:
//-----------------------------------------------------------------------------
//
tmErrorCode_t
tmbsl10086GetPowerState(
tmUnitSelect_t demodUnit, // I: demodUnit number
ptmPowerState_t pPowerState // O: Receives current power state
)
{
UInt32 uByte;
//----------------------
// test input parameters
//----------------------
// test the instance number
if (demodUnit > TDA10086_MAX_UNITS)
return TMBSL_ERR_DEMOD_BAD_UNIT_NUMBER;
// test the object
if (g10086Instance[demodUnit].Init == False)
return TMBSL_ERR_DEMOD_NOT_INITIALIZED;
//----------------------
// Core function
//----------------------
if (g10086Instance[demodUnit].systemFunc.SY_Read(
g10086Instance[demodUnit].uDemodHwAdd,
TDA10086_CLEAR_IND,
1,
&uByte) != 1)
return TM_ERR_IIC_ERR;
if (uByte & TDA10086_CLEAR_STDBY_MSK)
*pPowerState = tmPowerStandby;
else
*pPowerState = tmPowerOn;
return TM_OK;
}
//-----------------------------------------------------------------------------
// FUNCTION: tmbsl10086SetConfig:
//
// DESCRIPTION: Set the config of the 10086
//
// RETURN: TMBSL_ERR_DEMOD_BAD_UNIT_NUMBER
// TMBSL_ERR_DEMOD_NOT_INITIALIZED
// TM_ERR_NOT_SUPPORTED
// TM_ERR_BAD_PARAMETER
// TM_OK
//
// NOTES: The item id are defined in the tmbsl10086local.h
// The item id 0 (board) will set the entire config value for the
// specified board.
//-----------------------------------------------------------------------------
//
tmErrorCode_t
tmbsl10086SetConfig(
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
)
{
//----------------------
// test input parameters
//----------------------
// test the instance number
if (demodUnit > TDA10086_MAX_UNITS)
return TMBSL_ERR_DEMOD_BAD_UNIT_NUMBER;
// test the object
if (g10086Instance[demodUnit].Init == False)
return TMBSL_ERR_DEMOD_NOT_INITIALIZED;
//--------------
// set the value
//--------------
switch((tm10086cfgIndex_t)uItemId)
{
// Board config
case BOARD:
// default hardware config
g10086Instance[demodUnit].sConfig.uXtall = OM57XX_XTAL_DEF;
g10086Instance[demodUnit].sConfig.bPLL_M_Factor = OM57XX_PLLMFACTOR_DEF;
g10086Instance[demodUnit].sConfig.bPLL_P_Factor = OM57XX_PLLPFACTOR_DEF;
g10086Instance[demodUnit].sConfig.bBerDepth = OM57XX_BERDEPTH_DEF;
g10086Instance[demodUnit].sConfig.bSearchRange = OM57XX_SEARCHRANGE_DEF;
g10086Instance[demodUnit].sConfig.bPolaAGC = OM57XX_POLAGC_DEF;
g10086Instance[demodUnit].sConfig.bIQ_Swapped = OM57XX_IQSWAPPED_DEF;
g10086Instance[demodUnit].sConfig.bOUT1_ModeABC = OM57XX_MODEABC1_DEF;
g10086Instance[demodUnit].sConfig.bOUT1_ParaSer = OM57XX_PARASER1_DEF;
g10086Instance[demodUnit].sConfig.bOUT1_POClk = OM57XX_POCLK1_DEF;
g10086Instance[demodUnit].sConfig.bOUT1_MSBFirst = OM57XX_MSBFIRST1_DEF;
g10086Instance[demodUnit].sConfig.bOUT1_ParBDiv = OM57XX_PARBDIV1_DEF;
g10086Instance[demodUnit].sConfig.bOUT2_ModeAB = OM57XX_MODEAB2_DEF;
g10086Instance[demodUnit].sConfig.bOUT2_POClk = OM57XX_POCLK2_DEF;
g10086Instance[demodUnit].sConfig.bOUT2_MSBFirst = OM57XX_MSBFIRST2_DEF;
// specific soft config
// none
// specific board config
switch (uValue & 0xffff0000)
{
case OM5751_BOARD_DEF:
case OM5752_BOARD_DEF:
g10086Instance[demodUnit].sConfig.bIQ_Swapped = 1;
break;
case OM5756_BOARD_DEF:
g10086Instance[demodUnit].sConfig.bIQ_Swapped = 0;
break;
case CUSTOM_BOARD_DEF:
// do nothing more than setting the default values
break;
default:
// board not supported
return TM_ERR_NOT_SUPPORTED;
}
// store board
g10086Instance[demodUnit].sConfig.uBoard = uValue;
break;
case DSSDVB:
g10086Instance[demodUnit].sConfig.bDSS_DVB = (UInt8)uValue;
break;
case XTALL:
g10086Instance[demodUnit].sConfig.uXtall = uValue;
break;
case PLLMFACTOR:
g10086Instance[demodUnit].sConfig.bPLL_M_Factor = (UInt8)uValue;
break;
case PLLPFACTOR:
g10086Instance[demodUnit].sConfig.bPLL_P_Factor = (UInt8)uValue;
break;
case BERDEPTH:
g10086Instance[demodUnit].sConfig.bBerDepth = (UInt8)uValue;
break;
case SEARCHRANGE:
g10086Instance[demodUnit].sConfig.bSearchRange = (UInt8)uValue;
break;
case POLAAGC:
g10086Instance[demodUnit].sConfig.bPolaAGC = (UInt8)uValue;
break;
case IQSWAPPED:
g10086Instance[demodUnit].sConfig.bIQ_Swapped = (UInt8)uValue;
break;
case OUT1MODEABC:
g10086Instance[demodUnit].sConfig.bOUT1_ModeABC = (UInt8)uValue;
break;
case OUT1PARASER:
g10086Instance[demodUnit].sConfig.bOUT1_ParaSer = (UInt8)uValue;
break;
case OUT1POCLK:
g10086Instance[demodUnit].sConfig.bOUT1_POClk = (UInt8)uValue;
break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -