rf_cr.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:8k
- /*****************************************************************************
- * 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_cr.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * RF continuous RX 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
- #include "form_RFTool.h"
- #include "man_active.h"
- #include "man_fdm.h"
- // RF
- #ifndef _RF_COMMON_H_
- #include "rf_common.h"
- #endif
- #ifndef _RF_CR_H_
- #include "rf_cr.h"
- #endif
- //===========================================================================
- static CRFCR* rf_cr_ptr;
- static bool g_bIsRunning;
- //===========================================================================
- static void REQ_SelectBand( void )
- { rf_cr_ptr->REQ_SelectBand( );
- }
- //---------------------------------------------------------------------------
- static void __stdcall CNF_SelectBand( const unsigned char cnf, const short token, void *usrData )
- {
- rf_cr_ptr->CNF_SelectBand( cnf, token, usrData );
- }
- //---------------------------------------------------------------------------
- static void REQ_ContinueRX( void )
- { rf_cr_ptr->REQ_ContinueRX( );
- }
- //---------------------------------------------------------------------------
- static void __stdcall CNF_ContinueRX(const unsigned char cnf, const short token, void *usrData)
- {
- rf_cr_ptr->CNF_ContinueRX( cnf, token, usrData);
- }
- //---------------------------------------------------------------------------
- static void REQ_TimeOut( void )
- { rf_cr_ptr->REQ_TimeOut();
- }
- //---------------------------------------------------------------------------
- static void REQ_Finish( void )
- { rf_cr_ptr->REQ_Finish();
- }
- //===========================================================================
- CRFCR::CRFCR( void )
- {
- g_bIsRunning = false;
- ConfirmCallback = 0;
- RFReq_CR = NULL;
- }
- //---------------------------------------------------------------------------
- CRFCR::~CRFCR()
- {
- g_bIsRunning = false;
- ConfirmCallback = 0;
- if( RFReq_CR != NULL )
- {
- delete RFReq_CR;
- RFReq_CR = NULL;
- }
- }
- //---------------------------------------------------------------------------
- void CRFCR::REQ_Finish( void )
- {
- if (!g_bIsRunning)
- {
- return;
- }
- //TimerMan->CounterStop();
- Confirm(METAAPP_SUCCESS);
- g_bIsRunning = false;
- }
- //---------------------------------------------------------------------------
- void CRFCR::REQ_Stop(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- //TimerMan->CounterStop();
- META_Cancel_r(m_META_HANDLE_Obj.Get_MainHandle(), RFID_CR);
- Confirm(METAAPP_STOP);
- // g_bIsRunning = false;
- }
- //---------------------------------------------------------------------------
- void CRFCR::REQ_TimeOut( void )
- {
- if(!g_bIsRunning) return;
- //TimerMan->CounterStop();
- META_Cancel_r(m_META_HANDLE_Obj.Get_MainHandle(), RFID_CR);
- Confirm(METAAPP_TIMEOUT);
- // g_bIsRunning = false;
- }
- //---------------------------------------------------------------------------
- void CRFCR::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 CRFCR::REQ_Start( int band, short arfcn, int gain, int on_off )
- {
- rf_cr_ptr = this;
- g_bIsRunning = true;
- Band = band;
- m_sArfcn = arfcn;
- Gain = gain;
- OnOff = on_off;
- //TimerMan->CounterStart( 1000, ::REQ_TimeOut );
- ActiveMan->SetActiveFunction( ::REQ_SelectBand );
- }
- //---------------------------------------------------------------------------
- void CRFCR::REQ_SelectBand( void )
- {
- if(!g_bIsRunning) return;
- unsigned char selected_PCS1900;
- if(Band==BANDSEL_PCS1900)
- selected_PCS1900 = 1;
- else
- selected_PCS1900 = 0;
- META_RESULT MetaResult = META_Rf_SelectFrequencyBand1900_r( m_META_HANDLE_Obj.Get_MainHandle(), selected_PCS1900, ::CNF_SelectBand, &RFID_CR, NULL );
- if(MetaResult!=META_SUCCESS)
- { Confirm( METAAPP_FAIL ); return; }
- }
- //-------------------------------------
- void CRFCR::CNF_SelectBand( unsigned char cnf, short token, void *usrData )
- {
- if(!g_bIsRunning) return;
- if(cnf==false)
- { Confirm( METAAPP_FAIL ); return; }
- ActiveMan->SetActiveFunction( ::REQ_ContinueRX );
- }
- //---------------------------------------------------------------------------
- void CRFCR::REQ_ContinueRX( void )
- {
- if (!g_bIsRunning)
- {
- return;
- }
- if (NULL == RFReq_CR)
- {
- RFReq_CR = new RfCnRx_Req;
- }
- RFReq_CR->arfcn = m_sArfcn;
- RFReq_CR->gain = Gain;
- RFReq_CR->OnOff = OnOff;
- META_RESULT MetaResult = META_Rf_CONTINUE_RX_r( m_META_HANDLE_Obj.Get_MainHandle(), RFReq_CR, ::CNF_ContinueRX, &RFID_CR, NULL );
- if(MetaResult!=META_SUCCESS)
- { Confirm( METAAPP_FAIL ); return; }
- }
- //-------------------------------------
- void __stdcall CRFCR::CNF_ContinueRX( const unsigned char cnf, const short token, void *usrData)
- {
- if(!g_bIsRunning) return;
- if(cnf==false)
- { Confirm( METAAPP_FAIL ); return; }
- ActiveMan->SetActiveFunction( ::REQ_Finish );
- }
- //===========================================================================
- ///////////////////////// Global information //////////////////////////////
- //===========================================================================
- E_METAAPP_RESULT_T CRFCR::Get_ConfirmState(void)
- {
- return m_eConfirmState;
- }