rf_ct.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:13k
- /*****************************************************************************
- * 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_ct.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * RF continuous TX 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
- // RF
- #ifndef _RF_CT_H_
- #include "rf_ct.h"
- #endif
- // man
- #include "man_active.h"
- #include "man_fdm.h"
- //------------------------------------------------------------------------------
- static CRFCT* g_rf_ct_ptr;
- static bool g_bIsRunning = false;
- //===========================================================================
- static void REQ_SelectBand(void)
- {
- g_rf_ct_ptr->REQ_SelectBand();
- }
- //------------------------------------------------------------------------------
- static void __stdcall CNF_SelectBand(const unsigned char cnf, const short token, void *usrData)
- {
- g_rf_ct_ptr->CNF_SelectBand(cnf, token, usrData);
- }
- //------------------------------------------------------------------------------
- static void REQ_BBTXCfg(void)
- {
- g_rf_ct_ptr->REQ_BBTXCfg();
- }
- //------------------------------------------------------------------------------
- static void __stdcall CNF_BBTXCfg(const unsigned char cnf, const short token, void *usrData)
- {
- g_rf_ct_ptr->CNF_BBTXCfg(cnf, token, usrData);
- }
- //------------------------------------------------------------------------------
- static void REQ_ContinueTX(void)
- {
- g_rf_ct_ptr->REQ_ContinueTX();
- }
- //------------------------------------------------------------------------------
- static void __stdcall CNF_ContinueTX(const unsigned char cnf, const short token, void *usrData)
- {
- g_rf_ct_ptr->CNF_ContinueTX(cnf, token, usrData);
- }
- //------------------------------------------------------------------------------
- static void REQ_TimeOut(void)
- {
- g_rf_ct_ptr->REQ_TimeOut();
- }
- //------------------------------------------------------------------------------
- static void REQ_Finish(void)
- {
- g_rf_ct_ptr->REQ_Finish();
- }
- //===========================================================================
- CRFCT::CRFCT(void)
- {
- g_bIsRunning = false;
- ConfirmCallback = 0;
- m_psRFReq_CT = NULL;
- m_psRFReq_BBTXCFG = NULL;
- m_psRfCnTxEx = NULL;
- }
- //---------------------------------------------------------------------------
- CRFCT::~CRFCT()
- {
- if (m_psRFReq_BBTXCFG != NULL)
- {
- delete m_psRFReq_BBTXCFG;
- m_psRFReq_BBTXCFG = NULL;
- }
- if (m_psRFReq_CT != NULL)
- {
- delete m_psRFReq_CT;
- m_psRFReq_CT = NULL;
- }
- if (m_psRfCnTxEx != NULL)
- {
- delete m_psRfCnTxEx;
- m_psRfCnTxEx = NULL;
- }
- }
- //---------------------------------------------------------------------------
- void CRFCT::REQ_Finish(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- Confirm(METAAPP_SUCCESS);
- }
- //---------------------------------------------------------------------------
- void CRFCT::REQ_Stop(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- META_Cancel_r(m_META_HANDLE_Obj.Get_MainHandle(), m_sRFID_CT);
- META_CancelAllBlockingCall_r( m_META_HANDLE_Obj.Get_MainHandle() );
- Confirm(METAAPP_STOP);
- }
- //---------------------------------------------------------------------------
- void CRFCT::REQ_TimeOut(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- META_Cancel_r(m_META_HANDLE_Obj.Get_MainHandle(), m_sRFID_CT);
- META_CancelAllBlockingCall_r(m_META_HANDLE_Obj.Get_MainHandle());
- Confirm(METAAPP_TIMEOUT);
- }
- //---------------------------------------------------------------------------
- void CRFCT::Confirm(E_METAAPP_RESULT_T confirm_state)
- {
- if(!g_bIsRunning) return;
- g_bIsRunning = false;
- if(ConfirmCallback==0) return;
- m_eConfirmState = confirm_state;
- ActiveMan->SetActiveFunction( ConfirmCallback );
- }
- //===========================================================================
- void CRFCT::REQ_Start(S_RF_CT rf_ct)
- {
- g_rf_ct_ptr = this;
- g_bIsRunning = true;
- m_sRfCt = rf_ct;
- // m_sRFID_CT.e_band = band;
- // Arfcn = arfcn;
- // Pattern = pattern;
- // OnOff = on_off;
- //PatternData = pattern_data;
- // ModType = modtype;
- // TrimI = trim_i;
- // TrimQ = trim_q;
- // OffsetI = off_i;
- // OffsetQ = off_q;
- ActiveMan->SetActiveFunction( ::REQ_SelectBand );
- }
- //---------------------------------------------------------------------------
- void CRFCT::REQ_SelectBand(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- unsigned char select_PCS1900;
- if(m_sRfCt.e_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, &m_sRFID_CT, NULL );
- if(MetaResult!=META_SUCCESS)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- }
- //-------------------------------------
- void __stdcall CRFCT::CNF_SelectBand(const unsigned char cnf, const short token, void *usrData)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- if (0 == cnf)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- ActiveMan->SetActiveFunction(::REQ_ContinueTX);
- }
- //---------------------------------------------------------------------------
- void CRFCT::REQ_BBTXCfg(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- if (NULL == m_psRFReq_BBTXCFG)
- {
- m_psRFReq_BBTXCFG = new RfSetBBTXCfg_Req;
- }
- // set to default
- m_psRFReq_BBTXCFG->TxTrimI = 0;
- m_psRFReq_BBTXCFG->TxTrimQ = 0;
- m_psRFReq_BBTXCFG->TxOffsetI = 0;
- m_psRFReq_BBTXCFG->TxOffsetQ = 0;
- META_RESULT MetaResult = META_Rf_SetBBTXCfg_r( m_META_HANDLE_Obj.Get_MainHandle(), m_psRFReq_BBTXCFG, ::CNF_BBTXCfg, &m_sRFID_CT, NULL );
- if (MetaResult != META_SUCCESS)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- }
- //-------------------------------------
- void __stdcall CRFCT::CNF_BBTXCfg(const unsigned char cnf, const short token, void *usrData)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- if (0 == cnf)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- ActiveMan->SetActiveFunction(::REQ_ContinueTX);
- }
- //---------------------------------------------------------------------------
- void CRFCT::REQ_ContinueTX(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- META_RESULT MetaResult;
- if( CT_SUPPORT_0 == m_sRfCt.e_rf_ct_support )
- {
- if( NULL == m_psRFReq_CT )
- {
- m_psRFReq_CT = new RfCnTx_Req;
- }
- m_psRFReq_CT->arfcn = m_sRfCt.s_arfcn;
- m_psRFReq_CT->pattern = (ContTxPattern)m_sRfCt.i_pattern;
- m_psRFReq_CT->OnOff = m_sRfCt.i_on_off;
- MetaResult = META_Rf_CONTINUE_TX_r( m_META_HANDLE_Obj.Get_MainHandle(), m_psRFReq_CT, ::CNF_ContinueTX, &m_sRFID_CT, NULL );
- if(MetaResult!=META_SUCCESS)
- {
- if( MetaResult!=META_TIMEOUT )
- { Confirm( METAAPP_FAIL ); return; }
- else
- { ActiveMan->SetActiveFunction( ::REQ_TimeOut ); return; }
- }
- }
- else if( CT_SUPPORT_1 == m_sRfCt.e_rf_ct_support )
- {
- if( NULL == m_psRfCnTxEx )
- {
- m_psRfCnTxEx = new RfCnTxEx_Req;
- }
- m_psRfCnTxEx->arfcn = m_sRfCt.s_arfcn;
- m_psRfCnTxEx->pattern = (ContTxPattern)m_sRfCt.i_pattern;
- m_psRfCnTxEx->OnOff = m_sRfCt.i_on_off;
- m_psRfCnTxEx->pattern_data = m_sRfCt.us_pattern_data;
- m_psRfCnTxEx->modtype = m_sRfCt.us_modtype;
- MetaResult = META_Rf_CONTINUE_TX_Ex_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, m_psRfCnTxEx);
- if(MetaResult!=META_SUCCESS)
- {
- if (MetaResult != META_TIMEOUT)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- else
- {
- ActiveMan->SetActiveFunction(::REQ_TimeOut);
- return;
- }
- }
- }
- else
- {
- if (NULL == m_psRfCnTxEx2)
- {
- m_psRfCnTxEx2 = new RfCnTxEx2_Req;
- }
- m_psRfCnTxEx2->arfcn = m_sRfCt.s_arfcn;
- m_psRfCnTxEx2->pattern = (ContTxPattern)m_sRfCt.i_pattern;
- m_psRfCnTxEx2->OnOff = m_sRfCt.i_on_off;
- m_psRfCnTxEx2->pattern_data = m_sRfCt.us_pattern_data;
- m_psRfCnTxEx2->modtype = m_sRfCt.us_modtype;
- m_psRfCnTxEx2->powerLev = (Power) m_sRfCt.i_pcl;
- MetaResult = META_Rf_CONTINUE_TX_Ex2_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, m_psRfCnTxEx2);
- if (MetaResult != META_SUCCESS)
- {
- if (MetaResult != META_TIMEOUT)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- else
- {
- ActiveMan->SetActiveFunction(::REQ_TimeOut);
- return;
- }
- }
- }
- ActiveMan->SetActiveFunction(::REQ_Finish);
- }
- //-------------------------------------
- void __stdcall CRFCT::CNF_ContinueTX(const unsigned char cnf, const short token, void *usrData)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- if (0 == cnf)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- ActiveMan->SetActiveFunction(::REQ_Finish);
- }
- //===========================================================================
- ///////////////////////// Global information //////////////////////////////
- //===========================================================================
- E_METAAPP_RESULT_T CRFCT::Get_ConfirmState(void)
- {
- return m_eConfirmState;
- }