📄 ctcaldat.c
字号:
}
/* FFR/031126: END of SETAFCDAC modification */
#if defined (AERO_PLUS)
/*---------------------------------------------------------------------*/
/*
Name: CTShowTX_DXCOVal
Desc: Shows the currently used value for use in the TX_DXCO
Params:
Returns:
Caveats:
*/
static void CTShowTX_DXCOVal( void )
{
INT8 *s1 = GSM_NEW_ARRAY( INT8, 300 );
INT8 *ctout = s1;
ctout += GSMsprintf( ctout, "ShowTXDXCO:RET:" );
GSMsprintf( ctout, "%d\n", CalDataPtr->TX_DXCO );
CTSendStringResponse( s1 );
GSMFree( s1 );
}
/*---------------------------------------------------------------------*/
/*
Name: CTSetTX_DXCOVal
Desc: Set up a new value for use in the TX_DXCO
Params:
Returns:
Caveats:
*/
static void CTSetTX_DXCOVal( void )
{
INT8 *s1 = GSM_NEW_ARRAY( INT8, 300 );
INT8 *ctout = s1;
CalDataPtr->TX_DXCO = CTTX_DXCOValue;
GSMsprintf( ctout, "SetTXDXCOVal:DONE\n" );
CTSendStringResponse( s1 );
GSMFree( s1 );
}
#endif
/* ----------------------------------------------------------------------- */
/*
Name: ServiceListingToPort
Desc: Callback for putting cal data details out to trace port on a timer
Params:
Returns:
Caveats:
*/
static void ServiceListingToPort( void *dummy )
{
INT8 *ctout,
*s1;
UINT32 numberBytesThisTime,
dwTickPeriod = 200;
UNUSED( dummy );
numberBytesThisTime = ( UINT32 ) ( theFullReply[currentReply + 1] )
- ( UINT32 ) ( theFullReply[currentReply] );
#if defined (IO_TRACER)
dwTickPeriod = ( numberBytesThisTime * CTTXBITSPERCHAR / IOTRGetBaudrate( ) * 1000 /* mSec */ );
if ( dwTickPeriod < 50 )
dwTickPeriod = 50; /* Wait at least a few frames so not to overlaod the
system.. */
#endif
s1 = GSM_NEW_ARRAY( INT8, numberBytesThisTime + 1 );
ctout = s1;
GSMstrncpy( ctout, theFullReply[currentReply], numberBytesThisTime );
ctout += numberBytesThisTime;
*ctout = 0;
CTSendStringResponse( s1 );
/* Now if there's still more, arrange to send out next chunk later */
currentReply++;
if ( theFullReply[currentReply] && *( theFullReply[currentReply] ) )
{
GSMStartTimer( CT_MISC_TIMER, MSECS( ( INT32 ) dwTickPeriod ), ServiceListingToPort, NULL );
}
else
{
/* We must be at the end of the big buffer. Need to free it now. */
GSMFree( theFullReply[0] );
}
GSMFree( s1 );
}
/* ----------------------------------------------------------------------- */
/*
Name: CTSetUpAFullListing
Desc: Prepare strings describing the contents of the passed calibration data
structure in the ptr array theFullReply and start off the pumping out of
these strings sequentially to the serial output (using a timer)
Params:
Returns:
Caveats:
*/
static void CTSetUpAFullListing( CALIBRATION_DATA * listingPtr, INT8 * firstLine )
{
INT8 *ctout;
UINT8 *Table;
UINT16 i,
j;
UINT16 *pRamp,
wRXCalDataOffset;
UINT8 tempGLIMEISV[8],
bBand,
bFirstPCL,
bLastPCL;
#if defined( BRITE4_RF )
UINT16 wBand,
wGain,
wSubband;
#endif
currentReply = 0;
ctout = GSM_NEW_ARRAY( INT8, ( GSM_SIZE_T ) ( BufSize ) );
theFullReply[0] = ctout;
currentReply++;
ctout += GSMsprintf( ctout, firstLine );
if ( !bListDCROffsetsOnly )
{
/* VERSION */
theFullReply[currentReply++] = ctout;
ctout += GSMsprintf( ctout, "Cal Data Version" );
for ( i = 0; i < 10; i++ )
{
ctout += GSMsprintf( ctout, ",%u", ( UINT8 ) listingPtr->Version[i] );
}
ctout += GSMsprintf( ctout, "\n" );
/* TX RAMP DATA */
pRamp = ( UINT16 * ) & ( listingPtr->PowerRampTablesBand0[0][0] );
for ( bBand = 0; bBand < CalibrationBandInfo.bActiveBands; bBand++ )
{
bFirstPCL = CalibrationBandInfo.bFirstPCLInBand[bBand];
bLastPCL = bFirstPCL + CalibrationBandInfo.bRampsInBand[bBand];
for ( j = bFirstPCL; j < bLastPCL; j++ )
{
theFullReply[currentReply++] = ctout;
ctout += GSMsprintf( ctout, "Band %u power level %d ramp & adjust values\n", bBand, j );
for ( i = 0; i < SIZE_OF_GSM_RAMP; i++ )
ctout += GSMsprintf( ctout, ",%u", *pRamp++ );
ctout += GSMsprintf( ctout, "\n" );
}
}
/* RX GAIN DATA */
theFullReply[currentReply++] = ctout;
ctout += GSMsprintf( ctout, "RX Baseband Gain Cal Table:\n" );
Table = &( listingPtr->Hw_Rf_Gain_Cal_Table[RX_BB_TABLE_POS] );
for ( i = 0; i < RX_BB_TABLE_SIZE; i++ )
{
ctout += GSMsprintf( ctout, ", %u", Table[i] );
}
ctout += GSMsprintf( ctout, "\n" );
for ( bBand = 0; bBand < CalibrationBandInfo.bActiveBands; bBand++ )
{
wRXCalDataOffset = ( RX_BB_TABLE_SIZE + ( bBand * RX_BAND_TABLE_SIZE ) );
theFullReply[currentReply++] = ctout;
ctout += GSMsprintf( ctout, "Band %u Gain Cal Table:\n", bBand );
for ( i = wRXCalDataOffset; i < wRXCalDataOffset + RX_BAND_TABLE_SIZE; i++ )
{
ctout += GSMsprintf( ctout, ", %u", Table[i] );
}
ctout += GSMsprintf( ctout, "\n" );
}
/* The AFCDACStartValue - section */
theFullReply[currentReply++] = ctout;
ctout += GSMsprintf( ctout, "AFC DAC start value, %d\n", listingPtr->AFCDACStartValue );
/* The IMEI - section: Descramble it in a temp buffer before showing! */
GSMmemcpy( tempGLIMEISV, listingPtr->GLIMEISV, 8 );
UHNVMDecodeIMEI( tempGLIMEISV );
theFullReply[currentReply++] = ctout;
ctout += GSMsprintf( ctout, "IMEI" );
for ( i = 0; i < 8; i++ )
{
ctout += GSMsprintf( ctout, ",%x", ( UINT8 ) tempGLIMEISV[i] );
}
ctout += GSMsprintf( ctout, "\n" );
theFullReply[currentReply++] = ctout;
ctout += GSMsprintf( ctout, "PTEBootSeq, %u", listingPtr->PTEBootSeq );
/* e.g. Vbatt measurement offset... */
theFullReply[currentReply++] = ctout;
ctout += GSMsprintf( ctout, "ADCcal:\n" );
for ( i = 0; i < ADC_CAL_CHANNELS; i++ )
{
ctout += GSMsprintf( ctout, "Chan %u, High Offset = %d", i, listingPtr->ADCcal[0][i] );
ctout += GSMsprintf( ctout, ", Chan %u, Low Offset = %d\n", i, listingPtr->ADCcal[1][i] );
}
}
/* Brite 4 RF DCR offsets */
#if defined( BRITE4_RF )
theFullReply[currentReply++] = ctout;
for ( wBand = 0; wBand < NO_RF_BANDS; wBand++ )
{
for ( wGain = 0; wGain < DCROFFS_GAIN_SETTINGS; wGain++ )
{
ctout += GSMsprintf( ctout, "DCROffset (Dec) Band %u, Gain %u = ", wBand, wGain );
for ( wSubband = 0; wSubband < DCROFFS_SUBBANDS; wSubband++ )
{
ctout += GSMsprintf( ctout, "(%u,%u) ", listingPtr->DCRRXOffset[wBand][wGain][wSubband][0], listingPtr->DCRRXOffset[wBand][wGain][wSubband][1] );
}
ctout += GSMsprintf( ctout, "\n" );
theFullReply[currentReply++] = ctout;
}
}
#endif
theFullReply[currentReply] = ctout;
*( theFullReply[currentReply] ) = '\0';
currentReply = 0;
/*
Now, start off a timer for pumping this data out at the serial port, not too fast
but also not too slow
*/
GSMStartTimer( CT_MISC_TIMER, MSECS( 200 ), ServiceListingToPort, NULL );
}
/*---------------------------------------------------------------------*/
/*
Name: CTForceHWNVMValid
Desc: Force a correct checksum into NVM HW area
Params: -
Returns: -
Caveats:
*/
#if !defined(FFS)
static void CTForceHWNVMValid( void )
{
INT8 *s1 = GSM_NEW_ARRAY( INT8, 300 );
INT8 *ctout = s1;
GSMsprintf( ctout, "ForceNVMGood:DONE\n" );
HWNVMForceValid( );
CTSendStringResponse( s1 );
GSMFree( s1 );
}
#endif
/*---------------------------------------------------------------------*/
/*
Name: CTForceHWNVMInvalid
Desc: Force an incorrect checksum into NVM HW area
Params: -
Returns: -
Caveats:
For test purposes only!
*/
#if !defined(FFS)
static void CTForceHWNVMInvalid( void )
{
INT8 *s1 = GSM_NEW_ARRAY( INT8, 300 );
INT8 *ctout = s1;
GSMsprintf( ctout, "ForceNVMBad:DONE\n" );
HWNVMForceInvalid( );
CTSendStringResponse( s1 );
GSMFree( s1 );
}
#endif
/* ----------------------------------------------------------------------- */
/*
Name: CTListCalibrationData
Desc: Initiate the process of showing the entire calibration data structure
as currently present in RAM (i.e. CalDataPtr structure).
Params: -
Returns: -
Caveats:
*/
static void CTListCalibrationData( void )
{
bListDCROffsetsOnly = FALSE;
BufSize = COMPLETE_CAL_REPORT_BUF_SIZE;
CTSetUpAFullListing( ( CALIBRATION_DATA * ) CalDataPtr, "ListCalData:RET:\n" );
}
/*---------------------------------------------------------------------*/
/*
Name: CTShowDefaultCalContents
Desc: List out the contents of the default calibration data even if
we're not currently using it
Params: -
Returns: -
Caveats:
*/
static void CTShowDefaultCalContents( void )
{
bListDCROffsetsOnly = FALSE;
BufSize = COMPLETE_CAL_REPORT_BUF_SIZE;
CTSetUpAFullListing( ( CALIBRATION_DATA * ) & DefaultCalibrationData, "ListDefCalData:RET:\n" );
}
/*---------------------------- Global Functions: --------------------------*/
/*------------------------------------------------------------------------*/
/*
Name: CTCalDataInit
Desc: Returns the pointer to the CTCalDataTable table.
Params:
Returns:
Caveats:
*/
CTItem *CTCalDataInit( void )
{
return ( CTCalDataTable );
}
/* ----------------------------------------------------------------------- */
/*
Name: CheckHWOK
Desc:
Params:
Returns:
Caveats:
*/
static void CTQueryCalChecksum( void )
{
if ( IsCalibrationDataOk( ) )
CTSendStringResponse( "CheckCalDataOK:RET:1\n" );
else
CTSendStringResponse( "CheckCalDataOK:RET:0\n" );
}
/* MZO: Intermediate Function DumpDSP */
/*---------------------------------------------------------------------*/
/*
Name: CTDumpDSP
Desc: Force an incorrect checksum into NVM HW area
Params: -
Returns: -
Caveats:
For test purposes only!
*/
static void CTDumpDSP( void )
{
GSMExit( GSMEXIT_CT_FORCE_EXIT );
}
/* ----------------------------------------------------------------------- */
/*
Name: CTStoreCalData
Desc: Stores the calibration data into flash sector 0
Params:
Returns:
Caveats:
*/
static void CTStoreCalData( void )
{
if ( HWNVMStoreCalData( ) )
{
CTSendStringResponse( "StoreCalData:DONE\n" );
CTDeallocateRAMCalData( );
}
else
CTSendStringResponse( "StoreCalData:FAILED\n" );
}
/*---------------------------------------------------------------------*/
/*
Name: CTAllocateRAMCalData
Desc: Allocates a RAM copy of the calibration data structure for PTE work. Called internally
so there is no Tracer response.
Params: None
Returns: None
Caveats:
*/
void CTAllocateRAMCalData( void )
{
HWCalibrationData = ( CALIBRATION_DATA * ) GSMMalloc( sizeof( CALIBRATION_DATA ) ); /* Allocte RAM data
space */
GSMmemcpy( HWCalibrationData, CalDataPtr, sizeof( CALIBRATION_DATA ) ); /* Load the current
values into RAM */
CalDataPtr = HWCalibrationData; /* From now on everything uses the RAM copy until RAM
data is stored */
SetCTRAMCalDataFlag( TRUE );
#if defined (DEBUG)
GSMprintf( "RAM cal data allocated to %lx\n", ( UINT32 ) HWCalibrationData );
#endif
return;
}
/*---------------------------------------------------------------------*/
/*
Name: CTDeallocateRAMCalData
Desc: Deallocates the RAM copy of the calibration data structure for PTE work. Called internally from the
command to store the RAM data to Flash since the RAM data is probably no longer required.
Params: None
Returns: None
Caveats:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -