rf_pm.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:91k
- /*****************************************************************************
- * 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.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * RF power measurement source
- *
- * 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!!
- *============================================================================
- ****************************************************************************/
- #include <IniFiles.hpp>
- #pragma hdrstop
- //#ifndef _FORM_RFTOOL_H_
- //#include "form_RFTool.h"
- //#endif
- #ifndef _FORM_MAIN_H_
- #include "form_main.h"
- #endif
- #ifndef _RF_PM_H_
- #include "rf_pm.h"
- #endif
- #include "man_active.h"
- #include "man_fdm.h"
- // misc
- #ifndef _FT_UTILS_H_
- #include "ft_utils.h"
- #endif
- // NVRAM
- #ifndef _NVRAM_VER_H_
- #include "nvram_ver.h"
- #endif
- static const SKY74045_RCX_MIN = -127;
- static const SKY74045_RCX_MAX = 127;
- static const SKY74117_RCX_MIN = -63;
- static const SKY74117_RCX_MAX = 63;
- //===========================================================================
- static CRFPM* rf_pm_ptr;
- static bool g_bIsRunning;
- static const char SUBBAND_NAME[][32] =
- {
- "GSM400 Sub band, IP2",
- "GSM850 Sub band, IP2",
- "GSM900 Sub band, IP2",
- "DCS1800 Sub band, IP2",
- "PCS1900 Sub band, IP2",
- };
- //===========================================================================
- static void REQ_SelectBand( void )
- { rf_pm_ptr->REQ_SelectBand( );
- }
- //------------------------------------------------------------------------------
- static void __stdcall CNF_SelectBand(const unsigned char cnf, const short token, void *usrData)
- {
- rf_pm_ptr->CNF_SelectBand(cnf, token, NULL);
- }
- //------------------------------------------------------------------------------
- static void REQ_PowerMeasurement(void)
- {
- rf_pm_ptr->REQ_PowerMeasurement();
- }
- //------------------------------------------------------------------------------
- static void __stdcall CNF_PowerMeasurement(const RfPm_Cnf *cnf, const short token, void *usrData)
- {
- rf_pm_ptr->CNF_PowerMeasurement(cnf, token, usrData);
- }
- //----------------------------------------------------------------------------
- static void CNF_ReadIP2RegFromNVRAM(void)
- {
- rf_pm_ptr->CNF_ReadIP2RegFromNVRAM();
- }
- //----------------------------------------------------------------------------
- static void CNF_WriteIP2RegToNVRAM(void)
- {
- rf_pm_ptr->CNF_WriteIP2RegToNVRAM();
- }
- //----------------------------------------------------------------------------
- static void Set_Sky74117IP2MagToReg(void)
- {
- rf_pm_ptr->Set_Sky74117IP2MagToReg();
- }
- //----------------------------------------------------------------------------
- static void Set_Sky74117IP2Gsm850ToReg(void)
- {
- rf_pm_ptr->Set_Sky74117IP2Gsm850ToReg();
- }
- //----------------------------------------------------------------------------
- static void Set_Sky74117IP2Gsm900ToReg(void)
- {
- rf_pm_ptr->Set_Sky74117IP2Gsm900ToReg();
- }
- //----------------------------------------------------------------------------
- static void Set_Sky74117IP2Dcs1800ToReg(void)
- {
- rf_pm_ptr->Set_Sky74117IP2Dcs1800ToReg();
- }
- //----------------------------------------------------------------------------
- static void Set_Sky74117IP2Pcs1900ToReg(void)
- {
- rf_pm_ptr->Set_Sky74117IP2Pcs1900ToReg();
- }
- //----------------------------------------------------------------------------
- static void Set_Sky74117IP2PolToReg(void)
- {
- rf_pm_ptr->Set_Sky74117IP2PolToReg();
- }
- //----------------------------------------------------------------------------
- static void Get_AcodeFromReg(void)
- {
- rf_pm_ptr->Get_AcodeFromReg();
- }
- //----------------------------------------------------------------------------
- static void Get_BCcodeFromReg(void)
- {
- rf_pm_ptr->Get_BCcodeFromReg();
- }
- //----------------------------------------------------------------------------
- static void Set_BCcodeToReg(void)
- {
- rf_pm_ptr->Set_BCcodeToReg();
- }
- //----------------------------------------------------------------------------
- static void Get_ABCcodeFromReg(void)
- {
- rf_pm_ptr->Get_ABCcodeFromReg();
- }
- //----------------------------------------------------------------------------
- static void Set_MT6139CW2ToReg( void )
- {
- rf_pm_ptr->Set_MT6139CW2ToReg();
- }
- //----------------------------------------------------------------------------
- static void Get_MT6139CW7FromReg( void )
- {
- rf_pm_ptr->Get_MT6139CW7FromReg();
- }
- //----------------------------------------------------------------------------
- static void Set_MT6139CW7ToReg( void )
- {
- rf_pm_ptr->Set_MT6139CW7ToReg();
- }
- //----------------------------------------------------------------------------
- static void Set_MT6139CW8ToReg( void )
- {
- rf_pm_ptr->Set_MT6139CW8ToReg();
- }
- //----------------------------------------------------------------------------
- static void Get_MT6139CW9FromReg(void )
- {
- rf_pm_ptr->Get_MT6139CW9FromReg();
- }
- //----------------------------------------------------------------------------
- static void Set_MT6139CW9ToReg(void )
- {
- rf_pm_ptr->Set_MT6139CW9ToReg();
- }
- //----------------------------------------------------------------------------
- static void Set_MT6139CoefToReg(void )
- {
- rf_pm_ptr->Set_MT6139CoefToReg();
- }
- //----------------------------------------------------------------------------
- static void REQ_TimeOut( void )
- { rf_pm_ptr->REQ_TimeOut();
- }
- //----------------------------------------------------------------------------
- static void REQ_Finish( void )
- { rf_pm_ptr->REQ_Finish();
- }
- //===========================================================================
- CRFPM::CRFPM( void )
- {
- g_bIsRunning = false;
- ConfirmCallback = 0;
- RFReq_PM = NULL;
- EvalPmrcx_I_sky[0] = 0;
- EvalPmrcx_I_sky[1] = 0;
- EvalPmrcx_Q_sky[0] = 0;
- EvalPmrcx_Q_sky[1] = 0;
- EvalDC_I_sky[0] = 0;
- EvalDC_I_sky[1] = 0;
- EvalDC_Q_sky[0] = 0;
- EvalDC_Q_sky[1] = 0;
- m_uiIP2BufSize = 0;
- m_cIP2Buf = 0;
- // reserved
- mt6139_cw7.uc_reserved = 0x00;
- mt6139_cw8.uc_reserved = 0x00;
- mt6139_cw9.uc_reserved = 0x0F;
- }
- //---------------------------------------------------------------------------
- CRFPM::~CRFPM()
- {
- g_bIsRunning = false;
- ConfirmCallback = 0;
- if( RFReq_PM != NULL)
- {
- delete RFReq_PM;
- RFReq_PM = NULL;
- }
- if(m_cIP2Buf)
- {
- delete [] m_cIP2Buf;
- m_cIP2Buf = NULL;
- }
- }
- //---------------------------------------------------------------------------
- void CRFPM::REQ_Finish( void )
- {
- if(!g_bIsRunning) return;
- Confirm( METAAPP_SUCCESS );
- }
- //---------------------------------------------------------------------------
- void CRFPM::REQ_Stop( void )
- {
- if(!g_bIsRunning) return;
- META_Cancel_r( m_META_HANDLE_Obj.Get_MainHandle(), RFID_PM );
- Confirm( METAAPP_STOP );
- }
- //---------------------------------------------------------------------------
- void CRFPM::REQ_TimeOut( void )
- {
- if(!g_bIsRunning) return;
- META_Cancel_r( m_META_HANDLE_Obj.Get_MainHandle(), RFID_PM );
- Confirm( METAAPP_TIMEOUT );
- }
- //---------------------------------------------------------------------------
- void CRFPM::Confirm(E_METAAPP_RESULT_T confirm_state)
- {
- if(!g_bIsRunning) return;
-
- if( METAAPP_SECTION_OK != confirm_state )
- g_bIsRunning = false;
- if(ConfirmCallback==0) return;
- m_eConfirmState = confirm_state;
- ActiveMan->SetActiveFunction( ConfirmCallback );
- }
- //===========================================================================
- void CRFPM::REQ_Start( int band, int arfcn, int pm_per_frame, unsigned int pm_count, unsigned int rfmod_id, bool dnpwr_on, int gain_min, int gain_max, int gain_step )
- {
- rf_pm_ptr = this;
- g_bIsRunning = true;
- Band = band;
- Arfcn = arfcn;
- PMPerFrame = pm_per_frame;
- PMCount = pm_count;
- GainMin = gain_min;
- GainMax = gain_max;
- GainStep = gain_step;
- if(GainStep==0) GainMax = GainMin-1;
- CurPmCount = PMCount;
- CurGain = GainMin;
- m_uiFinalRfid = rfmod_id;
- DnPwrOn = dnpwr_on;
- ActiveMan->SetActiveFunction( ::REQ_SelectBand );
- }
- //---------------------------------------------------------------------------
- void CRFPM::REQ_SelectBand( void )
- {
- if(!g_bIsRunning) return;
- unsigned char selected_pcs1900;
- if(Band==BANDSEL_PCS1900)
- selected_pcs1900 = 1;
- else
- selected_pcs1900 = 0;
- META_RESULT MetaResult = META_Rf_SelectFrequencyBand1900_r( m_META_HANDLE_Obj.Get_MainHandle(), selected_pcs1900, ::CNF_SelectBand, &RFID_PM, NULL );
- if(MetaResult!=META_SUCCESS)
- { Confirm( METAAPP_FAIL ); return; }
- }
- //-------------------------------------
- void __stdcall CRFPM::CNF_SelectBand(const unsigned char cnf, const short token, void *usrData)
- {
- if(!g_bIsRunning) return;
- if(cnf==false)
- { Confirm( METAAPP_FAIL ); return; }
- HasMeasured = false;
- ActiveMan->SetActiveFunction( ::REQ_PowerMeasurement );
- }
- //---------------------------------------------------------------------------
- void CRFPM::REQ_PowerMeasurement( void )
- {
- if(!g_bIsRunning) return;
- if( HasMeasured )
- {
- Confirm( METAAPP_SECTION_OK );
- }
- if( PMCount==-1 ) /* infinit PM */
- { CurPmCount = 2001;
- }
- if( CurPmCount==0 )
- { CurGain += GainStep;
- if( CurGain>GainMax )
- { REQ_Finish();
- return;
- }
- CurPmCount = PMCount;
- }
- if( RFReq_PM == NULL)
- {
- RFReq_PM = new RfPm_Req;
- }
- RFReq_PM->arfcn = Arfcn;
- RFReq_PM->sampleNoPerFrame = PMPerFrame;
- RFReq_PM->gain = CurGain;
- if( CurPmCount>2000 )
- {
- // RFReq_PM->frames = (int)(1.0*2000/PMPerFrame+0.99);
- // CurPmCount -= 2000;
- RFReq_PM->frames = 2000/PMPerFrame;
- CurPmCount -= PMPerFrame * RFReq_PM->frames;
- }
- else
- { //RFReq_PM->frames = (int)(1.0*CurPmCount/PMPerFrame+0.99);
- RFReq_PM->frames = CurPmCount/PMPerFrame;
- CurPmCount = 0;
- }
- META_RESULT MetaResult = META_Rf_PM_r( m_META_HANDLE_Obj.Get_MainHandle(), RFReq_PM, ::CNF_PowerMeasurement, &RFID_PM, NULL );
- if(MetaResult!=META_SUCCESS)
- { Confirm( METAAPP_FAIL ); return; }
- }
- //-------------------------------------
- void __stdcall CRFPM::CNF_PowerMeasurement( const RfPm_Cnf *cnf, const short token, void *usrData )
- {
- if(!g_bIsRunning) return;
- FrequencyBand FreqBand = Get_FreqBandFromBandIndex(Band);
- HasMeasured = true;
- if(cnf->ok == STATUS_PM_OK)
- {
- RFCnf_PM = *cnf;
- if( RF_ID_SKY74045 == m_uiFinalRfid )
- {
- if( cnf->extra_info.valid && cnf->extra_info.validSamples)
- {
- EvalPmrcx_I_sky[0] = EvalPmrcx_I_sky[1];
- EvalPmrcx_Q_sky[0] = EvalPmrcx_Q_sky[1];
- EvalPmrcx_I_sky[1] = c_sky74045_coef.rx.coef[FreqBand].icorrection;
- EvalPmrcx_Q_sky[1] = c_sky74045_coef.rx.coef[FreqBand].qcorrection;
- EvalDC_I_sky[0] = EvalDC_I_sky[1];
- EvalDC_Q_sky[0] = EvalDC_Q_sky[1];
- EvalDC_I_sky[1] = cnf->extra_info.iOffset;
- EvalDC_Q_sky[1] = cnf->extra_info.qOffset;
- }
- }
- else if( RF_ID_SKY74117 == m_uiFinalRfid || RF_ID_SKY74400 == m_uiFinalRfid )
- {
- if( cnf->extra_info.valid && cnf->extra_info.validSamples)
- {
- EvalPmrcx_I_sky[0] = EvalPmrcx_I_sky[1];
- EvalPmrcx_Q_sky[0] = EvalPmrcx_Q_sky[1];
- EvalPmrcx_I_sky[1] = mc_sky74117_coef.rx.coef[FreqBand].icorrection;
- EvalPmrcx_Q_sky[1] = mc_sky74117_coef.rx.coef[FreqBand].qcorrection;
- EvalDC_I_sky[0] = EvalDC_I_sky[1];
- EvalDC_Q_sky[0] = EvalDC_Q_sky[1];
- EvalDC_I_sky[1] = cnf->extra_info.iOffset;
- EvalDC_Q_sky[1] = cnf->extra_info.qOffset;
- }
- }
- else if( RF_ID_MT6139B == m_uiFinalRfid ||
- RF_ID_MT6139C == m_uiFinalRfid ||
- RF_ID_MT6139E == m_uiFinalRfid ||
- RF_ID_MT6140A == m_uiFinalRfid ||
- RF_ID_MT6140B == m_uiFinalRfid
- )
- {
- if( DnPwrOn )
- {
- // EvalAcodeI_mt[0] = EvalAcodeI_mt[1];
- // EvalAcodeQ_mt[0] = EvalAcodeQ_mt[1];
- EvalAmcodeI_mt[0] = EvalAmcodeI_mt[1];
- EvalAmcodeQ_mt[0] = EvalAmcodeQ_mt[1];
- // EvalAcodeI_mt[1] = uc_mt6139_coef.rx.coef[FreqBand].acodeI;
- // EvalAcodeQ_mt[1] = uc_mt6139_coef.rx.coef[FreqBand].acodeQ;
- EvalAmcodeI_mt[1] = uc_mt6139_coef.rx.coef[FreqBand].amcodeI;
- EvalAmcodeQ_mt[1] = uc_mt6139_coef.rx.coef[FreqBand].amcodeQ;
- // EvalMdcOn_AcodeI_mt[0] = EvalMdcOn_AcodeI_mt[1];
- // EvalMdcOn_AcodeQ_mt[0] = EvalMdcOn_AcodeQ_mt[1];
- EvalMdcOn_AmcodeI_mt[0]= EvalMdcOn_AmcodeI_mt[1];
- EvalMdcOn_AmcodeQ_mt[0]= EvalMdcOn_AmcodeQ_mt[1];
- // EvalMdcOn_AcodeI_mt[1] = cnf->extra_info.iOffset;
- // EvalMdcOn_AcodeQ_mt[1] = cnf->extra_info.qOffset;
- EvalMdcOn_AmcodeI_mt[1] = cnf->extra_info.iOffset;
- EvalMdcOn_AmcodeQ_mt[1] = cnf->extra_info.qOffset;
- }
- else
- {
- // EvalMdcOff_AcodeI_mt[0] = EvalMdcOff_AcodeI_mt[1];
- // EvalMdcOff_AcodeQ_mt[0] = EvalMdcOff_AcodeQ_mt[1];
- EvalMdcOff_AmcodeI_mt[0]= EvalMdcOff_AmcodeI_mt[1];
- EvalMdcOff_AmcodeQ_mt[0]= EvalMdcOff_AmcodeQ_mt[1];
- // EvalMdcOff_AcodeI_mt[1] = cnf->extra_info.iOffset;
- // EvalMdcOff_AcodeQ_mt[1] = cnf->extra_info.qOffset;
- EvalMdcOff_AmcodeI_mt[1] = cnf->extra_info.iOffset;
- EvalMdcOff_AmcodeQ_mt[1] = cnf->extra_info.qOffset;
- }
- }
- }
- else
- {
- Confirm( METAAPP_FAIL ); return;
- }
- ActiveMan->SetActiveFunction( ::REQ_PowerMeasurement );
- }
- //===========================================================================
- void CRFPM::REQ_Read_IP2Reg_From_NVRAM_Start(unsigned int rfmod_id)
- {
- rf_pm_ptr = this;
- g_bIsRunning = true;
- m_bDownloadTrigger = false;
- m_uiFinalRfid = rfmod_id;
- REQ_Read_IP2Reg_From_NVRAM();
- }
- //----------------------------------------------------------------------------
- void CRFPM::REQ_Read_IP2Reg_From_NVRAM(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- if (NULL == m_cIP2Buf)
- {
- META_RESULT MetaResult = META_NVRAM_GetRecLen("NVRAM_EF_L1_RFSPECIALCOEF_LID", (int *) &m_uiIP2BufSize);
- if (MetaResult != META_SUCCESS)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- m_cIP2Buf = new char[m_uiIP2BufSize];
- }
- NVRAMMan->ConfirmCallback = ::CNF_ReadIP2RegFromNVRAM;
- NVRAMMan->REQ_ReadNVRAM_Start("NVRAM_EF_L1_RFSPECIALCOEF_LID",
- 1,
- m_uiIP2BufSize,
- m_cIP2Buf
- );
- }
- //-------------------------------------
- void CRFPM::CNF_ReadIP2RegFromNVRAM(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- META_RESULT MetaResult;
- E_METAAPP_RESULT_T state = NVRAMMan->Get_ConfirmState();
- if (METAAPP_SUCCESS == state)
- {
- if (m_bDownloadTrigger)
- {
- REQ_Write_IP2Reg_To_NVRAM();
- }
- else
- {
- switch (m_uiFinalRfid)
- {
- case RF_ID_SKY74045:
- {
- MetaResult = META_NVRAM_Decompose_SKY74045_RFSpecialCoef(&sky74045_coef, m_cIP2Buf, m_uiIP2BufSize);
- if(MetaResult != META_SUCCESS)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- Sky74045_Coef_ui2c(sky74045_coef, c_sky74045_coef);
- }
- break;
- case RF_ID_SKY74117:
- case RF_ID_SKY74400:
- {
- MetaResult = META_NVRAM_Decompose_SKY74117_RFSpecialCoef(&m_sky74117_coef, m_cIP2Buf, m_uiIP2BufSize);
- if (MetaResult != META_SUCCESS)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- Sky74117_Coef_ui2c(m_sky74117_coef, mc_sky74117_coef);
- }
- break;
- case RF_ID_MT6139B:
- case RF_ID_MT6139C:
- case RF_ID_MT6139E:
- case RF_ID_MT6140A:
- case RF_ID_MT6140B:
- {
- MetaResult = META_NVRAM_Decompose_MT6139B_RFSpecialCoef(&mt6139_coef, m_cIP2Buf, m_uiIP2BufSize);
- if (MetaResult != META_SUCCESS)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- MT6139_Coef_ui2uc(mt6139_coef, uc_mt6139_coef);
- }
- break;
- }
- ActiveMan->SetActiveFunction( ::REQ_Finish );
- }
- }
- else
- { Confirm(state);
- }
- }
- //===========================================================================
- void CRFPM::REQ_Write_IP2Reg_To_NVRAM_Start(unsigned int rfmod_id)
- {
- rf_pm_ptr = this;
- g_bIsRunning = true;
- m_bDownloadTrigger = true;
- m_uiFinalRfid = rfmod_id;
- REQ_Read_IP2Reg_From_NVRAM();
- }
- //---------------------------------------------------------------------------
- void CRFPM::REQ_Write_IP2Reg_To_NVRAM(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- META_RESULT MetaResult;
- unsigned short lid_ver;
- MetaResult = META_NVRAM_GetLIDVersion("NVRAM_EF_L1_RFSPECIALCOEF_LID", &lid_ver);
- if (lid_ver > NVRAM_EF_L1_RFSPECIALCOEF_LID_VERNO)
- {
- Confirm(METAAPP_NVRAM_LID_VER_NOT_SUPPORT);
- return;
- }
- if (NULL == m_cIP2Buf)
- {
- META_RESULT MetaResult = META_NVRAM_GetRecLen("NVRAM_EF_L1_RFSPECIALCOEF_LID", (int *) &m_uiIP2BufSize);
- if (MetaResult!=META_SUCCESS)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- m_cIP2Buf = new char[m_uiIP2BufSize];
- }
- switch (m_uiFinalRfid)
- {
- case RF_ID_SKY74045:
- {
- Sky74045_Coef_c2ui( c_sky74045_coef, sky74045_coef );
- MetaResult = META_NVRAM_Compose_SKY74045_RFSpecialCoef(&sky74045_coef, m_cIP2Buf, m_uiIP2BufSize);
- }
- break;
- case RF_ID_SKY74117:
- case RF_ID_SKY74400:
- {
- Sky74117_Coef_c2ui( mc_sky74117_coef, m_sky74117_coef );
- MetaResult = META_NVRAM_Compose_SKY74117_RFSpecialCoef(&m_sky74117_coef, m_cIP2Buf, m_uiIP2BufSize);
- }
- break;
- case RF_ID_MT6139B:
- case RF_ID_MT6139C:
- case RF_ID_MT6139E:
- case RF_ID_MT6140A:
- case RF_ID_MT6140B:
- {
- MT6139_Coef_uc2ui( uc_mt6139_coef, mt6139_coef );
- MetaResult = META_NVRAM_Compose_MT6139B_RFSpecialCoef(&mt6139_coef, m_cIP2Buf, m_uiIP2BufSize);
- }
- break;
- default:
- break;
- }
- if (MetaResult != META_SUCCESS)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- NVRAMMan->ConfirmCallback = ::CNF_WriteIP2RegToNVRAM;
- NVRAMMan->REQ_WriteNVRAM_Start("NVRAM_EF_L1_RFSPECIALCOEF_LID",
- 1,
- m_uiIP2BufSize,
- m_cIP2Buf );
- }
- //-------------------------------------
- void CRFPM::CNF_WriteIP2RegToNVRAM(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- E_METAAPP_RESULT_T state = NVRAMMan->Get_ConfirmState();
- Confirm(state);
- }
- #if 0
- //==============================================================================
- bool CRFPM::AnyRxLossSectionExist( char *filename )
- {
- int FrequencyBandStart;
- TIniFile *ini_file;
- ini_file = new TIniFile( filename );
- if( ini_file == NULL ) return false;
- // frmMainSel->Get_FinalBandSupport( band_support );
- if(frmMainSel->cbGSM850->Checked)
- // if( band_support.GSM850 )
- {
- FrequencyBandStart = FrequencyBand850;
- }
- else
- { FrequencyBandStart = FrequencyBand900;
- }
- for(int band = FrequencyBandStart; band<=FrequencyBand1900; band++)
- {
- if( ini_file->SectionExists( (AnsiString) SUBBAND_NAME[band] ) )
- {
- return true;
- }
- }
- return false;
- }
- #endif
- //==============================================================================
- bool CRFPM::AnyIP2SectionExist( char *filename )
- {
- TIniFile *ini_file;
- ini_file = new TIniFile( filename );
- if( ini_file == NULL ) return false;
- if( ini_file->SectionExists( "GSM850 Sub band, IP2" ) ||
- ini_file->SectionExists( "GSM900 Sub band, IP2" ) ||
- ini_file->SectionExists( "DCS1800 Sub band, IP2" ) ||
- ini_file->SectionExists( "PCS1900 Sub band, IP2" )
- )
- {
- return true;
- }
- return false;
- }
- //--------------------------------------------------------------------------
- bool CRFPM::REQ_Read_IP2Reg_From_File( char *filename, unsigned int rfmod_id )
- {
- TIniFile *ini_file;
- int band;
- int FrequencyBandStart;
- ini_file = new TIniFile( filename );
- if( ini_file == NULL ) return false;
- // frmMainSel->Get_FinalBandSupport( band_support );
- if(frmMainSel->cbGSM850->Checked)
- // if( band_support.GSM850 )
- {
- FrequencyBandStart = FrequencyBand850;
- }
- else
- { FrequencyBandStart = FrequencyBand900;
- }
- switch( rfmod_id )
- {
- case RF_ID_SKY74045:
- {
- for( band = FrequencyBandStart; band<=FrequencyBand1900; band++)
- {
- c_sky74045_coef.rx.coef[band].icorrection = ini_file->ReadInteger( SUBBAND_NAME[band],
- "icorrection",
- 0);
- c_sky74045_coef.rx.coef[band].qcorrection = ini_file->ReadInteger( SUBBAND_NAME[band],
- "qcorrection",
- 0);
- }
- }
- break;
- case RF_ID_SKY74117:
- case RF_ID_SKY74400:
- {
- for( band = FrequencyBandStart; band<=FrequencyBand1900; band++)
- {
- mc_sky74117_coef.rx.coef[band].icorrection = ini_file->ReadInteger( SUBBAND_NAME[band],
- "icorrection",
- 0);
- mc_sky74117_coef.rx.coef[band].qcorrection = ini_file->ReadInteger( SUBBAND_NAME[band],
- "qcorrection",
- 0);
- }
- }
- break;
- case RF_ID_MT6139B:
- case RF_ID_MT6139C:
- case RF_ID_MT6139E:
- case RF_ID_MT6140A:
- case RF_ID_MT6140B:
- {
- for( band = FrequencyBandStart; band<=FrequencyBand1900; band++)
- {
- uc_mt6139_coef.rx.coef[band].acodeI = ini_file->ReadInteger( SUBBAND_NAME[band],
- "acodeI",
- 0);
- uc_mt6139_coef.rx.coef[band].amcodeI = ini_file->ReadInteger( SUBBAND_NAME[band],
- "amcodeI",
- 0);
- uc_mt6139_coef.rx.coef[band].acodeQ = ini_file->ReadInteger( SUBBAND_NAME[band],
- "acodeQ",
- 0);
- uc_mt6139_coef.rx.coef[band].amcodeQ = ini_file->ReadInteger( SUBBAND_NAME[band],
- "amcodeQ",
- 0);
- }
- uc_mt6139_coef.rx.rxamcalmode = ini_file->ReadInteger( "IP2 control",
- "rxamcalmode",
- RXAMCALMODE_MT6139C_NORMAL);
-
- }
- break;
- // case RF_ID_BRIGHT5P:
- default:
- break;
- }
- delete ini_file;
- return true;
- }
- //===========================================================================
- bool CRFPM::REQ_Write_IP2Reg_To_File_Single_Band( char *filename, unsigned int rfmod_id, int band )
- {
- TIniFile *ini_file;
- int FrequencyBandStart;
- ini_file = new TIniFile( filename );
- if( ini_file == NULL ) return false;
- switch( rfmod_id )
- {
- case RF_ID_SKY74045:
- {
- ini_file->WriteString( SUBBAND_NAME[band],
- "icorrection",
- c_sky74045_coef.rx.coef[band].icorrection );
- ini_file->WriteString( SUBBAND_NAME[band],
- "qcorrection",
- c_sky74045_coef.rx.coef[band].qcorrection );
- }
- break;
- case RF_ID_SKY74117:
- case RF_ID_SKY74400:
- {
- ini_file->WriteString( SUBBAND_NAME[band],
- "icorrection",
- mc_sky74117_coef.rx.coef[band].icorrection );
- ini_file->WriteString( SUBBAND_NAME[band],
- "qcorrection",
- mc_sky74117_coef.rx.coef[band].qcorrection );
- }
- break;
- case RF_ID_MT6139B:
- case RF_ID_MT6139C:
- case RF_ID_MT6139E:
- case RF_ID_MT6140A:
- case RF_ID_MT6140B:
- {
- ini_file->WriteString( SUBBAND_NAME[band],
- "acodeI",
- uc_mt6139_coef.rx.coef[band].acodeI );
- ini_file->WriteString( SUBBAND_NAME[band],
- "acodeQ",
- uc_mt6139_coef.rx.coef[band].acodeQ );
- ini_file->WriteString( SUBBAND_NAME[band],
- "amcodeI",
- uc_mt6139_coef.rx.coef[band].amcodeI );
- ini_file->WriteString( SUBBAND_NAME[band],
- "amcodeQ",
- uc_mt6139_coef.rx.coef[band].amcodeQ );
- }
- break;
- default:
- break;
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool CRFPM::REQ_Write_IP2Reg_RxAmCalMode_To_File( char *filename, unsigned int rfmod_id )
- {
- TIniFile *ini_file;
- int FrequencyBandStart;
- ini_file = new TIniFile( filename );
- if( ini_file == NULL ) return false;
- switch( rfmod_id )
- {
- case RF_ID_MT6139B:
- case RF_ID_MT6139C:
- case RF_ID_MT6139E:
- case RF_ID_MT6140A:
- case RF_ID_MT6140B:
- ini_file->WriteString( "IP2 control",
- "rxamcalmode",
- uc_mt6139_coef.rx.rxamcalmode );
- break;
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool CRFPM::REQ_Write_IP2Reg_To_File(char *filename, unsigned int rfmod_id)
- {
- TIniFile *ini_file;
- int band;
- int FrequencyBandStart;
- ini_file = new TIniFile(filename);
- if (NULL == ini_file)
- {
- return false;
- }
- // frmMainSel->Get_FinalBandSupport( band_support );
- if(frmMainSel->cbGSM850->Checked)
- // if( band_support.GSM850 )
- {
- FrequencyBandStart = FrequencyBand850;
- }
- else
- { FrequencyBandStart = FrequencyBand900;
- }
- switch( rfmod_id )
- {
- case RF_ID_SKY74045:
- {
- for( band = FrequencyBandStart; band<=FrequencyBand1900; band++)
- {
- ini_file->WriteString( SUBBAND_NAME[band],
- "icorrection",
- c_sky74045_coef.rx.coef[band].icorrection );
- ini_file->WriteString( SUBBAND_NAME[band],
- "qcorrection",
- c_sky74045_coef.rx.coef[band].qcorrection );
- }
- }
- break;
- case RF_ID_SKY74117:
- case RF_ID_SKY74400:
- {
- for( band = FrequencyBandStart; band<=FrequencyBand1900; band++)
- {
- ini_file->WriteString( SUBBAND_NAME[band],
- "icorrection",
- mc_sky74117_coef.rx.coef[band].icorrection );
- ini_file->WriteString( SUBBAND_NAME[band],
- "qcorrection",
- mc_sky74117_coef.rx.coef[band].qcorrection );
- }
- }
- break;
- case RF_ID_MT6139B:
- case RF_ID_MT6139C:
- case RF_ID_MT6139E:
- case RF_ID_MT6140A:
- case RF_ID_MT6140B:
- {
- for( band = FrequencyBandStart; band<=FrequencyBand1900; band++)
- {
- ini_file->WriteString( SUBBAND_NAME[band],
- "acodeI",
- uc_mt6139_coef.rx.coef[band].acodeI );
- ini_file->WriteString( SUBBAND_NAME[band],
- "acodeQ",
- uc_mt6139_coef.rx.coef[band].acodeQ );
- ini_file->WriteString( SUBBAND_NAME[band],
- "amcodeI",
- uc_mt6139_coef.rx.coef[band].amcodeI );
- ini_file->WriteString( SUBBAND_NAME[band],
- "amcodeQ",
- uc_mt6139_coef.rx.coef[band].amcodeQ );
- }
- ini_file->WriteString( "IP2 control",
- "rxamcalmode",
- uc_mt6139_coef.rx.rxamcalmode );
- }
- break;
- default:
- break;
- }
- return true;
- }
- //==============================================================================
- bool CRFPM::Sky74045_Coef_c2ui( c_RFMod_Sky74045_Coef_T &c_sky74045_coef, RF_SKY74045_Coef_T &ui_sky74045_coef)
- {
- unsigned char icorrection;
- unsigned char qcorrection;
- AnsiString as_correction;
- for(int i=0; i<sizeof(c_sky74045_coef.rx.coef)/sizeof(c_sky74045_coef.rx.coef[0]); i++)
- {
- if( c_sky74045_coef.rx.coef[i].icorrection < 0 )
- {
- as_correction = IntToStr( c_sky74045_coef.rx.coef[i].icorrection );
- AnsiString_To_msbUnsignedChar( as_correction, icorrection, -127, 127 );
- ui_sky74045_coef.rx.coef[i].icorrection = (unsigned int) icorrection;
- }
- else
- {
- ui_sky74045_coef.rx.coef[i].icorrection = c_sky74045_coef.rx.coef[i].icorrection & 0x0000007f;
- }
- if( c_sky74045_coef.rx.coef[i].qcorrection < 0 )
- {
- as_correction = IntToStr( c_sky74045_coef.rx.coef[i].qcorrection );
- AnsiString_To_msbUnsignedChar( as_correction, qcorrection, -127, 127 );
- ui_sky74045_coef.rx.coef[i].qcorrection = (unsigned int) qcorrection;
- }
- else
- {
- ui_sky74045_coef.rx.coef[i].qcorrection = c_sky74045_coef.rx.coef[i].qcorrection & 0x0000007f;
- }
- }
- return true;
- }
- //------------------------------------------------------------------------------
- bool CRFPM::Sky74045_Coef_ui2c( RF_SKY74045_Coef_T &ui_sky74045_coef, c_RFMod_Sky74045_Coef_T &c_sky74045_coef)
- {
- signed char icorrection;
- signed char qcorrection;
- AnsiString as_correction;
- for(int i=0; i<sizeof(ui_sky74045_coef.rx.coef)/sizeof(ui_sky74045_coef.rx.coef[0]); i++)
- {
- if( ui_sky74045_coef.rx.coef[i].icorrection & 0x00000080 )
- {
- icorrection = ui_sky74045_coef.rx.coef[i].icorrection & 0x0000007F;
- as_correction = IntToStr( icorrection );
- as_correction = "-" + as_correction;
- c_sky74045_coef.rx.coef[i].icorrection = as_correction.ToInt();
- }
- else
- {
- c_sky74045_coef.rx.coef[i].icorrection = ui_sky74045_coef.rx.coef[i].icorrection & 0x0000007f;
- }
- if( ui_sky74045_coef.rx.coef[i].qcorrection & 0x00000080 )
- {
- qcorrection = ui_sky74045_coef.rx.coef[i].qcorrection & 0x0000007F;
- as_correction = IntToStr( qcorrection );
- as_correction = "-" + as_correction;
- c_sky74045_coef.rx.coef[i].qcorrection = as_correction.ToInt();
- }
- else
- {
- c_sky74045_coef.rx.coef[i].qcorrection = ui_sky74045_coef.rx.coef[i].qcorrection & 0x0000007f;
- }
- }
- return true;
- }
- //==============================================================================
- void CRFPM::Sky74117_Coef_c2ui( c_RFMod_Sky74117_Coef_T &c_sky74117_coef, RF_SKY74117_Coef_T &ui_sky74117_coef)
- {
- unsigned char icorrection;
- unsigned char qcorrection;
- AnsiString as_correction;
- for(int i=0; i<sizeof(c_sky74117_coef.rx.coef)/sizeof(c_sky74117_coef.rx.coef[0]); i++)
- {
- if( c_sky74117_coef.rx.coef[i].icorrection < 0 )
- {
- as_correction = IntToStr( c_sky74117_coef.rx.coef[i].icorrection );
- as_correction = as_correction.SubString(2, as_correction.Length()-1);
- ui_sky74117_coef.rx.coef[i].icorrection = (unsigned int) as_correction.ToInt();
- ui_sky74117_coef.rx.pol[i].ipol = 1;
- }
- else
- {
- ui_sky74117_coef.rx.coef[i].icorrection = (unsigned int) c_sky74117_coef.rx.coef[i].icorrection & 0x0000007f;
- ui_sky74117_coef.rx.pol[i].ipol = 0;
- }
- if( c_sky74117_coef.rx.coef[i].qcorrection < 0 )
- {
- as_correction = IntToStr( c_sky74117_coef.rx.coef[i].qcorrection );
- as_correction = as_correction.SubString(2, as_correction.Length()-1);
- ui_sky74117_coef.rx.coef[i].qcorrection = (unsigned int) as_correction.ToInt();
- ui_sky74117_coef.rx.pol[i].qpol = 1;
- }
- else
- {
- ui_sky74117_coef.rx.coef[i].qcorrection = (unsigned int) c_sky74117_coef.rx.coef[i].qcorrection & 0x0000007f;
- ui_sky74117_coef.rx.pol[i].qpol = 0;
- }
- }
- }
- //------------------------------------------------------------------------------
- void CRFPM::Sky74117_Coef_ui2c( RF_SKY74117_Coef_T &ui_sky74117_coef, c_RFMod_Sky74117_Coef_T &c_sky74117_coef)
- {
- signed char icorrection;
- signed char qcorrection;
- AnsiString as_correction;
- for(int i=0; i<sizeof(ui_sky74117_coef.rx.coef)/sizeof(ui_sky74117_coef.rx.coef[0]); i++)
- {
- if( ui_sky74117_coef.rx.pol[i].ipol ) // negtive
- {
- icorrection = ui_sky74117_coef.rx.coef[i].icorrection;
- as_correction = IntToStr( icorrection );
- as_correction = "-" + as_correction;
- c_sky74117_coef.rx.coef[i].icorrection = as_correction.ToInt();
- }
- else
- {
- c_sky74117_coef.rx.coef[i].icorrection = ui_sky74117_coef.rx.coef[i].icorrection;
- }
- if( ui_sky74117_coef.rx.pol[i].qpol ) // negtive
- {
- qcorrection = ui_sky74117_coef.rx.coef[i].qcorrection;
- as_correction = IntToStr( qcorrection );
- as_correction = "-" + as_correction;
- c_sky74117_coef.rx.coef[i].qcorrection = as_correction.ToInt();
- }
- else
- {
- c_sky74117_coef.rx.coef[i].qcorrection = ui_sky74117_coef.rx.coef[i].qcorrection;
- }
- }
-
- }
- //------------------------------------------------------------------------------
- void CRFPM::MT6139_Coef_uc2ui( uc_RFMod_MT6139_Coef_T &uc_mt6139_coef, RF_MT6139B_Coef_T &ui_mt6139_coef)
- {
- for(int i=0; i<sizeof(uc_mt6139_coef.rx.coef)/sizeof(uc_mt6139_coef.rx.coef[0]); i++)
- {
- ui_mt6139_coef.rx.coef[i].acode = (uc_mt6139_coef.rx.coef[i].acodeI<<6 | uc_mt6139_coef.rx.coef[i].acodeQ) & 0x0FFF;
- ui_mt6139_coef.rx.coef[i].amcode = (uc_mt6139_coef.rx.coef[i].amcodeI<<8 | uc_mt6139_coef.rx.coef[i].amcodeQ) & 0xFFFF;
- }
- ui_mt6139_coef.rx.rxamcalmode = uc_mt6139_coef.rx.rxamcalmode;
-
- }
- //------------------------------------------------------------------------------
- void CRFPM::MT6139_Coef_ui2uc( RF_MT6139B_Coef_T &ui_mt6139_coef, uc_RFMod_MT6139_Coef_T &uc_mt6139_coef)
- {
- for(int i=0; i<sizeof(ui_mt6139_coef.rx.coef)/sizeof(ui_mt6139_coef.rx.coef[0]); i++)
- {
- uc_mt6139_coef.rx.coef[i].acodeI = (ui_mt6139_coef.rx.coef[i].acode >> 6) & 0x3F;
- uc_mt6139_coef.rx.coef[i].acodeQ = (ui_mt6139_coef.rx.coef[i].acode) & 0x3F;
- uc_mt6139_coef.rx.coef[i].amcodeI = (ui_mt6139_coef.rx.coef[i].amcode >> 8) & 0xFF;
- uc_mt6139_coef.rx.coef[i].amcodeQ = (ui_mt6139_coef.rx.coef[i].amcode) & 0xFF;
- }
- uc_mt6139_coef.rx.rxamcalmode = ui_mt6139_coef.rx.rxamcalmode;
- }
- //------------------------------------------------------------------------------
- signed char CRFPM::Get_realcoefofcx( unsigned char cx, unsigned int rfid )
- {
- int i_realcoef;
- signed char c_realcoef;
- if( (unsigned int) RF_ID_SKY74045 == rfid )
- {
- if (cx <= 127)
- i_realcoef = (cx * (-1)) & 0xFF;
- else
- i_realcoef = (255-cx) & 0xFF;
- }
- else if( (unsigned int) RF_ID_SKY74117 == rfid || (unsigned int) RF_ID_SKY74400 == rfid )
- {
- if (cx <= 63)
- i_realcoef = (cx * (-1)) & 0xFF;
- else
- i_realcoef = (127-cx) & 0xFF;
- }
- c_realcoef = (signed char) i_realcoef & 0xFF;
- return c_realcoef;
- }
- //------------------------------------------------------------------------------
- unsigned char CRFPM::Get_cxofrealcoef( signed char realcoef, unsigned int rfid )
- {
- unsigned char cx;
- if( (unsigned int) RF_ID_SKY74045 == rfid )
- {
- if (realcoef < 0)
- cx = (unsigned char) realcoef * (-1);
- else
- cx = 255-realcoef;
- }
- else if( (unsigned int) RF_ID_SKY74117 == rfid || (unsigned int) RF_ID_SKY74400 == rfid )
- {
- if (realcoef < 0)
- cx = (unsigned char) realcoef * (-1);
- else
- cx = 127-realcoef;
- }
- return cx;
- }
- //------------------------------------------------------------------------------
- bool CRFPM::Get_cxofDC0( IP2vsDC_T &ip2vsdc, unsigned char &cx )
- {
- if( (ip2vsdc.c1 - ip2vsdc.c0) == 0 ) return false;
- int slope = (ip2vsdc.DC1 - ip2vsdc.DC0) / (ip2vsdc.c1 - ip2vsdc.c0);
- int offset = ip2vsdc.DC0 - slope*ip2vsdc.c0;
- cx = - offset/slope;
- return true;
- }
- //------------------------------------------------------------------------------
- bool CRFPM::Evaluate_sky74045(signed char &rcx_I, signed char &rcx_Q, unsigned int rfid)
- {
- unsigned char c0_I = Get_cxofrealcoef(EvalPmrcx_I_sky[0], rfid);
- unsigned char c1_I = Get_cxofrealcoef(EvalPmrcx_I_sky[1], rfid);
- unsigned char c0_Q = Get_cxofrealcoef(EvalPmrcx_Q_sky[0], rfid);
- unsigned char c1_Q = Get_cxofrealcoef(EvalPmrcx_Q_sky[1], rfid);
- int f0_I = EvalDC_I_sky[0];
- int f1_I = EvalDC_I_sky[1];
- int f0_Q = EvalDC_Q_sky[0];
- int f1_Q = EvalDC_Q_sky[1];
- rcx_I = 0;
- rcx_Q = 0;
- if ((c1_I - c0_I) == 0 && (c1_Q - c0_Q)==0)
- {
- return false;
- }
- if ((c1_I - c0_I) != 0)
- {
- float slope_I = 1.0*(f1_I - f0_I) / (c1_I - c0_I);
- int offset_I = f0_I - slope_I*c0_I;
- if (slope_I != 0)
- {
- unsigned char cx_I = - offset_I/slope_I;
- rcx_I = Get_realcoefofcx( cx_I, rfid );
- if (rcx_I < SKY74045_RCX_MIN)
- {
- rcx_I = SKY74045_RCX_MIN;
- }
- }
- }
- if ((c1_Q - c0_Q) != 0)
- {
- float slope_Q = 1.0*(f1_Q - f0_Q) / (c1_Q - c0_Q);
- int offset_Q = f0_Q - slope_Q*c0_Q;
- if (slope_Q != 0)
- {
- unsigned char cx_Q = - offset_Q/slope_Q;
- rcx_Q = Get_realcoefofcx( cx_Q, rfid );
- if (rcx_Q < SKY74045_RCX_MIN)
- {
- rcx_Q = SKY74045_RCX_MIN;
- }
- }
- }
- return true;
- }
- //------------------------------------------------------------------------------
- bool CRFPM::Evaluate_sky74117( signed char &rcx_I, signed char &rcx_Q, unsigned int rfid )
- {
- unsigned char c0_I = Get_cxofrealcoef(EvalPmrcx_I_sky[0], rfid);
- unsigned char c1_I = Get_cxofrealcoef(EvalPmrcx_I_sky[1], rfid);
- unsigned char c0_Q = Get_cxofrealcoef(EvalPmrcx_Q_sky[0], rfid);
- unsigned char c1_Q = Get_cxofrealcoef(EvalPmrcx_Q_sky[1], rfid);
- int f0_I = EvalDC_I_sky[0];
- int f1_I = EvalDC_I_sky[1];
- int f0_Q = EvalDC_Q_sky[0];
- int f1_Q = EvalDC_Q_sky[1];
- rcx_I = 0;
- rcx_Q = 0;
- if( (c1_I - c0_I) == 0 && (c1_Q - c0_Q)==0 ) return false;
- if( (c1_I - c0_I) != 0 )
- {
- float slope_I = 1.0*(f1_I - f0_I) / (c1_I - c0_I);
- int offset_I = f0_I - slope_I*c0_I;
- if( slope_I != 0 )
- {
- unsigned char cx_I = - offset_I/slope_I;
- rcx_I = Get_realcoefofcx( cx_I, rfid );
- if( rcx_I < SKY74117_RCX_MIN ) rcx_I = SKY74117_RCX_MIN;
- else if( rcx_I > SKY74117_RCX_MAX ) rcx_I = SKY74117_RCX_MAX;
- }
- }
- if( (c1_Q - c0_Q) != 0 )
- {
- float slope_Q = 1.0*(f1_Q - f0_Q) / (c1_Q - c0_Q);
- int offset_Q = f0_Q - slope_Q*c0_Q;
- if( slope_Q != 0 )
- {
- unsigned char cx_Q = - offset_Q/slope_Q;
- rcx_Q = Get_realcoefofcx( cx_Q, rfid );
- if( rcx_Q < SKY74117_RCX_MIN ) rcx_Q = SKY74117_RCX_MIN;
- else if( rcx_Q > SKY74117_RCX_MAX ) rcx_Q = SKY74117_RCX_MAX;
- }
- }
- return true;
- }
- //------------------------------------------------------------------------------
- bool CRFPM::Evaluate_mt6139( unsigned char &AcodeI0, unsigned char &AcodeQ0,
- unsigned char &AmcodeI0, unsigned char &AmcodeQ0 )
- {
- unsigned char c0_AcodeI = EvalAcodeI_mt[0];
- unsigned char c0_AcodeQ = EvalAcodeQ_mt[0];
- unsigned char c1_AcodeI = EvalAcodeI_mt[1];
- unsigned char c1_AcodeQ = EvalAcodeQ_mt[1];
- unsigned char c0_AmcodeI = EvalAmcodeI_mt[0];
- unsigned char c0_AmcodeQ = EvalAmcodeQ_mt[0];
- unsigned char c1_AmcodeI = EvalAmcodeI_mt[1];
- unsigned char c1_AmcodeQ = EvalAmcodeQ_mt[1];
- // EvalDC_AcodeI_mt[0] = EvalMdcOn_AcodeI_mt[0];
- // EvalDC_AcodeI_mt[1] = EvalMdcOn_AcodeI_mt[1];
- // EvalDC_AcodeQ_mt[0] = EvalMdcOn_AcodeQ_mt[0];
- // EvalDC_AcodeQ_mt[1] = EvalMdcOn_AcodeQ_mt[1];
- EvalDC_AmcodeI_mt[0] = EvalMdcOn_AmcodeI_mt[0]-EvalMdcOff_AmcodeI_mt[0];
- EvalDC_AmcodeI_mt[1] = EvalMdcOn_AmcodeI_mt[1]-EvalMdcOff_AmcodeI_mt[1];
- EvalDC_AmcodeQ_mt[0] = EvalMdcOn_AmcodeQ_mt[0]-EvalMdcOff_AmcodeQ_mt[0];
- EvalDC_AmcodeQ_mt[1] = EvalMdcOn_AmcodeQ_mt[1]-EvalMdcOff_AmcodeQ_mt[1];
- // int f0_AcodeI = EvalDC_AcodeI_mt[0];
- // int f1_AcodeI = EvalDC_AcodeI_mt[1];
- // int f0_AcodeQ = EvalDC_AcodeQ_mt[0];
- // int f1_AcodeQ = EvalDC_AcodeQ_mt[1];
- int f0_AmcodeI = EvalDC_AmcodeI_mt[0];
- int f1_AmcodeI = EvalDC_AmcodeI_mt[1];
- int f0_AmcodeQ = EvalDC_AmcodeQ_mt[0];
- int f1_AmcodeQ = EvalDC_AmcodeQ_mt[1];
- AcodeI0 = 0;
- AcodeQ0 = 0;
- AmcodeI0 = 0;
- AmcodeQ0 = 0;
- if( (c0_AcodeI - c1_AcodeI) == 0 && (c0_AcodeQ - c1_AcodeQ)==0 &&
- (c0_AmcodeI - c1_AmcodeI)==0 && (c0_AmcodeQ - c1_AmcodeQ)==0 ) return false;
- // AcodeI0
- AcodeI0 = ( c1_AcodeI + c0_AcodeI)/2;
- if( AcodeI0 > 63 ) AcodeI0 = 63;
- //if( (c1_AcodeI - c0_AcodeI) != 0 )
- // {
- // float slope_AcodeI = 1.0*(f1_AcodeI - f0_AcodeI) / (c1_AcodeI - c0_AcodeI);
- // int offset_AcodeI = f0_AcodeI - slope_AcodeI*c0_AcodeI;
- // if( slope_AcodeI != 0 )
- // {
- // AcodeI0 = - offset_AcodeI/slope_AcodeI;
- // }
- // }
- // AcodeQ0
- AcodeQ0 = ( c1_AcodeQ + c0_AcodeQ)/2;
- if( AcodeQ0 > 63 ) AcodeQ0 = 63;
- // if( (c1_AcodeQ - c0_AcodeQ) != 0 )
- // {
- // float slope_AcodeQ = 1.0*(f1_AcodeQ - f0_AcodeQ) / (c1_AcodeQ - c0_AcodeQ);
- // int offset_AcodeQ = f0_AcodeQ - slope_AcodeQ*c0_AcodeQ;
- // if( slope_AcodeQ != 0 )
- // {
- // AcodeQ0 = - offset_AcodeQ/slope_AcodeQ;
- // }
- // }
- // AMcodeI0
- if( (c1_AmcodeI - c0_AmcodeI) != 0 )
- {
- float slope_AmcodeI = 1.0*(f1_AmcodeI - f0_AmcodeI) / (c1_AmcodeI - c0_AmcodeI);
- int offset_AmcodeI = f0_AmcodeI - slope_AmcodeI*c0_AmcodeI;
- if( slope_AmcodeI != 0 )
- {
- AmcodeI0 = - offset_AmcodeI/slope_AmcodeI;
- }
- }
- // AMcodeQ0
- if( (c1_AmcodeQ - c0_AmcodeQ) != 0 )
- {
- float slope_AmcodeQ = 1.0*(f1_AmcodeQ - f0_AmcodeQ) / (c1_AmcodeQ - c0_AmcodeQ);
- int offset_AmcodeQ = f0_AmcodeQ - slope_AmcodeQ*c0_AmcodeQ;
- if( slope_AmcodeQ != 0 )
- {
- AmcodeQ0 = - offset_AmcodeQ/slope_AmcodeQ;
- }
- }
- return true;
- }
- //==============================================================================
- void CRFPM::Set_Sky74045Coef( RF_SKY74045_Coef_T &ui_sky74045_coef )
- {
- sky74045_coef = ui_sky74045_coef;
- }
- //---------------------------------------------------------------------------
- void CRFPM::Set_MT6139Coef( RF_MT6139B_Coef_T &ui_mt6139_coef )
- {
- mt6139_coef = ui_mt6139_coef;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CRFPM::Get_cSky74045Coef( c_RFMod_Sky74045_Coef_T &char_sky74045_coef )
- {
- char_sky74045_coef = c_sky74045_coef;
- }
- //---------------------------------------------------------------------------
- void CRFPM::Set_cSky74045Coef( c_RFMod_Sky74045_Coef_T &char_sky74045_coef )
- {
- c_sky74045_coef = char_sky74045_coef;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CRFPM::Get_cSky74117Coef( c_RFMod_Sky74117_Coef_T &c_sky74117_coef )
- {
- c_sky74117_coef = mc_sky74117_coef;
- }
- //---------------------------------------------------------------------------
- void CRFPM::Set_cSky74117Coef( c_RFMod_Sky74117_Coef_T &c_sky74117_coef )
- {
- mc_sky74117_coef = c_sky74117_coef;
- }
- //----------------------------------------------------------------------------
- void CRFPM::Get_ucMT6139Coef( uc_RFMod_MT6139_Coef_T &uchar_mt6139_coef )
- {
- uchar_mt6139_coef = uc_mt6139_coef;
- }
- //----------------------------------------------------------------------------
- void CRFPM::Set_ucMT6139Coef( uc_RFMod_MT6139_Coef_T &uchar_mt6139_coef )
- {
- uc_mt6139_coef = uchar_mt6139_coef;
- }
- //----------------------------------------------------------------------------
- void CRFPM::Set_ucMT6139CoefExceptCalMode( uc_RFMod_MT6139_Coef_T &uchar_mt6139_coef )
- {
- for(int i=0; i<sizeof(uc_mt6139_coef.rx.coef)/sizeof(uc_mt6139_coef.rx.coef[0]); i++)
- {
- uc_mt6139_coef.rx.coef[i].acodeI = uchar_mt6139_coef.rx.coef[i].acodeI;
- uc_mt6139_coef.rx.coef[i].acodeQ = uchar_mt6139_coef.rx.coef[i].acodeQ;
- uc_mt6139_coef.rx.coef[i].amcodeI = uchar_mt6139_coef.rx.coef[i].amcodeI;
- uc_mt6139_coef.rx.coef[i].amcodeQ = uchar_mt6139_coef.rx.coef[i].amcodeQ;
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CRFPM::Get_AcodeFromReg_Start( FrequencyBand freq_band, uc_RFMod_MT6139_Coef_T &uc_mt6139_coef_par, unsigned int rf_id )
- {
- rf_pm_ptr = this;
- g_bIsRunning = true;
- m_uiFinalRfid = rf_id;
- m_FreqBand = freq_band;
- p_uc_mt6139_coef = &uc_mt6139_coef_par;
- ActiveMan->SetActiveFunction( ::Get_AcodeFromReg );
- }
- //----------------------------------------------------------------------------
- void CRFPM::Get_AcodeFromReg( void )
- {
- if( ! g_bIsRunning )
- { Confirm( METAAPP_FAIL ); return; }
- unsigned int reg_data;
- // unsigned int reg_addr=ADDR_AUXOUT_ACODE;
- // Acode
- META_RESULT MetaResult = META_Rf_GetRFImmediateBSI_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, ADDR_MT6139_AUXOUT_CW2, ®_data);
- if(MetaResult!=META_SUCCESS)
- {
- if( MetaResult!=META_TIMEOUT )
- { Confirm( METAAPP_FAIL ); return; }
- else
- { Confirm( METAAPP_TIMEOUT ); return; }
- }
- uc_mt6139_coef.rx.coef[m_FreqBand].acodeI = (reg_data >> 15) & 0x3F;
- uc_mt6139_coef.rx.coef[m_FreqBand].acodeQ = (reg_data >> 9) & 0x3F;
- p_uc_mt6139_coef->rx.coef[m_FreqBand].acodeI = uc_mt6139_coef.rx.coef[m_FreqBand].acodeI;
- p_uc_mt6139_coef->rx.coef[m_FreqBand].acodeQ = uc_mt6139_coef.rx.coef[m_FreqBand].acodeQ;
- DeCompose_MT6139CW2( reg_data, mt6139_cw2, m_uiFinalRfid );
- ActiveMan->SetActiveFunction( ::REQ_Finish );
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CRFPM::Get_BCcodeFromReg_Start( FrequencyBand freq_band, uc_RFMod_MT6139_Coef_T &uc_mt6139_coef_par, unsigned int rf_id )
- {
- rf_pm_ptr = this;
- g_bIsRunning = true;
- m_FreqBand = freq_band;
- p_uc_mt6139_coef = &uc_mt6139_coef_par;
- m_uiFinalRfid = rf_id;
- ActiveMan->SetActiveFunction( ::Get_BCcodeFromReg );
- }
- //----------------------------------------------------------------------------
- void CRFPM::Get_BCcodeFromReg( void )
- {
- if( ! g_bIsRunning )
- { Confirm( METAAPP_FAIL ); return; }
- unsigned int reg_data;
- // B, C codeI
- META_RESULT MetaResult = META_Rf_GetRFImmediateBSI_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, ADDR_MT6139_AUXOUT_CW8, ®_data);
- if(MetaResult!=META_SUCCESS)
- {
- if( MetaResult!=META_TIMEOUT )
- { Confirm( METAAPP_FAIL ); return; }
- else
- { Confirm( METAAPP_TIMEOUT ); return; }
- }
- uc_mt6139_coef.rx.coef[m_FreqBand].ccodeI = reg_data & 0x7F;
- uc_mt6139_coef.rx.coef[m_FreqBand].bcodeI = (reg_data >> 7) & 0x7F;
- p_uc_mt6139_coef->rx.coef[m_FreqBand].ccodeI = uc_mt6139_coef.rx.coef[m_FreqBand].ccodeI;
- p_uc_mt6139_coef->rx.coef[m_FreqBand].bcodeI = uc_mt6139_coef.rx.coef[m_FreqBand].bcodeI;
- DeCompose_MT6139CW8( reg_data, mt6139_cw8, m_uiFinalRfid );
- // B, C codeQ
- MetaResult = META_Rf_GetRFImmediateBSI_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, ADDR_MT6139_AUXOUT_CW9, ®_data);
- if(MetaResult!=META_SUCCESS)
- {
- if( MetaResult!=META_TIMEOUT )
- { Confirm( METAAPP_FAIL ); return; }
- else
- { Confirm( METAAPP_TIMEOUT ); return; }
- }
- uc_mt6139_coef.rx.coef[m_FreqBand].ccodeQ = reg_data & 0x7F;
- uc_mt6139_coef.rx.coef[m_FreqBand].bcodeQ = (reg_data >> 7) & 0x7F;
- p_uc_mt6139_coef->rx.coef[m_FreqBand].ccodeQ = uc_mt6139_coef.rx.coef[m_FreqBand].ccodeQ;
- p_uc_mt6139_coef->rx.coef[m_FreqBand].bcodeQ = uc_mt6139_coef.rx.coef[m_FreqBand].bcodeQ;
- DeCompose_MT6139CW9( reg_data, mt6139_cw9, m_uiFinalRfid );
- ActiveMan->SetActiveFunction( ::REQ_Finish );
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CRFPM::Get_ABCcodeFromReg_Start( FrequencyBand freq_band, uc_RFMod_MT6139_Coef_T &uc_mt6139_coef_par, unsigned int rf_id )
- {
- rf_pm_ptr = this;
- g_bIsRunning = true;
- m_uiFinalRfid = rf_id;
- m_FreqBand = freq_band;
- p_uc_mt6139_coef = &uc_mt6139_coef_par;
- ActiveMan->SetActiveFunction( ::Get_ABCcodeFromReg );
- }
- //----------------------------------------------------------------------------
- void CRFPM::Get_ABCcodeFromReg( void )
- {
- if( ! g_bIsRunning )
- { Confirm( METAAPP_FAIL ); return; }
- unsigned int reg_data;
- // unsigned int reg_addr=ADDR_AUXOUT_ACODE;
- // Acode
- META_RESULT MetaResult = META_Rf_GetRFImmediateBSI_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, ADDR_MT6139_AUXOUT_CW2, ®_data);
- if(MetaResult!=META_SUCCESS)
- {
- if( MetaResult!=META_TIMEOUT )
- { Confirm( METAAPP_FAIL ); return; }
- else
- { Confirm( METAAPP_TIMEOUT ); return; }
- }
- uc_mt6139_coef.rx.coef[m_FreqBand].acodeI = (reg_data >> 15) & 0x3F;
- uc_mt6139_coef.rx.coef[m_FreqBand].acodeQ = (reg_data >> 9) & 0x3F;
- p_uc_mt6139_coef->rx.coef[m_FreqBand].acodeI = uc_mt6139_coef.rx.coef[m_FreqBand].acodeI;
- p_uc_mt6139_coef->rx.coef[m_FreqBand].acodeQ = uc_mt6139_coef.rx.coef[m_FreqBand].acodeQ;
- DeCompose_MT6139CW2( reg_data, mt6139_cw2, m_uiFinalRfid );
- // B, C codeI
- MetaResult = META_Rf_GetRFImmediateBSI_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, ADDR_MT6139_AUXOUT_CW8, ®_data);
- if(MetaResult!=META_SUCCESS)
- {
- if( MetaResult!=META_TIMEOUT )
- { Confirm( METAAPP_FAIL ); return; }
- else
- { Confirm( METAAPP_TIMEOUT ); return; }
- }
- uc_mt6139_coef.rx.coef[m_FreqBand].ccodeI = reg_data & 0x7F;
- uc_mt6139_coef.rx.coef[m_FreqBand].bcodeI = (reg_data >> 7) & 0x7F;
- p_uc_mt6139_coef->rx.coef[m_FreqBand].ccodeI = uc_mt6139_coef.rx.coef[m_FreqBand].ccodeI;
- p_uc_mt6139_coef->rx.coef[m_FreqBand].bcodeI = uc_mt6139_coef.rx.coef[m_FreqBand].bcodeI;
- DeCompose_MT6139CW8( reg_data, mt6139_cw8, m_uiFinalRfid );
- // B, C codeQ
- MetaResult = META_Rf_GetRFImmediateBSI_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, ADDR_MT6139_AUXOUT_CW9, ®_data);
- if(MetaResult!=META_SUCCESS)
- {
- if( MetaResult!=META_TIMEOUT )
- { Confirm( METAAPP_FAIL ); return; }
- else
- { Confirm( METAAPP_TIMEOUT ); return; }
- }
- uc_mt6139_coef.rx.coef[m_FreqBand].ccodeQ = reg_data & 0x7F;
- uc_mt6139_coef.rx.coef[m_FreqBand].bcodeQ = (reg_data >> 7) & 0x7F;
- p_uc_mt6139_coef->rx.coef[m_FreqBand].ccodeQ = uc_mt6139_coef.rx.coef[m_FreqBand].ccodeQ;
- p_uc_mt6139_coef->rx.coef[m_FreqBand].bcodeQ = uc_mt6139_coef.rx.coef[m_FreqBand].bcodeQ;
- DeCompose_MT6139CW9( reg_data, mt6139_cw9, m_uiFinalRfid );
- ActiveMan->SetActiveFunction( ::REQ_Finish );
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CRFPM::Set_MT6139CW2ToReg_Start( unsigned char mode_par, unsigned int rf_id )
- {
- rf_pm_ptr = this;
- g_bIsRunning = true;
- m_uiFinalRfid = rf_id;
- mode = mode_par;
- ActiveMan->SetActiveFunction( ::Set_MT6139CW2ToReg );
- }
- //----------------------------------------------------------------------------
- void CRFPM::Set_MT6139CW2ToReg( void )
- {
- if( ! g_bIsRunning )
- { Confirm( METAAPP_FAIL ); return; }
- unsigned int bsi_data;
- mt6139_cw2.uc_mode = mode;
- Compose_MT6139CW2( mt6139_cw2, bsi_data, m_uiFinalRfid );
- META_RESULT MetaResult = META_Rf_SetRFImmediateBSI_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, bsi_data);
- if(MetaResult!=META_SUCCESS)
- {
- if( MetaResult!=META_TIMEOUT )
- { Confirm( METAAPP_FAIL ); return; }
- else
- { Confirm( METAAPP_TIMEOUT ); return; }
- }
- ActiveMan->SetActiveFunction( ::REQ_Finish );
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CRFPM::Set_BCcodeToReg_Start( FrequencyBand freq_band, uc_RFMod_MT6139_Coef_T &uc_mt6139_coef_par, unsigned int rf_id )
- {
- rf_pm_ptr = this;
- g_bIsRunning = true;
- m_FreqBand = freq_band;
- uc_mt6139_coef = uc_mt6139_coef_par;
- ActiveMan->SetActiveFunction( ::Set_BCcodeToReg );
- }
- //----------------------------------------------------------------------------
- void CRFPM::Set_BCcodeToReg( void )
- {
- if( ! g_bIsRunning )
- { Confirm( METAAPP_FAIL ); return; }
- unsigned int bsi_data;
- // CW8
- mt6139_cw8.uc_dc_dac_bi = uc_mt6139_coef.rx.coef[m_FreqBand].bcodeI;
- mt6139_cw8.uc_dc_dac_ci = uc_mt6139_coef.rx.coef[m_FreqBand].ccodeI;
- Compose_MT6139CW8( mt6139_cw8, bsi_data, m_uiFinalRfid );
- // bsi_data = uc_mt6139_coef_par.rx.coef[FreqBand].bcodeI<<11 | uc_mt6139_coef_par.rx.coef[FreqBand].ccodeI<<4 | ADDR_MT6139_CW8;
- META_RESULT MetaResult = META_Rf_SetRFImmediateBSI_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, bsi_data);
- if(MetaResult!=META_SUCCESS)
- {
- if( MetaResult!=META_TIMEOUT )
- { Confirm( METAAPP_FAIL ); return; }
- else
- { Confirm( METAAPP_TIMEOUT ); return; }
- }
- // CW9
- mt6139_cw9.uc_dc_dac_bq = uc_mt6139_coef.rx.coef[m_FreqBand].bcodeQ;
- mt6139_cw9.uc_dc_dac_cq = uc_mt6139_coef.rx.coef[m_FreqBand].ccodeQ;
- Compose_MT6139CW9( mt6139_cw9, bsi_data, m_uiFinalRfid );
- // bsi_data = uc_mt6139_coef_par.rx.coef[FreqBand].bcodeQ<<11 | uc_mt6139_coef_par.rx.coef[FreqBand].ccodeQ<<4 | ADDR_MT6139_CW9;
- MetaResult = META_Rf_SetRFImmediateBSI_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, bsi_data);
- if(MetaResult!=META_SUCCESS)
- {
- if( MetaResult!=META_TIMEOUT )
- { Confirm( METAAPP_FAIL ); return; }
- else
- { Confirm( METAAPP_TIMEOUT ); return; }
- }
- #if 0
- uc_mt6139_coef.rx.coef[FreqBand].bcodeI = uc_mt6139_coef_par.rx.coef[FreqBand].bcodeI;
- uc_mt6139_coef.rx.coef[FreqBand].bcodeQ = uc_mt6139_coef_par.rx.coef[FreqBand].bcodeQ;
- uc_mt6139_coef.rx.coef[FreqBand].ccodeI = uc_mt6139_coef_par.rx.coef[FreqBand].ccodeI;
- uc_mt6139_coef.rx.coef[FreqBand].ccodeQ = uc_mt6139_coef_par.rx.coef[FreqBand].ccodeQ;
- #endif
- ActiveMan->SetActiveFunction( ::REQ_Finish );
-
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- //////////////////////////// CW2 /////////////////////////////////
- //----------------------------------------------------------------------------
- void CRFPM::Compose_MT6139CW2( S_MT6139_CW2 &mt6139_cw2_par, unsigned int &bsi_data, unsigned int rf_id )
- {
- if( RF_ID_MT6139B == rf_id ||
- RF_ID_MT6139C == rf_id ||
- RF_ID_MT6139E == rf_id ||
- RF_ID_MT6140A == rf_id
- )
- {
- bsi_data = mt6139_cw2_par.uc_dc_dac_ai << 19 |
- mt6139_cw2_par.uc_dc_dac_aq << 13 |
- mt6139_cw2_par.uc_mode << 10 |
- mt6139_cw2_par.uc_gain_table << 4 |
- ADDR_MT6139_CW2;
- }
- else
- {
- bsi_data = mt6139_cw2_par.uc_dc_dac_ai << 20 |
- mt6139_cw2_par.uc_dc_dac_aq << 14 |
- mt6139_cw2_par.uc_auto_cal << 13 |
- mt6139_cw2_par.uc_mode << 10 |
- mt6139_cw2_par.uc_gain_table << 4 |
- ADDR_MT6139_CW2;
- }
- }
- //----------------------------------------------------------------------------
- void CRFPM::DeCompose_MT6139CW2( unsigned int reg_data, S_MT6139_CW2 &mt6139_cw2_par, unsigned int rf_id )
- {
- if( RF_ID_MT6139B == rf_id ||
- RF_ID_MT6139C == rf_id ||
- RF_ID_MT6140A == rf_id
- )
- {
- mt6139_cw2_par.uc_dc_dac_ai = (reg_data >> 15) & 0x3F;
- mt6139_cw2_par.uc_dc_dac_aq = (reg_data >> 9) & 0x3F;
- mt6139_cw2_par.uc_mode = (reg_data >> 6) & 0x07;
- mt6139_cw2_par.uc_gain_table = (reg_data ) & 0x3F;
- }
- else
- {
- mt6139_cw2_par.uc_dc_dac_ai = (reg_data >> 16) & 0x3F;
- mt6139_cw2_par.uc_dc_dac_aq = (reg_data >> 10) & 0x3F;
- mt6139_cw2_par.uc_auto_cal = (reg_data >> 9) & 0x01;
- mt6139_cw2_par.uc_mode = (reg_data >> 6) & 0x07;
- mt6139_cw2_par.uc_gain_table = (reg_data ) & 0x3F;
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- //////////////////////////// CW7 /////////////////////////////////
- //----------------------------------------------------------------------------
- void CRFPM::Compose_MT6139CW7( S_MT6139_CW7 &mt6139_cw7_par, unsigned int &bsi_data, unsigned int rf_id )
- {
- if( RF_ID_MT6139B == rf_id ||
- RF_ID_MT6139C == rf_id
- )
- {
- bsi_data = (mt6139_cw7_par.uc_reserved<<18) |
- (mt6139_cw7_par.uc_lo_vsw<<15) |
- (mt6139_cw7_par.uc_lpf_corner<<14) |
- (mt6139_cw7_par.uc_auto_cal<<13) |
- (mt6139_cw7_par.uc_auto_gain_select<<12) |
- (mt6139_cw7_par.uc_rx_gain<<4) |
- ADDR_MT6139_CW7;
- }
- else
- {
- bsi_data =(mt6139_cw7_par.uc_lpf_corner<<14) |
- (mt6139_cw7_par.uc_man_cal<<13) |
- (mt6139_cw7_par.uc_auto_gain_select<<12) |
- (mt6139_cw7_par.uc_rx_gain<<4) |
- ADDR_MT6139_CW7;
- }
- }
- //----------------------------------------------------------------------------
- void CRFPM::DeCompose_MT6139CW7( unsigned int reg_data, S_MT6139_CW7 &mt6139_cw7_par, unsigned int rf_id )
- {
- if( RF_ID_MT6139B == rf_id ||
- RF_ID_MT6139C == rf_id
- )
- {
- mt6139_cw7_par.uc_reserved = (reg_data>>14) & 0x7F;
- mt6139_cw7_par.uc_lo_vsw = (reg_data>>11) & 0x07;
- mt6139_cw7_par.uc_lpf_corner = (reg_data>>10) & 0x01;
- mt6139_cw7_par.uc_auto_cal = (reg_data>>9) & 0x01;
- mt6139_cw7_par.uc_auto_gain_select = (reg_data>>8) & 0x01;
- mt6139_cw7_par.uc_rx_gain = reg_data & 0xFF;
- }
- else
- {
- mt6139_cw7_par.uc_lpf_corner = (reg_data>>10) & 0x01;
- mt6139_cw7_par.uc_man_cal = (reg_data>>9) & 0x01;
- mt6139_cw7_par.uc_auto_gain_select = (reg_data>>8) & 0x01;
- mt6139_cw7_par.uc_rx_gain = reg_data & 0xFF;
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CRFPM::Set_MT6139CW7ToReg_Start( S_MT6139_CW7 &mt6139_cw7_par, unsigned int rf_id )
- {
- rf_pm_ptr = this;
- g_bIsRunning = true;
- mt6139_cw7 = mt6139_cw7_par;
- ActiveMan->SetActiveFunction( ::Set_MT6139CW7ToReg );
- }
- //----------------------------------------------------------------------------
- void CRFPM::Set_MT6139CW7ToReg( void )
- {
- if( ! g_bIsRunning )
- { Confirm( METAAPP_FAIL ); return; }
- unsigned int bsi_data;
- Compose_MT6139CW7( mt6139_cw7, bsi_data, m_uiFinalRfid );
- META_RESULT MetaResult = META_Rf_SetRFImmediateBSI_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, bsi_data);
- if(MetaResult!=META_SUCCESS)
- {
- if( MetaResult!=META_TIMEOUT )
- { Confirm( METAAPP_FAIL ); return; }
- else
- { Confirm( METAAPP_TIMEOUT ); return; }
- }
- ActiveMan->SetActiveFunction( ::REQ_Finish );
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CRFPM::Get_MT6139CW7FromReg_Start( S_MT6139_CW7 &mt6139_cw7_par, unsigned int rfmod_id )
- {
- rf_pm_ptr = this;
- g_bIsRunning = true;
- p_mt6139_cw7 = &mt6139_cw7_par;
- m_uiFinalRfid = rfmod_id;
- ActiveMan->SetActiveFunction( ::Get_MT6139CW7FromReg );
- }
- //----------------------------------------------------------------------------
- void CRFPM::Get_MT6139CW7FromReg( void )
- {
- if( ! g_bIsRunning )
- { Confirm( METAAPP_FAIL ); return; }
- unsigned int reg_data;
- META_RESULT MetaResult = META_Rf_GetRFImmediateBSI_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, ADDR_MT6139_AUXOUT_CW7, ®_data);
- if(MetaResult!=META_SUCCESS)
- {
- if( MetaResult!=META_TIMEOUT )
- { Confirm( METAAPP_FAIL ); return; }
- else
- { Confirm( METAAPP_TIMEOUT ); return; }
- }
- DeCompose_MT6139CW7( reg_data, *p_mt6139_cw7, m_uiFinalRfid );
- ActiveMan->SetActiveFunction( ::REQ_Finish );
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- //////////////////////////// CW8 /////////////////////////////////
- //----------------------------------------------------------------------------
- void CRFPM::Compose_MT6139CW8( S_MT6139_CW8 &mt6139_cw8_par, unsigned int &bsi_data, unsigned int rf_id )
- {
- bsi_data = (mt6139_cw8_par.uc_reserved << 18) |
- (mt6139_cw8_par.uc_dc_dac_bi << 11) |
- (mt6139_cw8_par.uc_dc_dac_ci << 4) |
- ADDR_MT6139_CW8;
- }
- //----------------------------------------------------------------------------
- void CRFPM::DeCompose_MT6139CW8( unsigned int reg_data, S_MT6139_CW8 &mt6139_cw8_par, unsigned int rf_id )
- {
- mt6139_cw8_par.uc_reserved = (reg_data>>14) & 0x7F;
- mt6139_cw8_par.uc_dc_dac_bi = (reg_data>>7 ) & 0x7F;
- mt6139_cw8_par.uc_dc_dac_ci = (reg_data ) & 0x7F;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CRFPM::Set_MT6139CW8ToReg_Start( S_MT6139_CW8 &mt6139_cw8_par, unsigned int rf_id )
- {
- rf_pm_ptr = this;
- g_bIsRunning = true;
- mt6139_cw8 = mt6139_cw8_par;
- ActiveMan->SetActiveFunction( ::Set_MT6139CW8ToReg );
- }
- //----------------------------------------------------------------------------
- void CRFPM::Set_MT6139CW8ToReg( void )
- {
- unsigned int bsi_data;
- Compose_MT6139CW8( mt6139_cw8, bsi_data, m_uiFinalRfid );
- META_RESULT MetaResult = META_Rf_SetRFImmediateBSI_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, bsi_data);
- if(MetaResult!=META_SUCCESS)
- {
- if( MetaResult!=META_TIMEOUT )
- { Confirm( METAAPP_FAIL ); return; }
- else
- { Confirm( METAAPP_TIMEOUT ); return; }
- }
- ActiveMan->SetActiveFunction( ::REQ_Finish );
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CRFPM::Get_MT6139CW8FromReg_Start( S_MT6139_CW8 &mt6139_cw8_par, unsigned int rf_id )
- {
- rf_pm_ptr = this;
- g_bIsRunning = true;
- p_mt6139_cw8 = &mt6139_cw8_par;
- ActiveMan->SetActiveFunction( ::Get_MT6139CW7FromReg );
- }
- //----------------------------------------------------------------------------
- void CRFPM::Get_MT6139CW8FromReg( void )
- {
- if( ! g_bIsRunning )
- { Confirm( METAAPP_FAIL ); return; }
- unsigned int reg_data;
- META_RESULT MetaResult = META_Rf_GetRFImmediateBSI_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, ADDR_MT6139_AUXOUT_CW8, ®_data);
- if(MetaResult!=META_SUCCESS)
- {
- if( MetaResult!=META_TIMEOUT )
- { Confirm( METAAPP_FAIL ); return; }
- else
- { Confirm( METAAPP_TIMEOUT ); return; }
- }
- DeCompose_MT6139CW8( reg_data, *p_mt6139_cw8, m_uiFinalRfid );
- ActiveMan->SetActiveFunction( ::REQ_Finish );
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- //////////////////////////// CW9 /////////////////////////////////
- //----------------------------------------------------------------------------
- void CRFPM::Compose_MT6139CW9( S_MT6139_CW9 &mt6139_cw9_par, unsigned int &bsi_data, unsigned int rf_id )
- {
- bsi_data = (mt6139_cw9_par.uc_reserved << 18) |
- (mt6139_cw9_par.uc_dc_dac_bq << 11) |
- (mt6139_cw9_par.uc_dc_dac_cq << 4) |
- ADDR_MT6139_CW9;
- }
- //----------------------------------------------------------------------------
- void CRFPM::DeCompose_MT6139CW9( unsigned int reg_data, S_MT6139_CW9 &mt6139_cw9_par, unsigned int rf_id )
- {
- mt6139_cw9_par.uc_reserved = (reg_data>>14) & 0x7F;
- mt6139_cw9_par.uc_dc_dac_bq = (reg_data>>7 ) & 0x7F;
- mt6139_cw9_par.uc_dc_dac_cq = (reg_data ) & 0x7F;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CRFPM::Set_MT6139CW9ToReg_Start( S_MT6139_CW9 &mt6139_cw9_par, unsigned int rf_id )
- {
- rf_pm_ptr = this;
- g_bIsRunning = true;
- mt6139_cw9 = mt6139_cw9_par;
- ActiveMan->SetActiveFunction( ::Set_MT6139CW9ToReg );
- }
- //----------------------------------------------------------------------------
- void CRFPM::Set_MT6139CW9ToReg( void )
- {
- if( ! g_bIsRunning )
- { Confirm( METAAPP_FAIL ); return; }
- unsigned int bsi_data;
- Compose_MT6139CW9( mt6139_cw9, bsi_data, m_uiFinalRfid );
- META_RESULT MetaResult = META_Rf_SetRFImmediateBSI_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, bsi_data);
- if(MetaResult!=META_SUCCESS)
- {
- if( MetaResult!=META_TIMEOUT )
- { Confirm( METAAPP_FAIL ); return; }
- else
- { Confirm( METAAPP_TIMEOUT ); return; }
- }
- ActiveMan->SetActiveFunction( ::REQ_Finish );
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CRFPM::Get_MT6139CW9FromReg_Start( S_MT6139_CW9 &mt6139_cw9_par, unsigned int rf_id )
- {
- rf_pm_ptr = this;
- g_bIsRunning = true;
- p_mt6139_cw9 = &mt6139_cw9_par;
- ActiveMan->SetActiveFunction( ::Get_MT6139CW9FromReg );
- }
- //----------------------------------------------------------------------------
- void CRFPM::Get_MT6139CW9FromReg( void )
- {
- if( ! g_bIsRunning )
- { Confirm( METAAPP_FAIL ); return; }
- unsigned int reg_data;
- META_RESULT MetaResult = META_Rf_GetRFImmediateBSI_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, ADDR_MT6139_AUXOUT_CW9, ®_data);
- if(MetaResult!=META_SUCCESS)
- {
- if( MetaResult!=META_TIMEOUT )
- { Confirm( METAAPP_FAIL ); return; }
- else
- { Confirm( METAAPP_TIMEOUT ); return; }
- }
- DeCompose_MT6139CW9( reg_data, *p_mt6139_cw9, m_uiFinalRfid );
- ActiveMan->SetActiveFunction( ::REQ_Finish );
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- //////////////////////////// CW10 ////////////////////////////////
- //----------------------------------------------------------------------------
- void CRFPM::Set_MT6139AmcodeToReg_Start( S_MT6139_CW10 &mt6139_cw10_par, unsigned int rf_id )
- {
- mt6139_cw10 = mt6139_cw10_par;
- }
- //----------------------------------------------------------------------------
- void CRFPM::Set_MT6139AmcodeToReg( S_MT6139_CW10 &mt6139_cw10_par, unsigned int rf_id )
- {
- #if 0
- unsigned int bsi_data;
- Compose_MT6139CW10( mt6139_cw10_par, bsi_data );
- MetaResult = META_Rf_SetRFImmediateBSI_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, bsi_data);
- if(MetaResult!=META_SUCCESS)
- return false;
- return true;
- #endif
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CRFPM::Set_MT6139CoefToReg_Start( uc_RFMod_MT6139_Coef_T &uc_mt6139_coef_par )
- {
- rf_pm_ptr = this;
- g_bIsRunning = true;
- uc_mt6139_coef = uc_mt6139_coef_par;
- ActiveMan->SetActiveFunction( ::Set_MT6139CoefToReg );
- }
- //----------------------------------------------------------------------------
- void CRFPM::Set_MT6139CoefToReg( void )
- {
- if( ! g_bIsRunning )
- { Confirm( METAAPP_FAIL ); return; }
- MT6139_Coef_uc2ui( uc_mt6139_coef, mt6139_coef);
- META_RESULT MetaResult = META_Rf_MT6139B_SetSpecialCoef_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, &mt6139_coef);
- if(MetaResult!=META_SUCCESS)
- {
- if( MetaResult!=META_TIMEOUT )
- { Confirm( METAAPP_FAIL ); return; }
- else
- { Confirm( METAAPP_TIMEOUT ); return; }
- }
- ActiveMan->SetActiveFunction( ::REQ_Finish );
- }
- //===========================================================================
- //////////////////////////// Sky74117 and Sky74400 ///////////////////////
- //===========================================================================
- void CRFPM::Compose_Sky74117_Mag( FrequencyBand freqband, c_RFMod_Sky74117_Coef_T &c_sky74117_coef, SKY74117_IP2CW_MAG &sky74117_mag_par )
- {
- RF_SKY74117_Coef_T ui_sky74117_coef;
- Sky74117_Coef_c2ui( c_sky74117_coef, ui_sky74117_coef);
- sky74117_mag_par.i_temp = 0;
- sky74117_mag_par.q_temp = 0;
- sky74117_mag_par.i_mag = ui_sky74117_coef.rx.coef[freqband].icorrection;
- sky74117_mag_par.q_mag = ui_sky74117_coef.rx.coef[freqband].qcorrection;
- }
- //---------------------------------------------------------------------------
- void CRFPM::Compose_Sky74117_Pol( c_RFMod_Sky74117_Coef_T &c_sky74117_coef, SKY74117_IP2CW_POL &sky74117_pol_par )
- {
- RF_SKY74117_Coef_T ui_sky74117_coef;
- Sky74117_Coef_c2ui( c_sky74117_coef, ui_sky74117_coef);
- sky74117_pol_par.reserved = 0;
- sky74117_pol_par.ip2_temp_ena = 0;
- sky74117_pol_par.i_pcs_pol = (unsigned char) ui_sky74117_coef.rx.pol[FrequencyBand1900].ipol;
- sky74117_pol_par.i_dcs_pol = (unsigned char) ui_sky74117_coef.rx.pol[FrequencyBand1800].ipol;
- sky74117_pol_par.i_gsm_pol = (unsigned char) ui_sky74117_coef.rx.pol[FrequencyBand900 ].ipol;
- sky74117_pol_par.i_gsm850_pol = (unsigned char) ui_sky74117_coef.rx.pol[FrequencyBand850 ].ipol;
- sky74117_pol_par.q_pcs_pol = (unsigned char) ui_sky74117_coef.rx.pol[FrequencyBand1900].qpol;
- sky74117_pol_par.q_dcs_pol = (unsigned char) ui_sky74117_coef.rx.pol[FrequencyBand1800].qpol;
- sky74117_pol_par.q_gsm_pol = (unsigned char) ui_sky74117_coef.rx.pol[FrequencyBand900 ].qpol;
- sky74117_pol_par.q_gsm850_pol = (unsigned char) ui_sky74117_coef.rx.pol[FrequencyBand850 ].qpol;
- sky74117_pol_par.ip2_coef = 1;
- sky74117_pol_par.ip2_pol_cal = 1;
- sky74117_pol_par.cal_ctrl = 0;
- }
- //---------------------------------------------------------------------------
- void CRFPM::Compose_Sky74117_GSM850CW( SKY74117_IP2CW_MAG &sky74117_mag_par, unsigned int &bsi_data )
- {
- sky74117_mag_par.i_temp = 0;
- sky74117_mag_par.q_temp = 0;
- bsi_data = sky74117_mag_par.i_mag <<18 |
- sky74117_mag_par.q_mag <<12 |
- sky74117_mag_par.i_temp<< 9 |
- sky74117_mag_par.q_temp<< 6 |
- ADDR_SKY74117_IP2_GSM850;
- }
- //----------------------------------------------------------------------------
- void CRFPM::DeCompose_Sky74117_GSM850CW( unsigned int reg_data, SKY74117_IP2CW_MAG &sky74117_mag_par)
- {
- sky74117_mag_par.i_mag = (reg_data>>18) & 0x3F;
- sky74117_mag_par.q_mag = (reg_data>>12) & 0x3F;
- sky74117_mag_par.i_temp = (reg_data>> 9) & 0x07;
- sky74117_mag_par.q_temp = (reg_data>> 6) & 0x07;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CRFPM::Compose_Sky74117_GSM900CW( SKY74117_IP2CW_MAG &sky74117_mag_par, unsigned int &bsi_data )
- {
- sky74117_mag_par.i_temp = 0;
- sky74117_mag_par.q_temp = 0;
- bsi_data = sky74117_mag_par.i_mag <<18 |
- sky74117_mag_par.q_mag <<12 |
- sky74117_mag_par.i_temp<< 9 |
- sky74117_mag_par.q_temp<< 6 |
- ADDR_SKY74117_IP2_GSM900;
- }
- //----------------------------------------------------------------------------
- void CRFPM::DeCompose_Sky74117_GSM900CW( unsigned int reg_data, SKY74117_IP2CW_MAG &sky74117_mag_par)
- {
- sky74117_mag_par.i_mag = (reg_data>>18) & 0x3F;
- sky74117_mag_par.q_mag = (reg_data>>12) & 0x3F;
- sky74117_mag_par.i_temp = (reg_data>> 9) & 0x07;
- sky74117_mag_par.q_temp = (reg_data>> 6) & 0x07;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CRFPM::Compose_Sky74117_DCS1800CW( SKY74117_IP2CW_MAG &sky74117_mag_par, unsigned int &bsi_data )
- {
- sky74117_mag_par.i_temp = 0;
- sky74117_mag_par.q_temp = 0;
- bsi_data = sky74117_mag_par.i_mag <<18 |
- sky74117_mag_par.q_mag <<12 |
- sky74117_mag_par.i_temp<< 9 |
- sky74117_mag_par.q_temp<< 6 |
- ADDR_SKY74117_IP2_DCS1800;
- }
- //----------------------------------------------------------------------------
- void CRFPM::DeCompose_Sky74117_DCS1800CW( unsigned int reg_data, SKY74117_IP2CW_MAG &sky74117_mag_par)
- {
- sky74117_mag_par.i_mag = (reg_data>>18) & 0x3F;
- sky74117_mag_par.q_mag = (reg_data>>12) & 0x3F;
- sky74117_mag_par.i_temp = (reg_data>> 9) & 0x07;
- sky74117_mag_par.q_temp = (reg_data>> 6) & 0x07;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CRFPM::Compose_Sky74117_PCS1900CW( SKY74117_IP2CW_MAG &sky74117_mag_par, unsigned int &bsi_data )
- {
- sky74117_mag_par.i_temp = 0;
- sky74117_mag_par.q_temp = 0;
- bsi_data = sky74117_mag_par.i_mag <<18 |
- sky74117_mag_par.q_mag <<12 |
- sky74117_mag_par.i_temp<< 9 |
- sky74117_mag_par.q_temp<< 6 |
- ADDR_SKY74117_IP2_PCS1900;
- }
- //----------------------------------------------------------------------------
- void CRFPM::DeCompose_Sky74117_PCS1900CW( unsigned int reg_data, SKY74117_IP2CW_MAG &sky74117_mag_par)
- {
- sky74117_mag_par.i_mag = (reg_data>>18) & 0x3F;
- sky74117_mag_par.q_mag = (reg_data>>12) & 0x3F;
- sky74117_mag_par.i_temp = (reg_data>> 9) & 0x07;
- sky74117_mag_par.q_temp = (reg_data>> 6) & 0x07;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CRFPM::Compose_Sky74117_PolCW( SKY74117_IP2CW_POL &sky74117_pol_par, unsigned int &bsi_data )
- {
- sky74117_pol_par.reserved = 0;
- sky74117_pol_par.ip2_temp_ena = 0;
- sky74117_pol_par.ip2_coef = 1;
- sky74117_pol_par.ip2_pol_cal = 1;
- sky74117_pol_par.cal_ctrl = 0;
- bsi_data = sky74117_pol_par.reserved <<20 |
- sky74117_pol_par.ip2_temp_ena <<19 |
- sky74117_pol_par.i_pcs_pol <<18 |
- sky74117_pol_par.i_dcs_pol <<17 |
- sky74117_pol_par.i_gsm_pol <<16 |
- sky74117_pol_par.i_gsm850_pol <<15 |
- sky74117_pol_par.q_pcs_pol <<14 |
- sky74117_pol_par.q_dcs_pol <<13 |
- sky74117_pol_par.q_gsm_pol <<12 |
- sky74117_pol_par.q_gsm850_pol <<11 |
- sky74117_pol_par.ip2_coef <<10 |
- sky74117_pol_par.ip2_pol_cal << 9 |
- sky74117_pol_par.cal_ctrl << 6 |
- ADDR_SKY74117_IP2_POL;
- }
- //----------------------------------------------------------------------------
- void CRFPM::DeCompose_Sky74117_PolCW( unsigned int reg_data, SKY74117_IP2CW_POL &sky74117_pol_par)
- {
- sky74117_pol_par.reserved = (reg_data>>20) & 0x0F;
- sky74117_pol_par.ip2_temp_ena = (reg_data>>19) & 0x01;
- sky74117_pol_par.i_pcs_pol = (reg_data>>18) & 0x01;
- sky74117_pol_par.i_dcs_pol = (reg_data>>17) & 0x01;
- sky74117_pol_par.i_gsm_pol = (reg_data>>16) & 0x01;
- sky74117_pol_par.i_gsm850_pol = (reg_data>>15) & 0x01;
- sky74117_pol_par.q_pcs_pol = (reg_data>>14) & 0x01;
- sky74117_pol_par.q_dcs_pol = (reg_data>>13) & 0x01;
- sky74117_pol_par.q_gsm_pol = (reg_data>>12) & 0x01;
- sky74117_pol_par.q_gsm850_pol = (reg_data>>11) & 0x01;
- sky74117_pol_par.ip2_coef = (reg_data>>10) & 0x01;
- sky74117_pol_par.ip2_coef = (reg_data>>10) & 0x01;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CRFPM::Set_Sky74117IP2MagToReg_Start( FrequencyBand freqband, SKY74117_IP2CW_MAG &sky74117_mag_par )
- {
- rf_pm_ptr = this;
- g_bIsRunning = true;
- m_FreqBand = freqband;
- m_sky74117_mag[freqband] = sky74117_mag_par;
- ActiveMan->SetActiveFunction( ::Set_Sky74117IP2MagToReg );
- }
- //----------------------------------------------------------------------------
- void CRFPM::Set_Sky74117IP2MagToReg( void )
- {
- unsigned int bsi_data;
- switch( m_FreqBand )
- {
- case FrequencyBand850:
- Compose_Sky74117_GSM850CW( m_sky74117_mag[m_FreqBand], bsi_data );
- break;
- case FrequencyBand900:
- Compose_Sky74117_GSM900CW( m_sky74117_mag[m_FreqBand], bsi_data );
- break;
- case FrequencyBand1800:
- Compose_Sky74117_DCS1800CW( m_sky74117_mag[m_FreqBand], bsi_data );
- break;
- case FrequencyBand1900:
- Compose_Sky74117_PCS1900CW( m_sky74117_mag[m_FreqBand], bsi_data );
- break;
- }
- META_RESULT MetaResult = META_Rf_SetRFImmediateBSI_r(m_META_HANDLE_Obj.Get_MainHandle(), 1500, bsi_data);
- if(MetaResult!=META_SUCCESS)
- {
- if( MetaResult!=META_TIMEOUT )
- { Confirm( METAAPP_FAIL ); return; }
- else
- { Confirm( METAAPP_TIMEOUT ); return; }
- }
- ActiveMan->SetActiveFunction( ::REQ_Finish );
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CRFPM::Set_Sky74117IP2Gsm850ToReg_Start( SKY74117_IP2CW_MAG &sky74117_mag_par )
- {
- rf_pm_ptr = this;
- g_bIsRunning = true;
- m_sky74117_mag[FrequencyBand850] = sky74117_mag_par;
- ActiveMan->SetActiveFunction( ::Set_Sky74117IP2Gsm850ToReg );
- }
- //----------------------------------------------------------------------------
- void CRFPM::Set_Sky74117IP2Gsm850ToReg( void )
- {
- unsigned int bsi_data;
- Compose_Sky74117_GSM850CW( m_sky74117_mag[FrequencyBand850], bsi_data );
- META_RESULT MetaResult = META_Rf_SetRFImmediateBSI_r(m_META_HANDLE_Obj.Get_MainHandle(), 1500, bsi_data);
- if(MetaResult!=META_SUCCESS)
- {
- if( MetaResult!=META_TIMEOUT )
- { Confirm( METAAPP_FAIL ); return; }
- else
- { Confirm( METAAPP_TIMEOUT ); return; }
- }
- ActiveMan->SetActiveFunction( ::REQ_Finish );
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CRFPM::Set_Sky74117IP2Gsm900ToReg_Start( SKY74117_IP2CW_MAG &sky74117_mag_par )
- {
- rf_pm_ptr = this;
- g_bIsRunning = true;
- m_sky74117_mag[FrequencyBand900] = sky74117_mag_par;
- ActiveMan->SetActiveFunction( ::Set_Sky74117IP2Gsm900ToReg );
- }
- //----------------------------------------------------------------------------
- void CRFPM::Set_Sky74117IP2Gsm900ToReg( void )
- {
- unsigned int bsi_data;
- Compose_Sky74117_GSM850CW( m_sky74117_mag[FrequencyBand900], bsi_data );
- META_RESULT MetaResult = META_Rf_SetRFImmediateBSI_r(m_META_HANDLE_Obj.Get_MainHandle(), 1500, bsi_data);
- if(MetaResult!=META_SUCCESS)
- {
- if( MetaResult!=META_TIMEOUT )
- { Confirm( METAAPP_FAIL ); return; }
- else
- { Confirm( METAAPP_TIMEOUT ); return; }
- }
- ActiveMan->SetActiveFunction( ::REQ_Finish );
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CRFPM::Set_Sky74117IP2Dcs1800ToReg_Start( SKY74117_IP2CW_MAG &sky74117_mag_par )
- {
- rf_pm_ptr = this;
- g_bIsRunning = true;
- m_sky74117_mag[FrequencyBand1800] = sky74117_mag_par;
- ActiveMan->SetActiveFunction( ::Set_Sky74117IP2Dcs1800ToReg );
- }
- //----------------------------------------------------------------------------
- void CRFPM::Set_Sky74117IP2Dcs1800ToReg( void )
- {
- unsigned int bsi_data;
- Compose_Sky74117_GSM850CW( m_sky74117_mag[FrequencyBand1800], bsi_data );
- META_RESULT MetaResult = META_Rf_SetRFImmediateBSI_r(m_META_HANDLE_Obj.Get_MainHandle(), 1500, bsi_data);
- if(MetaResult!=META_SUCCESS)
- {
- if( MetaResult!=META_TIMEOUT )
- { Confirm( METAAPP_FAIL ); return; }
- else
- { Confirm( METAAPP_TIMEOUT ); return; }
- }
- ActiveMan->SetActiveFunction( ::REQ_Finish );
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CRFPM::Set_Sky74117IP2Pcs1900ToReg_Start( SKY74117_IP2CW_MAG &sky74117_mag_par )
- {
- rf_pm_ptr = this;
- g_bIsRunning = true;
- m_sky74117_mag[FrequencyBand1900] = sky74117_mag_par;
- ActiveMan->SetActiveFunction( ::Set_Sky74117IP2Pcs1900ToReg );
- }
- //----------------------------------------------------------------------------
- void CRFPM::Set_Sky74117IP2Pcs1900ToReg( void )
- {
- unsigned int bsi_data;
- Compose_Sky74117_GSM850CW( m_sky74117_mag[FrequencyBand1900], bsi_data );
- META_RESULT MetaResult = META_Rf_SetRFImmediateBSI_r(m_META_HANDLE_Obj.Get_MainHandle(), 1500, bsi_data);
- if(MetaResult!=META_SUCCESS)
- {
- if( MetaResult!=META_TIMEOUT )
- { Confirm( METAAPP_FAIL ); return; }
- else
- { Confirm( METAAPP_TIMEOUT ); return; }
- }
- ActiveMan->SetActiveFunction( ::REQ_Finish );
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CRFPM::Set_Sky74117IP2PolToReg_Start( SKY74117_IP2CW_POL &sky74117_pol_par )
- {
- rf_pm_ptr = this;
- g_bIsRunning = true;
- m_sky74117_pol = sky74117_pol_par;
- ActiveMan->SetActiveFunction( ::Set_Sky74117IP2PolToReg );
- }
- //----------------------------------------------------------------------------
- void CRFPM::Set_Sky74117IP2PolToReg( void )
- {
- unsigned int bsi_data;
- Compose_Sky74117_PolCW( m_sky74117_pol, bsi_data );
- META_RESULT MetaResult = META_Rf_SetRFImmediateBSI_r(m_META_HANDLE_Obj.Get_MainHandle(), 1500, bsi_data);
- if(MetaResult!=META_SUCCESS)
- {
- if( MetaResult!=META_TIMEOUT )
- { Confirm( METAAPP_FAIL ); return; }
- else
- { Confirm( METAAPP_TIMEOUT ); return; }
- }
- ActiveMan->SetActiveFunction( ::REQ_Finish );
- }
- //===========================================================================
- //////////////////////////// Ouery ////////////////////////
- //===========================================================================
- //---------------------------------------------------------------------------
- unsigned char CRFPM::Query_PM_Support_Start(void)
- {
- rf_pm_ptr = this;
- g_bIsRunning = true;
- unsigned char pm_support_num;
- pm_support_num = Query_PM_Support();
- return pm_support_num;
- }
- //---------------------------------------------------------------------------
- unsigned char CRFPM::Query_PM_Support( void )
- {
- #if 0
- if(!g_bIsRunning) return false;
- MetaResult = META_QueryIfFunctionSupportedByTarget_r(500, "META_Rf_SetBBTxCfg3");
- if( MetaResult != META_SUCCESS )
- {
- return false;
- }
- #endif
- return 4;
- }
- //===========================================================================
- //////////////////////////// Global information ////////////////////////
- //===========================================================================
- //---------------------------------------------------------------------------
- E_METAAPP_RESULT_T CRFPM::Get_ConfirmState( void )
- {
- return m_eConfirmState;
- }
- //---------------------------------------------------------------------------
- RfPm_Cnf CRFPM::Get_RfPmCnf( void )
- {
- return RFCnf_PM;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- c_RFMod_Sky74045_Coef_T CRFPM::Get_c_sky74045_coef( void )
- {
- return c_sky74045_coef;
- }
- //----------------------------------------------------------------------------
- void CRFPM::Set_c_sky74045_coef( c_RFMod_Sky74045_Coef_T c_sky74045_coef_par )
- {
- c_sky74045_coef = c_sky74045_coef_par;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- c_RFMod_Sky74117_Coef_T CRFPM::Get_c_sky74117_coef( void )
- {
- return mc_sky74117_coef;
- }
- //----------------------------------------------------------------------------
- void CRFPM::Set_c_sky74117_coef( c_RFMod_Sky74117_Coef_T c_sky74117_coef_par )
- {
- mc_sky74117_coef = c_sky74117_coef_par;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- uc_RFMod_MT6139_Coef_T CRFPM::Get_uc_mt6139_coef( void )
- {
- return uc_mt6139_coef;
- }
- //----------------------------------------------------------------------------
- void CRFPM::Set_uc_mt6139_coef_rxamcalmode( int mode )
- {
- uc_mt6139_coef.rx.rxamcalmode = mode;
- }