T_META_factory_calibration.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:55k
源码类别:
MTK
开发平台:
C++ Builder
- /*****************************************************************************
- * 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_META_factory_calibration.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * Factory calibration thread 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 <Classes.hpp>
- #include <assert.h>
- #include <math.h>
- #include <stdlib.h>
- #include "age1960.h"
- #include "hp661x.h"
- #include "hp663x2.h"
- #pragma hdrstop
- // common
- #ifndef _METAAPP_COMMON_H_
- #include "metaapp_common.h"
- #endif
- // equipment
- #ifndef _RCT_COMMON_H_
- #include "rct_common.h"
- #endif
- #include "age1968a.h"
- #include "cmu200.h"
- #ifndef _AGE_MISC_H_
- #include "age_misc.h"
- #endif
- // misc
- #include "math_utils.h"
- #include "meta_utils.h"
- #include "meta_msg.h"
- #include "META_const.h"
- #include "GSM_utils.h"
- #ifndef _TIME_UTILS_H_
- #include "time_utils.h"
- #endif
- #ifndef _MISC_WIFI_H_
- #include "misc_wifi.h"
- #endif
- #include "META_factory_type.h"
- #include "META_factory_cfg.h"
- // call back
- #include "META_factory_RF_cb.h"
- #include "META_factory_crystal_cb.h"
- #include "META_factory_NVRAM_cb.h"
- #ifndef _META_FACTORY_BB_CB_H_
- #include "META_factory_bb_cb.h"
- #endif
- // form
- #include "META_Factory.h"
- #include "form_Main.h"
- #include "T_META_factory_calibration.h"
- //////
- #include "rf_apc.h"
- #include "rf_agc.h"
- #include "rf_afc.h"
- #include "rf_stop.h"
- #include "bb_adc.h"
- // file
- #include "META_Factory_Result_Handle.h"
- #include "META_Factory_CFG_Handle.h"
- #ifndef _CAL_COMMON_H_
- #include "cal_common.h"
- #endif
- #ifndef _APCCAL_COMMON_H_
- #include "apccal_common.h"
- #endif
- // BT
- #ifndef _BT_POWER_H_
- #include "bt_power.h"
- #endif
- //------------------------------------------------------------------------------
- // phase error calibration
- #define BB_TX_NOT_CALIBRATED 0
- #define BB_TX_CALIBRATED 1
- // timeout value
- #define TREE_SENCONDS 3000
- #define FIVE_SENCONDS 5000
- #define TEN_SENCONDS 10000
- #define FIFTEEN_SENCONDS 15000
- //---------------------------------------------------------------------------
- // Important: Methods and properties of objects in VCL can only be
- // used in a method called using Synchronize, for example:
- //
- // Synchronize(UpdateCaption);
- //
- // where UpdateCaption could look like:
- //
- // void __fastcall Unit1::UpdateCaption()
- // {
- // Form1->Caption = "Updated in a thread";
- // }
- //---------------------------------------------------------------------------
- // {GSM, DCS, PCS}
- int PCL_high[3] = { 6, 1, 1};
- int PCL_mid[3] = {12, 8, 13};
- int PCL_low[3] = {17, 13, 13};
- // {low, mid, high}
- int PCL_GSM[3] = {17, 12, 6};
- int PCL_DCS[3] = {13, 8, 1};
- int PCL_PCS[3] = {13, 8, 1};
- bool is_suspend_cal = true;
- extern int TimerCalTimeoutID;
- int TimeoutInterval = FIFTEEN_SENCONDS;
- int ADC_TimeoutInterval = FIVE_SENCONDS;
- extern int TimerADCCalTimeoutID;
- //------------------------------------------------------------------------------
- // common
- extern bool is_calibration_start;
- // AFC
- extern CRFAFC* MF_rf_afc_ptr;
- // crystal AFC
- extern CCRYSTALAFC* MF_crystal_afc_ptr;
- // RX path loss
- extern CRFAGC* MF_rf_agc_ptr;
- // IP2
- extern CRFPM* MF_rf_pm_ptr;
- // APC
- extern CRFAPC* MF_rf_apc_ptr;
- extern RfNbtx_Req *MF_rf_tx_level_req;
- extern BOOL MF_rf_tx_level_cnf;
- extern CRFAPC8PSK* MF_rf_apc_8psk_ptr;
- // TX phase error
- extern CRFTXIQ* MF_rf_txiq_ptr;
- // ADC
- extern CBBADC* MF_BB_ADC_ptr;
- // Theread
- //extern T_META_factory_calibration* pt_calibration;
- extern bool IS_AgilentPowerSupply_INITIALISE; // T_Init_Age8960.cpp
- //CMU
- extern char cmd[1024], buf[1024];
- extern unsigned long num;
- //------------------------------------------------------------------------------
- __fastcall T_META_factory_calibration::T_META_factory_calibration(
- bool CreateSuspended,
- TYPE_META_FACTORY_CONTROL MF_ctrl,
- TYPE_META_FACTORY_ADC_CONTROL MF_ADC_ctrl, // add by Andy Ueng for ADC calibration
- TMETA_factory_cfg *MF_cfg,
- TStringList *st_Log,
- TNotifyEvent ne_onTermSuccess,
- TNotifyEvent ne_onTermByUser,
- AnsiString as_ID_par,
- AnsiString as_TaModel,
- S_RCT *p_Rct,
- S_BTT *p_Btt,
- S_WFT *p_Wft,
- S_DCS *p_Dcs,
- S_CAL *p_Cal)
- : TThread(CreateSuspended)
- {
- ctrl = MF_ctrl;
- ADC_ctrl = MF_ADC_ctrl; // ADC calibration
- cfg = MF_cfg;
- log = st_Log;
- neSuccess = ne_onTermSuccess;
- neByUser = ne_onTermByUser;
- as_ID = as_ID_par;
- as_AgeTaModel = as_TaModel;
- is_calibration_start = true;
- m_pRct = p_Rct;
- m_pBtt = p_Btt;
- m_pWft = p_Wft;
- // rct.age.vi = ctrl.vi;
- m_pDcs = p_Dcs;
- m_pCal = p_Cal;
- }
- //==============================================================================
- void __fastcall T_META_factory_calibration::Execute()
- {
- Read_Common_CFG();
- if( m_pCal->s_CalItem.b_wifi_tx_power_cal )
- {
- Read_WiFi_Common_CFG();
- }
- if (!WriteInitValueToNVRAM())
- {
- return;
- }
- if( m_pCal->s_CalItem.b_ip2_cal ||
- m_pCal->s_CalItem.b_afc_cal ||
- m_pCal->s_CalItem.b_rx_path_loss_cal ||
- m_pCal->s_CalItem.b_tx_iq_cal ||
- m_pCal->s_CalItem.b_tx_pcl_cal
- )
- {
- if( ! m_rct_ctrl.RCT_Init( m_pRct, m_asFreqBank ) )
- {
- CalErrorHandler( WM_MF_AGE8960_INIT_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_pRct->as_RCT+ " < Initialize"
- );
- return;
- }
- }
- // IP2 calibration
- if( m_pCal->s_CalItem.b_ip2_cal )
- {
- Read_IP2_CFG();
- if( ! IP2Cal() )
- {
- return;
- }
- }
- // AFC calibration
- m_sDefault_value = 4100;
- if( m_pCal->s_CalItem.b_afc_cal )
- {
- Read_AFC_CFG();
- if( TCVCXO == m_pCal->e_AFC_type )
- {
- if( ! AFCCal() )
- {
- return;
- }
- }
- else // crystal
- {
- Read_CrystalAFC_CFG();
- if( ! CrystalAFCCapIDCommon() )
- {
- return;
- }
- if( ! CrystalAFCCapIDPreCheck() )
- {
- return;
- }
- if( ! m_bBypassCapIDCal )
- {
- if( m_bFreqErrIncrease )
- {
- if( ! CrystalAFCCapIDCalInc() )
- {
- return;
- }
- }
- else
- {
- if( ! CrystalAFCCapIDCalDec() )
- {
- return;
- }
- }
- }
- if( ! m_bBypassCapIDCal )
- {
- if( ! CrystalAFCCapIDCheck_Normal() )
- {
- return;
- }
- }
- else
- {
- if( ! CrystalAFCCapIDCheck_BypassCapIDCal() )
- {
- return;
- }
- }
- if (!AFCCal())
- {
- return;
- }
- }
- }
- // RX path loss calibration
- if( m_pCal->s_CalItem.b_rx_path_loss_cal)
- {
- Read_RxPathLoss_CFG();
- if (!RxPathLossCal())
- {
- return;
- }
- }
- //TX DC offset calibration
- if( m_pCal->s_CalItem.b_tx_iq_cal )
- {
- if (!m_pCal->s_CalItem.b_afc_cal &&
- (AGILENT_8960 == m_pRct->device_type)
- )
- {
- PostMessage(
- ctrl.hPostMsgDestHandle,
- WM_MF_AFC_NOT_CHECK,
- 0,
- 0
- );
- return;
- }
- Read_TxIq_CFG();
- if( TX_IQ_GMSK == m_pCal->e_TX_IQ_type )
- {
- if( ! TXIqCal() )
- {
- return;
- }
- }
- else
- {
- if( ! TXIqCal_EPSK() )
- {
- return;
- }
- }
- }
- // TX PCL calibration
- if (m_pCal->s_CalItem.b_tx_pcl_cal)
- {
- if (!TXPCLCal())
- {
- return;
- }
- }
- // TRX offset calibration
- if (m_pCal->s_CalItem.b_trx_offset_cal)
- {
- if (!m_pCal->s_CalItem.b_afc_cal)
- {
- PostMessage(
- ctrl.hPostMsgDestHandle,
- WM_MF_AFC_NOT_CHECK,
- 0,
- 0
- );
- return;
- }
- if (CMU_200 == m_pRct->device_type)
- {
- if (!m_rct_ctrl.RCT_sig_Init(m_pRct, m_asFreqBank))
- {
- CalErrorHandler(WM_MF_AGE8960_INIT_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: CMU 200 < Initialize"
- );
- return;
- }
- }
- if (!CrystalTXAfcOffsetCal())
- {
- return;
- }
- // if (!m_rct_ctrl.RCT_Init(m_pRct, m_asFreqBank))
- // {
- // CalErrorHandler(WM_MF_AGE8960_INIT_FAIL);
- // log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- // " FAIL: " + m_pRct->as_RCT+ " < Initialize"
- // );
- // return;
- // }
- }
- //BT
- if (m_pCal->s_CalItem.b_bt_cap_id_cal)
- {
- if (!m_cBT_POWER_Obj.REQ_Query_Power_On_Start())
- {
- m_cBT_POWER_Obj.REQ_Power_On_Main_BT_Start();
- }
- Read_BT_CMU200_CFG();
- Read_BT_CBT_CFG();
- Read_BT_Common_CFG();
- Read_BT_CrystalCapID_CFG();
- if (BTMODULE_MT6601 == m_pCal->s_bt_bb_id.id)
- {
- if (!m_btt_ctrl.BTT_Init(m_pBtt))
- {
- PostMessage(ctrl.hPostMsgDestHandle,
- WM_MF_BTT_INIT_FAIL,
- 0,
- 0
- );
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " BT tester initialize fail "
- );
- return;
- }
- if (!m_btt_ctrl.BTT_Config_Downlink_Power(m_pBtt, m_dBT_DOWNLINK_POWER))
- {
- PostMessage(ctrl.hPostMsgDestHandle,
- WM_MF_BTT_CONFIG_DOWNLINK_POWER_FAIL,
- 0,
- 0
- );
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " BT tester < config downlink power fail "
- );
- return;
- }
- if (!BTCrystalCapIDCal_MT6601())
- {
- return;
- }
- if (!BTCrystalCapIDCheck_MT6601())
- {
- return;
- }
- }
- else if(BTMODULE_MT6611 == m_pCal->s_bt_bb_id.id)
- {
- if (!BTCrystalCapIDCal_MT6611())
- {
- return;
- }
- }
- if (!MF_rf_stop.REQ_Start())
- {
- CalErrorHandler(WM_MF_RF_STOP_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < stop RF fail."
- );
- return;
- }
- }
- // ADC calibration
- if (m_pCal->s_CalItem.b_adc_cal)
- {
- Read_ADC_CFG();
- if( ! ADCCal() )
- {
- return;
- }
- }
- // CV calibration
- if (m_pCal->s_CalItem.b_cv_cal)
- {
- Read_ADC_CFG();
- Read_CV_CFG();
- if (!CVCal_cal())
- {
- return;
- }
- if (!CVCal_check())
- {
- return;
- }
- }
- // WiFi TX DC offset
- if( m_pCal->s_CalItem.b_wifi_tx_dc_offset_cal )
- {
- if( ! WiFiTxDcOffsetCal() )
- {
- return;
- }
- }
- if( m_pCal->s_CalItem.b_wifi_tx_power_cal )
- {
- // Read_WiFi_Common_CFG();
- Read_WiFi_IQviewInit_CFG();
- Read_WiFi_AgeN4010aInit_CFG();
- Read_WiFi_TxPcl_CFG();
- // if( NULL == m_pWft->iqv.p_handle )
- // {
- if( ! m_wft_ctrl.WFT_Init( m_pWft ) )
- {
- PostMessage(
- ctrl.hPostMsgDestHandle,
- WM_MF_WIFI_INIT_FAIL,
- 0,
- 0
- );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " WiFi tester initialize fail "
- );
- return;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " WiFi tester initialize successfully "
- );
- if( ! m_wft_ctrl.WFT_ConOpen( m_pWft ) )
- {
- PostMessage(
- ctrl.hPostMsgDestHandle,
- WM_MF_WIFI_CONN_OPEN_FAIL,
- 0,
- 0
- );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " WiFi tester conncetion open fail "
- );
- return;
- }
- if( ! m_wft_ctrl.WFT_ConCalUpdate( m_pWft ) )
- {
- PostMessage(
- ctrl.hPostMsgDestHandle,
- WM_MF_WIFI_CONN_UPDATE_CALDATA_FAIL,
- 0,
- 0
- );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " WiFi tester update calibration data fail "
- );
- return;
- }
- if( ! m_wft_ctrl.WFT_SetDefault( m_pWft ) )
- {
- PostMessage(
- ctrl.hPostMsgDestHandle,
- WM_MF_WIFI_SET_DEFAULT_FAIL,
- 0,
- 0
- );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " WiFi tester sets default value fail "
- );
- return;
- }
- if( IQVIEW == m_pWft->device_type )
- {
- m_pWft->iqv.p_handle->adc.sampling_time = 0.005;
- m_pWft->iqv.p_handle->adc.sampling_trig_pre_time = 1.0e-6;
- m_pWft->iqv.p_handle->adc.sampling_trig_type = IQV_TRIG_TYPE_IF_NO_CAL;
- m_pWft->iqv.p_handle->select_input_mod = IQV_INPUT_MOD_DAC_RF; //1:IQV_INPUT_MOD_DAC_BB
- m_pWft->iqv.p_handle->select_input_adc = IQV_INPUT_ADC_RF;
- }
- if( ! m_wft_ctrl.WFT_SetTriggerStyle( m_pWft ) )
- {
- PostMessage(
- ctrl.hPostMsgDestHandle,
- WM_MF_WIFI_SET_TRIGGER_STYLE_FAIL,
- 0,
- 0
- );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " WiFi tester sets trigger style fail "
- );
- return;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " WiFi tester sets trigger style successfully "
- );
- if( ! m_wft_ctrl.WFT_SetPacketLength( m_pWft, 0.0001 ) ) // 100 us
- {
- PostMessage(
- ctrl.hPostMsgDestHandle,
- WM_MF_WIFI_SET_PACKET_LEN_FAIL,
- 0,
- 0
- );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " WiFi tester sets default value fail "
- );
- return;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " WiFi tester sets packet length = 100us "
- );
- if( ! WiFiTxPclCal_cal() )
- {
- return;
- }
- if( ! WiFiTxPclCal_check() )
- {
- return;
- }
- // if( ! m_wft_ctrl.WFT_ConClose( m_pWft ) )
- // {
- // PostMessage(
- // ctrl.hPostMsgDestHandle,
- // WM_MF_WIFI_CONN_CLOSE_FAIL,
- // 0,
- // 0
- // );
- // log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " WiFi tester closes connection fail "
- // );
- // }
- // if( ! m_wft_ctrl.WFT_Terminate( m_pWft ) )
- // {
- // PostMessage(
- // ctrl.hPostMsgDestHandle,
- // WM_MF_WIFI_TERMINATE_FAIL,
- // 0,
- // 0
- // );
- // log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " WiFi tester terminates fail "
- // );
- // }
- }
- this->OnTerminate = neSuccess;
- }
- //==============================================================================
- bool __fastcall T_META_factory_calibration::WriteInitValueToNVRAM(void)
- {
- char tempbuf[256];
- log->Add("n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " =============== Write initial value to flash begin ==============="
- );
- //== write AFC value to NVRAM !! ===========================================
- if (m_pCal->s_CalItem.b_afc_cal)
- {
- MF_rf_afc_ptr->ConfirmCallback = ::ccb_write_afc_to_nvram;
- MF_rf_afc_ptr->REQ_Write_To_NVRAM_Start();
- CHECK_TERMINATE_BY_USER
- 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"
- );
- if (CRYSTAL == m_pCal->e_AFC_type )
- {
- //== write crystal AFC value to NVRAM !! ===============================
- MF_crystal_afc_ptr->ConfirmCallback = ::ccb_write_crystal_afc_to_nvram;
- MF_crystal_afc_ptr->REQ_Write_CAPID_To_NVRAM_Start();
- CHECK_TERMINATE_BY_USER
- RestartTimerCal (WM_MF_NVRAM_CRYSTAL_AFC_CAPID_WRITE_FAIL);
- SUSPEND_CAL_THREAD
- 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 value to NVRAM fail "
- );
- }
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < Write crystal AFC CAP ID value to NVRAM"
- );
- if (!m_pCal->s_CalItem.b_tx_pcl_cal)
- {
- // AFC TRX offset
- MF_rf_apc_ptr->ConfirmCallback = ::ccb_read_apc_from_nvram;
- MF_rf_apc_ptr->REQ_Read_APC_From_NVRAM_Start(m_pCal->ui_rf_id, m_pCal->b_TADOSupport);
- RestartTimerCal( WM_MF_NVRAM_LEVEL_RAMP_READ_FAIL );
- SUSPEND_CAL_THREAD
- CHECK_TERMINATE_BY_USER
- if (MF_rf_apc_ptr->Get_ConfirmState() != METAAPP_SUCCESS)
- {
- CalErrorHandler(WM_MF_NVRAM_LEVEL_RAMP_READ_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target > read GMSK level ramp from NVRAM fail."
- );
- return false;
- }
- else
- {
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target > read GMSK level ramp from NVRAM."
- );
- }
- if (!MF_rf_apc_ptr->REQ_Read_TX_AFC_DAC_offset_From_File(frmFatcory->stIniFile->Caption.c_str()))
- return false;
- if ((CRYSTAL == m_pCal->e_AFC_type) &&
- m_pCal->s_CalItem.b_trx_offset_cal
- )
- {
- int i=0;
- for (i=0; i<MAX_SUPPORT_BAND_NUM; i++)
- {
- MF_rf_apc_ptr->Set_TxAfcOffset(i, 0);
- }
- }
- MF_rf_apc_ptr->ConfirmCallback = ::ccb_write_apc_to_nvram;
- MF_rf_apc_ptr->REQ_Write_APC_To_NVRAM_Start(m_pCal->ui_rf_id, m_pCal->b_TADOSupport);
- RestartTimerCal(WM_MF_NVRAM_LEVEL_RAMP_WRITE_FAIL);
- SUSPEND_CAL_THREAD
- CHECK_TERMINATE_BY_USER
- E_METAAPP_RESULT_T state = MF_rf_apc_ptr->Get_ConfirmState();
- if (state != METAAPP_SUCCESS)
- {
- if (METAAPP_NVRAM_LID_VER_NOT_SUPPORT == state)
- {
- CalErrorHandler(WM_MF_NVRAM_EF_L1_RAMPTABLE_xxx_LID_VERNO_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : NVRAM_EF_L1_RAMPTABLE_xxx_LID version is not support, please update META to latest version. "
- );
- }
- else
- {
- CalErrorHandler(WM_MF_NVRAM_LEVEL_RAMP_WRITE_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < write GMSK level ramp to NVRAM fail."
- );
- }
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < write GMSK level ramp to NVRAM."
- );
- }
- }
- }
- //== write path loss to NVRAM !! ============================================
- if (frmFatcory->cbRxPathLoss->Checked)
- {
- MF_rf_agc_ptr->ConfirmCallback = ::ccb_write_agc_to_nvram;
- MF_rf_agc_ptr->REQ_Write_To_NVRAM_Start();
- CHECK_TERMINATE_BY_USER
- RestartTimerCal(WM_MF_NVRAM_PATH_LOSS_WRITE_FAIL);
- SUSPEND_CAL_THREAD
- E_METAAPP_RESULT_T state = MF_rf_agc_ptr->Get_ConfirmState();
- if (state != METAAPP_SUCCESS)
- {
- if (METAAPP_NVRAM_LID_VER_NOT_SUPPORT == state)
- {
- CalErrorHandler(WM_MF_NVRAM_EF_L1_AGCPATHLOSS_LID_VERNO_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : NVRAM_EF_L1_AGCPATHLOSS_LID version is not support, please update META to latest version. "
- );
- }
- else
- {
- CalErrorHandler( WM_MF_NVRAM_PATH_LOSS_WRITE_FAIL );
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < Write path loss to NVRAM "
- );
- }
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < Write path loss to NVRAM "
- );
- }
- //======================================================================
- // write IP2 to NVRAM
- // MF_rf_pm_ptr->ConfirmCallback = ccb_write_ip2_to_nvram;
- // MF_rf_pm_ptr->REQ_Write_IP2Reg_To_NVRAM(final_rfid);
- // if ( this->Terminated )
- // {
- // this->OnTerminate = neByUser;
- // return false;
- // }
- // RestartTimerCal( WM_MF_NVRAM_IP2_WRITE_FAIL );
- // is_suspend_cal = true;
- // this->Suspend();
- // is_suspend_cal = false;
- // if (MF_rf_pm_ptr->ConfirmState != METAAPP_SUCCESS)
- // {
- // CalErrorHandler( WM_MF_NVRAM_IP2_WRITE_FAIL );
- // pt_calibration->log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " FAIL: Target < Write IP2 to NVRAM "
- // );
- // return false;
- // }
- // else
- // {
- // log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " Target < Write IP2 to NVRAM "
- // );
- // }
- //===================== write ramp table to NVRAM =========================
- if (m_pCal->s_CalItem.b_tx_pcl_cal)
- {
- if (m_pCal->s_CalItem.b_afc_cal && (CRYSTAL == m_pCal->e_AFC_type))
- {
- if (!MF_rf_apc_ptr->REQ_Read_APC_From_File(frmFatcory->stIniFile->Caption.c_str(), m_pCal->ui_rf_id, m_pCal->b_TADOSupport))
- {
- return false;
- }
- }
- if (//m_pCal->s_CalItem.b_afc_cal &&
- (CRYSTAL == m_pCal->e_AFC_type) &&
- m_pCal->s_CalItem.b_trx_offset_cal
- )
- {
- int i=0;
- for (i=0; i<MAX_SUPPORT_BAND_NUM; i++)
- {
- MF_rf_apc_ptr->Set_TxAfcOffset(i, 0);
- }
- }
- if (!m_pCal->s_CalItem.b_afc_cal)
- {
- MF_rf_apc_ptr->ConfirmCallback = ::ccb_read_apc_from_nvram;
- MF_rf_apc_ptr->REQ_Read_APC_From_NVRAM_Start(m_pCal->ui_rf_id, m_pCal->b_TADOSupport);
- RestartTimerCal(WM_MF_NVRAM_LEVEL_RAMP_READ_FAIL);
- SUSPEND_CAL_THREAD
- CHECK_TERMINATE_BY_USER
- if (MF_rf_apc_ptr->Get_ConfirmState() != METAAPP_SUCCESS)
- {
- CalErrorHandler(WM_MF_NVRAM_LEVEL_RAMP_READ_FAIL);
- log->Add(DateToStr(Date()) + " " + TimeToStr(Time()) +
- " FAIL: Target > read GMSK level ramp from NVRAM fail."
- );
- return false;
- }
- log->Add(DateToStr(Date()) + " " + TimeToStr(Time()) +
- " Target > read GMSK level ramp from NVRAM."
- );
- short tx_afc_offset[4];
- for (int i=0; i<4; i++)
- {
- tx_afc_offset[i] = MF_rf_apc_ptr->Get_TxAfcOffset(i);
- }
- if (!MF_rf_apc_ptr->REQ_Read_APC_From_File(m_pCal->as_IniFile.c_str(), m_pCal->ui_rf_id, m_pCal->b_TADOSupport))
- {
- return false;
- }
- for (int i=0; i<4; i++)
- {
- MF_rf_apc_ptr->Set_TxAfcOffset(i, tx_afc_offset[i]);
- }
- }
- if (m_pCal->i_APC_mod & APC_MOD_GMSK)
- {
- MF_rf_apc_ptr->ConfirmCallback = ::ccb_write_apc_to_nvram;
- MF_rf_apc_ptr->REQ_Write_APC_To_NVRAM_Start(m_pCal->b_TADOSupport, m_pCal->ui_rf_id);
- RestartTimerCal(WM_MF_NVRAM_LEVEL_RAMP_WRITE_FAIL);
- SUSPEND_CAL_THREAD
- CHECK_TERMINATE_BY_USER
- E_METAAPP_RESULT_T state = MF_rf_apc_ptr->Get_ConfirmState();
- if (state != METAAPP_SUCCESS)
- {
- if (METAAPP_NVRAM_LID_VER_NOT_SUPPORT == state)
- {
- CalErrorHandler(WM_MF_NVRAM_EF_L1_RAMPTABLE_xxx_LID_VERNO_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : NVRAM_EF_L1_RAMPTABLE_xxx_LID version is not support, please update META to latest version. "
- );
- }
- else
- {
- CalErrorHandler(WM_MF_NVRAM_LEVEL_RAMP_WRITE_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < write GMSK level ramp to NVRAM fail."
- );
- }
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < write GMSK level ramp to NVRAM."
- );
- }
- }
- if (m_pCal->s_CalItem.b_tx_pcl_cal &&
- ((RFMD_3159 == m_pCal->e_PA_type) || (SKY_77316 == m_pCal->e_PA_type) || (SKY_77340 == m_pCal->e_PA_type)) &&
- (APC_MOD_EPSK & m_pCal->i_APC_mod)
- )
- {
- MF_rf_apc_8psk_ptr->ConfirmCallback = ::ccb_write_apc_to_nvram;
- MF_rf_apc_8psk_ptr->REQ_Write_APC_To_NVRAM_Start(m_pCal->ui_rf_id);
- RestartTimerCal(WM_MF_NVRAM_LEVEL_RAMP_WRITE_FAIL);
- SUSPEND_CAL_THREAD
- CHECK_TERMINATE_BY_USER
- E_METAAPP_RESULT_T state = MF_rf_apc_8psk_ptr->Get_ConfirmState();
- if (state != METAAPP_SUCCESS)
- {
- if (METAAPP_NVRAM_LID_VER_NOT_SUPPORT == state)
- {
- CalErrorHandler(WM_MF_NVRAM_EF_L1_EPSK_RAMPTABLE_xxx_LID_VERNO_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : NVRAM_EF_L1_EPSK_RAMPTABLE_xxx_LID version is not support, please update META to latest version. "
- );
- }
- else
- {
- CalErrorHandler(WM_MF_NVRAM_LEVEL_RAMP_WRITE_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < write EPSK level ramp to NVRAM fail."
- );
- }
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < write EPSK level ramp to NVRAM."
- );
- }
- #if 0
- //===================== write TXIQ to NVRAM =========================
- if( frmFatcory->cbTxPhaseError->Checked )
- {
- MF_rf_txiq_ptr->ConfirmCallback = ::ccb_write_txiq_to_nvram;
- MF_rf_txiq_ptr->REQ_Write_To_NVRAM_Start();
- //log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " TimerCal->Enabled 5= " + IntToStr((int)frmFatcory->TimerCal->Enabled)
- // );
- RestartTimerCal( WM_MF_FDM_TXIQ_WRITE_FAIL );
- SUSPEND_CAL_THREAD
- CHECK_TERMINATE_BY_USER
- if (MF_rf_txiq_ptr->Get_ConfirmState() != STATE_TXIQ_OK)
- {
- CalErrorHandler( WM_MF_FDM_TXIQ_WRITE_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < write TXIQ to NVRAM fail."
- );
- return false;
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < write TXIQ to NVRAM."
- );
- }
- }
- #endif
- //====================== write ADC to NVRAM =========================
- if (m_pCal->s_CalItem.b_adc_cal)
- {
- MF_BB_ADC_ptr->ConfirmCallback = ccb_write_ADC_to_nvram;
- MF_BB_ADC_ptr->REQ_Write_To_NVRAM_Start();
- RestartTimerCal(WM_MF_NVRAM_ADC_WRITE_FAIL);
- SUSPEND_CAL_THREAD
- CHECK_TERMINATE_BY_USER
- E_METAAPP_RESULT_T state = MF_BB_ADC_ptr->Get_ConfirmState();
- if (state != METAAPP_SUCCESS)
- {
- if (METAAPP_NVRAM_LID_VER_NOT_SUPPORT == state)
- {
- CalErrorHandler(WM_MF_NVRAM_EF_ADC_LID_VERNO_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : NVRAM_EF_ADC_LID version is not support, please update META to latest version. "
- );
- }
- else
- {
- CalErrorHandler(WM_MF_NVRAM_ADC_WRITE_FAIL);
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < write ADC to NVRAM fail."
- );
- }
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < write ADC to NVRAM."
- );
- }
- #if 0
- //---------------------------------------------------------------------
- // write WiFi APC to NVRAM
- if( m_pCal->s_CalItem.wifi_tx_power_cal )
- {
- if( IsWiFiSupported( m_asWiFi_Support, WIFI_802_11B_IDX ) ||
- IsWiFiSupported( m_asWiFi_Support, WIFI_802_11G_IDX )
- )
- {
- m_pCal->cal_data.MF_wifi_apc_ptr->ConfirmCallback = ::CNF_MF_write_WiFi_APC_to_nvram;
- m_pCal->cal_data.MF_wifi_apc_ptr->REQ_Write_TxPower2400M_To_NVRAM_Start();
- RestartTimerCal( WM_MF_NVRAM_WIFI_APC_WRITE_FAIL );
- SUSPEND_CAL_THREAD
- CHECK_TERMINATE_BY_USER
- if( m_pCal->cal_data.MF_wifi_apc_ptr->Get_ConfirmState() != STATE_WIFI_APC_OK )
- {
- CalErrorHandler( WM_MF_NVRAM_WIFI_APC_WRITE_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < write WiFi 2.4G TX power to NVRAM fail."
- );
- return false;
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < write WiFi 2.4G TX power to NVRAM."
- );
- }
- }
- if( IsWiFiSupported( m_asWiFi_Support, WIFI_802_11A_IDX ) )
- {
- m_pCal->cal_data.MF_wifi_apc_ptr->ConfirmCallback = ::CNF_MF_write_WiFi_APC_to_nvram;
- m_pCal->cal_data.MF_wifi_apc_ptr->REQ_Write_TxPower5000M_To_NVRAM_Start();
- RestartTimerCal( WM_MF_NVRAM_WIFI_APC_WRITE_FAIL );
- SUSPEND_CAL_THREAD
- CHECK_TERMINATE_BY_USER
- if( m_pCal->cal_data.MF_wifi_apc_ptr->Get_ConfirmState() != STATE_WIFI_APC_OK )
- {
- CalErrorHandler( WM_MF_NVRAM_WIFI_APC_WRITE_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < write WiFi 5G TX power to NVRAM fail."
- );
- return false;
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < write WiFi 5G TX power to NVRAM."
- );
- }
- }
- }
- #endif
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " ================ Write initial value to flash end ================ n "
- );
- //== write initail value to flash end =======================================
- return true;
- }
- //******************************************************************************
- // IP2 calibration
- //******************************************************************************
- bool __fastcall T_META_factory_calibration::IP2Cal(void)
- {
- switch (m_pCal->ui_rf_id)
- {
- case RF_ID_SKY74045:
- {
- if (!IP2Cal_sky74045_cal())
- {
- return false;
- }
- if (!IP2Cal_sky74045_check())
- {
- return false;
- }
- }
- break;
- case RF_ID_SKY74117:
- case RF_ID_SKY74400:
- {
- if (!IP2Cal_sky74117_cal())
- {
- return false;
- }
- if (!IP2Cal_sky74117_check())
- {
- return false;
- }
- }
- break;
- // case RF_ID_MT6139B:
- // {
- // if( ! IP2Cal_mt6139b_cal() ) return false;
- // if( ! IP2Cal_mt6139_check() ) return false;
- // }
- // break;
- // case RF_ID_MT6139C:
- // case RF_ID_MT6139E:
- // case RF_ID_MT6140A:
- // case RF_ID_MT6140B:
- // {
- // if( ! IP2Cal_mt6139c_cal() ) return false;
- // if( ! IP2Cal_mt6139_check() ) return false;
- // }
- // break;
- }
- return true;
- }
- //***********************************************************************************
- // TX level calibration
- //***********************************************************************************
- bool __fastcall T_META_factory_calibration::TXPCLCal(void)
- {
- PostMessage(
- ctrl.hPostMsgDestHandle,
- WM_MF_RF_TX_LEVEL_BEGIN,
- 0,
- 0
- );
- Read_TXPCL_CFG();
- if (((SKY_77316 == m_pCal->e_PA_type) || (SKY_77340 == m_pCal->e_PA_type) || (RFMD_3159 == m_pCal->e_PA_type)) &&
- (m_pCal->i_APC_mod & APC_MOD_EPSK)
- )
- {
- Read_EPSK_TXPCL_CFG();
- }
- switch (m_pCal->e_PA_type)
- {
- case RFMD_3140: // RFMD 3140
- {
- if (THREE_PCL == m_pCal->e_GMSK_APC_type)
- {
- if (!TXPCLCal_3cal())
- {
- return false;
- }
- if (!TXPCLCal_RFMD3140_3PCLEvalDac())
- {
- return false;
- }
- }
- else if (FULL_PCL == m_pCal->e_GMSK_APC_type)
- {
- if (!TXPCLCal_FullCal())
- {
- return false;
- }
- }
- }
- break;
- case RFMD_3159:
- case SKY_77340:
- {
- if (m_pCal->i_APC_mod & APC_MOD_GMSK)
- {
- if (THREE_PCL == m_pCal->e_GMSK_APC_type)
- {
- if (! TXPCLCal_3cal())
- {
- return false;
- }
- if (!TXPCLCal_RFMD3140_3PCLEvalDac())
- {
- return false;
- }
- }
- else if (FULL_PCL == m_pCal->e_GMSK_APC_type)
- {
- if (!TXPCLCal_FullCal())
- {
- return false;
- }
- }
- }
- if (m_pCal->i_APC_mod & APC_MOD_EPSK)
- {
- if (RF_ID_A60111A == m_pCal->ui_rf_id)
- {
- if (!m_RF_A60111A_REG_Obj.Enter_Factory_Cal())
- {
- CalErrorHandler(WM_MF_RF_A60111A_ENTER_FACTORY_MODE_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target < A60111A enter test mode "
- );
- return false;
- }
- }
- switch (m_pCal->e_EPSK_APC_type)
- {
- case ONE_PCL:
- {
- if (!TXPCLCal_EPSK_1cal())
- {
- return false;
- }
- if (!TXPCLCal_EvalDac_A60111A_EPSK())
- {
- return false;
- }
- }
- break;
- case FOUR_PCL:
- {
- if (!TXPCLCal_EPSK_4cal())
- {
- return false;
- }
- if (!TXPCLCal_EvalDac_RFMD3159_FixedPaBias())
- {
- return false;
- }
- }
- break;
- case FULL_PCL:
- {
- if (RF_ID_A60111A == m_pCal->ui_rf_id)
- {
- if (!TXPCLCal_EPSK_FullCal_A60111A())
- {
- return false;
- }
- }
- else
- {
- if (!TXPCLCal_EPSK_FullCal())
- {
- return false;
- }
- }
- }
- break;
- }
- if (RF_ID_A60111A == m_pCal->ui_rf_id)
- {
- if (!m_RF_A60111A_REG_Obj.Read_CW26())
- {
- CalErrorHandler(WM_MF_RF_A60111A_READ_REF_TEMP_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target > read ref_temp from register "
- );
- return false;
- }
- m_RF_A60111A_REG_Obj.ConfirmCallback = ::CNF_MF;
- m_RF_A60111A_REG_Obj.REQ_Write_To_NVRAM_Start();
- RestartTimerCal(WM_MF_NVRAM_REF_TEMP_WRITE_FAIL);
- SUSPEND_CAL_THREAD
- CHECK_TERMINATE_BY_USER
- if (m_RF_A60111A_REG_Obj.Get_ConfirmState() != METAAPP_SUCCESS)
- {
- CalErrorHandler(WM_MF_NVRAM_REF_TEMP_WRITE_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < write ref_temp to NVRAM fail."
- );
- return false;
- }
- unsigned char us_reftemp = m_RF_A60111A_REG_Obj.Get_RefTemp();
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < write ref_temp = " + IntToStr(us_reftemp) + " to NVRAM"
- );
- }
- }
- }
- break;
- case SKY_77328:
- case SKY_77506:
- {
- if (TWO_PCL == m_pCal->e_GMSK_APC_type)
- {
- if (!TXPCLCal_CalApcDcOffset_Skyworks77328())
- {
- return false;
- }
- if (!TXPCLCal_2cal())
- {
- return false;
- }
- if (!TXPCLCal_EvalDac_Skyworks77328())
- {
- return false;
- }
- }
- else if (FULL_PCL == m_pCal->e_GMSK_APC_type)
- {
- if (!TXPCLCal_CalApcDcOffset_Skyworks77328())
- {
- return false;
- }
- if (!TXPCLCal_FullCal())
- {
- return false;
- }
- }
- }
- break;
- case SKY_77316:
- {
- if (m_pCal->i_APC_mod & APC_MOD_GMSK)
- {
- if (TWO_PCL == m_pCal->e_GMSK_APC_type)
- {
- if (!TXPCLCal_2cal())
- {
- return false;
- }
- if (!TXPCLCal_EvalDac_Skyworks77316_GMSK())
- {
- return false;
- }
- }
- else if (FULL_PCL == m_pCal->e_GMSK_APC_type)
- {
- if (!TXPCLCal_FullCal())
- {
- return false;
- }
- }
- }
- if (m_pCal->i_APC_mod & APC_MOD_EPSK)
- {
- if (TWO_PCL == m_pCal->e_EPSK_APC_type)
- {
- if (!TXPCLCal_EPSK_2cal())
- {
- return false;
- }
- if (!TXPCLCal_EvalDac_Skyworks77316_EPSK())
- {
- return false;
- }
- }
- else if (FULL_PCL == m_pCal->e_EPSK_APC_type)
- {
- if (!TXPCLCal_EPSK_FullCal())
- {
- return false;
- }
- }
- }
- }
- break;
- case RENESAS_PF08155B:
- {
- if (THREE_PCL == m_pCal->e_GMSK_APC_type)
- {
- if (!TXPCLCal_3cal())
- {
- return false;
- }
- if (!TXPCLCal_EvalDac_RenesasPF08155B())
- {
- return false;
- }
- }
- else if (FULL_PCL == m_pCal->e_GMSK_APC_type)
- {
- if (!TXPCLCal_FullCal())
- {
- return false;
- }
- }
- }
- break;
- // case RENESAS_PF09016B:
- // {
- // if( THREE_PCL == m_pCal->e_AFC_type )
- // {
- // if( ! TXPCLCal_3cal() )
- // {
- // return false;
- // }
- // if(! TXPCLCal_EvalDac_RenesasPF09016B() )
- // {
- // return false;
- // }
- // }
- // }
- // break;
- case AXIOM_AX502:
- {
- if (SIX_DAC == m_pCal->e_GMSK_APC_type)
- {
- if (!TXPCLCal_6cal_DAC())
- {
- return false;
- }
- if (!TXPCLCal_Axiom502_3PCLEvalDac())
- {
- return false;
- }
- }
- else if (FULL_PCL == m_pCal->e_GMSK_APC_type)
- {
- if (!TXPCLCal_FullCal())
- {
- return false;
- }
- }
- }
- break;
- case TRIQUINT_TQM6M5001:
- {
- if (THREE_PCL == m_pCal->e_GMSK_APC_type)
- {
- if (!TXPCLCal_3cal())
- {
- return false;
- }
- if (!TXPCLCal_RFMD3140_3PCLEvalDac())
- {
- return false;
- }
- }
- else if (FULL_PCL == m_pCal->e_GMSK_APC_type)
- {
- if (!TXPCLCal_FullCal())
- {
- return false;
- }
- }
- if (m_pCal->i_APC_mod & APC_MOD_EPSK)
- {
- if (TWO_PCL == m_pCal->e_EPSK_APC_type)
- {
- if (!TXPCLCal_EPSK_2cal())
- {
- return false;
- }
- if (!TXPCLCal_EvalDac_Skyworks77316_EPSK())
- {
- return false;
- }
- }
- else if (FULL_PCL == m_pCal->e_EPSK_APC_type)
- {
- if (!TXPCLCal_EPSK_FullCal())
- {
- return false;
- }
- }
- }
- }
- break;
- } // switch()
- if (m_asAPC_Check.AnsiCompareIC("yes") == 0)
- {
- if ((SKY_77316 != m_pCal->e_PA_type) &&
- (SKY_77340 != m_pCal->e_PA_type) &&
- (RFMD_3159 != m_pCal->e_PA_type)
- )
- {
- if (!TXPCLCal_check())
- {
- return false;
- }
- PostMessage(
- ctrl.hPostMsgDestHandle,
- WM_MF_RF_TX_LEVEL_CALIBRATION_DONE,
- 0,
- 0
- );
- log->Add( "n" + DateToStr(Date()) + " "+ CurrentTimeStr() +
- " TX PCL calibration done! n"
- );
- }
- else // skyworks 77316
- {
- bool gmsk_check_result = true;
- bool epsk_check_result = true;
- if (m_pCal->i_APC_mod & APC_MOD_GMSK)
- {
- gmsk_check_result = TXPCLCal_check();
- if (!gmsk_check_result)
- {
- return false;
- }
- }
- if (m_pCal->i_APC_mod & APC_MOD_EPSK)
- {
- epsk_check_result = TXPCLCal_EPSK_check();
- if (!epsk_check_result)
- {
- return false;
- }
- }
- PostMessage(
- ctrl.hPostMsgDestHandle,
- WM_MF_RF_TX_LEVEL_CALIBRATION_DONE,
- 0,
- 0
- );
- log->Add( "n" + DateToStr(Date()) + " "+ CurrentTimeStr() +
- " TX PCL calibration done! n"
- );
- }
- }
- return true;
- }
- ////////////////////////////////// end of TX level calibration /////////////////////////////////////
- //=========================================================================================
- __fastcall T_META_factory_calibration::~T_META_factory_calibration( void )
- {
- }
- //------------------------------------------------------------------------------
- bool __fastcall T_META_factory_calibration::RestartTimerADCCal( int TimeoutID )
- {
- TimerADCCalTimeoutID = TimeoutID;
- frmFatcory->TimerADCCal->Interval = ADC_TimeoutInterval;
- frmFatcory->TimerADCCal->Enabled = false;
- frmFatcory->TimerADCCal->Enabled = true;
- return true;
- }
- //------------------------------------------------------------------------------
- bool __fastcall T_META_factory_calibration::RestartTimerCal( int TimeoutID )
- {
- TimerCalTimeoutID = TimeoutID;
- frmFatcory->TimerCal->Interval = TimeoutInterval;
- frmFatcory->TimerCal->Enabled = false;
- frmFatcory->TimerCal->Enabled = true;
- return true;
- }
- //==============================================================================
- void T_META_factory_calibration::PostErrorMsg( ErrorMsg error_msg )
- {
- PostMessage(
- ctrl.hPostMsgDestHandle,
- error_msg,
- 0,
- 0
- );
- }
- //------------------------------------------------------------------------------
- //==============================================================================
- void T_META_factory_calibration::CalErrorHandler( ErrorMsg error_msg )
- {
- frmFatcory->DisableAllCalTimer();
- PostMessage(
- ctrl.hPostMsgDestHandle,
- error_msg,
- 0,
- 0
- );
- }