//#include "meta2.h"
#include <IniFiles.hpp>
#include "form_RFTool.h"
#include "rf_apc.h"
#include "man_timer.h"
#include "man_fdm.h"
#include "man_active.h"
#include "misc.h"
#include "form_main.h" // for GSM 850
//===========================================================================
extern TfrmMainSel *frmMainSel; // for GSM 850
static CRFAPC* rf_apc_ptr;
//===========================================================================
static void REQ_ReadFromNVRAM( void )
{
rf_apc_ptr->REQ_ReadFromNVRAM( );
}
static void CNF_ReadFromNVRAM( void )
{
rf_apc_ptr->CNF_ReadFromNVRAM();
}
static void REQ_WriteToNVRAM( void )
{
rf_apc_ptr->REQ_WriteToNVRAM( );
}
static void CNF_WriteToNVRAM( void )
{
rf_apc_ptr->CNF_WriteToNVRAM( );
}
static void REQ_TimeOut( void )
{ rf_apc_ptr->REQ_TimeOut();
}
static void REQ_Finish( void )
{ rf_apc_ptr->REQ_Finish();
}
static void __stdcall CNF_RfSetRampApcLevl(const unsigned char cnf, const short token, void *usrData)
{ rf_apc_ptr->CNF_RfSetRampApcLevl(cnf, token, usrData);
}
//===========================================================================
CRFAPC::CRFAPC( void )
{
IsRunning = false;
ConfirmCallback = 0;
ApcBufSize = 0;
ApcBuf = 0;
}
//---------------------------------------------------------------------------
CRFAPC::~CRFAPC()
{
IsRunning = false;
ConfirmCallback = 0;
if(ApcBuf)
{
delete [] ApcBuf;
ApcBuf = NULL;
}
}
//---------------------------------------------------------------------------
void CRFAPC::REQ_Finish( void )
{
if(!IsRunning) return;
TimerMan->CounterStop();
Confirm( STATE_APC_OK );
IsRunning = false;
}
//---------------------------------------------------------------------------
void CRFAPC::REQ_Stop( void )
{
if(!IsRunning) return;
TimerMan->CounterStop();
NVRAMMan->REQ_Stop();
Confirm( STATE_APC_STOP );
IsRunning = false;
}
//---------------------------------------------------------------------------
void CRFAPC::REQ_TimeOut( void )
{
if(!IsRunning) return;
TimerMan->CounterStop();
NVRAMMan->REQ_Stop();
Confirm( STATE_APC_TIMEOUT );
IsRunning = false;
}
//---------------------------------------------------------------------------
void CRFAPC::Confirm( int confirm_state )
{
if(!IsRunning) return;
if(ConfirmCallback==0) return;
ConfirmState = confirm_state;
ActiveMan->SetActiveFunction( ConfirmCallback );
}
//===========================================================================
static int NVRAM_APC_LOWEST_POWER[] =
{ 5, 0, 0, 5 };
static char NVRAM_RAMPNAME[][32] =
{
"L1_RAMPTABLE_GSM900",
"L1_RAMPTABLE_DCS1800",
"L1_RAMPTABLE_PCS1900",
"L1_RAMPTABLE_GSM850",
};
void CRFAPC::REQ_Read_From_NVRAM( void )
{
rf_apc_ptr = this;
IsRunning = true;
CurWRBand = BANDSEL_GSM900;
ActiveMan->SetActiveFunction( ::REQ_ReadFromNVRAM );
}
//-------------------------------------
void CRFAPC::REQ_ReadFromNVRAM( void )
{ int band = CurWRBand;
if(!IsRunning) return;
if(ApcBuf==0)
{
MetaResult = META_NVRAM_rampTable_Len( &ApcBufSize );
if(MetaResult!=META_SUCCESS)
{ Confirm( STATE_APC_FAIL ); return; }
ApcBuf = new char[ApcBufSize];
}
NVRAMMan->ConfirmCallback = ::CNF_ReadFromNVRAM;
switch(band)
{
case BANDSEL_GSM850:
NVRAMMan->REQ_ReadNVRAM_Start( "NVRAM_EF_L1_RAMPTABLE_GSM850_LID",
1, // only 1 record
ApcBufSize,
ApcBuf );
break;
case BANDSEL_GSM900:
NVRAMMan->REQ_ReadNVRAM_Start( "NVRAM_EF_L1_RAMPTABLE_GSM900_LID",
1, // only 1 record
ApcBufSize,
ApcBuf );
break;
case BANDSEL_DCS1800:
NVRAMMan->REQ_ReadNVRAM_Start( "NVRAM_EF_L1_RAMPTABLE_DCS1800_LID",
1, // only 1 record
ApcBufSize,
ApcBuf );
break;
case BANDSEL_PCS1900:
NVRAMMan->REQ_ReadNVRAM_Start( "NVRAM_EF_L1_RAMPTABLE_PCS1900_LID",
1, // only 1 record
ApcBufSize,
ApcBuf );
break;
}
}
//-------------------------------------
void CRFAPC::CNF_ReadFromNVRAM( void )
{
int band = CurWRBand;
if(!IsRunning) return;
int state = NVRAMMan->ConfirmState;
if(state==STATE_NVRAM_OK)
{ int i;
int idata;
MetaResult = META_NVRAM_Decompose_rampTable( &ApcProfile[band],
ApcBuf,
ApcBufSize );
if(MetaResult!=META_SUCCESS)
{ Confirm( STATE_APC_FAIL ); return; }
ApcDcOffset = (ApcProfile[band].rampData.lowest_power>>8);
ApcProfile[band].rampData.lowest_power &=0x0FF;
for( i=0; i<12; i++ )
{
idata = ApcProfile[band].rampData.arfcn_weight[i].mid_level;
ApcProfile[band].rampData.arfcn_weight[i].mid_level = POWER2PCL(band, idata);
if(ApcProfile[band].rampData.arfcn_weight[i].max_arfcn==32767)
{ ApcProfile[band].rampData.arfcn_weight[i].max_arfcn = -1; }
}
if(frmMainSel->cbGSM850->Checked == false)
{
if(band==BANDSEL_GSM900)
{
ApcProfile[band].rampData.power[15] = ApcProfile[band].rampData.power[14];
}
}
else
{
if(band==BANDSEL_GSM900 || band==BANDSEL_GSM850)
{
ApcProfile[band].rampData.power[15] = ApcProfile[band].rampData.power[14];
}
}
if(frmMainSel->cbGSM850->Checked == false)
{
if(band==BANDSEL_PCS1900)
{ ActiveMan->SetActiveFunction( ::REQ_Finish );
}
else
{ CurWRBand++;
ActiveMan->SetActiveFunction( ::REQ_ReadFromNVRAM );
}
}
else
{
if(band==BANDSEL_GSM850)
{ ActiveMan->SetActiveFunction( ::REQ_Finish );
}
else
{ CurWRBand++;
ActiveMan->SetActiveFunction( ::REQ_ReadFromNVRAM );
}
}
}
else if(state==STATE_NVRAM_TIMEOUT)
{ Confirm( STATE_APC_TIMEOUT );
}
else if(state==STATE_NVRAM_STOP)
{ Confirm( STATE_APC_STOP );
}
else
{ Confirm( STATE_APC_FAIL );
}
}
//===========================================================================
void CRFAPC::REQ_Write_To_NVRAM( void )
{
rf_apc_ptr = this;
IsRunning = true;
IsSingleBand = false;
CurWRBand = BANDSEL_GSM900;
ActiveMan->SetActiveFunction( ::REQ_WriteToNVRAM );
}
//-------------------------------------
void CRFAPC::REQ_Write_To_NVRAM_Single_Band( int band )
{
rf_apc_ptr = this;
IsRunning = true;
IsSingleBand = true;
CurWRBand = band;
ActiveMan->SetActiveFunction( ::REQ_WriteToNVRAM );
}
//-------------------------------------
void CRFAPC::REQ_WriteToNVRAM( void )
{ int i;
int idata;
int band = CurWRBand;
if(!IsRunning) return;
if(ApcBuf==0)
{
MetaResult = META_NVRAM_rampTable_Len( &ApcBufSize );
if(MetaResult!=META_SUCCESS)
{ Confirm( STATE_APC_FAIL ); return; }
ApcBuf = new char[ApcBufSize];
}
if(band==BANDSEL_GSM900 || band==BANDSEL_GSM850)
{
ApcProfile[band].rampData.power[15] = ApcProfile[band].rampData.power[14];
}
ApcProfile[band].rampD
MTK_RF.rar_mtk_mtk 源码_rf
版权申诉
182 浏览量
2022-09-24
13:51:56
上传
评论
收藏 46KB RAR 举报
刘良运
- 粉丝: 68
- 资源: 1万+
评论0