⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 t_wifi_txpcl.cpp

📁 MTK 手机软件开发 META 源代码,开发环境: C++ Builder
💻 CPP
📖 第 1 页 / 共 4 页
字号:
                int second_ch_index;
                double d_slope;
                double d_offset;
                nvram_ch_idx = GetWiFiNVRAMChannelIndex(e_802_11_idx, s_remain_ch_freq_mhz.ch_freq_MHz[i]);
                if ((int)NOT_FOUND == nvram_ch_idx)
                {
                    PostMessage(ctrl.hPostMsgDestHandle,
                                WM_MF_WIFI_CHANNEL_INDEX_NOT_FOUND_FAIL,
                                0,
                                0
                               );
                    log->Add(DateToStr(Date()) +  " " + CurrentTimeStr() +
                              " WiFi Channel index not found fail, channel = " + IntToStr(s_remain_ch_freq_mhz.ch_freq_MHz[i]) + " MHz fail"
                            );
                    return false;
                }

                if (!GetWiFiTwoClosetNVRAMChannelIndex(e_802_11_idx, s_remain_ch_freq_mhz.ch_freq_MHz[i], s_cal_ch_freq_mhz, first_ch_index, second_ch_index))
                {
                    PostMessage(ctrl.hPostMsgDestHandle,
                                WM_MF_WIFI_CHANNEL_INDEX_NOT_FOUND_FAIL,
                                0,
                                0
                               );
                    log->Add(DateToStr(Date()) +  " " + CurrentTimeStr() +
                              " Two closest WiFi Channel index not found fail, channel = " + IntToStr(s_remain_ch_freq_mhz.ch_freq_MHz[i]) + " MHz fail"
                            );
                    return false;
                }
                unsigned char uc_first_dac  = m_pCal->s_cal_obj.pc_WIFI_APC_Obj->Get_TxPowerDac(e_802_11_idx, mod, first_ch_index);
                unsigned char uc_second_dac = m_pCal->s_cal_obj.pc_WIFI_APC_Obj->Get_TxPowerDac(e_802_11_idx, mod, second_ch_index);
                double d_data;
                unsigned char uc_target_dac;
                d_slope = (double) (uc_first_dac - uc_second_dac)/(double)(first_ch_index - second_ch_index);
                d_offset = (double) uc_first_dac - (d_slope * first_ch_index);
                d_data = d_slope * nvram_ch_idx + d_offset;
                d_data += (d_data>=0) ? 0.5 : -0.5 ;
                uc_target_dac = (unsigned char) d_data;
                m_pCal->s_cal_obj.pc_WIFI_APC_Obj->Set_TxPowerDac(e_802_11_idx, mod, nvram_ch_idx, uc_target_dac);
                log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
                              " slope = " + Double_To_AnsiString(d_slope) +
                              ", offset = " + Double_To_AnsiString(d_offset)
                            );
                log->Add(DateToStr(Date()) +  " " + CurrentTimeStr() +
                         " channel index = " + IntToStr(nvram_ch_idx) +
                         ", WiFi TX power DAC = " + IntToStr(uc_target_dac)
                        );

                // evaluate remain channel ALC vaue
                if (m_pCal->b_WiFiAlcSupport)
                {
                    unsigned char uc_first_alc = m_pCal->s_cal_obj.pc_WIFI_ALC_Obj->Get_AlcPower2400MAlc(mod, first_ch_index, (WiFi_TestRate_E) 0);
                    unsigned char uc_second_alc = m_pCal->s_cal_obj.pc_WIFI_ALC_Obj->Get_AlcPower2400MAlc(mod, second_ch_index, (WiFi_TestRate_E) 0);

                    double d_data;
                    unsigned char uc_target_alc;
                    d_slope = (double) (uc_first_alc - uc_second_alc)/(double)(first_ch_index - second_ch_index);
                    d_offset = (double) uc_first_alc - (d_slope * first_ch_index);
                    d_data = d_slope * nvram_ch_idx + d_offset;
                    d_data += (d_data>=0) ? 0.5 : -0.5 ;
                    uc_target_alc = (unsigned char) d_data;
                    if (WIFI_MOD_CCK == mod)
                    {
                        m_pCal->s_cal_obj.pc_WIFI_ALC_Obj->Set_AlcPower2400MAlc(mod, nvram_ch_idx, (WiFi_TestRate_E) 0, uc_target_alc);
                    }
                    else
                    {
                        for (int rate = 0; rate < WIFI_ALC_2400M_TX_RATE_NUM; rate++)
                        {
                            m_pCal->s_cal_obj.pc_WIFI_ALC_Obj->Set_AlcPower2400MAlc(mod, nvram_ch_idx, (WiFi_TestRate_E) rate, uc_target_alc);
                        }
                    }
                    log->Add(DateToStr(Date()) +  " " + CurrentTimeStr() +
                              " slope = " + Double_To_AnsiString(d_slope) +
                              ", offset = " + Double_To_AnsiString(d_offset)
                            );
                    log->Add(DateToStr(Date()) +  " " + CurrentTimeStr() +
                             " channel index = " + IntToStr(nvram_ch_idx) +
                             ", WiFi ALC = " + IntToStr(uc_target_alc)
                        );
                }

            } // for(i)



            log->Add("\n" +DateToStr(Date()) +  " " + CurrentTimeStr() +
                  " -------------------- Evaluate WiFi TX power DAC value end ------------------ "
                );
        }

        // write to NVRAM
        m_pCal->s_cal_obj.pc_WIFI_APC_Obj->ConfirmCallback = ::CNF_MF_WriteToNVRAM;
        if( WIFI_802_11A_IDX == e_802_11_idx )
        {
            m_pCal->s_cal_obj.pc_WIFI_APC_Obj->REQ_Write_TxPower5000M_To_NVRAM_Start();
        }
        else
        {
            m_pCal->s_cal_obj.pc_WIFI_APC_Obj->REQ_Write_TxPower2400M_To_NVRAM_Start();
        }

        RestartTimerCal( WM_MF_NVRAM_WIFI_APC_WRITE_FAIL );
        SUSPEND_CAL_THREAD
        CHECK_TERMINATE_BY_USER

        E_METAAPP_RESULT_T state = m_pCal->s_cal_obj.pc_WIFI_APC_Obj->Get_ConfirmState();
        if (state != METAAPP_SUCCESS)
        {
            if (METAAPP_NVRAM_LID_VER_NOT_SUPPORT == state)
            {
                CalErrorHandler(WM_MF_NVRAM_EF_WNDRV_TX_POWER_xxx_LID_VERNO_FAIL);
                log->Add(DateToStr(Date()) +  " " + CurrentTimeStr() +
                               " FAIL : NVRAM_EF_WNDRV_TX_POWER_xxx_LID version is not support, please update META to latest version. "
                               );
            }
            else
            {
                CalErrorHandler(WM_MF_NVRAM_WIFI_APC_WRITE_FAIL);
                log->Add(DateToStr(Date()) +  " " + CurrentTimeStr() +
                      " FAIL: Target < write WiFi 2.4G TX power to NVRAM fail."
                    );
            }
            return false;
        }

        log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
                      " Target < write WiFi 2.4G TX power to NVRAM."
                    );

        if ( this->Terminated )
        {
            this->OnTerminate = neByUser;
            return false;
        }

        WriteWiFiAPCCalResultToFile(as_ID+".cal",Application->ExeName, m_pCal->b_CalResultPath, e_802_11_idx );
        e_802_11_idx++;
    } // while

    if (m_pCal->b_WiFiAlcSupport)
    {
        // CCK
        for (int ch_idx=0; ch_idx<max_ch_num; ch_idx++)
        {
            m_pCal->s_cal_obj.pc_WIFI_ALC_Obj->Set_AlcPower2400MPowerDB(WIFI_MOD_CCK, ch_idx, (WiFi_TestRate_E) 0, m_dCCK_WANTED_P);
        }

        // OFDM
        for (int rate = 0; rate < WIFI_ALC_2400M_TX_RATE_NUM; rate++)
        {
            for (int ch_idx = 0; ch_idx < max_ch_num; ch_idx++)
            {
                m_pCal->s_cal_obj.pc_WIFI_ALC_Obj->Set_AlcPower2400MPowerDB(WIFI_MOD_OFDM, ch_idx, (WiFi_TestRate_E) rate, m_dOFDM_WANTED_P);
            }
        }

        // write to NVRAM
        m_pCal->s_cal_obj.pc_WIFI_ALC_Obj->ConfirmCallback = ::CNF_MF_WriteToNVRAM;
        m_pCal->s_cal_obj.pc_WIFI_ALC_Obj->REQ_Write_To_NVRAM_Start();

        RestartTimerCal(WM_MF_NVRAM_WIFI_ALC_WRITE_FAIL);
        SUSPEND_CAL_THREAD
        CHECK_TERMINATE_BY_USER

        E_METAAPP_RESULT_T state = m_pCal->s_cal_obj.pc_WIFI_ALC_Obj->Get_ConfirmState();
        if (state != METAAPP_SUCCESS)
        {
            if (METAAPP_NVRAM_LID_VER_NOT_SUPPORT == state)
            {
                CalErrorHandler(WM_MF_NVRAM_EF_WNDRV_TX_ALC_POWER_LID_VERNO_FAIL);
                log->Add(DateToStr(Date()) +  " " + CurrentTimeStr() +
                               " FAIL : NVRAM_EF_WNDRV_TX_ALC_POWER_LID version is not support, please update META to latest version. "
                               );
            }
            else
            {
                CalErrorHandler(WM_MF_NVRAM_WIFI_ALC_WRITE_FAIL);
                log->Add(DateToStr(Date()) +  " " + CurrentTimeStr() +
                      " FAIL: Target < write WiFi 2.4G ALC to NVRAM fail."
                    );
            }
            return false;
        }

        log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
                      " Target < write WiFi 2.4G TX power to NVRAM."
                    );
    }
    frmFatcory->DisableAllCalTimer();
    log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
             " ====================== WiFi TX power calibration end ===================== "
           );

    return true;
}

//----------------------------------------------------------------------------
bool __fastcall T_META_factory_calibration::WiFiTxPclCal_check( void )
{
    log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
             " ====================== WiFi TX power check begin ===================== "
           );

    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;
    }
    WiFi_TestPktTx_Ex_S  pkt_tx_ex;
    S_WIFICPT  wifi_cpt;
    double   virTX;
    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.tx_rate = WIFI_TEST_RATE_5_5M;
    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;
    int tx_power_ch_num;
    AnsiString as_check_channel;
    int nvram_ch_idx;
    S_WIFI_CH_FREQ_MHZ s_check_ch_freq_mhz;
    double d_max_p;
    double d_min_p;
    double d_CL;
    double d_n4010a_power_range;
    E_WIFI_MOD mod;
    bool out_of_range_flag = false; // set initial value
    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_check_channel  = m_as802_11G_CHECK_CHANNEL;
                max_ch_num      = NUM_TX_POWER_5000M_CH;
                d_max_p         = m_dOFDM_MAX_P;
                d_min_p         = m_dOFDM_MIN_P;
                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_CHECK_RATE;
            }
            break;

            case WIFI_802_11B_IDX:
            {
                if (!IsWiFiSupported(m_asWiFi_Support, e_802_11_idx))
                {
                    e_802_11_idx++;
                    continue;
                }
                as_check_channel  = m_as802_11B_CHECK_CHANNEL;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -