rf_afc.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:26k
- /*****************************************************************************
- * 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_afc.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * RF 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 <IniFiles.hpp>
- #pragma hdrstop
- #ifndef _RF_COMMON_H_
- #include "rf_common.h"
- #endif
- #ifndef _RF_AFC_H_
- #include "rf_afc.h"
- #endif
- #ifndef _MAN_ACTIVE_H_
- #include "man_active.h"
- #endif
- #ifndef _MAN_FDM_H_
- #include "man_fdm.h"
- #endif
- #ifndef _MAN_HANDLE_H_
- #include "man_handle.h"
- #endif
- // NVRAM
- #ifndef _NVRAM_VER_H_
- #include "nvram_ver.h"
- #endif
- //===========================================================================
- static CRFAFC* g_rf_afc_ptr;
- static bool g_bIsRunning = false;
- //===========================================================================
- static void REQ_SelectBand(void)
- { g_rf_afc_ptr->REQ_SelectBand( );
- }
- //------------------------------------------------------------------------------
- static void __stdcall CNF_SelectBand( const unsigned char cnf, const short token, void *usrData )
- {
- g_rf_afc_ptr->CNF_SelectBand( cnf, token, usrData );
- }
- //------------------------------------------------------------------------------
- static void REQ_MeasureAFC( void )
- { g_rf_afc_ptr->REQ_MeasureAFC( );
- }
- //------------------------------------------------------------------------------
- static void __stdcall CNF_MeasureAFC(const RfAfc_Cnf *cnf, const short token, void *usrData)
- {
- g_rf_afc_ptr->CNF_MeasureAFC( cnf, token, usrData);
- }
- //------------------------------------------------------------------------------
- static void CNF_ReadFromNVRAM( void )
- {
- g_rf_afc_ptr->CNF_ReadFromNVRAM();
- }
- //------------------------------------------------------------------------------
- static void CNF_WriteToNVRAM( void )
- {
- g_rf_afc_ptr->CNF_WriteToNVRAM( );
- }
- //------------------------------------------------------------------------------
- static void REQ_TimeOut( void )
- { g_rf_afc_ptr->REQ_TimeOut();
- }
- //------------------------------------------------------------------------------
- static void REQ_Finish( void )
- { g_rf_afc_ptr->REQ_Finish();
- }
- //------------------------------------------------------------------------------
- static void REQ_SetAfcDacValue(short dacValue)
- { g_rf_afc_ptr->REQ_SetAfcDacValue(dacValue);
- }
- //------------------------------------------------------------------------------
- static void __stdcall CNF_RfSet_AFCDACValue(const unsigned char cnf, const short token, void *usrData)
- { g_rf_afc_ptr->CNF_RfSet_AFCDACValue(cnf, token, usrData);
- }
- //--------------------------------------------------------------------------
- // continuous sine wave
- static void Query_ContSineSupport( void )
- {
- g_rf_afc_ptr->Query_ContSineSupport();
- }
- //--------------------------------------------------------------------------
- static void REQ_SetAfcSinWaveDetection(void)
- {
- g_rf_afc_ptr->REQ_SetAfcSinWaveDetection();
- }
- //===========================================================================
- CRFAFC::CRFAFC(void)
- {
- g_bIsRunning = false;
- ConfirmCallback = 0;
- m_psRFReq_AFC = NULL;
- m_iAfcBufSize = 0;
- m_cAfcBuf = NULL;
- m_sEvalAfcDac[0] = 4100;
- m_sEvalAfcDac[1] = 4100;
- m_iEvalFreqErr[0] = 0;
- m_iEvalFreqErr[1] = 0;
- }
- //---------------------------------------------------------------------------
- CRFAFC::~CRFAFC()
- {
- g_bIsRunning = false;
- ConfirmCallback = 0;
- if(m_psRFReq_AFC)
- {
- delete m_psRFReq_AFC;
- m_psRFReq_AFC = NULL;
- }
- if(m_cAfcBuf)
- {
- delete [] m_cAfcBuf;
- m_cAfcBuf = NULL;
- }
- }
- //---------------------------------------------------------------------------
- void CRFAFC::REQ_Finish(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- Confirm(METAAPP_SUCCESS);
- }
- //---------------------------------------------------------------------------
- void CRFAFC::REQ_Stop(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- META_Cancel_r(m_META_HANDLE_Obj.Get_MainHandle(), m_sRFID_AFC);
- Confirm(METAAPP_STOP);
- }
- //---------------------------------------------------------------------------
- void CRFAFC::REQ_TimeOut(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- META_Cancel_r( m_META_HANDLE_Obj.Get_MainHandle(), m_sRFID_AFC );
- Confirm( METAAPP_TIMEOUT );
- }
- //---------------------------------------------------------------------------
- void CRFAFC::Confirm(E_METAAPP_RESULT_T confirm_state)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- if (confirm_state != METAAPP_SECTION_OK)
- {
- g_bIsRunning = false;
- }
-
- if (NULL == ConfirmCallback)
- {
- return;
- }
- m_eConfirmState = confirm_state;
- ActiveMan->SetActiveFunction(ConfirmCallback);
- }
- //===========================================================================
- void CRFAFC::REQ_Start( int band, int arfcn, int gain, int afc_dac, short test_count )
- {
- g_rf_afc_ptr = this;
- g_bIsRunning = true;
- m_iBand = band;
- m_sArfcn = arfcn;
- m_iGain = gain;
- m_sAfcDac = afc_dac;
- m_sTestCount = test_count;
- m_bAfcSweep = false;
- ActiveMan->SetActiveFunction( ::REQ_SelectBand );
- }
- //--------------------------------------------------------------------------------------------------
- void CRFAFC::REQ_Start( int band, int arfcn, int gain, int minafc_dac, short test_count, int maxafc_dac, int stepafc_dac )
- {
- g_rf_afc_ptr = this;
- g_bIsRunning = true;
- m_iBand = band;
- m_sArfcn = arfcn;
- m_iGain = gain;
- m_sAfcDac = minafc_dac;
- m_sTestCount = test_count;
- m_sCurAFC = minafc_dac;
- m_sAFCMin = minafc_dac;
- m_sAFCMax = maxafc_dac;
- m_sAFCStep = stepafc_dac;
- m_bAfcSweep = true;
- ActiveMan->SetActiveFunction( ::REQ_SelectBand );
- }
- //---------------------------------------------------------------------------
- void CRFAFC::REQ_SelectBand( void )
- {
- if(!g_bIsRunning) return;
- unsigned char select_PCS1900;
- if(m_iBand==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, &m_sRFID_AFC, NULL );
- if(MetaResult!=META_SUCCESS)
- { Confirm( METAAPP_FAIL ); return; }
- }
- //-------------------------------------
- void __stdcall CRFAFC::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_MeasureAFC );
- }
- //---------------------------------------------------------------------------
- void CRFAFC::REQ_MeasureAFC( void )
- {
- if (!g_bIsRunning)
- {
- return;
- }
- if (NULL == m_psRFReq_AFC)
- {
- m_psRFReq_AFC = new RfAfc_Req;
- }
- if (!m_bAfcSweep)
- {
- m_psRFReq_AFC->arfcn = m_sArfcn;
- m_psRFReq_AFC->gain = m_iGain;
- m_psRFReq_AFC->dacValue = m_sAfcDac;
- m_psRFReq_AFC->testNumber = m_sTestCount;
- META_RESULT MetaResult = META_Rf_AFC_r( m_META_HANDLE_Obj.Get_MainHandle(), m_psRFReq_AFC, ::CNF_MeasureAFC, &m_sRFID_AFC, NULL );
- if (MetaResult != META_SUCCESS)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- }
- else
- {
- if( m_bHasMeasured )
- {
- m_sDisplayAFC = m_sCurAFC - m_sAFCStep;
- Confirm( METAAPP_SECTION_OK );
- }
- m_psRFReq_AFC->arfcn = m_sArfcn;
- m_psRFReq_AFC->gain = m_iGain;
- m_psRFReq_AFC->dacValue = m_sCurAFC;
- m_psRFReq_AFC->testNumber = m_sTestCount;
- m_bHasMeasured = false;
- META_RESULT MetaResult = META_Rf_AFC_r( m_META_HANDLE_Obj.Get_MainHandle(), m_psRFReq_AFC, ::CNF_MeasureAFC, &m_sRFID_AFC, NULL );
- if (MetaResult != META_SUCCESS)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- }
- m_sCurAFC += m_sAFCStep;
- if (m_bAfcSweep)
- {
- if (m_sCurAFC > (m_sAFCMax + m_sAFCStep))
- {
- REQ_Finish();
- return;
- }
- }
- }
- //-------------------------------------
- void __stdcall CRFAFC::CNF_MeasureAFC(const RfAfc_Cnf *cnf, const short token, void *usrData)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- //int i = 0;
- if (!m_bAfcSweep)
- {
- if (STATUS_AFC_OK == (E_AFC_STATUS_T) cnf->ok)
- {
- m_sRFCnf_AFC = *cnf;
- if (cnf->fcb_ok_number)
- {
- m_sEvalAfcDac[0] = m_sEvalAfcDac[1];
- m_iEvalFreqErr[0] = m_iEvalFreqErr[1];
- m_sEvalAfcDac[1] = m_sAfcDac;
- m_iEvalFreqErr[1] = cnf->freqOffset;
- }
- ActiveMan->SetActiveFunction( ::REQ_Finish );
- }
- else
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- }
- else
- {
- m_bHasMeasured = true;
- if (cnf->ok == STATUS_AFC_OK)
- {
- m_sRFCnf_AFC = *cnf;
- ActiveMan->SetActiveFunction( ::REQ_MeasureAFC );
- }
- else
- {
- Confirm( METAAPP_FAIL );
- return;
- }
- }
- }
- //===========================================================================
- void CRFAFC::REQ_Read_From_NVRAM_Start(void)
- {
- g_rf_afc_ptr = this;
- g_bIsRunning = true;
- m_bDownloadTrigger = false;
- REQ_Read_From_NVRAM();
- }
- //--------------------------------------------------------------------------
- void CRFAFC::REQ_Read_From_NVRAM(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- if (NULL == m_cAfcBuf)
- {
- META_RESULT MetaResult = META_NVRAM_GetRecLen( "NVRAM_EF_L1_AFCDATA_LID",
- &m_iAfcBufSize );
- if (MetaResult!=META_SUCCESS)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- m_cAfcBuf = new char[m_iAfcBufSize];
- }
- NVRAMMan->ConfirmCallback = ::CNF_ReadFromNVRAM;
- NVRAMMan->REQ_ReadNVRAM_Start("NVRAM_EF_L1_AFCDATA_LID",
- 1,
- m_iAfcBufSize,
- m_cAfcBuf);
- }
- //-------------------------------------
- void CRFAFC::CNF_ReadFromNVRAM(void)
- {
- if(!g_bIsRunning) return;
- E_METAAPP_RESULT_T state = NVRAMMan->Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- if (m_bDownloadTrigger)
- {
- REQ_Write_To_NVRAM();
- }
- else
- {
- META_RESULT MetaResult = META_NVRAM_GetRecFieldValue("NVRAM_EF_L1_AFCDATA_LID",
- "dacValue",
- m_cAfcBuf,
- m_iAfcBufSize,
- &m_sAfcResult.s_InitAfcDac,
- sizeof(m_sAfcResult.s_InitAfcDac));
- if (MetaResult != META_SUCCESS)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- MetaResult = META_NVRAM_GetRecFieldValue("NVRAM_EF_L1_AFCDATA_LID",
- "slopeInv",
- m_cAfcBuf,
- m_iAfcBufSize,
- &m_sAfcResult.i_AfcSlopeInv,
- sizeof(m_sAfcResult.i_AfcSlopeInv));
- if (MetaResult != META_SUCCESS)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- ActiveMan->SetActiveFunction(::REQ_Finish);
- }
- }
- break;
- default:
- {
- Confirm(state);
- }
- break;
- }
- }
- //===========================================================================
- void CRFAFC::REQ_Write_To_NVRAM_Start(void)
- {
- g_rf_afc_ptr = this;
- g_bIsRunning = true;
- m_bDownloadTrigger = true;
- REQ_Write_To_NVRAM();
- }
- //---------------------------------------------------------------------------
- void CRFAFC::REQ_Write_To_NVRAM(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- unsigned short lid_ver;
- META_RESULT MetaResult;
- MetaResult = META_NVRAM_GetLIDVersion("NVRAM_EF_L1_AFCDATA_LID", &lid_ver);
- if (lid_ver > NVRAM_EF_L1_AFCDATA_LID_VERNO)
- {
- Confirm(METAAPP_NVRAM_LID_VER_NOT_SUPPORT);
- return;
- }
- if (NULL == m_cAfcBuf)
- {
- META_RESULT MetaResult = META_NVRAM_GetRecLen( "NVRAM_EF_L1_AFCDATA_LID",
- &m_iAfcBufSize);
- if (MetaResult != META_SUCCESS)
- {
- Confirm( METAAPP_FAIL );
- return;
- }
- m_cAfcBuf = new char[m_iAfcBufSize];
- }
- unsigned short sdata = (unsigned short)m_sAfcResult.s_InitAfcDac;
- MetaResult = META_NVRAM_SetRecFieldValue( "NVRAM_EF_L1_AFCDATA_LID",
- "dacValue",
- m_cAfcBuf,
- m_iAfcBufSize,
- &sdata,
- sizeof(sdata) );
- if(MetaResult!=META_SUCCESS)
- { Confirm( METAAPP_FAIL ); return; }
- MetaResult = META_NVRAM_SetRecFieldValue( "NVRAM_EF_L1_AFCDATA_LID",
- "slopeInv",
- m_cAfcBuf,
- m_iAfcBufSize,
- &m_sAfcResult.i_AfcSlopeInv,
- sizeof(m_sAfcResult.i_AfcSlopeInv) );
- if(MetaResult!=META_SUCCESS)
- { Confirm( METAAPP_FAIL ); return; }
- NVRAMMan->ConfirmCallback = ::CNF_WriteToNVRAM;
- NVRAMMan->REQ_WriteNVRAM_Start( "NVRAM_EF_L1_AFCDATA_LID",
- 1, // only 1 record
- m_iAfcBufSize,
- m_cAfcBuf );
- }
- //-------------------------------------
- void CRFAFC::CNF_WriteToNVRAM(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- E_METAAPP_RESULT_T state = NVRAMMan->Get_ConfirmState();
- Confirm(state);
- }
- //===========================================================================
- bool CRFAFC::AfcSectionExist( char *filename )
- {
- TIniFile *ini_file;
- ini_file = new TIniFile( filename );
- if( ini_file == NULL ) return false;
- if( ini_file->SectionExists( "AFC control" ) )
- {
- return true;
- }
- return false;
- }
- //-----------------------------------------------------------------------------
- bool CRFAFC::REQ_Read_From_File( char *filename )
- {
- TIniFile *ini_file;
- AnsiString as_slope;
- double ddata;
- ini_file = new TIniFile( filename );
- if( ini_file == NULL ) return false;
- // if( ini_file->SectionExists( "AFC control" ) == false )
- // return false;
- m_sAfcResult.s_InitAfcDac = ini_file->ReadInteger( "AFC control",
- "Initial value",
- 4100 );
- as_slope = ini_file->ReadString("AFC control",
- "Slope",
- "1.0");
- ddata = atof(as_slope.c_str());
- if (0 == ddata)
- {
- ddata=0.0000001;
- }
- ddata = AFC_SLOPE_SCALE/ddata;
- ddata += (ddata>=0) ? 0.5 : -0.5 ;
- m_sAfcResult.i_AfcSlopeInv = (int) ddata;
- delete ini_file;
- return true;
- }
- //===========================================================================
- bool CRFAFC::REQ_Write_To_File( char *filename )
- {
- TIniFile *ini_file;
- char str[20];
- float fdata;
- ini_file = new TIniFile( filename );
- if(ini_file == NULL) return false;
- ini_file->WriteInteger( "AFC control",
- "Initial value",
- m_sAfcResult.s_InitAfcDac );
- if( 0 == m_sAfcResult.i_AfcSlopeInv ) m_sAfcResult.i_AfcSlopeInv=1;
- fdata = 1.0*AFC_SLOPE_SCALE/m_sAfcResult.i_AfcSlopeInv;
- sprintf( str, "%.4f", fdata );
- ini_file->WriteString( "AFC control",
- "Slope",
- str );
- delete ini_file;
-
- return true;
- }
- //===========================================================================
- E_BANDSEL CRFAFC::Get_Band_Index(AnsiString as_AFC_BAND )
- {
- E_BANDSEL band_index;
- if( as_AFC_BAND.AnsiCompareIC("GSM") == 0 )
- {
- band_index = BANDSEL_GSM900;
- }
- else if( as_AFC_BAND.AnsiCompareIC("DCS") == 0 )
- {
- band_index = BANDSEL_DCS1800;
- }
- else if( as_AFC_BAND.AnsiCompareIC("PCS") == 0 )
- {
- band_index = BANDSEL_PCS1900;
- }
- else if( as_AFC_BAND.AnsiCompareIC("GSM850") == 0 )
- {
- band_index = BANDSEL_GSM850;
- }
- else if( as_AFC_BAND.AnsiCompareIC("GSM400") == 0 )
- {
- band_index = BANDSEL_GSM400;
- }
- return band_index;
- }
- //---------------------------------------------------------------------------
- float CRFAFC::Get_Afc_Slope_factor( int band_index )
- {
- float Afc_Slope_factor;
- switch( band_index )
- {
- case BANDSEL_GSM900:
- Afc_Slope_factor = 1.0;
- break;
- case BANDSEL_DCS1800:
- Afc_Slope_factor = 900.0/1800.0;
- break;
- case BANDSEL_PCS1900:
- Afc_Slope_factor = 900.0/1900.0;
- break;
- case BANDSEL_GSM850:
- Afc_Slope_factor = 900.0/850.0;
- break;
- case BANDSEL_GSM400:
- Afc_Slope_factor = 900.0/400.0;
- break;
- default:
- Afc_Slope_factor = 1.0;
- break;
- }
- return Afc_Slope_factor;
- }
- //---------------------------------------------------------------------------
- void CRFAFC::Evaluate( E_BANDSEL band_index )
- {
- short d0 = m_sEvalAfcDac[0];
- short d1 = m_sEvalAfcDac[1];
- int f0 = m_iEvalFreqErr[0];
- int f1 = m_iEvalFreqErr[1];
- float fdata;
- float Afc_Slope_factor = Get_Afc_Slope_factor(band_index);
- if(f0-f1!=0)
- {
- fdata = d0 - 1.0*f0*(d0-d1)/(f0-f1);
- fdata += (fdata>=0) ? 0.5 : -0.5 ;
- m_sEvalInitDac = (int)fdata;
- fdata = -1.0*(d0-d1)/(f0-f1)/Afc_Slope_factor*AFC_SLOPE_SCALE;
- fdata += (fdata>=0) ? 0.5 : -0.5 ;
- m_iEvalSlope = (int)fdata;
- if(m_iEvalSlope==0) m_iEvalSlope=1;
- }
- }
- //===========================================================================
- void CRFAFC::REQ_SetAfcDacValue(short dacValue)
- {
- if(!g_bIsRunning) return;
- m_sRFReq_SetAfcDac.dacValue = dacValue;
- META_Rf_SetAfcDacValue_r(m_META_HANDLE_Obj.Get_MainHandle(), &m_sRFReq_SetAfcDac, ::CNF_RfSet_AFCDACValue, &m_sRFID_AFC, NULL );
- }
- //---------------------------------------------------------------------------
- void __stdcall CRFAFC::CNF_RfSet_AFCDACValue(const unsigned char cnf, const short token, void *usrData)
- {
- if(!g_bIsRunning) return;
- if(cnf==false)
- { Confirm( METAAPP_FAIL ); return; }
- ActiveMan->SetActiveFunction( ::REQ_Finish );
- }
- //===========================================================================
- ///////////////////////////// Query /////////////////////////
- //===========================================================================
- bool CRFAFC::Query_ContSineSupport_Start(void)
- {
- g_rf_afc_ptr = this;
- g_bIsRunning = true;
- bool support = Query_ContSineSupport();
- return support;
- }
- //-------------------------------------------------------------------------
- bool CRFAFC::Query_ContSineSupport(void)
- {
- META_RESULT MetaResult = META_QueryIfFunctionSupportedByTarget_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, "META_Rf_SetAfcSinWaveDetection");
- if (MetaResult!=META_SUCCESS)
- {
- return false;
- }
- return true;
- }
- //===========================================================================
- void CRFAFC::REQ_SetAfcSinWaveDetection_Start(bool b_sinewave)
- {
- g_rf_afc_ptr = this;
- g_bIsRunning = true;
- m_bSineWave = b_sinewave;
- ActiveMan->SetActiveFunction( ::REQ_SetAfcSinWaveDetection );
- }
- //------------------------------------------------------------------------
- void CRFAFC::REQ_SetAfcSinWaveDetection(void)
- {
- if(!g_bIsRunning) return;
- AFC_SINWAVE_DETECTION_E bIsAfcSinWaveOn;
- bIsAfcSinWaveOn = m_bSineWave ? AFC_SINWAVE_ON : AFC_SINWAVE_OFF;
- META_RESULT MetaResult = META_Rf_SetAfcSinWaveDetection_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, bIsAfcSinWaveOn);
- if (MetaResult != META_SUCCESS)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- ActiveMan->SetActiveFunction(::REQ_Finish);
- }
- //===========================================================================
- ///////////////////////////// Global information /////////////////////////
- //===========================================================================
- E_METAAPP_RESULT_T CRFAFC::Get_ConfirmState(void)
- {
- return m_eConfirmState;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- RfAfc_Cnf CRFAFC::Get_AfcCnf( void )
- { return m_sRFCnf_AFC;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- short CRFAFC::Get_EvalAfcDac( int idx )
- { return m_sEvalAfcDac[idx];
- }
- //---------------------------------------------------------------------------
- int CRFAFC::Get_EvalFreqErr( int idx )
- { return m_iEvalFreqErr[idx];
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- short CRFAFC::Get_DisplayAFC( void )
- { return m_sDisplayAFC;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CRFAFC::Get_AfcResult(S_AFC_RESULT& afc_result)
- {
- afc_result = m_sAfcResult;
- }
- //---------------------------------------------------------------------------
- void CRFAFC::Set_AfcResult( S_AFC_RESULT afc_result )
- { m_sAfcResult = afc_result;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- short CRFAFC::Get_EvalInitDac( void )
- { return m_sEvalInitDac;
- }
- //---------------------------------------------------------------------------
- int CRFAFC::Get_EvalSlope( void )
- { return m_iEvalSlope;
- }