T_TXPCL_Skyworks77316.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:45k
源码类别:
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_TXPCL_Skyworks74046.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * Skyworks 74046 TX PCL 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
- #ifndef _APCCAL_COMMON_H_
- #include "apccal_common.h"
- #endif
- #ifndef _RF_APC_H_
- #include "rf_apc.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
- // form
- #ifndef _META_FACTORY_H_
- #include "META_Factory.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 _BAND_UTILS_H_
- #include "band_utils.h"
- #endif
- #ifndef _TIME_UTILS_H_
- #include "time_utils.h"
- #endif
- //----------------------------------------------------------------------------
- extern CRFAPC* MF_rf_apc_ptr;
- extern CRFAPC8PSK* MF_rf_apc_8psk_ptr;
- extern RfNbtx_Req *MF_rf_tx_level_req;
- extern bool MF_rf_tx_level_cnf;
- extern bool is_suspend_cal; // in T_META_factory_calibration.cpp
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ///////////////////////////// Skyworks 77316 ///////////////////////
- //---------------------------------------------------------------------------
- bool __fastcall T_META_factory_calibration::TXPCLCal_EPSK_Skyworks77316_cal( void )
- {
- #if 0
- log->Add( "n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " ========== EPSK TX power control level calibration begin ========== n "
- );
- if( ! 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;
- }
- if( ! 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;
- }
- eFreqBand = FrequencyBand850;
- i_N_TX = -99; // TX frames
- //---------------------------------------------------------------------------
- while (eFreqBand < FrequencyBandCount)
- {
- switch ( eFreqBand )
- {
- case FrequencyBand850:
- {
- if (! IsFreqBankSupported( m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- FIRST_PCL = GSM850_FIRST_PCL;
- vi_Band = age1960_GSM850_BAND;
- band_index = BANDSEL_GSM850;
- s_ARFCN = m_sARFCN_C0_GSM850;
- i_TX_level_count = RF_RAMP_TABLE_TX_LEVEL_1_CAL_COUNT;
- as_epsk_tx_cal_pcl = as_gsm850_epsk_tx_2cal_pcl;
- as_epsk_tx_pcl = as_gsm850_epsk_tx_pcl;
- as_epsk_max_p = as_gsm850_epsk_max_p;
- as_epsk_wanted_p = as_gsm850_epsk_wanted_p;
- as_epsk_min_p = as_gsm850_epsk_min_p;
- as_epsk_c = as_gsm850_epsk_c;
- }
- break;
- case FrequencyBand900:
- {
- if (! IsFreqBankSupported( m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- FIRST_PCL = GSM900_FIRST_PCL;
- vi_Band = age1960_EGSM_BAND;
- band_index = BANDSEL_GSM900;
- s_ARFCN = m_sARFCN_C0_GSM;
- i_TX_level_count = RF_RAMP_TABLE_TX_LEVEL_2_CAL_COUNT;
- as_epsk_tx_2cal_pcl = as_gsm900_epsk_tx_2cal_pcl;
- as_epsk_tx_pcl = as_gsm900_epsk_tx_pcl;
- as_epsk_max_p = as_gsm900_epsk_max_p;
- as_epsk_wanted_p = as_gsm900_epsk_wanted_p;
- as_epsk_min_p = as_gsm900_epsk_min_p;
- as_epsk_c = as_gsm900_epsk_c;
- }
- break;
- case FrequencyBand1800:
- {
- if (! IsFreqBankSupported( m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- FIRST_PCL = DCS1800_FIRST_PCL;
- vi_Band = age1960_DCS1800_BAND;
- band_index = BANDSEL_DCS1800;
- s_ARFCN = m_sARFCN_C0_DCS;
- i_TX_level_count = RF_RAMP_TABLE_TX_LEVEL_2_CAL_COUNT;
- as_epsk_tx_2cal_pcl = as_dcs1800_epsk_tx_2cal_pcl;
- as_epsk_tx_pcl = as_dcs1800_epsk_tx_pcl;
- as_epsk_max_p = as_dcs1800_epsk_max_p;
- as_epsk_wanted_p = as_dcs1800_epsk_wanted_p;
- as_epsk_min_p = as_dcs1800_epsk_min_p;
- as_epsk_c = as_dcs1800_epsk_c;
- }
- break;
- case FrequencyBand1900:
- {
- if (! IsFreqBankSupported( m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- FIRST_PCL = PCS1900_FIRST_PCL;
- vi_Band = age1960_PCS1900_BAND;
- band_index = BANDSEL_PCS1900;
- s_ARFCN = m_sARFCN_C0_PCS;
- i_TX_level_count = RF_RAMP_TABLE_TX_LEVEL_2_CAL_COUNT;
- as_epsk_tx_2cal_pcl = as_pcs1900_epsk_tx_2cal_pcl;
- as_epsk_tx_pcl = as_pcs1900_epsk_tx_pcl;
- as_epsk_max_p = as_pcs1900_epsk_max_p;
- as_epsk_wanted_p = as_pcs1900_epsk_wanted_p;
- as_epsk_min_p = as_pcs1900_epsk_min_p;
- as_epsk_c = as_pcs1900_epsk_c;
- }
- break;
- default:
- assert(false);
- break;
- } // switch
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( "n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
- );
- if(IsFreqBankSupported( m_asFreqBank, eFreqBand))
- {
- if( FrequencyBand1900 == eFreqBand )
- {
- if(META_Rf_SelectFrequencyBand1900_r( m_pCal->i_MainMETAHandle, 1, MF_SelectBand_cnf_cb, &MF_SelectBand_token, NULL) != META_SUCCESS)
- {
- CalErrorHandler( WM_MF_RF_TX_LEVEL_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_TX_LEVEL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: target < set Band1900 flag = 0"
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " target < set Band1900 flag = 0"
- );
- }
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- }
- if( ! rct_ctrl.RCT_cellBand( m_pRct, vi_Band ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_BAND_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : "+
- m_pRct->as_RCT + " < Band = " + ViBand_To_Str( vi_Band )
- );
- return false;
- }
- Sleep( 100 ); // wait Agilent 8960 cell band setup ready!
- // if Agilent 8960 not read, target will get error power!
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < Band = " + ViBand_To_Str( vi_Band )
- );
- short bch_arfcn = ::Get_SeperateChannel( vi_Band, s_ARFCN );
- if( ! rct_ctrl.RCT_BCHARFCN( m_pRct, bch_arfcn) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_BCH_ARFCN_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < BCH ARFCN = " + IntToStr( bch_arfcn )
- );
- return false;
- }
- if( ! rct_ctrl.RCT_PDTCHARFCN( m_pRct, s_ARFCN ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_PDTCH_ARFCN_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < PDTCH ARFCN = " + IntToStr( s_ARFCN )
- );
- return false;
- }
- if( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < PDTCH ARFCN = " + IntToStr( s_ARFCN )
- );
- if( ! 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;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < TSC = " + IntToStr( m_cTSC)
- );
- if( ! rct_ctrl.RCT_EPSK_TXPowerContOff( m_pRct ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_TX_POWER_CONT_OFF_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_pRct->as_RCT + " < set TX power continuous OFF "
- );
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- //log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " TimerCal->Enabled 8= " + IntToStr((int)frmFatcory->TimerCal->Enabled)
- // );
- RestartTimerCal( WM_MF_AGE8960_CONFIG_TX_POWER_FAIL );
- if( ! rct_ctrl.RCT_confTXPower_EPSK( m_pRct ) )
- {
- CalErrorHandler( WM_MF_AGE8960_CONFIG_TX_POWER_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_pRct->as_RCT + " < config TX power 1."
- );
- return false;
- }
- #endif
- return true;
- }
- //----------------------------------------------------------------------------
- bool __fastcall T_META_factory_calibration::TXPCLCal_EvalDac_Skyworks77316_GMSK( void )
- {
- AnsiString as_tx_pcl;
- AnsiString as_tx_2cal_pcl;
- AnsiString as_wanted_p;
- AnsiString as_correction;
- AnsiString as_sub_tx_pcl;
- AnsiString as_sub_tx_2cal_pcl;
- AnsiString as_sub_wanted_p;
- AnsiString as_sub_correction;
- // AnsiString as_epsk_tx_pcl;
- // AnsiString as_epsk_tx_2cal_pcl;
- // AnsiString as_epsk_wanted_p;
- // AnsiString as_epsk_correction;
- // AnsiString as_epsk_sub_tx_pcl;
- // AnsiString as_epsk_sub_tx_2cal_pcl;
- // AnsiString as_epsk_sub_wanted_p;
- // AnsiString as_epsk_sub_correction;
- unsigned short i_PCL_Cal[MAX_SUPPORT_BAND_NUM][CALIBRATIE_NUM_2PCL];
- // unsigned short i_EPSK_PCL_Cal[MAX_SUPPORT_BAND_NUM][CALIBRATIE_NUM_2PCL];
- double slope[MAX_SUPPORT_BAND_NUM]; // DAC/slope
- // double slope_epsk[MAX_SUPPORT_BAND_NUM]; // DAC/slope
- unsigned short offset[MAX_SUPPORT_BAND_NUM];
- // unsigned short offset_epsk[MAX_SUPPORT_BAND_NUM];
- log->Add("n" +DateToStr(Date()) + " " + CurrentTimeStr() +
- " =================== Evaluate GMSK PCL DAC value begin =================== "
- );
- E_BANDSEL band_index;
- FrequencyBand eFreqBand = FrequencyBand850;
- while (eFreqBand < FrequencyBandCount)
- {
- switch (eFreqBand)
- {
- case FrequencyBand850:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- band_index = BANDSEL_GSM850;
- as_tx_2cal_pcl = m_as_gsm850_tx_2cal_pcl;
- as_tx_pcl = m_as_gsm850_tx_pcl;
- as_wanted_p = m_as_gsm850_wanted_p;
- as_correction = m_as_gsm850_correction;
- //as_epsk_tx_2cal_pcl = m_as_gsm850_epsk_tx_2cal_pcl;
- //as_epsk_tx_pcl = m_as_gsm850_epsk_tx_pcl;
- //as_epsk_wanted_p = m_as_gsm850_epsk_wanted_p;
- //as_epsk_correction = m_as_gsm850_epsk_correction;
- }
- break;
- case FrequencyBand900:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- band_index = BANDSEL_GSM900;
- as_tx_2cal_pcl = m_as_gsm900_tx_2cal_pcl;
- as_tx_pcl = m_as_gsm900_tx_pcl;
- as_wanted_p = m_as_gsm900_wanted_p;
- as_correction = m_as_gsm900_correction;
- //as_epsk_tx_2cal_pcl = m_as_gsm900_epsk_tx_2cal_pcl;
- //as_epsk_tx_pcl = m_as_gsm900_epsk_tx_pcl;
- //as_epsk_wanted_p = m_as_gsm900_epsk_wanted_p;
- //as_epsk_correction = m_as_gsm900_epsk_correction;
- }
- break;
- case FrequencyBand1800:
- {
- if (! IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- band_index = BANDSEL_DCS1800;
- as_tx_2cal_pcl = m_as_dcs1800_tx_2cal_pcl;
- as_tx_pcl = m_as_dcs1800_tx_pcl;
- as_wanted_p = m_as_dcs1800_wanted_p;
- as_correction = m_as_dcs1800_correction;
- }
- break;
- case FrequencyBand1900:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- band_index = BANDSEL_PCS1900;
- as_tx_2cal_pcl = m_as_pcs1900_tx_2cal_pcl;
- as_tx_pcl = m_as_pcs1900_tx_pcl;
- as_wanted_p = m_as_pcs1900_wanted_p;
- as_correction = m_as_pcs1900_correction;
- }
- break;
- default:
- {
- assert(false);
- }
- break;
- } // switch
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- BandIdx_To_String(band_index)
- );
- for(int i=0; i<CALIBRATIE_NUM_2PCL; i++)
- {
- if (! getAnsiStrSubItem( as_tx_2cal_pcl, i+1, DEFAULT_SEP_CHAR, as_sub_tx_2cal_pcl) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_tx_cal_pcl)."
- );
- return false;
- }
- i_PCL_Cal[band_index][i] = as_sub_tx_2cal_pcl.ToInt();
- // EPSK
- // if (m_pCal->i_APC_mod & APC_MOD_EPSK)
- // {
- // if (! getAnsiStrSubItem( as_epsk_tx_2cal_pcl, i+1, DEFAULT_SEP_CHAR, as_epsk_sub_tx_2cal_pcl) )
- // {
- // CalErrorHandler(WM_MF_CFG_READ_FAIL);
- // log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- // " FAIL: Read config file fail(epsk_sub_tx_cal_pcl)."
- // );
- // return false;
- // }
- // i_EPSK_PCL_Cal[band_index][i] = as_epsk_sub_tx_2cal_pcl.ToInt();
- // }
- }
- offset[band_index] = m_usPCLDacValue[band_index][0];
- slope[band_index] = (m_usPCLDacValue[band_index][1]-m_usPCLDacValue[band_index][0])/(m_dPCL_dBm[band_index][1]-m_dPCL_dBm[band_index][0]);
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " slope = " + Double_To_AnsiString(slope[band_index]) + " (DAC/dBm)" +
- ", offset = " + IntToStr(offset[band_index])
- );
- // if (m_pCal->i_APC_mod & APC_MOD_EPSK)
- // {
- // offset_epsk[band_index] = m_usPCLDacValue_EPSK[band_index][0];
- // slope_epsk[band_index] = (m_usPCLDacValue_EPSK[band_index][1]-m_usPCLDacValue_EPSK[band_index][0])/(m_dPCL_dBm_EPSK[band_index][1]-m_dPCL_dBm_EPSK[band_index][0]);
- // log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- // " slope_epsk = " + Double_To_AnsiString(slope_epsk[band_index]) + " (DAC/dBm)" +
- // ", offset_epsk = " + IntToStr(offset_epsk[band_index])
- // );
- // }
- for(int i=0; i<RF_RAMP_TABLE_TX_LEVEL_COUNT; i++)
- {
- if( i==RF_RAMP_TABLE_TX_LEVEL_COUNT-1 &&
- (eFreqBand==FrequencyBand850 || eFreqBand==FrequencyBand900 )
- )
- {
- break;
- }
- if (! getAnsiStrSubItem( as_tx_pcl, i+1, DEFAULT_SEP_CHAR, as_sub_tx_pcl) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_tx_pcl)."
- );
- return false;
- }
- if (! getAnsiStrSubItem( as_wanted_p, i+1, DEFAULT_SEP_CHAR, as_sub_wanted_p) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_wanted_p)."
- );
- return false;
- }
- if (! getAnsiStrSubItem( as_correction, i+1, DEFAULT_SEP_CHAR, as_sub_correction) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(as_sub_correction)."
- );
- return false;
- }
- if( as_sub_tx_pcl.ToInt() != i_PCL_Cal[band_index][PCL_LOW_INDEX] &&
- as_sub_tx_pcl.ToInt() != i_PCL_Cal[band_index][PCL_MID_INDEX]
- )
- {
- m_usPCLDacValue_ideal[band_index][i] = (atof(as_sub_wanted_p.c_str()) + atof(as_sub_correction.c_str()) - m_dPCL_dBm[band_index][0]) * slope[band_index] + offset[band_index];
- // MF_rf_apc_ptr->ApcProfile[band_index].rampData.power[i] = m_usPCLDacValue_ideal[band_index][i];
- MF_rf_apc_ptr->Set_ApcProfilePower( band_index, i, m_usPCLDacValue_ideal[band_index][i] );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " " +
- " m_usPCLDacValue_ideal[" + IntToStr(band_index) + "][" + IntToStr(i) + "] = " +
- Double_To_AnsiString(m_usPCLDacValue_ideal[band_index][i]) + "n"
- );
- }
- }
- // Evaluate DAC except highest and lowest PCL
- // if (m_pCal->i_APC_mod & APC_MOD_EPSK)
- // {
- // for(int i=0; i<RF_RAMP_TABLE_TX_LEVEL_COUNT; i++)
- // {
- // if (i==RF_RAMP_TABLE_TX_LEVEL_COUNT-1 &&
- // (eFreqBand==FrequencyBand850 || eFreqBand==FrequencyBand900 )
- // )
- // {
- // break;
- // }
- //
- // EPSK
- // if (! getAnsiStrSubItem(as_epsk_tx_pcl, i+1, DEFAULT_SEP_CHAR, as_epsk_sub_tx_pcl))
- // {
- // CalErrorHandler(WM_MF_CFG_READ_FAIL);
- // log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " FAIL: Read config file fail(epsk_sub_tx_pcl)."
- // );
- // return false;
- // }
- //
- // // EPSK
- // if (! getAnsiStrSubItem( as_epsk_wanted_p, i+1, DEFAULT_SEP_CHAR, as_epsk_sub_wanted_p) )
- // {
- // CalErrorHandler(WM_MF_CFG_READ_FAIL);
- // log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- // " FAIL: Read config file fail(epsk_sub_wanted_p)."
- // );
- // return false;
- // }
- //
- // // EPSK
- // if (! getAnsiStrSubItem( as_epsk_correction, i+1, DEFAULT_SEP_CHAR, as_epsk_sub_correction) )
- // {
- // CalErrorHandler(WM_MF_CFG_READ_FAIL);
- // log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- // " FAIL: Read config file fail(as_epsk_sub_correction)."
- // );
- // return false;
- // }
- // // EPSK
- // if (as_epsk_sub_tx_pcl.ToInt() != i_EPSK_PCL_Cal[band_index][PCL_LOW_INDEX] &&
- // as_epsk_sub_tx_pcl.ToInt() != i_EPSK_PCL_Cal[band_index][PCL_MID_INDEX]
- // )
- // {
- // m_usPCLDacValue_ideal_EPSK[band_index][i] = (atof(as_epsk_sub_wanted_p.c_str()) + atof(as_epsk_sub_correction.c_str()) - m_dPCL_dBm_EPSK[band_index][0]) * slope_epsk[band_index] + offset_epsk[band_index];
- // MF_rf_apc_8psk_ptr->Set_ApcProfilePower( band_index, i, m_usPCLDacValue_ideal_EPSK[band_index][i] );
- // log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // // " " +
- // " m_usPCLDacValue_ideal_EPSK[" + IntToStr(band_index) + "][" + IntToStr(i) + "] = " +
- // Double_To_AnsiString(m_usPCLDacValue_ideal_EPSK[band_index][i]) + "n"
- // );
- // }
- // }
- //}
- MF_rf_apc_ptr->ConfirmCallback = ::ccb_write_apc_to_nvram;
- MF_rf_apc_ptr->REQ_Write_APC_To_NVRAM_Single_Band_Start(m_pCal->ui_rf_id, band_index, m_pCal->b_TADOSupport );
- RestartTimerCal( WM_MF_NVRAM_LEVEL_RAMP_WRITE_FAIL );
- CHECK_TERMINATE_BY_USER
- SUSPEND_CAL_THREAD
- 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 APC to NVRAM "
- );
- }
- return false;
- }
- WriteAPCCalResultToFile(as_ID+".cal",Application->ExeName, m_pCal->b_CalResultPath, FreqBand_To_BandIdx(eFreqBand) );
- // EPSK
- // if (m_pCal->i_APC_mod & APC_MOD_EPSK)
- // {
- // MF_rf_apc_8psk_ptr->ConfirmCallback = ::ccb_write_apc_to_nvram;
- // MF_rf_apc_8psk_ptr->REQ_Write_APC_To_NVRAM_Single_Band_Start(m_pCal->ui_rf_id, band_index, false);
- //
- // log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- // " Write to NVRAM band_index = " + IntToStr(band_index)
- // );
- //
- //
- // RestartTimerCal(WM_MF_NVRAM_LEVEL_RAMP_WRITE_FAIL);
- // CHECK_TERMINATE_BY_USER
- // SUSPEND_CAL_THREAD
- //
- // 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 APC to NVRAM "
- // );
- // }
- // return false;
- // }
- //
- // WriteEpskAPCCalResultToFile(as_ID+".cal",Application->ExeName, m_pCal->b_CalResultPath, FreqBand_To_BandIdx(eFreqBand) );
- // }
- eFreqBand++;
- } // while
- frmFatcory->DisableAllCalTimer();
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " ===================== Evaluate other PCL DAC value end =========== n "
- );
- return true;
- }
- //----------------------------------------------------------------------------
- bool __fastcall T_META_factory_calibration::TXPCLCal_EvalDac_Skyworks77316_EPSK(void)
- {
- //AnsiString as_tx_pcl;
- //AnsiString as_tx_2cal_pcl;
- //AnsiString as_wanted_p;
- //AnsiString as_correction;
- //AnsiString as_sub_tx_pcl;
- //AnsiString as_sub_tx_2cal_pcl;
- //AnsiString as_sub_wanted_p;
- //AnsiString as_sub_correction;
- AnsiString as_epsk_tx_pcl;
- AnsiString as_epsk_tx_2cal_pcl;
- AnsiString as_epsk_wanted_p;
- AnsiString as_epsk_correction;
- AnsiString as_epsk_sub_tx_pcl;
- AnsiString as_epsk_sub_tx_2cal_pcl;
- AnsiString as_epsk_sub_wanted_p;
- AnsiString as_epsk_sub_correction;
- //unsigned short i_PCL_Cal[MAX_SUPPORT_BAND_NUM][CALIBRATIE_NUM_2PCL];
- unsigned short i_EPSK_PCL_Cal[MAX_SUPPORT_BAND_NUM][CALIBRATIE_NUM_2PCL];
- // double slope[MAX_SUPPORT_BAND_NUM]; // DAC/slope
- double slope_epsk[MAX_SUPPORT_BAND_NUM]; // DAC/slope
- //unsigned short offset[MAX_SUPPORT_BAND_NUM];
- unsigned short offset_epsk[MAX_SUPPORT_BAND_NUM];
- log->Add( "n" +DateToStr(Date()) + " " + CurrentTimeStr() +
- " =================== Evaluate EPSK PCL DAC value begin =================== "
- );
- short s_ARFCN;
- E_BANDSEL band_index;
- FrequencyBand eFreqBand = FrequencyBand850;
- while (eFreqBand < FrequencyBandCount)
- {
- switch (eFreqBand)
- {
- case FrequencyBand850:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- band_index = BANDSEL_GSM850;
- as_epsk_tx_2cal_pcl = m_as_gsm850_epsk_tx_2cal_pcl;
- as_epsk_tx_pcl = m_as_gsm850_epsk_tx_pcl;
- as_epsk_wanted_p = m_as_gsm850_epsk_wanted_p;
- as_epsk_correction = m_as_gsm850_epsk_correction;
- }
- break;
- case FrequencyBand900:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- band_index = BANDSEL_GSM900;
- as_epsk_tx_2cal_pcl = m_as_gsm900_epsk_tx_2cal_pcl;
- as_epsk_tx_pcl = m_as_gsm900_epsk_tx_pcl;
- as_epsk_wanted_p = m_as_gsm900_epsk_wanted_p;
- as_epsk_correction = m_as_gsm900_epsk_correction;
- }
- break;
- case FrequencyBand1800:
- {
- if (! IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- band_index = BANDSEL_DCS1800;
- as_epsk_tx_2cal_pcl = m_as_dcs1800_epsk_tx_2cal_pcl;
- as_epsk_tx_pcl = m_as_dcs1800_epsk_tx_pcl;
- as_epsk_wanted_p = m_as_dcs1800_epsk_wanted_p;
- as_epsk_correction = m_as_dcs1800_epsk_correction;
- }
- break;
- case FrequencyBand1900:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- band_index = BANDSEL_PCS1900;
- as_epsk_tx_2cal_pcl = m_as_pcs1900_epsk_tx_2cal_pcl;
- as_epsk_tx_pcl = m_as_pcs1900_epsk_tx_pcl;
- as_epsk_wanted_p = m_as_pcs1900_epsk_wanted_p;
- as_epsk_correction = m_as_pcs1900_epsk_correction;
- }
- break;
- default:
- assert(false);
- break;
- } // switch
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- BandIdx_To_String(band_index)
- );
- for(int i=0; i<CALIBRATIE_NUM_2PCL; i++)
- {
- // if (! getAnsiStrSubItem( as_tx_2cal_pcl, i+1, DEFAULT_SEP_CHAR, as_sub_tx_2cal_pcl) )
- // {
- // CalErrorHandler( WM_MF_CFG_READ_FAIL );
- // log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " FAIL: Read config file fail(sub_tx_cal_pcl)."
- // );
- // return false;
- // }
- // i_PCL_Cal[band_index][i] = as_sub_tx_2cal_pcl.ToInt();
- // EPSK
- // if (m_pCal->i_APC_mod & APC_MOD_EPSK)
- {
- if (! getAnsiStrSubItem( as_epsk_tx_2cal_pcl, i+1, DEFAULT_SEP_CHAR, as_epsk_sub_tx_2cal_pcl) )
- {
- CalErrorHandler(WM_MF_CFG_READ_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(epsk_sub_tx_cal_pcl)."
- );
- return false;
- }
- i_EPSK_PCL_Cal[band_index][i] = as_epsk_sub_tx_2cal_pcl.ToInt();
- }
- }
- // offset[band_index] = m_usPCLDacValue[band_index][0];
- // slope[band_index] = (m_usPCLDacValue[band_index][1]-m_usPCLDacValue[band_index][0])/(m_dPCL_dBm[band_index][1]-m_dPCL_dBm[band_index][0]);
- // log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " slope = " + Double_To_AnsiString(slope[band_index]) + " (DAC/dBm)" +
- // ", offset = " + IntToStr(offset[band_index])
- // );
- // if (m_pCal->i_APC_mod & APC_MOD_EPSK)
- {
- offset_epsk[band_index] = m_usPCLDacValue_EPSK[band_index][0];
- slope_epsk[band_index] = (m_usPCLDacValue_EPSK[band_index][1]-m_usPCLDacValue_EPSK[band_index][0])/(m_dPCL_dBm_EPSK[band_index][1]-m_dPCL_dBm_EPSK[band_index][0]);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " slope_epsk = " + Double_To_AnsiString(slope_epsk[band_index]) + " (DAC/dBm)" +
- ", offset_epsk = " + IntToStr(offset_epsk[band_index])
- );
- }
- // for(int i=0; i<RF_RAMP_TABLE_TX_LEVEL_COUNT; i++)
- // {
- //
- // if( i==RF_RAMP_TABLE_TX_LEVEL_COUNT-1 &&
- // (eFreqBand==FrequencyBand850 || eFreqBand==FrequencyBand900 )
- // )
- // {
- // break;
- // }
- //
- // if (! getAnsiStrSubItem( as_tx_pcl, i+1, DEFAULT_SEP_CHAR, as_sub_tx_pcl) )
- // {
- // CalErrorHandler( WM_MF_CFG_READ_FAIL );
- // log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " FAIL: Read config file fail(sub_tx_pcl)."
- // );
- // return false;
- // }
- //
- // if (! getAnsiStrSubItem( as_wanted_p, i+1, DEFAULT_SEP_CHAR, as_sub_wanted_p) )
- // {
- // CalErrorHandler( WM_MF_CFG_READ_FAIL );
- // log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " FAIL: Read config file fail(sub_wanted_p)."
- // );
- // return false;
- // }
- //
- // if (! getAnsiStrSubItem( as_correction, i+1, DEFAULT_SEP_CHAR, as_sub_correction) )
- // {
- // CalErrorHandler( WM_MF_CFG_READ_FAIL );
- // log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " FAIL: Read config file fail(as_sub_correction)."
- // );
- // return false;
- // }
- //
- //
- // if( as_sub_tx_pcl.ToInt() != i_PCL_Cal[band_index][PCL_LOW_INDEX] &&
- // as_sub_tx_pcl.ToInt() != i_PCL_Cal[band_index][PCL_MID_INDEX]
- //
- // )
- // {
- // m_usPCLDacValue_ideal[band_index][i] = (atof(as_sub_wanted_p.c_str()) + atof(as_sub_correction.c_str()) - m_dPCL_dBm[band_index][0]) * slope[band_index] + offset[band_index];
- // // MF_rf_apc_ptr->ApcProfile[band_index].rampData.power[i] = m_usPCLDacValue_ideal[band_index][i];
- // MF_rf_apc_ptr->Set_ApcProfilePower( band_index, i, m_usPCLDacValue_ideal[band_index][i] );
- // log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // // " " +
- // " m_usPCLDacValue_ideal[" + IntToStr(band_index) + "][" + IntToStr(i) + "] = " +
- // Double_To_AnsiString(m_usPCLDacValue_ideal[band_index][i]) + "n"
- // );
- // }
- //
- //
- // }
- // Evaluate DAC except highest and lowest PCL
- // if (m_pCal->i_APC_mod & APC_MOD_EPSK)
- {
- for(int i=0; i<RF_RAMP_TABLE_TX_LEVEL_COUNT; i++)
- {
- if (i==RF_RAMP_TABLE_TX_LEVEL_COUNT-1 &&
- (eFreqBand==FrequencyBand850 || eFreqBand==FrequencyBand900 )
- )
- {
- break;
- }
- // EPSK
- if (! getAnsiStrSubItem(as_epsk_tx_pcl, i+1, DEFAULT_SEP_CHAR, as_epsk_sub_tx_pcl))
- {
- CalErrorHandler(WM_MF_CFG_READ_FAIL);
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(epsk_sub_tx_pcl)."
- );
- return false;
- }
- // EPSK
- if (! getAnsiStrSubItem( as_epsk_wanted_p, i+1, DEFAULT_SEP_CHAR, as_epsk_sub_wanted_p) )
- {
- CalErrorHandler(WM_MF_CFG_READ_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(epsk_sub_wanted_p)."
- );
- return false;
- }
- // EPSK
- if (! getAnsiStrSubItem( as_epsk_correction, i+1, DEFAULT_SEP_CHAR, as_epsk_sub_correction) )
- {
- CalErrorHandler(WM_MF_CFG_READ_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(as_epsk_sub_correction)."
- );
- return false;
- }
- // EPSK
- if (as_epsk_sub_tx_pcl.ToInt() != i_EPSK_PCL_Cal[band_index][PCL_LOW_INDEX] &&
- as_epsk_sub_tx_pcl.ToInt() != i_EPSK_PCL_Cal[band_index][PCL_MID_INDEX]
- )
- {
- m_usPCLDacValue_ideal_EPSK[band_index][i] = (atof(as_epsk_sub_wanted_p.c_str()) + atof(as_epsk_sub_correction.c_str()) - m_dPCL_dBm_EPSK[band_index][0]) * slope_epsk[band_index] + offset_epsk[band_index];
- MF_rf_apc_8psk_ptr->Set_ApcProfilePower( band_index, i, m_usPCLDacValue_ideal_EPSK[band_index][i] );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " " +
- " m_usPCLDacValue_ideal_EPSK[" + IntToStr(band_index) + "][" + IntToStr(i) + "] = " +
- Double_To_AnsiString(m_usPCLDacValue_ideal_EPSK[band_index][i]) + "n"
- );
- }
- }
- }
- // MF_rf_apc_ptr->ConfirmCallback = ::ccb_write_apc_to_nvram;
- // MF_rf_apc_ptr->REQ_Write_APC_To_NVRAM_Single_Band_Start(m_pCal->ui_rf_id, band_index, m_pCal->b_TADOSupport );
- // RestartTimerCal( WM_MF_NVRAM_LEVEL_RAMP_WRITE_FAIL );
- // CHECK_TERMINATE_BY_USER
- // SUSPEND_CAL_THREAD
- // 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 APC to NVRAM "
- // );
- // }
- // return false;
- // }
- // WriteAPCCalResultToFile(as_ID+".cal",Application->ExeName, m_pCal->b_CalResultPath, FreqBand_To_BandIdx(eFreqBand) );
- // EPSK
- if (m_pCal->i_APC_mod & APC_MOD_EPSK)
- {
- MF_rf_apc_8psk_ptr->ConfirmCallback = ::ccb_write_apc_to_nvram;
- MF_rf_apc_8psk_ptr->REQ_Write_APC_To_NVRAM_Single_Band_Start(m_pCal->ui_rf_id, band_index);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " Write to NVRAM band_index = " + IntToStr(band_index)
- );
- RestartTimerCal(WM_MF_NVRAM_LEVEL_RAMP_WRITE_FAIL);
- CHECK_TERMINATE_BY_USER
- SUSPEND_CAL_THREAD
- 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 APC to NVRAM "
- );
- }
- return false;
- }
- WriteEpskAPCCalResultToFile(as_ID+".cal",Application->ExeName, m_pCal->b_CalResultPath, FreqBand_To_BandIdx(eFreqBand) );
- }
- eFreqBand++;
- } // while
- frmFatcory->DisableAllCalTimer();
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " ===================== Evaluate other PCL DAC value end =========== n "
- );
- return true;
- }