tcmu30311.h
上传用户:fy98168
上传日期:2015-06-26
资源大小:13771k
文件大小:16k
- #ifndef _TCMU30311_H_
- #define _TCMU30311_H_
- #include "gendef.h"
- #include <string.h>
- #include "dmd.h"
- //#define FALSE 0
- //#define TRUE 1
- #define NBPARAM 50
- #define NBREG 86 // papi 86
- #define NBFIELD 188
- #define SET 0
- #define GET 1
- #define NOCHANGE 0
- #define END 0
- #define ON 1
- #define OFF 0
- #define UNSIGNED 0
- #define SIGNED 1
- /*********** Register structure definition ******************************/
- typedef enum {NO = 0, YES = 1, AUTO = 2} FLAG_SAM ; /*version 3p8 */
- /*********** Signal structure *************************************/
- typedef struct
- {
- INT32 Frequency ; /* carrier frequency (in Hz) */
- UINT32 SymbolRate; /* Symbol Rate (in Baud) */
- INT32 QAMSize; /* QAM size (16/32/64/128/256) */
- } SIGNAL;
- /*********** Register structure *************************************/
- typedef struct
- {
- UINT8 Addr, //Address
- Reset, //Default value
- Value, //Current value
- Store; //Stored value
- char Name[30]; //Name
- } REGISTER;
- typedef struct
- {
- INT32 Reg; //Register index
- UINT8 Pos, //Bit position
- Bits, //Bit width
- Type, //Signed or unsigned
- Mask; //Mask compute with width and position
- char Name[30]; //Name
- } FIELD;
- // REGISTERS
- //
- #define EQU_0 0
- #define EQU_1 1
- #define EQU_3 2
- #define EQU_4 3
- #define EQU_7 4
- #define EQU_8 5
- #define INITDEM_0 6
- #define INITDEM_1 7
- #define INITDEM_2 8
- #define INITDEM_3 9
- #define INITDEM_4 10
- #define INITDEM_5 11
- #define DELAGC_0 12
- #define DELAGC_1 13
- #define DELAGC_2 14
- #define DELAGC_3 15
- #define DELAGC_4 16
- #define DELAGC_5 17
- #define DELAGC_6 18
- #define DELAGC_7 19
- #define DELAGC_8 20
- #define WBAGC_0 21
- #define WBAGC_1 22
- #define WBAGC_2 23
- #define WBAGC_3 24
- #define WBAGC_4 25
- #define WBAGC_5 26
- #define WBAGC_6 27
- #define WBAGC_9 28
- #define WBAGC_10 29
- #define WBAGC_11 30
- #define STLOOP_2 31
- #define STLOOP_3 32
- #define STLOOP_5 33
- #define STLOOP_6 34
- #define STLOOP_7 35
- #define STLOOP_8 36
- #define STLOOP_9 37
- #define STLOOP_10 38
- #define STLOOP_11 39
- #define CRL_0 40
- #define CRL_1 41
- #define CRL_2 42
- #define CRL_3 43
- #define CRL_4 44
- #define CRL_5 45
- #define CRL_6 46
- #define CRL_7 47
- #define CRL_8 48
- #define CRL_9 49
- #define CRL_10 50
- #define CRL_11 51
- #define PMFAGC_0 52
- #define PMFAGC_1 53
- #define PMFAGC_2 54
- #define PMFAGC_3 55
- #define PMFAGC_4 56
- #define CTRL_0 57
- #define CTRL_1 58
- #define CTRL_2 59
- #define CTRL_3 60
- #define CTRL_4 61
- #define CTRL_5 62
- #define CTRL_6 63
- #define CTRL_7 64
- #define CTRL_8 65
- #define CTRL_9 66
- #define DEINT_SYNC_0 67
- #define DEINT_SYNC_1 68
- #define BERT_0 69
- #define BERT_1 70
- #define BERT_2 71
- #define DEINT_0 72
- #define DEINT_1 73
- #define OUTFORMAT_0 74
- #define OUTFORMAT_1 75
- #define OUTFORMAT_2 76
- #define RS_DESC_0 77
- #define RS_DESC_1 78
- #define RS_DESC_2 79
- #define RS_DESC_3 80
- #define RS_DESC_4 81
- #define RS_DESC_5 82
- #define RS_DESC_14 83
- #define RS_DESC_15 84
- // Test registers
- #define TST_EQU_2 85
- // FIELDS
- //
- #define U_THRESHOLD 0
- #define MODE_SELECT 1
- #define BLIND_U 2
- #define INITIAL_U 3
- #define EQ_FSM_CTL 4
- #define EQ_COEFF_CTL 5
- #define NBLIND 6
- #define NOISE_EST_LO 7
- #define NOISE_EST_HI 8
- #define DEM_FQCY_LO 9
- #define DEM_FQCY_HI 10
- #define LATENCY 11
- #define SCAN_STEP_LO 12
- #define CHSCANITEN 13
- #define CHSCANITSOFT 14
- #define SCAN_STEP_HI 15
- #define IN_DEMOD_EN 16
- #define SCAN_ON 17
- #define AUTOSTOP 18
- #define SCALE_A 19
- #define SCALE_B 20
- #define AGC2MAX 21
- #define AGC2MIN 22
- #define AGC1MAX 23
- #define AGC1MIN 24
- #define RATIO_A 25
- #define RATIO_B 26
- #define RATIO_C 27
- #define AGC2_THRES 28
- #define DAGC_ON 29
- #define FRZ2_CTRL 30
- #define FRZ1_CTRL 31
- #define TIME_CST 32
- #define OVF_RATE_LO 33
- #define CORNER_RATE_LO 34
- #define OVF_RATE_HI 35
- #define CORNER_RATE_HI 36
- #define I_REF 37
- #define AGC2SD_LO 38
- #define AGC2SD_HI 39
- #define ACQ_THRESH 40
- #define WAGC_CLR 41
- #define WAGC_INV 42
- #define WAGC_EN 43
- #define WAGC_ACQ 44
- #define SWAP 45
- #define ROLL_LO 46
- #define ACQ_COUNT_LO 47
- #define ACQ_COUNT_HI 48
- #define ROLL_HI 49
- #define IF_PWM_LO 50
- #define TARGET_RATE_LO 51
- #define IF_PWM_HI 52
- #define TARGET_RATE_HI 53
- #define GAIN_SCALE_PATH0 54
- #define GAIN_SCALE_PATH1 55
- #define INTEGRAL_GAIN_HI 56
- #define DIRECT_GAIN_LO 57
- #define SYMB_RATE_0 58
- #define SYMB_RATE_1 59
- #define SYMB_RATE_2 60
- #define SYMB_RATE_3 61
- #define INTEGRAL_GAIN_LO 62
- #define DIRECT_GAIN_HI 63
- #define PHASE_EN 64
- #define PHASE_CLR 65
- #define ERR_RANGE 66
- #define ALGOSEL 67
- #define ERR_CLR 68
- #define ERR_EN 69
- #define SWEEP_LO 70
- #define GAIN_INT 71
- #define GAIN_DIR 72
- #define GAIN_INT_ADJ 73
- #define GAIN_DIR_ADJ 74
- #define APHASE_0 75
- #define APHASE_1 76
- #define APHASE_2 77
- #define IPHASE_0 78
- #define IPHASE_1 79
- #define IPHASE_2 80
- #define IPHASE_3 81
- #define SWEEP_HI 82
- #define SWEEP_EN 83
- #define PH_EN 84
- #define DIR_EN 85
- #define INT_EN 86
- #define DIR_DIS 87
- #define INT_DIS 88
- #define CRL_SNAPSHOT 89
- #define LOCK_THRES_LO 90
- #define PMFA_F_UNLOCK 91
- #define PMFA_F_LOCK 92
- #define WBAGC_F_LOCK 93
- #define UP_STOP 94
- #define LOCK_THRES_HI 95
- #define PMFA_ACC0 96
- #define PMFA_ACC1 97
- #define PMFA_LOCK_STATE 98
- #define PMFA_ACC2 99
- #define SOFT_RESET 100
- #define VERSION 101
- #define RESET_DI 102
- #define RS_UNCORR 103
- #define CORNER_LOCK 104
- #define EQU_LMS2 105
- #define EQU_LMS1 106
- #define PMFAGC_IT 107
- #define WBAGC_IT 108
- #define J83C 109
- #define DFS 110
- #define SPEC_INV 111
- #define RESET_RS 112
- #define RESET_EQL 113
- #define CKX2SEL 114
- #define CKX2DIS 115
- #define INVADCLK 116
- #define M_OEN 117
- #define AGC_OD 118
- #define LOCKPOL 119
- #define DY_SY_MASK 120
- #define DY_SY_EV 121
- #define DY_SY_DIR 122
- #define SYNC_MSK 123
- #define SYNC_EV 124
- #define SYNC_DIR 125
- #define I2CT_EN 126
- #define SCLT_OD 127
- #define EXTADCLK_EN 128
- #define ITLOCKSEL 129
- #define ITPWMSEL 130
- #define LOCKSCE 131
- #define TWB_ACT 132
- #define SOURCESEL 133
- #define PRGCLKDIV 134
- #define AUXCLKSEL 135
- #define ITLOCK_OD 136
- #define ITPWM_OD 137
- #define AGC12SEL 138
- #define AGC12B_EN 139
- #define SIGMA_INV_1 140
- #define SIGMA_INV_2 141
- #define AUTOQAMMODE_SEL 142
- #define AUTOCONSTEL_TIMER 143
- #define AUTOSTOP_CONSTEL 144
- #define AUTOCONSTEL_ON 145
- #define DI_UNLOCK 146
- #define DI_FREEZE 147
- #define MISMATCH 148
- #define ACQ_MODE 149
- #define TRKMODE 150
- #define SYNLOST 151
- #define BERT_ON 152
- #define ERR_SOURCE 153
- #define ERR_MODE 154
- #define NBYTE 155
- #define ERRCOUNT_LO 156
- #define ERRCOUNT_HI 157
- #define USEINT 158
- #define DAVIC 159
- #define M 160
- #define DEPTH 161
- #define REFRESH47 162
- #define BE_BYPASS 163
- #define CKOUTPAR 164
- #define CT_NBST 165
- #define S_NP 166
- #define TEI_ENA 167
- #define DS_ENA 168
- #define SYNC_STRIP 169
- #define CI_EN 170
- #define CICLK_POL 171
- #define CICLK_BASE 172
- #define CI_DIVRANGE 173
- #define BK_CT_LO 174
- #define BK_CT_HI 175
- #define CORR_CT_LO 176
- #define CORR_CT_HI 177
- #define UNCORR_CT_HI 178
- #define UNCORR_CT_LO 179
- #define DIS_UNLOCK 180
- #define MODE 181
- #define CT_CLEAR 182
- #define CT_HOLD 183
- #define RS_NOCORR 184
- #define SYNCSTATE 185
- #define EN_CORNER_DET 186
- #define TEST_SEL 187
- #define IIC_ADDR_NIM_30311 (0x38) // 定义TCMU30311的IIC地址
- #define IIC_TUNER_ADDRESS_SAM (0xc2) // samsung tuner IIC地址
- #define IIC_TUNER_ADDRESS_TH (0xc0) // Thomson tuner IIC地址
- //QAM 定义
- #define SAM_QAM16 0
- #define SAM_QAM32 1
- #define SAM_QAM64 4
- #define SAM_QAM128 2
- #define SAM_QAM256 3
- //定义STV0297的寄存器
- #define STV_EQU_0 0x00
- #define STV_EQU_1 0x01
- #define STV_EQU_2 0x02
- #define STV_EQU_3 0x03
- #define STV_EQU_4 0x04
- #define STV_EQU_5 0x05
- #define STV_EQU_6 0x06
- #define STV_EQU_7 0x07
- #define STV_EQU_8 0x08
- #define STV_INITDEM_0 0x20
- #define STV_INITDEM_1 0x21
- #define STV_INITDEM_2 0x22
- #define STV_INITDEM_3 0x23
- #define STV_INITDEM_4 0x24
- #define STV_INITDEM_5 0x25
- #define STV_DELAGC_0 0x30
- #define STV_DELAGC_1 0x31
- #define STV_DELAGC_2 0x32
- #define STV_DELAGC_3 0x33
- #define STV_DELAGC_4 0x34
- #define STV_DELAGC_5 0x35
- #define STV_DELAGC_6 0x36
- #define STV_DELAGC_7 0x37
- #define STV_DELAGC_8 0x38
- #define STV_WBAGC_0 0x40
- #define STV_WBAGC_1 0x41
- #define STV_WBAGC_2 0x42
- #define STV_WBAGC_3 0x43
- #define STV_WBAGC_4 0x44
- #define STV_WBAGC_5 0x45
- #define STV_WBAGC_6 0x46
- #define STV_WBAGC_9 0x49
- #define STV_WBAGC_10 0x4a
- #define STV_WBAGC_11 0x4b
- #define STV_STLOOP_2 0x52
- #define STV_STLOOP_3 0x53
- #define STV_STLOOP_5 0x55
- #define STV_STLOOP_6 0x56
- #define STV_STLOOP_7 0x57
- #define STV_STLOOP_8 0x58
- #define STV_STLOOP_9 0x59
- #define STV_STLOOP_10 0x5a
- #define STV_STLOOP_11 0x5b
- #define STV_CRL_0 0x60
- #define STV_CRL_1 0x61
- #define STV_CRL_2 0x62
- #define STV_CRL_3 0x63
- #define STV_CRL_4 0x64
- #define STV_CRL_5 0x65
- #define STV_CRL_6 0x66
- #define STV_CRL_7 0x67
- #define STV_CRL_8 0x68
- #define STV_CRL_9 0x69
- #define STV_CRL_10 0x6a
- #define STV_CRL_11 0x6b
- #define STV_PMFAGC_0 0x70
- #define STV_PMFAGC_1 0x71
- #define STV_PMFAGC_2 0x72
- #define STV_PMFAGC_3 0x73
- #define STV_PMFAGC_4 0x74
- #define STV_CTRL_0 0x80
- #define STV_CTRL_1 0x81
- #define STV_CTRL_2 0x82
- #define STV_CTRL_3 0x83
- #define STV_CTRL_4 0x84
- #define STV_CTRL_5 0x85
- #define STV_CTRL_6 0x86
- #define STV_CTRL_7 0x87
- #define STV_CTRL_8 0x88
- #define STV_CTRL_9 0x89
- #define STV_DEINT_SYNC_0 0x90
- #define STV_DEINT_SYNC_1 0x91
- #define STV_BERT_0 0xa0
- #define STV_BERT_1 0xa1
- #define STV_BERT_2 0xa2
- #define STV_DEINT_0 0xb0
- #define STV_DEINT_1 0xb1
- #define STV_DEINT_2 0xb2
- #define STV_DEINT_3 0xb3
- #define STV_OUTFORMAT_0 0xc0
- #define STV_OUTFORMAT_1 0xc1
- #define STV_OUTFORMAT_2 0xc2
- #define STV_RS_DESC_0 0xd0
- #define STV_RS_DESC_1 0xd1
- #define STV_RS_DESC_2 0xd2
- #define STV_RS_DESC_3 0xd3
- #define STV_RS_DESC_4 0xd4
- #define STV_RS_DESC_5 0xd5
- #define STV_RS_DESC_14 0xde
- #define STV_RS_DESC_15 0xdf
- //操作SAM1216的函数
- UINT8 SAMRevision(void);
- void SAMInit(KB_DMDTunerParameters *pParam);
- INT32 SAMCheckLock(void);
- void SAMReset(void);
- void SAMResetAll(void);
- void QAMHandleTimeout2(void);
- INT32 SAMWriteReg(UINT32 whichReg,UINT32 writeValue);
- INT32 SAMStartConnect(void);
- void SAMStopConnect(void);
- void SAMSetQAMMode(UINT8 qammode);
- UINT32 SAMSignalVAGC(void);
- INT32 SAMCalSAMlateVAFC(void);
- UINT32 SAMReadSCOffset(void);
- UINT8 SAMReadUncor(void);
- //操作TUNER的函数
- void SAMEnableIICTuner(void);
- void SAMDisableIICTuner(void);
- INT32 SAMWriteTunerReg(UINT8 *cont,UINT8 DEMOD_ADD);
- INT32 SAMSetTunerFrequency(UINT32 frequency);
- void samDelay(int n);
- UINT8 FieldCreateMask(INT32 field);
- void RegSetOneRegister(INT32 reg_id, UINT8 Data);
- INT32 RegGetOneRegister(INT32 reg_id);
- void FieldSetVal(INT32 field, INT32 fieldval);
- void RegSetField(INT32 field,INT32 value);
- INT32 FieldGetVal(INT32 field);
- INT32 RegGetField(INT32 field);
- void QAM64_RegInit(void);
- void QAM64_Regreset(void);
- void QAM256_Regreset(void);
- void RegSTV0297reset(void);
- void RegResetAfterDI(void);
- void RegSetQAMSize(INT32 _QAMSize);
- INT32 RegGetQAMSize(void);
- INT32 RegGetSymbolRate(void);
- void RegSetSymbolRate(INT32 _SymbolRate);
- INT32 RegGetSweepRate(void);
- void RegSetSweepRate(INT16 _FShift);
- INT32 RegGetCarrierOffset(void);
- void Driv0297Init(void);
- void Driv0297DemodSetting(INT32 _Offset);
- FLAG_SAM Driv0297DataSearch(SIGNAL *_pSignal, INT32 _SweepRate, INT32 _CarrierOffset,
- FLAG_SAM _SpectrumInversion, INT32 _InitDemodOffset);
- FLAG_SAM Driv0297CarrierSearch(SIGNAL *_pSignal, FLAG_SAM _SpectrumInversion,
- INT32 _SweepRate, INT32 _CarrierOffset);
- void CarrierStatusSetAcquisitionStatus(void);
- FLAG_SAM Acquisition(float _Freq1, UINT32 _SymbolRate,
- INT32 _QAMSize, FLAG_SAM _SpectrumInversion);
- void QAM_Init(void);
- INT16 Check_Lock(void);
- void RegReset(void);
- void LoadRegisters(void);
- void RegStoreValue(void);
- INT32 RegSearchAddress(INT32 _Address);
- void RegReloadValue(void);
- UINT32 SAMReadNoise(void);
- UINT32 SAMReadBER(void);
- INT32 QamagcToDbuv(UINT32 nQamagc);
- void init_RF_Level(void);
- boolean Check_Signal_Strenth_Quality(int *Signal_Strengh,int *Signal_Quality);
- INT32 SAMDetect(UINT16 addr);
- #endif /* #ifdef _TCMU30311_H_ */