META_Factory_Result_Handle.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:17k
源码类别:
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:
- * ---------
- * META_Factory_Result_Handle.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * META factory result file handle 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 <vcl.h>
- #pragma hdrstop
- #include "meta_utils.h"
- #include "rf_agc.h"
- #include "rf_afc.h"
- #include "crystal_afc.h"
- #ifndef _RF_PM_H_
- #include "rf_pm.h"
- #endif
- #include "rf_apc.h"
- #ifndef _RF_TXIQ_H_
- #include "rf_txiq.h"
- #endif
- #include "bb_adc.h"
- #include "META_Factory.h"
- #pragma package(smart_init)
- extern CRFAFC* MF_rf_afc_ptr;
- extern CCRYSTALAFC* MF_crystal_afc_ptr;
- extern CRFAGC* MF_rf_agc_ptr;
- extern CRFPM* MF_rf_pm_ptr;
- extern CRFAPC* MF_rf_apc_ptr;
- extern CRFAPC8PSK* MF_rf_apc_8psk_ptr;
- extern CRFTXIQ* MF_rf_txiq_ptr;
- extern CBBADC* MF_BB_ADC_ptr;
- //==============================================================================
- bool __fastcall T_META_factory_calibration::Get_CalFilePathName(AnsiString asCalFile, AnsiString asExeName, bool b_CalResultPath, AnsiString& asPathName)
- {
- AnsiString asPath;
- if (b_CalResultPath)
- {
- asPath = m_pCal->as_CalPath + "\";
- }
- else
- {
- getPathFromStr(asExeName, asPath);
- }
- if (withPath(asPath) && !withPath(asCalFile))
- {
- asPathName = asPath + asCalFile;
- }
- else
- {
- return false;
- }
- return true;
- }
- //==============================================================================
- bool __fastcall T_META_factory_calibration::WriteIP2CalResultToFile(AnsiString asCalFile, AnsiString asExeName, bool b_CalResultPath, unsigned int rfmod_id, int band)
- {
- AnsiString asPath;
- if (b_CalResultPath)
- {
- asPath = m_pCal->as_CalPath + "\";
- }
- else
- {
- getPathFromStr(asExeName, asPath);
- }
- if (withPath(asPath) && !withPath(asCalFile))
- {
- asCalFile = asPath + asCalFile;
- }
- else
- {
- return false;
- }
- try
- {
- MF_rf_pm_ptr->REQ_Write_IP2Reg_To_File_Single_Band(asCalFile.c_str(), rfmod_id, band);
- return true;
- }
- catch (...)
- {
- ShowMessage(" Write : write calibration result file : " + asCalFile + " error ");
- }
- return true;
- }
- //==============================================================================
- bool __fastcall T_META_factory_calibration::WriteIP2RxAmCalModeToFile(AnsiString asCalFile, AnsiString asExeName, bool b_CalResultPath, unsigned int rfmod_id )
- {
- AnsiString asPath;
- if (b_CalResultPath)
- {
- asPath = m_pCal->as_CalPath + "\";
- }
- else
- {
- getPathFromStr(asExeName, asPath);
- }
- if (withPath(asPath) && !withPath(asCalFile))
- {
- asCalFile = asPath + asCalFile;
- }
- else
- {
- return false;
- }
- try
- {
- MF_rf_pm_ptr->REQ_Write_IP2Reg_RxAmCalMode_To_File(asCalFile.c_str(), rfmod_id);
- return true;
- }
- catch (...)
- {
- ShowMessage(" Write : write calibration result file : " + asCalFile + " error ");
- }
- return true;
- }
- //==============================================================================
- bool __fastcall T_META_factory_calibration::WriteAFCCalResultToFile(AnsiString asCalFile, AnsiString asExeName, bool b_CalResultPath)
- {
- AnsiString asPath;
- if (b_CalResultPath)
- {
- asPath = m_pCal->as_CalPath + "\";
- }
- else
- {
- getPathFromStr(asExeName, asPath);
- }
- if (withPath(asPath) && !withPath(asCalFile))
- {
- asCalFile = asPath + asCalFile;
- }
- try
- {
- MF_rf_afc_ptr->REQ_Write_To_File(asCalFile.c_str());
- return true;
- }
- catch (...)
- {
- ShowMessage(" Write : write calibration result file : " + asCalFile + " error ");
- }
- return true;
- }
- //=================================================================================================
- bool __fastcall T_META_factory_calibration::WriteCrystalAFCCalResultToFile(AnsiString asCalFile, AnsiString asExeName, bool b_CalResultPath)
- {
- AnsiString asPath;
- if (b_CalResultPath)
- {
- asPath = m_pCal->as_CalPath + "\";
- }
- else
- {
- getPathFromStr(asExeName, asPath);
- }
- if ( withPath( asPath) && !withPath( asCalFile) )
- {
- asCalFile = asPath + asCalFile;
- }
- else
- {
- return false;
- }
- try
- {
- MF_crystal_afc_ptr->REQ_Write_CAPID_To_File( asCalFile.c_str() );
- return true;
- }
- catch (...)
- {
- ShowMessage( " Write : write calibration result file : " + asCalFile + " error ");
- }
- return true;
- }
- //==============================================================================
- bool __fastcall T_META_factory_calibration::WriteAGCCalResultToFile(AnsiString asCalFile, AnsiString asExeName, bool b_CalResultPath, FrequencyBand freqband)
- {
- AnsiString asPath;
- if (b_CalResultPath)
- {
- asPath = m_pCal->as_CalPath + "\";
- }
- else
- {
- getPathFromStr(asExeName, asPath);
- }
- if ( withPath( asPath) && !withPath( asCalFile) )
- {
- asCalFile = asPath + asCalFile;
- }
- else
- {
- return false;
- }
- try
- {
- MF_rf_agc_ptr->REQ_Write_To_File_Single_Band( asCalFile.c_str(), freqband);
- return true;
- }
- catch (...)
- {
- ShowMessage( " Write : write calibration result file : " + asCalFile + " error ");
- }
- return true;
- }
- //=================================================================================================
- bool __fastcall T_META_factory_calibration::WriteTxDcOffsetCalResultToFile(AnsiString asCalFile, AnsiString asExeName, bool b_CalResultPath)
- {
- AnsiString asPath;
- if (b_CalResultPath)
- {
- asPath = m_pCal->as_CalPath + "\";
- }
- else
- {
- getPathFromStr(asExeName, asPath);
- }
- if ( withPath( asPath) && !withPath( asCalFile) )
- {
- asCalFile = asPath + asCalFile;
- }
- else
- {
- return false;
- }
- try
- {
- MF_rf_txiq_ptr->REQ_Write_To_File(asCalFile.c_str(), m_pCal->ui_rf_id, m_pCal->e_bbtxcfg_ver );
- return true;
- }
- catch (...)
- {
- ShowMessage( " Write : write calibration result file : " + asCalFile + " error ");
- }
- return true;
- }
- //=================================================================================================
- bool __fastcall T_META_factory_calibration::WriteAPCCalResultToFile(AnsiString asCalFile, AnsiString asExeName, bool b_CalResultPath, int band )
- {
- AnsiString asPath;
- if (b_CalResultPath)
- {
- asPath = m_pCal->as_CalPath + "\";
- }
- else
- {
- getPathFromStr(asExeName, asPath);
- }
- if ( withPath( asPath) && !withPath( asCalFile) )
- {
- asCalFile = asPath + asCalFile;
- }
- else
- {
- return false;
- }
- try
- {
- MF_rf_apc_ptr->REQ_Write_APC_To_File_Single_Band(asCalFile.c_str(), m_pCal->ui_rf_id, band, m_pCal->b_TADOSupport );
- return true;
- }
- catch (...)
- {
- ShowMessage( " Write : write calibration result file : " + asCalFile + " error ");
- }
- return true;
- }
- //=================================================================================================
- bool __fastcall T_META_factory_calibration::WriteEpskAPCCalResultToFile(AnsiString asCalFile, AnsiString asExeName, bool b_CalResultPath, int band )
- {
- AnsiString asPath;
- if (b_CalResultPath)
- {
- asPath = m_pCal->as_CalPath + "\";
- }
- else
- {
- getPathFromStr(asExeName, asPath);
- }
- if ( withPath( asPath) && !withPath( asCalFile) )
- {
- asCalFile = asPath + asCalFile;
- }
- else
- {
- return false;
- }
- try
- {
- MF_rf_apc_8psk_ptr->REQ_Write_APC_To_File_Single_Band(asCalFile.c_str(), m_pCal->ui_rf_id, band);
- return true;
- }
- catch (...)
- {
- ShowMessage( " Write : write calibration result file : " + asCalFile + " error ");
- }
- return true;
- }
- //=================================================================================================
- bool __fastcall T_META_factory_calibration::WriteTxPhaseErrCalResultToFile(AnsiString asCalFile, AnsiString asExeName, bool b_CalResultPath)
- {
- AnsiString asPath;
- if (b_CalResultPath)
- {
- asPath = m_pCal->as_CalPath + "\";
- }
- else
- {
- getPathFromStr(asExeName, asPath);
- }
- if ( withPath( asPath) && !withPath( asCalFile) )
- {
- asCalFile = asPath + asCalFile;
- }
- else
- {
- return false;
- }
- try
- {
- #if 0
- S_BB_TX_PARAMETER_ACCESS s_BBTXParAccess;
- s_BBTXParAccess.b_bbtx_common_mode_voltage = true;
- s_BBTXParAccess.b_bbtx_gain = true;
- s_BBTXParAccess.b_bbtx_calrcsel = true;
- s_BBTXParAccess.b_bbtx_trimI = true;
- s_BBTXParAccess.b_bbtx_trimQ = true;
- s_BBTXParAccess.b_bbtx_offsetI = true;
- s_BBTXParAccess.b_bbtx_offsetQ = true;
- s_BBTXParAccess.b_bbtx_isCalibrated = true;
- s_BBTXParAccess.b_apc_bat_low_voltage = true;
- s_BBTXParAccess.b_apc_bat_high_voltage = true;
- s_BBTXParAccess.b_apc_bat_low_temperature = true;
- s_BBTXParAccess.b_apc_bat_high_temperature = true;
- // high band
- bool flag = ((RF_ID_MT6140C == m_Cal.ui_rf_id) || (RF_ID_MT6140C == m_Cal.ui_rf_id));
- s_BBTXParAccess.b_bbtx_common_mode_voltage_h = flag;
- s_BBTXParAccess.b_bbtx_gain_h = flag;
- s_BBTXParAccess.b_bbtx_calrcsel_h = flag;
- s_BBTXParAccess.b_bbtx_trimI_h = flag;
- s_BBTXParAccess.b_bbtx_trimQ_h = flag;
- s_BBTXParAccess.b_bbtx_offsetI_h = flag;
- s_BBTXParAccess.b_bbtx_offsetQ_h = flag;
- // s_BBTXParAccess.b_bbtx_isCalibrated_h = flag;
- s_BBTXParAccess.b_bbtx_phsel_h = flag;
- #endif
- MF_rf_txiq_ptr->REQ_Write_To_File( asCalFile.c_str(), m_pCal->ui_rf_id, m_pCal->e_bbtxcfg_ver );
- return true;
- }
- catch (...)
- {
- ShowMessage( " Write : write calibration result file : " + asCalFile + " error ");
- }
- return true;
- }
- //=================================================================================================
- bool __fastcall T_META_factory_calibration::WriteADCCalResultToFile(AnsiString asCalFile, AnsiString asExeName, bool b_CalResultPath)
- {
- AnsiString asPath;
- if (b_CalResultPath)
- {
- asPath = m_pCal->as_CalPath + "\";
- }
- else
- {
- getPathFromStr(asExeName, asPath);
- }
- if ( withPath( asPath) && !withPath( asCalFile))
- {
- asCalFile = asPath + asCalFile;
- }
- else
- {
- return false;
- }
- try
- {
- MF_BB_ADC_ptr->REQ_Write_To_File( asCalFile.c_str() );
- return true;
- }
- catch (...)
- {
- ShowMessage( " Write : write calibration result file : " + asCalFile + " error ");
- }
- return true;
- }
- //==============================================================================
- bool __fastcall T_META_factory_calibration::WriteBtCapIDCalResultToFile(AnsiString asCalFile, AnsiString asExeName, bool b_CalResultPath, BT_ModuleID_S bt_module)
- {
- AnsiString asPathName;
- if (!Get_CalFilePathName(asCalFile, asExeName, b_CalResultPath, asPathName))
- {
- return false;
- }
- return true;
- }
- //==============================================================================
- bool __fastcall T_META_factory_calibration::WriteWiFiAPCCalResultToFile(AnsiString asCalFile, AnsiString asExeName, bool b_CalResultPath, E_WIFI_GENERATION e_802_11_idx )
- {
- AnsiString asPath;
- if (b_CalResultPath)
- {
- asPath = m_pCal->as_CalPath + "\";
- }
- else
- {
- getPathFromStr(asExeName, asPath);
- }
- if ( withPath( asPath) && !withPath( asCalFile) )
- {
- asCalFile = asPath + asCalFile;
- }
- else
- {
- return false;
- }
- switch (e_802_11_idx )
- {
- case WIFI_802_11A_IDX:
- {
- if( ! m_pCal->s_cal_obj.pc_WIFI_APC_Obj->REQ_Write_TxPower5000M_To_File( asCalFile.c_str() ) )
- { return false;
- }
- }
- break;
- case WIFI_802_11B_IDX:
- {
- if( ! m_pCal->s_cal_obj.pc_WIFI_APC_Obj->REQ_Write_TxPower2400M_To_File( asCalFile.c_str() ) )
- { return false;
- }
- }
- break;
- case WIFI_802_11G_IDX:
- {
- if( ! m_pCal->s_cal_obj.pc_WIFI_APC_Obj->REQ_Write_TxPower2400M_To_File( asCalFile.c_str() ) )
- { return false;
- }
- }
- break;
- default:
- return false;
- }
- return true;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- bool __fastcall T_META_factory_calibration::WriteWiFiALCCalResultToFile(AnsiString asCalFile, AnsiString asExeName, bool b_CalResultPath)
- {
- AnsiString asPath;
- if ( b_CalResultPath )
- {
- asPath = m_pCal->as_CalPath + "\";
- }
- else
- {
- getPathFromStr(asExeName, asPath);
- }
- if (withPath(asPath) && !withPath(asCalFile))
- {
- asCalFile = asPath + asCalFile;
- }
- else
- {
- return false;
- }
- if (!m_pCal->s_cal_obj.pc_WIFI_ALC_Obj->REQ_Write_To_File(asCalFile.c_str()))
- {
- return false;
- }
- return true;
- }
- //=============================================================================
- bool __fastcall T_META_factory_calibration::WriteWiFiTxDcOffsetCalResultToFile(AnsiString asCalFile, AnsiString asExeName, bool b_CalResultPath)
- {
- AnsiString asPath;
- if ( b_CalResultPath )
- {
- asPath = m_pCal->as_CalPath + "\";
- }
- else
- {
- getPathFromStr(asExeName, asPath);
- }
- if ( withPath( asPath) && !withPath( asCalFile) )
- {
- asCalFile = asPath + asCalFile;
- }
- else
- {
- return false;
- }
- if (! m_pCal->s_cal_obj.pc_WIFI_TXDC_Obj->REQ_Write_To_File(asCalFile.c_str() ))
- { return false;
- }
- return true;
- }