T_IP2_Skyworks74045.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:53k
- /*****************************************************************************
- * 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:
- * ---------
- * T_IP2_Skyworks74045.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * Skyworks 74045 IP2 calibration 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 <assert.h>
- #include <math.h>
- #pragma hdrstop
- #ifndef _T_META_FACTORY_CALIBRATION_H_
- #include "T_META_factory_calibration.H"
- #endif
- #ifndef _CAL_COMMON_H_
- #include "cal_common.h"
- #endif
- // form
- #ifndef _META_FACTORY_H_
- #include "META_Factory.h"
- #endif
- // call back
- #ifndef _META_FACTORY_NVRAM_CB_H_
- #include "meta_factory_nvram_cb.h"
- #endif
- #ifndef _META_FACTORY_RF_CB_H_
- #include "meta_factory_rf_cb.h"
- #endif
- // equipment
- #ifndef _AGECOMMON_H_
- #include "agecommon.h"
- #endif
- // misc
- #ifndef _FT_UTILS_H_
- #include "ft_utils.h"
- #endif
- #ifndef _BAND_UTILS_H_
- #include "band_utils.h"
- #endif
- #ifndef _GSM_UTILS_H_
- #include "gsm_utils.h"
- #endif
- #ifndef _TIME_UTILS_H_
- #include "time_utils.h"
- #endif
- static const SKY74045_RCX_MIN = -127;
- static const SKY74045_RCX_MAX = 127;
- //----------------------------------------------------------------------------
- // IP2
- extern CRFPM* MF_rf_pm_ptr;
- extern RfPm_Cnf *MF_rf_pm_cnf; // define in T_META_factory_calibration.cpp
- extern RfPm_Req *MF_rf_pm_req;
- // Tthread
- extern T_META_factory_calibration* pt_calibration;
- extern bool is_suspend_cal; // in T_META_factory_calibration.cpp
- //----------------------------------------------------------------------------
- bool __fastcall T_META_factory_calibration::IP2Cal_sky74045_cal( void )
- {
- char tempbuf[256];
- PostMessage(
- ctrl.hPostMsgDestHandle,
- WM_MF_RF_IP2_BEGIN,
- 0,
- 0
- );
- log->Add( "n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " ================== IP2 calibration begin ==================="
- );
-
- // read IP2 register from NVRAM
- MF_rf_pm_ptr->ConfirmCallback = ccb_read_ip2_from_nvram;
- MF_rf_pm_ptr->REQ_Read_IP2Reg_From_NVRAM_Start(m_pCal->ui_rf_id);
- CHECK_TERMINATE_BY_USER
- RestartTimerCal( WM_MF_NVRAM_IP2_READ_FAIL );
- SUSPEND_CAL_THREAD
- if (MF_rf_pm_ptr->Get_ConfirmState() != METAAPP_SUCCESS)
- {
- CalErrorHandler( WM_MF_NVRAM_IP2_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target > read IP2 from NVRAM fail."
- );
- return false;
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target > read IP2 from NVRAM."
- );
- }
- MF_rf_pm_ptr->Get_cSky74045Coef( mc_sky74045_coef );
- if( ! m_rct_ctrl.RCT_operatingMode( m_pRct, OPERATING_MODE_GSM_BCH ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_OPERATION_MODE_FAIL );
- if ( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- " Agilent 8960< Operation mode = GSM BCH"
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- " cmu200 < Band = Operation mode = GSM BCH"
- );
- }
- return false;
- }
-
- int vi_Band;
- short s_ARFCN;
- //int i_TCH_ARFCN;
- FrequencyBand eFreqBand = FrequencyBand850;
- while (eFreqBand < FrequencyBandCount)
- {
- switch (eFreqBand)
- {
- case FrequencyBand850:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- vi_Band = age1960_GSM850_BAND;
- s_ARFCN = m_sIP2_arfcn_C0_GSM850;
- }
- break;
- case FrequencyBand900:
- {
- if (! IsFreqBankSupported( m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- vi_Band = age1960_EGSM_BAND;
- s_ARFCN = m_sIP2_arfcn_C0_GSM;
- }
- break;
- case FrequencyBand1800:
- {
- if (! IsFreqBankSupported( m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- vi_Band = age1960_DCS1800_BAND;
- s_ARFCN = m_sIP2_arfcn_C0_DCS;
- }
- break;
- case FrequencyBand1900:
- {
- if (! IsFreqBankSupported( m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- vi_Band = age1960_PCS1900_BAND;
- s_ARFCN = m_sIP2_arfcn_C0_PCS;
- }
- break;
- default:
- assert(false);
- break;
- } // switch
- if( ! m_rct_ctrl.RCT_cellBand( m_pRct, vi_Band ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_BAND_FAIL );
- if ( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- " Agilent 8960< Band = " + ViBand_To_Str( vi_Band )
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- " cmu200 < Band = " + ViBand_To_Str( vi_Band )
- );
- }
- return false;
- }
- if( ! m_rct_ctrl.RCT_ContModTran( m_pRct ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_BAND_FAIL );
- if ( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- " Agilent 8960< set continous mode transmition "
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : "+
- " cmu200 < set continous mode transmition "
- );
- }
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if ( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " Agilent 8960< band = " +
- FreqBand_To_Str( eFreqBand) );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " CMU 200< band = " +
- FreqBand_To_Str( eFreqBand) );
- }
- if (IsFreqBankSupported( m_asFreqBank, eFreqBand))
- {
- if(eFreqBand == FrequencyBand1900)
- {
- if(META_Rf_SelectFrequencyBand1900_r( m_pCal->i_MainMETAHandle, 1, MF_SelectBand_cnf_cb, &MF_SelectBand_token, NULL) != META_SUCCESS)
- {
- CalErrorHandler( WM_MF_RF_PM_SELECT_BAND_FAIL );
- pt_calibration->log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < set Band1900 flag = 1 "
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < set Band1900 flag = 1"
- );
- }
- else
- {
- if(META_Rf_SelectFrequencyBand1900_r( m_pCal->i_MainMETAHandle, 0, MF_SelectBand_cnf_cb, &MF_SelectBand_token, NULL) != META_SUCCESS)
- {
- CalErrorHandler( WM_MF_RF_PM_SELECT_BAND_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < set Band1900 flag = 0 "
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < set Band1900 flag = 0"
- );
- }
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- }
- if (!m_rct_ctrl.RCT_BCHARFCN(m_pRct, s_ARFCN))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_BCH_ARFCN_FAIL);
- if ( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: Agilent 8960< BCH ARFCN = " +
- IntToStr(s_ARFCN)
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: cmu200 < BCH ARFCN = " +
- IntToStr(s_ARFCN)
- );
- }
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if ( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " Agilent 8960< BCH ARFCN = " +
- AnsiString(s_ARFCN)
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " CMU 200< BCH ARFCN = " +
- AnsiString(s_ARFCN)
- );
- }
- i_IP2_ICORRECTION[0]=i_IP2_ICORRECTION1_SKY74045;
- i_IP2_ICORRECTION[1]=i_IP2_ICORRECTION2_SKY74045;
- i_IP2_QCORRECTION[0]=i_IP2_QCORRECTION1_SKY74045;
- i_IP2_QCORRECTION[1]=i_IP2_QCORRECTION2_SKY74045;
- for( int i=0; i<2; i++)
- {
- if( ! m_rct_ctrl.RCT_cellPower( m_pRct, d_IP2_CAL_P_DL_OFF_SKY ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_POWER_FAIL );
- if( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: Agilent 8960< Power = " +
- Double_To_AnsiString( d_IP2_CAL_P_DL_OFF_SKY ) ) + " dBm";
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: cmu200< Power = " +
- Double_To_AnsiString( d_IP2_CAL_P_DL_OFF_SKY ) ) + " dBm";
- }
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " Agilent 8960< Power = " +
- Double_To_AnsiString( d_IP2_CAL_P_DL_OFF_SKY ) );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " CMU 200< Power = " +
- Double_To_AnsiString( d_IP2_CAL_P_DL_OFF_SKY ) );
- }
- {
- Sleep( 200 ); // wait Agilent 8960 ready!
- }
- mc_sky74045_coef.rx.coef[eFreqBand].icorrection = i_IP2_ICORRECTION[i];
- mc_sky74045_coef.rx.coef[eFreqBand].qcorrection = i_IP2_QCORRECTION[i];
- EvalPmrcx_I_sky[i] = i_IP2_ICORRECTION[i];
- EvalPmrcx_Q_sky[i] = i_IP2_QCORRECTION[i];
- MF_rf_pm_ptr->Set_cSky74045Coef( mc_sky74045_coef );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < Set icorrection = " + IntToStr( EvalPmrcx_I_sky[i] ) +
- ", Qcorrection = " + IntToStr( EvalPmrcx_Q_sky[i] )
- );
- // write IP2 register to NVRAM
- MF_rf_pm_ptr->ConfirmCallback = ccb_write_ip2_to_nvram;
- MF_rf_pm_ptr->REQ_Write_IP2Reg_To_NVRAM_Start(m_pCal->ui_rf_id);
- CHECK_TERMINATE_BY_USER
- RestartTimerCal(WM_MF_NVRAM_IP2_WRITE_FAIL);
- SUSPEND_CAL_THREAD
- E_METAAPP_RESULT_T state = MF_rf_pm_ptr->Get_ConfirmState();
- if (state != METAAPP_SUCCESS)
- {
- if (METAAPP_NVRAM_LID_VER_NOT_SUPPORT == state)
- {
- CalErrorHandler(WM_MF_NVRAM_EF_L1_RFSPECIALCOEF_LID_VERNO_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : NVRAM_EF_L1_RFSPECIALCOEF_LID version is not support, please update META to latest version. "
- );
- }
- else
- {
- CalErrorHandler(WM_MF_NVRAM_IP2_WRITE_FAIL);
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < write IP2 to NVRAM fail."
- );
- }
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < write IP2 to NVRAM."
- );
- // if Agilent 8960 not read, target will get error power!
- MF_rf_pm_cnf->deviation = 0;
- MF_rf_pm_cnf->power = 0;
- MF_rf_pm_cnf->usedGain = 0;
- MF_rf_pm_cnf->extra_info.valid =0;
- MF_rf_pm_cnf->extra_info.iOffset=0;
- MF_rf_pm_cnf->extra_info.qOffset=0;
- MF_rf_pm_cnf->extra_info.validSamples =0;
- MF_rf_pm_req->arfcn = s_ARFCN-30;
- MF_rf_pm_req->sampleNoPerFrame = c_IP2_M_PM;
- MF_rf_pm_req->gain = d_IP2_GAIN *AVG_POWER_PC_SIDE_MULTIPLY ;
- MF_rf_pm_req->frames = i_IP2_N_PM;
- if( META_Rf_PM_r( m_pCal->i_MainMETAHandle, MF_rf_pm_req, MF_rf_pm_cnf_cb, &MF_rf_pm_token, NULL ) != META_SUCCESS )
- {
- CalErrorHandler( WM_MF_RF_IP2_PM_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- " Target < PM : ARFCN = " + IntToStr( s_ARFCN-30 ) +
- " sample per frame = " + IntToStr( c_IP2_M_PM) +
- " gain = " + IntToStr( MF_rf_pm_req->gain ) +
- " frames = " + IntToStr( i_IP2_N_PM)
- );
- return false;
- } // if
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < PM : ARFCN = " + IntToStr( s_ARFCN-30 ) +
- ", sample per frame = " + IntToStr( c_IP2_M_PM) +
- ", gain = " + IntToStr( MF_rf_pm_req->gain ) +
- ", frames = " + IntToStr( i_IP2_N_PM)
- );
- // Sleep(100);// delay for power measurement
- RestartTimerCal( WM_MF_RF_IP2_PM_FAIL );
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- if ( this->Terminated )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Terminate at line " + AnsiString(__FILE__) + " " + AnsiString(__LINE__)
- );
- this->OnTerminate = neByUser;
- return false;
- }
- if( !MF_rf_pm_cnf->ok )
- {
- CalErrorHandler( WM_MF_RF_IP2_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < ok = " + IntToStr(MF_rf_pm_cnf->ok) +
- ", power = " + Double_To_AnsiString(MF_rf_pm_cnf->power/8.0) +
- ", deviation = " + Double_To_AnsiString(sqrt(MF_rf_pm_cnf->deviation)/8.0) +
- ", usedGain = " + Double_To_AnsiString(MF_rf_pm_cnf->usedGain/8.0) +
- ", valid = " + IntToStr(MF_rf_pm_cnf->extra_info.valid) +
- ", I_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.iOffset) +
- ", Q_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.qOffset) +
- ", valid sample = " + IntToStr(MF_rf_pm_cnf->extra_info.validSamples)
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target > power = " + Double_To_AnsiString(MF_rf_pm_cnf->power/8.0) +
- ", deviation = " + Double_To_AnsiString(sqrt(MF_rf_pm_cnf->deviation)/8.0) +
- ", usedGain = " + Double_To_AnsiString(MF_rf_pm_cnf->usedGain/8.0) +
- ", valid = " + IntToStr(MF_rf_pm_cnf->extra_info.valid) +
- ", I_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.iOffset) +
- ", Q_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.qOffset) +
- ", valid sample = " + IntToStr(MF_rf_pm_cnf->extra_info.validSamples)
- );
- EvalMDC1_I_sky[i] = MF_rf_pm_cnf->extra_info.iOffset;
- EvalMDC1_Q_sky[i] = MF_rf_pm_cnf->extra_info.qOffset;
- //===========================================================
- // 1.0 SS power on
- if( ! m_rct_ctrl.RCT_cellPower( m_pRct, d_IP2_CAL_P_DL_ON_SKY ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_POWER_FAIL );
- if( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: Agilent 8960< Power = " +
- Double_To_AnsiString( d_IP2_CAL_P_DL_ON_SKY ) ) + " dBm";
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: cmu200< Power = " +
- Double_To_AnsiString( d_IP2_CAL_P_DL_ON_SKY ) ) + " dBm";
- }
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " Agilent 8960< Power = " +
- Double_To_AnsiString( d_IP2_CAL_P_DL_ON_SKY ) );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " CMU 200< Power = " +
- Double_To_AnsiString( d_IP2_CAL_P_DL_ON_SKY ) );
- }
- Sleep( 200 ); // wait Agilent 8960 ready!
- mc_sky74045_coef.rx.coef[eFreqBand].icorrection = i_IP2_ICORRECTION[i];
- mc_sky74045_coef.rx.coef[eFreqBand].qcorrection = i_IP2_QCORRECTION[i];
- EvalPmrcx_I_sky[i] = i_IP2_ICORRECTION[i];
- EvalPmrcx_Q_sky[i] = i_IP2_QCORRECTION[i];
- MF_rf_pm_ptr->Set_cSky74045Coef( mc_sky74045_coef );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < Set icorrection = " + IntToStr( EvalPmrcx_I_sky[i] ) +
- ", Qcorrection = " + IntToStr( EvalPmrcx_Q_sky[i] )
- );
- // write IP2 register to NVRAM
- MF_rf_pm_ptr->ConfirmCallback = ccb_write_ip2_to_nvram;
- MF_rf_pm_ptr->REQ_Write_IP2Reg_To_NVRAM_Start(m_pCal->ui_rf_id);
- CHECK_TERMINATE_BY_USER
- RestartTimerCal(WM_MF_NVRAM_IP2_WRITE_FAIL);
- SUSPEND_CAL_THREAD
- state = MF_rf_pm_ptr->Get_ConfirmState();
- if (state != METAAPP_SUCCESS)
- {
- if (METAAPP_NVRAM_LID_VER_NOT_SUPPORT == state)
- {
- CalErrorHandler(WM_MF_NVRAM_EF_L1_RFSPECIALCOEF_LID_VERNO_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : NVRAM_EF_L1_RFSPECIALCOEF_LID version is not support, please update META to latest version. "
- );
- }
- else
- {
- CalErrorHandler(WM_MF_NVRAM_IP2_WRITE_FAIL);
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < write IP2 to NVRAM fail."
- );
- }
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < write IP2 to NVRAM."
- );
- // if Agilent 8960 not read, target will get error power!
- MF_rf_pm_cnf->deviation = 0;
- MF_rf_pm_cnf->power = 0;
- MF_rf_pm_cnf->usedGain = 0;
- MF_rf_pm_cnf->extra_info.valid =0;
- MF_rf_pm_cnf->extra_info.iOffset=0;
- MF_rf_pm_cnf->extra_info.qOffset=0;
- MF_rf_pm_cnf->extra_info.validSamples =0;
- MF_rf_pm_req->arfcn = s_ARFCN-30;
- MF_rf_pm_req->sampleNoPerFrame = c_IP2_M_PM;
- MF_rf_pm_req->gain = d_IP2_GAIN *AVG_POWER_PC_SIDE_MULTIPLY ;
- MF_rf_pm_req->frames = i_IP2_N_PM;
- if( META_Rf_PM_r( m_pCal->i_MainMETAHandle, MF_rf_pm_req, MF_rf_pm_cnf_cb, &MF_rf_pm_token, NULL ) != META_SUCCESS )
- {
- CalErrorHandler( WM_MF_RF_IP2_PM_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- " Target < PM : ARFCN = " + IntToStr( s_ARFCN-30 ) +
- " sample per frame = " + IntToStr( c_IP2_M_PM) +
- " gain = " + IntToStr( MF_rf_pm_req->gain ) +
- " frames = " + IntToStr( i_IP2_N_PM)
- );
- return false;
- } // if
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < PM : ARFCN = " + IntToStr( s_ARFCN-30 ) +
- ", sample per frame = " + IntToStr( c_IP2_M_PM) +
- ", gain = " + IntToStr( MF_rf_pm_req->gain ) +
- ", frames = " + IntToStr( i_IP2_N_PM)
- );
- // Sleep(100);// delay for power measurement
- RestartTimerCal( WM_MF_RF_IP2_PM_FAIL );
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- if ( this->Terminated )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Terminate at line " + AnsiString(__FILE__) + " " + AnsiString(__LINE__)
- );
- this->OnTerminate = neByUser;
- return false;
- }
- if( !MF_rf_pm_cnf->ok )
- {
- CalErrorHandler( WM_MF_RF_IP2_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < ok = " + IntToStr(MF_rf_pm_cnf->ok) +
- ", power = " + Double_To_AnsiString(MF_rf_pm_cnf->power/8.0) +
- ", deviation = " + Double_To_AnsiString(sqrt(MF_rf_pm_cnf->deviation)/8.0) +
- ", usedGain = " + Double_To_AnsiString(MF_rf_pm_cnf->usedGain/8.0) +
- ", valid = " + IntToStr(MF_rf_pm_cnf->extra_info.valid) +
- ", I_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.iOffset) +
- ", Q_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.qOffset) +
- ", valid sample = " + IntToStr(MF_rf_pm_cnf->extra_info.validSamples)
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target > power = " + Double_To_AnsiString(MF_rf_pm_cnf->power/8.0) +
- ", deviation = " + Double_To_AnsiString(sqrt(MF_rf_pm_cnf->deviation)/8.0) +
- ", usedGain = " + Double_To_AnsiString(MF_rf_pm_cnf->usedGain/8.0) +
- ", valid = " + IntToStr(MF_rf_pm_cnf->extra_info.valid) +
- ", I_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.iOffset) +
- ", Q_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.qOffset) +
- ", valid sample = " + IntToStr(MF_rf_pm_cnf->extra_info.validSamples)
- );
- EvalMDC2_I_sky[i] = MF_rf_pm_cnf->extra_info.iOffset;
- EvalMDC2_Q_sky[i] = MF_rf_pm_cnf->extra_info.qOffset;
- } // for
- // Evaluate
- unsigned char c0_I = MF_rf_pm_ptr->Get_cxofrealcoef(EvalPmrcx_I_sky[0], m_pCal->ui_rf_id);
- unsigned char c1_I = MF_rf_pm_ptr->Get_cxofrealcoef(EvalPmrcx_I_sky[1], m_pCal->ui_rf_id);
- unsigned char c0_Q = MF_rf_pm_ptr->Get_cxofrealcoef(EvalPmrcx_Q_sky[0], m_pCal->ui_rf_id);
- unsigned char c1_Q = MF_rf_pm_ptr->Get_cxofrealcoef(EvalPmrcx_Q_sky[1], m_pCal->ui_rf_id);
- int f0_I = EvalMDC2_I_sky[0] - EvalMDC1_I_sky[0];
- int f1_I = EvalMDC2_I_sky[1] - EvalMDC1_I_sky[1];
- int f0_Q = EvalMDC2_Q_sky[0] - EvalMDC1_Q_sky[0];
- int f1_Q = EvalMDC2_Q_sky[1] - EvalMDC1_Q_sky[1];
- signed char rcx_I = 0;
- signed char rcx_Q = 0;
- if( (c1_I - c0_I) == 0 && (c1_Q - c0_Q)==0 ) return false;
- // display evaluate error
- 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 = MF_rf_pm_ptr->Get_realcoefofcx( cx_I, m_pCal->ui_rf_id );
- if( rcx_I < SKY74045_RCX_MIN ) rcx_I = SKY74045_RCX_MIN;
- // else if( rcx_I > SKY74045_RCX_MAX ) rcx_I = SKY74045_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 = MF_rf_pm_ptr->Get_realcoefofcx( cx_Q, m_pCal->ui_rf_id );
- if( rcx_Q < SKY74045_RCX_MIN ) rcx_Q = SKY74045_RCX_MIN;
- //else if( rcx_Q > SKY74045_RCX_MAX ) rcx_Q = SKY74045_RCX_MAX;
- }
- }
- mc_sky74045_coef.rx.coef[eFreqBand].icorrection = rcx_I;
- mc_sky74045_coef.rx.coef[eFreqBand].qcorrection = rcx_Q;
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " rcx_I = " + IntToStr(rcx_I) +
- " rcx_Q = " + IntToStr(rcx_Q)
- );
- sprintf( tempbuf, "%8d", rcx_I );
- m_pCal->as_ResultBuf = m_pCal->as_ResultBuf + tempbuf + ", ";
- sprintf( tempbuf, "%8d", rcx_Q );
- m_pCal->as_ResultBuf = m_pCal->as_ResultBuf + tempbuf + ", ";
- MF_rf_pm_ptr->Set_cSky74045Coef( mc_sky74045_coef );
- if (!WriteIP2CalResultToFile(as_ID+".cal",Application->ExeName, m_pCal->b_CalResultPath, m_pCal->ui_rf_id, eFreqBand ) )
- {
- CalErrorHandler( WM_MF_RF_AFC_WRITE_CAL_RESULT_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : write IP2 parameter to cal file "
- );
- return false;
- }
- eFreqBand++;
- } // while
- // if( ! frmFatcory->WriteIP2CalResultToFile(as_ID+".cal",Application->ExeName, p_cal->b_CalResultPath, m_pCal->ui_rf_id ) )
- // {
- // CalErrorHandler( WM_MF_RF_AFC_WRITE_CAL_RESULT_FAIL );
- // log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " FAIL : write IP2 parameter to cal file "
- // );
- // return false;
- //}
- // write IP2 register to NVRAM
- MF_rf_pm_ptr->ConfirmCallback = ccb_write_ip2_to_nvram;
- MF_rf_pm_ptr->REQ_Write_IP2Reg_To_NVRAM_Start(m_pCal->ui_rf_id);
- CHECK_TERMINATE_BY_USER
- RestartTimerCal(WM_MF_NVRAM_IP2_WRITE_FAIL);
- SUSPEND_CAL_THREAD
- E_METAAPP_RESULT_T state = MF_rf_pm_ptr->Get_ConfirmState();
- if (state != METAAPP_SUCCESS)
- {
- if (METAAPP_NVRAM_LID_VER_NOT_SUPPORT == state)
- {
- CalErrorHandler(WM_MF_NVRAM_EF_L1_RFSPECIALCOEF_LID_VERNO_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : NVRAM_EF_L1_RFSPECIALCOEF_LID version is not support, please update META to latest version. "
- );
- }
- else
- {
- CalErrorHandler( WM_MF_NVRAM_IP2_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < write IP2 to NVRAM fail."
- );
- }
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < write IP2 to NVRAM."
- );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " =================== IP2 calibration end ==================== n "
- );
- return true;
- }
- //===========================================================================
- bool __fastcall T_META_factory_calibration::IP2Cal_sky74045_check(void)
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " =================== IP2 check begin ==================== n "
- );
-
- int MDCI[2];
- int MDCQ[2];
- int DCI;
- int DCQ;
- int vi_Band;
- short s_ARFCN;
- FrequencyBand eFreqBand = FrequencyBand850;
- while (eFreqBand < FrequencyBandCount)
- {
- switch (eFreqBand)
- {
- case FrequencyBand850:
- {
- if (! IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- vi_Band = age1960_GSM850_BAND;
- s_ARFCN = m_sIP2_arfcn_C0_GSM850;
- }
- break;
- case FrequencyBand900:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- vi_Band = age1960_EGSM_BAND;
- s_ARFCN = m_sIP2_arfcn_C0_GSM;
- }
- break;
- case FrequencyBand1800:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- vi_Band = age1960_DCS1800_BAND;
- s_ARFCN = m_sIP2_arfcn_C0_DCS;
- }
- break;
- case FrequencyBand1900:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- vi_Band = age1960_PCS1900_BAND;
- s_ARFCN = m_sIP2_arfcn_C0_PCS;
- }
- break;
- default:
- assert(false);
- break;
- } // switch
- if( ! m_rct_ctrl.RCT_cellBand( m_pRct, vi_Band ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_BAND_FAIL );
- if ( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- " Agilent 8960< Band = " + ViBand_To_Str( vi_Band )
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- " cmu200 < Band = " + ViBand_To_Str( vi_Band )
- );
- }
- return false;
- }
- if( ! m_rct_ctrl.RCT_ContModTran(m_pRct))
- {
- CalErrorHandler( WM_MF_AGE8960_SET_BAND_FAIL );
- if ( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- " Agilent 8960< set continous mode transmition "
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : "+
- " cmu200 < set continous mode transmition "
- );
- }
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if ( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " Agilent 8960< band = " +
- FreqBand_To_Str( eFreqBand) );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " CMU 200< band = " +
- FreqBand_To_Str( eFreqBand) );
- }
- if (IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- if(eFreqBand == FrequencyBand1900)
- {
- if(META_Rf_SelectFrequencyBand1900_r( m_pCal->i_MainMETAHandle, 1, MF_SelectBand_cnf_cb, &MF_SelectBand_token, NULL) != META_SUCCESS)
- {
- CalErrorHandler( WM_MF_RF_PM_SELECT_BAND_FAIL );
- pt_calibration->log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < set Band1900 flag = 1 "
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < set Band1900 flag = 1"
- );
- }
- else
- {
- if(META_Rf_SelectFrequencyBand1900_r( m_pCal->i_MainMETAHandle, 0, MF_SelectBand_cnf_cb, &MF_SelectBand_token, NULL) != META_SUCCESS)
- {
- CalErrorHandler( WM_MF_RF_PM_SELECT_BAND_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < set Band1900 flag = 0 "
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < set Band1900 flag = 0"
- );
- }
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- }
- if( ! m_rct_ctrl.RCT_BCHARFCN( m_pRct, s_ARFCN ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_BCH_ARFCN_FAIL );
- if ( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: Agilent 8960< BCH ARFCN = " +
- IntToStr(s_ARFCN)
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: cmu200 < BCH ARFCN = " +
- IntToStr(s_ARFCN)
- );
- }
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if ( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " Agilent 8960< BCH ARFCN = " +
- AnsiString(s_ARFCN)
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " CMU 200< BCH ARFCN = " +
- AnsiString(s_ARFCN)
- );
- }
- if( ! m_rct_ctrl.RCT_cellPower( m_pRct, d_IP2_CHECK_P_DL_OFF ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_POWER_FAIL );
- if( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: Agilent 8960< Power = " +
- Double_To_AnsiString( d_IP2_CHECK_P_DL_OFF) ) + " dBm";
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: cmu200< Power = " +
- Double_To_AnsiString( d_IP2_CHECK_P_DL_OFF) ) + " dBm";
- }
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " Agilent 8960< Power = " +
- Double_To_AnsiString( d_IP2_CHECK_P_DL_OFF) );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " CMU 200< Power = " +
- Double_To_AnsiString( d_IP2_CHECK_P_DL_OFF) );
- }
- Sleep( 200 ); // wait Agilent 8960 ready!
-
- MF_rf_pm_cnf->deviation = 0;
- MF_rf_pm_cnf->power = 0;
- MF_rf_pm_cnf->usedGain = 0;
- MF_rf_pm_cnf->extra_info.valid =0;
- MF_rf_pm_cnf->extra_info.iOffset=0;
- MF_rf_pm_cnf->extra_info.qOffset=0;
- MF_rf_pm_cnf->extra_info.validSamples =0;
- MF_rf_pm_req->arfcn = s_ARFCN-30;
- MF_rf_pm_req->sampleNoPerFrame = c_IP2_M_PM;
- MF_rf_pm_req->gain = d_IP2_GAIN *AVG_POWER_PC_SIDE_MULTIPLY ;
- MF_rf_pm_req->frames = i_IP2_N_PM;
- if( META_Rf_PM_r( m_pCal->i_MainMETAHandle, MF_rf_pm_req, MF_rf_pm_cnf_cb, &MF_rf_pm_token, NULL ) != META_SUCCESS )
- {
- CalErrorHandler( WM_MF_RF_IP2_PM_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- " Target < PM : ARFCN = " + IntToStr( s_ARFCN-30 ) +
- " sample per frame = " + IntToStr( c_IP2_M_PM) +
- " gain = " + IntToStr( MF_rf_pm_req->gain ) +
- " frames = " + IntToStr( i_IP2_N_PM)
- );
- return false;
- } // if
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < PM : ARFCN = " + IntToStr( s_ARFCN-30 ) +
- ", sample per frame = " + IntToStr( c_IP2_M_PM) +
- ", gain = " + IntToStr( MF_rf_pm_req->gain ) +
- ", frames = " + IntToStr( i_IP2_N_PM)
- );
- // Sleep(100);// delay for power measurement
- RestartTimerCal( WM_MF_RF_IP2_PM_FAIL );
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- if ( this->Terminated )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Terminate at line " + AnsiString(__FILE__) + " " + AnsiString(__LINE__)
- );
- this->OnTerminate = neByUser;
- return false;
- }
- if( !MF_rf_pm_cnf->ok )
- {
- CalErrorHandler( WM_MF_RF_IP2_PM_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < ok = " + IntToStr(MF_rf_pm_cnf->ok) +
- ", power = " + Double_To_AnsiString(MF_rf_pm_cnf->power/8.0) +
- ", deviation = " + Double_To_AnsiString(sqrt(MF_rf_pm_cnf->deviation)/8.0) +
- ", usedGain = " + Double_To_AnsiString(MF_rf_pm_cnf->usedGain/8.0) +
- ", valid = " + IntToStr(MF_rf_pm_cnf->extra_info.valid) +
- ", I_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.iOffset) +
- ", Q_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.qOffset) +
- ", valid sample = " + IntToStr(MF_rf_pm_cnf->extra_info.validSamples)
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target > power = " + Double_To_AnsiString(MF_rf_pm_cnf->power/8.0) +
- ", deviation = " + Double_To_AnsiString(sqrt(MF_rf_pm_cnf->deviation)/8.0) +
- ", usedGain = " + Double_To_AnsiString(MF_rf_pm_cnf->usedGain/8.0) +
- ", valid = " + IntToStr(MF_rf_pm_cnf->extra_info.valid) +
- ", I_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.iOffset) +
- ", Q_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.qOffset) +
- ", valid sample = " + IntToStr(MF_rf_pm_cnf->extra_info.validSamples)
- );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " I_MDC_OFF = " + IntToStr(MF_rf_pm_cnf->extra_info.iOffset) +
- ", Q_MDC_OFF = " + IntToStr(MF_rf_pm_cnf->extra_info.qOffset)
- );
- MDCI[0] = MF_rf_pm_cnf->extra_info.iOffset;
- MDCQ[0] = MF_rf_pm_cnf->extra_info.qOffset;
- //----------------------------------------------------------------
- // cell power on
- if( ! m_rct_ctrl.RCT_cellPower( m_pRct, d_IP2_CHECK_P_DL_ON ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_POWER_FAIL );
- if( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: Agilent 8960< Power = " +
- Double_To_AnsiString( d_IP2_CHECK_P_DL_ON) ) + " dBm";
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: cmu200< Power = " +
- Double_To_AnsiString( d_IP2_CHECK_P_DL_ON) ) + " dBm";
- }
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " Agilent 8960< Power = " +
- Double_To_AnsiString( d_IP2_CHECK_P_DL_ON) );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " CMU 200< Power = " +
- Double_To_AnsiString( d_IP2_CHECK_P_DL_ON) );
- }
- Sleep( 200 ); // wait Agilent 8960 ready!
- MF_rf_pm_cnf->deviation = 0;
- MF_rf_pm_cnf->power = 0;
- MF_rf_pm_cnf->usedGain = 0;
- MF_rf_pm_cnf->extra_info.valid =0;
- MF_rf_pm_cnf->extra_info.iOffset=0;
- MF_rf_pm_cnf->extra_info.qOffset=0;
- MF_rf_pm_cnf->extra_info.validSamples =0;
- MF_rf_pm_req->arfcn = s_ARFCN-30;
- MF_rf_pm_req->sampleNoPerFrame = c_IP2_M_PM;
- MF_rf_pm_req->gain = d_IP2_GAIN *AVG_POWER_PC_SIDE_MULTIPLY ;
- MF_rf_pm_req->frames = i_IP2_N_PM;
- if( META_Rf_PM_r( m_pCal->i_MainMETAHandle, MF_rf_pm_req, MF_rf_pm_cnf_cb, &MF_rf_pm_token, NULL ) != META_SUCCESS )
- {
- CalErrorHandler( WM_MF_RF_IP2_PM_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- " Target < PM : ARFCN = " + IntToStr( s_ARFCN-30 ) +
- " sample per frame = " + IntToStr( c_IP2_M_PM) +
- " gain = " + IntToStr( MF_rf_pm_req->gain ) +
- " frames = " + IntToStr( i_IP2_N_PM)
- );
- return false;
- } // if
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < PM : ARFCN = " + IntToStr( s_ARFCN-30 ) +
- ", sample per frame = " + IntToStr( c_IP2_M_PM) +
- ", gain = " + IntToStr( MF_rf_pm_req->gain ) +
- ", frames = " + IntToStr( i_IP2_N_PM)
- );
- // Sleep(100);// delay for power measurement
- RestartTimerCal( WM_MF_RF_IP2_PM_FAIL );
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- if ( this->Terminated )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Terminate at line " + AnsiString(__FILE__) + " " + AnsiString(__LINE__)
- );
- this->OnTerminate = neByUser;
- return false;
- }
- if( !MF_rf_pm_cnf->ok )
- {
- CalErrorHandler( WM_MF_RF_IP2_PM_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < ok = " + IntToStr(MF_rf_pm_cnf->ok) +
- ", power = " + Double_To_AnsiString(MF_rf_pm_cnf->power/8.0) +
- ", deviation = " + Double_To_AnsiString(sqrt(MF_rf_pm_cnf->deviation)/8.0) +
- ", usedGain = " + Double_To_AnsiString(MF_rf_pm_cnf->usedGain/8.0) +
- ", valid = " + IntToStr(MF_rf_pm_cnf->extra_info.valid) +
- ", I_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.iOffset) +
- ", Q_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.qOffset) +
- ", valid sample = " + IntToStr(MF_rf_pm_cnf->extra_info.validSamples)
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target > power = " + Double_To_AnsiString(MF_rf_pm_cnf->power/8.0) +
- ", deviation = " + Double_To_AnsiString(sqrt(MF_rf_pm_cnf->deviation)/8.0) +
- ", usedGain = " + Double_To_AnsiString(MF_rf_pm_cnf->usedGain/8.0) +
- ", valid = " + IntToStr(MF_rf_pm_cnf->extra_info.valid) +
- ", I_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.iOffset) +
- ", Q_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.qOffset) +
- ", valid sample = " + IntToStr(MF_rf_pm_cnf->extra_info.validSamples)
- );
- #if 0
- int abs_iOffset = abs(MF_rf_pm_cnf->extra_info.iOffset);
- int abs_qOffset = abs(MF_rf_pm_cnf->extra_info.qOffset);
- if( abs_iOffset > i_IP2_MAX_IDC || abs_qOffset > i_IP2_MAX_QDC)
- {
- CalErrorHandler( WM_MF_RF_IP2_CHECK_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Fail: IP2 check ." + " I_MDC_ON = " + IntToStr(MF_rf_pm_cnf->extra_info.iOffset) +
- ", Q_MDC_ON = " + IntToStr(MF_rf_pm_cnf->extra_info.qOffset) +
- ", IP2_MAX_IDC = " + IntToStr( i_IP2_MAX_IDC ) +
- ", IP2_MAX_QDC = " + IntToStr( i_IP2_MAX_QDC )
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Pass: IP2 check ." + " I_MDC_ON = " + IntToStr(MF_rf_pm_cnf->extra_info.iOffset) +
- ", Q_MDC_ON = " + IntToStr(MF_rf_pm_cnf->extra_info.qOffset) +
- ", IP2_MAX_IDC = " + IntToStr( i_IP2_MAX_IDC ) +
- ", IP2_MAX_QDC = " + IntToStr( i_IP2_MAX_QDC )
- );
- #endif
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " I_MDC_ON = " + IntToStr(MF_rf_pm_cnf->extra_info.iOffset) +
- ", Q_MDC_ON = " + IntToStr(MF_rf_pm_cnf->extra_info.qOffset)
- );
- MDCI[1] = MF_rf_pm_cnf->extra_info.iOffset;
- MDCQ[1] = MF_rf_pm_cnf->extra_info.qOffset;
- DCI = MDCI[1] - MDCI[0];
- DCQ = MDCQ[1] - MDCQ[0];
- int ab_DCI = abs(DCI);
- int ab_QCQ = abs(DCQ);
- if( ab_DCI > m_iIP2_MAX_IDC_SKY74045 || ab_QCQ > m_iIP2_MAX_QDC_SKY74045 )
- {
- CalErrorHandler( WM_MF_RF_IP2_CHECK_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Fail: IP2 check ." + " I_DC = " + IntToStr(DCI) +
- ", Q_DC = " + IntToStr(DCQ) +
- ", IP2_MAX_IDC = " + IntToStr( m_iIP2_MAX_IDC_SKY74045 ) +
- ", IP2_MAX_QDC = " + IntToStr( m_iIP2_MAX_QDC_SKY74045 )
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Pass: IP2 check ." + " I_DC = " + IntToStr(DCI) +
- ", Q_DC = " + IntToStr(DCQ) +
- ", IP2_MAX_IDC = " + IntToStr( m_iIP2_MAX_IDC_SKY74045 ) +
- ", IP2_MAX_QDC = " + IntToStr( m_iIP2_MAX_QDC_SKY74045 )
- );
-
- eFreqBand++;
- } // while
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " =================== IP2 check end ==================== n "
- );
- PostMessage(
- ctrl.hPostMsgDestHandle,
- WM_MF_RF_IP2_CALIBRATION_DONE,
- 0,
- 0
- );
- frmFatcory->DisableAllCalTimer();
- return true;
- }