⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mt2063.c

📁 microtune 公司 硅高频头 源码
💻 C
📖 第 1 页 / 共 5 页
字号:
/*********************************************************************************  Name: mt2063.c****  Copyright 2007 Microtune, Inc. All Rights Reserved****  This source code file contains confidential information and/or trade**  secrets of Microtune, Inc. or its affiliates and is subject to the**  terms of your confidentiality agreement with Microtune, Inc. or one of**  its affiliates, as applicable.*******************************************************************************//*********************************************************************************  Name: mt2063.c****  Description:    Microtune MT2063 B0 & B1 Tuner software interface**                  Supports tuners with Part/Rev code: 0x9B and 0x9C.****  Functions**  Implemented:    UData_t  MT2063_Open**                  UData_t  MT2063_Close**                  UData_t  MT2063_ClearPowerMaskBits**                  UData_t  MT2063_GetGPIO**                  UData_t  MT2063_GetLocked**                  UData_t  MT2063_GetParam**                  UData_t  MT2063_GetPowerMaskBits**                  UData_t  MT2063_GetReg**                  UData_t  MT2063_GetTemp**                  UData_t  MT2063_GetUserData**                  UData_t  MT2063_ReInit**                  UData_t  MT2063_SetGPIO**                  UData_t  MT2063_SetParam**                  UData_t  MT2063_SetPowerMaskBits**                  UData_t  MT2063_SetReg**                  UData_t  MT2063_Tune****  References:     AN-xxxxx: MT2063 Programming Procedures Application Note**                  MicroTune, Inc.**                  AN-00010: MicroTuner Serial Interface Application Note**                  MicroTune, Inc.****  Exports:        None****  Dependencies:   MT_ReadSub(hUserData, IC_Addr, subAddress, *pData, cnt);**                  - Read byte(s) of data from the two-wire bus.****                  MT_WriteSub(hUserData, IC_Addr, subAddress, *pData, cnt);**                  - Write byte(s) of data to the two-wire bus.****                  MT_Sleep(hUserData, nMinDelayTime);**                  - Delay execution for nMinDelayTime milliseconds****  CVS ID:         $Id: mt2063.c,v 1.2 2008/01/16 12:09:53 software Exp $**  CVS Source:     $Source: /export/home/cvsroot/software/tuners/MT2063/mt2063.c,v $****  Revision History:****   SCR      Date      Author  Description**  -------------------------------------------------------------------------**   138   06-19-2007    DAD    Ver 1.00: Initial, derived from mt2067_b.**   N/A   08-01-2007    PINZ   Ver 1.01: Changed Analog &DVB-T settings and added**                                        SAW-less receiver mode.**   148   09-04-2007    RSK    Ver 1.02: Corrected logic of Reg 3B Reference**   153   09-07-2007    RSK    Ver 1.03: Lock Time improvements**   150   09-10-2007    RSK    Ver 1.04: Added GetParam/SetParam support for**                                        LO1 and LO2 freq for PHY-21 cal.**   154   09-13-2007    RSK    Ver 1.05: Get/SetParam changes for LOx_FREQ**   155   10-01-2007    DAD    Ver 1.06: Add receiver mode for SECAM positive**                                        modulation**                                        (MT2063_ANALOG_TV_POS_NO_RFAGC_MODE)**   N/A   10-22-2007    PINZ   Ver 1.07: Changed some Registers at init to have **                                        the same settings as with MT Launcher **   N/A   10-30-2007    PINZ             Add SetParam VGAGC & VGAOI**                                        Add SetParam DNC_OUTPUT_ENABLE**                                        Removed VGAGC from receiver mode, **                                        default now 1 **   N/A   10-31-2007    PINZ   Ver 1.08: Add SetParam TAGC, removed from rcvr-mode**                                        Add SetParam AMPGC, removed from rcvr-mode**                                        Corrected names of GCU values**                                        reorganized receiver modes, removed, **                                        (MT2063_ANALOG_TV_POS_NO_RFAGC_MODE)**                                        Actualized Receiver-Mode values**   N/A   11-12-2007    PINZ   Ver 1.09: Actualized Receiver-Mode values**   N/A   11-27-2007    PINZ             Improved buffered writing**         01-03-2008    PINZ   Ver 1.10: Added a trigger of BYPATNUP for **                                        correct wakeup of the LNA after shutdown**                                        Set AFCsd = 1 as default**                                        Changed CAP1sel default**         01-14-2008    PINZ   Ver 1.11: Updated gain settings*****************************************************************************/#include "mt2063.h"#include "mt_spuravoid.h"#include <stdlib.h>                     /*  for NULL      *//*  Version of this module                          */#define VERSION 10011             /*  Version 01.11 *//***  The expected version of MT_AvoidSpursData_t**  If the version is different, an updated file is needed from Microtune*//* Expecting version 1.20 of the Spur Avoidance API */#define EXPECTED_MT_AVOID_SPURS_INFO_VERSION  010200#if MT_AVOID_SPURS_INFO_VERSION < EXPECTED_MT_AVOID_SPURS_INFO_VERSION#error Contact Microtune for a newer version of MT_SpurAvoid.c#elif MT_AVOID_SPURS_INFO_VERSION > EXPECTED_MT_AVOID_SPURS_INFO_VERSION#error Contact Microtune for a newer version of mt2063.c#endif#ifndef MT2063_CNT#error You must define MT2063_CNT in the "mt_userdef.h" file#endiftypedef enum{    MT2063_SET_ATTEN,    MT2063_INCR_ATTEN,    MT2063_DECR_ATTEN} MT2063_ATTEN_CNTL_MODE;/***  Two-wire serial bus subaddresses of the tuner registers.**  Also known as the tuner's register addresses.*/static enum MT2063_Register_Offsets{    PART_REV = 0,   /*  0x00: Part/Rev Code         */    LO1CQ_1,        /*  0x01: LO1C Queued Byte 1    */    LO1CQ_2,        /*  0x02: LO1C Queued Byte 2    */    LO2CQ_1,        /*  0x03: LO2C Queued Byte 1    */    LO2CQ_2,        /*  0x04: LO2C Queued Byte 2    */    LO2CQ_3,        /*  0x05: LO2C Queued Byte 3    */    RSVD_06,        /*  0x06: Reserved              */    LO_STATUS,      /*  0x07: LO Status             */    FIFFC,          /*  0x08: FIFF Center           */    CLEARTUNE,      /*  0x09: ClearTune Filter      */    ADC_OUT,        /*  0x0A: ADC_OUT               */    LO1C_1,         /*  0x0B: LO1C Byte 1           */    LO1C_2,         /*  0x0C: LO1C Byte 2           */    LO2C_1,         /*  0x0D: LO2C Byte 1           */    LO2C_2,         /*  0x0E: LO2C Byte 2           */    LO2C_3,         /*  0x0F: LO2C Byte 3           */    RSVD_10,        /*  0x10: Reserved              */    PWR_1,          /*  0x11: PWR Byte 1            */    PWR_2,          /*  0x12: PWR Byte 2            */    TEMP_STATUS,    /*  0x13: Temp Status           */    XO_STATUS,      /*  0x14: Crystal Status        */    RF_STATUS,      /*  0x15: RF Attn Status        */    FIF_STATUS,     /*  0x16: FIF Attn Status       */    LNA_OV,         /*  0x17: LNA Attn Override     */    RF_OV,          /*  0x18: RF Attn Override      */    FIF_OV,         /*  0x19: FIF Attn Override     */    LNA_TGT,        /*  0x1A: Reserved              */    PD1_TGT,        /*  0x1B: Pwr Det 1 Target      */    PD2_TGT,        /*  0x1C: Pwr Det 2 Target      */    RSVD_1D,        /*  0x1D: Reserved              */    RSVD_1E,        /*  0x1E: Reserved              */    RSVD_1F,        /*  0x1F: Reserved              */    RSVD_20,        /*  0x20: Reserved              */    BYP_CTRL,       /*  0x21: Bypass Control        */    RSVD_22,        /*  0x22: Reserved              */    RSVD_23,        /*  0x23: Reserved              */    RSVD_24,        /*  0x24: Reserved              */    RSVD_25,        /*  0x25: Reserved              */    RSVD_26,        /*  0x26: Reserved              */    RSVD_27,        /*  0x27: Reserved              */    FIFF_CTRL,      /*  0x28: FIFF Control          */    FIFF_OFFSET,    /*  0x29: FIFF Offset           */    RSVD_2A,        /*  0x2A: Reserved              */    RSVD_2B,        /*  0x2B: Reserved              */    CTRL_2C,        /*  0x2C: Reserved              */    FIFF_CTRL2,     /*  0x2D: Fiff Control          */    RSVD_2E,        /*  0x2E: Reserved              */    DNC_GAIN,       /*  0x2F: DNC Control           */    VGA_GAIN,       /*  0x30: VGA Gain Ctrl         */    RSVD_31,        /*  0x31: Reserved              */    TEMP_SEL,       /*  0x32: Temperature Selection */    RSVD_33,        /*  0x33: Reserved              */    RSVD_34,        /*  0x34: Reserved              */    RSVD_35,        /*  0x35: Reserved              */    RSVD_36,        /*  0x36: Reserved              */    RSVD_37,        /*  0x37: Reserved              */    RSVD_38,        /*  0x38: Reserved              */    RSVD_39,        /*  0x39: Reserved              */    RSVD_3A,        /*  0x3A: Reserved              */    RSVD_3B,        /*  0x3B: Reserved              */    END_REGS};/*** Constants used by the tuning algorithm*/#define REF_FREQ          (16000000UL)  /* Reference oscillator Frequency (in Hz) */#define IF1_BW            (22000000UL)  /* The IF1 filter bandwidth (in Hz) */#define TUNE_STEP_SIZE       (50000UL)  /* Tune in steps of 50 kHz */#define SPUR_STEP_HZ        (250000UL)  /* Step size (in Hz) to move IF1 when avoiding spurs */#define ZIF_BW             (2000000UL)  /* Zero-IF spur-free bandwidth (in Hz) */#define MAX_HARMONICS_1         (15UL)  /* Highest intra-tuner LO Spur Harmonic to be avoided */#define MAX_HARMONICS_2          (5UL)  /* Highest inter-tuner LO Spur Harmonic to be avoided */#define MIN_LO_SEP         (1000000UL)  /* Minimum inter-tuner LO frequency separation */#define LO1_FRACN_AVOID          (0UL)  /* LO1 FracN numerator avoid region (in Hz) */#define LO2_FRACN_AVOID     (199999UL)  /* LO2 FracN numerator avoid region (in Hz) */#define MIN_FIN_FREQ      (44000000UL)  /* Minimum input frequency (in Hz) */#define MAX_FIN_FREQ    (1100000000UL)  /* Maximum input frequency (in Hz) */#define MIN_FOUT_FREQ     (36000000UL)  /* Minimum output frequency (in Hz) */#define MAX_FOUT_FREQ     (57000000UL)  /* Maximum output frequency (in Hz) */#define MIN_DNC_FREQ    (1293000000UL)  /* Minimum LO2 frequency (in Hz) */#define MAX_DNC_FREQ    (1614000000UL)  /* Maximum LO2 frequency (in Hz) */#define MIN_UPC_FREQ    (1396000000UL)  /* Minimum LO1 frequency (in Hz) */#define MAX_UPC_FREQ    (2750000000UL)  /* Maximum LO1 frequency (in Hz) *//***  Define the supported Part/Rev codes for the MT2063*/#define MT2063_B0       (0x9B)#define MT2063_B1       (0x9C)/***  The number of Tuner Registers*/static const UData_t Num_Registers = END_REGS;typedef struct{    Handle_t    handle;    Handle_t    hUserData;    UData_t     address;    UData_t     version;    UData_t     tuner_id;    MT_AvoidSpursData_t AS_Data;    UData_t     f_IF1_actual;    UData_t     rcvr_mode;    UData_t     num_regs;    U8Data      reg[END_REGS];}  MT2063_Info_t;static UData_t nMaxTuners = MT2063_CNT;static MT2063_Info_t MT2063_Info[MT2063_CNT];static MT2063_Info_t *Avail[MT2063_CNT];static UData_t nOpenTuners = 0;/***  Constants for setting receiver modes.**  (6 modes defined at this time, enumerated by MT2063_RCVR_MODES )**  (DNC1GC & DNC2GC are the values, which are used, when the specific **   DNC Output is selected, the other is always off) ****                --------------+----------------------------------------------**                 Mode 0 :     | MT2063_CABLE_QAM**                 Mode 1 :     | MT2063_CABLE_ANALOG**                 Mode 2 :     | MT2063_OFFAIR_COFDM**                 Mode 3 :     | MT2063_OFFAIR_COFDM_SAWLESS**                 Mode 4 :     | MT2063_OFFAIR_ANALOG**                 Mode 5 :     | MT2063_OFFAIR_8VSB**                --------------+----+----+----+----+-----+-----+--------------**                 Mode         |  0 |  1 |  2 |  3 |  4  |  5  |**                --------------+----+----+----+----+-----+-----+*****/static const U8Data RFAGCEN[]  = {  0,   0,   0,   0,   0,   0 };static const U8Data LNARIN[]   = {  0,   0,   3,   3,   3,   3 };static const U8Data FIFFQEN[]  = {  1,   1,   1,   1,   1,   1 };static const U8Data FIFFQ[]    = {  0,   0,   0,   0,   0,   0 };static const U8Data DNC1GC[]   = {  0,   0,   0,   0,   0,   0 };static const U8Data DNC2GC[]   = {  0,   0,   0,   0,   0,   0 };static const U8Data GCUAUTO[]  = {  1,   1,   1,   1,   1,   1 };static const U8Data ACLNAMAX[] = { 31,  31,  31,  31,  31,  31 };static const U8Data LNATGT[]   = { 44,  43,  43,  43,  43,  43 };static const U8Data RFOVDIS[]  = {  0,   0,   0,   0,   0,   0 };static const U8Data ACRFMAX[]  = { 31,  31,  31,  31,  31,  31 };static const U8Data PD1TGT[]   = { 36,  36,  38,  38,  36,  38 };static const U8Data FIFOVDIS[] = {  0,   0,   0,   0,   0,   0 };static const U8Data ACFIFMAX[] = {  5,   5,   5,   5,   5,   5 };static const U8Data PD2TGT[]   = { 40,  33,  42,  42,  33,  42 };/***  Local Function Prototypes - not available for external access.*/static UData_t MT2063_ControlAtten( Handle_t               h,                                    MT2063_ATTEN_CNTL_MODE control_mode,                                    U8Data                 regNum,                                    U8Data                 val,                                    U8Data                 bitMask );/*  Forward declaration(s):  */static UData_t CalcLO1Mult(UData_t *Div, UData_t *FracN, UData_t f_LO, UData_t f_LO_Step, UData_t f_Ref);static UData_t CalcLO2Mult(UData_t *Div, UData_t *FracN, UData_t f_LO, UData_t f_LO_Step, UData_t f_Ref);static UData_t fLO_FractionalTerm(UData_t f_ref, UData_t num, UData_t denom);/**********************************************************************************  Name: MT2063_Open****  Description:    Initialize the tuner's register values.****  Parameters:     MT2063_Addr  - Serial bus address of the tuner.**                  hMT2063      - Tuner handle passed back.**                  hUserData    - User-defined data, if needed for the**                                 MT_ReadSub() & MT_WriteSub functions.****  Returns:        status:**                      MT_OK             - No errors**                      MT_TUNER_ID_ERR   - Tuner Part/Rev code mismatch**                      MT_TUNER_INIT_ERR - Tuner initialization failed**                      MT_COMM_ERR       - Serial bus communications error**                      MT_ARG_NULL       - Null pointer argument passed**                      MT_TUNER_CNT_ERR  - Too many tuners open****  Dependencies:   MT_ReadSub  - Read byte(s) of data from the two-wire bus**                  MT_WriteSub - Write byte(s) of data to the two-wire bus****  Revision History:****   SCR      Date      Author  Description**  -------------------------------------------------------------------------**   138   06-19-2007    DAD    Ver 1.00: Initial, derived from mt2067_b.********************************************************************************/UData_t MT2063_Open(UData_t MT2063_Addr,                    Handle_t* hMT2063,                    Handle_t hUserData){    UData_t status = MT_OK;                        /*  Status to be returned.  */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -