rf_apc.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:100k
- /*****************************************************************************
- * 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:
- * ---------
- * rf_apc.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * RF APC 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!!
- *============================================================================
- ****************************************************************************/
- #pragma hdrstop
- #ifndef META_DLL_H
- #include "meta.h"
- #endif
- #ifndef _RF_APC_H_
- #include "rf_apc.h"
- #endif
- #include "man_fdm.h"
- #include "man_active.h"
- #include "form_main.h" // for GSM 850
- // misc
- #include "misc.h"
- #ifndef _FT_UTILS_H_
- #include "ft_utils.h"
- #endif
- #ifndef _BAND_UTILS_H_
- #include "band_utils.h"
- #endif
- #ifndef _GSM_UTILS_H_
- #include "gsm_utils.h"
- #endif
- // NVRAM
- #ifndef _NVRAM_VER_H_
- #include "nvram_ver.h"
- #endif
- //===========================================================================
- extern TfrmMainSel *frmMainSel; // for GSM 850
- static CRFAPC* rf_apc_ptr;
- static bool g_bIsRunning = false;
- //===========================================================================
- static const char SUBBAND_NAME[][32] =
- {
- "GSM900 level, ramp",
- "DCS1800 level, ramp",
- "PCS1900 level, ramp",
- "GSM850 level, ramp",
- };
- //--------------------------------------------------------------------------
- static const char SUBBAND_NAME_WORD3[32] =
- {
- "RENESAS WORD3"
- };
- //--------------------------------------------------------------------------
- static const char SUBBAND_NAME_WORD6S[32] =
- {
- "RENESAS WORD6S"
- };
- //===========================================================================
- static const char BAND_NAME1[4][12] =
- { "GSM",
- "DCS",
- "PCS",
- "GSM850"
- };
- //---------------------------------------------------------------------------
- static const char BAND_NAME2[4][12] =
- { "GSM900",
- "DCS1800",
- "PCS1900",
- "GSM850"
- };
- //---------------------------------------------------------------------------
- static const int LOWEST_POWER[] =
- { 5, 0, 0, 5 };
- //---------------------------------------------------------------------------
- static const char BAND_PCL_COMMENT[4][128] =
- { " /* 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35 dBm */n",
- " /* 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30 dBm */n",
- " /* 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30 dBm */n",
- " /* 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35 dBm */n"
- };
- //===========================================================================
- static void REQ_ReadApcFromNVRAM( void )
- {
- rf_apc_ptr->REQ_ReadApcFromNVRAM( );
- }
- //---------------------------------------------------------------------------
- static void CNF_ReadApcFromNVRAM( void )
- {
- rf_apc_ptr->CNF_ReadApcFromNVRAM();
- }
- //---------------------------------------------------------------------------
- static void REQ_WriteApcToNVRAM( void )
- {
- rf_apc_ptr->REQ_WriteApcToNVRAM( );
- }
- //---------------------------------------------------------------------------
- static void CNF_WriteApcToNVRAM( void )
- {
- rf_apc_ptr->CNF_WriteApcToNVRAM( );
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- //static void CNF_ReadWord3FromNVRAM( void )
- //{
- // rf_apc_ptr->CNF_ReadWord3FromNVRAM();
- //}
- //---------------------------------------------------------------------------
- //static void CNF_WriteWord3ToNVRAM( void )
- //{
- // rf_apc_ptr->CNF_WriteWord3ToNVRAM( );
- //}
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- static void CNF_ReadB5PFromNVRAM( void )
- {
- rf_apc_ptr->CNF_ReadB5PFromNVRAM();
- }
- //---------------------------------------------------------------------------
- static void CNF_WriteB5PToNVRAM( void )
- {
- rf_apc_ptr->CNF_WriteB5PToNVRAM( );
- }
- //---------------------------------------------------------------------------
- static void REQ_SetW6sImmediateBSI( void )
- {
- rf_apc_ptr->REQ_SetW6sImmediateBSI();
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- //---------------------------------------------------------------------------
- static void REQ_TimeOut( void )
- { rf_apc_ptr->REQ_TimeOut();
- }
- //---------------------------------------------------------------------------
- static void REQ_Finish( void )
- { rf_apc_ptr->REQ_Finish();
- }
- //---------------------------------------------------------------------------
- static void __stdcall CNF_RfSetRampApcLevl(const unsigned char cnf, const short token, void *usrData)
- { rf_apc_ptr->CNF_RfSetRampApcLevl(cnf, token, usrData);
- }
- //---------------------------------------------------------------------------
- static void REQ_RfSetRampTable( void )
- {
- rf_apc_ptr->REQ_RfSetRampTable();
- }
- //---------------------------------------------------------------------------
- static void Query_RfSetRampTable( void )
- { rf_apc_ptr->Query_RfSetRampTable();
- }
- //---------------------------------------------------------------------------
- static void Query_TwoApcDcOffset( void )
- { rf_apc_ptr->Query_TwoApcDcOffset();
- }
- //===========================================================================
- CRFAPC::CRFAPC( void )
- {
- g_bIsRunning = false;
- ConfirmCallback = 0;
- ApcBufSize = 0;
- ApcBuf = NULL;
- B5PBufSize = 0;
- B5PBuf = NULL;
- // query
- m_bTADOSupport = false;
- }
- //---------------------------------------------------------------------------
- CRFAPC::~CRFAPC()
- {
- g_bIsRunning = false;
- ConfirmCallback = 0;
- if(ApcBuf)
- {
- delete [] ApcBuf;
- ApcBuf = NULL;
- }
- //if(Word3Buf)
- // {
- // delete [] Word3Buf;
- // Word3Buf = NULL;
- //}
- if(B5PBuf)
- {
- delete [] B5PBuf;
- B5PBuf = NULL;
- }
- }
- //---------------------------------------------------------------------------
- void CRFAPC::REQ_Finish( void )
- {
- if(!g_bIsRunning) return;
- Confirm( METAAPP_SUCCESS );
- g_bIsRunning = false;
- }
- //---------------------------------------------------------------------------
- void CRFAPC::REQ_Stop( void )
- {
- if(!g_bIsRunning) return;
- NVRAMMan->REQ_Stop();
- Confirm( METAAPP_STOP );
- g_bIsRunning = false;
- }
- //---------------------------------------------------------------------------
- void CRFAPC::REQ_TimeOut( void )
- {
- if(!g_bIsRunning) return;
- NVRAMMan->REQ_Stop();
- Confirm( METAAPP_TIMEOUT );
- g_bIsRunning = false;
- }
- //---------------------------------------------------------------------------
- void CRFAPC::Confirm(E_METAAPP_RESULT_T confirm_state)
- {
- if(!g_bIsRunning) return;
- if(ConfirmCallback==0) return;
- m_eConfirmState = confirm_state;
- ActiveMan->SetActiveFunction( ConfirmCallback );
- }
- //===========================================================================
- //---------------------------------------------------------------------------
- //static char NVRAM_RAMPNAME[][32] =
- //{
- // "L1_RAMPTABLE_GSM900",
- // "L1_RAMPTABLE_DCS1800",
- // "L1_RAMPTABLE_PCS1900",
- // "L1_RAMPTABLE_GSM850",
- //};
- //===========================================================================
- void CRFAPC::REQ_Read_APC_From_NVRAM_Start(unsigned int rf_id, bool b_tapo_support)
- {
- rf_apc_ptr = this;
- g_bIsRunning = true;
- CurWRBand = BANDSEL_GSM900;
- m_uiRfModId = rf_id;
- m_bTADOSupport = b_tapo_support;
- m_bSingleBand = false;
- m_bDownloadTrigger = false;
- REQ_ReadApcFromNVRAM();
- }
- //------------------------------------------------------------------------------
- void CRFAPC::REQ_Read_APC_From_NVRAM_Single_Band_Start(unsigned int rf_id, int band, bool b_tapo_support)
- {
- rf_apc_ptr = this;
- g_bIsRunning = true;
- CurWRBand = band;
- m_uiRfModId = rf_id;
- m_bTADOSupport = b_tapo_support;
- m_bSingleBand = true;
- m_bDownloadTrigger = false;
- REQ_ReadApcFromNVRAM();
- }
- //-------------------------------------
- void CRFAPC::REQ_ReadApcFromNVRAM(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- META_RESULT MetaResult;
- int band = CurWRBand;
- if (NULL == ApcBuf)
- {
- //bool vbias_support = NVRAMMan->Get_VbiasSupport();
- MetaResult = META_NVRAM_GetRecLen("NVRAM_EF_L1_RAMPTABLE_GSM900_LID", &ApcBufSize);
- if (MetaResult != META_SUCCESS)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- ApcBuf = new char[ApcBufSize];
- }
- NVRAMMan->ConfirmCallback = ::CNF_ReadApcFromNVRAM;
- switch(band)
- {
- case BANDSEL_GSM850:
- {
- NVRAMMan->REQ_ReadNVRAM_Start("NVRAM_EF_L1_RAMPTABLE_GSM850_LID",
- 1,
- ApcBufSize,
- ApcBuf);
- }
- break;
- case BANDSEL_GSM900:
- {
- NVRAMMan->REQ_ReadNVRAM_Start("NVRAM_EF_L1_RAMPTABLE_GSM900_LID",
- 1,
- ApcBufSize,
- ApcBuf);
- }
- break;
- case BANDSEL_DCS1800:
- {
- NVRAMMan->REQ_ReadNVRAM_Start("NVRAM_EF_L1_RAMPTABLE_DCS1800_LID",
- 1,
- ApcBufSize,
- ApcBuf);
- }
- break;
- case BANDSEL_PCS1900:
- {
- NVRAMMan->REQ_ReadNVRAM_Start("NVRAM_EF_L1_RAMPTABLE_PCS1900_LID",
- 1,
- ApcBufSize,
- ApcBuf);
- }
- break;
- default:
- {
- Confirm(METAAPP_FAIL);
- }
- break;
- }
- }
- //-------------------------------------
- void CRFAPC::CNF_ReadApcFromNVRAM(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- META_RESULT MetaResult;
- int band = CurWRBand;
- E_METAAPP_RESULT_T state = NVRAMMan->Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- if (m_bDownloadTrigger)
- {
- if (!frmMainSel->cbGSM850->Checked)
- {
- if ((BANDSEL_PCS1900 == band) | m_bSingleBand)
- {
- if (!m_bSingleBand)
- {
- CurWRBand = BANDSEL_GSM900;
- }
- REQ_WriteApcToNVRAM();
- }
- else
- {
- CurWRBand++;
- ActiveMan->SetActiveFunction(::REQ_ReadApcFromNVRAM);
- }
- }
- else
- {
- if ((BANDSEL_GSM850 == band) | m_bSingleBand)
- {
- if (!m_bSingleBand)
- {
- CurWRBand = BANDSEL_GSM900;
- }
- REQ_WriteApcToNVRAM();
- }
- else
- {
- CurWRBand++;
- ActiveMan->SetActiveFunction( ::REQ_ReadApcFromNVRAM );
- }
- }
- }
- else
- {
- int idata;
- //bool vbias_support = NVRAMMan->Get_VbiasSupport();
- //if (vbias_support)
- //{
- // MetaResult = META_NVRAM_Decompose_rampTable_Ex2(&m_sApcProfile[band],
- // ApcBuf,
- // ApcBufSize);
- // }
- // else
- {
- //l1cal_rampTable_T ramp_table;
- MetaResult = META_NVRAM_Decompose_rampTable(&m_sApcProfile[band],
- ApcBuf,
- ApcBufSize);
- // m_sApcProfile[band].rampData.lowest_power = ramp_table.rampData.lowest_power;
- // for (int i=0; i<MAX_APC_PCL_NUM; i++)
- // {
- // m_sApcProfile[band].rampData.power[i] = ramp_table.rampData.power[i];
- // m_sApcProfile[band].rampData.ramp[i] = ramp_table.rampData.ramp[i];
- // }
- //
- // for (int i=0; i<ARFCN_SECTION_NUM; i++)
- // {
- // m_sApcProfile[band].rampData.arfcn_weight[i] = ramp_table.rampData.arfcn_weight[i];
- // }
- //
- // for (int i=0; i<APC_BATTERY_COMP_NUM; i++)
- // {
- // for (int j=0; j<APC_BATTERY_COMP_NUM; j++)
- // {
- // m_sApcProfile[band].rampData.battery_compensate[i][j] = ramp_table.rampData.battery_compensate[i][j];
- // }
- // }
- // m_sApcProfile[band].rampData.tx_afc_offset = ramp_table.rampData.tx_afc_offset;
- }
- if (MetaResult!=META_SUCCESS)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- m_usHighApcDcOffset[band] = (m_sApcProfile[band].rampData.lowest_power>>8) & 0x03FF;
- if (m_bTADOSupport)
- {
- m_usLowApcDcOffset[band] = (m_sApcProfile[band].rampData.lowest_power>>18) & 0x03FF;
- m_iApcLowestPower[band] = m_sApcProfile[band].rampData.lowest_power & 0x00FF;
- }
- m_sApcProfile[band].rampData.lowest_power &=0x0FF;
- for (int i=0; i<ARFCN_SECTION_NUM; i++)
- {
- idata = m_sApcProfile[band].rampData.arfcn_weight[i].mid_level;
- m_sApcProfile[band].rampData.arfcn_weight[i].mid_level = POWER2PCL(band, idata);
- if (32767 == m_sApcProfile[band].rampData.arfcn_weight[i].max_arfcn)
- {
- m_sApcProfile[band].rampData.arfcn_weight[i].max_arfcn = -1;
- }
- }
- bool isAllBCEqualZero = true;
- for (int i=0; i<3; i++)
- {
- for (int j=0; j<3; j++)
- {
- if (m_sApcProfile[band].rampData.battery_compensate[i][j] != 0)
- {
- isAllBCEqualZero = false;
- break;
- }
- }
- }
- if (isAllBCEqualZero)
- {
- for (int i=0; i<3; i++)
- {
- for (int j=0; j<3; j++)
- {
- m_sApcProfile[band].rampData.battery_compensate[i][j] = BATTERY_COMPENSATE_SCALE;
- }
- }
- }
- if (!frmMainSel->cbGSM850->Checked)
- {
- if (BANDSEL_GSM900 == band)
- {
- m_sApcProfile[band].rampData.power[15] = m_sApcProfile[band].rampData.power[14];
- }
- }
- else
- {
- if (BANDSEL_GSM900 == band || BANDSEL_GSM850 == band)
- {
- m_sApcProfile[band].rampData.power[15] = m_sApcProfile[band].rampData.power[14];
- }
- }
- if (!frmMainSel->cbGSM850->Checked)
- {
- if ((BANDSEL_PCS1900 == band) || m_bSingleBand)
- {
- ActiveMan->SetActiveFunction(::REQ_Finish);
- }
- else
- {
- CurWRBand++;
- ActiveMan->SetActiveFunction(::REQ_ReadApcFromNVRAM);
- }
- }
- else
- {
- if ((BANDSEL_GSM850 == band) || m_bSingleBand)
- {
- ActiveMan->SetActiveFunction( ::REQ_Finish );
- }
- else
- {
- CurWRBand++;
- ActiveMan->SetActiveFunction( ::REQ_ReadApcFromNVRAM );
- }
- }
- }
- }
- break;
- default:
- {
- Confirm(state);
- }
- break;
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CRFAPC::REQ_Write_APC_To_NVRAM_Start(unsigned int rf_id, bool b_tapo_support)
- {
- rf_apc_ptr = this;
- g_bIsRunning = true;
- m_uiRfModId = rf_id;
- m_bSingleBand = false;
- CurWRBand = BANDSEL_GSM900;
- m_bTADOSupport = b_tapo_support;
- m_bDownloadTrigger = true;
- REQ_WriteApcToNVRAM();
- }
- //-------------------------------------
- void CRFAPC::REQ_Write_APC_To_NVRAM_Single_Band_Start(unsigned int rf_id, int band, bool b_tapo_support)
- {
- rf_apc_ptr = this;
- g_bIsRunning = true;
- m_uiRfModId = false;
- m_bSingleBand = true;
- CurWRBand = band;
- m_bTADOSupport = b_tapo_support;
- m_bDownloadTrigger = true;
- REQ_WriteApcToNVRAM();
- }
- //-------------------------------------
- void CRFAPC::REQ_WriteApcToNVRAM(void)
- {
- if(!g_bIsRunning) return;
- int i, j;
- int idata;
- int band = CurWRBand;
- META_RESULT MetaResult;
- if (NULL==ApcBuf)
- {
- MetaResult = META_NVRAM_GetRecLen("NVRAM_EF_L1_RAMPTABLE_GSM900_LID", &ApcBufSize);
- if(MetaResult!=META_SUCCESS)
- { Confirm( METAAPP_FAIL ); return; }
- ApcBuf = new char[ApcBufSize];
- }
- if (BANDSEL_GSM900 == band || BANDSEL_GSM850 == band)
- {
- m_sApcProfile[band].rampData.power[15] = m_sApcProfile[band].rampData.power[14];
- }
- if( ! m_bTADOSupport )
- {
- m_sApcProfile[band].rampData.lowest_power = ((m_usHighApcDcOffset[band]&0x03FF)<<8) |
- NVRAM_APC_LOWEST_POWER[band];
- }
- else
- {
- m_sApcProfile[band].rampData.lowest_power = ((m_usHighApcDcOffset[band]&0x03FF)<<8) |
- ((m_usLowApcDcOffset[band]&0x03FF)<<18) |
- m_iApcLowestPower[band];
- }
- for( i=0; i<12; i++ )
- {
- idata = m_sApcProfile[band].rampData.arfcn_weight[i].mid_level;
- m_sApcProfile[band].rampData.arfcn_weight[i].mid_level = PCL2POWER(band, idata);
- }
- //bool vbias_support = NVRAMMan->Get_VbiasSupport();
- //if (vbias_support)
- //{
- // MetaResult = META_NVRAM_Compose_rampTable_Ex2( &m_sApcProfile[band],
- // ApcBuf,
- // ApcBufSize );
- //}
- //else
- //{
- // l1cal_rampTable_T ramp_table;
- //
- // ramp_table.rampData.lowest_power = m_sApcProfile[band].rampData.lowest_power;
- // for (int i=0; i<MAX_APC_PCL_NUM; i++)
- // {
- // ramp_table.rampData.power[i] = m_sApcProfile[band].rampData.power[i];
- // ramp_table.rampData.ramp[i] = m_sApcProfile[band].rampData.ramp[i];
- // }
- //
- // for (int i=0; i<ARFCN_SECTION_NUM; i++)
- // {
- // ramp_table.rampData.arfcn_weight[i] = m_sApcProfile[band].rampData.arfcn_weight[i];
- // }
- //
- // for (int i=0; i<APC_BATTERY_COMP_NUM; i++)
- // {
- // for (int j=0; j<APC_BATTERY_COMP_NUM; j++)
- // {
- // ramp_table.rampData.battery_compensate[i][j] = m_sApcProfile[band].rampData.battery_compensate[i][j];
- // }
- // }
- // ramp_table.rampData.tx_afc_offset = m_sApcProfile[band].rampData.tx_afc_offset;
- //
- MetaResult = META_NVRAM_Compose_rampTable(&m_sApcProfile[band],
- ApcBuf,
- ApcBufSize );
- //}
- m_sApcProfile[band].rampData.lowest_power &= 0x0FF;
- for( i=0; i<12; i++ )
- {
- idata = m_sApcProfile[band].rampData.arfcn_weight[i].mid_level;
- m_sApcProfile[band].rampData.arfcn_weight[i].mid_level = POWER2PCL(band, idata);
- }
- if (MetaResult != META_SUCCESS)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- NVRAMMan->ConfirmCallback = ::CNF_WriteApcToNVRAM;
- switch (band)
- {
- case BANDSEL_GSM850:
- {
- unsigned short lid_ver;
- MetaResult = META_NVRAM_GetLIDVersion("NVRAM_EF_L1_RAMPTABLE_GSM850_LID", &lid_ver);
- if (lid_ver > NVRAM_EF_L1_RAMPTABLE_GSM850_LID_VERNO)
- {
- Confirm(METAAPP_NVRAM_LID_VER_NOT_SUPPORT);
- return;
- }
- NVRAMMan->REQ_WriteNVRAM_Start("NVRAM_EF_L1_RAMPTABLE_GSM850_LID",
- 1,
- ApcBufSize,
- ApcBuf);
- }
- break;
- case BANDSEL_GSM900:
- {
- unsigned short lid_ver;
- MetaResult = META_NVRAM_GetLIDVersion("NVRAM_EF_L1_RAMPTABLE_GSM900_LID", &lid_ver);
- if (lid_ver > NVRAM_EF_L1_RAMPTABLE_GSM900_LID_VERNO)
- {
- Confirm(METAAPP_NVRAM_LID_VER_NOT_SUPPORT);
- return;
- }
- NVRAMMan->REQ_WriteNVRAM_Start("NVRAM_EF_L1_RAMPTABLE_GSM900_LID",
- 1,
- ApcBufSize,
- ApcBuf);
- }
- break;
- case BANDSEL_DCS1800:
- {
- unsigned short lid_ver;
- MetaResult = META_NVRAM_GetLIDVersion("NVRAM_EF_L1_RAMPTABLE_DCS1800_LID", &lid_ver);
- if (lid_ver > NVRAM_EF_L1_RAMPTABLE_DCS1800_LID_VERNO)
- {
- Confirm(METAAPP_NVRAM_LID_VER_NOT_SUPPORT);
- return;
- }
- NVRAMMan->REQ_WriteNVRAM_Start("NVRAM_EF_L1_RAMPTABLE_DCS1800_LID",
- 1,
- ApcBufSize,
- ApcBuf);
- }
- break;
- case BANDSEL_PCS1900:
- {
- unsigned short lid_ver;
- MetaResult = META_NVRAM_GetLIDVersion("NVRAM_EF_L1_RAMPTABLE_PCS1900_LID", &lid_ver);
- if (lid_ver > NVRAM_EF_L1_RAMPTABLE_PCS1900_LID_VERNO)
- {
- Confirm(METAAPP_NVRAM_LID_VER_NOT_SUPPORT);
- return;
- }
- NVRAMMan->REQ_WriteNVRAM_Start("NVRAM_EF_L1_RAMPTABLE_PCS1900_LID",
- 1,
- ApcBufSize,
- ApcBuf);
- }
- break;
- }
- }
- //-------------------------------------
- void CRFAPC::CNF_WriteApcToNVRAM( void )
- {
- int band = CurWRBand;
- if(!g_bIsRunning) return;
- E_METAAPP_RESULT_T state = NVRAMMan->Get_ConfirmState();
- if(state==METAAPP_SUCCESS)
- {
- if (frmMainSel->cbGSM850->Checked)
- {
- if( (band==BANDSEL_GSM850)||(m_bSingleBand) )
- { ActiveMan->SetActiveFunction( ::REQ_Finish );
- }
- else
- {
- CurWRBand++;
- ActiveMan->SetActiveFunction( ::REQ_WriteApcToNVRAM );
- }
- }
- else
- {
- if( (band==BANDSEL_PCS1900)||(m_bSingleBand) )
- { ActiveMan->SetActiveFunction( ::REQ_Finish );
- }
- else
- {
- CurWRBand++;
- ActiveMan->SetActiveFunction( ::REQ_WriteApcToNVRAM );
- }
- }
- }
- else
- { Confirm(state);
- }
- }
- #if 0
- //===========================================================================
- void CRFAPC::REQ_Read_WORD3_From_NVRAM( void )
- {
- rf_apc_ptr = this;
- g_bIsRunning = true;
- if(Word3Buf==0)
- {
- MetaResult = META_NVRAM_GetRecLen( "NVRAM_EF_L1_RFSPECIALCOEF_LID",
- &Word3BufSize );
- if(MetaResult!=META_SUCCESS)
- { Confirm( METAAPP_FAIL ); return; }
- Word3Buf = new char[Word3BufSize];
- }
- NVRAMMan->ConfirmCallback = ::CNF_ReadWord3FromNVRAM;
- NVRAMMan->REQ_ReadNVRAM_Start( "NVRAM_EF_L1_RFSPECIALCOEF_LID",
- 1, // only one record
- Word3BufSize,
- Word3Buf );
- }
- //-------------------------------------
- void CRFAPC::CNF_ReadWord3FromNVRAM( void )
- {
- if(!g_bIsRunning) return;
- int state = NVRAMMan->m_eConfirmState;
- if(state==METAAPP_SUCCESS)
- {
- int i;
- int idata;
- // MetaResult = META_NVRAM_Decompose_rampTable( &Word3Profile[band],
- // Word3Buf,
- // Word3BufSize );
- if(MetaResult!=META_SUCCESS)
- { Confirm( METAAPP_FAIL ); return; }
- ActiveMan->SetActiveFunction( ::REQ_Finish );
- }
- else if(state==STATE_NVRAM_TIMEOUT)
- { Confirm( METAAPP_TIMEOUT );
- }
- else if(state==STATE_NVRAM_STOP)
- { Confirm( METAAPP_STOP );
- }
- else
- { Confirm( METAAPP_FAIL );
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CRFAPC::REQ_Write_WORD3_To_NVRAM( void )
- {
- rf_apc_ptr = this;
- g_bIsRunning = true;
- if(Word3Buf==0)
- {
- MetaResult = META_NVRAM_GetRecLen( "NVRAM_EF_L1_RFSPECIALCOEF_LID",
- &Word3BufSize );
- if(MetaResult!=META_SUCCESS)
- { Confirm( METAAPP_FAIL ); return; }
- Word3Buf = new char[Word3BufSize];
- }
- // MetaResult = META_NVRAM_Compose_rampTable( &m_sApcProfile[band],
- // Word3Buf,
- // Word3BufSize );
- if(MetaResult!=META_SUCCESS)
- { Confirm( METAAPP_FAIL ); return; }
- NVRAMMan->ConfirmCallback = ::CNF_WriteApcToNVRAM;
- NVRAMMan->REQ_WriteNVRAM_Start( "NVRAM_EF_L1_RFSPECIALCOEF_LID",
- 1, // only 1 record
- Word3BufSize,
- Word3Buf );
- }
- //-------------------------------------
- void CRFAPC::CNF_WriteWord3ToNVRAM( void )
- {
- if(!g_bIsRunning) return;
- int state = NVRAMMan->m_eConfirmState;
- if(state==METAAPP_SUCCESS)
- {
- ActiveMan->SetActiveFunction( ::REQ_Finish );
- }
- else if(state==STATE_NVRAM_TIMEOUT)
- { Confirm( METAAPP_TIMEOUT );
- }
- else if(state==STATE_NVRAM_STOP)
- { Confirm( METAAPP_STOP );
- }
- else
- { Confirm( METAAPP_FAIL );
- }
- }
- #endif
- //===========================================================================
- void CRFAPC::Compose_wordC3(sC3Mode c3mode, unsigned int &wordC3)
- {
- wordC3 = (c3mode.uc_tn << 11) | (c3mode.uc_to << 7) | ( 0x06 << 3 ) | ADDR_WORD_C3;
- }
- //---------------------------------------------------------------------------
- void CRFAPC::DeCompose_wordC3(unsigned int wordC3, sC3Mode & c3mode)
- {
- c3mode.uc_tn = (wordC3 >> 11) & 0x3F;
- c3mode.uc_to = (wordC3 >> 7) & 0x0F;
- c3mode.uc_pm = (wordC3 >> 3) & 0x0F;
- c3mode.uc_addr = (wordC3 ) & 0x07;
- }
- //---------------------------------------------------------------------------
- void CRFAPC::Compose_word6_4_0(sBVW0 &bvw0, unsigned int &word6_4_0)
- {
- word6_4_0 = (bvw0.uc_ap<<20) | (bvw0.uc_as<<17) | (bvw0.uc_ao<<11) | (bvw0.uc_bd<<6) | ADDR_BV_WORD_6_4_0;
- }
- //---------------------------------------------------------------------------
- void CRFAPC::Compose_word6_5_0(sBVW0 &bvw0, unsigned int &word6_5_0)
- {
- word6_5_0 = (bvw0.uc_ap<<20) | (bvw0.uc_as<<17) | (bvw0.uc_ao<<11) | (bvw0.uc_bd<<6) | ADDR_BV_WORD_6_5_0;
- }
- //---------------------------------------------------------------------------
- void CRFAPC::Compose_word6_6_0(sBVW0 &bvw0, unsigned int &word6_6_0)
- {
- word6_6_0 = (bvw0.uc_ap<<20) | (bvw0.uc_as<<17) | (bvw0.uc_ao<<11) | (bvw0.uc_bd<<6) | ADDR_BV_WORD_6_6_0;
- }
- //---------------------------------------------------------------------------
- void CRFAPC::Compose_word6_7_0(sBVW0 &bvw0, unsigned int &word6_7_0)
- {
- word6_7_0 = (bvw0.uc_ap<<20) | (bvw0.uc_as<<17) | (bvw0.uc_ao<<11) | (bvw0.uc_bd<<6) | ADDR_BV_WORD_6_7_0;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CRFAPC::DeCompose_word6_x_0(unsigned int &word6_x_0, sBVW0 &bvw6x0)
- {
- bvw6x0.uc_ap = word6_x_0>>20 & 0x07;
- bvw6x0.uc_as = word6_x_0>>17 & 0x07;
- bvw6x0.uc_ao = word6_x_0>>11 & 0x3F;
- bvw6x0.uc_bd = word6_x_0>>6 & 0x1F;
- }
- //===========================================================================
- void CRFAPC::REQ_Read_B5P_From_NVRAM( void )
- {
- rf_apc_ptr = this;
- g_bIsRunning = true;
- if(B5PBuf==0)
- {
- META_RESULT MetaResult = META_NVRAM_GetRecLen( "NVRAM_EF_L1_RFSPECIALCOEF_LID",
- &B5PBufSize );;
- if(MetaResult!=META_SUCCESS)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- B5PBuf = new char[B5PBufSize];
- }
- NVRAMMan->ConfirmCallback = ::CNF_ReadB5PFromNVRAM;
- NVRAMMan->REQ_ReadNVRAM_Start( "NVRAM_EF_L1_RFSPECIALCOEF_LID",
- 1, // only one record
- B5PBufSize,
- B5PBuf );
- }
- //-------------------------------------
- void CRFAPC::CNF_ReadB5PFromNVRAM( void )
- {
- if(!g_bIsRunning) return;
- E_METAAPP_RESULT_T state = NVRAMMan->Get_ConfirmState();
- if(state==METAAPP_SUCCESS)
- {
- int i;
- int idata;
- META_RESULT MetaResult = META_NVRAM_Decompose_BRIGHT5P_RFSpecialCoef( &b5p_coef,
- B5PBuf,
- B5PBufSize );
- if(MetaResult!=META_SUCCESS)
- { Confirm( METAAPP_FAIL ); return; }
- ActiveMan->SetActiveFunction( ::REQ_Finish );
- }
- else
- { Confirm(state);
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CRFAPC::REQ_Write_B5P_To_NVRAM( void )
- {
- rf_apc_ptr = this;
- g_bIsRunning = true;
- META_RESULT MetaResult;
- if(B5PBuf==0)
- {
- MetaResult = META_NVRAM_GetRecLen( "NVRAM_EF_L1_RFSPECIALCOEF_LID",
- &B5PBufSize );;
- if(MetaResult!=META_SUCCESS)
- { Confirm( METAAPP_FAIL ); return; }
- B5PBuf = new char[B5PBufSize];
- }
- MetaResult = META_NVRAM_Compose_BRIGHT5P_RFSpecialCoef(&b5p_coef, B5PBuf, B5PBufSize );
- if(MetaResult!=META_SUCCESS)
- { Confirm( METAAPP_FAIL ); return; }
- NVRAMMan->ConfirmCallback = ::CNF_WriteApcToNVRAM;
- NVRAMMan->REQ_WriteNVRAM_Start( "NVRAM_EF_L1_RFSPECIALCOEF_LID",
- 1, // only 1 record
- B5PBufSize,
- B5PBuf );
- }
- //-------------------------------------
- void CRFAPC::CNF_WriteB5PToNVRAM(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- E_METAAPP_RESULT_T state = NVRAMMan->Get_ConfirmState();
- Confirm(state);
- }
- //============================================================================
- //////////////////////////////// INI file ////////////////////////////////
- //============================================================================
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- bool CRFAPC::ApcGSM850SectionExist( char *filename )
- {
- TIniFile *ini_file;
- ini_file = new TIniFile( filename );
- if( ini_file == NULL ) return false;
- if( ini_file->SectionExists( "GSM850 level, ramp" ) )
- {
- return true;
- }
- return false;
- }
- //----------------------------------------------------------------------------
- bool CRFAPC::ApcGSM900SectionExist( char *filename )
- {
- TIniFile *ini_file;
- ini_file = new TIniFile( filename );
- if( ini_file == NULL ) return false;
- if( ini_file->SectionExists( "GSM900 level, ramp" ) )
- {
- return true;
- }
- return false;
- }
- //----------------------------------------------------------------------------
- bool CRFAPC::ApcDCS1800SectionExist( char *filename )
- {
- TIniFile *ini_file;
- ini_file = new TIniFile( filename );
- if( ini_file == NULL ) return false;
- if( ini_file->SectionExists( "DCS1800 level, ramp" ) )
- {
- return true;
- }
- return false;
- }
- //----------------------------------------------------------------------------
- bool CRFAPC::ApcPCS1900SectionExist( char *filename )
- {
- TIniFile *ini_file;
- ini_file = new TIniFile( filename );
- if( ini_file == NULL ) return false;
- if( ini_file->SectionExists( "PCS1900 level, ramp" ) )
- {
- return true;
- }
- return false;
- }
- //----------------------------------------------------------------------------
- bool CRFAPC::ApcSectionExist( char *filename, int band )
- {
- int total_band_num;
- TIniFile *ini_file;
- ini_file = new TIniFile( filename );
- if( ini_file == NULL ) return false;
- if( ini_file->SectionExists( (AnsiString) SUBBAND_NAME[band] ) )
- {
- return true;
- }
- return false;
- }
- //----------------------------------------------------------------------------
- bool CRFAPC::AnyApcSectionExist( char *filename )
- {
- int total_band_num;
- TIniFile *ini_file;
- ini_file = new TIniFile( filename );
- if( ini_file == NULL ) return false;
- // frmMainSel->Get_FinalBandSupport( band_support );
- if(frmMainSel->cbGSM850->Checked)
- // if( band_support.GSM850 )
- { total_band_num = 4;
- }
- else
- {
- total_band_num = 3;
- }
- for(int band = 0; band<total_band_num; band++)
- {
- if( ini_file->SectionExists( (AnsiString) SUBBAND_NAME[band] ) )
- {
- return true;
- }
- }
- return false;
- }
- //----------------------------------------------------------------------------
- bool CRFAPC::RenesasWord3SectionExist( char *filename )
- {
- TIniFile *ini_file;
- ini_file = new TIniFile( filename );
- if( ini_file == NULL ) return false;
- if( ini_file->SectionExists( "RENESAS WORD3" ) )
- {
- return true;
- }
- return false;
- }
- //----------------------------------------------------------------------------
- bool CRFAPC::RenesasWord6sSectionExist( char *filename )
- {
- int total_band_num;
- TIniFile *ini_file;
- ini_file = new TIniFile( filename );
- if( ini_file == NULL ) return false;
- if( ini_file->SectionExists( "RENESAS WORD6S" ) )
- {
- return true;
- }
- return false;
- }
- //-----------------------------------------------------------------------------
- bool CRFAPC::REQ_Read_TX_AFC_DAC_offset_From_File_Single_Band( char *filename, int band )
- {
- TIniFile *ini_file;
- ini_file = new TIniFile( filename );
- if( ini_file == NULL ) return false;
- // TX AFC DAC offset
- m_sApcProfile[band].rampData.tx_afc_offset = ini_file->ReadInteger(SUBBAND_NAME[band],
- "TX AFC DAC offset",
- 0);
- delete ini_file;
- return true;
- }
- //-----------------------------------------------------------------------------
- bool CRFAPC::REQ_Read_TX_AFC_DAC_offset_From_File( char *filename )
- {
- TIniFile *ini_file;
- int band;
- int total_band_num;
- ini_file = new TIniFile( filename );
- if( ini_file == NULL ) return false;
- if(frmMainSel->cbGSM850->Checked)
- { total_band_num = 4;
- }
- else
- {
- total_band_num = 3;
- }
- for (band = 0; band<total_band_num; band++)
- {
- // TX AFC DAC offset
- m_sApcProfile[band].rampData.tx_afc_offset = ini_file->ReadInteger( SUBBAND_NAME[band],
- "TX AFC DAC offset",
- 0);
- }
- return true;
- }
- //-----------------------------------------------------------------------------
- bool CRFAPC::REQ_Read_APC_From_File_Single_Band(char *filename, unsigned int rf_id, int band, bool b_tapo_support)
- {
- TIniFile *ini_file;
- AnsiString data;
- char ini_section[128];
- char str[2048];
- int idata[16];
- unsigned short usdata[MAX_APC_PCL_NUM];
- float fdata[16];
- int i, pcl;
- int total_band_num;
- ini_file = new TIniFile( filename );
- if( ini_file == NULL ) return false;
- m_bTADOSupport = b_tapo_support;
- m_uiRfModId = rf_id;
- data = ini_file->ReadString( SUBBAND_NAME[band],
- "APC dc offset",
- "0");
- strcpy( str, data.c_str() );
- String_To_Array_int( str, idata, 1 );
- m_usHighApcDcOffset[band] = idata[0];
- if( m_bTADOSupport )
- {
- data = ini_file->ReadString( SUBBAND_NAME[band],
- "Low APC dc offset",
- "0");
- strcpy( str, data.c_str() );
- String_To_Array_int( str, idata, 1 );
- m_usLowApcDcOffset[band] = idata[0];
- data = ini_file->ReadString( SUBBAND_NAME[band],
- "APC lowest power",
- "0");
- strcpy( str, data.c_str() );
- String_To_Array_int( str, idata, 1 );
- m_iApcLowestPower[band] = idata[0];
- }
- data = ini_file->ReadString( SUBBAND_NAME[band],
- "TX power level",
- "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0");
- strcpy(str, data.c_str());
- String_To_Array_UnsignedShort(str, usdata, MAX_APC_PCL_NUM);
- for (i=0; i<MAX_APC_PCL_NUM; i++)
- {
- m_sApcProfile[band].rampData.power[i] = usdata[i];
- }
- for( pcl=0; pcl<16; pcl++)
- {
- sprintf( ini_section, "profile %d ramp up", pcl );
- data = ini_file->ReadString( SUBBAND_NAME[band],
- ini_section,
- "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0");
- strcpy( str, data.c_str() );
- String_To_Array_int( str, idata, 16 );
- for( i=0; i<16; i++ )
- {
- m_sApcProfile[band].rampData.ramp[pcl].point[0][i] = idata[i];
- }
- sprintf( ini_section, "profile %d ramp down", pcl );
- data = ini_file->ReadString( SUBBAND_NAME[band],
- ini_section,
- "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0");
- strcpy( str, data.c_str() );
- String_To_Array_int( str, idata, 16 );
- for( i=0; i<16; i++ )
- { m_sApcProfile[band].rampData.ramp[pcl].point[1][i] = idata[i]; }
- }
- data = ini_file->ReadString( SUBBAND_NAME[band],
- "Subband max arfcn",
- "-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1");
- strcpy( str, data.c_str() );
- String_To_Array_int( str, idata, 11 );
- idata[11] = -1;
- for( i=0; i<12; i++ )
- { m_sApcProfile[band].rampData.arfcn_weight[i].max_arfcn = idata[i]; }
- data = ini_file->ReadString( SUBBAND_NAME[band],
- "Subband mid level",
- "0,0,0,0,0,0,0,0,0,0,0");
- strcpy( str, data.c_str() );
- String_To_Array_int( str, idata, 11 );
- idata[11] = 0;
- for( i=0; i<12; i++ )
- { m_sApcProfile[band].rampData.arfcn_weight[i].mid_level = idata[i]; }
- data = ini_file->ReadString( SUBBAND_NAME[band],
- "Subband high weight",
- "1,1,1,1,1,1,1,1,1,1,1");
- strcpy( str, data.c_str() );
- String_To_Array_float( str, fdata, 11 );
- fdata[11] = 0.0;
- for( i=0; i<12; i++ )
- { m_sApcProfile[band].rampData.arfcn_weight[i].hi_weight = (int)(fdata[i]*WEIGHT_SCALE); }
- data = ini_file->ReadString( SUBBAND_NAME[band],
- "Subband low weight",
- "1,1,1,1,1,1,1,1,1,1,1");
- strcpy( str, data.c_str() );
- String_To_Array_float( str, fdata, 11 );
- fdata[11] = 0.0;
- for( i=0; i<12; i++ )
- {
- m_sApcProfile[band].rampData.arfcn_weight[i].low_weight = (int)(fdata[i]*WEIGHT_SCALE);
- }
- // battery compensate
- data = ini_file->ReadString(SUBBAND_NAME[band],
- "Battery compensate, low voltage, low temperature",
- "1.0"
- );
- m_sApcProfile[band].rampData.battery_compensate[LOW_VOLTAGE_INDEX][LOW_TEMPERATURE_INDEX]
- = atof(data.c_str()) * BATTERY_COMPENSATE_SCALE;
- data = ini_file->ReadString(SUBBAND_NAME[band],
- "Battery compensate, low voltage, mid temperature",
- "1.0");
- m_sApcProfile[band].rampData.battery_compensate[LOW_VOLTAGE_INDEX][MID_TEMPERATURE_INDEX] =
- atof(data.c_str()) * BATTERY_COMPENSATE_SCALE;
- data = ini_file->ReadString(SUBBAND_NAME[band],
- "Battery compensate, low voltage, high temperature",
- "1.0");
- m_sApcProfile[band].rampData.battery_compensate[LOW_VOLTAGE_INDEX][HIGH_TEMPERATURE_INDEX] =
- atof(data.c_str()) * BATTERY_COMPENSATE_SCALE;
- data = ini_file->ReadString(SUBBAND_NAME[band],
- "Battery compensate, mid voltage, low temperature",
- "1.0");
- m_sApcProfile[band].rampData.battery_compensate[MID_VOLTAGE_INDEX][LOW_TEMPERATURE_INDEX] =
- atof(data.c_str()) * BATTERY_COMPENSATE_SCALE;
- data = ini_file->ReadString(SUBBAND_NAME[band],
- "Battery compensate, mid voltage, mid temperature",
- "1.0");
- m_sApcProfile[band].rampData.battery_compensate[MID_VOLTAGE_INDEX][MID_TEMPERATURE_INDEX] =
- atof(data.c_str()) * BATTERY_COMPENSATE_SCALE;
- data = ini_file->ReadString(SUBBAND_NAME[band],
- "Battery compensate, mid voltage, high temperature",
- "1.0");
- m_sApcProfile[band].rampData.battery_compensate[MID_VOLTAGE_INDEX][HIGH_TEMPERATURE_INDEX] =
- atof(data.c_str()) * BATTERY_COMPENSATE_SCALE;
- data = ini_file->ReadString(SUBBAND_NAME[band],
- "Battery compensate, high voltage, low temperature",
- "1.0");
- m_sApcProfile[band].rampData.battery_compensate[HIGH_VOLTAGE_INDEX][LOW_TEMPERATURE_INDEX] =
- atof(data.c_str()) * BATTERY_COMPENSATE_SCALE;
- data = ini_file->ReadString(SUBBAND_NAME[band],
- "Battery compensate, high voltage, mid temperature",
- "1.0");
- m_sApcProfile[band].rampData.battery_compensate[HIGH_VOLTAGE_INDEX][MID_TEMPERATURE_INDEX] =
- atof(data.c_str()) * BATTERY_COMPENSATE_SCALE;
- data = ini_file->ReadString(SUBBAND_NAME[band],
- "Battery compensate, high voltage, high temperature",
- "1.0");
- m_sApcProfile[band].rampData.battery_compensate[HIGH_VOLTAGE_INDEX][HIGH_TEMPERATURE_INDEX] =
- atof(data.c_str()) * BATTERY_COMPENSATE_SCALE;
- // TX AFC DAC offset
- m_sApcProfile[band].rampData.tx_afc_offset = ini_file->ReadInteger( SUBBAND_NAME[band],
- "TX AFC DAC offset",
- 0);
- if( band==BANDSEL_GSM900 || band==BANDSEL_GSM850 )
- {
- m_sApcProfile[band].rampData.power[15] = m_sApcProfile[band].rampData.power[14];
- }
- delete ini_file;
- return true;
- }
- //-----------------------------------------------------------------------------
- bool CRFAPC::REQ_Read_APC_From_File(char *filename, unsigned int rf_id, bool b_tapo_support)
- {
- TIniFile *ini_file;
- AnsiString data;
- char ini_section[128];
- char str[2048];
- int idata[16];
- unsigned short usdata[MAX_APC_PCL_NUM];
- float fdata[16];
- int i, pcl, band;
- int total_band_num;
- ini_file = new TIniFile( filename );
- if( ini_file == NULL ) return false;
- m_bTADOSupport = b_tapo_support;
- m_uiRfModId = rf_id;
- if(frmMainSel->cbGSM850->Checked)
- { total_band_num = 4;
- }
- else
- {
- total_band_num = 3;
- }
- for( band = 0; band<total_band_num; band++)
- {
- data = ini_file->ReadString( SUBBAND_NAME[band],
- "APC dc offset",
- "0");
- strcpy( str, data.c_str() );
- String_To_Array_int( str, idata, 1 );
- m_usHighApcDcOffset[band] = idata[0];
- if (m_bTADOSupport)
- {
- data = ini_file->ReadString( SUBBAND_NAME[band],
- "Low APC dc offset",
- "0");
- strcpy( str, data.c_str() );
- String_To_Array_int( str, idata, 1 );
- m_usLowApcDcOffset[band] = idata[0];
- data = ini_file->ReadString( SUBBAND_NAME[band],
- "APC lowest power",
- "0");
- strcpy( str, data.c_str() );
- String_To_Array_int( str, idata, 1 );
- m_iApcLowestPower[band] = idata[0];
- }
- data = ini_file->ReadString( SUBBAND_NAME[band],
- "TX power level",
- "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0");
- strcpy(str, data.c_str());
- String_To_Array_UnsignedShort(str, usdata, 16);
- for (i=0; i<MAX_APC_PCL_NUM; i++)
- {
- m_sApcProfile[band].rampData.power[i] = usdata[i];
- }
- for( pcl=0; pcl<16; pcl++)
- {
- sprintf( ini_section, "profile %d ramp up", pcl );
- data = ini_file->ReadString( SUBBAND_NAME[band],
- ini_section,
- "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0");
- strcpy( str, data.c_str() );
- String_To_Array_int( str, idata, 16 );
- for (i=0; i<16; i++)
- {
- m_sApcProfile[band].rampData.ramp[pcl].point[0][i] = idata[i];
- }
- sprintf( ini_section, "profile %d ramp down", pcl );
- data = ini_file->ReadString( SUBBAND_NAME[band],
- ini_section,
- "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0");
- strcpy( str, data.c_str() );
- String_To_Array_int( str, idata, 16 );
- for( i=0; i<16; i++ )
- { m_sApcProfile[band].rampData.ramp[pcl].point[1][i] = idata[i]; }
- }
- data = ini_file->ReadString( SUBBAND_NAME[band],
- "Subband max arfcn",
- "-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1");
- strcpy( str, data.c_str() );
- String_To_Array_int( str, idata, 11 );
- idata[11] = -1;
- for( i=0; i<12; i++ )
- { m_sApcProfile[band].rampData.arfcn_weight[i].max_arfcn = idata[i]; }
- data = ini_file->ReadString( SUBBAND_NAME[band],
- "Subband mid level",
- "0,0,0,0,0,0,0,0,0,0,0");
- strcpy( str, data.c_str() );
- String_To_Array_int( str, idata, 11 );
- idata[11] = 0;
- for( i=0; i<12; i++ )
- { m_sApcProfile[band].rampData.arfcn_weight[i].mid_level = idata[i]; }
- data = ini_file->ReadString( SUBBAND_NAME[band],
- "Subband high weight",
- "1,1,1,1,1,1,1,1,1,1,1");
- strcpy( str, data.c_str() );
- String_To_Array_float( str, fdata, 11 );
- fdata[11] = 0.0;
- for( i=0; i<12; i++ )
- { m_sApcProfile[band].rampData.arfcn_weight[i].hi_weight = (int)(fdata[i]*WEIGHT_SCALE); }
- data = ini_file->ReadString( SUBBAND_NAME[band],
- "Subband low weight",
- "1,1,1,1,1,1,1,1,1,1,1");
- strcpy( str, data.c_str() );
- String_To_Array_float( str, fdata, 11 );
- fdata[11] = 0.0;
- for( i=0; i<12; i++ )
- { m_sApcProfile[band].rampData.arfcn_weight[i].low_weight = (int)(fdata[i]*WEIGHT_SCALE);
- }
- // battery compensate
- data = ini_file->ReadString(SUBBAND_NAME[band],
- "Battery compensate, low voltage, low temperature",
- "1.0");
- m_sApcProfile[band].rampData.battery_compensate[LOW_VOLTAGE_INDEX][LOW_TEMPERATURE_INDEX] =
- atof(data.c_str()) * BATTERY_COMPENSATE_SCALE;
- data = ini_file->ReadString(SUBBAND_NAME[band],
- "Battery compensate, low voltage, mid temperature",
- "1.0");
- m_sApcProfile[band].rampData.battery_compensate[LOW_VOLTAGE_INDEX][MID_TEMPERATURE_INDEX] =
- atof(data.c_str()) * BATTERY_COMPENSATE_SCALE;
- data = ini_file->ReadString(SUBBAND_NAME[band],
- "Battery compensate, low voltage, high temperature",
- "1.0");
- m_sApcProfile[band].rampData.battery_compensate[LOW_VOLTAGE_INDEX][HIGH_TEMPERATURE_INDEX] =
- atof(data.c_str()) * BATTERY_COMPENSATE_SCALE;
- data = ini_file->ReadString(SUBBAND_NAME[band],
- "Battery compensate, mid voltage, low temperature",
- "1.0");
- m_sApcProfile[band].rampData.battery_compensate[MID_VOLTAGE_INDEX][LOW_TEMPERATURE_INDEX] =
- atof(data.c_str()) * BATTERY_COMPENSATE_SCALE;
- data = ini_file->ReadString(SUBBAND_NAME[band],
- "Battery compensate, mid voltage, mid temperature",
- "1.0");
- m_sApcProfile[band].rampData.battery_compensate[MID_VOLTAGE_INDEX][MID_TEMPERATURE_INDEX] =
- atof(data.c_str()) * BATTERY_COMPENSATE_SCALE;
- data = ini_file->ReadString(SUBBAND_NAME[band],
- "Battery compensate, mid voltage, high temperature",
- "1.0");
- m_sApcProfile[band].rampData.battery_compensate[MID_VOLTAGE_INDEX][HIGH_TEMPERATURE_INDEX] =
- atof(data.c_str()) * BATTERY_COMPENSATE_SCALE;
- data = ini_file->ReadString(SUBBAND_NAME[band],
- "Battery compensate, high voltage, low temperature",
- "1.0");
- m_sApcProfile[band].rampData.battery_compensate[HIGH_VOLTAGE_INDEX][LOW_TEMPERATURE_INDEX] =
- atof(data.c_str()) * BATTERY_COMPENSATE_SCALE;
- data = ini_file->ReadString(SUBBAND_NAME[band],
- "Battery compensate, high voltage, mid temperature",
- "1.0");
- m_sApcProfile[band].rampData.battery_compensate[HIGH_VOLTAGE_INDEX][MID_TEMPERATURE_INDEX] =
- atof(data.c_str()) * BATTERY_COMPENSATE_SCALE;
- data = ini_file->ReadString(SUBBAND_NAME[band],
- "Battery compensate, high voltage, high temperature",
- "1.0");
- m_sApcProfile[band].rampData.battery_compensate[HIGH_VOLTAGE_INDEX][HIGH_TEMPERATURE_INDEX] =
- atof(data.c_str()) * BATTERY_COMPENSATE_SCALE;
- // TX AFC DAC offset
- m_sApcProfile[band].rampData.tx_afc_offset = ini_file->ReadInteger( SUBBAND_NAME[band],
- "TX AFC DAC offset",
- 0);
- }
- delete ini_file;
- band = BANDSEL_GSM900;
- m_sApcProfile[band].rampData.power[15] = m_sApcProfile[band].rampData.power[14];
- if( frmMainSel->cbGSM850->Checked )
- {
- band = BANDSEL_GSM850;
- m_sApcProfile[band].rampData.power[15] = m_sApcProfile[band].rampData.power[14];
- }
- return true;
- }
- //===========================================================================
- bool CRFAPC::REQ_Write_APC_To_File_Single_Band(char *filename, unsigned int rf_id, int band, bool b_tapo_support)
- {
- TIniFile *ini_file;
- AnsiString data;
- char ini_section[128];
- char str[2048];
- int idata[MAX_APC_PCL_NUM];
- float fdata[MAX_APC_PCL_NUM];
- unsigned short usdata[MAX_APC_PCL_NUM];
- unsigned char ucdata[MAX_APC_PCL_NUM];
- int i, pcl;
- ini_file = new TIniFile(filename);
- if (NULL == ini_file)
- {
- return false;
- }
- m_bTADOSupport = b_tapo_support;
- m_uiRfModId = rf_id;
- usdata[0] = m_usHighApcDcOffset[band];
- sprintf(str, "%d", usdata[0] );
- ini_file->WriteString( SUBBAND_NAME[band],
- "APC dc offset",
- str );
- if (m_bTADOSupport)
- {
- usdata[0] = m_usLowApcDcOffset[band];
- sprintf(str, "%d", usdata[0] );
- ini_file->WriteString( SUBBAND_NAME[band],
- "Low APC dc offset",
- str );
- usdata[0] = m_iApcLowestPower[band];
- sprintf(str, "%d", usdata[0] );
- ini_file->WriteString( SUBBAND_NAME[band],
- "APC lowest power",
- str );
- }
- if (BANDSEL_GSM900 == band || BANDSEL_GSM850 == band)
- {
- m_sApcProfile[band].rampData.power[15] = m_sApcProfile[band].rampData.power[14];
- }
- // TX power level
- for (i=0; i<MAX_APC_PCL_NUM ; i++)
- {
- usdata[i] = m_sApcProfile[band].rampData.power[i];
- }
- Array_To_String_UnsignedShort(str, usdata, MAX_APC_PCL_NUM , ',');
- ini_file->WriteString( SUBBAND_NAME[band],
- "TX power level",
- str );
- // ramp
- for (pcl=0; pcl<MAX_APC_PCL_NUM ; pcl++)
- {
- for (i=0; i<APC_RAMP_UP_NUM; i++)
- {
- ucdata[i] = m_sApcProfile[band].rampData.ramp[pcl].point[0][i];
- }
- Array_To_String_UnsignedChar(str, ucdata, APC_RAMP_UP_NUM, ',');
- sprintf(ini_section, "profile %d ramp up", pcl);
- ini_file->WriteString( SUBBAND_NAME[band],
- ini_section,
- str);
- for (i=0; i<APC_RAMP_DN_NUM; i++ )
- {
- ucdata[i] = m_sApcProfile[band].rampData.ramp[pcl].point[1][i];
- }
- Array_To_String_UnsignedChar(str, ucdata, APC_RAMP_DN_NUM, ',');
- sprintf( ini_section, "profile %d ramp down", pcl );
- ini_file->WriteString( SUBBAND_NAME[band],
- ini_section,
- str);
- }
- for (i=0; i<ARFCN_SECTION_NUM-1; i++)
- {
- idata[i] = m_sApcProfile[band].rampData.arfcn_weight[i].max_arfcn;
- }
- idata[ARFCN_SECTION_NUM-1] = -1;
- Array_To_String_int( str, idata, 11, ',' );
- ini_file->WriteString( SUBBAND_NAME[band],
- "Subband max arfcn",
- str);
- for (i=0; i<ARFCN_SECTION_NUM-1; i++)
- {
- idata[i] = m_sApcProfile[band].rampData.arfcn_weight[i].mid_level;
- }
- idata[ARFCN_SECTION_NUM-1] = 0;
- Array_To_String_int(str, idata, ARFCN_SECTION_NUM-1, ',');
- ini_file->WriteString( SUBBAND_NAME[band],
- "Subband mid level",
- str);
- for (i=0; i<ARFCN_SECTION_NUM-1; i++)
- {
- fdata[i] = m_sApcProfile[band].rampData.arfcn_weight[i].hi_weight*1.0/WEIGHT_SCALE;
- }
- fdata[ARFCN_SECTION_NUM-1] = 0;
- Array_To_String_float(str, fdata, ARFCN_SECTION_NUM-1, ',');
- ini_file->WriteString(SUBBAND_NAME[band],
- "Subband high weight",
- str);
- for (i=0; i<ARFCN_SECTION_NUM-1; i++)
- {
- fdata[i] = m_sApcProfile[band].rampData.arfcn_weight[i].low_weight*1.0/WEIGHT_SCALE;
- }
- fdata[ARFCN_SECTION_NUM-1] = 0;
- Array_To_String_float( str, fdata, ARFCN_SECTION_NUM-1, ',' );
- ini_file->WriteString( SUBBAND_NAME[band],
- "Subband low weight",
- str);
- // battery compensate
- ini_file->WriteString( SUBBAND_NAME[band],
- "Battery compensate, low voltage, low temperature",
- Double_To_AnsiString( (long) (m_sApcProfile[band].rampData.battery_compensate[LOW_VOLTAGE_INDEX][LOW_TEMPERATURE_INDEX]*1.0/BATTERY_COMPENSATE_SCALE*1000+0.5)/1000.0) );
- ini_file->WriteString( SUBBAND_NAME[band],
- "Battery compensate, low voltage, mid temperature",
- Double_To_AnsiString( (long) (m_sApcProfile[band].rampData.battery_compensate[LOW_VOLTAGE_INDEX][MID_TEMPERATURE_INDEX]*1.0/BATTERY_COMPENSATE_SCALE*1000+0.5)/1000.0) );
- ini_file->WriteString( SUBBAND_NAME[band],
- "Battery compensate, low voltage, high temperature",
- Double_To_AnsiString( (long) (m_sApcProfile[band].rampData.battery_compensate[LOW_VOLTAGE_INDEX][HIGH_TEMPERATURE_INDEX]*1.0/BATTERY_COMPENSATE_SCALE*1000+0.5)/1000.0) );
- ini_file->WriteString( SUBBAND_NAME[band],
- "Battery compensate, mid voltage, low temperature",
- Double_To_AnsiString( (long) (m_sApcProfile[band].rampData.battery_compensate[MID_VOLTAGE_INDEX][LOW_TEMPERATURE_INDEX]*1.0/BATTERY_COMPENSATE_SCALE*1000+0.5)/1000.0) );
- ini_file->WriteString( SUBBAND_NAME[band],
- "Battery compensate, mid voltage, mid temperature",
- Double_To_AnsiString( (long) (m_sApcProfile[band].rampData.battery_compensate[MID_VOLTAGE_INDEX][MID_TEMPERATURE_INDEX]*1.0/BATTERY_COMPENSATE_SCALE*1000+0.5)/1000.0) );
- ini_file->WriteString( SUBBAND_NAME[band],
- "Battery compensate, mid voltage, high temperature",
- Double_To_AnsiString( (long) (m_sApcProfile[band].rampData.battery_compensate[MID_VOLTAGE_INDEX][HIGH_TEMPERATURE_INDEX]*1.0/BATTERY_COMPENSATE_SCALE*1000+0.5)/1000.0) );
- ini_file->WriteString( SUBBAND_NAME[band],
- "Battery compensate, high voltage, low temperature",
- Double_To_AnsiString( (long) (m_sApcProfile[band].rampData.battery_compensate[HIGH_VOLTAGE_INDEX][LOW_TEMPERATURE_INDEX]*1.0/BATTERY_COMPENSATE_SCALE*1000+0.5)/1000.0) );
- ini_file->WriteString( SUBBAND_NAME[band],
- "Battery compensate, high voltage, mid temperature",
- Double_To_AnsiString( (long) (m_sApcProfile[band].rampData.battery_compensate[HIGH_VOLTAGE_INDEX][MID_TEMPERATURE_INDEX]*1.0/BATTERY_COMPENSATE_SCALE*1000+0.5)/1000.0) );
- ini_file->WriteString( SUBBAND_NAME[band],
- "Battery compensate, high voltage, high temperature",
- Double_To_AnsiString( (long) (m_sApcProfile[band].rampData.battery_compensate[HIGH_VOLTAGE_INDEX][HIGH_TEMPERATURE_INDEX]*1.0/BATTERY_COMPENSATE_SCALE*1000+0.5)/1000.0) );
- ini_file->WriteString( SUBBAND_NAME[band],
- "TX AFC DAC offset",
- m_sApcProfile[band].rampData.tx_afc_offset);
- delete ini_file;
- return true;
- }
- //--------------------------------------------------------------------------
- bool CRFAPC::REQ_Write_APC_To_File(char *filename, unsigned int rf_id, bool b_tapo_support)
- {
- TIniFile *ini_file;
- AnsiString data;
- char ini_section[128];
- char str[2048];
- int idata[16];
- unsigned short usdata[MAX_APC_PCL_NUM];
- unsigned char ucdata[MAX_APC_PCL_NUM];
- float fdata[16];
- int i, pcl;
- int total_band_num;
- ini_file = new TIniFile( filename );
- if( ini_file == NULL ) return false;
- m_uiRfModId = rf_id;
- m_bTADOSupport = b_tapo_support;
- m_sApcProfile[BANDSEL_GSM900].rampData.power[15] = m_sApcProfile[BANDSEL_GSM900].rampData.power[14];
- m_sApcProfile[BANDSEL_GSM850].rampData.power[15] = m_sApcProfile[BANDSEL_GSM850].rampData.power[14];
- if( frmMainSel->cbGSM850->Checked )
- { total_band_num = 4;
- }
- else
- {
- total_band_num = 3;
- }
- for (int band = 0; band<total_band_num; band++)
- {
- sprintf(str, "%d", m_usHighApcDcOffset[band] );
- ini_file->WriteString( SUBBAND_NAME[band],
- "APC dc offset",
- str );
- if (m_bTADOSupport)
- {
- sprintf(str, "%d", m_usLowApcDcOffset[band] );
- ini_file->WriteString( SUBBAND_NAME[band],
- "Low APC dc offset",
- str );
- sprintf(str, "%d", m_iApcLowestPower[band] );
- ini_file->WriteString( SUBBAND_NAME[band],
- "APC lowest power",
- str );
- }
- for (i=0; i<MAX_APC_PCL_NUM; i++)
- {
- usdata[i] = m_sApcProfile[band].rampData.power[i];
- }
- Array_To_String_UnsignedShort(str, usdata, MAX_APC_PCL_NUM, ',');
- ini_file->WriteString(SUBBAND_NAME[band],
- "TX power level",
- str );
- for (pcl=0; pcl<MAX_APC_PCL_NUM; pcl++)
- {
- for (i=0; i<APC_RAMP_UP_NUM; i++)
- {
- ucdata[i] = m_sApcProfile[band].rampData.ramp[pcl].point[0][i];
- }
- Array_To_String_UnsignedChar(str, ucdata, 16, ',');
- sprintf(ini_section, "profile %d ramp up", pcl);
- ini_file->WriteString( SUBBAND_NAME[band],
- ini_section,
- str);
- for( i=0; i<APC_RAMP_DN_NUM; i++ )
- {
- ucdata[i] = m_sApcProfile[band].rampData.ramp[pcl].point[1][i];
- }
- Array_To_String_UnsignedChar(str, ucdata, 16, ',');
- sprintf(ini_section, "profile %d ramp down", pcl);
- ini_file->WriteString(SUBBAND_NAME[band],
- ini_section,
- str);
- }
- for( i=0; i<11; i++ )
- { idata[i] = m_sApcProfile[band].rampData.arfcn_weight[i].max_arfcn; }
- idata[11] = -1;
- Array_To_String_int( str, idata, 11, ',' );
- ini_file->WriteString( SUBBAND_NAME[band],
- "Subband max arfcn",
- str);
- for( i=0; i<11; i++ )
- { idata[i] = m_sApcProfile[band].rampData.arfcn_weight[i].mid_level; }
- idata[11] = 0;
- Array_To_String_int( str, idata, 11, ',' );
- ini_file->WriteString( SUBBAND_NAME[band],
- "Subband mid level",
- str);
- for( i=0; i<11; i++ )
- { fdata[i] = m_sApcProfile[band].rampData.arfcn_weight[i].hi_weight*1.0/WEIGHT_SCALE; }
- fdata[11] = 0;
- Array_To_String_float( str, fdata, 11, ',' );
- ini_file->WriteString( SUBBAND_NAME[band],
- "Subband high weight",
- str);
- for( i=0; i<11; i++ )
- { fdata[i] = m_sApcProfile[band].rampData.arfcn_weight[i].low_weight*1.0/WEIGHT_SCALE; }
- fdata[11] = 0;
- Array_To_String_float( str, fdata, 11, ',' );
- ini_file->WriteString( SUBBAND_NAME[band],
- "Subband low weight",
- str);
- // battery compensate
- ini_file->WriteString( SUBBAND_NAME[band],
- "Battery compensate, low voltage, low temperature",
- Double_To_AnsiString( (long) (m_sApcProfile[band].rampData.battery_compensate[LOW_VOLTAGE_INDEX][LOW_TEMPERATURE_INDEX]*1.0/BATTERY_COMPENSATE_SCALE*1000+0.5)/1000.0) );
- ini_file->WriteString( SUBBAND_NAME[band],
- "Battery compensate, low voltage, mid temperature",
- Double_To_AnsiString( (long) (m_sApcProfile[band].rampData.battery_compensate[LOW_VOLTAGE_INDEX][MID_TEMPERATURE_INDEX]*1.0/BATTERY_COMPENSATE_SCALE*1000+0.5)/1000.0 ) );
- ini_file->WriteString( SUBBAND_NAME[band],
- "Battery compensate, low voltage, high temperature",
- Double_To_AnsiString( (long) (m_sApcProfile[band].rampData.battery_compensate[LOW_VOLTAGE_INDEX][HIGH_TEMPERATURE_INDEX]*1.0/BATTERY_COMPENSATE_SCALE*1000+0.5)/1000.0 ) );
- ini_file->WriteString( SUBBAND_NAME[band],
- "Battery compensate, mid voltage, low temperature",
- Double_To_AnsiString( (long) (m_sApcProfile[band].rampData.battery_compensate[MID_VOLTAGE_INDEX][LOW_TEMPERATURE_INDEX]*1.0/BATTERY_COMPENSATE_SCALE*1000+0.5)/1000.0 ) );
- ini_file->WriteString( SUBBAND_NAME[band],
- "Battery compensate, mid voltage, mid temperature",
- Double_To_AnsiString( (long) (m_sApcProfile[band].rampData.battery_compensate[MID_VOLTAGE_INDEX][MID_TEMPERATURE_INDEX]*1.0/BATTERY_COMPENSATE_SCALE*1000+0.5)/1000.0 ) );
- ini_file->WriteString( SUBBAND_NAME[band],
- "Battery compensate, mid voltage, high temperature",
- Double_To_AnsiString( (long) (m_sApcProfile[band].rampData.battery_compensate[MID_VOLTAGE_INDEX][HIGH_TEMPERATURE_INDEX]*1.0/BATTERY_COMPENSATE_SCALE*1000+0.5)/1000.0 ) );
- ini_file->WriteString( SUBBAND_NAME[band],
- "Battery compensate, high voltage, low temperature",
- Double_To_AnsiString( (long) (m_sApcProfile[band].rampData.battery_compensate[HIGH_VOLTAGE_INDEX][LOW_TEMPERATURE_INDEX]*1.0/BATTERY_COMPENSATE_SCALE*1000+0.5)/1000.0 ) );
- ini_file->WriteString( SUBBAND_NAME[band],
- "Battery compensate, high voltage, mid temperature",
- Double_To_AnsiString( (long) (m_sApcProfile[band].rampData.battery_compensate[HIGH_VOLTAGE_INDEX][MID_TEMPERATURE_INDEX]*1.0/BATTERY_COMPENSATE_SCALE*1000+0.5)/1000.0 ) );
- ini_file->WriteString( SUBBAND_NAME[band],
- "Battery compensate, high voltage, high temperature",
- Double_To_AnsiString( (long) (m_sApcProfile[band].rampData.battery_compensate[HIGH_VOLTAGE_INDEX][HIGH_TEMPERATURE_INDEX]*1.0/BATTERY_COMPENSATE_SCALE*1000+0.5)/1000.0 ) );
- ini_file->WriteString( SUBBAND_NAME[band],
- "TX AFC DAC offset",
- m_sApcProfile[band].rampData.tx_afc_offset);
- }
- delete ini_file;
- return true;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- bool CRFAPC::REQ_Read_Word3_From_File( char *filename )
- {
- TIniFile *ini_file;
- ini_file = new TIniFile( filename );
- if( ini_file == NULL ) return false;
- b5p_coef.tx.c3mode = ini_file->ReadInteger( SUBBAND_NAME_WORD3, "c3mode",0);
- b5p_coef.tx.wordC3 = ini_file->ReadInteger( SUBBAND_NAME_WORD3, "WordC3",0);
- delete ini_file;
- return true;
- }
- //---------------------------------------------------------------------------
- bool CRFAPC::REQ_Write_Word3_To_File( char *filename )
- {
- TIniFile *ini_file;
- ini_file = new TIniFile( filename );
- if( ini_file == NULL ) return false;
- ini_file->WriteString(SUBBAND_NAME_WORD3, "c3mode", b5p_coef.tx.c3mode );
- ini_file->WriteString(SUBBAND_NAME_WORD3, "WordC3", b5p_coef.tx.wordC3 );
- delete ini_file;
- return true;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- bool CRFAPC::REQ_Read_Word6s_From_File( char *filename )
- {
- TIniFile *ini_file;
- ini_file = new TIniFile( filename );
- if( ini_file == NULL ) return false;
- b5p_coef.tx.bvmode = ini_file->ReadInteger( SUBBAND_NAME_WORD6S,"bvmode",0);
- b5p_coef.tx.word6_4_0 = ini_file->ReadInteger( SUBBAND_NAME_WORD6S,"W6-4-0",0);
- b5p_coef.tx.word6_5_0 = ini_file->ReadInteger( SUBBAND_NAME_WORD6S,"W6-5-0",0);
- b5p_coef.tx.word6_6_0 = ini_file->ReadInteger( SUBBAND_NAME_WORD6S,"W6-6-0",0);
- b5p_coef.tx.word6_7_0 = ini_file->ReadInteger( SUBBAND_NAME_WORD6S,"W6-7-0",0);
- delete ini_file;
- return true;
- }
- //---------------------------------------------------------------------------
- bool CRFAPC::REQ_Read_W64_From_File( TIniFile *ini_file )
- {
- #if 0
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "BD",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "AO",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "AS",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "AP",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "KAG",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "KSG",
- );
- #endif
- return true;
- }
- //---------------------------------------------------------------------------
- bool CRFAPC::REQ_Read_W65_From_File( TIniFile *ini_file )
- {
- #if 0
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "BD",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "AO",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "AS",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "AP",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "KAD",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "KSD",
- );
- #endif
- return true;
- }
- //---------------------------------------------------------------------------
- bool CRFAPC::REQ_Read_W66_From_File( TIniFile *ini_file )
- {
- #if 0
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "BD",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "AO",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "AS",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "AP",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "VRE",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "VOF",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "ARE",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "AOF",
- );
- #endif
- return true;
- }
- //---------------------------------------------------------------------------
- bool CRFAPC::REQ_Read_W67_From_File( TIniFile *ini_file )
- {
- #if 0
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "BD",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "AO",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "AS",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "AP",
- );
- #endif
- return true;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- bool CRFAPC::REQ_Write_Word6s_To_File( char *filename )
- {
- TIniFile *ini_file;
- ini_file = new TIniFile( filename );
- if( ini_file == NULL ) return false;
- ini_file->WriteString( SUBBAND_NAME_WORD6S,"bvmode",b5p_coef.tx.bvmode);
- ini_file->WriteString( SUBBAND_NAME_WORD6S,"W6-4-0",b5p_coef.tx.word6_4_0);
- ini_file->WriteString( SUBBAND_NAME_WORD6S,"W6-5-0",b5p_coef.tx.word6_5_0);
- ini_file->WriteString( SUBBAND_NAME_WORD6S,"W6-6-0",b5p_coef.tx.word6_6_0);
- ini_file->WriteString( SUBBAND_NAME_WORD6S,"W6-7-0",b5p_coef.tx.word6_7_0);
- delete ini_file;
- return true;
- }
- //---------------------------------------------------------------------------
- bool CRFAPC::REQ_Write_W64_To_File( TIniFile *ini_file )
- {
- #if 0
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "BD",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "AO",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "AS",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "AP",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "KAG",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "KSG",
- );
- #endif
- return true;
- }
- //---------------------------------------------------------------------------
- bool CRFAPC::REQ_Write_W65_To_File( TIniFile *ini_file )
- {
- #if 0
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "BD",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "AO",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "AS",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "AP",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "KAD",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "KSD",
- );
- #endif
- return true;
- }
- //---------------------------------------------------------------------------
- bool CRFAPC::REQ_Write_W66_To_File( TIniFile *ini_file )
- {
- #if 0
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "BD",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "AO",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "AS",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "AP",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "VRE",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "VOF",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "ARE",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "AOF",
- );
- #endif
- return true;
- }
- //---------------------------------------------------------------------------
- bool CRFAPC::REQ_Write_W67_To_File( TIniFile *ini_file )
- {
- #if 0
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "BD",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "AO",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "AS",
- );
- ini_file->WriteString( SUBBAND_NAME_BV[band],
- "AP",
- );
-
- #endif
- return true;
- }
- //---------------------------------------------------------------------------
- bool CRFAPC::REQ_Write_To_M12193(char *filename, unsigned int rf_id)
- {
- FILE *fs;
- int arfcn, loss;
- int band, profile, i;
- fs = fopen( filename, "a+t" );
- if (fs==NULL) return(false);
- fprintf( fs, "/*----------------------------------------*/n");
- fprintf( fs, "/* Calibration data for power ramp */n");
- fprintf( fs, "/*----------------------------------------*/n");
- fprintf( fs, "n");
- fprintf( fs, "#define APC_DC_OFFSET %dn", m_usHighApcDcOffset[0]);
- for(band=0; band<3; band++)
- {
- fprintf( fs, "n");
- fprintf( fs, "/* %s....................................................................*/n", BAND_NAME2[band] );
- fprintf( fs, "n");
- fprintf( fs, "sRAMPDATA %s_RampData =n", BAND_NAME1[band] );
- fprintf( fs, "{n");
- fprintf( fs, " /*-------------------------------------------------------------------------------------------*/n");
- fprintf( fs, " /* lowest power */n");
- fprintf( fs, " ((APC_DC_OFFSET)<<8) | %d,n", LOWEST_POWER[band] );
- fprintf( fs, " /*-------------------------------------------------------------------------------------------*/n");
- fprintf( fs, " /* power level */n");
- fprintf( fs, "%s", BAND_PCL_COMMENT[band] );
- fprintf( fs, " { ");
- for(i=0; i<15; i++) fprintf( fs, "%3d,", m_sApcProfile[band].rampData.power[i] );
- fprintf( fs, "%3d },n", m_sApcProfile[band].rampData.power[15] );
- fprintf( fs, " /*-------------------------------------------------------------------------------------------*/n");
- fprintf( fs, " {n");
- for( profile=0; profile<16; profile++ )
- {
- fprintf( fs, " /* profile %2d : %2d dBm | p00,p01,p02,p03,p04,p05,p06,p07,p08,p09,p10,p11,p12,p13,p14,p15 */n", profile, LOWEST_POWER[band]+2*profile);
- fprintf( fs, " { /* ramp up */ { { ");
- for(i=0; i<15; i++) fprintf( fs, "%3d,", m_sApcProfile[band].rampData.ramp[profile].point[0][i] );
- fprintf( fs, "%3d },n", m_sApcProfile[band].rampData.ramp[profile].point[0][15] );
- fprintf( fs, " /* ramp down */ { ");
- for(i=0; i<15; i++) fprintf( fs, "%3d,", m_sApcProfile[band].rampData.ramp[profile].point[1][i] );
- fprintf( fs, "%3d } }n", m_sApcProfile[band].rampData.ramp[profile].point[1][15] );
- fprintf( fs, " }, /*-------------------------------------------------------------------------------------*/n");
- }
- fprintf( fs, " },n");
- fprintf( fs, " /* ARFCN WEIGHT */n");
- fprintf( fs, " { /* max arfcn , mid_level , hi_weight , lo_weight */n");
- for(i=0; i<11; i++)
- { int arfcn = m_sApcProfile[band].rampData.arfcn_weight[i].max_arfcn;
- if( (arfcn<0)||(arfcn>1023) ) break;
- int mid_level = PCL2POWER(band, m_sApcProfile[band].rampData.arfcn_weight[i].mid_level);
- int hi_weight = m_sApcProfile[band].rampData.arfcn_weight[i].hi_weight;
- int lo_weight = m_sApcProfile[band].rampData.arfcn_weight[i].low_weight;
- fprintf( fs, " { %4d , %2d , WEIGHT(%.3f), WEIGHT(%.3f) },n", arfcn, mid_level, (float)(1.0*hi_weight/WEIGHT_SCALE), (float)(1.0*lo_weight/WEIGHT_SCALE));
- }
- fprintf( fs, " /*------------------------------------------------------*/n");
- fprintf( fs, " { TABLE_END }n");
- fprintf( fs, " },n");
- fprintf( fs, "};n");
- fprintf( fs, "n");
- }
- fprintf( fs, "/*..........................................................................*/n");
- fprintf( fs, "n");
- fprintf( fs, "sRAMPDATA* RampData[] =n");
- fprintf( fs, "{n");
- fprintf( fs, " 0, /* FrequencyBand400 (not support) */n");
- fprintf( fs, " 0, /* FrequencyBand850 (not support) */n");
- fprintf( fs, " &GSM_RampData, /* FrequencyBand900 */n");
- fprintf( fs, " &DCS_RampData, /* FrequencyBand1800 */n");
- fprintf( fs, " &PCS_RampData, /* FrequencyBand1900 */n");
- fprintf( fs, "};n");
- fprintf( fs, "n");
- fprintf( fs, "#undef APC_DC_OFFSETn");
- fclose(fs);
- return(true);
- }
- //===========================================================================
- void CRFAPC::Req_Rf_SetRampApcLevel(FrequencyBand rf_band, int power_level, int apc_dac)
- {
- g_bIsRunning = true;
- RampApcLevelReq.rf_band = rf_band;
- RampApcLevelReq.power_level = power_level;
- RampApcLevelReq.apc_dac = apc_dac;
- META_RESULT MetaResult = META_Rf_SetRampApcLevel_r(m_META_HANDLE_Obj.Get_MainHandle(), &RampApcLevelReq, ::CNF_RfSetRampApcLevl, &RampApcLevelToken, NULL);
- if(MetaResult!=META_SUCCESS)
- { Confirm( METAAPP_FAIL ); return; }
- }
- //-------------------------------------------------------------------------------------------------
- void __stdcall CRFAPC::CNF_RfSetRampApcLevl(const unsigned char cnf, const short token, void *usrData)
- {
- if(cnf == false)
- { Confirm( METAAPP_FAIL ); return; }
- ActiveMan->SetActiveFunction( ::REQ_Finish );
- }
- #if 0
- //----------------------------------------------------------------------------
- bool CRFAPC::Req_SetWord3ToReg( RF_BRIGHT5P_Coef_T &rf_mod_coef )
- {
- b5p_coef = rf_mod_coef;
- MetaResult = META_Rf_BRIGHT5P_SetSpecialCoef_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, &b5p_coef);
- if(MetaResult!=META_SUCCESS)
- {
- Confirm( METAAPP_FAIL );
- return false;
- }
- ActiveMan->SetActiveFunction( ::REQ_Finish );
- return true;
- }
- #endif
- //----------------------------------------------------------------------------
- bool CRFAPC::Req_SetB5PToReg( RF_BRIGHT5P_Coef_T &rf_mod_coef )
- {
- b5p_coef = rf_mod_coef;
- META_RESULT MetaResult = META_Rf_BRIGHT5P_SetSpecialCoef_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, &b5p_coef);
- if(MetaResult!=META_SUCCESS)
- {
- Confirm( METAAPP_FAIL );
- return false;
- }
- ActiveMan->SetActiveFunction( ::REQ_Finish );
- return true;
- }
- //-----------------------------------------------------------------------------
- bool CRFAPC::Set_RenesasCoef( RF_BRIGHT5P_Coef_T &rf_mod_coef )
- {
- b5p_coef = rf_mod_coef;
- return true;
- }
- //-----------------------------------------------------------------------------
- bool CRFAPC::Get_RenesasCoef( RF_BRIGHT5P_Coef_T &rf_mod_coef )
- {
- rf_mod_coef = b5p_coef;
- return true;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- bool CRFAPC::Get_BvMode( void )
- {
- return b5p_coef.tx.bvmode;
- }
- //-----------------------------------------------------------------------------
- void CRFAPC::Set_BvMode( unsigned int bvmode )
- {
- b5p_coef.tx.bvmode = bvmode;
- }
- //-----------------------------------------------------------------------------
- void CRFAPC::REQ_SetW6sImmediateBSI_Start( unsigned int w6s )
- {
- W6S = w6s;
- ActiveMan->SetActiveFunction( ::REQ_SetW6sImmediateBSI );
- }
- //-----------------------------------------------------------------------------
- void CRFAPC::REQ_SetW6sImmediateBSI( void )
- {
- META_RESULT MetaResult = META_Rf_SetRFImmediateBSI_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, W6S);
- if(MetaResult!=META_SUCCESS)
- {
- Confirm( METAAPP_FAIL );
- return;
- }
- ActiveMan->SetActiveFunction( ::REQ_Finish );
- }
- //=============================================================================
- bool CRFAPC::Get_SubBandWeighting(l1cal_rampTable_T apc_profile, int arfcn, unsigned short pcl, unsigned short &weight)
- {
- short max_arfcn;
- for(int i=0; i<ARFCN_SECTION_NUM; i++ )
- {
- max_arfcn = apc_profile.rampData.arfcn_weight[i].max_arfcn;
- if (max_arfcn == -1) return false;
- if (arfcn <= max_arfcn)
- {
- if( pcl >= apc_profile.rampData.arfcn_weight[i].mid_level )
- {
- weight = apc_profile.rampData.arfcn_weight[i].low_weight;
- }
- else
- {
- weight = apc_profile.rampData.arfcn_weight[i].hi_weight;
- }
- break;
- }
- }
- return true;
- }
- //----------------------------------------------------------------------------
- bool CRFAPC::Get_RightTopRampUpValue(l1cal_rampTable_T apc_profile, E_BANDSEL band_idx, int pcl_idx, unsigned short &ramp_value)
- {
- switch (band_idx)
- {
- case BANDSEL_GSM850:
- case BANDSEL_GSM900:
- case BANDSEL_DCS1800:
- case BANDSEL_PCS1900:
- {
- ramp_value = apc_profile.rampData.ramp[pcl_idx].point[RAMP_UP_INDEX][15];
- }
- break;
- default:
- return false;
-
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool CRFAPC::Get_BatteryCompensate( l1cal_rampTable_T apc_profile, int voltage_idx, int temp_idx, unsigned short &battery_compensate)
- {
- if( voltage_idx > 2 || temp_idx > 2 ) return false;
- battery_compensate = apc_profile.rampData.battery_compensate[voltage_idx][temp_idx];
- return true;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CRFAPC::REQ_RfSetRampTable_Start(unsigned int rf_id, bool b_tapo_support, int band_idx)
- {
- rf_apc_ptr = this;
- g_bIsRunning = true;
- CurWRBand = band_idx;
- m_uiRfModId = rf_id;
- m_bTADOSupport = b_tapo_support;
- ActiveMan->SetActiveFunction( ::REQ_RfSetRampTable );
- }
- //-------------------------------------------------------------------------
- bool CRFAPC::REQ_RfSetRampTable( void )
- {
- int band = CurWRBand;
- int idata;
- META_RESULT MetaResult;
-
- if(BANDSEL_GSM900 == band || BANDSEL_GSM850 == band)
- {
- m_sApcProfile[band].rampData.power[15] = m_sApcProfile[band].rampData.power[14];
- }
- if( ! m_bTADOSupport )
- {
- m_sApcProfile[band].rampData.lowest_power = ((m_usHighApcDcOffset[band]&0x03FF)<<8) |
- NVRAM_APC_LOWEST_POWER[band];
- }
- else
- {
- m_sApcProfile[band].rampData.lowest_power = ((m_usHighApcDcOffset[band]&0x03FF)<<8) |
- ((m_usLowApcDcOffset[band]&0x03FF)<<18) |
- m_iApcLowestPower[band];
- }
- for(int i=0; i<12; i++ )
- {
- idata = m_sApcProfile[band].rampData.arfcn_weight[i].mid_level;
- m_sApcProfile[band].rampData.arfcn_weight[i].mid_level = PCL2POWER(band, idata);
- }
- FrequencyBand freqband = BandIdx_To_FreqBand((E_BANDSEL)CurWRBand);
- // bool vbias_support = NVRAMMan->Get_VbiasSupport();
- // if (vbias_support)
- //{
- // MetaResult = META_Rf_SetRampTable_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, freqband, &m_sApcProfile[band]);
- // }
- // else
- // {
- // l1cal_rampTable_T ramp_table;
- //
- // ramp_table.rampData.lowest_power = m_sApcProfile[band].rampData.lowest_power;
- // for (int i=0; i<MAX_APC_PCL_NUM; i++)
- // {
- // ramp_table.rampData.power[i] = m_sApcProfile[band].rampData.power[i];
- // ramp_table.rampData.ramp[i] = m_sApcProfile[band].rampData.ramp[i];
- // }
- //
- // for (int i=0; i<ARFCN_SECTION_NUM; i++)
- // {
- // ramp_table.rampData.arfcn_weight[i] = m_sApcProfile[band].rampData.arfcn_weight[i];
- // }
- //
- // for (int i=0; i<APC_BATTERY_COMP_NUM; i++)
- // {
- // for (int j=0; j<APC_BATTERY_COMP_NUM; j++)
- // {
- // ramp_table.rampData.battery_compensate[i][j] = m_sApcProfile[band].rampData.battery_compensate[i][j];
- // }
- // }
- // ramp_table.rampData.tx_afc_offset = m_sApcProfile[band].rampData.tx_afc_offset;
- MetaResult = META_Rf_SetRampTable_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, freqband, &m_sApcProfile[band]);
- //}
- for (int i=0; i<12; i++)
- {
- idata = m_sApcProfile[band].rampData.arfcn_weight[i].mid_level;
- m_sApcProfile[band].rampData.arfcn_weight[i].mid_level = POWER2PCL(band, idata);
- }
- if (MetaResult!=META_SUCCESS)
- {
- if (MetaResult!=META_TIMEOUT)
- {
- Confirm(METAAPP_FAIL);
- return false;
- }
- else
- {
- Confirm(METAAPP_TIMEOUT);
- return false;
- }
- }
- ActiveMan->SetActiveFunction( ::REQ_Finish );
- return true;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- bool CRFAPC::Get_RealApcDcOffset( bool b_tadosupport, int band_idx, int pcl, int &apc_dc_offset )
- {
- if( ! b_tadosupport )
- {
- apc_dc_offset = m_usHighApcDcOffset[band_idx];
- }
- else
- {
- int min_dBm;
- FrequencyBand FreqBand = BandIdx_To_FreqBand((E_BANDSEL) band_idx );
- if( ! PCL_To_MindBm( FreqBand, pcl, min_dBm ) ) return false;
- if( min_dBm >= m_iApcLowestPower[band_idx] )
- apc_dc_offset = m_usHighApcDcOffset[band_idx];
- else
- apc_dc_offset = m_usLowApcDcOffset[band_idx];
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool CRFAPC::Set_RealApcDcOffset( bool b_tadosupport, int band_idx, int pcl, int apc_dc_offset )
- {
- if( ! b_tadosupport )
- {
- m_usHighApcDcOffset[band_idx] = apc_dc_offset;
- }
- else
- {
- int min_dBm;
- FrequencyBand FreqBand = BandIdx_To_FreqBand((E_BANDSEL) band_idx );
- if( ! PCL_To_MindBm( FreqBand, pcl, min_dBm ) ) return false;
- if( min_dBm >= m_iApcLowestPower[band_idx] )
- m_usHighApcDcOffset[band_idx] = apc_dc_offset;
- else
- m_usLowApcDcOffset[band_idx] = apc_dc_offset;
- }
- return true;
- }
- //===========================================================================
- ///////////////////////// Query //////////////////////////////
- //===========================================================================
- void CRFAPC::Query_RfSetRampTable_Start( bool &RfSetRampTableSupport )
- {
- rf_apc_ptr = this;
- g_bIsRunning = true;
- p_rf_set_ramp_table_support = &RfSetRampTableSupport;
- Query_RfSetRampTable();
- }
- //-------------------------------------------------------------------------
- bool CRFAPC::Query_RfSetRampTable( void )
- {
- META_RESULT MetaResult = META_QueryIfFunctionSupportedByTarget_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, "META_Rf_SetRampTable");
- if(MetaResult!=META_SUCCESS)
- {
- *p_rf_set_ramp_table_support = false;
- if( MetaResult!=META_TIMEOUT )
- { Confirm( METAAPP_FAIL ); return false; }
- else
- { Confirm( METAAPP_TIMEOUT ); return false; }
- }
- *p_rf_set_ramp_table_support = true;
- ActiveMan->SetActiveFunction( ::REQ_Finish );
- return true;
- }
- //--------------------------------------------------------------------------
- void CRFAPC::Query_TwoApcDcOffset_Start( bool &b_two_apc_dc_offset_support )
- {
- rf_apc_ptr = this;
- g_bIsRunning = true;
- pb_TwoApcDcOffsetSupport = &b_two_apc_dc_offset_support;
- Query_TwoApcDcOffset();
- }
- //-------------------------------------------------------------------------
- bool CRFAPC::Query_TwoApcDcOffset( void )
- {
- META_RESULT MetaResult = META_Rf_QueryIfTwoApcDCOffsetSupport_r( m_META_HANDLE_Obj.Get_MainHandle(), 300 );
- if(MetaResult!=META_SUCCESS)
- {
- *pb_TwoApcDcOffsetSupport = false;
- return false;
- }
- *pb_TwoApcDcOffsetSupport = true;
- // ActiveMan->SetActiveFunction( ::REQ_Finish );
- return true;
- }
- #if 0
- //-------------------------------------------------------------------------
- bool CRFAPC::Query_TwoApcDcOffset( void )
- {
- META_RESULT MetaResult = META_Rf_QueryIfTwoApcDCOffsetSupport_r( 500 );
- if(MetaResult!=META_SUCCESS)
- {
- *pb_TwoApcDcOffsetSupport = false;
- if( MetaResult!=META_TIMEOUT )
- { Confirm( METAAPP_FAIL ); return false; }
- else
- { Confirm( METAAPP_TIMEOUT ); return false; }
- }
- *pb_TwoApcDcOffsetSupport = true;
- ActiveMan->SetActiveFunction( ::REQ_Finish );
- return true;
- }
- #endif
- //===========================================================================
- ///////////////////////// Global information //////////////////////////////
- //===========================================================================
- E_METAAPP_RESULT_T CRFAPC::Get_ConfirmState(void)
- {
- return m_eConfirmState;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- unsigned short CRFAPC::Get_HighApcDcOffset(int band_idx)
- {
- return m_usHighApcDcOffset[band_idx];
- }
- //---------------------------------------------------------------------------
- void CRFAPC::Set_HighApcDcOffset( int band_idx, unsigned short ApcDcOffset)
- {
- m_usHighApcDcOffset[band_idx] = ApcDcOffset;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- unsigned short CRFAPC::Get_LowApcDcOffset(int band_idx)
- {
- return m_usLowApcDcOffset[band_idx];
- }
- //---------------------------------------------------------------------------
- void CRFAPC::Set_LowApcDcOffset(int band_idx, unsigned short ApcDcOffset)
- {
- m_usLowApcDcOffset[band_idx] = ApcDcOffset;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- int CRFAPC::Get_ApcLowestPower( int band_idx )
- {
- return m_iApcLowestPower[band_idx];
- }
- //---------------------------------------------------------------------------
- void CRFAPC::Set_ApcLowestPower( int band_idx, int apc_lowest_power )
- {
- m_iApcLowestPower[band_idx] = apc_lowest_power;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- l1cal_rampTable_T* CRFAPC::Get_ApcProfile( int band_idx )
- {
- return &m_sApcProfile[band_idx];
- }
- //---------------------------------------------------------------------------
- void CRFAPC::Set_ApcProfile(int band_idx, l1cal_rampTable_T apc_profile )
- {
- m_sApcProfile[band_idx] = apc_profile;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- unsigned short CRFAPC::Get_ApcProfilePower( int band_idx, int pcl_idx )
- {
- return m_sApcProfile[band_idx].rampData.power[pcl_idx];
- }
- //---------------------------------------------------------------------------
- void CRFAPC::Set_ApcProfilePower( int band_idx, int pcl_idx, unsigned short power )
- {
- m_sApcProfile[band_idx].rampData.power[pcl_idx] = power;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- short CRFAPC::Get_TxAfcOffset( int band_idx )
- {
- return m_sApcProfile[band_idx].rampData.tx_afc_offset;
- }
- //---------------------------------------------------------------------------
- void CRFAPC::Set_TxAfcOffset( int band_idx, short tx_afc_offset )
- {
- m_sApcProfile[band_idx].rampData.tx_afc_offset = tx_afc_offset;
- }