crystal_afc.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:25k
- /*****************************************************************************
- * 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:
- * ---------
- * crystal_afc.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * Crystal AFC 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 <vcl.h>
- #include <IniFiles.hpp>
- #pragma hdrstop
- // NVRAM
- #ifndef _NVRAM_VER_H_
- #include "nvram_ver.h"
- #endif
- #include "form_RFTool.h"
- #include "crystal_afc.h"
- #include "man_fdm.h"
- #include "man_active.h"
- //==============================================================================
- static CCRYSTALAFC* crystal_afc_ptr;
- static bool g_bIsRunning = false;
- //==============================================================================
- static void REQ_SelectBand(void)
- {
- crystal_afc_ptr->REQ_SelectBand();
- }
- //------------------------------------------------------------------------------
- static void __stdcall CNF_SelectBand(const unsigned char cnf, const short token, void *usrData)
- {
- crystal_afc_ptr->CNF_SelectBand(cnf, token, usrData);
- }
- //------------------------------------------------------------------------------
- static void REQ_NormalTX(void)
- {
- crystal_afc_ptr->REQ_NormalTX();
- }
- //------------------------------------------------------------------------------
- static void REQ_SetCapID(void)
- {
- crystal_afc_ptr->REQ_SetCapID();
- }
- //------------------------------------------------------------------------------
- static void __stdcall CNF_NormalTX(const unsigned char cnf, const short token, void *usrData)
- {
- crystal_afc_ptr->CNF_NormalTX(cnf, token, usrData);
- }
- //------------------------------------------------------------------------------
- static void CNF_ReadCrystalAfcDataFromNVRAM(void)
- {
- crystal_afc_ptr->CNF_ReadCrystalAfcDataFromNVRAM();
- }
- //------------------------------------------------------------------------------
- static void CNF_WriteCrystalAfcDataToNVRAM(void)
- {
- crystal_afc_ptr->CNF_WriteCrystalAfcDataToNVRAM();
- }
- //------------------------------------------------------------------------------
- static void REQ_TimeOut(void)
- {
- crystal_afc_ptr->REQ_TimeOut();
- }
- //------------------------------------------------------------------------------
- static void REQ_Finish( void )
- {
- crystal_afc_ptr->REQ_Finish();
- }
- //------------------------------------------------------------------------------
- static void REQ_Read_CAPID_From_NVRAM( void )
- {
- crystal_afc_ptr->REQ_Read_CAPID_From_NVRAM();
- }
- //------------------------------------------------------------------------------
- static void CNF_CAPID_ReadFromNVRAM( void )
- {
- crystal_afc_ptr->CNF_CAPID_ReadFromNVRAM();
- }
- //------------------------------------------------------------------------------
- static void REQ_Write_CAPID_To_NVRAM (void)
- {
- crystal_afc_ptr->REQ_Write_CAPID_To_NVRAM();
- }
- //------------------------------------------------------------------------------
- static void CNF_CAPID_WriteToNVRAM( void )
- {
- crystal_afc_ptr->CNF_CAPID_WriteToNVRAM( );
- }
- //==============================================================================
- CCRYSTALAFC::CCRYSTALAFC(void)
- {
- m_uiCrystalAfcBufSize = 0;
- m_cCrystalAfcBuf = NULL;
- RFReq_AFC = NULL;
- RFReq_TX = NULL;
- CapIDBuf = NULL;
- CapIDBufSize = 0;
- g_bIsRunning = false;
- }
- //------------------------------------------------------------------------------
- CCRYSTALAFC::~CCRYSTALAFC()
- {
- if(m_cCrystalAfcBuf)
- {
- delete m_cCrystalAfcBuf;
- m_cCrystalAfcBuf = NULL;
- }
- if(RFReq_AFC)
- {
- delete RFReq_AFC;
- RFReq_AFC = NULL;
- }
- if(RFReq_TX)
- {
- delete RFReq_TX;
- RFReq_TX = NULL;
- }
- if(CapIDBuf)
- {
- delete CapIDBuf;
- CapIDBuf = NULL;
- }
- }
- //---------------------------------------------------------------------------
- void CCRYSTALAFC::REQ_Finish(void)
- {
- if(!g_bIsRunning) return;
- Confirm(METAAPP_SUCCESS);
- g_bIsRunning = false;
- }
- //---------------------------------------------------------------------------
- void CCRYSTALAFC::REQ_Stop( void )
- {
- if(!g_bIsRunning) return;
- META_Cancel_r( m_META_HANDLE_Obj.Get_MainHandle(), CRYSTALID_AFC );
- Confirm( METAAPP_STOP );
- g_bIsRunning = false;
- }
- //------------------------------------------------------------------------------
- void CCRYSTALAFC::REQ_TimeOut( void )
- {
- if(!g_bIsRunning) return;
- META_Cancel_r( m_META_HANDLE_Obj.Get_MainHandle(), CRYSTALID_AFC );
- Confirm( METAAPP_TIMEOUT );
- g_bIsRunning = false;
- }
- //---------------------------------------------------------------------------
- void CCRYSTALAFC::Confirm(E_METAAPP_RESULT_T confirm_state)
- {
- if(!g_bIsRunning) return;
- if(ConfirmCallback==0) return;
- m_eConfirmState = confirm_state;
- ActiveMan->SetActiveFunction( ConfirmCallback );
- }
- //===========================================================================
- void CCRYSTALAFC::REQ_Start_TX(int band, short arfcn, int bsic, int pcl, int frames, int afc_dac)
- {
- crystal_afc_ptr = this;
- g_bIsRunning = true;
- Band = band;
- m_sArfcn = arfcn;
- Bsic = bsic;
- PCL = pcl;
- Frames = frames;
- AFCDac = afc_dac;
- BurstType = 1;
- ActiveMan->SetActiveFunction( ::REQ_SelectBand );
- }
- //===========================================================================
- void CCRYSTALAFC::REQ_SelectBand( void )
- {
- if(!g_bIsRunning) return;
- unsigned char select_PCS1900;
- if(Band==BANDSEL_PCS1900)
- select_PCS1900 = 1;
- else
- select_PCS1900 = 0;
- META_RESULT MetaResult = META_Rf_SelectFrequencyBand1900_r( m_META_HANDLE_Obj.Get_MainHandle(), select_PCS1900, ::CNF_SelectBand, &CRYSTALID_AFC, NULL );
- if(MetaResult!=META_SUCCESS)
- { Confirm( METAAPP_FAIL ); return; }
- }
- //-------------------------------------
- void __stdcall CCRYSTALAFC::CNF_SelectBand( const unsigned char cnf, const short token, void *usrData )
- {
- if(!g_bIsRunning) return;
- if(cnf==false)
- { Confirm(METAAPP_FAIL); return; }
- ActiveMan->SetActiveFunction( ::REQ_NormalTX );
- }
- //-------------------------------------
- void CCRYSTALAFC::REQ_NormalTX( void )
- {
- if(!g_bIsRunning) return;
- if(RFReq_TX == NULL)
- {
- RFReq_TX = new RfNbtx_Req;
- }
- RFReq_TX->arfcn = m_sArfcn;
- RFReq_TX->bsic = Bsic;
- RFReq_TX->power = PCL;
- RFReq_TX->frames = Frames;
- RFReq_TX->dacValue = AFCDac;
- if(BurstType==0) RFReq_TX->burstTypeNB = AB_TX_RANDOM_WITH_SYNC_SEQ;
- if(BurstType==1) RFReq_TX->burstTypeNB = NB_TX_RANDOM_WITH_TSC;
- if(BurstType==2) RFReq_TX->burstTypeNB = NB_TX_ALL_ONES_WITHOUT_TSC;
- META_RESULT MetaResult = META_Rf_NB_TX_r( m_META_HANDLE_Obj.Get_MainHandle(), RFReq_TX, ::CNF_NormalTX, &CRYSTALID_AFC, NULL );
- if(MetaResult!=META_SUCCESS)
- { Confirm( METAAPP_FAIL ); return; }
- }
- //-------------------------------------
- void __stdcall CCRYSTALAFC::CNF_NormalTX(const unsigned char cnf, const short token, void *usrData)
- {
- if(!g_bIsRunning) return;
- if(cnf==false)
- { Confirm( METAAPP_FAIL ); return; }
- ActiveMan->SetActiveFunction( ::REQ_Finish );
- }
- //===========================================================================
- void CCRYSTALAFC::REQ_SetCapID_Start(int cap_id)
- {
- crystal_afc_ptr = this;
- g_bIsRunning = true;
- m_iCapId = cap_id;
- ActiveMan->SetActiveFunction(::REQ_SetCapID);
- }
- //---------------------------------------------------------------------------
- void CCRYSTALAFC::REQ_SetCapID(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- RfSetCrystalCfg_Req req;
- req.cap_id = m_iCapId;
- META_RESULT MetaResult = META_Rf_SetCrystalCapId_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, (const RfSetCrystalCfg_Req *) &req);
- if (MetaResult != META_SUCCESS)
- {
- if (MetaResult != META_TIMEOUT)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- else
- {
- ActiveMan->SetActiveFunction(::REQ_TimeOut);
- return;
- }
- }
- ActiveMan->SetActiveFunction(::REQ_Finish);
- }
- //===========================================================================
- bool CCRYSTALAFC::Decompose_crystalAfcData( void )
- {
- META_RESULT MetaResult = META_NVRAM_Decompose_crystalAfcData(&xo_afc, m_cCrystalAfcBuf, m_uiCrystalAfcBufSize);
- if(MetaResult!=META_SUCCESS) return(false);
- return(true);
- }
- //----------------------------------------------------------------------------
- bool CCRYSTALAFC::Compose_crystalAfcData( void )
- {
- META_RESULT MetaResult = META_NVRAM_Compose_crystalAfcData(&xo_afc, m_cCrystalAfcBuf, m_uiCrystalAfcBufSize);
- if(MetaResult!=META_SUCCESS) return(false);
- return(true);
- }
- //===========================================================================
- void CCRYSTALAFC::REQ_Read_CrystalAfcData_From_NVRAM_Start(void)
- {
- crystal_afc_ptr = this;
- g_bIsRunning = true;
- m_bDownloadCrystalAfcDataTrigger = false;
- REQ_Read_CrystalAfcData_From_NVRAM();
- }
- //---------------------------------------------------------------------------
- void CCRYSTALAFC::REQ_Read_CrystalAfcData_From_NVRAM(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- if (NULL == m_cCrystalAfcBuf)
- {
- META_RESULT MetaResult = META_NVRAM_GetRecLen("NVRAM_EF_L1_CRYSTAL_AFCDATA_LID",
- (int *) &m_uiCrystalAfcBufSize);
- if (MetaResult != META_SUCCESS)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- m_cCrystalAfcBuf = new char[m_uiCrystalAfcBufSize];
- }
- NVRAMMan->ConfirmCallback = ::CNF_ReadCrystalAfcDataFromNVRAM;
- NVRAMMan->REQ_ReadNVRAM_Start( "NVRAM_EF_L1_CRYSTAL_AFCDATA_LID",
- 1,
- m_uiCrystalAfcBufSize,
- m_cCrystalAfcBuf );
- }
- //---------------------------------------------------------------------------
- void CCRYSTALAFC::CNF_ReadCrystalAfcDataFromNVRAM(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- E_METAAPP_RESULT_T state = NVRAMMan->Get_ConfirmState();
- if (METAAPP_SUCCESS == state)
- {
- if (m_bDownloadCrystalAfcDataTrigger)
- {
- REQ_Write_CrystalAfcData_To_NVRAM();
- }
- else
- {
- if (!Decompose_crystalAfcData())
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- ActiveMan->SetActiveFunction(::REQ_Finish);
- }
- }
- else
- {
- Confirm(state);
- }
- }
- //===========================================================================
- void CCRYSTALAFC::REQ_Write_CrystalAfcData_To_NVRAM_Start(void)
- {
- crystal_afc_ptr = this;
- g_bIsRunning = true;
- m_bDownloadCrystalAfcDataTrigger = true;
- REQ_Write_CrystalAfcData_To_NVRAM();
- }
- //---------------------------------------------------------------------------
- void CCRYSTALAFC::REQ_Write_CrystalAfcData_To_NVRAM(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- unsigned short lid_ver;
- META_RESULT MetaResult;
- MetaResult = META_NVRAM_GetLIDVersion("NVRAM_EF_L1_CRYSTAL_AFCDATA_LID", &lid_ver);
- if (lid_ver > NVRAM_EF_L1_CRYSTAL_AFCDATA_LID_VERNO)
- {
- Confirm(METAAPP_NVRAM_LID_VER_NOT_SUPPORT);
- return;
- }
- if (NULL == m_cCrystalAfcBuf)
- {
- MetaResult = META_NVRAM_GetRecLen("NVRAM_EF_L1_CRYSTAL_AFCDATA_LID", (int *) &m_uiCrystalAfcBufSize);
- if (MetaResult != META_SUCCESS)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- m_cCrystalAfcBuf = new char[m_uiCrystalAfcBufSize];
- }
- if (!Compose_crystalAfcData())
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- NVRAMMan->ConfirmCallback = ::CNF_WriteCrystalAfcDataToNVRAM;
- NVRAMMan->REQ_WriteNVRAM_Start("NVRAM_EF_L1_CRYSTAL_AFCDATA_LID",
- 1,
- m_uiCrystalAfcBufSize,
- m_cCrystalAfcBuf);
- }
- //-------------------------------------
- void CCRYSTALAFC::CNF_WriteCrystalAfcDataToNVRAM(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- E_METAAPP_RESULT_T state = NVRAMMan->Get_ConfirmState();
- Confirm(state);
- }
- //===========================================================================
- bool CCRYSTALAFC::REQ_Read_CrystalAfcData_From_File( char *filename )
- {
- TIniFile *ini_file;
- AnsiString as_freq_err;
- ini_file = new TIniFile(filename);
- if (NULL == ini_file)
- {
- return false;
- }
- int i;
- m_iCapId = ini_file->ReadInteger("Crystal AFC control",
- "cap_id",
- 0);
- for (i=0; i<8; i++)
- {
- xo_afc.XO_SlopeAreaData[i].min_dac = ini_file->ReadInteger("Crystal AFC control",
- "AFC_DAC_" + IntToStr(i),
- 0);
- as_freq_err = ini_file->ReadString("Crystal AFC control",
- "FREQ_ERR_" + IntToStr(i),
- "0");
- xo_afc.XO_SlopeAreaData[i].min_freq = atof(as_freq_err.c_str());
- }
- delete ini_file;
- return true;
- }
- //---------------------------------------------------------------------------
- bool CCRYSTALAFC::REQ_Write_CrystalAfcData_To_File(char *filename)
- {
- TIniFile *ini_file;
- ini_file = new TIniFile(filename);
- if (NULL == ini_file)
- {
- return false;
- }
- int i;
- ini_file->WriteInteger("Crystal AFC control",
- "cap_id",
- m_iCapId);
- for (i=0; i<TOTAL_AFCDAC_COUNT; i++)
- {
- ini_file->WriteInteger("Crystal AFC control",
- "AFC_DAC_" + IntToStr(i),
- xo_afc.XO_SlopeAreaData[i].min_dac);
- }
- for (i=0; i<TOTAL_AFCDAC_COUNT; i++)
- {
- ini_file->WriteInteger("Crystal AFC control",
- "FREQ_ERR_" + IntToStr(i),
- xo_afc.XO_SlopeAreaData[i].min_freq);
- }
- delete ini_file;
- return true;
- }
- //===========================================================================
- ///////////////////////// CAP ID ////////////////////////////////////////////
- //===========================================================================
- void CCRYSTALAFC::REQ_Read_CAPID_From_NVRAM_Start(void)
- {
- crystal_afc_ptr = this;
- g_bIsRunning = true;
- m_bDownloadCAPIDTrigger = false;
- REQ_Read_CAPID_From_NVRAM();
- }
- //---------------------------------------------------------------------------
- void CCRYSTALAFC::REQ_Read_CAPID_From_NVRAM(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- if (NULL == CapIDBuf)
- {
- META_RESULT MetaResult = META_NVRAM_GetRecLen("NVRAM_EF_L1_CRYSTAL_CAPDATA_LID",
- &CapIDBufSize);
- if (MetaResult != META_SUCCESS)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- CapIDBuf = new char[CapIDBufSize];
- }
- NVRAMMan->ConfirmCallback = ::CNF_CAPID_ReadFromNVRAM;
- NVRAMMan->REQ_ReadNVRAM_Start("NVRAM_EF_L1_CRYSTAL_CAPDATA_LID",
- 1,
- CapIDBufSize,
- CapIDBuf);
- }
- //---------------------------------------------------------------------------
- void CCRYSTALAFC::CNF_CAPID_ReadFromNVRAM(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- E_METAAPP_RESULT_T state = NVRAMMan->Get_ConfirmState();
- if (METAAPP_SUCCESS == state)
- {
- if (m_bDownloadCAPIDTrigger)
- {
- REQ_Write_CAPID_To_NVRAM();
- }
- else
- {
- if (!Decompose_CapID())
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- ActiveMan->SetActiveFunction(::REQ_Finish);
- }
- }
- else
- {
- Confirm(state);
- }
- }
- //==============================================================================
- void CCRYSTALAFC::REQ_Write_CAPID_To_NVRAM_Start(void)
- {
- crystal_afc_ptr = this;
- g_bIsRunning = true;
- m_bDownloadCAPIDTrigger = true;
- REQ_Write_CAPID_To_NVRAM();
- }
- //---------------------------------------------------------------------------
- void CCRYSTALAFC::REQ_Write_CAPID_To_NVRAM(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- unsigned short lid_ver;
- META_RESULT MetaResult;
- MetaResult = META_NVRAM_GetLIDVersion("NVRAM_EF_L1_CRYSTAL_CAPDATA_LID", &lid_ver);
- if (lid_ver > NVRAM_EF_L1_CRYSTAL_CAPDATA_LID_VERNO)
- {
- Confirm(METAAPP_NVRAM_LID_VER_NOT_SUPPORT);
- return;
- }
- if (NULL == CapIDBuf)
- {
- MetaResult = MetaResult = META_NVRAM_GetRecLen("NVRAM_EF_L1_CRYSTAL_CAPDATA_LID",
- &CapIDBufSize );
- if(MetaResult!=META_SUCCESS)
- { Confirm( METAAPP_FAIL ); return; }
- CapIDBuf = new char[CapIDBufSize];
- }
- if( !Compose_CapID() )
- { Confirm( METAAPP_FAIL ); return; }
- NVRAMMan->ConfirmCallback = ::CNF_CAPID_WriteToNVRAM;
- NVRAMMan->REQ_WriteNVRAM_Start("NVRAM_EF_L1_CRYSTAL_CAPDATA_LID",
- 1,
- CapIDBufSize,
- CapIDBuf);
- }
- //-------------------------------------
- void CCRYSTALAFC::CNF_CAPID_WriteToNVRAM(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- E_METAAPP_RESULT_T state = NVRAMMan->Get_ConfirmState();
- Confirm(state);
- }
- //===========================================================================
- bool CCRYSTALAFC::Decompose_CapID(void)
- {
- META_RESULT MetaResult = META_NVRAM_GetRecFieldValue("NVRAM_EF_L1_CRYSTAL_CAPDATA_LID",
- "cap_id",
- CapIDBuf,
- CapIDBufSize,
- &m_iCapId,
- sizeof(m_iCapId));
- if (MetaResult!=META_SUCCESS)
- {
- return false;
- }
- return true;
- }
- //----------------------------------------------------------------------------
- bool CCRYSTALAFC::Compose_CapID(void)
- {
- char str[64];
- META_RESULT MetaResult = META_NVRAM_SetRecFieldValue("NVRAM_EF_L1_CRYSTAL_CAPDATA_LID",
- "cap_id",
- CapIDBuf,
- CapIDBufSize,
- &m_iCapId,
- sizeof(m_iCapId));
- if (MetaResult != META_SUCCESS)
- {
- return false;
- }
- return true;
- }
- //===========================================================================
- bool CCRYSTALAFC::CrystalAfcSectionExist(char *filename)
- {
- int FrequencyBandStart;
- TIniFile *ini_file;
- ini_file = new TIniFile(filename);
- if (NULL == ini_file)
- {
- return false;
- }
- if (ini_file->SectionExists("AFC control") &&
- ini_file->SectionExists("Crystal AFC control"))
- {
- return true;
- }
- return false;
- }
- //--------------------------------------------------------------------------
- bool CCRYSTALAFC::REQ_Read_CAPID_From_File(char *filename)
- {
- TIniFile *ini_file;
- float fdata;
- ini_file = new TIniFile(filename);
- if (NULL == ini_file)
- {
- return false;
- }
- m_iCapId = ini_file->ReadInteger("Crystal AFC control", "cap_id", 31);
- delete ini_file;
- return true;
- }
- //---------------------------------------------------------------------------
- bool CCRYSTALAFC::REQ_Write_CAPID_To_File(char *filename)
- {
- TIniFile *ini_file;
- ini_file = new TIniFile( filename);
- if (NULL == ini_file)
- {
- return false;
- }
- ini_file->WriteInteger("Crystal AFC control", "cap_id", m_iCapId);
- delete ini_file;
- return true;
- }
- //===========================================================================
- ///////////////////////// Global information ///////////////////////
- //===========================================================================
- E_METAAPP_RESULT_T CCRYSTALAFC::Get_ConfirmState(void)
- {
- return m_eConfirmState;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- int CCRYSTALAFC::Get_max_cap_id(unsigned int rf_id)
- {
- int max_cap_id;
- if ((RF_ID_A60111A == rf_id) ||
- (RF_ID_AERO2 == rf_id) ||
- (RF_ID_AERO2E == rf_id) ||
- (RF_ID_ALICEG2S == rf_id)
- )
- {
- max_cap_id = CAP_ID_MAX_127;
- }
- else if (RF_ID_AG2550 == rf_id)
- {
- max_cap_id = CAP_ID_MAX_511;
- }
- else // AD6548, AD6546, MT6139, MT6140
- {
- max_cap_id = CAP_ID_MAX_63;
- }
- return max_cap_id;
- }
- //------------------------------------------------------------------------
- int CCRYSTALAFC::Get_cap_id(void)
- {
- return m_iCapId;
- }
- //-------------------------------------------------------------------------
- void CCRYSTALAFC::Set_cap_id(int cap_id_par)
- {
- m_iCapId = cap_id_par;
- }