rf_pm.h
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:16k
- /*****************************************************************************
- * Copyright Statement:
- * --------------------
- * This software is protected by Copyright and the information contained
- * herein is confidential. The software may not be copied and the information
- * contained herein may not be used or disclosed except with the written
- * permission of MediaTek Inc. (C) 2005
- *
- * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
- * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
- * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
- * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
- * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
- * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
- * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
- * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
- * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
- * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
- *
- * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
- * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
- * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
- * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
- * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
- *
- * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
- * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
- * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
- * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
- * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
- *
- *****************************************************************************/
- /*****************************************************************************
- *
- * Filename:
- * ---------
- * rf_pm.h
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * RF power measurement header
- *
- * Author:
- * -------
- * Andy Ueng (mtk00490)
- *
- *============================================================================
- * HISTORY
- * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *------------------------------------------------------------------------------
- * $Revision$
- * $Modtime$
- * $Log$
- *
- *------------------------------------------------------------------------------
- * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *============================================================================
- ****************************************************************************/
- #ifndef _RF_PM_H_
- #define _RF_PM_H_
- // common
- #ifndef _METAAPP_COMMON_H_
- #include "metaapp_common.h"
- #endif
- #ifndef META_DLL_H
- #include "meta.h"
- #endif
- #ifndef _MAN_HANDLE_H_
- #include "man_handle.h"
- #endif
- // chip
- #ifndef _MT6139_COMMON_H_
- #include "mt6139_common.h"
- #endif
- #ifndef _SKY74117_COMMON_H_
- #include "sky74117_common.h"
- #endif
- /*---------------------------------------------------------------------------*/
- #define STATUS_PM_OK 1
- #define STATUS_PM_FAIL 0
- // way of trigger to set MT6139 to register
- #define SET_MT6139_TO_COEF_REG_BY_GET_ACCODE 0
- #define SET_MT6139_TO_COEF_REG_BY_PM_START 1
- #define SET_MT6139_TO_COEF_REG_BY_GET_BCCCODE 2
- // way of trigger to set MT6139 CW2 to register
- #define SET_S_MT6139_CW2_TO_REG_BY_GET_ACODE 0
- #define SET_S_MT6139_CW2_TO_REG_BY_GET_BCCODE 1
- /*---------------------------------------------------------------------------*/
- // Skyworks
- typedef struct {
- signed char icorrection;
- signed char qcorrection;
- } c_RFMod_Sky74045_IP2_Coef;
- typedef struct {
- c_RFMod_Sky74045_IP2_Coef coef[5/*band*/];
- } c_RFMod_Sky74045_RX_Coef;
- typedef struct {
- c_RFMod_Sky74045_RX_Coef rx;
- } c_RFMod_Sky74045_Coef_T;
- // MT6139
- typedef struct
- {
- unsigned char acodeI;
- unsigned char acodeQ;
- unsigned char amcodeI;
- unsigned char amcodeQ;
- unsigned char bcodeI;
- unsigned char bcodeQ;
- unsigned char ccodeI;
- unsigned char ccodeQ;
- } uc_RFMod_MT6139_IP2_Coef;
- typedef struct
- {
- uc_RFMod_MT6139_IP2_Coef coef[5/*band*/];
- unsigned char rxamcalmode;
- } uc_RFMod_MT6139_RX_Coef;
- typedef struct
- {
- uc_RFMod_MT6139_RX_Coef rx;
- } uc_RFMod_MT6139_Coef_T;
- typedef struct
- {
- unsigned int c0;
- unsigned int c1;
- int DC0;
- int DC1;
- } IP2vsDC_T;
- /*---------------------------------------------------------------------------*/
- class CRFPM
- {
- private:
- bool m_bDownloadTrigger;
- E_METAAPP_RESULT_T m_eConfirmState;
- CMETAHANDLE m_META_HANDLE_Obj;
- RfPm_Req *RFReq_PM;
- RfPm_Cnf RFCnf_PM;
- int CurPmCount;
- int CurGain;
- bool HasMeasured;
- //----------------------------------------------------------------------
- // band
- //RFBandSupport_S band_support;
- FrequencyBand m_FreqBand;
-
- // IP2
- unsigned int m_uiFinalRfid;
- bool DnPwrOn;
- unsigned int m_uiIP2BufSize;
- char *m_cIP2Buf;
- // skyworth 74045
- signed char EvalPmrcx_I_sky[2];
- signed char EvalPmrcx_Q_sky[2];
- unsigned char EvalPmcx_I_sky[2];
- unsigned char EvalPmcx_Q_sky[2];
- int EvalDC_I_sky[2];
- int EvalDC_Q_sky[2];
- unsigned char Evalcx_I_sky;
- unsigned char Evalcx_Q_sky;
- // Skyworks 74117
- RF_SKY74117_Coef_T m_sky74117_coef;
- c_RFMod_Sky74117_Coef_T mc_sky74117_coef;
- SKY74117_IP2CW_MAG m_sky74117_mag[5];
- SKY74117_IP2CW_POL m_sky74117_pol;
- // MT6139
- unsigned char EvalAcodeI_mt[2];
- unsigned char EvalAcodeQ_mt[2];
- unsigned char EvalAmcodeI_mt[2];
- unsigned char EvalAmcodeQ_mt[2];
- int EvalMdcOn_AcodeI_mt[2];
- int EvalMdcOn_AcodeQ_mt[2];
- int EvalMdcOn_AmcodeI_mt[2];
- int EvalMdcOn_AmcodeQ_mt[2];
- int EvalMdcOff_AcodeI_mt[2];
- int EvalMdcOff_AcodeQ_mt[2];
- int EvalMdcOff_AmcodeI_mt[2];
- int EvalMdcOff_AmcodeQ_mt[2];
- int EvalDC_AcodeI_mt[2];
- int EvalDC_AcodeQ_mt[2];
- int EvalDC_AmcodeI_mt[2];
- int EvalDC_AmcodeQ_mt[2];
- unsigned char EvalAcodeI0_mt;
- unsigned char EvalAmcodeI0_mt;
- unsigned char mode; // CW2
- S_MT6139_CW2 mt6139_cw2;
- S_MT6139_CW7 mt6139_cw7;
- S_MT6139_CW7 *p_mt6139_cw7;
- S_MT6139_CW8 mt6139_cw8;
- S_MT6139_CW8 *p_mt6139_cw8;
- S_MT6139_CW9 mt6139_cw9;
- S_MT6139_CW9 *p_mt6139_cw9;
- S_MT6139_CW10 mt6139_cw10; // amcode
- uc_RFMod_MT6139_Coef_T *p_uc_mt6139_coef;
- protected:
- void Confirm(E_METAAPP_RESULT_T confirm_state );
- public:
- int Band;
- int Arfcn;
- int PMPerFrame;
- unsigned int PMCount;
- int GainMin;
- int GainMax;
- int GainStep;
- short RFID_PM;
- c_RFMod_Sky74045_Coef_T c_sky74045_coef;
- uc_RFMod_MT6139_Coef_T uc_mt6139_coef;
- RF_SKY74045_Coef_T sky74045_coef;
- RF_MT6139B_Coef_T mt6139_coef;
- CRFPM( void );
- ~CRFPM( );
-
- void REQ_Finish( void );
- void REQ_TimeOut( void );
- // RF
- void REQ_SelectBand( void );
- void __stdcall CNF_SelectBand(const unsigned char cnf, const short token, void *usrData);
- void REQ_PowerMeasurement( void );
- void __stdcall CNF_PowerMeasurement( const RfPm_Cnf *cnf, const short token, void *usrData );
- // NVRAM
- void REQ_Read_IP2Reg_From_NVRAM(void);
- void CNF_ReadIP2RegFromNVRAM(void);
- void REQ_Write_IP2Reg_To_NVRAM(void);
- void CNF_WriteIP2RegToNVRAM(void);
- /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
- void (*ConfirmCallback)( void );
- void REQ_Start( int band, int arfcn, int pm_per_frame, unsigned int pm_count, unsigned int rfmod_id, bool dnpwr_on=false, int gain_min=0, int gain_max=0, int gain_step=0 );
- void REQ_Stop( void );
- // ip2
- void REQ_Read_IP2Reg_From_NVRAM_Start(unsigned int rf_id);
- void REQ_Write_IP2Reg_To_NVRAM_Start(unsigned int rf_id);
- bool AnyIP2SectionExist(char *filename);
- bool REQ_Read_IP2Reg_From_File(char *filename, unsigned int rf_id);
- bool REQ_Write_IP2Reg_To_File(char *filename, unsigned int rf_id);
- bool REQ_Write_IP2Reg_To_File_Single_Band(char *filename, unsigned int rf_id, int band);
- // Sky74045
- bool Sky74045_Coef_c2ui( c_RFMod_Sky74045_Coef_T &c_sky74045_coef, RF_SKY74045_Coef_T &ui_sky74045_coef);
- bool Sky74045_Coef_ui2c( RF_SKY74045_Coef_T &ui_sky74045_coef, c_RFMod_Sky74045_Coef_T &c_sky74045_coef);
- signed char Get_realcoefofcx( unsigned char cx, unsigned int rfid );
- unsigned char Get_cxofrealcoef( signed char realcoef, unsigned int rfid );
- bool Get_cxofDC0( IP2vsDC_T &ip2vsdc, unsigned char &cx );
- bool Evaluate_sky74045( signed char &rcx_I, signed char &rcx_Q, unsigned int rfid );
- void Get_cSky74045Coef( c_RFMod_Sky74045_Coef_T &char_sky74045_coef );
- void Set_cSky74045Coef( c_RFMod_Sky74045_Coef_T &char_sky74045_coef );
- void Set_Sky74045Coef( RF_SKY74045_Coef_T &ui_sky74045_coef );
- // Sky74117
- bool Evaluate_sky74117( signed char &rcx_I, signed char &rcx_Q, unsigned int rfid );
- void Sky74117_Coef_c2ui( c_RFMod_Sky74117_Coef_T &c_sky74117_coef, RF_SKY74117_Coef_T &ui_sky74117_coef);
- void Sky74117_Coef_ui2c( RF_SKY74117_Coef_T &ui_sky74117_coef, c_RFMod_Sky74117_Coef_T &c_sky74117_coef);
- void Get_cSky74117Coef( c_RFMod_Sky74117_Coef_T &c_sky74117_coef );
- void Set_cSky74117Coef( c_RFMod_Sky74117_Coef_T &c_sky74117_coef );
- void Compose_Sky74117_GSM850CW( SKY74117_IP2CW_MAG &sky74117_mag_par, unsigned int &bsi_data );
- void DeCompose_Sky74117_GSM850CW( unsigned int reg_data, SKY74117_IP2CW_MAG &sky74117_mag_par);
- void Compose_Sky74117_GSM900CW( SKY74117_IP2CW_MAG &sky74117_mag_par, unsigned int &bsi_data );
- void DeCompose_Sky74117_GSM900CW( unsigned int reg_data, SKY74117_IP2CW_MAG &sky74117_mag_par);
- void Compose_Sky74117_DCS1800CW( SKY74117_IP2CW_MAG &sky74117_mag_par, unsigned int &bsi_data );
- void DeCompose_Sky74117_DCS1800CW( unsigned int reg_data, SKY74117_IP2CW_MAG &sky74117_mag_par);
- void Compose_Sky74117_PCS1900CW( SKY74117_IP2CW_MAG &sky74117_mag_par, unsigned int &bsi_data );
- void DeCompose_Sky74117_PCS1900CW( unsigned int reg_data, SKY74117_IP2CW_MAG &sky74117_mag_par);
- void Compose_Sky74117_PolCW( SKY74117_IP2CW_POL &sky74117_pol_par, unsigned int &bsi_data );
- void DeCompose_Sky74117_PolCW( unsigned int reg_data, SKY74117_IP2CW_POL &sky74117_pol_par);
- void Compose_Sky74117_Mag( FrequencyBand freqband, c_RFMod_Sky74117_Coef_T &c_sky74117_coef, SKY74117_IP2CW_MAG &sky74117_mag_par );
- void Compose_Sky74117_Pol( c_RFMod_Sky74117_Coef_T &c_sky74117_coef, SKY74117_IP2CW_POL &sky74117_pol_par );
- void Set_Sky74117IP2MagToReg_Start( FrequencyBand freqband, SKY74117_IP2CW_MAG &sky74117_mag_par );
- void Set_Sky74117IP2MagToReg( void );
- void Set_Sky74117IP2Gsm850ToReg_Start( SKY74117_IP2CW_MAG &sky74117_mag_par );
- void Set_Sky74117IP2Gsm850ToReg( void );
- void Set_Sky74117IP2Gsm900ToReg_Start( SKY74117_IP2CW_MAG &sky74117_mag_par );
- void Set_Sky74117IP2Gsm900ToReg( void );
- void Set_Sky74117IP2Dcs1800ToReg_Start( SKY74117_IP2CW_MAG &sky74117_mag_par );
- void Set_Sky74117IP2Dcs1800ToReg( void );
- void Set_Sky74117IP2Pcs1900ToReg_Start( SKY74117_IP2CW_MAG &sky74117_mag_par );
- void Set_Sky74117IP2Pcs1900ToReg( void );
- void Set_Sky74117IP2PolToReg_Start( SKY74117_IP2CW_POL &sky74117_pol_par );
- void Set_Sky74117IP2PolToReg( void );
- // MT6139
- bool REQ_Write_IP2Reg_RxAmCalMode_To_File( char *filename, unsigned int rf_id );
- bool Evaluate_mt6139( unsigned char &AcodeI0, unsigned char &AcodeQ0,
- unsigned char &AmcodeI0, unsigned char &AmcodeQ0 );
- void Get_ucMT6139Coef( uc_RFMod_MT6139_Coef_T &uchar_mt6139_coef );
- void Set_ucMT6139Coef( uc_RFMod_MT6139_Coef_T &uchar_mt6139_coef );
- void Set_ucMT6139CoefExceptCalMode( uc_RFMod_MT6139_Coef_T &uchar_mt6139_coef );
- void Set_MT6139Coef(RF_MT6139B_Coef_T &ui_mt6139_coef );
- void Set_MT6139CoefToReg_Start( uc_RFMod_MT6139_Coef_T &uc_mt6139_coef_par );
- void Set_MT6139CoefToReg( void );
- void Get_AcodeFromReg_Start( FrequencyBand freq_band, uc_RFMod_MT6139_Coef_T &uc_mt6139_coef_par, unsigned int rf_id );
- void Get_AcodeFromReg( void );
- void Get_BCcodeFromReg_Start( FrequencyBand FreqBand, uc_RFMod_MT6139_Coef_T &uc_mt6139_coef_par, unsigned int rf_id );
- void Get_BCcodeFromReg( void );
- void Get_ABCcodeFromReg_Start( FrequencyBand freq_band, uc_RFMod_MT6139_Coef_T &uc_mt6139_coef_par, unsigned int rf_id );
- void Get_ABCcodeFromReg( void );
- void Set_BCcodeToReg_Start( FrequencyBand FreqBand, uc_RFMod_MT6139_Coef_T &uc_mt6139_coef_par, unsigned int rf_id );
- void Set_BCcodeToReg( void );
- void MT6139_Coef_uc2ui( uc_RFMod_MT6139_Coef_T &uc_mt6139_coef, RF_MT6139B_Coef_T &ui_mt6139_coef);
- void MT6139_Coef_ui2uc( RF_MT6139B_Coef_T &ui_mt6139_coef, uc_RFMod_MT6139_Coef_T &uc_mt6139_coef);
- // MT6139 CW2
- void Compose_MT6139CW2( S_MT6139_CW2 &mt6139_cw2_par, unsigned int &bsi_data, unsigned int rf_id );
- void DeCompose_MT6139CW2( unsigned int reg_data, S_MT6139_CW2 &mt6139_cw2_par, unsigned int rf_id );
- void Set_MT6139CW2ToReg_Start( unsigned char mode_par, unsigned int rf_id );
- void Set_MT6139CW2ToReg( void );
- // MT6139 CW7
- void Compose_MT6139CW7( S_MT6139_CW7 &mt6139_cw7, unsigned int &bsi_data, unsigned int rf_id );
- void DeCompose_MT6139CW7( unsigned int reg_data, S_MT6139_CW7 &mt6139_cw7, unsigned int rf_id );
- void Set_MT6139CW7ToReg_Start( S_MT6139_CW7 &mt6139_cw7_par, unsigned int rf_id );
- void Set_MT6139CW7ToReg( void );
- void Get_MT6139CW7FromReg_Start( S_MT6139_CW7 &mt6139_cw7_par, unsigned int rf_id );
- void Get_MT6139CW7FromReg( void );
- // MT6139 CW8
- void Compose_MT6139CW8( S_MT6139_CW8 &mt6139_cw8_par, unsigned int &bsi_data, unsigned int rf_id );
- void DeCompose_MT6139CW8( unsigned int reg_data, S_MT6139_CW8 &mt6139_cw8_par, unsigned int rf_id );
- void Set_MT6139CW8ToReg_Start( S_MT6139_CW8 &mt6139_cw8_par, unsigned int rf_id );
- void Set_MT6139CW8ToReg( void );
- void Get_MT6139CW8FromReg_Start( S_MT6139_CW8 &mt6139_cw8_par, unsigned int rf_id );
- void Get_MT6139CW8FromReg( void );
- // MT6139 CW9
- void Compose_MT6139CW9( S_MT6139_CW9 &mt6139_cw9_par, unsigned int &bsi_data, unsigned int rf_id );
- void DeCompose_MT6139CW9( unsigned int reg_data, S_MT6139_CW9 &mt6139_cw9_par, unsigned int rf_id );
- void Set_MT6139CW9ToReg_Start( S_MT6139_CW9 &mt6139_cw9_par, unsigned int rf_id );
- void Set_MT6139CW9ToReg( void );
- void Get_MT6139CW9FromReg_Start( S_MT6139_CW9 &mt6139_cw9_par, unsigned int rf_id );
- void Get_MT6139CW9FromReg( void );
- // MT6139 CW10
- void Set_MT6139AmcodeToReg_Start( S_MT6139_CW10 &mt6139_cw10_par, unsigned int rf_id );
- void Set_MT6139AmcodeToReg( S_MT6139_CW10 &mt6139_cw10_par, unsigned int rf_id );
- // query
- unsigned char Query_PM_Support_Start( void );
- unsigned char Query_PM_Support( void );
- // Global information
- E_METAAPP_RESULT_T Get_ConfirmState( void );
- RfPm_Cnf Get_RfPmCnf( void );
- c_RFMod_Sky74045_Coef_T Get_c_sky74045_coef( void );
- void Set_c_sky74045_coef( c_RFMod_Sky74045_Coef_T c_sky74045_coef_par );
- c_RFMod_Sky74117_Coef_T Get_c_sky74117_coef( void );
- void Set_c_sky74117_coef( c_RFMod_Sky74117_Coef_T c_sky74117_coef_par );
- uc_RFMod_MT6139_Coef_T Get_uc_mt6139_coef( void );
- void Set_uc_mt6139_coef_rxamcalmode( int mode );
- };
- /*---------------------------------------------------------------------------*/
- #endif