T_WiFi_TxDcOffset.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:6k
- /*****************************************************************************
- * 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_WiFi_TxDcOffset.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * WiFi TX DC offset 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_META_FACTORY_CALIBRATION_H_
- #include "T_META_factory_calibration.H"
- #endif
- #ifndef _CAL_COMMON_H_
- #include "cal_common.h"
- #endif
- // form
- #ifndef _META_FACTORY_H_
- #include "META_Factory.h"
- #endif
- #ifndef _FORM_MAIN_H_
- #include "form_Main.h"
- #endif
- // misc
- #ifndef _TIME_UTILS_H_
- #include "time_utils.h"
- #endif
- #ifndef _MISC_WIFI_H_
- #include "misc_wifi.h"
- #endif
- // WiFi
- #ifndef _WIFI_TXDC_H_
- #include "wifi_txdc.h"
- #endif
- // callback
- #ifndef _META_FACTORY_NVRAM_CB_H_
- #include "meta_factory_nvram_cb.h"
- #endif
- #ifndef _MF_WIFI_RF_CB_H_
- #include "mf_wifi_rf_cb.h"
- #endif
- #ifndef _MF_WIFI_NVRAM_CB_H_
- #include "mf_wifi_nvram_cb.h"
- #endif
- //----------------------------------------------------------------------------
- extern bool is_suspend_cal; // in T_META_factory_calibration.cpp
- //----------------------------------------------------------------------------
- bool __fastcall T_META_factory_calibration::WiFiTxDcOffsetCal( void )
- {
- char tempbuf[256];
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " ====================== WiFi TX DC offset calibration begin ===================== "
- );
- PostMessage(
- ctrl.hPostMsgDestHandle,
- WM_MF_WIFI_TX_DC_OFFSET_BEGIN,
- 0,
- 0
- );
- m_pCal->s_cal_obj.pc_WIFI_TXDC_Obj->ConfirmCallback = ::CNF_MF_TxDcOffsetCal;
- m_pCal->s_cal_obj.pc_WIFI_TXDC_Obj->REQ_TxDcOffsetCal_Start();
- RestartTimerCal( WM_MF_WIFI_TX_DC_OFFSET_FAIL );
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- E_METAAPP_RESULT_T state = m_pCal->s_cal_obj.pc_WIFI_TXDC_Obj->Get_ConfirmState();
- if (state != METAAPP_SUCCESS)
- {
- CalErrorHandler( WM_MF_WIFI_TX_DC_OFFSET_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < WiFi TX DC offset fail."
- );
- return false;
- }
- WiFi_DAC_DC_Offset_S sTxDcOffset = m_pCal->s_cal_obj.pc_WIFI_TXDC_Obj->Get_TxDcOffset();
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " I Offset = " + IntToStr( sTxDcOffset.i_ch_offset ) +
- ", Q Offset = " + IntToStr( sTxDcOffset.q_ch_offset)
- );
- WriteWiFiTxDcOffsetCalResultToFile(as_ID+".cal",Application->ExeName, m_pCal->b_CalResultPath);
- sprintf(tempbuf, "%8d", sTxDcOffset.i_ch_offset );
- m_pCal->as_ResultBuf = m_pCal->as_ResultBuf + tempbuf + ", ";
- sprintf(tempbuf, "%8d", sTxDcOffset.q_ch_offset );
- m_pCal->as_ResultBuf = m_pCal->as_ResultBuf + tempbuf + ", ";
- m_pCal->s_cal_obj.pc_WIFI_TXDC_Obj->ConfirmCallback = ::CNF_MF_WriteToNVRAM;
- m_pCal->s_cal_obj.pc_WIFI_TXDC_Obj->REQ_Write_To_NVRAM_Start();
- RestartTimerCal( WM_MF_WIFI_TX_DC_OFFSET_FAIL );
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- state = m_pCal->s_cal_obj.pc_WIFI_TXDC_Obj->Get_ConfirmState();
- if (state != METAAPP_SUCCESS)
- {
- if (METAAPP_NVRAM_LID_VER_NOT_SUPPORT == state)
- {
- CalErrorHandler(WM_MF_NVRAM_EF_WNDRV_DAC_DC_OFFSET_LID_VERNO_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : NVRAM_EF_WNDRV_DAC_DC_OFFSET_LID version is not support, please update META to latest version. "
- );
- }
- else
- {
- CalErrorHandler(WM_MF_NVRAM_WIFI_TX_DC_OFFSET_WRITE_FAIL);
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target< Write WiFi TX DC offset to flash "
- );
- }
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target< Write WiFi TX DC offset to flash "
- );
- PostMessage(
- ctrl.hPostMsgDestHandle,
- WM_MF_WIFI_TX_DC_OFFSET_CALIBRATION_DONE,
- 0,
- 0
- );
- log->Add( "n" + DateToStr(Date()) + " "+ CurrentTimeStr() +
- " WiFi TX power calibration done! n"
- );
- frmFatcory->DisableAllCalTimer();
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " ====================== WiFi TX DC offset calibration end ===================== "
- );
- return true;
- }