📄 ctcaldat.c
字号:
BOOLEAN PokeOK;
#ifdef DEBUG
GSMprintf( "Offset%u,Length:%u,Buffer:%u\n", Offset, Length, Buffer );
#endif
PokeOK = HWNVMPoke( Offset, Length, Buffer );
if ( PokeOK )
{
CTSendStringResponse( "PokeHWNVM:DONE\n" );
}
else
{
CTSendStringResponse( "PokeHWNVM:WRONG:OUT_OF_RANGE\n" );
}
}
/*---------------------------------------------------------------------*/
/*
Name: CTPrepareForIMEIBlackout
Desc: Figures out if the bytes to be 'peeked' include IMEI bytes.
Params: Input params: The offset and size in HW data which is being peeked
Output params: The lengths along that stretch that should be blacked out
if the IMEI is present in it (i.e. only filled if function returns TRUE).
Returns: TRUE if some blacking out will be needed
Caveats:
*/
static BOOLEAN CTPrepareForIMEIBlackout( UINT16 Offset, UINT16 Length, UINT16 * Start, UINT16 * End )
{
UINT16 IMEIOffset = HWNVMGetIMEIOffset( );
UINT16 IMEISize = HWNVMGetIMEISize( );
UINT16 IMEILastByte;
UINT16 LastByte;
IMEILastByte = IMEIOffset + IMEISize - 1;
LastByte = Offset + Length - 1;
if ( Offset >= IMEIOffset && Offset <= IMEILastByte )
{
/* The start of the area to be peeked at is in the IMEI range */
*Start = 0;
*End = ( LastByte > IMEILastByte ? IMEILastByte : LastByte ) - Offset;
return TRUE;
}
else if ( LastByte >= IMEIOffset && LastByte <= IMEILastByte )
{
/* The end of the area to be peeked at is in the IMEI range */
*Start = IMEIOffset - Offset;
*End = LastByte - Offset;
return TRUE;
}
else if ( Offset < IMEIOffset && LastByte > IMEILastByte )
{
/*
The start of the area to be peeked at is before the IMEI range and the end of
the area to be peeked at is after the IMEI range
*/
*Start = IMEIOffset - Offset;
*End = IMEILastByte - Offset;
return TRUE;
}
return FALSE;
}
/*---------------------------------------------------------------------*/
/*
Name: CTPeekHWNVM
Desc: Returns the requested number of bytes stored at the given address.
Params:
Returns:
Caveats:
We don't allow the scramled IMEI to be peeked at.
*/
static void CTPeekHWNVM( void )
{
UINT16 Offset = GeneralPurposeArray[0] * 256 + GeneralPurposeArray[1];
UINT8 Length = GeneralPurposeArray[2];
STRING s1 = GSM_NEW_STRING( 150 ); /* collect string for output to CT window */
STRING ctout = s1;
UINT8 *peekptr;
UINT16 limit = HWNVMGetDataSize( );
UINT16 blackOutStart = 0,
blackOutEnd = 0;
UINT16 i;
BOOLEAN doBlackOut;
if ( ( Length == 0 ) || ( Offset + Length >= limit ) )
{
CTSendStringResponse( "PeekHWNVM:WRONG:OUT_OF_RANGE\n" );
}
doBlackOut = CTPrepareForIMEIBlackout( Offset, Length, &blackOutStart, &blackOutEnd );
ctout += GSMsprintf( s1, "PeekHWNVM:RET:" );
if ( Length > 32 )
{
Length = 32;
}
peekptr = HWNVMGetDataPtr( ) + Offset;
#ifdef DEBUG
GSMprintf( "Offset%u,Length:%u,Peek - ptr:%u\n", Offset, Length, peekptr );
#endif
for ( i = 0; i < Length; i++ )
{
if ( doBlackOut )
{
if ( blackOutStart <= i && i <= blackOutEnd )
ctout += GSMsprintf( ctout, "0," );
else
ctout += GSMsprintf( ctout, "%u,", ( UINT8 ) ( *peekptr ) );
}
else
{
ctout += GSMsprintf( ctout, "%u,", ( UINT8 ) ( *peekptr ) );
}
peekptr++;
}
ctout--;
GSMsprintf( ctout, "\n" );
CTSendStringResponse( s1 );
GSMFree( s1 );
}
/*---------------------------------------------------------------------*/
/*
Name: CTSetVersion
Desc: Sets the version array in the hw calibration data. The version array
is a general purpose one and can be used by customers as they wish.
Params:
Returns:
Caveats:
*/
static void CTSetVersion( void )
{
UINT8 i;
for ( i = 0; i < 10; i++ )
{
CalDataPtr->Version[i] = GeneralPurposeArray[i];
}
CTSendStringResponse( "SetCalDataVer:DONE\n" );
}
/*---------------------------------------------------------------------*/
/*
Name: CTSetVersionString
Desc: Sets the cal version array in the calibration data as a string.
Params: CMD_LINE parameter treated as a string
Returns: Done or error message
Caveats: String to be set must be 1 cahr shorter than the structure to allow addition of end of string '\0'
*/
static void CTSetVersionString( CTTokenList * tokenList )
{
if ( GSMstrlen( tokenList->Token[1] ) >= sizeof( CalDataPtr->Version ) )
CTSendStringResponse( "SetCalDataVerText:FAIL:String too long.\n" );
else
{
GSMstrncpy( ( char * ) CalDataPtr->Version, tokenList->Token[1], sizeof( CalDataPtr->Version ) );
CTSendStringResponse( "SetCalDataVerText:DONE\n" );
}
}
/*---------------------------------------------------------------------*/
/*
Name: CTShowVersionText
Desc: Sends the content of the version array in the calibration data structure in text format.
Params:
Returns:
Caveats:
*/
static void CTShowVersionText( void )
{
STRING s1 = GSM_NEW_STRING( 20 + sizeof( CalDataPtr->Version ) ); /* collect string for
output to CT window */
GSMsprintf( s1, "ShowCalDataVerText:RET:%s\n", CalDataPtr->Version );
CTSendStringResponse( s1 );
GSMFree( s1 );
}
/*---------------------------------------------------------------------*/
/*
Name: CTShowVersion
Desc: Sends the content of the version array in the hw calibration data.
The version array is a general purpose one and can be used by
customers as they wish.
Params:
Returns:
Caveats:
*/
static void CTShowVersion( void )
{
UINT16 i;
STRING s1 = GSM_NEW_STRING( 55 ); /* collect string for output to CT window */
STRING ctout = s1;
ctout += GSMsprintf( s1, "ShowCalDataVer:RET:" );
ctout += GSMsprintf( ctout, "%u", ( UINT8 ) CalDataPtr->Version[0] );
for ( i = 1; i < 10; i++ )
{
ctout += GSMsprintf( ctout, ",%u", ( UINT8 ) CalDataPtr->Version[i] );
}
GSMsprintf( ctout, "\n" );
CTSendStringResponse( s1 );
GSMFree( s1 );
}
/*---------------------------------------------------------------------*/
/*
Name: CTShowCalStruct
Desc: A debug function, useful for checking the range for the peek and
poke commands.
Params:
Returns:
Caveats:
*/
static void CTShowCalStruct( void )
{
STRING s1 = GSM_NEW_STRING( 300 ); /* collect string for output to CT window */
STRING ctout = s1;
ctout += GSMsprintf( ctout, "Element starting positions:\n" );
ctout += GSMsprintf( ctout, "CheckSum:%u\n", HWNVMGetCheckSumOffset( ) );
ctout += GSMsprintf( ctout, "Cal data Version :%u\n", HWNVMGetCheckSumCalcOffset( ) );
ctout += GSMsprintf( ctout, "Powerramps start at:%u\n", HWNVMGetRampsOffset( ) );
ctout += GSMsprintf( ctout, "RX cal table starts at:%u\n", HWNVMGetGainCalTableOffset( ) );
ctout += GSMsprintf( ctout, "AFCDAC starts at:%u\n", HWNVMGetAFCDACStartValOffset( ) );
#if 0 && defined (POLARIS_II)
ctout += GSMsprintf( ctout, "PLL Call Table starts at:%u\n", HWNVMGetPLLTableStartValOffset( ) );
#endif
ctout += GSMsprintf( ctout, "IMEI at:%u\n", HWNVMGetIMEIOffset( ) );
ctout += GSMsprintf( ctout, "PTE Boot flag is at:%u\n", HWNVMGetPTEBootOffset( ) );
ctout += GSMsprintf( ctout, "ADC cal tables at:%u", HWNVMGetADCcalOffset( ) );
#if defined (BRITE4_RF)
ctout += GSMsprintf( ctout, "\nDCR offset table at:%u", HWNVMGetDCROffsetOffset( ) );
#endif
GSMsprintf( ctout, "\nLast byte of HW at:%u\n", sizeof( CALIBRATION_DATA ) );
CTSendStringResponse( s1 );
GSMFree( s1 );
}
/*---------------------------------------------------------------------*/
/*
Name: CTUseDefCalData
Desc: Enforces the use of default calibration data even if the checksum
in NVM was correct. This data can then be stored to NVM by using
"StoreHW".
Params:
Returns:
Caveats:
*/
static void CTUseDefCalData( void )
{
/* HWNVMVarsSetDefault( );*/
GSMmemcpy( CalDataPtr, &DefaultCalibrationData, sizeof( CALIBRATION_DATA ) );
CTSendStringResponse( "UseDefCalData:DONE\n" );
}
/*---------------------------------------------------------------------*/
/*
Name: CTShowAFCDACVal
Desc: Shows the currently used value for use in the AFC DAC
Params:
Returns:
Caveats:
*/
static void CTShowAFCDACVal( void )
{
STRING s1 = GSM_NEW_STRING( 300 );
STRING ctout = s1;
ctout += GSMsprintf( ctout, "ShowAFCDAC:RET:" );
GSMsprintf( ctout, "%d\n", CalDataPtr->AFCDACStartValue );
CTSendStringResponse( s1 );
GSMFree( s1 );
}
/*---------------------------------------------------------------------*/
/*
Name: CTDSPSetAFCDACVal
Desc: Set up a new value for use in the AFC DAC
Params:
Returns:
Caveats:
*/
static void CTDSPSetAFCDACVal( void )
{
if ( CalDataPtr->AFCDACStartValue )
{
HwCTSendSetAFCDAC( DC_SET_AFC_DAC_MODE_ON, CalDataPtr->AFCDACStartValue );
CTDSPControl.ActionSheduled = FALSE;
CTSendStringResponse( "SetAFCDAC:DONE\n" );
}
else
{
CTDSPControl.ActionSheduled = FALSE;
CTSendStringResponse( "CTAFCDACValue = zero ! ... DONE\n" );
}
}
/*---------------------------------------------------------------------*/
/*
Name: CTSetAFCDACVal
Desc: Set up a new value for use in the AFC DAC
Params:
Returns:
Caveats:
*/
static void CTSetAFCDACVal( void )
{
CalDataPtr->AFCDACStartValue = CTAFCDACValue;
CTDSPControl.ActionSheduled = TRUE;
CTDSPControl.Action = CTDSPSetAFCDACVal;
}
#if 0 && defined (POLARIS_II)
/*---------------------------------------------------------------------*/
/*
Name: CTShowPLLCallTable
Desc: Shows the currently used value for use in the PLL Call Table
Params:
Returns:
Caveats:
*/
static void CTShowPLLCallTable( void )
{
STRING s1 = GSM_NEW_STRING( 300 );
STRING ctout = s1;
INT8 i;
ctout += GSMsprintf( ctout, "ShowPLLCallTable:RET:" );
for ( i = 0; i < SIZE_OF_PLLTABLE; i++ )
{
ctout += GSMsprintf( ctout, "%d ", CalDataPtr->PllCallTables[i] );
}
ctout += GSMsprintf( ctout, "\n" );
CTSendStringResponse( s1 );
GSMFree( s1 );
}
/*---------------------------------------------------------------------*/
/*
Name: CTSetPLLCallTable
Desc: Set up new value for use in the PLL Call Table
Params:
Returns:
Caveats:
*/
static void CTSetPLLCallTable( void )
{
INT8 i;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -