T_AFC.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:133k
- /*****************************************************************************
- * 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_AFC.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * AFC 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
- // callback
- #ifndef _META_FACTORY_RF_CB_H_
- #include "meta_factory_rf_cb.h"
- #endif
- #ifndef _META_FACTORY_NVRAM_CB_H_
- #include "meta_factory_nvram_cb.h"
- #endif
- #ifndef _META_FACTORY_CRYSTAL_CB_H_
- #include "META_factory_crystal_cb.h"
- #endif
- #ifndef _META_FACTORY_BB_CB_H_
- #include "meta_factory_bb_cb.h"
- #endif
- // form
- #ifndef _META_FACTORY_H_
- #include "META_Factory.h"
- #endif
- #ifndef _FORM_MAIN_H_
- #include "form_main.h"
- #endif
- // equipment
- #ifndef _AGECOMMON_H_
- #include "agecommon.h"
- #endif
- #ifndef _AGE_MISC_H_
- #include "age_misc.h"
- #endif
- // misc
- #ifndef _FT_UTILS_H_
- #include "ft_utils.h"
- #endif
- #ifndef _MATH_UTILS_H_
- #include "math_utils.h"
- #endif
- #ifndef _GSM_UTILS_H_
- #include "gsm_utils.h"
- #endif
- #ifndef _BAND_UTILS_H_
- #include "band_utils.h"
- #endif
- #ifndef _TIME_UTILS_H_
- #include "time_utils.h"
- #endif
- #define TIMESLOT_0 0
- #define TIMESLOT_3 3
- #define ADDR_AFC_DAC 0x80250064
- //----------------------------------------------------------------------------
- // AFC
- extern CRFAFC* MF_rf_afc_ptr;
- extern RfAfc_Req *MF_rf_afc_req;
- extern RfAfc_Cnf *MF_rf_afc_cnf;
- //extern RfSetAfcDacValue_Req *MF_rf_SetAfcDacValue;
- extern unsigned char RfSetAfcDacCnf;
- // crystal AFC
- extern CCRYSTALAFC* MF_crystal_afc_ptr;
- extern RfNbtx_Req *MF_rf_tx_level_req;
- extern bool MF_rf_tx_level_cnf;
- extern CBBREG* MF_bb_reg_ptr;
- // APC
- extern CRFAPC* MF_rf_apc_ptr;
- extern bool is_suspend_cal; // in T_META_factory_calibration.cpp
- //******************************************************************************
- // AFC calibration
- //******************************************************************************
- bool __fastcall T_META_factory_calibration::AFCCal( void )
- {
- char tempbuf[256];
- if (TCVCXO == m_pCal->e_AFC_type)
- {
- log->Add( "n" +DateToStr(Date()) + " " + CurrentTimeStr() +
- " ====================== AFC calibration begin ===================== "
- );
- }
- else
- {
- log->Add( "n" +DateToStr(Date()) + " " + CurrentTimeStr() +
- " =================== AFC slope calibration begin ================== "
- );
- }
- if (TCVCXO == m_pCal->e_AFC_type)
- {
- PostMessage(
- ctrl.hPostMsgDestHandle,
- WM_MF_RF_AFC_BEGIN,
- 0,
- 0
- );
- }
- if( ! m_rct_ctrl.RCT_operatingMode( m_pRct, OPERATING_MODE_GSM_BCH ) )
- {
- CalErrorHandler(WM_MF_AGE8960_SET_OPERATION_MODE_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- m_pRct->as_RCT + " < Operation mode = GSM BCH"
- );
- return false;
- }
- int vi_AFC_BAND = Get_AgeBand(m_asAFC_BAND);
- // if (!(CRYSTAL == m_pCal->e_AFC_type) && (CMU_200 == m_pRct->device_type))
- {
- if (!m_rct_ctrl.RCT_cellBand(m_pRct, vi_AFC_BAND))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_BAND_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- m_pRct->as_RCT + " < Band = " + ViBand_To_Str(vi_AFC_BAND)
- );
- return false;
- }
- if (!m_rct_ctrl.RCT_PowTranBurst(m_pRct))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_BAND_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- m_pRct->as_RCT + " < Band = " + ViBand_To_Str(vi_AFC_BAND)
- );
- return false;
- }
- if (!m_rct_ctrl.RCT_GenBitMod(m_pRct, CMU200_GEN_BIT_MODU_ALL_ZERO))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_BIT_MODULATION_FAIL );
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_pRct->as_RCT + " < set bit modulation "
- );
- return false;
- }
- if ((MT6205 == m_pCal->e_bb_chip) ||
- (MT6205B == m_pCal->e_bb_chip) ||
- (MT6223 == m_pCal->e_bb_chip) ||
- (MT6223P == m_pCal->e_bb_chip) ||
- (MT6225 == m_pCal->e_bb_chip) ||
- (MT6229 == m_pCal->e_bb_chip) ||
- (MT6230 == m_pCal->e_bb_chip) ||
- (MT6235 == m_pCal->e_bb_chip) ||
- (MT6238 == m_pCal->e_bb_chip) ||
- (TK6516_MD == m_pCal->e_bb_chip)
- )
- {
- if (!m_rct_ctrl.RCT_GenTsc(m_pRct, CMU200_GEN_TSC_ALL_ZERO))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_GENERATOR_TSC_FAIL );
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- m_pRct->as_RCT + " < set generator TSC = all 0 "
- );
- return false;
- }
- }
- else
- {
- if (!m_rct_ctrl.RCT_GenTsc(m_pRct, CMU200_GEN_TSC_GSM_5))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_GENERATOR_TSC_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : "+
- m_pRct->as_RCT + " < set generator TSC = TSC5"
- );
- return false;
- }
- }
- if( ! m_rct_ctrl.RCT_InitRfg( m_pRct ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_RF_GENERATOR_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: cmu200 > set RF generator "
- );
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- }
- #if 0
- else // crystal at CMU200
- {
- if( ! m_rct_ctrl.RCT_sig_cellBand( m_pRct, vi_AFC_BAND ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_BAND_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- " cmu200 < Band = " + ViBand_To_Str( vi_AFC_BAND )
- );
- return false;
- }
- }
- #endif
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- m_pRct->as_RCT + " < Band = "+
- ViBand_To_Str(Get_AgeBand(m_asAFC_BAND))
- );
- // if (!(CRYSTAL == m_pCal->e_AFC_type) && (CMU_200 == m_pRct->device_type))
- {
- if( ! m_rct_ctrl.RCT_BCHARFCN( m_pRct, m_sAFC_ARFCN ) )
- {
- CalErrorHandler(WM_MF_AGE8960_SET_BCH_ARFCN_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: " + m_pRct->as_RCT + " < BCH ARFCN = " +
- IntToStr(m_sAFC_ARFCN)
- );
- return false;
- }
- }
- #if 0
- else // crystal af CMU200
- {
- if( ! m_rct_ctrl.RCT_sig_BCHARFCN( m_pRct, m_sAFC_ARFCN ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_BCH_ARFCN_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: cmu200 < BCH ARFCN = " +
- IntToStr(m_sAFC_ARFCN)
- );
- return false;
- }
- }
- #endif
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- m_pRct->as_RCT + " < BCH ARFCN = "+
- IntToStr(m_sAFC_ARFCN)
- );
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- //if (!(CRYSTAL == m_pCal->e_AFC_type) && (CMU_200 == m_pRct->device_type))
- {
- if (!m_rct_ctrl.RCT_cellPower(m_pRct, d_P_DL))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_POWER_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: " + m_pRct->as_RCT + " < Power = " +
- Double_To_AnsiString(d_P_DL)) + " dBm";
- return false;
- }
- }
- #if 0
- else // crystal at CMU200
- {
- if (!m_rct_ctrl.RCT_sig_cellPower(m_pRct, d_P_DL))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_POWER_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: cmu200< Power = " +
- Double_To_AnsiString(d_P_DL)) + " dBm";
- return false;
- }
- }
- #endif
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- m_pRct->as_RCT = " < cell power = "+
- Double_To_AnsiString( d_P_DL )
- );
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- #ifdef _MYDEBUG
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Sleep 100 " + AnsiString(__FILE__)
- );
- #endif
- if( age1960_PCS1900_BAND == vi_AFC_BAND )
- {
- if(META_Rf_SelectFrequencyBand1900_r( m_pCal->i_MainMETAHandle, 1, MF_SelectBand_cnf_cb, &MF_SelectBand_token, NULL) != META_SUCCESS)
- {
- CalErrorHandler( WM_MF_RF_AFC_SELECT_BAND_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target < set Band1900 flag = 1"
- );
- return false;
- }
- }
- 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_AFC_SELECT_BAND_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target < set Band1900 flag = 0"
- );
- return false;
- }
- }
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- // Sleep( 23000 ); // wait Agilent 8960 ready!
- // If Agilent 8960 not ready, target will not detection FB
- Sleep( 100 );
- MF_rf_afc_req->arfcn = m_sAFC_ARFCN;
- MF_rf_afc_req->dacValue = (TCVCXO == m_pCal->e_AFC_type)?m_sDAC1:m_sCRYSTAL_DAC1;
- MF_rf_afc_req->gain = (MF_RF_GAIN_TO_BE_SUB - d_P_DL) * GAIN_REQUEST_PC_SIDE_MULTIPLY;
- MF_rf_afc_req->testNumber = m_sN_AFC;
- if ( META_Rf_AFC_r( m_pCal->i_MainMETAHandle, MF_rf_afc_req, MF_rf_afc_cb, &MF_rf_afc_token,NULL ) != META_SUCCESS )
- {
- CalErrorHandler( WM_MF_RF_AFC_CONTROL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target < AFC: ARFCN = "+ IntToStr( m_sAFC_ARFCN ) +
- ", dac value = "+ IntToStr(MF_rf_afc_req->dacValue) +
- ", gain = " + Double_To_AnsiString(MF_rf_afc_req->gain/RF_RX_GAIN_SCALE) + " dB" +
- ", testing number = " + IntToStr( m_sN_AFC )
- );
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < ARFCN = "+ IntToStr( m_sAFC_ARFCN ) +
- ", dac value = "+ IntToStr(MF_rf_afc_req->dacValue) +
- ", gain = " + Double_To_AnsiString(MF_rf_afc_req->gain/RF_RX_GAIN_SCALE) + " dB" +
- ", testing number = " + IntToStr( m_sN_AFC )
- );
- #ifdef _MYDEBUG_
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " TimerCal->Enabled 2= " + IntToStr((int)frmFatcory->TimerCal->Enabled)
- );
- #endif
- RestartTimerCal( WM_MF_RF_AFC_CONTROL_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_afc_cnf->fcb_ok_number <= 0 )
- {
- CalErrorHandler( WM_MF_RF_AFC_CONTROL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target< AFC FB detection fail "
- );
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- int i_FreqOffset1 = MF_rf_afc_cnf->freqOffset;
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target > freqOffset = "+ IntToStr(i_FreqOffset1)
- );
- // if( i_DAC2 <= i_DAC1)
- // {
- // CalErrorHandler( WM_MF_RF_AFC_CONTROL_FAIL );
- // log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " FAIL: target < i_DAC2 <= i_DAC1 "
- // );
- // return false;
- // }
- // if ( this->Terminated )
- // {
- // this->OnTerminate = neByUser;
- // return false;
- // }
- // if( frmFatcory->rbAgilent8960->Checked && frmFatcory->rbCrystal->Checked )
- // { MF_rf_afc_req->dacValue = i_DAC2 | TIMESLOT_3<<13;
- // }
- // else if( frmFatcory->rbCMU200->Checked && frmFatcory->rbCrystal->Checked )
- // { MF_rf_afc_req->dacValue = i_DAC2 | TIMESLOT_0<<13;
- // }
- // else // TVCVXO
- {
- MF_rf_afc_req->dacValue = (TCVCXO == m_pCal->e_AFC_type)?m_sDAC2:m_sCRYSTAL_DAC2;
- }
- if ( META_Rf_AFC_r( m_pCal->i_MainMETAHandle,
- MF_rf_afc_req,
- MF_rf_afc_cb,
- &MF_rf_afc_token,
- NULL
- ) != META_SUCCESS )
- {
- CalErrorHandler( WM_MF_RF_AFC_CONTROL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target < ARFCN = "+ IntToStr( m_sARFCN_C0_GSM ) +
- ", dac value = "+ IntToStr(MF_rf_afc_req->dacValue) +
- ", gain = " + Double_To_AnsiString(MF_rf_afc_req->gain/RF_RX_GAIN_SCALE) + " dB" +
- ", testing number = " + IntToStr(m_sN_AFC)
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < ARFCN = "+ IntToStr( m_sAFC_ARFCN ) +
- ", dac value = "+ IntToStr(MF_rf_afc_req->dacValue) +
- ", gain = " + Double_To_AnsiString(MF_rf_afc_req->gain/RF_RX_GAIN_SCALE) + " dB" +
- ", testing number = " + IntToStr(m_sN_AFC)
- );
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Terminate at line " + AnsiString(__FILE__) + " " + AnsiString(__LINE__)
- );
- return false;
- }
- // log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " TimerCal->Enabled 3= " + IntToStr((int)frmFatcory->TimerCal->Enabled)
- // );
- RestartTimerCal(WM_MF_RF_AFC_CONTROL_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_afc_cnf->fcb_ok_number <= 0 )
- {
- CalErrorHandler( WM_MF_RF_AFC_CONTROL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target< FB detection fail "
- );
- return false;
- }
- int i_FreqOffset2 = MF_rf_afc_cnf->freqOffset;
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target > freqOffset = "+ IntToStr( i_FreqOffset2 )
- );
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- int i_band_index = MF_rf_afc_ptr->Get_Band_Index( m_asAFC_BAND );
- float Afc_Slope_factor = MF_rf_afc_ptr->Get_Afc_Slope_factor(i_band_index);
- if (TCVCXO == m_pCal->e_AFC_type)
- {
- f_Slope = (double)(i_FreqOffset1 - i_FreqOffset2)/(double)(m_sDAC2 - m_sDAC1);
- i_Slope_inv = (int)(RF_AFC_SLOPE_DENOMINATOR * (m_sDAC2 - m_sDAC1)) /
- (i_FreqOffset1 - i_FreqOffset2)/Afc_Slope_factor;
- m_sDefault_value = (unsigned short) ((i_FreqOffset1/f_Slope)+ m_sDAC1);
- }
- else
- {
- f_Slope = (double)(i_FreqOffset1 - i_FreqOffset2)/(double)(m_sCRYSTAL_DAC2 - m_sCRYSTAL_DAC1);
- i_Slope_inv = (int)(RF_AFC_SLOPE_DENOMINATOR * (m_sCRYSTAL_DAC2 - m_sCRYSTAL_DAC1)) /
- (i_FreqOffset1 - i_FreqOffset2)/Afc_Slope_factor;
- m_sDefault_value = (unsigned short) ((i_FreqOffset1/f_Slope)+ m_sCRYSTAL_DAC1);
- }
- f_Slope = f_Slope * Afc_Slope_factor; // normalization
- ///// write afc to NVRAM
- S_AFC_RESULT navram_afc;
- navram_afc.s_InitAfcDac = m_sDefault_value;
- navram_afc.i_AfcSlopeInv = i_Slope_inv;
- MF_rf_afc_ptr->Set_AfcResult(navram_afc);
- MF_rf_afc_ptr->ConfirmCallback = ::ccb_write_afc_to_nvram;
- MF_rf_afc_ptr->REQ_Write_To_NVRAM_Start();
- RestartTimerCal (WM_MF_NVRAM_AFC_WRITE_FAIL);
- SUSPEND_CAL_THREAD
- E_METAAPP_RESULT_T state = MF_rf_afc_ptr->Get_ConfirmState();
- if (state != METAAPP_SUCCESS)
- {
- if (METAAPP_NVRAM_LID_VER_NOT_SUPPORT == state)
- {
- CalErrorHandler(WM_MF_NVRAM_EF_L1_AFCDATA_LID_VERNO_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : NVRAM_EF_L1_AFCDATA_LID version is not support, please update META to latest version. "
- );
- }
- else
- {
- CalErrorHandler(WM_MF_NVRAM_AFC_WRITE_FAIL);
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < Write AFC slope and offset to NVRAM fail "
- );
- }
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < Write AFC slope and offset to NVRAM"
- );
- //ResultHeaderBuf2 = ResultHeaderBuf2 + "Initial_DAC" + " ";
- sprintf(tempbuf, "%11d", navram_afc.s_InitAfcDac);
- m_pCal->as_ResultBuf = m_pCal->as_ResultBuf + tempbuf + ", ";
- // ResultHeaderBuf2 = ResultHeaderBuf2 + "AFC_slope" + " ";
- sprintf(tempbuf, "%8.4f", 1.0*RF_AFC_SLOPE_DENOMINATOR/navram_afc.i_AfcSlopeInv);
- m_pCal->as_ResultBuf = m_pCal->as_ResultBuf + tempbuf + ", ";
- // added by Andy Ueng
- // WriteAFCCalResultToFile(IntToStr(i_ID)+".cal",Application->ExeName );
- if (!WriteAFCCalResultToFile(as_ID+".cal",Application->ExeName, m_pCal->b_CalResultPath ) )
- {
- CalErrorHandler(WM_MF_RF_AFC_WRITE_CAL_RESULT_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : write AFC parameter to cal file "
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " ======================= AFC calibration end ====================== n "
- );
- // ---------------- AFC calibration result check begin -------------------------
- log->Add( "n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " ================== AFC calibration check begin =================== "
- );
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- // if( as_max_AfcSlope != NULL && as_min_AfcSlope != NULL)
- {
- if( ( d_min_AfcSlope<=f_Slope && f_Slope<= d_max_AfcSlope ))
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " PASS: AFC slope check:" + " AFC = " +
- Double_To_AnsiString( f_Slope ) +
- " min AFC slope = " + Double_To_AnsiString( d_min_AfcSlope ) + "," +
- " max AFC slope = " + Double_To_AnsiString( d_max_AfcSlope )
- );
- }
- else
- {
- CalErrorHandler( WM_MF_RF_AFC_CHECK_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: AFC slope check ." + " AFC = " +
- Double_To_AnsiString(f_Slope)+
- "n" +
- " min AFC slope = " + Double_To_AnsiString( d_min_AfcSlope ) + "n" +
- " max AFC slope = " + Double_To_AnsiString( d_max_AfcSlope )
- );
- return false;
- }
- }//if
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if( (m_sMinInitAfcDac<=navram_afc.s_InitAfcDac && navram_afc.s_InitAfcDac<= m_sMaxInitAfcDac))
- {
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " PASS: AFC initial DAC value check:" + " AFC = " +
- Double_To_AnsiString(navram_afc.s_InitAfcDac) + "," +
- " min AFC initial DAC value = " + IntToStr( m_sMinInitAfcDac ) + "," +
- " max AFC initial DAC value = " + IntToStr( m_sMaxInitAfcDac )
- );
- }
- else
- {
- CalErrorHandler(WM_MF_RF_AFC_CHECK_FAIL);
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: AFC initial DAC value check:" + " AFC = " +
- Double_To_AnsiString(navram_afc.s_InitAfcDac)+
- "n" +
- " min AFC initial DAC value = " + IntToStr( m_sMinInitAfcDac ) + "n" +
- " max AFC initial DAC value = " + IntToStr( m_sMaxInitAfcDac )
- );
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- // ---------------- AFC calibration result check end ---------------------------
- // end of added
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target< default value = " + IntToStr(m_sDefault_value)
- );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target< slope inv = " + IntToStr(i_Slope_inv)
- );
- MF_rf_afc_ptr->ConfirmCallback = ccb_write_afc_to_nvram;
- MF_rf_afc_ptr->REQ_Write_To_NVRAM_Start();
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- // log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " TimerCal->Enabled 4= " + IntToStr((int)frmFatcory->TimerCal->Enabled)
- // );
- RestartTimerCal(WM_MF_NVRAM_AFC_WRITE_FAIL);
- SUSPEND_CAL_THREAD
- state = MF_rf_afc_ptr->Get_ConfirmState();
- if (state != METAAPP_SUCCESS)
- {
- if (METAAPP_NVRAM_LID_VER_NOT_SUPPORT == state)
- {
- CalErrorHandler(WM_MF_NVRAM_EF_L1_AFCDATA_LID_VERNO_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : NVRAM_EF_L1_AFCDATA_LID version is not support, please update META to latest version. "
- );
- }
- else
- {
- CalErrorHandler(WM_MF_NVRAM_AFC_WRITE_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target< Write AFC value to NVRAM fail "
- );
- return false;
- }
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target< Write AFC value to NVRAM"
- );
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- // set AFC initial DAC value
- RfSetAfcDacValue_Req MF_rf_SetAfcDacValue;
- MF_rf_SetAfcDacValue.dacValue = navram_afc.s_InitAfcDac;
- if (META_Rf_SetAfcDacValue_r(m_pCal->i_MainMETAHandle, &MF_rf_SetAfcDacValue, MF_rf_SetAfcDacValue_cb, &MF_rf_afc_token, NULL)
- != META_SUCCESS )
- {
- CalErrorHandler(WM_MF_RF_SET_AFC_DAC_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target < Set AFC DAC = "+ IntToStr(MF_rf_SetAfcDacValue.dacValue)
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < Set AFC DAC = "+ IntToStr( MF_rf_SetAfcDacValue.dacValue )
- );
- RestartTimerCal( WM_MF_RF_SET_AFC_DAC_CNF_FAIL );
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- if( RfSetAfcDacCnf == false )
- {
- CalErrorHandler( WM_MF_RF_SET_AFC_DAC_CNF_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target < Set AFC DAC = "+ IntToStr(MF_rf_SetAfcDacValue.dacValue)
- );
- return false;
- }
- PostMessage(
- ctrl.hPostMsgDestHandle,
- WM_MF_RF_AFC_CALIBRATION_DONE,
- 0,
- 0
- );
-
- if (TCVCXO == m_pCal->e_AFC_type)
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " =================== AFC calibration check end ==================== n "
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " =================== AFC slope calibration check end ==================== n "
- );
- }
- frmFatcory->DisableAllCalTimer();
- return true;
- } // AFCCalibration()
- //--------------------------------------------------------------------------
- bool __fastcall T_META_factory_calibration::AFCSlopeCal( int vi_band, short bch, float &slope, unsigned short &us_init_value )
- {
- char tempbuf[256];
- #if 0
- 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;
- }
- if( ! m_rct_ctrl.RCT_sig_cellBand( m_pRct, vi_band ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_BAND_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- " cmu200 < Band = " + ViBand_To_Str( vi_band )
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " CMU 200< Band = "+
- ViBand_To_Str( vi_band )
- );
- if( ! m_rct_ctrl.RCT_sig_BCHARFCN( m_pRct, bch ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_BCH_ARFCN_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: cmu200 < BCH ARFCN = " +
- IntToStr(bch)
- );
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " CMU 200< BCH ARFCN = "+
- IntToStr( bch )
- );
- if( ! m_rct_ctrl.RCT_sig_cellPower( m_pRct, d_P_DL ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_POWER_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: cmu200< Power = " +
- Double_To_AnsiString( d_P_DL) ) + " dBm";
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " CMU 200< cell power = "+
- Double_To_AnsiString( d_P_DL )
- );
- if( age1960_PCS1900_BAND == vi_band )
- {
- if(META_Rf_SelectFrequencyBand1900_r( m_META_HANDLE_Obj.Get_MainHandle(), 1, MF_SelectBand_cnf_cb, &MF_SelectBand_token, NULL) != META_SUCCESS)
- {
- CalErrorHandler( WM_MF_RF_AFC_SELECT_BAND_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target < set Band1900 flag = 1"
- );
- return false;
- }
- }
- else
- {
- if(META_Rf_SelectFrequencyBand1900_r( m_META_HANDLE_Obj.Get_MainHandle(), 0, MF_SelectBand_cnf_cb, &MF_SelectBand_token, NULL) != META_SUCCESS)
- {
- CalErrorHandler( WM_MF_RF_AFC_SELECT_BAND_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target < set Band1900 flag = 0"
- );
- return false;
- }
- }
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- #endif
- Sleep( 100 ); // wait Agilent 8960 ready!
- // If Agilent 8960 not ready, target will not detection FB
- if( m_bFirstAfcTracking )
- {
- m_bFirstAfcTracking = false;
- if (TCVCXO == m_pCal->e_AFC_type)
- {
- m_sDAC1 = m_sDefault_value;
- }
- else
- {
- m_sCRYSTAL_DAC1 = m_sDefault_value;
- }
- }
- else
- {
- if( META_SUCCESS != META_QueryIfFunctionSupportedByTarget_r(m_pCal->i_MainMETAHandle, 500, "META_Rf_GetAfcDacValueAtRTXOffsetCal_r") )
- {
- MF_bb_reg_ptr->ConfirmCallback = ::CNF_BB;
- MF_bb_reg_ptr->REQ_ReadRegister_Start(ADDR_AFC_DAC);
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- if( MF_bb_reg_ptr->Get_ConfirmState() != METAAPP_SUCCESS )
- {
- CalErrorHandler( WM_MF_NVRAM_IP2_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target > read AFC DAC value from baseband register fail."
- );
- return false;
- }
- if (TCVCXO == m_pCal->e_AFC_type)
- {
- m_sDAC1 = (int) MF_bb_reg_ptr->Get_RegValue();
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target > read AFC DAC value from baseband register, AFC DAC = " + IntToStr(m_sDAC1)
- );
- }
- else
- {
- m_sCRYSTAL_DAC1 = (int) MF_bb_reg_ptr->Get_RegValue();
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target > read AFC DAC value from baseband register, AFC DAC = " + IntToStr(m_sCRYSTAL_DAC1)
- );
- }
- }
- else
- {
- // i_DAC2 = i_DAC1 - 400;
- RfGetAfcDacValueAtRTXOffsetCal cnf;
- if( META_SUCCESS != META_Rf_GetAfcDacValueAtRTXOffsetCal_r( m_pCal->i_MainMETAHandle, 5000, &cnf) )
- {
- CalErrorHandler( WM_MF_RF_AFC_GET_AFCDAC_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target > read AFC DAC value fail "
- );
- return false;
- }
- if (TCVCXO == m_pCal->e_AFC_type)
- {
- m_sDAC1 = cnf.dacValue;
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target > read AFC DAC value , AFC DAC = " + IntToStr(m_sDAC1)
- );
- }
- else
- {
- m_sCRYSTAL_DAC1 = cnf.dacValue;
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target > read AFC DAC value , AFC DAC = " + IntToStr(m_sCRYSTAL_DAC1)
- );
- }
- }
- }
- int count = 0;
- long i_FreqOffset1;
- do
- {
- count++;
- // Sleep(1000);
- MF_rf_afc_req->dacValue = (TCVCXO == m_pCal->e_AFC_type)?m_sDAC1:m_sCRYSTAL_DAC1;
- MF_rf_afc_req->arfcn = bch;
- MF_rf_afc_req->gain = (MF_RF_GAIN_TO_BE_SUB - d_P_DL) * GAIN_REQUEST_PC_SIDE_MULTIPLY;
- MF_rf_afc_req->testNumber = m_sN_AFC;
- if ( META_Rf_AFC_r( m_pCal->i_MainMETAHandle, MF_rf_afc_req, MF_rf_afc_cb, &MF_rf_afc_token,NULL ) != META_SUCCESS )
- {
- CalErrorHandler( WM_MF_RF_AFC_CONTROL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target < AFC: ARFCN = "+ IntToStr( bch ) +
- ", dac value = "+ IntToStr(MF_rf_afc_req->dacValue) +
- ", gain = " + Double_To_AnsiString(MF_rf_afc_req->gain/RF_RX_GAIN_SCALE) + " dB" +
- ", testing number = " + IntToStr( m_sN_AFC )
- );
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < ARFCN = "+ IntToStr( bch ) +
- ", dac value = "+ IntToStr(MF_rf_afc_req->dacValue) +
- ", gain = " + Double_To_AnsiString(MF_rf_afc_req->gain/RF_RX_GAIN_SCALE) + " dB" +
- ", testing number = " + IntToStr( m_sN_AFC )
- );
- //log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- // " TimerCal->Enabled 2= " + IntToStr((int)frmFatcory->TimerCal->Enabled)
- // );
- RestartTimerCal( WM_MF_RF_AFC_CONTROL_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_afc_cnf->fcb_ok_number <= 0 )
- {
- CalErrorHandler( WM_MF_RF_AFC_CONTROL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target< AFC FB detection fail "
- );
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- i_FreqOffset1 = MF_rf_afc_cnf->freqOffset;
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target > freqOffset = "+ IntToStr( i_FreqOffset1 )
- );
- int i_band_index = MF_rf_afc_ptr->Get_Band_Index( m_asAFC_BAND );
- float Afc_Slope_factor = MF_rf_afc_ptr->Get_Afc_Slope_factor(i_band_index);
- slope = (float)( RF_AFC_SLOPE_DENOMINATOR * 1.0 / ( i_Slope_inv * Afc_Slope_factor ));
- if (TCVCXO == m_pCal->e_AFC_type)
- {
- m_sDAC1 = (unsigned short) ((0.5*i_FreqOffset1/slope)+ m_sDAC1);
- }
- else
- {
- m_sCRYSTAL_DAC1 = (unsigned short) ((0.5*i_FreqOffset1/slope)+ m_sCRYSTAL_DAC1);
- }
- }
- while( abs(i_FreqOffset1) > m_dCRYSTAL_AFC_MAX_AFC_TRACK_INIT_FREQ_ERR && count <= m_sCRYSTAL_AFC_RECURSIVE_TIMES);
- if (TCVCXO == m_pCal->e_AFC_type)
- {
- us_init_value = m_sDAC1;
- }
- else
- {
- us_init_value = m_sCRYSTAL_DAC1;
- }
- #if 0
- // set AFC initial DAC value
- MF_rf_SetAfcDacValue->dacValue = us_init_value;
- if ( META_Rf_SetAfcDacValue_r( m_META_HANDLE_Obj.Get_MainHandle(), MF_rf_SetAfcDacValue, MF_rf_SetAfcDacValue_cb, &MF_rf_afc_token, NULL)
- != META_SUCCESS )
- {
- CalErrorHandler( WM_MF_RF_SET_AFC_DAC_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target < Set AFC DAC = "+ IntToStr( MF_rf_SetAfcDacValue->dacValue )
- );
- return false;
- }
- #endif
- // if( i_DAC2 <= i_DAC1)
- // {
- // CalErrorHandler( WM_MF_RF_AFC_CONTROL_FAIL );
- // log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " FAIL: target < i_DAC2 <= i_DAC1 "
- // );
- // return false;
- // }
- //
- // if ( this->Terminated )
- // {
- // this->OnTerminate = neByUser;
- // return false;
- // }
- // if( frmFatcory->rbAgilent8960->Checked && frmFatcory->rbCrystal->Checked )
- // { MF_rf_afc_req->dacValue = i_DAC2 | TIMESLOT_3<<13;
- // }
- // else if( frmFatcory->rbCMU200->Checked && frmFatcory->rbCrystal->Checked )
- // { MF_rf_afc_req->dacValue = i_DAC2 | TIMESLOT_0<<13;
- // }
- // else // TVCVXO
- #if 0
- {
- MF_rf_afc_req->dacValue = i_DAC2;
- }
- if ( META_Rf_AFC_r( m_META_HANDLE_Obj.Get_MainHandle(),
- MF_rf_afc_req,
- MF_rf_afc_cb,
- &MF_rf_afc_token,
- NULL
- ) != META_SUCCESS )
- {
- CalErrorHandler( WM_MF_RF_AFC_CONTROL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target < ARFCN = "+ IntToStr( m_sARFCN_C0_GSM ) +
- ", dac value = "+ IntToStr( i_DAC2 ) +
- ", gain = " + IntToStr( MF_rf_afc_req->gain ) +
- ", testing number = " + IntToStr( m_sN_AFC )
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < ARFCN = "+ IntToStr( bch ) +
- ", dac value = "+ IntToStr( i_DAC2 ) +
- ", gain = " + IntToStr( MF_rf_afc_req->gain ) +
- ", testing number = " + IntToStr( m_sN_AFC )
- );
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Terminate at line " + AnsiString(__FILE__) + " " + AnsiString(__LINE__)
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " TimerCal->Enabled 3= " + IntToStr((int)frmFatcory->TimerCal->Enabled)
- );
- RestartTimerCal( WM_MF_RF_AFC_CONTROL_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_afc_cnf->fcb_ok_number <= 0 )
- {
- CalErrorHandler( WM_MF_RF_AFC_CONTROL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target< FB detection fail "
- );
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- int i_band_index = MF_rf_afc_ptr->Get_Band_Index( m_asAFC_BAND );
- float Afc_Slope_factor = MF_rf_afc_ptr->Get_Afc_Slope_factor(i_band_index);
- i_FreqOffset2 = MF_rf_afc_cnf->freqOffset;
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target > freqOffset = "+ IntToStr( i_FreqOffset2 )
- );
- slope = double( i_FreqOffset1 - i_FreqOffset2 )/
- double( i_DAC2 - i_DAC1 );
- i_Slope_inv = (int)( RF_AFC_SLOPE_DENOMINATOR * ( i_DAC2 - i_DAC1 )) /
- ( i_FreqOffset1 - i_FreqOffset2 )/Afc_Slope_factor;
- #endif
- #if 0 // mark temp
- int i_band_index = MF_rf_afc_ptr->Get_Band_Index( m_asAFC_BAND );
- float Afc_Slope_factor = MF_rf_afc_ptr->Get_Afc_Slope_factor(i_band_index);
- slope = (float)( RF_AFC_SLOPE_DENOMINATOR * 1.0 / ( i_Slope_inv * Afc_Slope_factor ));
- i_DAC2 = (unsigned short) ((i_FreqOffset1/slope)+ i_DAC1);
- MF_rf_afc_req->dacValue = i_DAC2;
- if ( META_Rf_AFC_r( m_META_HANDLE_Obj.Get_MainHandle(),
- MF_rf_afc_req,
- MF_rf_afc_cb,
- &MF_rf_afc_token,
- NULL
- ) != META_SUCCESS )
- {
- CalErrorHandler( WM_MF_RF_AFC_CONTROL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target < ARFCN = "+ IntToStr( m_sARFCN_C0_GSM ) +
- ", dac value = "+ IntToStr( i_DAC2 ) +
- ", gain = " + IntToStr( MF_rf_afc_req->gain ) +
- ", testing number = " + IntToStr( m_sN_AFC )
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < ARFCN = "+ IntToStr( bch ) +
- ", dac value = "+ IntToStr( i_DAC2 ) +
- ", gain = " + IntToStr( MF_rf_afc_req->gain ) +
- ", testing number = " + IntToStr( m_sN_AFC )
- );
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Terminate at line " + AnsiString(__FILE__) + " " + AnsiString(__LINE__)
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " TimerCal->Enabled 3= " + IntToStr((int)frmFatcory->TimerCal->Enabled)
- );
- RestartTimerCal( WM_MF_RF_AFC_CONTROL_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_afc_cnf->fcb_ok_number <= 0 )
- {
- CalErrorHandler( WM_MF_RF_AFC_CONTROL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target< FB detection fail "
- );
- return false;
- }
- i_FreqOffset2 = MF_rf_afc_cnf->freqOffset;
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target > freqOffset = "+ IntToStr( i_FreqOffset2 )
- );
- //slope = (float)( RF_AFC_SLOPE_DENOMINATOR * 1.0 / ( i_Slope_inv ));
- us_init_value = (unsigned short) ((i_FreqOffset2/slope)+ i_DAC2);
- // slope = slope * Afc_Slope_factor; // normalization
- ///// write afc to fdm
- // if( frmFatcory->rbAgilent8960->Checked && frmFatcory->rbCrystal->Checked )
- // { MF_rf_afc_req->dacValue = us_init_value | TIMESLOT_3<<13;
- // }
- // else if( frmFatcory->rbCMU200->Checked && frmFatcory->rbCrystal->Checked )
- // { MF_rf_afc_req->dacValue = us_init_value | TIMESLOT_0<<13;
- // }
- // else // TVCVXO
- {
- MF_rf_afc_req->dacValue = us_init_value;
- }
- MF_rf_afc_req->arfcn = bch;
- // MF_rf_afc_req->dacValue = us_init_value;
- MF_rf_afc_req->gain = (MF_RF_GAIN_TO_BE_SUB - d_P_DL) * GAIN_REQUEST_PC_SIDE_MULTIPLY;
- MF_rf_afc_req->testNumber = 1;
- if ( META_Rf_AFC_r( m_META_HANDLE_Obj.Get_MainHandle(), MF_rf_afc_req, MF_rf_afc_cb, &MF_rf_afc_token,NULL ) != META_SUCCESS )
- {
- CalErrorHandler( WM_MF_RF_AFC_CONTROL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target < AFC: ARFCN = "+ IntToStr( bch ) +
- ", dac value = "+ IntToStr( us_init_value ) +
- ", gain = " + IntToStr( MF_rf_afc_req->gain ) +
- ", testing number = " + IntToStr( m_sN_AFC )
- );
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < ARFCN = "+ IntToStr( bch ) +
- ", dac value = "+ IntToStr( us_init_value ) +
- ", gain = " + IntToStr( MF_rf_afc_req->gain ) +
- ", testing number = " + IntToStr( m_sN_AFC )
- );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " TimerCal->Enabled 2= " + IntToStr((int)frmFatcory->TimerCal->Enabled)
- );
- RestartTimerCal( WM_MF_RF_AFC_CONTROL_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;
- }
- // set AFC initial DAC value
- MF_rf_SetAfcDacValue->dacValue = us_init_value;
- if ( META_Rf_SetAfcDacValue_r( m_META_HANDLE_Obj.Get_MainHandle(), MF_rf_SetAfcDacValue, MF_rf_SetAfcDacValue_cb, &MF_rf_afc_token, NULL)
- != META_SUCCESS )
- {
- CalErrorHandler( WM_MF_RF_SET_AFC_DAC_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target < Set AFC DAC = "+ IntToStr( MF_rf_SetAfcDacValue->dacValue )
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < Set AFC DAC = "+ IntToStr( MF_rf_SetAfcDacValue->dacValue )
- );
- RestartTimerCal( WM_MF_RF_SET_AFC_DAC_CNF_FAIL );
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- if( RfSetAfcDacCnf == false )
- {
- CalErrorHandler( WM_MF_RF_SET_AFC_DAC_CNF_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target < Set AFC DAC = "+ IntToStr( MF_rf_SetAfcDacValue->dacValue )
- );
- return false;
- }
- #endif
- return true;
- } // AFCSlopeCal()
- //******************************************************************************
- // Crystal AFC calibration
- //******************************************************************************
- bool __fastcall T_META_factory_calibration::CrystalAFCCapIDCommon( void )
- {
- //bool isAgilent8960Seleced = frmFatcory->rbAgilent8960->Checked;
- int vi_CRYSTAL_AFC_BAND;
- char tempbuf[256];
- PostMessage(
- ctrl.hPostMsgDestHandle,
- WM_MF_RF_CRYSTAL_AFC_CAPID_BEGIN,
- 0,
- 0
- );
- log->Add( "n" +DateToStr(Date()) + " " + CurrentTimeStr() +
- " ================= Crystal CAPID calibration begin ================ "
- );
- //int init_cap_id = MF_crystal_afc_ptr->Get_cap_id(); // get cap_id from NVRAM
- FrequencyBand freq_band = Get_FreqBandFromAnsiString( as_CRYSTAL_AFC_BAND );
- vi_CRYSTAL_AFC_BAND = Get_AgeBand( as_CRYSTAL_AFC_BAND );
- if( getCenterFreq(freq_band, m_sCRYSTAL_AFC_ARFCN, false, &d_CAL_Center_Freq) == false )
- {
- CalErrorHandler( WM_MF_RF_CRYSTAL_AFC_CHECK_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : get center frequency error."
- );
- return false;
- }
- if (!m_rct_ctrl.RCT_operatingMode(m_pRct, OPERATING_MODE_GSM_BCH_TCH))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_OPERATION_MODE_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " +
- m_pRct->as_RCT + " < Operation mode = GSM BCH+TCH"
- );
- return false;
- }
- if (!m_rct_ctrl.RCT_cellBand(m_pRct, vi_CRYSTAL_AFC_BAND))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_BAND_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " +
- m_pRct->as_RCT + " < Band = " + ViBand_To_Str(vi_CRYSTAL_AFC_BAND)
- );
- return false;
- }
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- m_pRct->as_RCT + " < Band = " +
- FreqBand_To_Str(AgeBand_To_FreqBand(vi_CRYSTAL_AFC_BAND))
- );
- if (!m_rct_ctrl.RCT_cellPower(m_pRct, d_P_DL))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_POWER_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: " + m_pRct->as_RCT + " < Power = " +
- Double_To_AnsiString(d_P_DL)) + " dBm";
- return false;
- }
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < cell power = "+
- Double_To_AnsiString(d_P_DL)
- );
- // short bch_arfcn = ::Get_SeperateChannel( vi_CRYSTAL_AFC_BAND, m_sCRYSTAL_AFC_ARFCN );
- if (!m_rct_ctrl.RCT_BCHARFCN(m_pRct, m_sCRYSTAL_AFC_ARFCN))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_TCH_ARFCN_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " +
- m_pRct->as_RCT + " < BCH ARFCN = " + IntToStr( m_sCRYSTAL_AFC_ARFCN )
- );
- return false;
- }
- if (!m_rct_ctrl.RCT_TCHARFCN(m_pRct, m_sCRYSTAL_AFC_ARFCN))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_TCH_ARFCN_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- m_pRct->as_RCT + " < TCH ARFCN = " + IntToStr( m_sCRYSTAL_AFC_ARFCN )
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- m_pRct->as_RCT + " < TCH ARFCN = " + IntToStr( m_sCRYSTAL_AFC_ARFCN )
- );
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if (!m_rct_ctrl.RCT_ConfigTSC(m_pRct, m_cTSC))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_TSC_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- "FAIL : " + m_pRct->as_RCT + " < set TSC fail."
- );
- return false;
- }
- EquConfigPFER();
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- int i_CRYSTAL_AFC_PCL = Get_CRYSTAL_AFC_PCL( as_CRYSTAL_AFC_BAND );
- if( ! m_rct_ctrl.RCT_MSTXLevel( m_pRct, i_CRYSTAL_AFC_PCL ) )
- {
- CalErrorHandler(WM_MF_AGE8960_SET_MS_TX_LEVEL_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " + m_pRct->as_RCT + " < MS TX level = " + IntToStr(i_CRYSTAL_AFC_PCL)
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- m_pRct->as_RCT + " < MS TX level = " + IntToStr(i_CRYSTAL_AFC_PCL)
- );
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if( freq_band == 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_CRYSTAL_AFC_SELECT_BAND_FAIL );
- 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_CRYSTAL_AFC_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;
- return true;
- }
- //---------------------------------------------------------------------------
- bool __fastcall T_META_factory_calibration::CrystalAFCCapIDPreCheck( void )
- {
- char tempbuf[256];
- log->Add( "n" +DateToStr(Date()) + " " + CurrentTimeStr() +
- " -------------- Crystal AFC pre-check begin --------------- "
- );
- int prechk_cap_id[2];
- double prechk_freq_err[2];
- prechk_cap_id[0] = CAP_ID_MIN;
- prechk_cap_id[1] = MF_crystal_afc_ptr->Get_max_cap_id(m_pCal->ui_rf_id);
- int i;
- for(i=0; i<2; i++)
- {
- MF_crystal_afc_ptr->Set_cap_id(prechk_cap_id[i]);
- CrystalCfg_req.cap_id = prechk_cap_id[i];
- if (WRITE_NVARM == m_pCal->s_crystal_afc_option.crystal_cap_id_update)
- {
- MF_crystal_afc_ptr->ConfirmCallback = ::ccb_write_CrystalAFC_to_nvram;
- MF_crystal_afc_ptr->REQ_Write_CAPID_To_NVRAM_Start();
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- E_METAAPP_RESULT_T state = MF_crystal_afc_ptr->Get_ConfirmState();
- if (state != METAAPP_SUCCESS)
- {
- if (METAAPP_NVRAM_LID_VER_NOT_SUPPORT == state)
- {
- CalErrorHandler(WM_MF_NVRAM_EF_L1_CRYSTAL_CAPDATA_LID_VERNO_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : NVRAM_EF_L1_CRYSTAL_CAPDATA_LID version is not support, please update META to latest version. "
- );
- }
- else
- {
- CalErrorHandler(WM_MF_NVRAM_CRYSTAL_AFC_CAPID_WRITE_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target< Write crystal AFC CAP ID to NVRAM fail "
- );
- }
- return false;
- }
- }
- else
- {
- MetaResult = META_Rf_SetCrystalCapId_r( m_pCal->i_MainMETAHandle, 5000, &CrystalCfg_req );
- if( MetaResult != META_SUCCESS )
- {
- CalErrorHandler( WM_MF_RF_CRYSTAL_AFC_SET_CAPID_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target< Set crystal AFC CAP ID fail "
- );
- return false;
- }
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- Sleep(50);
- if (!MF_rf_stop.REQ_Start())
- {
- CalErrorHandler( WM_MF_RF_STOP_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < stop RF fail."
- );
- return false;
- }
- // Sleep(50);
- int i_CRYSTAL_AFC_PCL = Get_CRYSTAL_AFC_PCL( as_CRYSTAL_AFC_BAND );
- MF_rf_tx_level_req->arfcn = m_sCRYSTAL_AFC_ARFCN;
- MF_rf_tx_level_req->bsic = m_cTSC;
- MF_rf_tx_level_req->power = i_CRYSTAL_AFC_PCL;
- MF_rf_tx_level_req->frames = 2000;
- MF_rf_tx_level_req->dacValue = m_sCRYSTAL_AFC_CAL_DAC;
- MF_rf_tx_level_req->burstTypeNB = NB_TX_RANDOM_WITH_TSC; // NB burst
- if ( META_Rf_NB_TX_r( m_pCal->i_MainMETAHandle,
- MF_rf_tx_level_req,
- cb_MF_rf_tx_level_crystal,
- &MF_rf_tx_level_token,
- NULL
- ) != META_SUCCESS)
- {
- CalErrorHandler( WM_MF_RF_TX_LEVEL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target< ARFCN = " + IntToStr(m_sCRYSTAL_AFC_ARFCN) +
- ", TSC = " + IntToStr( m_cTSC ) +
- ", power = " + IntToStr(i_CRYSTAL_AFC_PCL) +
- ", frames = " + IntToStr(i_N_TX) +
- ", dac value = " + IntToStr( m_sDefault_value )
- );
- return false;
- }
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- if (! MF_rf_tx_level_cnf )
- {
- CalErrorHandler( WM_MF_RF_CRYSTAL_AFC_TX_LEVEL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: TX level (! MF_rf_tx_level_cnf ) ."
- );
- return false;
- }
- if( ! FetchAverageFreqErr( prechk_freq_err[i] ) )
- {
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " CAP ID = " + IntToStr( prechk_cap_id[i] ) + "," +
- " AFC DAC = " + IntToStr( m_sCRYSTAL_AFC_CAL_DAC ) + "," +
- " Freq error = " + Double_To_AnsiString(prechk_freq_err[i])
- );
- sprintf(tempbuf, "%8.3f", prechk_freq_err[i]/d_CAL_Center_Freq);
- m_pCal->as_ResultBuf = m_pCal->as_ResultBuf + tempbuf + ", ";
- } // pre-check
- if( prechk_freq_err[0] * prechk_freq_err[1] > 0 )
- {
- m_bBypassCapIDCal = true;
- if( Abs_double(prechk_freq_err[0]) < Abs_double(prechk_freq_err[1]) )
- {
- min_CapIdFreqErr.cap_id = prechk_cap_id[0];
- }
- else
- {
- min_CapIdFreqErr.cap_id = prechk_cap_id[1];
- }
- MF_crystal_afc_ptr->Set_cap_id( min_CapIdFreqErr.cap_id );
- MF_crystal_afc_ptr->ConfirmCallback = ::ccb_write_CrystalAFC_to_nvram;
- MF_crystal_afc_ptr->REQ_Write_CAPID_To_NVRAM_Start();
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- E_METAAPP_RESULT_T state = MF_crystal_afc_ptr->Get_ConfirmState();
- if (state != METAAPP_SUCCESS)
- {
- if (METAAPP_NVRAM_LID_VER_NOT_SUPPORT == state)
- {
- CalErrorHandler(WM_MF_NVRAM_EF_L1_CRYSTAL_CAPDATA_LID_VERNO_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : NVRAM_EF_L1_CRYSTAL_CAPDATA_LID version is not support, please update META to latest version. "
- );
- }
- else
- {
- CalErrorHandler(WM_MF_NVRAM_CRYSTAL_AFC_CAPID_WRITE_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target< Write crystal AFC CAP ID to NVRAM fail "
- );
- }
- return false;
- }
- }
- else
- {
- m_bBypassCapIDCal = false;
- }
- if( prechk_freq_err[0] < prechk_freq_err[1] )
- {
- m_bFreqErrIncrease = true;
- }
- else
- {
- m_bFreqErrIncrease = false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " -------------- Crystal AFC pre-check end ----------------- "
- );
- Sleep(50);
- if (!MF_rf_stop.REQ_Start())
- {
- CalErrorHandler( WM_MF_RF_STOP_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < stop RF fail."
- );
- return false;
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool __fastcall T_META_factory_calibration::CrystalAFCCapIDCalDec(void)
- {
- int init_cap_id = MF_crystal_afc_ptr->Get_cap_id();
- min_CapIdFreqErr.cap_id = init_cap_id;
- min_CapIdFreqErr.FreqErr = 1000000000.0;
- cal_CapIdFreqErr.cap_id = min_CapIdFreqErr.cap_id;
- int pre_cap_id = -1;
- int cap_id_max;
- int first_cap_id = CAP_ID_MIN;
- int last_cap_id = MF_crystal_afc_ptr->Get_max_cap_id(m_pCal->ui_rf_id);
- cap_id_max = last_cap_id;
- int count=0;
- while( min_CapIdFreqErr.FreqErr != 0.0 &&
- first_cap_id < last_cap_id &&
- CAP_ID_MIN <= cal_CapIdFreqErr.cap_id &&
- cal_CapIdFreqErr.cap_id <= cap_id_max &&
- count < m_sCRYSTAL_AFC_RECURSIVE_TIMES
- )
- {
- count++;
- MF_crystal_afc_ptr->Set_cap_id(cal_CapIdFreqErr.cap_id);
- CrystalCfg_req.cap_id = cal_CapIdFreqErr.cap_id;
- if (WRITE_NVARM == m_pCal->s_crystal_afc_option.crystal_cap_id_update)
- {
- MF_crystal_afc_ptr->ConfirmCallback = ::ccb_write_CrystalAFC_to_nvram;