T_TXPCL_RFMD3159.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:16k
- /*****************************************************************************
- * 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_RFMD3159.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * RFMD 3159 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
- //==============================================================================
- bool __fastcall T_META_factory_calibration::TXPCLCal_EvalDac_RFMD3159_FixedPaBias(void)
- {
- AnsiString as_epsk_tx_pcl;
- AnsiString as_epsk_tx_4cal_pcl;
- AnsiString as_epsk_wanted_p;
- AnsiString as_epsk_correction;
- AnsiString as_epsk_sub_tx_pcl;
- AnsiString as_epsk_sub_tx_4cal_pcl;
- AnsiString as_epsk_sub_wanted_p;
- AnsiString as_epsk_sub_correction;
- unsigned short i_EPSK_PCL_Cal[MAX_SUPPORT_BAND_NUM][RF_TX_LEVEL_4_CAL_COUNT];
- double slope_epsk1[MAX_SUPPORT_BAND_NUM]; // DAC/dBm
- double slope_epsk2[MAX_SUPPORT_BAND_NUM]; // DAC/dBm
- unsigned short offset_epsk[MAX_SUPPORT_BAND_NUM]; // DAC/dB
- log->Add( "n" +DateToStr(Date()) + " " + CurrentTimeStr() +
- " =================== Evaluate PCL DAC value begin =================== "
- );
- RF_GetITC_PCL s_itc_pcl;
- META_RESULT MetaResult = META_QueryITC_PCL_r(m_pCal->i_MainMETAHandle, 1000, &s_itc_pcl);
- if (META_SUCCESS != MetaResult)
- {
- CalErrorHandler(WM_MF_RF_QUERY_ITC_PCL_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target > query modulator switch PCL"
- );
- return false;
- }
- unsigned short us_high_band_itc_pcl = (s_itc_pcl.pcl & 0xFFFF0000) >> 16;
- unsigned short us_low_band_itc_pcl = (s_itc_pcl.pcl & 0x0000FFFF);
- unsigned short us_itc_pcl;
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target > High band ITC PCL = " + IntToStr(us_high_band_itc_pcl) +
- ", Low band ITC PCL = " + IntToStr(us_low_band_itc_pcl)
- );
- 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_4cal_pcl = m_as_gsm850_epsk_tx_4cal_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;
- us_itc_pcl = us_low_band_itc_pcl;
- }
- break;
- case FrequencyBand900:
- {
- if (! IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- band_index = BANDSEL_GSM900;
- as_epsk_tx_4cal_pcl = m_as_gsm900_epsk_tx_4cal_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;
- us_itc_pcl = us_low_band_itc_pcl;
- }
- break;
- case FrequencyBand1800:
- {
- if (! IsFreqBankSupported( m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- band_index = BANDSEL_DCS1800;
- as_epsk_tx_4cal_pcl = m_as_dcs1800_epsk_tx_4cal_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;
- us_itc_pcl = us_high_band_itc_pcl;
- }
- break;
- case FrequencyBand1900:
- {
- if (! IsFreqBankSupported( m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- band_index = BANDSEL_PCS1900;
- as_epsk_tx_4cal_pcl = m_as_pcs1900_epsk_tx_4cal_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;
- us_itc_pcl = us_high_band_itc_pcl;
- }
- break;
- default:
- assert(false);
- break;
- } // switch
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- BandIdx_To_String(band_index)
- );
- for (int i=0; i<RF_TX_LEVEL_4_CAL_COUNT; i++)
- {
- // EPSK
- if (! getAnsiStrSubItem( as_epsk_tx_4cal_pcl, i+1, DEFAULT_SEP_CHAR, as_epsk_sub_tx_4cal_pcl) )
- {
- CalErrorHandler(WM_MF_CFG_READ_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(epsk_sub_tx_3cal_pcl)."
- );
- return false;
- }
- i_EPSK_PCL_Cal[band_index][i] = as_epsk_sub_tx_4cal_pcl.ToInt();
- }
- slope_epsk1[band_index] = (m_usPCLDacValue_EPSK[band_index][3]-m_usPCLDacValue_EPSK[band_index][2])/(m_dPCL_dBm_EPSK[band_index][3]-m_dPCL_dBm_EPSK[band_index][2]);
- slope_epsk2[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]);
- offset_epsk[band_index] = m_usPCLDacValue_EPSK[band_index][1]-(m_usPCLDacValue_EPSK[band_index][2]-(m_dPCL_dBm_EPSK[band_index][2]-m_dPCL_dBm_EPSK[band_index][1])*slope_epsk1[band_index]);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " slope_epsk1 = " + Double_To_AnsiString(slope_epsk1[band_index]) + " (DAC/dBm)" +
- ", slope_epsk2 = " + Double_To_AnsiString(slope_epsk2[band_index]) + " (DAC/dBm)" +
- ", offset_epsk = " + IntToStr(offset_epsk[band_index])
- );
- // Evaluate DAC except highest and lowest PCL
- 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;
- }
- unsigned short us_pcl;
- double d_wanted_p;
- double d_correction_p;
- // 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;
- }
- us_pcl = as_epsk_sub_tx_pcl.ToInt();
- // 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;
- }
- d_wanted_p = atof(as_epsk_sub_wanted_p.c_str());
- // 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;
- }
- d_correction_p = atof(as_epsk_sub_correction.c_str());
- // 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] &&
- as_epsk_sub_tx_pcl.ToInt() != i_EPSK_PCL_Cal[band_index][PCL_HIGH_INDEX] &&
- as_epsk_sub_tx_pcl.ToInt() != i_EPSK_PCL_Cal[band_index][PCL_HIGH_INDEX+1]
- )
- {
- if (us_pcl <= us_itc_pcl)
- {
- m_usPCLDacValue_ideal_EPSK[band_index][i] = m_usPCLDacValue_EPSK[band_index][3] - (m_dPCL_dBm_EPSK[band_index][3] - (d_wanted_p + d_correction_p)) * slope_epsk1[band_index];
- }
- else if (us_pcl == us_itc_pcl+1)
- {
- m_usPCLDacValue_ideal_EPSK[band_index][i] = m_usPCLDacValue_EPSK[band_index][3] - (m_dPCL_dBm_EPSK[band_index][3] - (d_wanted_p + d_correction_p)) * slope_epsk1[band_index] + offset_epsk[band_index];
- }
- else
- {
- m_usPCLDacValue_ideal_EPSK[band_index][i] = m_usPCLDacValue_EPSK[band_index][1] - (m_dPCL_dBm_EPSK[band_index][1] - (d_wanted_p + d_correction_p)) * slope_epsk2[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"
- );
- }
- }
- // 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;
- }