📄 t_wifi_txpcl.cpp
字号:
/*****************************************************************************
* 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_TXPCL.cpp
*
* Project:
* --------
* Maui META APP
*
* Description:
* ------------
* WiFi TXPCL 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
#ifndef _FT_UTILS_H_
#include "ft_utils.h"
#endif
// callback
#ifndef _MF_WIFI_NVRAM_CB_H_
#include "mf_wifi_nvram_cb.h"
#endif
#ifndef _MF_WIFI_RF_CB_H_
#include "mf_wifi_rf_cb.h"
#endif
//----------------------------------------------------------------------------
extern bool is_suspend_cal; // in T_META_factory_calibration.cpp
//----------------------------------------------------------------------------
bool __fastcall T_META_factory_calibration::WiFiTxPclCal_cal(void)
{
char tempbuf[256];
log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
" ====================== WiFi TX power calibration begin ===================== "
);
PostMessage(
ctrl.hPostMsgDestHandle,
WM_MF_WIFI_TX_POWER_BEGIN,
0,
0
);
// m_pWft->rx.gain = -60;
if( IQVIEW == m_pWft->device_type )
{
m_pWft->iqv.p_handle->tx.rf_enabled = IQV_RF_DISABLED;
m_pWft->iqv.p_handle->rx.rf_enabled = IQV_RF_ENABLED;
m_pWft->iqv.p_handle->rx.rf_port = IQV_PORT_LEFT;
m_pWft->iqv.p_handle->rx.vsa_type = 1;
}
S_WIFICPT wifi_cpt;
double virTX;
WiFi_TestPktTx_Ex_S pkt_tx_ex;
WiFi_TxStatus_Ex_S pkt_tx_ex_status;
wifi_cpt.wifi_id = m_pCal->s_wifi_cap.rf_chip_id;
wifi_cpt.reg_domain.country_code[0] = 'U';
wifi_cpt.reg_domain.country_code[1] = 'S';;
wifi_cpt.pkt_length = 1024;
wifi_cpt.pkt_count = 0;
wifi_cpt.pkt_interval = 100;
wifi_cpt.pattern = WIFI_TX_PSEUDO_RANDOM;
wifi_cpt.is_short_preamble = 0;
wifi_cpt.s_mac_header.frame_ctrl[0] = 0x02;
wifi_cpt.s_mac_header.frame_ctrl[1] = 0x08;
wifi_cpt.s_mac_header.duration[0] = 0x00;
wifi_cpt.s_mac_header.duration[1] = 0x00;
wifi_cpt.s_mac_header.address1[0] = 0xFF;
wifi_cpt.s_mac_header.address1[1] = 0xFF;
wifi_cpt.s_mac_header.address1[2] = 0xFF;
wifi_cpt.s_mac_header.address1[3] = 0xFF;
wifi_cpt.s_mac_header.address1[4] = 0xFF;
wifi_cpt.s_mac_header.address1[5] = 0xFF;
wifi_cpt.s_mac_header.address2[0] = 0x01;
wifi_cpt.s_mac_header.address2[1] = 0x00;
wifi_cpt.s_mac_header.address2[2] = 0x00;
wifi_cpt.s_mac_header.address2[3] = 0x22;
wifi_cpt.s_mac_header.address2[4] = 0x08;
wifi_cpt.s_mac_header.address2[5] = 0x00;
wifi_cpt.s_mac_header.address3[0] = 0xFF;
wifi_cpt.s_mac_header.address3[1] = 0xFF;
wifi_cpt.s_mac_header.address3[2] = 0xFF;
wifi_cpt.s_mac_header.address3[3] = 0xFF;
wifi_cpt.s_mac_header.address3[4] = 0xFF;
wifi_cpt.s_mac_header.address3[5] = 0xFF;
wifi_cpt.s_mac_header.seq_ctrl[0] = 0x00;
wifi_cpt.s_mac_header.seq_ctrl[1] = 0x00;
pkt_tx_ex.pktCount = wifi_cpt.pkt_count;
pkt_tx_ex.pktInterval = wifi_cpt.pkt_interval;
pkt_tx_ex.pktLength = wifi_cpt.pkt_length;
pkt_tx_ex.pattern = wifi_cpt.pattern;
pkt_tx_ex.is_short_preamble = wifi_cpt.is_short_preamble;
int max_ch_num;
AnsiString as_cal_channel;
int nvram_ch_idx;
S_WIFI_CH_FREQ_MHZ s_cal_ch_freq_mhz;
double d_max_p;
double d_min_p;
double d_WANTED_P;
double d_Delta;
double d_CL;
double d_n4010a_power_range;
int i_C;
E_WIFI_MOD mod;
E_WIFI_GENERATION e_802_11_idx = WIFI_802_11A_IDX;
while (e_802_11_idx <= WIFI_802_11G_IDX)
{
switch(e_802_11_idx)
{
case WIFI_802_11A_IDX:
{
if (! IsWiFiSupported( m_asWiFi_Support, e_802_11_idx) )
{
e_802_11_idx++;
continue;
}
as_cal_channel = m_as802_11G_CAL_CHANNEL;
max_ch_num = NUM_TX_POWER_5000M_CH;
d_WANTED_P = m_dOFDM_WANTED_P;
d_max_p = m_dOFDM_MAX_P;
d_min_p = m_dOFDM_MIN_P;
d_Delta = m_dOFDM_Delta;
i_C = m_iOFDM_C;
mod = WIFI_MOD_OFDM;
if( IQVIEW == m_pWft->device_type )
{
d_CL = m_pWft->iqv.d_5g_cl;
m_pWft->iqv.p_handle->rx.ampl = m_dOFDM_WANTED_P + 10;
m_pWft->iqv.p_handle->adc.sampling_time = 0.001;
}
else
{
d_CL = m_pWft->s_age_n4010a.d_5g_cl;
d_n4010a_power_range = m_dOFDM_WANTED_P + 5;
}
wifi_cpt.tx_rate = m_eOFDM_CAL_RATE;
}
break;
case WIFI_802_11B_IDX:
{
if (! IsWiFiSupported( m_asWiFi_Support, e_802_11_idx) )
{
e_802_11_idx++;
continue;
}
as_cal_channel = m_as802_11B_CAL_CHANNEL;
max_ch_num = NUM_TX_POWER_2400M_CH;
d_WANTED_P = m_dCCK_WANTED_P;
d_max_p = m_dCCK_MAX_P;
d_min_p = m_dCCK_MIN_P;
d_Delta = m_dCCK_Delta;
i_C = m_iCCK_C;
mod = WIFI_MOD_CCK;
if( IQVIEW == m_pWft->device_type )
{
d_CL = m_pWft->iqv.d_2_4g_cl;
m_pWft->iqv.p_handle->rx.ampl = m_dCCK_WANTED_P + 2;
m_pWft->iqv.p_handle->adc.sampling_time = 0.005;
}
else
{
d_CL = m_pWft->s_age_n4010a.d_2_4g_cl;
d_n4010a_power_range = m_dCCK_WANTED_P + 5;
}
wifi_cpt.tx_rate = m_eCCK_CAL_RATE;
}
break;
case WIFI_802_11G_IDX:
{
if (! IsWiFiSupported( m_asWiFi_Support, e_802_11_idx) )
{
e_802_11_idx++;
continue;
}
as_cal_channel = m_as802_11G_CAL_CHANNEL;
max_ch_num = NUM_TX_POWER_2400M_CH;
d_WANTED_P = m_dOFDM_WANTED_P;
d_max_p = m_dOFDM_MAX_P;
d_min_p = m_dOFDM_MIN_P;
d_Delta = m_dOFDM_Delta;
i_C = m_iOFDM_C;
mod = WIFI_MOD_OFDM;
if( IQVIEW == m_pWft->device_type )
{
d_CL = m_pWft->iqv.d_2_4g_cl;
m_pWft->iqv.p_handle->rx.ampl = m_dOFDM_WANTED_P + 10;
m_pWft->iqv.p_handle->adc.sampling_time = 0.001;
}
else
{
d_CL = m_pWft->s_age_n4010a.d_2_4g_cl;
d_n4010a_power_range = m_dOFDM_WANTED_P + 5;
}
wifi_cpt.tx_rate = m_eOFDM_CAL_RATE;
}
break;
default:
assert(false);
break;
} // switch
log->Add( "\n" + DateToStr(Date()) + " " + CurrentTimeStr() +
" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
);
if( ! m_wft_ctrl.WFT_SetTriggerStyle( m_pWft ) )
{
PostMessage(
ctrl.hPostMsgDestHandle,
WM_MF_WIFI_SET_TRIGGER_STYLE_FAIL,
0,
0
);
log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
" WiFi tester sets trigger style fail "
);
return false;
}
if( ! m_wft_ctrl.WFT_SetPowerRange( m_pWft, d_n4010a_power_range ) )
{
PostMessage(
ctrl.hPostMsgDestHandle,
WM_MF_WIFI_SET_POWER_RANGE_FAIL,
0,
0
);
log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
" WiFi tester < power range = " + Double_To_AnsiString( d_n4010a_power_range ) + " dBm fail"
);
return false;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -