⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rf_cr.~cpp

📁 关于MTK 的MATA开发工具的RF源码
💻 ~CPP
字号:
//#include "meta2.h"
#include <IniFiles.hpp>

#include "form_RFTool.h"
#include "man_timer.h"
#include "man_active.h"
#include "man_fdm.h"
#include "rf_cr.h"

//===========================================================================

static CRFCR*  rf_cr_ptr;

//===========================================================================

static void  REQ_SelectBand( void )
{  rf_cr_ptr->REQ_SelectBand( );
}
//static void  CNF_SelectBand( BOOL cnf )
//static void  CNF_SelectBand( BOOL cnf, short token, void *usrData )
static void __stdcall CNF_SelectBand( const unsigned char cnf, const short token, void *usrData )
{ // rf_cr_ptr->CNF_SelectBand( cnf );
   rf_cr_ptr->CNF_SelectBand( cnf, token, usrData );
}
static void  REQ_ContinueRX( void )
{  rf_cr_ptr->REQ_ContinueRX( );
}
//static void  CNF_ContinueRX( BOOL cnf )
//static void  CNF_ContinueRX(BOOL cnf, short token, void *usrData)
static void __stdcall CNF_ContinueRX(const unsigned char cnf, const short token, void *usrData)
{  //rf_cr_ptr->CNF_ContinueRX( cnf );
   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 )
{
   IsRunning = false;
   ConfirmCallback = 0;
   RFReq_CR = NULL;
}
//---------------------------------------------------------------------------

CRFCR::~CRFCR()
{
   IsRunning = false;
   ConfirmCallback = 0;
   if( RFReq_CR != NULL )
   {
     delete RFReq_CR;
     RFReq_CR = NULL;
   }
}
//---------------------------------------------------------------------------

void  CRFCR::REQ_Finish( void )
{
   if(!IsRunning)  return;

   TimerMan->CounterStop();
   Confirm( STATE_CR_OK );
   IsRunning = false;
}
//---------------------------------------------------------------------------

void  CRFCR::REQ_Stop( void )
{
   if(!IsRunning)  return;

   TimerMan->CounterStop();
   META_Cancel( RFID_CR );
   Confirm( STATE_CR_STOP );
   IsRunning = false;
}
//---------------------------------------------------------------------------

void  CRFCR::REQ_TimeOut( void )
{
   if(!IsRunning)  return;

   TimerMan->CounterStop();
   META_Cancel( RFID_CR );
   Confirm( STATE_CR_TIMEOUT );
   IsRunning = false;
}
//---------------------------------------------------------------------------

void  CRFCR::Confirm( int confirm_state )
{
   if(!IsRunning)  return;

   if(ConfirmCallback==0)  return;
   ConfirmState = confirm_state;
   ActiveMan->SetActiveFunction( ConfirmCallback );
}
//===========================================================================

void  CRFCR::REQ_Start( int band, int arfcn, int gain, int on_off )
{
    rf_cr_ptr = this;
    IsRunning = true;

     Band = band;
    Arfcn = arfcn;
     Gain = gain;
    OnOff = on_off;

   TimerMan->CounterStart( 1000, ::REQ_TimeOut );
   ActiveMan->SetActiveFunction( ::REQ_SelectBand );
}
//---------------------------------------------------------------------------

void  CRFCR::REQ_SelectBand( void )
{
   if(!IsRunning)  return;


   unsigned char selected_PCS1900;
   if(Band==BANDSEL_PCS1900)
      selected_PCS1900 = 1;
   else
     selected_PCS1900 = 0;
   MetaResult = META_Rf_SelectFrequencyBand1900(  selected_PCS1900, ::CNF_SelectBand, &RFID_CR, NULL );

   if(MetaResult!=META_SUCCESS)
   {  Confirm( STATE_CR_FAIL );  return;  }
}
//-------------------------------------
void  CRFCR::CNF_SelectBand( unsigned char cnf, short token, void *usrData )
{
   if(!IsRunning)  return;

   if(cnf==false)
   {  Confirm( STATE_CR_FAIL );  return;  }

   ActiveMan->SetActiveFunction( ::REQ_ContinueRX );
}
//---------------------------------------------------------------------------

void  CRFCR::REQ_ContinueRX( void )
{
   if(!IsRunning)  return;

   if( RFReq_CR == NULL )
   {
      RFReq_CR = new RfCnRx_Req;
   }
   RFReq_CR->arfcn = Arfcn;
   RFReq_CR->gain  = Gain;
   RFReq_CR->OnOff = OnOff;


   MetaResult = META_Rf_CONTINUE_RX( RFReq_CR, ::CNF_ContinueRX, &RFID_CR, NULL );

   
   if(MetaResult!=META_SUCCESS)
   {  Confirm( STATE_CR_FAIL );  return;  }
}
//-------------------------------------

void __stdcall CRFCR::CNF_ContinueRX( const unsigned char cnf, const short token, void *usrData)
{
   if(!IsRunning)  return;

   if(cnf==false)
   {  Confirm( STATE_CR_FAIL );  return;  }

   ActiveMan->SetActiveFunction( ::REQ_Finish );
}
//===========================================================================

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -