📄 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 "tmbslDemodSat.h"
#include <stdlib.h> // for malloc in Tda10086StartPreScan()
//-----------------------------------------------------------------------------
// Project include files:
//-----------------------------------------------------------------------------
//
#include "tmbsl10086local.h"
#include "tmbsl10086scanauto.h"
#ifndef _WIN32
#include "dv_dbg.h"
#endif
//-----------------------------------------------------------------------------
// Types and defines:
//-----------------------------------------------------------------------------
//
// remove comments to find all channels but with long scanning time
//#define FIND_BAD_CHANNELS
#define NTHR 225
#define NEST_THR 220
#define TRACE_BLUE 0
#define TRACE_RED 1
#define TRACE_GREEN 2
#define DISPLAY_STEP 250000
#define FREQ2INDEX(x) ((x+(DISPLAY_STEP/2))/DISPLAY_STEP)
//-----------------------------------------------------------------------------
// Global data:
//-----------------------------------------------------------------------------
//
UInt32 StartTime = 0;
UInt32 StopTime = 0;
Int32 RFMinMargin;
Int32 RFMaxMargin;
Int32 SRMinMargin;
Int32 SRMaxMargin;
Int32 WorstRFMinMargin = 255;
Int32 WorstRFMaxMargin = 255;
Int32 WorstSRMinMargin = 255;
Int32 WorstSRMaxMargin = 255;
Int32 CarlockOnes;
Int32 CarlockZeros;
Bool bAutoScan = False;
Bool bAutoScanReallyStarted = False;
//-----------------------------------------------------------------------------
// Global data:
//-----------------------------------------------------------------------------
//
tm10086object_t g10086Instance[] =
{
{
(Bool)False, // True:instance is initialized
(UInt32)0, // Demod Hw Address not set
(tmUnitSelect_t)0, // Tuner unit not set
{ Null, Null, Null, // Demod system function not initialized
Null, Null, Null
},
{ Null, Null, Null, // BSL tuner function not initialized
Null, Null, Null,
Null, Null, Null,
Null, Null, Null
},
{
(UInt32)0, // Channel structure not initialized
(UInt32)0,
(tmhalFESpectrum_t)0,
(tmhalFEModulation_t)0,
(tmhalFEDepuncRate_t)0,
(UInt8)0,
(UInt16)0,
(tmhalFEToneBurst_t)0,
(UInt8)0,
(UInt8)0
},
{ OM5751_BOARD_DEF, // Default configuration structure
OM57XX_DSSDVB_DEF,
OM57XX_XTAL_DEF,
OM57XX_PLLMFACTOR_DEF,
OM57XX_PLLPFACTOR_DEF,
OM57XX_BERDEPTH_DEF,
OM57XX_SEARCHRANGE_DEF,
OM57XX_POLAGC_DEF,
OM57XX_IQSWAPPED_DEF,
OM57XX_MODEABC1_DEF,
OM57XX_PARASER1_DEF,
OM57XX_POCLK1_DEF,
OM57XX_MSBFIRST1_DEF,
OM57XX_PARBDIV1_DEF,
OM57XX_MODEAB2_DEF,
OM57XX_POCLK2_DEF,
OM57XX_MSBFIRST2_DEF,
OM57XX_ZIFTUNER_DEF,
OM57XX_STARTSR_DEF,
OM57XX_STOPSR_DEF,
OM57XX_SRMAXMARGIN_DEF,
OM57XX_SRMINMARGIN_DEF,
OM57XX_DELTATHRESHOLD_DEF
},
{ 0, 0, 0, 0 // api status structure not initialized
},
{ 0, 0 // demod status structure not initialized
},
{ 0, 0 // freq search structure not initialized
},
950000000, // start scanning frequency
2150000000, // stop scanning frequency
0, // system clock
0, // startAlgo OFF
0, // state of the main algo
0, // state of the RF algo
TDA10086_SR_MAX, // start symbol rate
TDA10086_SR_MIN, // stop symbol rate
0, // number of samples
0, // pointer on the buffer for derivation
0, // counter
0, // number of Region
0, // pointer on the buffer for Region
0, // state of the spectrum analyzer algo
0, // pointer on the buffer for spectrum analyzer
0, // Graph Position
0 // tick for the end of the timer
}
};
//-----------------------------------------------------------------------------
// Internal Prototypes:
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
// 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
//----------------
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.
//-----------------------------------------------------------------------------
//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -