T_TxIq_EPSK.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:69k
- /*****************************************************************************
- * 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) 2001
- *
- *****************************************************************************/
- /*****************************************************************************
- *
- * Filename:
- * ---------
- * T_TxIq_EPSK.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * EPSK TX IQ 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_TXIQ_COMMON_H_
- #include "T_TxIq_common.h"
- #endif
- #ifndef _CAL_COMMON_H_
- #include "cal_common.h"
- #endif
- // misc
- #ifndef _FT_UTILS_H_
- #include "ft_utils.h"
- #endif
- #ifndef _BAND_UTILS_H_
- #include "band_utils.h"
- #endif
- #ifndef _MATH_UTILS_H_
- #include "math_utils.h"
- #endif
- #ifndef _AGE_MISC_H_
- #include "age_misc.h"
- #endif
- #ifndef _GSM_UTILS_H_
- #include "gsm_utils.h"
- #endif
- #ifndef _TIME_UTILS_H_
- #include "time_utils.h"
- #endif
- // equipment
- #ifndef _AGECOMMON_H_
- #include "agecommon.h"
- #endif
- #ifndef _AGE1968A_H_
- #include "age1968a.h"
- #endif
- // TX phase error calibration
- #ifndef _RF_OFFSET_IQ_SWEEP_INIT_AGE8960_H_
- #include "rf_offset_iq_sweep_init_age8960.h"
- #endif
- #ifndef _RF_TXIQ_H_
- #include "rf_txiq.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
- //----------------------------------------------------------------------------
- // phase error
- extern RfNbtx_Req *MF_rf_tx_level_req;
- extern CRFTXIQ* MF_rf_txiq_ptr;
- // 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::TXIqCal_EPSK( void )
- {
- ViReal64 d_OOS[4];
- ViReal64 d_POOS[4];
- ViReal64 d_SBS[4];
- ViReal64 d_PSBS[4];
- ViReal64 d_OOS_min = 10000;
- //ViReal64 d_SBS_min = 10000;
- //S_IQ s_trim_sbs_min;
- S_IQ s_offset_oos_min;
- //RfBBTXCfg2 rf_bb_tx_cfg_req;
- RfBBTXCfg4 rf_bb_tx_cfg_req;
- BBTXParameters_T l1cal_txiq;
- S_TXIQ_RESULT s_iq_result_low;
- S_TXIQ_RESULT s_iq_result_high;
- S_IQ OffsetIQ[] =
- {
- { 0, 0},
- { 0, 30},
- { 30, -30},
- {-30, -30}
- };
- S_IQ TrimIQ[] =
- {
- { 0, 0},
- { 7, -7},
- { -7, 7},
- { 0, 0}
- };
- char c_TxPhasesel[] =
- {
- 0,
- 0,
- 0,
- 3
- };
- PostMessage(ctrl.hPostMsgDestHandle,
- WM_MF_RF_TX_IQ_BEGIN,
- 0,
- 0
- );
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " ================ TX IQ calibration begin ================== "
- );
- if (!m_rct_ctrl.RCT_operatingMode(m_pRct, OPERATING_MODE_EGPRS_BCH_PDTCH))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_OPERATION_MODE_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- m_pRct->as_RCT + " < Operation mode = EGPRS BCH+PDTCH"
- );
- return false;
- }
- m_viTX_IQ_BAND = Get_AgeBand(m_asTX_IQ_BAND);
- E_BANDSEL band_index = AgeBand_To_BandIdx(m_viTX_IQ_BAND);
- if (!m_rct_ctrl.RCT_cellBand(m_pRct, m_viTX_IQ_BAND))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_BAND_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : "+
- m_pRct->as_RCT + " < Band = " + ViBand_To_Str(m_viTX_IQ_BAND)
- );
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < Band = "+
- ViBand_To_Str(m_viTX_IQ_BAND)
- );
- short bch_arfcn = ::Get_SeperateChannel(m_viTX_IQ_BAND, m_sTX_IQ_ARFCN);
- if (!m_rct_ctrl.RCT_BCHARFCN(m_pRct, bch_arfcn))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_TCH_ARFCN_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- m_pRct->as_RCT + " < BCH ARFCN = " + IntToStr(bch_arfcn)
- );
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < BCH ARFCN = " + IntToStr(bch_arfcn)
- );
- if (!m_rct_ctrl.RCT_PDTCHARFCN(m_pRct, m_sTX_IQ_ARFCN))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_PDTCH_ARFCN_FAIL);
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : "+
- m_pRct->as_RCT + " < PDTCH ARFCN = " + IntToStr(m_sTX_IQ_ARFCN)
- );
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < PDTCH ARFCN = " + IntToStr( m_sTX_IQ_ARFCN )
- );
- if (!m_rct_ctrl.RCT_PDTCHMSTxLevel(m_pRct, m_sTX_IQ_PCL))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_MS_TX_LEVEL_FAIL);
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " + m_pRct->as_RCT + " < MS TX level = " + IntToStr(m_sTX_IQ_PCL)
- );
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < MS TX level = " + IntToStr(m_sTX_IQ_PCL)
- );
- 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;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < TSC = " + IntToStr( m_cTSC)
- );
- if (!m_rct_ctrl.RCT_Config_EPSK_CodingScheme(m_pRct, MCS5))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_CODING_SCHEME_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " +
- m_pRct->as_RCT + " < Coding scheme = MCS5"
- );
- return false;
- }
- if( ! m_rct_ctrl.RCT_Config_EPSK_ModACcuracy(m_pRct, m_uiTX_IQ_MEASUREMENT_COUNT, age1960_TRIG_AUTO, 0, 5) )
- {
- CalErrorHandler( WM_MF_AGE8960_CONFIG_EPSK_MOD_ACCURACY_FAIL );
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- "FAIL : " + m_pRct->as_RCT + " < config EPSK modulation accurary fail."
- );
- return false;
- }
- // read BB TX parameter from NVRAM
- m_cTXIQ_RUN_Obj.ConfirmCallback = ::CNF_MF;
- m_cTXIQ_RUN_Obj.REQ_GetBBTxCfg_Start(m_pCal->e_bbtxcfg_ver);
- RestartTimerCal(WM_MF_RF_GET_BB_TX_CFG_FAIL);
- SUSPEND_CAL_THREAD
- if (m_cTXIQ_RUN_Obj.Get_ConfirmState() != METAAPP_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_GET_BB_TX_CFG_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target > RF get BB TX CFG fail."
- );
- return false;
- }
- RfBBTXCfg4* p_bbtx_cfg = m_cTXIQ_RUN_Obj.Get_BbTxCfg();
- rf_bb_tx_cfg_req = *p_bbtx_cfg;
- // read TXIQ from NVRAM
- MF_rf_txiq_ptr->ConfirmCallback = ::ccb_read_txiq_from_nvram;
- MF_rf_txiq_ptr->REQ_Read_From_NVRAM_Start(m_pCal->ui_rf_id, m_pCal->e_bbtxcfg_ver);
- RestartTimerCal(WM_MF_NVRAM_TXIQ_READ_FAIL);
- SUSPEND_CAL_THREAD
- if (MF_rf_txiq_ptr->Get_ConfirmState() != METAAPP_SUCCESS)
- {
- CalErrorHandler(WM_MF_NVRAM_TXIQ_READ_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target > Read txiq value from NVRAM fail "
- );
- return false;
- }
- BBTXParameters_T* p_txiq = MF_rf_txiq_ptr->Get_BBTXParameters();
- l1cal_txiq = *p_txiq;
- l1cal_txiq.bbtx_gain = rf_bb_tx_cfg_req.TxGain;
- l1cal_txiq.bbtx_calrcsel = rf_bb_tx_cfg_req.TxCalrcsel; // new
- l1cal_txiq.bbtx_common_mode_voltage = rf_bb_tx_cfg_req.TxCMV; // new
- // high band
- l1cal_txiq.bbtx_gain_h = rf_bb_tx_cfg_req.TxGain;
- l1cal_txiq.bbtx_calrcsel_h = rf_bb_tx_cfg_req.TxCalrcsel; // new
- l1cal_txiq.bbtx_common_mode_voltage_h = rf_bb_tx_cfg_req.TxCMV; // new
- for (int i=0; i<4; i++)
- {
- rf_bb_tx_cfg_req.TxTrimI = TrimIQ[i].I;
- rf_bb_tx_cfg_req.TxTrimQ = TrimIQ[i].Q;
- rf_bb_tx_cfg_req.TxOffsetI = OffsetIQ[i].I;
- rf_bb_tx_cfg_req.TxOffsetQ = OffsetIQ[i].Q;
- rf_bb_tx_cfg_req.TxPhasesel = c_TxPhasesel[i];
- m_cTXIQ_RUN_Obj.ConfirmCallback = ::CNF_MF;
- m_cTXIQ_RUN_Obj.REQ_SetBBTxCfg_Start(m_pCal->e_bbtxcfg_ver, rf_bb_tx_cfg_req);
- RestartTimerCal(WM_MF_RF_SET_BB_TX_CFG_FAIL);
- SUSPEND_CAL_THREAD
- if (m_cTXIQ_RUN_Obj.Get_ConfirmState() != METAAPP_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_SET_BB_TX_CFG_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < RF set BB TX CFG fail."
- );
- return false;
- }
- CHECK_TERMINATE_BY_USER
- STOP_RF
- Sleep(50);
- int pcl[4];
- CodingScheme cs[4];
- APCTxPattern pattern;
- cs[0] = CodingSchemeMCS5;
- cs[1] = CodingSchemeMCS5;
- cs[2] = CodingSchemeMCS5;
- cs[3] = CodingSchemeMCS5;
- pcl[0] = m_sTX_IQ_PCL;
- pcl[1] = m_sTX_IQ_PCL;
- pcl[2] = m_sTX_IQ_PCL;
- pcl[3] = m_sTX_IQ_PCL;
- pattern = NB_TX_RANDOM_WITH_TSC;
- S_MULTI_SLOT_TX_T multi_slot_tx;
- multi_slot_tx.b_MultiSlotTXExSupport = m_pCal->b_MultiSlotTxExSupport;
- multi_slot_tx.e_bandsel = band_index;
- multi_slot_tx.req.arfcn = m_sTX_IQ_ARFCN;
- multi_slot_tx.req.bsic = m_cTSC;
- multi_slot_tx.req.timeSlotmask = 0x01;
- for (int i=0; i<4; i++)
- {
- multi_slot_tx.req.powerLev[i] = pcl[i];
- multi_slot_tx.req.cs[i] = cs[i];
- }
- multi_slot_tx.req.ta = 0;
- multi_slot_tx.req.frames = -99;
- multi_slot_tx.req.dacValue = m_sDefault_value;
- multi_slot_tx.req.pattern = pattern;
- multi_slot_tx.req.pattern_data = 0;
- RF_MULTI_SLOT_TX_Obj.ConfirmCallback = ::ConfirmCallback_MultiSlotTX;
- RF_MULTI_SLOT_TX_Obj.REQ_Start(multi_slot_tx);
- SUSPEND_CAL_THREAD
- if (RF_MULTI_SLOT_TX_Obj.Get_ConfirmState() != METAAPP_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_TX_LEVEL_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < multislot TX fail."
- );
- return false;
- }
- // TX original offset & iq imbalance
- if (!m_rct_ctrl.RCT_Fetch_EPSK_Average_TxIq(m_pRct, &d_SBS[i], &d_OOS[i]))
- {
- CalErrorHandler(WM_MF_AGE8960_FETCH_EPSK_OOS_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " + m_pRct->as_RCT + " > fetch EPSK original offset and IQ imbalance fail."
- );
- return false;
- }
- d_PSBS[i] = exp(d_SBS[i]/10.0*logl(10.0));
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " TrimI = " + IntToStr( TrimIQ[i].I ) +
- ", TrimQ = " + IntToStr( TrimIQ[i].Q ) +
- ", SBS = " + Double_To_AnsiString( d_SBS[i] ) +
- ", PSBS = " + Double_To_AnsiString( d_PSBS[i] )
- );
- // if (d_SBS_min > d_SBS[i])
- // {
- // d_SBS_min = d_SBS[i];
- // s_trim_sbs_min.I = rf_bb_tx_cfg_req.TxTrimI;
- // s_trim_sbs_min.Q = rf_bb_tx_cfg_req.TxTrimQ;
- // log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- // " TrimI = " + IntToStr(s_trim_sbs_min.I) +
- // ", TrimQ = " + IntToStr(s_trim_sbs_min.Q) +
- // ", min SBS = " + Double_To_AnsiString(d_SBS_min)
- // );
- // }
- if (NAN == d_OOS[i])
- {
- CalErrorHandler(WM_MF_RF_TX_IQ_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Get TX original offset fail."
- );
- return false;
- }
- d_POOS[i] = exp(d_OOS[i]/10.0*logl(10.0));
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " OffsetI = " + IntToStr( OffsetIQ[i].I ) +
- ", OffsetQ = " + IntToStr( OffsetIQ[i].Q ) +
- ", OOS = " + Double_To_AnsiString( d_OOS[i] ) +
- ", POOS = " + Double_To_AnsiString( d_POOS[i] )
- );
- if (d_OOS_min > d_OOS[i])
- {
- d_OOS_min = d_OOS[i];
- s_offset_oos_min.I = rf_bb_tx_cfg_req.TxOffsetI;
- s_offset_oos_min.Q = rf_bb_tx_cfg_req.TxOffsetQ;
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " OffsetI = " + IntToStr(s_offset_oos_min.I) +
- ", OffsetQ = " + IntToStr(s_offset_oos_min.Q) +
- ", min OOS = " + Double_To_AnsiString(d_OOS_min)
- );
- }
- Sleep(50);
- STOP_RF
- }
- S_IQ offset_IQt;
- S_IQ trim_IQt;
- char c_TxPhasesel_eval;
- // TX IQ gain imbalance
- ViReal64 Xt;
- Xt = 14*(d_PSBS[2]-d_PSBS[1]) / (2*(d_PSBS[2]+d_PSBS[1]-2*d_PSBS[0]));
- float fdata = Xt/2.0;
- fdata += (fdata>=0) ? 0.5 : -0.5 ;
- trim_IQt.I = fdata;
- fdata = -1.0*(Xt - trim_IQt.I);
- fdata += (fdata>=0) ? 0.5 : -0.5 ;
- trim_IQt.Q = fdata;
- if (trim_IQt.I > MAX_TRIM_IQ)
- {
- trim_IQt.I = MAX_TRIM_IQ;
- }
- else if (trim_IQt.I < MIN_TRIM_IQ)
- {
- trim_IQt.I = MIN_TRIM_IQ;
- }
- if (trim_IQt.Q > MAX_TRIM_IQ)
- {
- trim_IQt.Q = MAX_TRIM_IQ;
- }
- else if (trim_IQt.Q < MIN_TRIM_IQ)
- {
- trim_IQt.Q = MIN_TRIM_IQ;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " Evaluate Xt = " + Double_To_AnsiString(Xt) +
- ", TrimI = " + IntToStr(trim_IQt.I) +
- ", TrimQ = " + IntToStr(trim_IQt.Q)
- );
- // TX DC offset
- fdata = 30*3*(d_POOS[3]-d_POOS[2]) / (2*(d_POOS[3]+d_POOS[2]+2*d_POOS[1]-4*d_POOS[0]));
- fdata += (fdata>=0) ? 0.5 : -0.5 ;
- offset_IQt.I = (int) fdata;
- fdata= 30*(d_POOS[3]+d_POOS[2]-4*d_POOS[1]+2*d_POOS[0]) / (2*(d_POOS[3]+d_POOS[2]+2*d_POOS[1]-4*d_POOS[0]));
- fdata += (fdata>=0) ? 0.5 : -0.5 ;
- offset_IQt.Q = (int) fdata;
- char MAX_OFFSET_IQ;
- char MIN_OFFSET_IQ;
- if (m_pCal->e_bbtxcfg_ver < BBTXCFG_VER4)
- {
- MIN_OFFSET_IQ = MIN_OFFSET_IQ_OLD;
- MAX_OFFSET_IQ = MAX_OFFSET_IQ_OLD;
- }
- else
- {
- MIN_OFFSET_IQ = MIN_OFFSET_IQ_NEW;
- MAX_OFFSET_IQ = MAX_OFFSET_IQ_NEW;
- }
- if (offset_IQt.I > MAX_OFFSET_IQ)
- {
- offset_IQt.I = MAX_OFFSET_IQ;
- }
- else if (offset_IQt.I < MIN_OFFSET_IQ)
- {
- offset_IQt.I = MIN_OFFSET_IQ;
- }
- if (offset_IQt.Q > MAX_OFFSET_IQ)
- {
- offset_IQt.Q = MAX_OFFSET_IQ;
- }
- else if (offset_IQt.Q < MIN_OFFSET_IQ)
- {
- offset_IQt.Q = MIN_OFFSET_IQ;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " Evaluate OffsetI = " + IntToStr( offset_IQt.I ) +
- ", OffsetQ = " + IntToStr( offset_IQt.Q )
- );
- // Evaluate phasesel
- double d_norm_phasesel = c_TxPhasesel[3] * 6.28 / 360.0;
- fdata = ((pow(d_norm_phasesel, 2) + 4 * d_PSBS[0] - 4 * d_PSBS[3]) / (2 * d_norm_phasesel)) / 6.28 * 360.0;
- fdata += (fdata>=0) ? 0.5 : -0.5 ;
- c_TxPhasesel_eval = (char) fdata;
- char c_max_phasesel;
- char c_min_phasesel;
- if (m_pCal->e_bbtxcfg_ver <= BBTXCFG_VER4)
- {
- c_min_phasesel = MIN_PHASESEL_OLD;
- c_max_phasesel = MAX_PHASESEL_OLD;
- }
- else
- {
- c_min_phasesel = MIN_PHASESEL_NEW;
- c_max_phasesel = MAX_PHASESEL_NEW;
- }
- if (c_TxPhasesel_eval > c_max_phasesel)
- {
- c_TxPhasesel_eval = c_max_phasesel;
- }
- else if (c_TxPhasesel_eval < c_min_phasesel)
- {
- c_TxPhasesel_eval = c_min_phasesel;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " Evaluate Phasesel = " + IntToStr(c_TxPhasesel_eval)
- );
- l1cal_txiq.bbtx_trimI = trim_IQt.I;
- l1cal_txiq.bbtx_trimQ = trim_IQt.Q;
- l1cal_txiq.bbtx_offsetI = offset_IQt.I;
- l1cal_txiq.bbtx_offsetQ = offset_IQt.Q;
- l1cal_txiq.bbtx_phsel = c_TxPhasesel_eval;
- S_TXIQ txiq_low;
- txiq_low.offset_IQ = offset_IQt;
- txiq_low.trim_IQ = trim_IQt;
- txiq_low.c_TxPhasesel = c_TxPhasesel_eval;
- if (!TXIqCheck_EPSK(true, 1, txiq_low, s_iq_result_low))
- {
- return false;
- }
- if (s_iq_result_low.b_oos_out_of_range)
- {
- OffsetIQ[0].I = offset_IQt.I;
- OffsetIQ[0].Q = offset_IQt.Q;
- OffsetIQ[1].I = offset_IQt.I;
- OffsetIQ[1].Q = offset_IQt.Q + 5;
- OffsetIQ[2].I = offset_IQt.I + 5;
- OffsetIQ[2].Q = offset_IQt.Q - 5;
- OffsetIQ[3].I = offset_IQt.I - 5;
- OffsetIQ[3].Q = offset_IQt.Q - 5;
- for (int i=0; i<4; i++)
- {
- if (OffsetIQ[i].I > MAX_OFFSET_IQ)
- {
- OffsetIQ[i].I = MAX_OFFSET_IQ;
- }
- else if(OffsetIQ[i].I < MIN_OFFSET_IQ)
- {
- OffsetIQ[i].I = MIN_OFFSET_IQ;
- }
- if (OffsetIQ[i].Q > MAX_OFFSET_IQ)
- {
- OffsetIQ[i].Q = MAX_OFFSET_IQ;
- }
- else if(OffsetIQ[i].Q < MIN_OFFSET_IQ)
- {
- OffsetIQ[i].Q = MIN_OFFSET_IQ;
- }
- }
- for (int i=0; i<4; i++)
- {
- rf_bb_tx_cfg_req.TxOffsetI = OffsetIQ[i].I;
- rf_bb_tx_cfg_req.TxOffsetQ = OffsetIQ[i].Q;
- m_cTXIQ_RUN_Obj.ConfirmCallback = ::CNF_MF;
- m_cTXIQ_RUN_Obj.REQ_SetBBTxCfg_Start(m_pCal->e_bbtxcfg_ver, rf_bb_tx_cfg_req);
- RestartTimerCal(WM_MF_RF_SET_BB_TX_CFG_FAIL);
- SUSPEND_CAL_THREAD
- if (m_cTXIQ_RUN_Obj.Get_ConfirmState() != METAAPP_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_SET_BB_TX_CFG_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < RF set BB TX CFG fail."
- );
- return false;
- }
- CHECK_TERMINATE_BY_USER
- STOP_RF
- Sleep(50);
- int pcl[4];
- CodingScheme cs[4];
- APCTxPattern pattern;
- cs[0] = CodingSchemeMCS5;
- cs[1] = CodingSchemeMCS5;
- cs[2] = CodingSchemeMCS5;
- cs[3] = CodingSchemeMCS5;
- pcl[0] = m_sTX_IQ_PCL;
- pcl[1] = m_sTX_IQ_PCL;
- pcl[2] = m_sTX_IQ_PCL;
- pcl[3] = m_sTX_IQ_PCL;
- pattern = NB_TX_RANDOM_WITH_TSC;
- S_MULTI_SLOT_TX_T multi_slot_tx;
- multi_slot_tx.b_MultiSlotTXExSupport = m_pCal->b_MultiSlotTxExSupport;
- multi_slot_tx.e_bandsel = band_index;
- multi_slot_tx.req.arfcn = m_sTX_IQ_ARFCN;
- multi_slot_tx.req.bsic = m_cTSC;
- multi_slot_tx.req.timeSlotmask = 0x01;
- for (int i=0; i<4; i++)
- {
- multi_slot_tx.req.powerLev[i] = pcl[i];
- multi_slot_tx.req.cs[i] = cs[i];
- }
- multi_slot_tx.req.ta = 0;
- multi_slot_tx.req.frames = -99;
- multi_slot_tx.req.dacValue = m_sDefault_value;
- multi_slot_tx.req.pattern = pattern;
- multi_slot_tx.req.pattern_data = 0;
- RF_MULTI_SLOT_TX_Obj.ConfirmCallback = ::ConfirmCallback_MultiSlotTX;
- RF_MULTI_SLOT_TX_Obj.REQ_Start(multi_slot_tx);
- SUSPEND_CAL_THREAD
- if (RF_MULTI_SLOT_TX_Obj.Get_ConfirmState() != METAAPP_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_TX_LEVEL_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < multislot TX fail."
- );
- return false;
- }
- // TX DC offset & IQ imbalance
- if (!m_rct_ctrl.RCT_Fetch_EPSK_Average_OrignalOffset( m_pRct, &d_OOS[i]))
- {
- CalErrorHandler(WM_MF_AGE8960_FETCH_EPSK_OOS_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " + m_pRct->as_RCT + " > fetch EPSK original offset fail."
- );
- return false;
- }
- if (NAN == d_OOS[i])
- {
- CalErrorHandler(WM_MF_RF_TX_IQ_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Get TX original offset fail."
- );
- return false;
- }
- d_POOS[i] = exp(d_OOS[i]/10.0*logl(10.0));
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " OffsetI = " + IntToStr( OffsetIQ[i].I ) +
- ", OffsetQ = " + IntToStr( OffsetIQ[i].Q ) +
- ", OOS = " + Double_To_AnsiString( d_OOS[i] ) +
- ", POOS = " + Double_To_AnsiString( d_POOS[i] )
- );
- if (d_OOS_min > d_OOS[i])
- {
- d_OOS_min = d_OOS[i];
- s_offset_oos_min.I = rf_bb_tx_cfg_req.TxOffsetI;
- s_offset_oos_min.Q = rf_bb_tx_cfg_req.TxOffsetQ;
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " OffsetI = " + IntToStr(s_offset_oos_min.I) +
- ", OffsetQ = " + IntToStr(s_offset_oos_min.Q) +
- ", min OOS = " + Double_To_AnsiString(d_OOS_min)
- );
- }
- STOP_RF
- }
- // TX DC offset
- fdata = 5*3*(d_POOS[3]-d_POOS[2]) / (2*(d_POOS[3]+d_POOS[2]+2*d_POOS[1]-4*d_POOS[0])) + offset_IQt.I;
- fdata += (fdata>=0) ? 0.5 : -0.5 ;
- offset_IQt.I = fdata;
- fdata= 5*(d_POOS[3]+d_POOS[2]-4*d_POOS[1]+2*d_POOS[0]) / (2*(d_POOS[3]+d_POOS[2]+2*d_POOS[1]-4*d_POOS[0])) + offset_IQt.Q;
- fdata += (fdata>=0) ? 0.5 : -0.5 ;
- offset_IQt.Q = fdata;
- if (offset_IQt.I > MAX_OFFSET_IQ)
- {
- offset_IQt.I = MAX_OFFSET_IQ;
- }
- else if(offset_IQt.I < MIN_OFFSET_IQ)
- {
- offset_IQt.I = MIN_OFFSET_IQ;
- }
- if (offset_IQt.Q > MAX_OFFSET_IQ)
- {
- offset_IQt.Q = MAX_OFFSET_IQ;
- }
- else if(offset_IQt.Q < MIN_OFFSET_IQ)
- {
- offset_IQt.Q = MIN_OFFSET_IQ;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " Evaluate OffsetI = " + IntToStr( offset_IQt.I ) +
- ", OffsetQ = " + IntToStr( offset_IQt.Q )
- );
- S_TXIQ txiq_low;
- txiq_low.offset_IQ = offset_IQt;
- txiq_low.trim_IQ = trim_IQt;
- txiq_low.c_TxPhasesel = c_TxPhasesel_eval;
- if (!TXIqCheck_EPSK(true, 2, txiq_low, s_iq_result_low))
- {
- return false;
- }
- }
- // if (d_SBS_min > s_iq_result_low.d_sbs)
- // {
- // d_SBS_min = s_iq_result_low.d_sbs;
- // s_trim_sbs_min = txiq_low.trim_IQ;
- // log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- // " TrimI = " + IntToStr(s_trim_sbs_min.I) +
- // ", TrimQ = " + IntToStr(s_trim_sbs_min.Q) +
- // ", min SBS = " + Double_To_AnsiString(d_SBS_min)
- // );
- //
- // }
- if (d_OOS_min > s_iq_result_low.d_oos)
- {
- d_OOS_min = s_iq_result_low.d_oos;
- s_offset_oos_min = txiq_low.offset_IQ;
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " OffsetI = " + IntToStr(s_offset_oos_min.I) +
- ", OffsetQ = " + IntToStr(s_offset_oos_min.Q) +
- ", min OOS = " + Double_To_AnsiString(d_OOS_min)
- );
- }
- l1cal_txiq.bbtx_trimI = trim_IQt.I;
- l1cal_txiq.bbtx_trimQ = trim_IQt.Q;
- l1cal_txiq.bbtx_offsetI = s_offset_oos_min.I;
- l1cal_txiq.bbtx_offsetQ = s_offset_oos_min.Q;
- l1cal_txiq.bbtx_phsel = c_TxPhasesel_eval;
- // high band calibration
- if ((RF_ID_A60111A == m_pCal->ui_rf_id) ||
- (RF_ID_AERO2E == m_pCal->ui_rf_id) ||
- (RF_ID_MT6140A == m_pCal->ui_rf_id) ||
- (RF_ID_MT6140B == m_pCal->ui_rf_id) ||
- (RF_ID_MT6140C == m_pCal->ui_rf_id) ||
- (RF_ID_MT6140D == m_pCal->ui_rf_id)
- )
- {
- OffsetIQ[0].I = 0;
- OffsetIQ[0].Q = 0;
- OffsetIQ[1].I = 0;
- OffsetIQ[1].Q = 30;
- OffsetIQ[2].I = 30;
- OffsetIQ[2].Q = -30;
- OffsetIQ[3].I = -30;
- OffsetIQ[3].Q = -30;
- m_viTX_IQ_BAND_HIGH = Get_AgeBand(m_asTX_IQ_BAND_HIGH);
- band_index = AgeBand_To_BandIdx(m_viTX_IQ_BAND_HIGH);
- if (!m_rct_ctrl.RCT_cellBand(m_pRct, m_viTX_IQ_BAND_HIGH))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_BAND_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : "+
- m_pRct->as_RCT + " < Band = " + ViBand_To_Str(m_viTX_IQ_BAND_HIGH)
- );
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < Band = "+
- ViBand_To_Str( m_viTX_IQ_BAND_HIGH )
- );
- short bch_arfcn = ::Get_SeperateChannel(m_viTX_IQ_BAND_HIGH, m_sTX_IQ_ARFCN_HIGH);
- if (!m_rct_ctrl.RCT_BCHARFCN(m_pRct, bch_arfcn))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_TCH_ARFCN_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " +
- m_pRct->as_RCT + " < BCH ARFCN = " + IntToStr(bch_arfcn)
- );
- return false;
- }
- if (!m_rct_ctrl.RCT_PDTCHARFCN(m_pRct, m_sTX_IQ_ARFCN_HIGH))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_PDTCH_ARFCN_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " +
- m_pRct->as_RCT + " < PDTCH ARFCN = " + IntToStr(m_sTX_IQ_ARFCN_HIGH)
- );
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < PDTCH ARFCN = " + IntToStr(m_sTX_IQ_ARFCN_HIGH)
- );
- if (!m_rct_ctrl.RCT_PDTCHMSTxLevel(m_pRct, m_sTX_IQ_PCL_HIGH))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_MS_TX_LEVEL_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " + m_pRct->as_RCT + " < MS TX level = " + IntToStr(m_sTX_IQ_PCL_HIGH)
- );
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < MS TX level = " + IntToStr(m_sTX_IQ_PCL_HIGH)
- );
- 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;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < TSC = " + IntToStr(m_cTSC)
- );
- if (!m_rct_ctrl.RCT_Config_EPSK_ModACcuracy(m_pRct, m_uiTX_IQ_MEASUREMENT_COUNT, age1960_TRIG_AUTO, 0, 5))
- {
- CalErrorHandler(WM_MF_AGE8960_CONFIG_IQ_TUNNING_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- "FAIL : " + m_pRct->as_RCT + " < config EPSK modulation accurary fail."
- );
- return false;
- }
- for (int i=0; i<4; i++)
- {
- rf_bb_tx_cfg_req.TxTrimI = TrimIQ[i].I;
- rf_bb_tx_cfg_req.TxTrimQ = TrimIQ[i].Q;
- rf_bb_tx_cfg_req.TxOffsetI = OffsetIQ[i].I;
- rf_bb_tx_cfg_req.TxOffsetQ = OffsetIQ[i].Q;
- rf_bb_tx_cfg_req.TxPhasesel = c_TxPhasesel[i];
- m_cTXIQ_RUN_Obj.ConfirmCallback = ::CNF_MF;
- m_cTXIQ_RUN_Obj.REQ_SetBBTxCfg_Start(m_pCal->e_bbtxcfg_ver, rf_bb_tx_cfg_req);
- RestartTimerCal(WM_MF_RF_SET_BB_TX_CFG_FAIL);
- SUSPEND_CAL_THREAD
- if (m_cTXIQ_RUN_Obj.Get_ConfirmState() != METAAPP_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_SET_BB_TX_CFG_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < RF set BB TX CFG fail."
- );
- return false;
- }
- CHECK_TERMINATE_BY_USER
- STOP_RF
- Sleep(50);
- int pcl[4];
- CodingScheme cs[4];
- APCTxPattern pattern;
- cs[0] = CodingSchemeMCS5;
- cs[1] = CodingSchemeMCS5;
- cs[2] = CodingSchemeMCS5;
- cs[3] = CodingSchemeMCS5;
- pcl[0] = m_sTX_IQ_PCL_HIGH;
- pcl[1] = m_sTX_IQ_PCL_HIGH;
- pcl[2] = m_sTX_IQ_PCL_HIGH;
- pcl[3] = m_sTX_IQ_PCL_HIGH;
- pattern = NB_TX_RANDOM_WITH_TSC;
- S_MULTI_SLOT_TX_T multi_slot_tx;
- multi_slot_tx.b_MultiSlotTXExSupport = m_pCal->b_MultiSlotTxExSupport;
- multi_slot_tx.e_bandsel = band_index;
- multi_slot_tx.req.arfcn = m_sTX_IQ_ARFCN_HIGH;
- multi_slot_tx.req.bsic = m_cTSC;
- multi_slot_tx.req.timeSlotmask = 0x01;
- for (int i=0; i<4; i++)
- {
- multi_slot_tx.req.powerLev[i] = pcl[i];
- multi_slot_tx.req.cs[i] = cs[i];
- }
- multi_slot_tx.req.ta = 0;
- multi_slot_tx.req.frames = -99;
- multi_slot_tx.req.dacValue = m_sDefault_value;
- multi_slot_tx.req.pattern = pattern;
- multi_slot_tx.req.pattern_data = 0;
- RF_MULTI_SLOT_TX_Obj.ConfirmCallback = ::ConfirmCallback_MultiSlotTX;
- RF_MULTI_SLOT_TX_Obj.REQ_Start(multi_slot_tx);
- SUSPEND_CAL_THREAD
- if (RF_MULTI_SLOT_TX_Obj.Get_ConfirmState() != METAAPP_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_TX_LEVEL_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < multislot TX fail."
- );
- return false;
- }
- // TX DC offset & IQ imbalance
- if (!m_rct_ctrl.RCT_Fetch_EPSK_Average_TxIq(m_pRct, &d_SBS[i], &d_OOS[i]))
- {
- CalErrorHandler(WM_MF_AGE8960_FETCH_EPSK_OOS_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " + m_pRct->as_RCT + " > fetch EPSK original offset and IQ imbalance fail."
- );
- return false;
- }
- if (NAN == d_SBS[i])
- {
- CalErrorHandler(WM_MF_RF_TX_IQ_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Get TX IQ imbalance fail."
- );
- return false;
- }
- d_PSBS[i] = exp(d_SBS[i]/10.0*logl(10.0));
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " TrimI = " + IntToStr( TrimIQ[i].I ) +
- ", TrimQ = " + IntToStr( TrimIQ[i].Q ) +
- ", SBS = " + Double_To_AnsiString( d_SBS[i] ) +
- ", PSBS = " + Double_To_AnsiString( d_PSBS[i] )
- );
- // if (d_SBS_min >d_SBS[i])
- // {
- // d_SBS_min = d_SBS[i];
- // s_trim_sbs_min.I = rf_bb_tx_cfg_req.TxTrimI;
- // s_trim_sbs_min.Q = rf_bb_tx_cfg_req.TxTrimQ;
- // log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- // " TrimI = " + IntToStr(s_trim_sbs_min.I) +
- // ", TrimQ = " + IntToStr(s_trim_sbs_min.Q) +
- // ", min SBS = " + Double_To_AnsiString(d_SBS_min)
- // );
- // }
- if( NAN == d_OOS[i] )
- {
- CalErrorHandler( WM_MF_RF_TX_IQ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Get TX original offset fail."
- );
- return false;
- }
- d_POOS[i] = exp(d_OOS[i]/10.0*logl(10.0));
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " OffsetI = " + IntToStr( OffsetIQ[i].I ) +
- ", OffsetQ = " + IntToStr( OffsetIQ[i].Q ) +
- ", OOS = " + Double_To_AnsiString( d_OOS[i] ) +
- ", POOS = " + Double_To_AnsiString( d_POOS[i] )
- );
- if (d_OOS_min > d_OOS[i])
- {
- d_OOS_min = d_OOS[i];
- s_offset_oos_min.I = rf_bb_tx_cfg_req.TxOffsetI;
- s_offset_oos_min.Q = rf_bb_tx_cfg_req.TxOffsetQ;
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " OffsetI = " + IntToStr(s_offset_oos_min.I) +
- ", OffsetQ = " + IntToStr(s_offset_oos_min.Q) +
- ", min OOS = " + Double_To_AnsiString(d_OOS_min)
- );
- }
- STOP_RF
- }
- S_IQ offset_IQt_h;
- S_IQ trim_IQt_h;
- char c_TxPhasesel_eval_h;
- // TX IQ gain imbalance
- ViReal64 Xt;
- Xt = 14*(d_PSBS[2]-d_PSBS[1]) / (2*(d_PSBS[2]+d_PSBS[1]-2*d_PSBS[0]));
- float fdata = Xt/2.0;
- fdata += (fdata>=0) ? 0.5 : -0.5 ;
- trim_IQt_h.I = fdata;
- fdata = -1.0*(Xt - trim_IQt_h.I);
- fdata += (fdata>=0) ? 0.5 : -0.5 ;
- trim_IQt_h.Q = fdata;
- if (trim_IQt_h.I > MAX_TRIM_IQ)
- {
- trim_IQt_h.I = MAX_TRIM_IQ;
- }
- else if(trim_IQt_h.I < MIN_TRIM_IQ)
- {
- trim_IQt_h.I = MIN_TRIM_IQ;
- }
- if (trim_IQt_h.Q > MAX_TRIM_IQ)
- {
- trim_IQt_h.Q = MAX_TRIM_IQ;
- }
- else if(trim_IQt_h.Q < MIN_TRIM_IQ)
- {
- trim_IQt_h.Q = MIN_TRIM_IQ;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Evaluate Xt = " + Double_To_AnsiString(Xt) + ", TrimI = " + IntToStr( trim_IQt_h.I ) +
- ", TrimQ = " + IntToStr( trim_IQt_h.Q )
- );
- // TX DC offset
- fdata = 30*3*(d_POOS[3]-d_POOS[2]) / (2*(d_POOS[3]+d_POOS[2]+2*d_POOS[1]-4*d_POOS[0]));
- fdata += (fdata>=0) ? 0.5 : -0.5 ;
- offset_IQt_h.I = fdata;
- fdata= 30*(d_POOS[3]+d_POOS[2]-4*d_POOS[1]+2*d_POOS[0]) / (2*(d_POOS[3]+d_POOS[2]+2*d_POOS[1]-4*d_POOS[0]));
- fdata += (fdata>=0) ? 0.5 : -0.5 ;
- offset_IQt_h.Q = fdata;
- if (offset_IQt_h.I > MAX_OFFSET_IQ)
- {
- offset_IQt_h.I = MAX_OFFSET_IQ;
- }
- else if(offset_IQt_h.I < MIN_OFFSET_IQ)
- {
- offset_IQt_h.I = MIN_OFFSET_IQ;
- }
- if (offset_IQt_h.Q > MAX_OFFSET_IQ)
- {
- offset_IQt_h.Q = MAX_OFFSET_IQ;
- }
- else if(offset_IQt_h.Q < MIN_OFFSET_IQ)
- {
- offset_IQt_h.Q = MIN_OFFSET_IQ;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Evaluate OffsetI = " + IntToStr( offset_IQt_h.I ) +
- ", OffsetQ = " + IntToStr( offset_IQt_h.Q )
- );
- // Evaluate phasesel
- double d_norm_phasesel_h = c_TxPhasesel[3] * 6.28 / 360.0;
- fdata = ((pow(d_norm_phasesel_h, 2) + 4 * d_PSBS[0] - 4 * d_PSBS[3]) / (2 * d_norm_phasesel_h)) / 6.28 * 360.0;
- fdata += (fdata>=0) ? 0.5 : -0.5 ;
- c_TxPhasesel_eval_h = (char) fdata;
- if (c_TxPhasesel_eval_h > c_max_phasesel)
- {
- c_TxPhasesel_eval_h = c_max_phasesel;
- }
- else if (c_TxPhasesel_eval_h < c_min_phasesel)
- {
- c_TxPhasesel_eval_h = c_min_phasesel;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " Evaluate Phasesel = " + IntToStr(c_TxPhasesel_eval_h)
- );
- l1cal_txiq.bbtx_trimI_h = trim_IQt_h.I;
- l1cal_txiq.bbtx_trimQ_h = trim_IQt_h.Q;
- l1cal_txiq.bbtx_offsetI_h = offset_IQt_h.I;
- l1cal_txiq.bbtx_offsetQ_h = offset_IQt_h.Q;
- l1cal_txiq.bbtx_phsel_h = c_TxPhasesel_eval_h;
- S_TXIQ txiq_high;
- txiq_high.offset_IQ = offset_IQt_h;
- txiq_high.trim_IQ = trim_IQt_h;
- txiq_high.c_TxPhasesel = c_TxPhasesel_eval_h;
- if (!TXIqCheck_EPSK(false, 1, txiq_high, s_iq_result_high))
- {
- return false;
- }
- if (s_iq_result_high.b_oos_out_of_range)
- {
- OffsetIQ[0].I = offset_IQt_h.I;
- OffsetIQ[0].Q = offset_IQt_h.Q;
- OffsetIQ[1].I = offset_IQt_h.I;
- OffsetIQ[1].Q = offset_IQt_h.Q + 5;
- OffsetIQ[2].I = offset_IQt_h.I + 5;
- OffsetIQ[2].Q = offset_IQt_h.Q - 5;
- OffsetIQ[3].I = offset_IQt_h.I - 5;
- OffsetIQ[3].Q = offset_IQt_h.Q - 5;
- for (int i=0; i<4; i++)
- {
- if (OffsetIQ[i].I > MAX_OFFSET_IQ)
- {
- OffsetIQ[i].I = MAX_OFFSET_IQ;
- }
- else if(OffsetIQ[i].I < MIN_OFFSET_IQ)
- {
- OffsetIQ[i].I = MIN_OFFSET_IQ;
- }
- if (OffsetIQ[i].Q > MAX_OFFSET_IQ)
- {
- OffsetIQ[i].Q = MAX_OFFSET_IQ;
- }
- else if(OffsetIQ[i].Q < MIN_OFFSET_IQ)
- {
- OffsetIQ[i].Q = MIN_OFFSET_IQ;
- }
- }
- for (int i=0; i<4; i++)
- {
- rf_bb_tx_cfg_req.TxOffsetI = OffsetIQ[i].I;
- rf_bb_tx_cfg_req.TxOffsetQ = OffsetIQ[i].Q;
- m_cTXIQ_RUN_Obj.ConfirmCallback = ::CNF_MF;
- m_cTXIQ_RUN_Obj.REQ_SetBBTxCfg_Start(m_pCal->e_bbtxcfg_ver, rf_bb_tx_cfg_req);
- RestartTimerCal(WM_MF_RF_SET_BB_TX_CFG_FAIL);
- SUSPEND_CAL_THREAD
- if (m_cTXIQ_RUN_Obj.Get_ConfirmState() != METAAPP_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_SET_BB_TX_CFG_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < RF set BB TX CFG fail."
- );
- return false;
- }
- CHECK_TERMINATE_BY_USER
- STOP_RF
- Sleep(50);
- int pcl[4];
- CodingScheme cs[4];
- APCTxPattern pattern;
- cs[0] = CodingSchemeMCS5;
- cs[1] = CodingSchemeMCS5;
- cs[2] = CodingSchemeMCS5;
- cs[3] = CodingSchemeMCS5;
- pcl[0] = m_sTX_IQ_PCL_HIGH;
- pcl[1] = m_sTX_IQ_PCL_HIGH;
- pcl[2] = m_sTX_IQ_PCL_HIGH;
- pcl[3] = m_sTX_IQ_PCL_HIGH;
- pattern = NB_TX_RANDOM_WITH_TSC;
- S_MULTI_SLOT_TX_T multi_slot_tx;
- multi_slot_tx.b_MultiSlotTXExSupport = m_pCal->b_MultiSlotTxExSupport;
- multi_slot_tx.e_bandsel = band_index;
- multi_slot_tx.req.arfcn = m_sTX_IQ_ARFCN_HIGH;
- multi_slot_tx.req.bsic = m_cTSC;
- multi_slot_tx.req.timeSlotmask = 0x01;
- for (int i=0; i<4; i++)
- {
- multi_slot_tx.req.powerLev[i] = pcl[i];
- multi_slot_tx.req.cs[i] = cs[i];
- }
- multi_slot_tx.req.ta = 0;
- multi_slot_tx.req.frames = -99;
- multi_slot_tx.req.dacValue = m_sDefault_value;
- multi_slot_tx.req.pattern = pattern;
- multi_slot_tx.req.pattern_data = 0;
- RF_MULTI_SLOT_TX_Obj.ConfirmCallback = ::ConfirmCallback_MultiSlotTX;
- RF_MULTI_SLOT_TX_Obj.REQ_Start(multi_slot_tx);
- SUSPEND_CAL_THREAD
- if (RF_MULTI_SLOT_TX_Obj.Get_ConfirmState() != METAAPP_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_TX_LEVEL_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < multislot TX fail."
- );
- return false;
- }
- // TX DC offset
- if (!m_rct_ctrl.RCT_Fetch_EPSK_Average_OrignalOffset(m_pRct, &d_OOS[i]))
- {
- CalErrorHandler(WM_MF_AGE8960_FETCH_EPSK_OOS_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " + m_pRct->as_RCT + " > fetch EPSK original offset fail."
- );
- return false;
- }
- if (NAN == d_OOS[i])
- {
- CalErrorHandler(WM_MF_RF_TX_IQ_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Get TX original offset fail."
- );
- return false;
- }
- d_POOS[i] = exp(d_OOS[i]/10.0*logl(10.0));
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " OffsetI = " + IntToStr( OffsetIQ[i].I ) +
- ", OffsetQ = " + IntToStr( OffsetIQ[i].Q ) +
- ", OOS = " + Double_To_AnsiString( d_OOS[i] ) +
- ", POOS = " + Double_To_AnsiString( d_POOS[i] )
- );
- if (d_OOS_min > d_OOS[i])
- {
- d_OOS_min = d_OOS[i];
- s_offset_oos_min.I = rf_bb_tx_cfg_req.TxOffsetI;
- s_offset_oos_min.Q = rf_bb_tx_cfg_req.TxOffsetQ;
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " OffsetI = " + IntToStr(s_offset_oos_min.I) +
- ", OffsetQ = " + IntToStr(s_offset_oos_min.Q) +
- ", min OOS = " + Double_To_AnsiString(d_OOS_min)
- );
- }
- STOP_RF
- }
- // TX DC offset
- fdata = 5*3*(d_POOS[3]-d_POOS[2]) / (2*(d_POOS[3]+d_POOS[2]+2*d_POOS[1]-4*d_POOS[0])) + offset_IQt_h.I;
- fdata += (fdata>=0) ? 0.5 : -0.5 ;
- offset_IQt_h.I = fdata;
- fdata= 5*(d_POOS[3]+d_POOS[2]-4*d_POOS[1]+2*d_POOS[0]) / (2*(d_POOS[3]+d_POOS[2]+2*d_POOS[1]-4*d_POOS[0])) + offset_IQt_h.Q;
- fdata += (fdata>=0) ? 0.5 : -0.5 ;
- offset_IQt_h.Q = fdata;
- if (offset_IQt_h.I > MAX_OFFSET_IQ)
- {
- offset_IQt_h.I = MAX_OFFSET_IQ;
- }
- else if(offset_IQt_h.I < MIN_OFFSET_IQ)
- {
- offset_IQt_h.I = MIN_OFFSET_IQ;
- }
- if (offset_IQt_h.Q > MAX_OFFSET_IQ)
- {
- offset_IQt_h.Q = MAX_OFFSET_IQ;
- }
- else if(offset_IQt_h.Q < MIN_OFFSET_IQ)
- {
- offset_IQt_h.Q = MIN_OFFSET_IQ;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Evaluate OffsetI = " + IntToStr( offset_IQt_h.I ) +
- ", OffsetQ = " + IntToStr( offset_IQt_h.Q )
- );
- l1cal_txiq.bbtx_trimI_h = trim_IQt_h.I;
- l1cal_txiq.bbtx_trimQ_h = trim_IQt_h.Q;
- l1cal_txiq.bbtx_offsetI_h = offset_IQt_h.I;
- l1cal_txiq.bbtx_offsetQ_h = offset_IQt_h.Q;
- l1cal_txiq.bbtx_phsel_h = c_TxPhasesel_eval_h;
- S_TXIQ txiq_high;
- txiq_high.offset_IQ = offset_IQt_h;
- txiq_high.trim_IQ = trim_IQt_h;
- txiq_high.c_TxPhasesel = c_TxPhasesel_eval_h;
- if (!TXIqCheck_EPSK(false, 2, txiq_high, s_iq_result_high))
- {
- return false;
- }
- }
- #if 0
- // phase cal
- if ((MT6205 != m_pCal->e_bb_chip) &&
- (MT6205B != m_pCal->e_bb_chip) &&
- (MT6218 != m_pCal->e_bb_chip) &&
- (MT6218B != m_pCal->e_bb_chip) &&
- (MT6219 != m_pCal->e_bb_chip) &&
- (MT6217 != m_pCal->e_bb_chip) &&
- (MT6228 != m_pCal->e_bb_chip) &&
- (MT6227D != m_pCal->e_bb_chip) &&
- (MT6227 != m_pCal->e_bb_chip) &&
- (MT6229 != m_pCal->e_bb_chip) &&
- (MT6226 != m_pCal->e_bb_chip) &&
- (MT6226D != m_pCal->e_bb_chip) &&
- (MT6226M != m_pCal->e_bb_chip) &&
- (MT6230 != m_pCal->e_bb_chip) &&
- (MT6268T != m_pCal->e_bb_chip) &&
- (TK6516_MD != m_pCal->e_bb_chip)
- )
- {
- char cPhaseSel[] = {0, 3};
- double d_SBS_ph_h[2];
- double d_PSBS_ph_h[2];
- for (int i=0; i<2; i++)
- {
- rf_bb_tx_cfg_req.TxPhasesel = cPhaseSel[i];
- m_cTXIQ_RUN_Obj.ConfirmCallback = ::CNF_MF;
- m_cTXIQ_RUN_Obj.REQ_SetBBTxCfg_Start(m_pCal->e_bbtxcfg_ver, rf_bb_tx_cfg_req);
- RestartTimerCal(WM_MF_RF_SET_BB_TX_CFG_FAIL);
- SUSPEND_CAL_THREAD
- if (m_cTXIQ_RUN_Obj.Get_ConfirmState() != METAAPP_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_SET_BB_TX_CFG_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < RF set BB TX CFG fail."
- );
- return false;
- }
- int pcl[4];
- int cs[4];
- APCTxPattern pattern;
- cs[0] = CodingSchemeMCS5;
- cs[1] = CodingSchemeMCS5;
- cs[2] = CodingSchemeMCS5;
- cs[3] = CodingSchemeMCS5;
- pcl[0] = m_sTX_IQ_PCL_HIGH;
- pcl[1] = m_sTX_IQ_PCL_HIGH;
- pcl[2] = m_sTX_IQ_PCL_HIGH;
- pcl[3] = m_sTX_IQ_PCL_HIGH;
- pattern = NB_TX_RANDOM_WITH_TSC;
- S_MULTI_SLOT_TX_T multi_slot_tx;
- multi_slot_tx.b_MultiSlotTXExSupport = m_pCal->b_MultiSlotTxExSupport;
- multi_slot_tx.e_bandsel = band_index;
- multi_slot_tx.req.arfcn = m_sTX_IQ_ARFCN_HIGH;
- multi_slot_tx.req.bsic = m_cTSC;
- multi_slot_tx.req.timeSlotmask = 0x01;
- for (int i=0; i<4; i++)
- {
- multi_slot_tx.req.powerLev[i] = pcl[i];
- multi_slot_tx.req.cs[i] = cs[i];
- }
- multi_slot_tx.req.ta = 0;
- multi_slot_tx.req.frames = -99;
- multi_slot_tx.req.dacValue = m_sDefault_value;
- multi_slot_tx.req.pattern = pattern;
- multi_slot_tx.req.pattern_data = 0;
- RF_MULTI_SLOT_TX_Obj.ConfirmCallback = ::ConfirmCallback_MultiSlotTX;
- RF_MULTI_SLOT_TX_Obj.REQ_Start(multi_slot_tx);
- //RF_MULTI_SLOT_TX_Obj.ConfirmCallback = ::ConfirmCallback_MultiSlotTX;
- //RF_MULTI_SLOT_TX_Obj.REQ_Start(band_index, m_sTX_IQ_ARFCN_HIGH, m_cTSC, cs, pcl, -99, m_sDefault_value, 0x01, 0, true, pattern, 0 );
- SUSPEND_CAL_THREAD
- if (RF_MULTI_SLOT_TX_Obj.Get_ConfirmState() != METAAPP_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_TX_LEVEL_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < multislot TX fail."
- );
- return false;
- }
- // get SBS
- if (!m_rct_ctrl.RCT_Fetch_EPSK_Average_IQImbalance(m_pRct, &d_SBS_ph_h[i]))
- {
- CalErrorHandler(WM_MF_AGE8960_FETCH_EPSK_OOS_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " + m_pRct->as_RCT + " > fetch EPSK original offset fail."
- );
- return false;
- }
- d_PSBS_ph_h[i] = exp(d_SBS_ph_h[i]/10.0*logl(10.0));
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " TxPhasesel = " + IntToStr(cPhaseSel[i]) +
- ", SBS = " + Double_To_AnsiString(d_SBS_ph_h[i]) +
- ", PSBS = " + Double_To_AnsiString(d_PSBS_ph_h[i])
- );
- } // for(i)
- // evaluate optimal TxPhasesel
- double d_opt_TxPhasesel_h = (cPhaseSel[1]*cPhaseSel[1] + 4*d_PSBS_ph_h[0] - 4*d_PSBS_ph_h[1]) / (2*cPhaseSel[1]);
- rf_bb_tx_cfg_req.TxPhasesel += (d_opt_TxPhasesel_h>=0) ? 0.5 : -0.5 ;
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Evaluate TxPhasesel = " + IntToStr(rf_bb_tx_cfg_req.TxPhasesel)
- );
- l1cal_txiq.bbtx_phsel_h = rf_bb_tx_cfg_req.TxPhasesel;
- m_cTXIQ_RUN_Obj.ConfirmCallback = ::CNF_MF;
- m_cTXIQ_RUN_Obj.REQ_SetBBTxCfg_Start(m_pCal->e_bbtxcfg_ver, rf_bb_tx_cfg_req);
- RestartTimerCal(WM_MF_RF_SET_BB_TX_CFG_FAIL);
- SUSPEND_CAL_THREAD
- if (MF_rf_txiq_ptr->Get_ConfirmState() != METAAPP_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_SET_BB_TX_CFG_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < RF set BB TX CFG fail."
- );
- return false;
- }
- } // phase cal
- #endif
- }// high band
- // set calibration flag
- if ((RF_ID_A60111A == m_pCal->ui_rf_id) ||
- (RF_ID_AERO2E == m_pCal->ui_rf_id) ||
- (RF_ID_MT6140A == m_pCal->ui_rf_id) ||
- (RF_ID_MT6140B == m_pCal->ui_rf_id) ||
- (RF_ID_MT6140C == m_pCal->ui_rf_id) ||
- (RF_ID_MT6140D == m_pCal->ui_rf_id)
- )
- {
- if (s_iq_result_low.b_oos_out_of_range ||
- s_iq_result_low.b_sbs_out_of_range ||
- s_iq_result_high.b_oos_out_of_range ||
- s_iq_result_high.b_sbs_out_of_range
- )
- {
- l1cal_txiq.bbtx_isCalibrated = 0;
- }
- else
- {
- l1cal_txiq.bbtx_isCalibrated = BBTX_CALIBRATED_SCALE;
- }
- }
- else
- {
- if (s_iq_result_low.b_oos_out_of_range ||
- s_iq_result_low.b_sbs_out_of_range
- )
- {
- l1cal_txiq.bbtx_isCalibrated = 0;
- }
- else
- {
- l1cal_txiq.bbtx_isCalibrated = BBTX_CALIBRATED_SCALE;
- }
- }
- S_BBTXPARA_CHANGE_FLAG_T flag;
- flag.b_bbtx_common_mode_voltage = true;
- flag.b_bbtx_gain = true;
- flag.b_bbtx_calrcsel = true;
- flag.b_bbtx_trimI = true;
- flag.b_bbtx_trimQ = true;
- flag.b_bbtx_offsetI = true;
- flag.b_bbtx_offsetQ = true;
- flag.b_bbtx_isCalibrated = true;
- flag.b_apc_bat_low_voltage = true;
- flag.b_apc_bat_high_voltage = true;
- flag.b_apc_bat_low_temperature = true;
- flag.b_apc_bat_high_temperature = true;
- flag.b_bbtx_common_mode_voltage_h = true;
- flag.b_bbtx_gain_h = true;
- flag.b_bbtx_calrcsel_h = true;
- flag.b_bbtx_trimI_h = true;
- flag.b_bbtx_trimQ_h = true;
- flag.b_bbtx_offsetI_h = true;
- flag.b_bbtx_offsetQ_h = true;
- flag.b_bbtx_phsel = true;
- flag.b_bbtx_phsel_h = true;
- MF_rf_txiq_ptr->Set_BBTXChangeFlag(flag);
- MF_rf_txiq_ptr->Set_BBTXParameters(l1cal_txiq);
- WriteTxDcOffsetCalResultToFile(as_ID+".cal",Application->ExeName, m_pCal->b_CalResultPath );
- MF_rf_txiq_ptr->ConfirmCallback = ::ccb_write_txiq_to_nvram;
- MF_rf_txiq_ptr->REQ_Write_To_NVRAM_Start(m_pCal->ui_rf_id, m_pCal->e_bbtxcfg_ver);
- RestartTimerCal(WM_MF_NVRAM_TXIQ_WRITE_FAIL);
- SUSPEND_CAL_THREAD
- E_METAAPP_RESULT_T state = MF_rf_txiq_ptr->Get_ConfirmState();
- if (state != METAAPP_SUCCESS)
- {
- if (METAAPP_NVRAM_LID_VER_NOT_SUPPORT == state)
- {
- CalErrorHandler(WM_MF_NVRAM_EF_L1_TXIQ_LID_VERNO_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : NVRAM_EF_L1_TXIQ_LID version is not support, please update META to latest version. "
- );
- }
- else
- {
- CalErrorHandler(WM_MF_NVRAM_TXIQ_WRITE_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target< Write txiq value to NVRAM fail "
- );
- }
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target< Write TXIQ value to NVRAM"
- );
- if (0 == l1cal_txiq.bbtx_isCalibrated)
- {
- CalErrorHandler(WM_MF_RF_TX_IQ_CHECK_FAIL);
- return false;
- }
- PostMessage(
- ctrl.hPostMsgDestHandle,
- WM_MF_RF_TX_IQ_CALIBRATION_DONE,
- 0,
- 0
- );
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " ================== TX IQ calibration end ================== "
- );
- return true;
- }
- //==============================================================================
- bool __fastcall T_META_factory_calibration::TXIqCheck_EPSK(bool low_band, int stage, S_TXIQ iq, S_TXIQ_RESULT &result)
- {
- RfBBTXCfg4 rf_bb_tx_cfg_req;
- result.b_oos_out_of_range = false;
- result.b_sbs_out_of_range = false;
- // get BBTxCfg
- m_cTXIQ_RUN_Obj.ConfirmCallback = ::CNF_MF;
- m_cTXIQ_RUN_Obj.REQ_GetBBTxCfg_Start(m_pCal->e_bbtxcfg_ver);
- RestartTimerCal(WM_MF_RF_GET_BB_TX_CFG_FAIL);
- SUSPEND_CAL_THREAD
- if (m_cTXIQ_RUN_Obj.Get_ConfirmState() != METAAPP_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_GET_BB_TX_CFG_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target > RF get BB TX CFG fail."
- );
- return false;
- }
- RfBBTXCfg4* p_bbtx_cfg = m_cTXIQ_RUN_Obj.Get_BbTxCfg();
- rf_bb_tx_cfg_req = *p_bbtx_cfg;
- if (low_band)
- {
- // bool b_out_of_rangeL_low = false;
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " ===================== TX IQ low band stage " + IntToStr(stage) + " check begin =================== "
- );
- // set BBTxCfg2
- rf_bb_tx_cfg_req.TxTrimI = iq.trim_IQ.I;
- rf_bb_tx_cfg_req.TxTrimQ = iq.trim_IQ.Q;
- rf_bb_tx_cfg_req.TxOffsetI = iq.offset_IQ.I;
- rf_bb_tx_cfg_req.TxOffsetQ = iq.offset_IQ.Q;
- rf_bb_tx_cfg_req.TxPhasesel = iq.c_TxPhasesel;
- m_cTXIQ_RUN_Obj.ConfirmCallback = ::CNF_MF;
- m_cTXIQ_RUN_Obj.REQ_SetBBTxCfg_Start(m_pCal->e_bbtxcfg_ver, rf_bb_tx_cfg_req);
- RestartTimerCal(WM_MF_RF_SET_BB_TX_CFG_FAIL);
- SUSPEND_CAL_THREAD
- if (m_cTXIQ_RUN_Obj.Get_ConfirmState() != METAAPP_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_SET_BB_TX_CFG_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < RF set BB TX CFG fail."
- );
- return false;
- }
- STOP_RF
- Sleep(50);
- int pcl[4];
- CodingScheme cs[4];
- APCTxPattern pattern;
- cs[0] = CodingSchemeMCS5;
- cs[1] = CodingSchemeMCS5;
- cs[2] = CodingSchemeMCS5;
- cs[3] = CodingSchemeMCS5;
- pcl[0] = m_sTX_IQ_PCL;
- pcl[1] = m_sTX_IQ_PCL;
- pcl[2] = m_sTX_IQ_PCL;
- pcl[3] = m_sTX_IQ_PCL;
- pattern = NB_TX_RANDOM_WITH_TSC;
- S_MULTI_SLOT_TX_T multi_slot_tx;
- multi_slot_tx.b_MultiSlotTXExSupport = m_pCal->b_MultiSlotTxExSupport;
- E_BANDSEL band_index = String_To_BandIdx(m_asTX_IQ_BAND);
- multi_slot_tx.e_bandsel = band_index;
- multi_slot_tx.req.arfcn = m_sTX_IQ_ARFCN;
- multi_slot_tx.req.bsic = m_cTSC;
- multi_slot_tx.req.timeSlotmask = 0x01;
- for (int i=0; i<4; i++)
- {
- multi_slot_tx.req.powerLev[i] = pcl[i];
- multi_slot_tx.req.cs[i] = cs[i];
- }
- multi_slot_tx.req.ta = 0;
- multi_slot_tx.req.frames = -99;
- multi_slot_tx.req.dacValue = m_sDefault_value;
- multi_slot_tx.req.pattern = pattern;
- multi_slot_tx.req.pattern_data = 0;
- RF_MULTI_SLOT_TX_Obj.ConfirmCallback = ::ConfirmCallback_MultiSlotTX;
- RF_MULTI_SLOT_TX_Obj.REQ_Start(multi_slot_tx);
- SUSPEND_CAL_THREAD
- if (RF_MULTI_SLOT_TX_Obj.Get_ConfirmState() != METAAPP_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_TX_LEVEL_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < multislot TX fail."
- );
- return false;
- }
- // TX IQ gain imbalance check
- double d_SBS_Check;
- double d_OOS_Check;
- if (!m_rct_ctrl.RCT_Fetch_EPSK_Average_TxIq(m_pRct, &d_SBS_Check, &d_OOS_Check))
- {
- CalErrorHandler(WM_MF_AGE8960_FETCH_EPSK_OOS_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " + m_pRct->as_RCT + " > fetch EPSK original offset and IQ imbalance fail."
- );
- return false;
- }
- if (d_OOS_Check > m_dTX_IQ_DC_OFFSET_MAX)
- {
- // CalErrorHandler(WM_MF_RF_TX_IQ_CHECK_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: TX IQ calibration." +
- " , Check TX DC offset = " + Double_To_AnsiString(d_OOS_Check) +
- ", Max TX DC offset = " + Double_To_AnsiString( m_dTX_IQ_DC_OFFSET_MAX )
- );
- result.b_oos_out_of_range = true;
- }
- else
- {
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " PASS: TX IQ calibration." +
- " , Check TX DC offset = " + Double_To_AnsiString(d_OOS_Check) +
- ", Max TX DC offset = " + Double_To_AnsiString( m_dTX_IQ_DC_OFFSET_MAX )
- );
- }
- // TX IQ gain imbalnce check
- if (d_SBS_Check > m_dTX_IQ_GAIN_IMBALANCE_MAX)
- {
- // CalErrorHandler(WM_MF_RF_TX_IQ_CHECK_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: TX IQ calibration." +
- " , Check TX IQ gain imbalance = " + Double_To_AnsiString(d_SBS_Check) +
- ", Max TX IQ gain imbalance = " + Double_To_AnsiString( m_dTX_IQ_GAIN_IMBALANCE_MAX )
- );
- result.b_sbs_out_of_range = true;
- }
- else
- {
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " PASS: TX IQ calibration." +
- " , Check TX IQ gain imbalance = " + Double_To_AnsiString(d_SBS_Check) +
- ", Max TX IQ gain imbalance = " + Double_To_AnsiString( m_dTX_IQ_GAIN_IMBALANCE_MAX )
- );
- }
- STOP_RF
- result.d_oos = d_OOS_Check;
- result.d_sbs = d_SBS_Check;
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " ===================== TX IQ low band stage " + IntToStr(stage) + " check end ===================== "
- );
- }
- else // high band
- {
- if ((RF_ID_A60111A == m_pCal->ui_rf_id) ||
- (RF_ID_AERO2E == m_pCal->ui_rf_id) ||
- (RF_ID_MT6140A == m_pCal->ui_rf_id) ||
- (RF_ID_MT6140B == m_pCal->ui_rf_id) ||
- (RF_ID_MT6140C == m_pCal->ui_rf_id) ||
- (RF_ID_MT6140D == m_pCal->ui_rf_id)
- )
- {
- // bool b_out_of_range_high = false;
- double d_OOS_Check_h;
- double d_SBS_Check_h;
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " ===================== TX IQ high band stage " + IntToStr(stage) + " check begin =================== "
- );
- // set BBTxCfg2
- rf_bb_tx_cfg_req.TxTrimI = iq.trim_IQ.I;
- rf_bb_tx_cfg_req.TxTrimQ = iq.trim_IQ.Q;
- rf_bb_tx_cfg_req.TxOffsetI = iq.offset_IQ.I;
- rf_bb_tx_cfg_req.TxOffsetQ = iq.offset_IQ.Q;
- rf_bb_tx_cfg_req.TxPhasesel = iq.c_TxPhasesel;
- m_cTXIQ_RUN_Obj.ConfirmCallback = ::CNF_MF;
- m_cTXIQ_RUN_Obj.REQ_SetBBTxCfg_Start(m_pCal->e_bbtxcfg_ver, rf_bb_tx_cfg_req);
- RestartTimerCal(WM_MF_RF_SET_BB_TX_CFG_FAIL);
- SUSPEND_CAL_THREAD
- if (m_cTXIQ_RUN_Obj.Get_ConfirmState() != METAAPP_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_SET_BB_TX_CFG_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < RF set BB TX CFG fail."
- );
- return false;
- }
- STOP_RF
- Sleep(50);
- int pcl[4];
- CodingScheme cs[4];
- APCTxPattern pattern;
- cs[0] = CodingSchemeMCS5;
- cs[1] = CodingSchemeMCS5;
- cs[2] = CodingSchemeMCS5;
- cs[3] = CodingSchemeMCS5;
- pcl[0] = m_sTX_IQ_PCL_HIGH;
- pcl[1] = m_sTX_IQ_PCL_HIGH;
- pcl[2] = m_sTX_IQ_PCL_HIGH;
- pcl[3] = m_sTX_IQ_PCL_HIGH;
- pattern = NB_TX_RANDOM_WITH_TSC;
- S_MULTI_SLOT_TX_T multi_slot_tx;
- multi_slot_tx.b_MultiSlotTXExSupport = m_pCal->b_MultiSlotTxExSupport;
- E_BANDSEL band_index = String_To_BandIdx(m_asTX_IQ_BAND_HIGH);
- multi_slot_tx.e_bandsel = band_index;
- multi_slot_tx.req.arfcn = m_sTX_IQ_ARFCN_HIGH;
- multi_slot_tx.req.bsic = m_cTSC;
- multi_slot_tx.req.timeSlotmask = 0x01;
- for (int i=0; i<4; i++)
- {
- multi_slot_tx.req.powerLev[i] = pcl[i];
- multi_slot_tx.req.cs[i] = cs[i];
- }
- multi_slot_tx.req.ta = 0;
- multi_slot_tx.req.frames = -99;
- multi_slot_tx.req.dacValue = m_sDefault_value;
- multi_slot_tx.req.pattern = pattern;
- multi_slot_tx.req.pattern_data = 0;
- RF_MULTI_SLOT_TX_Obj.ConfirmCallback = ::ConfirmCallback_MultiSlotTX;
- RF_MULTI_SLOT_TX_Obj.REQ_Start(multi_slot_tx);
- SUSPEND_CAL_THREAD
- if (RF_MULTI_SLOT_TX_Obj.Get_ConfirmState() != METAAPP_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_TX_LEVEL_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < multislot TX fail."
- );
- return false;
- }
- if (!m_rct_ctrl.RCT_Fetch_EPSK_Average_TxIq(m_pRct, &d_SBS_Check_h, &d_OOS_Check_h))
- {
- CalErrorHandler(WM_MF_AGE8960_FETCH_EPSK_OOS_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " + m_pRct->as_RCT + " > fetch EPSK original offset fail."
- );
- return false;
- }
- STOP_RF
- if (d_OOS_Check_h > m_dTX_IQ_DC_OFFSET_MAX_HIGH)
- {
- // CalErrorHandler(WM_MF_RF_TX_IQ_CHECK_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: TX IQ calibration." +
- " , Check high band TX DC offset = " + Double_To_AnsiString(d_OOS_Check_h) +
- ", Max TX DC offset = " + Double_To_AnsiString( m_dTX_IQ_DC_OFFSET_MAX_HIGH )
- );
- result.b_oos_out_of_range = true;
- }
- else
- {
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " PASS: TX IQ calibration." +
- " , Check high band TX DC offset = " + Double_To_AnsiString(d_OOS_Check_h) +
- ", Max TX DC offset = " + Double_To_AnsiString( m_dTX_IQ_DC_OFFSET_MAX_HIGH )
- );
- }
- // TX IQ gain imbalnce check
- if (d_SBS_Check_h > m_dTX_IQ_GAIN_IMBALANCE_MAX_HIGH)
- {
- // CalErrorHandler(WM_MF_RF_TX_IQ_CHECK_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: TX IQ calibration." +
- " , Check high band TX IQ gain imbalance = " + Double_To_AnsiString(d_SBS_Check_h) +
- ", Max TX IQ gain imbalance = " + Double_To_AnsiString(m_dTX_IQ_GAIN_IMBALANCE_MAX_HIGH)
- );
- result.b_sbs_out_of_range = true;
- }
- else
- {
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " PASS: TX IQ calibration." +
- " , Check high band TX IQ gain imbalance = " + Double_To_AnsiString(d_SBS_Check_h) +
- ", Max TX IQ gain imbalance = " + Double_To_AnsiString(m_dTX_IQ_GAIN_IMBALANCE_MAX_HIGH)
- );
- }
- result.d_oos = d_OOS_Check_h;
- result.d_sbs = d_SBS_Check_h;
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " ===================== TX IQ high band stage " + IntToStr(stage) + " check end ===================== "
- );
- }
- }
- return true;
- }
- //------------------------------------------------------------------------------
- ViReal64 __fastcall T_META_factory_calibration::get_TX_Original_Offset(ViReal64 *p_IQTFreqs, ViReal64 *p_IQTResults, ViInt32 IQTTuningCount)
- {
- for(int i=0; i<IQTTuningCount; i++)
- {
- if( *(p_IQTFreqs+i) == IQT_ORIGINAL_OFFSET_FREQ )
- {
- return *(p_IQTResults+i);
- }
- }
- return NAN;
- }