rf_MultiSlotTx_run.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:15k
- /*****************************************************************************
- * 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_MultiSlotTx_run.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * RF multi slot runtime 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!!
- *============================================================================
- ****************************************************************************/
- #pragma hdrstop
- #include "meta.h"
- #ifndef _RF_MOD_H_
- #include "rf_mod.h"
- #endif
- #ifndef _FORM_RFTOOL_H_
- #include "form_RFTool.h"
- #endif
- #ifndef _RF_MULTISLOTTX_RUN_H_
- #include "rf_MultiSlotTx_run.h"
- #endif
- #include "man_timer.h"
- #include "man_active.h"
- //===========================================================================
- static CRFMULTISLOTTXRUN* rf_multi_slot_tx_run_ptr;
- static bool g_bIsRunning;
- //===========================================================================
- static void REQ_SelectBand( void )
- { rf_multi_slot_tx_run_ptr->REQ_SelectBand( );
- }
- //---------------------------------------------------------------------------
- static void __stdcall CNF_SelectBand( const unsigned char cnf, const short token, void *usrData )
- {
- rf_multi_slot_tx_run_ptr->CNF_SelectBand( cnf, token, usrData );
- }
- //---------------------------------------------------------------------------
- static void REQ_BBTXCfg2( void )
- { rf_multi_slot_tx_run_ptr->REQ_BBTXCfg2( );
- }
- //---------------------------------------------------------------------------
- static void REQ_BBTXCfg3( void )
- { rf_multi_slot_tx_run_ptr->REQ_BBTXCfg3( );
- }
- //---------------------------------------------------------------------------
- static void REQ_MultiSlotTx( void )
- { rf_multi_slot_tx_run_ptr->REQ_MultiSlotTx( );
- }
- //---------------------------------------------------------------------------
- static void __stdcall CNF_MultiSlotTx(const unsigned char cnf, const short token, void *usrData)
- {
- rf_multi_slot_tx_run_ptr->CNF_MultiSlotTx( cnf, token, usrData );
- }
- //---------------------------------------------------------------------------
- static void REQ_TimeOut( void )
- { rf_multi_slot_tx_run_ptr->REQ_TimeOut();
- }
- //---------------------------------------------------------------------------
- static void REQ_Finish( void )
- { rf_multi_slot_tx_run_ptr->REQ_Finish();
- }
- //===========================================================================
- CRFMULTISLOTTXRUN::CRFMULTISLOTTXRUN( void )
- {
- g_bIsRunning = false;
- ConfirmCallback = 0;
- RFReq_BBTXCFG2 = NULL;
- RFReq_MultiSlotTx = NULL;
- RFReq_EPSK_MultiSlotTx = NULL;
- isFirstReq = true;
- }
- //---------------------------------------------------------------------------
- CRFMULTISLOTTXRUN::~CRFMULTISLOTTXRUN( )
- {
- g_bIsRunning = false;
- ConfirmCallback = 0;
- if( RFReq_BBTXCFG2 != NULL )
- {
- delete RFReq_BBTXCFG2;
- RFReq_BBTXCFG2 = NULL;
- }
- if( RFCnf_BBTXCFG2 != NULL )
- {
- delete RFCnf_BBTXCFG2;
- RFCnf_BBTXCFG2 = NULL;
- }
- if( RFReq_BBTXCFG3 != NULL )
- {
- delete RFReq_BBTXCFG3;
- RFReq_BBTXCFG3 = NULL;
- }
- if( RFCnf_BBTXCFG3 != NULL )
- {
- delete RFCnf_BBTXCFG3;
- RFCnf_BBTXCFG3 = NULL;
- }
- if( RFReq_MultiSlotTx != NULL)
- {
- delete RFReq_MultiSlotTx;
- RFReq_MultiSlotTx = NULL;
- }
- if( RFReq_EPSK_MultiSlotTx != NULL )
- {
- delete RFReq_EPSK_MultiSlotTx;
- RFReq_EPSK_MultiSlotTx = NULL;
- }
- }
- //---------------------------------------------------------------------------
- void CRFMULTISLOTTXRUN::REQ_Finish( void )
- {
- if(!g_bIsRunning) return;
- Confirm(METAAPP_SUCCESS);
- g_bIsRunning = false;
- }
- //---------------------------------------------------------------------------
- void CRFMULTISLOTTXRUN::REQ_Stop( void )
- {
- if(!g_bIsRunning) return;
- META_Cancel_r( m_META_HANDLE_Obj.Get_MainHandle(), RFID_MULTISLOTTX );
- Confirm( METAAPP_STOP );
- g_bIsRunning = false;
- }
- //---------------------------------------------------------------------------
- void CRFMULTISLOTTXRUN::REQ_TimeOut( void )
- {
- if(!g_bIsRunning) return;
- META_Cancel_r( m_META_HANDLE_Obj.Get_MainHandle(), RFID_MULTISLOTTX );
- Confirm( METAAPP_TIMEOUT );
- g_bIsRunning = false;
- }
- //---------------------------------------------------------------------------
- void CRFMULTISLOTTXRUN::Confirm( int confirm_state )
- {
- if(!g_bIsRunning) return;
- if(ConfirmCallback==0) return;
- ConfirmState = confirm_state;
- ActiveMan->SetActiveFunction( ConfirmCallback );
- }
- //===========================================================================
- void CRFMULTISLOTTXRUN::REQ_Start( int band, int arfcn, int tsc, int *cs, int *pcl,
- int frames, int afc_dac, char TimeSlotMask_par,
- int ta, bool isEDGEsupport, int pattern, unsigned short pattern_data,
- char tx_trim_i, char tx_trim_q, char tx_offset_i,
- char tx_offset_q, char tx_cal_bias, char tx_iq_swap,
- char tx_cmv, char tx_gain, char tx_calrcsel, char tx_phasesel, bool bb_tx_cfg3_support )
- {
- rf_multi_slot_tx_run_ptr = this;
- g_bIsRunning = true;
- Band = band;
- Arfcn = arfcn;
- TSC = tsc;
- int i;
- for(i=0; i<4; i++)
- {
- CS[i] = *(cs+i);
- PCL[i] = *(pcl+i);
- }
- Frames = frames;
- AFCDac = afc_dac;
- TimeSlotMask = TimeSlotMask_par;
- TA = ta;
- IsEDGESupport = isEDGEsupport;
- Pattern = pattern;
- PatternData = pattern_data;
- TxTrimI = tx_trim_i;
- TxTrimQ = tx_trim_q;
- TxOffsetI = tx_offset_i;
- TxOffsetQ = tx_offset_q;
- TxCalbias = tx_cal_bias;
- TxIQSwap = tx_iq_swap;
- TxCMV = tx_cmv;
- TxGain = tx_gain;
- TxCalrcsel = tx_calrcsel;
- TxPhasesel = tx_phasesel;
- BBTXCfg3Support = bb_tx_cfg3_support;
- ActiveMan->SetActiveFunction( ::REQ_SelectBand );
- }
- //---------------------------------------------------------------------------
- void CRFMULTISLOTTXRUN::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, &RFID_MULTISLOTTX, NULL );
- if(MetaResult!=META_SUCCESS)
- { Confirm( METAAPP_FAIL ); return; }
- }
- //-------------------------------------
- void __stdcall CRFMULTISLOTTXRUN::CNF_SelectBand( const unsigned char cnf, const short token, void *usrData )
- {
- if(!g_bIsRunning) return;
- if(cnf==false)
- { Confirm( METAAPP_FAIL ); return; }
- if((TxTrimI==-99)&&(TxTrimQ==-99))
- { ActiveMan->SetActiveFunction( ::REQ_MultiSlotTx );
- }
- else
- {
- if( ! BBTXCfg3Support )
- {
- ActiveMan->SetActiveFunction( ::REQ_BBTXCfg2 );
- }
- else
- {
- ActiveMan->SetActiveFunction( ::REQ_BBTXCfg3 );
- }
- }
- }
- //---------------------------------------------------------------------------
- void CRFMULTISLOTTXRUN::REQ_BBTXCfg2( void )
- {
- if(!g_bIsRunning) return;
- if( RFReq_BBTXCFG2 == NULL )
- {
- RFReq_BBTXCFG2 = new RfBBTXCfg2;
- }
- RFReq_BBTXCFG2->TxTrimI = TxTrimI;
- RFReq_BBTXCFG2->TxTrimQ = TxTrimQ;
- RFReq_BBTXCFG2->TxOffsetI = TxOffsetI;
- RFReq_BBTXCFG2->TxOffsetQ = TxOffsetQ;
- RFReq_BBTXCFG2->TxCalbias = TxCalbias;
- RFReq_BBTXCFG2->TxIQSwap = TxIQSwap;
- RFReq_BBTXCFG2->TxCMV = TxCMV;
- RFReq_BBTXCFG2->TxGain = TxGain;
- RFReq_BBTXCFG2->TxCalrcsel = TxCalrcsel;
- META_RESULT MetaResult = META_Rf_SetBBTxCfg2_r( m_META_HANDLE_Obj.Get_MainHandle(), 500, RFReq_BBTXCFG2, RFCnf_BBTXCFG2);
- if(MetaResult!=META_SUCCESS)
- {
- if( MetaResult!=META_TIMEOUT )
- { Confirm( STATE_MULTI_SLOT_TX_RUN_FAIL ); return; }
- else
- { Confirm( STATE_MULTI_SLOT_TX_RUN_TIMEOUT ); return; }
- }
- ActiveMan->SetActiveFunction( ::REQ_MultiSlotTx );
- }
- //---------------------------------------------------------------------------
- void CRFMULTISLOTTXRUN::REQ_BBTXCfg3( void )
- {
- if(!g_bIsRunning) return;
- if( RFReq_BBTXCFG3 == NULL )
- {
- RFReq_BBTXCFG3 = new RfBBTXCfg3;
- }
- RFReq_BBTXCFG3->TxTrimI = TxTrimI;
- RFReq_BBTXCFG3->TxTrimQ = TxTrimQ;
- RFReq_BBTXCFG3->TxOffsetI = TxOffsetI;
- RFReq_BBTXCFG3->TxOffsetQ = TxOffsetQ;
- RFReq_BBTXCFG3->TxCalbias = TxCalbias;
- RFReq_BBTXCFG3->TxIQSwap = TxIQSwap;
- RFReq_BBTXCFG3->TxCMV = TxCMV;
- RFReq_BBTXCFG3->TxGain = TxGain;
- RFReq_BBTXCFG3->TxCalrcsel = TxCalrcsel;
- RFReq_BBTXCFG3->TxPhasesel = TxPhasesel;
- META_RESULT MetaResult = META_Rf_SetBBTxCfg3_r( m_META_HANDLE_Obj.Get_MainHandle(), 500, RFReq_BBTXCFG3, RFCnf_BBTXCFG3);
- if(MetaResult!=META_SUCCESS)
- {
- if( MetaResult!=META_TIMEOUT )
- { Confirm( STATE_MULTI_SLOT_TX_RUN_FAIL ); return; }
- else
- { Confirm( STATE_MULTI_SLOT_TX_RUN_TIMEOUT ); return; }
- }
- ActiveMan->SetActiveFunction( ::REQ_MultiSlotTx );
- }
- //---------------------------------------------------------------------------
- void CRFMULTISLOTTXRUN::REQ_MultiSlotTx( void )
- {
- if(!g_bIsRunning) return;
- int i;
- if( isFirstReq )
- {
- if( META_QueryIfFunctionSupportedByTarget_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, "META_Rf_MultiSlot_TX_Ex") == META_SUCCESS )
- {
- isMultiSlot_TX_ExSupport = true;
- }
- else
- {
- isMultiSlot_TX_ExSupport = false;
- }
- isFirstReq = false;
- }
- if( isMultiSlot_TX_ExSupport )
- {
- if(RFReq_EPSK_MultiSlotTx == NULL)
- {
- RFReq_EPSK_MultiSlotTx = new Rf_MultiSlotTXEx_Req;
- }
- RFReq_EPSK_MultiSlotTx->arfcn = Arfcn;
- RFReq_EPSK_MultiSlotTx->bsic = TSC;
- RFReq_EPSK_MultiSlotTx->timeSlotmask = TimeSlotMask;
- for(i=0; i<MAX_SUPPORT_TIMESLOT_NUM; i++)
- {
- RFReq_EPSK_MultiSlotTx->powerLev[i] = PCL[i];
- RFReq_EPSK_MultiSlotTx->cs[i]=CS[i];
- }
- RFReq_EPSK_MultiSlotTx->ta = TA;
- RFReq_EPSK_MultiSlotTx->frames = Frames;
- RFReq_EPSK_MultiSlotTx->dacValue = AFCDac;
- RFReq_EPSK_MultiSlotTx->pattern = Pattern;
- RFReq_EPSK_MultiSlotTx->pattern_data = PatternData;
- META_RESULT MetaResult = META_Rf_MultiSlot_TX_Ex_r( m_META_HANDLE_Obj.Get_MainHandle(), 500, RFReq_EPSK_MultiSlotTx);
- if(MetaResult!=META_SUCCESS)
- {
- if( MetaResult!=META_TIMEOUT )
- { Confirm( METAAPP_FAIL ); return; }
- else
- { Confirm( METAAPP_TIMEOUT ); return; }
- }
- ActiveMan->SetActiveFunction( ::REQ_Finish );
- }
- else
- {
- if(RFReq_MultiSlotTx == NULL)
- {
- RFReq_MultiSlotTx = new RfMultiSlotTX_Req;
- }
- RFReq_MultiSlotTx->arfcn = Arfcn;
- RFReq_MultiSlotTx->bsic = TSC;
- RFReq_MultiSlotTx->timeSlotmask = TimeSlotMask;
- for(i=0; i<MAX_SUPPORT_TIMESLOT_NUM; i++)
- {
- RFReq_MultiSlotTx->cs[i] = CS[i];
- RFReq_MultiSlotTx->powerLev[i] = PCL[i];
- }
- RFReq_MultiSlotTx->frames = Frames;
- RFReq_MultiSlotTx->dacValue = AFCDac;
- RFReq_MultiSlotTx->ta = TA;
- META_RESULT MetaResult = META_Rf_MultiSlot_TX_r(m_META_HANDLE_Obj.Get_MainHandle(), RFReq_MultiSlotTx, ::CNF_MultiSlotTx, &RFID_MULTISLOTTX, NULL);
- if(MetaResult!=META_SUCCESS)
- { Confirm( METAAPP_FAIL ); return; }
- }
- }
- //-------------------------------------
- void __stdcall CRFMULTISLOTTXRUN::CNF_MultiSlotTx(const unsigned char cnf, const short token, void *usrData)
- {
- if(!g_bIsRunning) return;
- if(cnf==false)
- { Confirm( METAAPP_FAIL ); return; }
- ActiveMan->SetActiveFunction( ::REQ_Finish );
- }