rf_apc_8psk.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:89k
- /*****************************************************************************
- * 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_8psk.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * RF 8PSK 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!!
- *============================================================================
- ****************************************************************************/
- #include <IniFiles.hpp>
- #pragma hdrstop
- #ifndef _RF_APC_8PSK_H_
- #include "rf_apc_8psk.h"
- #endif
- #include "man_fdm.h"
- #include "man_active.h"
- // form
- #include "form_RFTool.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
- // NVRAM
- #ifndef _NVRAM_VER_H_
- #include "nvram_ver.h"
- #endif
- //===========================================================================
- extern TfrmMainSel *frmMainSel; // for GSM 850
- static CRFAPC8PSK* rf_apc_8psk_ptr;
- static bool g_bIsRunning;
- //===========================================================================
- static const char SUBBAND_NAME[][32] =
- {
- "EPSK GSM900 level, ramp",
- "EPSK DCS1800 level, ramp",
- "EPSK PCS1900 level, ramp",
- "EPSK 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_8psk_ptr->REQ_ReadApcFromNVRAM();
- }
- //---------------------------------------------------------------------------
- static void CNF_ReadApcFromNVRAM(void)
- {
- rf_apc_8psk_ptr->CNF_ReadApcFromNVRAM();
- }
- //---------------------------------------------------------------------------
- static void REQ_WriteApcToNVRAM(void)
- {
- rf_apc_8psk_ptr->REQ_WriteApcToNVRAM( );
- }
- //---------------------------------------------------------------------------
- static void CNF_WriteApcToNVRAM(void)
- {
- rf_apc_8psk_ptr->CNF_WriteApcToNVRAM();
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- static void REQ_ReadVbiasFromNVRAM(void)
- {
- rf_apc_8psk_ptr->REQ_ReadVbiasFromNVRAM();
- }
- //---------------------------------------------------------------------------
- static void CNF_ReadVbiasFromNVRAM(void)
- {
- rf_apc_8psk_ptr->CNF_ReadVbiasFromNVRAM();
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- static void REQ_WriteVbiasToNVRAM(void)
- {
- rf_apc_8psk_ptr->REQ_WriteVbiasToNVRAM();
- }
- //---------------------------------------------------------------------------
- static void CNF_WriteVbiasToNVRAM(void)
- {
- rf_apc_8psk_ptr->CNF_WriteVbiasToNVRAM();
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- static void REQ_ReadAD6546CoefFromNVRAM(void)
- {
- rf_apc_8psk_ptr->REQ_ReadAD6546CoefFromNVRAM();
- }
- //---------------------------------------------------------------------------
- static void CNF_ReadAD6546CoefFromNVRAM(void)
- {
- rf_apc_8psk_ptr->CNF_ReadAD6546CoefFromNVRAM();
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- static void REQ_WriteAD6546CoefToNVRAM(void)
- {
- rf_apc_8psk_ptr->REQ_WriteAD6546CoefToNVRAM();
- }
- //---------------------------------------------------------------------------
- static void CNF_WriteAD6546CoefToNVRAM(void)
- {
- rf_apc_8psk_ptr->CNF_WriteAD6546CoefToNVRAM();
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- static void CNF_ReadB5PFromNVRAM(void)
- {
- rf_apc_8psk_ptr->CNF_ReadB5PFromNVRAM();
- }
- //---------------------------------------------------------------------------
- static void CNF_WriteB5PToNVRAM(void)
- {
- rf_apc_8psk_ptr->CNF_WriteB5PToNVRAM();
- }
- //---------------------------------------------------------------------------
- static void REQ_SetW6sImmediateBSI(void)
- {
- rf_apc_8psk_ptr->REQ_SetW6sImmediateBSI();
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- static void REQ_EPSK_SetRampApcLevel(void)
- {
- rf_apc_8psk_ptr->REQ_EPSK_SetRampApcLevel();
- }
- //---------------------------------------------------------------------------
- static void REQ_RfEPSKSetRampTable(void)
- {
- rf_apc_8psk_ptr->REQ_RfEPSKSetRampTable();
- }
- //---------------------------------------------------------------------------
- static void Query_RfEPSKSetRampTable(void)
- {
- rf_apc_8psk_ptr->Query_RfEPSKSetRampTable();
- }
- //===========================================================================
- CRFAPC8PSK::CRFAPC8PSK(void)
- {
- g_bIsRunning = false;
- ConfirmCallback = 0;
- ApcBufSize = 0;
- ApcBuf = NULL;
- m_VbiasBufSize = 0;
- m_VbiasBuf = NULL;
- B5PBufSize = 0;
- B5PBuf = NULL;
- m_iAD6546BufSize = 0;
- m_cAD6546Buf = NULL;
- }
- //---------------------------------------------------------------------------
- CRFAPC8PSK::~CRFAPC8PSK()
- {
- g_bIsRunning = false;
- ConfirmCallback = 0;
- if (ApcBuf)
- {
- delete [] ApcBuf;
- ApcBuf = NULL;
- }
- if (B5PBuf)
- {
- delete [] B5PBuf;
- B5PBuf = NULL;
- }
- if (m_VbiasBuf)
- {
- delete [] m_VbiasBuf;
- m_VbiasBuf = NULL;
- }
- if (m_cAD6546Buf)
- {
- delete [] m_cAD6546Buf;
- m_cAD6546Buf = NULL;
- }
- }
- //---------------------------------------------------------------------------
- void CRFAPC8PSK::REQ_Stop(void)
- {
- if(!g_bIsRunning) return;
- NVRAMMan->REQ_Stop();
- Confirm(METAAPP_STOP);
- g_bIsRunning = false;
- }
- //---------------------------------------------------------------------------
- void CRFAPC8PSK::Confirm(E_METAAPP_RESULT_T confirm_state)
- {
- if(!g_bIsRunning) return;
- if(ConfirmCallback==0) return;
- m_eConfirmState = confirm_state;
- ActiveMan->SetActiveFunction( ConfirmCallback );
- }
- //===========================================================================
- //static int NVRAM_APC_LOWEST_POWER[] =
- //{ 5, 0, 0, 5 };
- //---------------------------------------------------------------------------
- //static char NVRAM_RAMPNAME[][32] =
- //{
- // "L1_RAMPTABLE_GSM900",
- // "L1_RAMPTABLE_DCS1800",
- // "L1_RAMPTABLE_PCS1900",
- // "L1_RAMPTABLE_GSM850",
- //};
- //===========================================================================
- void CRFAPC8PSK::REQ_Read_APC_From_NVRAM_Start(unsigned int rf_id)
- {
- rf_apc_8psk_ptr = this;
- g_bIsRunning = true;
- m_uiRfModId = rf_id;
- // m_VbiasSupport = vbias_support;
- CurWRBand = BANDSEL_GSM900;
- m_bSingleBand = true;
- m_bDownloadTrigger = false;
- REQ_ReadApcFromNVRAM();
- }
- //-------------------------------------
- void CRFAPC8PSK::REQ_ReadApcFromNVRAM(void)
- {
- int band = CurWRBand;
- META_RESULT MetaResult;
- if(!g_bIsRunning) return;
- if( NULL == ApcBuf )
- {
- MetaResult = META_NVRAM_GetRecLen("NVRAM_EF_L1_EPSK_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_EPSK_RAMPTABLE_GSM850_LID",
- 1,
- ApcBufSize,
- ApcBuf);
- }
- break;
- case BANDSEL_GSM900:
- {
- NVRAMMan->REQ_ReadNVRAM_Start("NVRAM_EF_L1_EPSK_RAMPTABLE_GSM900_LID",
- 1,
- ApcBufSize,
- ApcBuf);
- }
- break;
- case BANDSEL_DCS1800:
- {
- NVRAMMan->REQ_ReadNVRAM_Start("NVRAM_EF_L1_EPSK_RAMPTABLE_DCS1800_LID",
- 1,
- ApcBufSize,
- ApcBuf);
- }
- break;
- case BANDSEL_PCS1900:
- {
- NVRAMMan->REQ_ReadNVRAM_Start("NVRAM_EF_L1_EPSK_RAMPTABLE_PCS1900_LID",
- 1,
- ApcBufSize,
- ApcBuf);
- }
- break;
- }
- }
- //-------------------------------------
- void CRFAPC8PSK::CNF_ReadApcFromNVRAM(void)
- {
- int band = CurWRBand;
- META_RESULT MetaResult;
- if(!g_bIsRunning) return;
- 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 i;
- int idata;
- MetaResult = META_NVRAM_Decompose_rampTable(&m_sEpskRamp.s_ramp_table[band],
- ApcBuf,
- ApcBufSize);
- if (MetaResult != META_SUCCESS)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- //else
- // {
- // MetaResult = META_NVRAM_Decompose_rampTable(&m_sEpskRamp.s_ramp_table,
- // ApcBuf,
- // ApcBufSize);
- // m_sEpskRamp.s_ramp_table[band].rampData.lowest_power = ramp_table.rampData.lowest_power;
- // for (int i=0; i<MAX_APC_PCL_NUM; i++)
- // {
- // m_sEpskRamp.s_ramp_table[band].rampData.power[i] = ramp_table.rampData.power[i];
- // m_sEpskRamp.s_ramp_table[band].rampData.ramp[i] = ramp_table.rampData.ramp[i];
- // }
- // for (int i=0; i<ARFCN_SECTION_NUM; i++)
- // {
- // m_sEpskRamp.s_ramp_table[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_sEpskRamp.s_ramp_table[band].rampData.battery_compensate[i][j] = ramp_table.rampData.battery_compensate[i][j];
- // }
- // }
- // m_sEpskRamp.s_ramp_table[band].rampData.tx_afc_offset = ramp_table.rampData.tx_afc_offset;
- // }
- m_usHighApcDcOffset[band] = (m_sEpskRamp.s_ramp_table[band].rampData.lowest_power>>8)&0x000003FF;
- m_ucInterslotLowestDAC[band] = (m_sEpskRamp.s_ramp_table[band].rampData.lowest_power>>18)&0x000000FF;
- m_sEpskRamp.s_ramp_table[band].rampData.lowest_power &=0x0FF;
- for (i=0; i<12; i++)
- {
- idata = m_sEpskRamp.s_ramp_table[band].rampData.arfcn_weight[i].mid_level;
- m_sEpskRamp.s_ramp_table[band].rampData.arfcn_weight[i].mid_level = POWER2PCL(band, idata);
- if (m_sEpskRamp.s_ramp_table[band].rampData.arfcn_weight[i].max_arfcn==32767)
- {
- m_sEpskRamp.s_ramp_table[band].rampData.arfcn_weight[i].max_arfcn = -1;
- }
- }
- bool isAllBCEqualZero = true;
- for (i=0; i<3; i++)
- {
- for(int j=0; j<3; j++)
- {
- if (m_sEpskRamp.s_ramp_table[band].rampData.battery_compensate[i][j] != 0)
- {
- isAllBCEqualZero = false;
- break;
- }
- }
- }
- if (isAllBCEqualZero)
- {
- for (i=0; i<3; i++)
- {
- for (int j=0; j<3; j++)
- {
- m_sEpskRamp.s_ramp_table[band].rampData.battery_compensate[i][j] = BATTERY_COMPENSATE_SCALE;
- }
- }
- }
- if (!frmMainSel->cbGSM850->Checked)
- {
- if (BANDSEL_GSM900 == band)
- {
- m_sEpskRamp.s_ramp_table[band].rampData.power[15] = m_sEpskRamp.s_ramp_table[band].rampData.power[14];
- }
- }
- else
- {
- if ((BANDSEL_GSM900 == band) || (BANDSEL_GSM850 == band))
- {
- m_sEpskRamp.s_ramp_table[band].rampData.power[15] = m_sEpskRamp.s_ramp_table[band].rampData.power[14];
- }
- }
- //bool vbias_support = NVRAMMan->Get_VbiasSupport();
- if (!frmMainSel->cbGSM850->Checked)
- {
- if (BANDSEL_PCS1900 == band)
- {
- if ((RF_ID_AERO2E == m_uiRfModId) ||
- (RF_ID_MT6140A == m_uiRfModId) ||
- (RF_ID_MT6140B == m_uiRfModId) ||
- (RF_ID_MT6140C == m_uiRfModId) ||
- (RF_ID_MT6140D == m_uiRfModId)
- )
- {
- REQ_ReadVbiasFromNVRAM();
- }
- else if (RF_ID_AD6546 == m_uiRfModId)
- {
- REQ_ReadAD6546CoefFromNVRAM();
- }
- else
- {
- Confirm(METAAPP_SUCCESS);
- }
- }
- else
- {
- CurWRBand++;
- ActiveMan->SetActiveFunction(::REQ_ReadApcFromNVRAM);
- }
- }
- else
- {
- if (BANDSEL_GSM850 == band)
- {
- if ((RF_ID_AERO2E == m_uiRfModId) ||
- (RF_ID_MT6140A == m_uiRfModId) ||
- (RF_ID_MT6140B == m_uiRfModId) ||
- (RF_ID_MT6140C == m_uiRfModId) ||
- (RF_ID_MT6140D == m_uiRfModId)
- )
- {
- REQ_ReadVbiasFromNVRAM();
- }
- else if (RF_ID_AD6546 == m_uiRfModId)
- {
- REQ_ReadAD6546CoefFromNVRAM();
- }
- else
- {
- Confirm(METAAPP_SUCCESS);
- }
- }
- else
- {
- CurWRBand++;
- ActiveMan->SetActiveFunction(::REQ_ReadApcFromNVRAM);
- }
- }
- }
- }
- break;
- default:
- {
- Confirm(state);
- }
- break;
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CRFAPC8PSK::REQ_Write_APC_To_NVRAM_Start(unsigned int rf_id)
- {
- rf_apc_8psk_ptr = this;
- g_bIsRunning = true;
- m_uiRfModId = rf_id;
- //m_VbiasSupport = vbias_support;
- CurWRBand = BANDSEL_GSM900;
- m_bDownloadTrigger = true;
- m_bSingleBand = false;
- REQ_ReadVbiasFromNVRAM();
- }
- //-------------------------------------
- void CRFAPC8PSK::REQ_Write_APC_To_NVRAM_Single_Band_Start(unsigned int rf_id, int band)
- {
- rf_apc_8psk_ptr = this;
- g_bIsRunning = true;
- m_uiRfModId = rf_id;
- //m_VbiasSupport = vbias_support;
- CurWRBand = band;
- m_bDownloadTrigger = true;
- m_bSingleBand = true;
- REQ_ReadVbiasFromNVRAM();
- }
- //-------------------------------------
- void CRFAPC8PSK::REQ_WriteApcToNVRAM(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- META_RESULT MetaResult;
- int i, j;
- int idata;
- int band = CurWRBand;
- if (NULL == ApcBuf)
- {
- MetaResult = META_NVRAM_GetRecLen("NVRAM_EF_L1_EPSK_RAMPTABLE_GSM900_LID", &ApcBufSize);
- if (MetaResult != META_SUCCESS)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- ApcBuf = new char[ApcBufSize];
- }
- if (BANDSEL_GSM900 == band || BANDSEL_GSM850 == band)
- {
- m_sEpskRamp.s_ramp_table[band].rampData.power[15] = m_sEpskRamp.s_ramp_table[band].rampData.power[14];
- }
- m_sEpskRamp.s_ramp_table[band].rampData.lowest_power = NVRAM_APC_LOWEST_POWER[band] |
- ((m_usHighApcDcOffset[band]&0x3FF)<<8) |
- m_ucInterslotLowestDAC[band]<<18;
- for (i=0; i<12; i++)
- {
- idata = m_sEpskRamp.s_ramp_table[band].rampData.arfcn_weight[i].mid_level;
- m_sEpskRamp.s_ramp_table[band].rampData.arfcn_weight[i].mid_level = PCL2POWER(band, idata);
- }
- // if (vbias_support)
- // {
- MetaResult = META_NVRAM_Compose_rampTable(&m_sEpskRamp.s_ramp_table[band],
- ApcBuf,
- ApcBufSize);
- if (MetaResult != META_SUCCESS)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- // }
- // else
- // {
- // l1cal_rampTable_T ramp_table;
- //
- // ramp_table.rampData.lowest_power = m_sEpskRamp.s_ramp_table[band].rampData.lowest_power;
- // for (int i=0; i<MAX_APC_PCL_NUM; i++)
- // {
- // ramp_table.rampData.power[i] = m_sEpskRamp.s_ramp_table[band].rampData.power[i];
- // ramp_table.rampData.ramp[i] = m_sEpskRamp.s_ramp_table[band].rampData.ramp[i];
- // }
- //
- // for (int i=0; i<ARFCN_SECTION_NUM; i++)
- // {
- // ramp_table.rampData.arfcn_weight[i] = m_sEpskRamp.s_ramp_table[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_sEpskRamp.s_ramp_table[band].rampData.battery_compensate[i][j];
- // }
- // }
- // ramp_table.rampData.tx_afc_offset = m_sEpskRamp.s_ramp_table[band].rampData.tx_afc_offset;
- // MetaResult = META_NVRAM_Compose_rampTable(&ramp_table,
- // ApcBuf,
- // ApcBufSize );
- //}
- m_sEpskRamp.s_ramp_table[band].rampData.lowest_power &= 0x0FF;
- for (i=0; i<12; i++)
- {
- idata = m_sEpskRamp.s_ramp_table[band].rampData.arfcn_weight[i].mid_level;
- m_sEpskRamp.s_ramp_table[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_EPSK_RAMPTABLE_GSM850_LID", &lid_ver);
- if (lid_ver > NVRAM_EF_L1_EPSK_RAMPTABLE_GSM850_LID_VERNO)
- {
- Confirm(METAAPP_NVRAM_LID_VER_NOT_SUPPORT);
- return;
- }
- NVRAMMan->REQ_WriteNVRAM_Start("NVRAM_EF_L1_EPSK_RAMPTABLE_GSM850_LID",
- 1,
- ApcBufSize,
- ApcBuf);
- }
- break;
- case BANDSEL_GSM900:
- {
- unsigned short lid_ver;
- MetaResult = META_NVRAM_GetLIDVersion("NVRAM_EF_L1_EPSK_RAMPTABLE_GSM900_LID", &lid_ver);
- if (lid_ver > NVRAM_EF_L1_EPSK_RAMPTABLE_GSM900_LID_VERNO)
- {
- Confirm(METAAPP_NVRAM_LID_VER_NOT_SUPPORT);
- return;
- }
- NVRAMMan->REQ_WriteNVRAM_Start("NVRAM_EF_L1_EPSK_RAMPTABLE_GSM900_LID",
- 1,
- ApcBufSize,
- ApcBuf);
- }
- break;
- case BANDSEL_DCS1800:
- {
- unsigned short lid_ver;
- MetaResult = META_NVRAM_GetLIDVersion("NVRAM_EF_L1_EPSK_RAMPTABLE_DCS1800_LID", &lid_ver);
- if (lid_ver > NVRAM_EF_L1_EPSK_RAMPTABLE_DCS1800_LID_VERNO)
- {
- Confirm(METAAPP_NVRAM_LID_VER_NOT_SUPPORT);
- return;
- }
- NVRAMMan->REQ_WriteNVRAM_Start("NVRAM_EF_L1_EPSK_RAMPTABLE_DCS1800_LID",
- 1,
- ApcBufSize,
- ApcBuf);
- }
- break;
- case BANDSEL_PCS1900:
- {
- unsigned short lid_ver;
- MetaResult = META_NVRAM_GetLIDVersion("NVRAM_EF_L1_EPSK_RAMPTABLE_PCS1900_LID", &lid_ver);
- if (lid_ver > NVRAM_EF_L1_EPSK_RAMPTABLE_PCS1900_LID_VERNO)
- {
- Confirm(METAAPP_NVRAM_LID_VER_NOT_SUPPORT);
- return;
- }
- NVRAMMan->REQ_WriteNVRAM_Start("NVRAM_EF_L1_EPSK_RAMPTABLE_PCS1900_LID",
- 1,
- ApcBufSize,
- ApcBuf );
- }
- break;
- }
- }
- //-------------------------------------
- void CRFAPC8PSK::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) )
- {
- if ((RF_ID_AERO2E == m_uiRfModId) ||
- (RF_ID_MT6140A == m_uiRfModId) ||
- (RF_ID_MT6140B == m_uiRfModId) ||
- (RF_ID_MT6140C == m_uiRfModId) ||
- (RF_ID_MT6140D == m_uiRfModId)
- )
- {
- REQ_WriteVbiasToNVRAM();
- }
- else if (RF_ID_AD6546 == m_uiRfModId)
- {
- REQ_WriteAD6546CoefToNVRAM();
- }
- else
- {
- Confirm(METAAPP_SUCCESS);
- }
- }
- else
- {
- CurWRBand++;
- ActiveMan->SetActiveFunction(::REQ_WriteApcToNVRAM);
- }
- }
- else
- {
- if( (band==BANDSEL_PCS1900)||(m_bSingleBand) )
- {
- if ((RF_ID_AERO2E == m_uiRfModId) ||
- (RF_ID_MT6140A == m_uiRfModId) ||
- (RF_ID_MT6140B == m_uiRfModId) ||
- (RF_ID_MT6140C == m_uiRfModId) ||
- (RF_ID_MT6140D == m_uiRfModId)
- )
- {
- REQ_WriteVbiasToNVRAM();
- }
- else if (RF_ID_AD6546 == m_uiRfModId)
- {
- REQ_WriteAD6546CoefToNVRAM();
- }
- else
- {
- Confirm(METAAPP_SUCCESS);
- }
- }
- else
- {
- CurWRBand++;
- REQ_WriteApcToNVRAM();
- }
- }
- }
- else
- { Confirm(state);
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CRFAPC8PSK::REQ_ReadVbiasFromNVRAM(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- if (NULL == m_VbiasBuf)
- {
- META_RESULT MetaResult = META_NVRAM_GetRecLen("NVRAM_EF_L1_RFSPECIALCOEF_LID", &m_VbiasBufSize);
- if (MetaResult != META_SUCCESS)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- m_VbiasBuf = new char[m_VbiasBufSize];
- }
- NVRAMMan->ConfirmCallback = ::CNF_ReadVbiasFromNVRAM;
- NVRAMMan->REQ_ReadNVRAM_Start("NVRAM_EF_L1_RFSPECIALCOEF_LID",
- 1,
- m_VbiasBufSize,
- m_VbiasBuf);
- }
- //------------------------------------------------
- void CRFAPC8PSK::CNF_ReadVbiasFromNVRAM(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- E_METAAPP_RESULT_T state = NVRAMMan->Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- if (m_bDownloadTrigger)
- {
- REQ_WriteApcToNVRAM();
- }
- else
- {
- META_RESULT MetaResult = META_NVRAM_Decompose_MT6140tx_PaVbias(&m_sEpskRamp.s_pa_vbias,
- m_VbiasBuf,
- m_VbiasBufSize);
- if (MetaResult != META_SUCCESS)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- // ActiveMan->SetActiveFunction(::REQ_Finish);
- Confirm(METAAPP_SUCCESS);
- }
- }
- break;
- default:
- {
- Confirm(state);
- }
- break;
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CRFAPC8PSK::REQ_WriteVbiasToNVRAM(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- META_RESULT MetaResult;
- if (NULL == m_VbiasBuf)
- {
- MetaResult = META_NVRAM_GetRecLen("NVRAM_EF_L1_RFSPECIALCOEF_LID", &m_VbiasBufSize);
- if (MetaResult != META_SUCCESS)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- m_VbiasBuf = new char[m_VbiasBufSize];
- }
- MetaResult = META_NVRAM_Compose_MT6140tx_PaVbias(&m_sEpskRamp.s_pa_vbias,
- m_VbiasBuf,
- m_VbiasBufSize);
- if (MetaResult != META_SUCCESS)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- unsigned short lid_ver;
- MetaResult = META_NVRAM_GetLIDVersion("NVRAM_EF_L1_RFSPECIALCOEF_LID", &lid_ver);
- if (lid_ver > NVRAM_EF_L1_RFSPECIALCOEF_LID_VERNO)
- {
- Confirm(METAAPP_NVRAM_LID_VER_NOT_SUPPORT);
- return;
- }
- NVRAMMan->ConfirmCallback = ::CNF_WriteVbiasToNVRAM;
- NVRAMMan->REQ_WriteNVRAM_Start("NVRAM_EF_L1_RFSPECIALCOEF_LID",
- 1,
- m_VbiasBufSize,
- m_VbiasBuf);
- }
- //------------------------------------------------
- void CRFAPC8PSK::CNF_WriteVbiasToNVRAM(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- E_METAAPP_RESULT_T state = NVRAMMan->Get_ConfirmState();
- Confirm(state);
- }
- //===========================================================================
- ////////////////////// AD6546 NVRAM read/write //////////////////////////
- //===========================================================================
- void CRFAPC8PSK::REQ_ReadAD6546CoefFromNVRAM(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- if (NULL == m_cAD6546Buf)
- {
- META_RESULT MetaResult = META_NVRAM_GetRecLen("NVRAM_EF_L1_RFSPECIALCOEF_LID", &m_iAD6546BufSize);
- if (MetaResult != META_SUCCESS)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- m_cAD6546Buf = new char[m_iAD6546BufSize];
- }
- NVRAMMan->ConfirmCallback = ::CNF_ReadAD6546CoefFromNVRAM;
- NVRAMMan->REQ_ReadNVRAM_Start("NVRAM_EF_L1_RFSPECIALCOEF_LID",
- 1,
- m_iAD6546BufSize,
- m_cAD6546Buf);
- }
- //------------------------------------------------
- void CRFAPC8PSK::CNF_ReadAD6546CoefFromNVRAM(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- E_METAAPP_RESULT_T state = NVRAMMan->Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- if (m_bDownloadTrigger)
- {
- REQ_WriteApcToNVRAM();
- }
- else
- {
- META_RESULT MetaResult = META_NVRAM_Decompose_ad6546tx(&m_sEpskRamp.s_ad6546,
- m_cAD6546Buf,
- m_iAD6546BufSize);
- if (MetaResult != META_SUCCESS)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- // ActiveMan->SetActiveFunction(::REQ_Finish);
- Confirm(METAAPP_SUCCESS);
- }
- }
- break;
- default:
- {
- Confirm(state);
- }
- break;
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CRFAPC8PSK::REQ_WriteAD6546CoefToNVRAM(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- META_RESULT MetaResult;
- if (NULL == m_cAD6546Buf)
- {
- MetaResult = META_NVRAM_GetRecLen("NVRAM_EF_L1_RFSPECIALCOEF_LID", &m_iAD6546BufSize);
- if (MetaResult != META_SUCCESS)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- m_cAD6546Buf = new char[m_iAD6546BufSize];
- }
- MetaResult = META_NVRAM_Compose_ad6546tx(&m_sEpskRamp.s_ad6546,
- m_cAD6546Buf,
- m_iAD6546BufSize);
- if (MetaResult != META_SUCCESS)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- unsigned short lid_ver;
- MetaResult = META_NVRAM_GetLIDVersion("NVRAM_EF_L1_RFSPECIALCOEF_LID", &lid_ver);
- if (lid_ver > NVRAM_EF_L1_RFSPECIALCOEF_LID_VERNO)
- {
- Confirm(METAAPP_NVRAM_LID_VER_NOT_SUPPORT);
- return;
- }
- NVRAMMan->ConfirmCallback = ::CNF_WriteVbiasToNVRAM;
- NVRAMMan->REQ_WriteNVRAM_Start("NVRAM_EF_L1_RFSPECIALCOEF_LID",
- 1,
- m_iAD6546BufSize,
- m_cAD6546Buf);
- }
- //------------------------------------------------
- void CRFAPC8PSK::CNF_WriteAD6546CoefToNVRAM(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- E_METAAPP_RESULT_T state = NVRAMMan->Get_ConfirmState();
- Confirm(state);
- }
- //===========================================================================
- void CRFAPC8PSK::Compose_wordC3(sC3Mode c3mode, unsigned int &wordC3)
- {
- wordC3 = (c3mode.uc_tn << 11) | (c3mode.uc_to << 7) | ( 0x06 << 3 ) | ADDR_WORD_C3;
- }
- //---------------------------------------------------------------------------
- void CRFAPC8PSK::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 CRFAPC8PSK::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 CRFAPC8PSK::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 CRFAPC8PSK::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 CRFAPC8PSK::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 CRFAPC8PSK::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 CRFAPC8PSK::REQ_Read_B5P_From_NVRAM( void )
- {
- rf_apc_8psk_ptr = this;
- g_bIsRunning = true;
- if( NULL == B5PBuf )
- {
- 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 CRFAPC8PSK::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;
- }
- Confirm(METAAPP_SUCCESS);
- }
- else
- {
- Confirm(state);
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CRFAPC8PSK::REQ_Write_B5P_To_NVRAM( void )
- {
- rf_apc_8psk_ptr = this;
- g_bIsRunning = true;
- if( NULL == B5PBuf )
- {
- META_RESULT MetaResult = META_NVRAM_GetRecLen( "NVRAM_EF_L1_RFSPECIALCOEF_LID",
- &B5PBufSize );;
- if(MetaResult!=META_SUCCESS)
- { Confirm( METAAPP_FAIL ); return; }
- B5PBuf = new char[B5PBufSize];
- }
- META_RESULT 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 CRFAPC8PSK::CNF_WriteB5PToNVRAM( void )
- {
- if(!g_bIsRunning) return;
- E_METAAPP_RESULT_T state = NVRAMMan->Get_ConfirmState();
- Confirm(state);
- }
- //===========================================================================
- ////////////////////////////////// INI file //////////////////////////////
- //===========================================================================
- static const AnsiString KEY_NAME_INTERSLOT_LOWEST_DAC = "Interslot lowest DAC";
- static const AnsiString asSECTION_NAME_VBIAS = "PA Vbias";
- static const AnsiString asKEY_NAME_Band[] = {"GSM900 band", "DCS1800 band", "PCS1900 band", "GSM850 band"};
- static const AnsiString asKEY_NAME_VBIAS = "Vbias";
- static const AnsiString asKEY_NAME_VBIAS_PCL = "Vbias PCL";
- static const AnsiString asSECTION_NAME_AD6546 = "AD6546 Parameters";
- static const AnsiString asKEY_NAME_SKEW = "Refdet slope skew";
- static const AnsiString asKEY_NAME_FB_DAC = "AM FB DAC";
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- bool CRFAPC8PSK::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 CRFAPC8PSK::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 CRFAPC8PSK::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 CRFAPC8PSK::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 CRFAPC8PSK::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 CRFAPC8PSK::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 CRFAPC8PSK::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 CRFAPC8PSK::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 CRFAPC8PSK::REQ_Read_APC_From_File_Single_Band(char *filename, unsigned int rf_id, int band)
- {
- TIniFile *ini_file;
- AnsiString asdata;
- char ini_section[128];
- char str[2048];
- unsigned char ucdata[MAX_PA_VBIAS_NUM];
- short sdata[16];
- int idata[16];
- unsigned short usdata[MAX_APC_PCL_NUM];
- float fdata[16];
- int total_band_num;
- ini_file = new TIniFile(filename);
- if (NULL == ini_file)
- {
- return false;
- }
- m_uiRfModId = rf_id;
- // Vbias
- if ((RF_ID_AERO2E == rf_id) ||
- (RF_ID_MT6140A == rf_id) ||
- (RF_ID_MT6140B == rf_id) ||
- (RF_ID_MT6140C == rf_id) ||
- (RF_ID_MT6140D == rf_id)
- )
- {
- pa_vbias* p_pa_vibas[] =
- {
- m_sEpskRamp.s_pa_vbias.data.GSM900_pa_vbias,
- m_sEpskRamp.s_pa_vbias.data.DCS1800_pa_vbias,
- m_sEpskRamp.s_pa_vbias.data.PCS1900_pa_vbias,
- m_sEpskRamp.s_pa_vbias.data.GSM850_pa_vbias
- };
- // vbias PCL
- AnsiString as_KEY_NAME = asKEY_NAME_Band[band] + " " + asKEY_NAME_VBIAS_PCL;
- asdata = ini_file->ReadString(asSECTION_NAME_VBIAS,
- as_KEY_NAME,
- "-1,-1,-1,-1,-1,-1,-1,-1,");
- String_To_Array_short(asdata.c_str(), sdata, MAX_PA_VBIAS_NUM);
- for (int j=0; j<MAX_PA_VBIAS_NUM; j++)
- {
- (*(p_pa_vibas[band]+j)).pcl_index = sdata[j];
- }
- // vbias
- as_KEY_NAME = asKEY_NAME_Band[band] + " " + asKEY_NAME_VBIAS;
- asdata = ini_file->ReadString(asSECTION_NAME_VBIAS,
- as_KEY_NAME,
- "0,0,0,0,0,0,0,0,");
- String_To_Array_UnsignedChar(asdata.c_str(), ucdata, MAX_PA_VBIAS_NUM);
- for (int j=0; j<MAX_PA_VBIAS_NUM; j++)
- {
- (*(p_pa_vibas[band]+j)).pa_vbias1 = ucdata[j];
- }
- }
- else if (RF_ID_AD6546 == rf_id)
- {
- m_sEpskRamp.s_ad6546.REFDET_SLOPE_SKEW = ini_file->ReadInteger(asSECTION_NAME_AD6546,
- asKEY_NAME_SKEW,
- 0
- );
- m_sEpskRamp.s_ad6546.AM_FB_DAC = ini_file->ReadInteger(asSECTION_NAME_AD6546,
- asKEY_NAME_FB_DAC,
- 0
- );
- }
- // TX power level
- asdata = 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, asdata.c_str());
- String_To_Array_UnsignedShort(str, usdata, MAX_APC_PCL_NUM);
- for (int i=0; i<MAX_APC_PCL_NUM; i++)
- {
- m_sEpskRamp.s_ramp_table[band].rampData.power[i] = usdata[i];
- }
- // ramp
- for (int pcl=0; pcl<MAX_APC_PCL_NUM; pcl++)
- {
- sprintf(ini_section, "profile %d ramp up", pcl );
- asdata = 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, asdata.c_str());
- String_To_Array_int(str, idata, 16 );
- for (int i=0; i<16; i++)
- {
- m_sEpskRamp.s_ramp_table[band].rampData.ramp[pcl].point[0][i] = idata[i];
- }
- sprintf( ini_section, "profile %d ramp down", pcl );
- asdata = 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, asdata.c_str() );
- String_To_Array_int(str, idata, 16 );
- for (int i=0; i<16; i++)
- {
- m_sEpskRamp.s_ramp_table[band].rampData.ramp[pcl].point[1][i] = idata[i];
- }
- }
- asdata = ini_file->ReadString( SUBBAND_NAME[band],
- "Subband max arfcn",
- "-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1");
- strcpy( str, asdata.c_str() );
- String_To_Array_int( str, idata, 11 );
- idata[11] = -1;
- for (int i=0; i<12; i++)
- {
- m_sEpskRamp.s_ramp_table[band].rampData.arfcn_weight[i].max_arfcn = idata[i];
- }
- asdata = ini_file->ReadString( SUBBAND_NAME[band],
- "Subband mid level",
- "0,0,0,0,0,0,0,0,0,0,0");
- strcpy(str, asdata.c_str());
- String_To_Array_int(str, idata, 11);
- idata[11] = 0;
- for (int i=0; i<12; i++)
- {
- m_sEpskRamp.s_ramp_table[band].rampData.arfcn_weight[i].mid_level = idata[i];
- }
- if (RF_ID_A60111A != rf_id)
- {
- // Subband high weight
- asdata = ini_file->ReadString(SUBBAND_NAME[band],
- "Subband high weight",
- "1,1,1,1,1,1,1,1,1,1,1");
- strcpy(str, asdata.c_str());
- String_To_Array_float(str, fdata, 11);
- fdata[11] = 0.0;
- for (int i=0; i<12; i++)
- {
- m_sEpskRamp.s_ramp_table[band].rampData.arfcn_weight[i].hi_weight = (unsigned short)(fdata[i]*WEIGHT_SCALE);
- }
- // Subband low weight
- asdata = ini_file->ReadString(SUBBAND_NAME[band],
- "Subband low weight",
- "1,1,1,1,1,1,1,1,1,1,1"
- );
- strcpy(str, asdata.c_str());
- String_To_Array_float(str, fdata, 11);
- fdata[11] = 0.0;
- for (int i=0; i<12; i++)
- {
- m_sEpskRamp.s_ramp_table[band].rampData.arfcn_weight[i].low_weight = (unsigned short) (fdata[i]*WEIGHT_SCALE);
- }
- }
- else
- {
- // Subband high weight
- asdata = ini_file->ReadString(SUBBAND_NAME[band],
- "Subband high weight",
- "1,1,1,1,1,1,1,1,1,1,1");
- strcpy(str, asdata.c_str());
- String_To_Array_short(str, sdata, 11);
- sdata[11] = 0;
- for (int i=0; i<12; i++)
- {
- m_sEpskRamp.s_ramp_table[band].rampData.arfcn_weight[i].hi_weight = (unsigned short)(sdata[i] + A60111A_WEIGHT_OFFSET);
- }
- // Subband low weight
- asdata = ini_file->ReadString(SUBBAND_NAME[band],
- "Subband low weight",
- "1,1,1,1,1,1,1,1,1,1,1"
- );
- strcpy(str, asdata.c_str());
- String_To_Array_short(str, sdata, 11);
- sdata[11] = 0.0;
- for (int i=0; i<12; i++)
- {
- m_sEpskRamp.s_ramp_table[band].rampData.arfcn_weight[i].low_weight = (unsigned short) (sdata[i] + A60111A_WEIGHT_OFFSET);
- }
- }
- // battery compensate
- asdata = ini_file->ReadString(SUBBAND_NAME[band],
- "Battery compensate, low voltage, low temperature",
- "1.0");
- m_sEpskRamp.s_ramp_table[band].rampData.battery_compensate[LOW_VOLTAGE_INDEX][LOW_TEMPERATURE_INDEX] =
- atof(asdata.c_str()) * BATTERY_COMPENSATE_SCALE;
- asdata = ini_file->ReadString(SUBBAND_NAME[band],
- "Battery compensate, low voltage, mid temperature",
- "1.0");
- m_sEpskRamp.s_ramp_table[band].rampData.battery_compensate[LOW_VOLTAGE_INDEX][MID_TEMPERATURE_INDEX] =
- atof(asdata.c_str()) * BATTERY_COMPENSATE_SCALE;
- asdata = ini_file->ReadString(SUBBAND_NAME[band],
- "Battery compensate, low voltage, high temperature",
- "1.0");
- m_sEpskRamp.s_ramp_table[band].rampData.battery_compensate[LOW_VOLTAGE_INDEX][HIGH_TEMPERATURE_INDEX] =
- atof(asdata.c_str()) * BATTERY_COMPENSATE_SCALE;
- asdata = ini_file->ReadString(SUBBAND_NAME[band],
- "Battery compensate, mid voltage, low temperature",
- "1.0");
- m_sEpskRamp.s_ramp_table[band].rampData.battery_compensate[MID_VOLTAGE_INDEX][LOW_TEMPERATURE_INDEX] =
- atof(asdata.c_str()) * BATTERY_COMPENSATE_SCALE;
- asdata = ini_file->ReadString(SUBBAND_NAME[band],
- "Battery compensate, mid voltage, mid temperature",
- "1.0");
- m_sEpskRamp.s_ramp_table[band].rampData.battery_compensate[MID_VOLTAGE_INDEX][MID_TEMPERATURE_INDEX] =
- atof(asdata.c_str()) * BATTERY_COMPENSATE_SCALE;
- asdata = ini_file->ReadString(SUBBAND_NAME[band],
- "Battery compensate, mid voltage, high temperature",
- "1.0");
- m_sEpskRamp.s_ramp_table[band].rampData.battery_compensate[MID_VOLTAGE_INDEX][HIGH_TEMPERATURE_INDEX] =
- atof(asdata.c_str()) * BATTERY_COMPENSATE_SCALE;
- asdata = ini_file->ReadString(SUBBAND_NAME[band],
- "Battery compensate, high voltage, low temperature",
- "1.0");
- m_sEpskRamp.s_ramp_table[band].rampData.battery_compensate[HIGH_VOLTAGE_INDEX][LOW_TEMPERATURE_INDEX] =
- atof(asdata.c_str()) * BATTERY_COMPENSATE_SCALE;
- asdata = ini_file->ReadString(SUBBAND_NAME[band],
- "Battery compensate, high voltage, mid temperature",
- "1.0");
- m_sEpskRamp.s_ramp_table[band].rampData.battery_compensate[HIGH_VOLTAGE_INDEX][MID_TEMPERATURE_INDEX] =
- atof(asdata.c_str()) * BATTERY_COMPENSATE_SCALE;
- asdata = ini_file->ReadString(SUBBAND_NAME[band],
- "Battery compensate, high voltage, high temperature",
- "1.0");
- m_sEpskRamp.s_ramp_table[band].rampData.battery_compensate[HIGH_VOLTAGE_INDEX][HIGH_TEMPERATURE_INDEX] =
- atof(asdata.c_str()) * BATTERY_COMPENSATE_SCALE;
- // CAP ID compensate
- m_sEpskRamp.s_ramp_table[band].rampData.tx_afc_offset = ini_file->ReadInteger( SUBBAND_NAME[band],
- "TX AFC DAC offset",
- 0);
- m_ucInterslotLowestDAC[band] = ini_file->ReadInteger( SUBBAND_NAME[band],
- KEY_NAME_INTERSLOT_LOWEST_DAC,
- 0);
- if (BANDSEL_GSM900 == band || BANDSEL_GSM850 == band)
- {
- m_sEpskRamp.s_ramp_table[band].rampData.power[15] = m_sEpskRamp.s_ramp_table[band].rampData.power[14];
- }
- delete ini_file;
- return true;
- }
- //-----------------------------------------------------------------------------
- bool CRFAPC8PSK::REQ_Read_APC_From_File(char *filename, unsigned int rf_id)
- {
- TIniFile *ini_file;
- AnsiString asdata;
- 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;
- 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++)
- {
- if (!REQ_Read_APC_From_File_Single_Band(filename, rf_id, band))
- {
- return false;
- }
- }
- return true;
- }
- //===========================================================================
- bool CRFAPC8PSK::REQ_Write_APC_To_File_Single_Band(char *filename, unsigned int rf_id, int band)
- {
- TIniFile *ini_file;
- AnsiString asdata;
- char ini_section[128];
- char str[2048];
- unsigned char ucdata[MAX_PA_VBIAS_NUM];
- short sdata[16];
- int idata[16];
- unsigned short usdata[MAX_APC_PCL_NUM];
- float fdata[16];
- ini_file = new TIniFile(filename);
- if (NULL == ini_file)
- {
- return false;
- }
-
- // Vbias
- if ((RF_ID_AERO2E == rf_id) ||
- (RF_ID_MT6140A == rf_id) ||
- (RF_ID_MT6140B == rf_id) ||
- (RF_ID_MT6140C == rf_id) ||
- (RF_ID_MT6140D == rf_id)
- )
- {
- pa_vbias* p_pa_vibas[] =
- {
- m_sEpskRamp.s_pa_vbias.data.GSM900_pa_vbias,
- m_sEpskRamp.s_pa_vbias.data.DCS1800_pa_vbias,
- m_sEpskRamp.s_pa_vbias.data.PCS1900_pa_vbias,
- m_sEpskRamp.s_pa_vbias.data.GSM850_pa_vbias
- };
- // vbias PCL
- for (int j=0; j<MAX_PA_VBIAS_NUM; j++)
- {
- sdata[j] = (*(p_pa_vibas[band]+j)).pcl_index;
- }
- AnsiString as_KEY_NAME = asKEY_NAME_Band[band] + " " + asKEY_NAME_VBIAS_PCL;
- Array_To_String_short(str, sdata, MAX_PA_VBIAS_NUM, ',');
- ini_file->WriteString(asSECTION_NAME_VBIAS,
- as_KEY_NAME,
- str);
- // vbias
- for (int j=0; j<MAX_PA_VBIAS_NUM; j++)
- {
- ucdata[j] = (*(p_pa_vibas[band]+j)).pa_vbias1;
- }
- as_KEY_NAME = asKEY_NAME_Band[band] + " " + asKEY_NAME_VBIAS;
- Array_To_String_UnsignedChar(str, ucdata, MAX_PA_VBIAS_NUM, ',');
- ini_file->WriteString(asSECTION_NAME_VBIAS,
- as_KEY_NAME,
- str);
- }
- else if (RF_ID_AD6546 == rf_id)
- {
- ini_file->WriteString(asSECTION_NAME_AD6546,
- asKEY_NAME_SKEW,
- IntToStr(m_sEpskRamp.s_ad6546.REFDET_SLOPE_SKEW)
- );
- ini_file->WriteString(asSECTION_NAME_AD6546,
- asKEY_NAME_FB_DAC,
- IntToStr(m_sEpskRamp.s_ad6546.AM_FB_DAC)
- );
- }
- if ((BANDSEL_GSM900 == band) || (BANDSEL_GSM850 == band))
- {
- m_sEpskRamp.s_ramp_table[band].rampData.power[15] = m_sEpskRamp.s_ramp_table[band].rampData.power[14];
- }
- m_uiRfModId = rf_id;
- // TX power level
- for (int i=0; i<MAX_APC_PCL_NUM; i++)
- {
- usdata[i] = m_sEpskRamp.s_ramp_table[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 (int pcl=0; pcl<16; pcl++)
- {
- for (int i=0; i<16; i++)
- {
- idata[i] = m_sEpskRamp.s_ramp_table[band].rampData.ramp[pcl].point[0][i];
- }
- Array_To_String_int(str, idata, 16, ',');
- sprintf(ini_section, "profile %d ramp up", pcl);
- ini_file->WriteString(SUBBAND_NAME[band],
- ini_section,
- str
- );
- for (int i=0; i<16; i++)
- {
- idata[i] = m_sEpskRamp.s_ramp_table[band].rampData.ramp[pcl].point[1][i];
- }
- Array_To_String_int(str, idata, 16, ',');
- sprintf(ini_section, "profile %d ramp down", pcl);
- ini_file->WriteString(SUBBAND_NAME[band],
- ini_section,
- str);
- }
- for (int i=0; i<11; i++)
- {
- idata[i] = m_sEpskRamp.s_ramp_table[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 (int i=0; i<11; i++)
- {
- idata[i] = m_sEpskRamp.s_ramp_table[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);
- if (RF_ID_A60111A != rf_id)
- {
- for (int i=0; i<11; i++)
- {
- fdata[i] = m_sEpskRamp.s_ramp_table[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 (int i=0; i<11; i++)
- {
- fdata[i] = m_sEpskRamp.s_ramp_table[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);
- }
- else
- {
- for (int i=0; i<11; i++)
- {
- sdata[i] = (short) (m_sEpskRamp.s_ramp_table[band].rampData.arfcn_weight[i].hi_weight - A60111A_WEIGHT_OFFSET);
- }
- sdata[11] = 0;
- Array_To_String_short(str, sdata, 11, ',');
- ini_file->WriteString(SUBBAND_NAME[band],
- "Subband high weight",
- str);
- for (int i=0; i<11; i++)
- {
- sdata[i] = (short) (m_sEpskRamp.s_ramp_table[band].rampData.arfcn_weight[i].low_weight - A60111A_WEIGHT_OFFSET);
- }
- sdata[11] = 0;
- Array_To_String_short(str, sdata, 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_sEpskRamp.s_ramp_table[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_sEpskRamp.s_ramp_table[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_sEpskRamp.s_ramp_table[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_sEpskRamp.s_ramp_table[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_sEpskRamp.s_ramp_table[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_sEpskRamp.s_ramp_table[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_sEpskRamp.s_ramp_table[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_sEpskRamp.s_ramp_table[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_sEpskRamp.s_ramp_table[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_sEpskRamp.s_ramp_table[band].rampData.tx_afc_offset);
- ini_file->WriteString(SUBBAND_NAME[band],
- KEY_NAME_INTERSLOT_LOWEST_DAC,
- m_ucInterslotLowestDAC[band]);
- delete ini_file;
- return true;
- }
- //--------------------------------------------------------------------------
- bool CRFAPC8PSK::REQ_Write_APC_To_File(char *filename, unsigned int rf_id)
- {
- TIniFile *ini_file;
- AnsiString asdata;
- 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;
- if( frmMainSel->cbGSM850->Checked )
- { total_band_num = 4;
- }
- else
- {
- total_band_num = 3;
- }
- for (band = 0; band<total_band_num; band++)
- {
- if (!REQ_Write_APC_To_File_Single_Band(filename, rf_id, band))
- {
- return false;
- }
- }
- return true;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- bool CRFAPC8PSK::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 CRFAPC8PSK::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 CRFAPC8PSK::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 CRFAPC8PSK::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 CRFAPC8PSK::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 CRFAPC8PSK::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 CRFAPC8PSK::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 CRFAPC8PSK::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 CRFAPC8PSK::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 CRFAPC8PSK::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 CRFAPC8PSK::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 CRFAPC8PSK::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 CRFAPC8PSK::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==0) 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);
- 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_sEpskRamp.s_ramp_table[band].rampData.power[i] );
- fprintf( fs, "%3d },n", m_sEpskRamp.s_ramp_table[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_sEpskRamp.s_ramp_table[band].rampData.ramp[profile].point[0][i] );
- fprintf( fs, "%3d },n", m_sEpskRamp.s_ramp_table[band].rampData.ramp[profile].point[0][15] );
- fprintf( fs, " /* ramp down */ { ");
- for(i=0; i<15; i++) fprintf( fs, "%3d,", m_sEpskRamp.s_ramp_table[band].rampData.ramp[profile].point[1][i] );
- fprintf( fs, "%3d } }n", m_sEpskRamp.s_ramp_table[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_sEpskRamp.s_ramp_table[band].rampData.arfcn_weight[i].max_arfcn;
- if( (arfcn<0)||(arfcn>1023) ) break;
- int mid_level = PCL2POWER(band, m_sEpskRamp.s_ramp_table[band].rampData.arfcn_weight[i].mid_level);
- int hi_weight = m_sEpskRamp.s_ramp_table[band].rampData.arfcn_weight[i].hi_weight;
- int lo_weight = m_sEpskRamp.s_ramp_table[band].rampData.arfcn_weight[i].low_weight;
- double d_weight_scale = (RF_ID_A60111A == rf_id) ? WEIGHT_SCALE : 1.0;
- fprintf( fs, " { %4d , %2d , WEIGHT(%.3f), WEIGHT(%.3f) },n", arfcn, mid_level, (float)(1.0*hi_weight/d_weight_scale), (float)(1.0*lo_weight/d_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);
- }
- #if 0
- //----------------------------------------------------------------------------
- bool CRFAPC8PSK::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 CRFAPC8PSK::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;
- }
- Confirm(METAAPP_SUCCESS);
- return true;
- }
- //-----------------------------------------------------------------------------
- bool CRFAPC8PSK::Set_RenesasCoef(RF_BRIGHT5P_Coef_T rf_mod_coef)
- {
- b5p_coef = rf_mod_coef;
- return true;
- }
- //-----------------------------------------------------------------------------
- bool CRFAPC8PSK::Get_RenesasCoef( RF_BRIGHT5P_Coef_T &rf_mod_coef )
- {
- rf_mod_coef = b5p_coef;
- return true;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- bool CRFAPC8PSK::Get_BvMode( void )
- {
- return b5p_coef.tx.bvmode;
- }
- //-----------------------------------------------------------------------------
- void CRFAPC8PSK::Set_BvMode( unsigned int bvmode )
- {
- b5p_coef.tx.bvmode = bvmode;
- }
- //-----------------------------------------------------------------------------
- void CRFAPC8PSK::REQ_SetW6sImmediateBSI_Start( unsigned int w6s )
- {
- W6S = w6s;
- ActiveMan->SetActiveFunction( ::REQ_SetW6sImmediateBSI );
- }
- //-----------------------------------------------------------------------------
- void CRFAPC8PSK::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;
- }
- Confirm(METAAPP_SUCCESS);
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CRFAPC8PSK::REQ_RfEPSKSetRampTable_Start( int band_idx )
- {
- rf_apc_8psk_ptr = this;
- g_bIsRunning = true;
- CurWRBand = band_idx;
- ActiveMan->SetActiveFunction( ::REQ_RfEPSKSetRampTable );
- }
- //-------------------------------------------------------------------------
- bool CRFAPC8PSK::REQ_RfEPSKSetRampTable( void )
- {
- #if 0
- FrequencyBand freqband = ApcBandIdx_To_FreqBand(CurWRBand);
- META_RESULT MetaResult = META_Rf_EPSK_SetRampTable_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, freqband, &m_sEpskRamp.s_ramp_table[CurWRBand]);
- if(MetaResult!=META_SUCCESS)
- {
- if( MetaResult!=META_TIMEOUT )
- { Confirm( METAAPP_FAIL ); return false; }
- else
- { Confirm( METAAPP_TIMEOUT ); return false; }
- }
- ActiveMan->SetActiveFunction( ::REQ_Finish );
- #endif
- return true;
- }
- //===========================================================================
- void CRFAPC8PSK::REQ_EPSK_SetRampApcLevel_Start(RfSetRampApcLevel_Req *req)
- {
- rf_apc_8psk_ptr = this;
- g_bIsRunning = true;
- m_pRfSetApcDac = req;
- ActiveMan->SetActiveFunction( ::REQ_EPSK_SetRampApcLevel );
- }
- //--------------------------------------------------------------------------
- void CRFAPC8PSK::REQ_EPSK_SetRampApcLevel( void )
- {
- if(!g_bIsRunning) return;
- META_RESULT MetaResult = META_Rf_EPSK_SetRampApcLevel_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, m_pRfSetApcDac);
- if(MetaResult!=META_SUCCESS)
- {
- if( MetaResult!=META_TIMEOUT )
- { Confirm( METAAPP_FAIL ); return; }
- else
- { Confirm( METAAPP_TIMEOUT ); return; }
- }
- Confirm(METAAPP_SUCCESS);
- }
- //===========================================================================
- ///////////////////////// Query //////////////////////////////
- //===========================================================================
- void CRFAPC8PSK::Query_RfEPSKSetRampTable_Start( bool &RfEPSKSetRampTableSupport )
- {
- rf_apc_8psk_ptr = this;
- g_bIsRunning = true;
- p_rf_epsk_set_ramp_table_support = &RfEPSKSetRampTableSupport;
- ActiveMan->SetActiveFunction( ::Query_RfEPSKSetRampTable );
- }
- //-------------------------------------------------------------------------
- bool CRFAPC8PSK::Query_RfEPSKSetRampTable( void )
- {
- META_RESULT MetaResult = META_QueryIfFunctionSupportedByTarget_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, "META_Rf_EPSK_SetRampTable");
- if(MetaResult!=META_SUCCESS)
- {
- *p_rf_epsk_set_ramp_table_support = false;
- if( MetaResult!=META_TIMEOUT )
- { Confirm( METAAPP_FAIL ); return false; }
- else
- { Confirm( METAAPP_TIMEOUT ); return false; }
- }
- *p_rf_epsk_set_ramp_table_support = true;
- Confirm(METAAPP_SUCCESS);
- return true;
- }
- //============================================================================
- ////////////////////////// Global information ////////////////////////////
- //============================================================================
- E_METAAPP_RESULT_T CRFAPC8PSK::Get_ConfirmState( void )
- {
- return m_eConfirmState;
- }
- #if 0
- //---------------------------------------------------------------------------
- unsigned short CRFAPC8PSK::Get_HighApcDcOffset(int band_idx)
- {
- return m_usHighApcDcOffset[band_idx];
- }
- //----------------------------------------------------------------------------
- void CRFAPC8PSK::Set_HighApcDcOffset(int band_idx, unsigned short high_apc_dc_offset)
- {
- m_usHighApcDcOffset[band_idx] = high_apc_dc_offset;
- }
- #endif
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- S_EPSK_RAMP_T* CRFAPC8PSK::Get_ApcProfile(void)
- {
- return &m_sEpskRamp;
- }
- //---------------------------------------------------------------------------
- void CRFAPC8PSK::Set_ApcProfile(S_EPSK_RAMP_T apc_profile)
- {
- m_sEpskRamp = apc_profile;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- unsigned short CRFAPC8PSK::Get_ApcProfilePower( int band_idx, int pcl_idx )
- {
- return m_sEpskRamp.s_ramp_table[band_idx].rampData.power[pcl_idx];
- }
- //---------------------------------------------------------------------------
- void CRFAPC8PSK::Set_ApcProfilePower( int band_idx, int pcl_idx, unsigned short power )
- {
- m_sEpskRamp.s_ramp_table[band_idx].rampData.power[pcl_idx] = power;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- short CRFAPC8PSK::Get_TxAfcOffset( int band_idx, int pcl_idx )
- {
- return m_sEpskRamp.s_ramp_table[band_idx].rampData.tx_afc_offset;
- }
- //---------------------------------------------------------------------------
- void CRFAPC8PSK::Set_TxAfcOffset( int band_idx, short tx_afc_offset )
- {
- m_sEpskRamp.s_ramp_table[band_idx].rampData.tx_afc_offset = tx_afc_offset;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- unsigned char CRFAPC8PSK::Get_InterslotLowestDAC( int band_idx )
- { return m_ucInterslotLowestDAC[band_idx];
- }
- //----------------------------------------------------------------------------
- void CRFAPC8PSK::Set_InterslotLowestDAC( int band_idx, unsigned char dac )
- { m_ucInterslotLowestDAC[band_idx] = dac;
- }