[code]
#include "..\system\portab.h"
#include "..\system\syslib.h"
#include "..\system\sysprim.h"
#include "..\global\timedate.h"
#include "..\global\gsmtimer.h"
#include "..\global\gsmexit.h"
#include "..\nv\hwcaldat.h"
#include "..\config\hwnvm.h"
#include "..\config\mnuitypes.h"
#include "..\config\uhconfig.h"
//#if defined (RENESAS_RF_B5)
#include "..\config\uhcaldat.h"
//#endif
/* CT related */
#include "..\ct\ct.h"
#include "..\ct\ctlocal.h"
#include "..\ct\cttri.h"
#if defined (TLC_PLATFORM)
#include "..\..\basecust\custt7\ct\security\imei_enc.h"
#endif
#include "..\hw\dsp_if\hwshared.h"
#include "..\hw\dsp_if\dc.h"
#if defined (IO_TRACER)
#include "..\io\iodriver.h"
#include "..\hw\hwvariant.h"
#include "..\io\trdriver.h"
#endif
// MSL
#if defined(IMEI_SECURITY_MSL)
#include "..\fl\flashgen.h"
#include "..\fl\flashutl.h"
#endif
/*---------------------------- Local Defines: ----------------------------*/
#define COMPLETE_CAL_REPORT_BUF_SIZE (40*1024) /* 20*1024 - buffer overflow */
#define DCROFFS_CAL_REPORT_BUF_SIZE (4*1024)
#define CT_BATT_SAMPLES 20
// MSL
#if defined(IMEI_SECURITY_MSL)
#define MSL_ADDR_WEIGHT 0x92
#define MSL_CODE_WEIGHT 0x47
#endif
/*---------------------------- Local Typedefs: ---------------------------*/
typedef struct
{
INT16 channelNo;
INT16 ADCLevel; /* High = 0, Low = 1 */
INT16 offsetValue;
} ADChannelOffsetType;
typedef struct
{
UINT16 SampleNumber;
UINT16 SampleDelay;
} BattSamplesType;
#if defined (RENESAS_RF_B5)
typedef struct
{
UINT16 Length;
UINT16 Data[RF_CONFIG_DATA_SIZE_MAX];
} RFConfigCal;
typedef struct
{
UINT16 Length;
UINT16 Data[NO_OF_RFINIT_PARM];
} RFInitCal;
#endif
/*---------------------------- Local Statics: ----------------------------*/
/* ADC and battery sampling static variables */
static UINT8 CTdummy8 = 0;
static ADChannelOffsetType CTADChannelOffset = {0, 0, 0};
static BattSamplesType CTBattSetup = {1, 0};
#if defined (PSC2010)
static UINT16 CTBattSamples[CT_BATT_SAMPLES + 1];
#endif
static UINT32 dwCTUserCalDataAddr = 0;
#if defined( BRITE4_RF )
static UINT8 bCTDCROffsetArea[2];
static INT16 wCTDCROffsetData[DCROFFS_SUBBANDS * 2];
static BOOLEAN BShowInHex = FALSE;
#endif
#if 0 && defined (POLARIS_II)
static UINT16 CTPLLCallTable[SIZE_OF_PLLTABLE];
#endif
#if defined (RENESAS_RF_B5)
static UINT16 CTRxTxFreqOffset[NO_RF_BANDS];
static RFConfigCal CTRFConfigCal =
{
0,
{
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0
}
};
static RFInitCal CTRFInitCal =
{
0,
{
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0
}
};
#endif
/* The size of the buffer to allocate and write everything into is LARGE! */
static UINT16 BufSize = COMPLETE_CAL_REPORT_BUF_SIZE;
static UINT8 GeneralPurposeArray[35];
static UINT16 currentReply = 0;
static UINT16 CTAFCDACValue = 0;
#if defined( AERO_PLUS ) || defined(MARS)
static UINT16 CTCDACValue = 0;
static INT16 CTCVARSlopeValue = 0;
#endif
static BOOLEAN CTRAMCalDataFlag = FALSE;
static CALIBRATION_DATA *HWCalibrationData; /* This is the RAM copy of cal data for PTE */
static BOOLEAN bListDCROffsetsOnly = FALSE;
// MSL
#if defined(IMEI_SECURITY_MSL)
static UINT8 IsSetMSLCode = FALSE;
static UINT8 IsSetMSLAddr = FALSE;
#endif
/*----------------------- Local Function Prototypes: ---------------------*/
#if defined(IMEI_SECURITY)
static void CTimeirandom(void);
static void CTimeiwrite( CTTokenList * CTCmd );
//static void CTSetIMEI( void );
#endif
// MSL
#if defined(IMEI_SECURITY_MSL)
static void CTSetMSLAddr( CTTokenList * CTCmd );
static void CTGetMSLAddr( void );
static void CTSetMSLCode( CTTokenList * CTCmd );
static void CTCheckMSL( CTTokenList * CTCmd );
#if defined(IMEI_SECURITY_DISABLE_MSL)
static void CTMakeUnvalidCal( void );
#endif
#endif
static void CTShowIMEI( void );
static void CTPokeHWNVM( void );
static void CTPeekHWNVM( void );
static void CTSetVersion( void );
static void CTSetVersionString( CTTokenList * tokenList );
static void CTShowVersion( void );
static void CTShowVersionText( void );
static void CTShowCalStruct( void );
static void CTUseDefCalData( void );
static void CTListCalibrationData( void );
static void CTShowDefaultCalContents( void );
static void CTShowAFCDACVal( void );
static void CTSetAFCDACVal( void );
#if 0 && defined (POLARIS_II)
static void CTShowPLLCallTable( void );
static void CTSetPLLCallTable( void );
#endif
#if defined (AERO_PLUS) || defined(MARS)
static void CTShowCDAC( void );
static void CTSetCDAC( void );
#if 1 /* OCR3789 */
static void CTShowCVARSlope( void );
static void CTSetCVARSlope( void );
#endif
#endif
#if defined (RENESAS_RF_B5)
static void CTShowRxTxFreqOffsetCal( void );
static void CTSetRxTxFreqOffsetCal( void );
static void CTSetRFConfigCal( void );
static void CTSendRFConfigCal( void );
static void CTShowRFConfigCal( void );
static void CTShowRFInit( void );
static void CTSetRFInit( void );
#endif
static void CTQueryCalChecksum( void );
#if !defined(FFS)
static void CTForceHWNVMValid( void );
static void CTForceHWNVMInvalid( void );
#endif
static void CTDumpDSP( void );
static void CTStoreCalData( void );
static void CTLoadCalDataFromFlash( void );
static void CTDeallocateRAMCalData( void );
static void CTReadADCChannel( void );
/*static void CTSelectADChannel( void );*/
static void CTGetADOffset( void );
static void CTSetupSetADChannelOffset( void );
static void CTSetADChannelOffset( void );
static void CTDoBatteryMeasurement( void );
#if defined (PSC2010)
static void CTBattSampling( void * );
#endif
#if defined( BRITE4_RF )
static void CTSetDCROffsetArea( void );
static void CTSetDCROffsetData( void );
static void CTShowDCROffsetsDec( void );
static void CTShowDCROffsetsHex( void );
static void CTShowDCRArea( void );
static void CTShowDCROffsetsAll( void );
static void CTReadDCROffset( void );
static void CTEnableDSPDCROffset( void );
#endif
void CTSendRFInit( void );
void CTRFInit( void );
/*-------------------------------- Globals -------------------------------*/
CTChecksumCauseType CTChecksumCause; /* For all store commands (except StoreHW) the
checksum is not written to flash directly after
the write but rather CT_CHECK_SUM_WRITE_DELAY
milliseconds later. This variable stores an
identifier of the 'calling' command so the CT
response string looks right */
CT_TABLE_BEGIN( CTCalDataTable, "CalData" ),
CT_ITEM_FUNCTION( "ShowCalStruct", CTShowCalStruct ),
CT_ITEM_ARRAY_FUNCTION( "SetCalDataVer", UINT8_TYPE, DECIMAL, GeneralPurposeArray, CTSetVersion, 10 ),
CT_ITEM_CT_CMD_LINE_FUNCTION( "SetCalDataVerText", CTSetVersionString ),
CT_ITEM_FUNCTION( "ShowCalDataVer", CTShowVersion ),
CT_ITEM_FUNCTION( "ShowCalDataVerText", CTShowVersionText ),
#if defined(IMEI_SECURITY)
CT_ITEM_FUNCTION( "imeirandom", CTimeirandom ),
CT_ITEM_CT_CMD_LINE_FUNCTION( "imeiwrite", ( pCT_CT_CMD_LINE_Fun ) CTimeiwrite),
//CT_ITEM_ARRAY_FUNCTION( "SetIMEI", UINT8_TYPE, HEX, GeneralPurposeArray, CTSetIMEI, 8 ),
#endif
// MSL
#if defined(IMEI_SECURITY_MSL)
CT_ITEM_CT_CMD_LINE_FUNCTION( "SetMSLAddr", ( pCT_CT_CMD_LINE_Fun ) CTSetMSLAddr),
CT_ITEM_FUNCTION( "GetMSLAddr", CTGetMSLAddr ),
CT_ITEM_CT_CMD_LINE_FUNCTION( "SetMSLCode", ( pCT_CT_CMD_LINE_Fun ) CTSetMSLCode),
CT_ITEM_CT_CMD_LINE_FUNCTION( "CheckMSL", ( pCT_CT_CMD_LINE_Fun ) CTCheckMSL),
#if defined(IMEI_SECURITY_DISABLE_MSL)
CT_ITEM_FUNCTION( "MakeUnvalidCal", CTMakeUnvalidCal ),
#endif
#endif
CT_ITEM_ARRAY_FUNCTION( "ShowIMEI", UINT8_TYPE, DECIMAL, GeneralPurposeArray, CTShowIMEI, 8 ),
CT_ITEM_FUNCTION( "ShowAFCDAC", CTShowAFCDACVal ),
CT_ITEM_VARIABLE_FUNCTION( "SetAFCDAC", UINT16_TYPE, DECIMAL, &CTAFCDACValue, CTSetAFCDACVal ),
#if 0 && defined (POLARIS_II)
CT_ITEM_FUNCTION( "ShowPLLCalTable", CTShowPLLCallTable ),
CT_ITEM_ARRAY_FUNCTION( "SetPLLCalTable", UINT16_TYPE, DECIMAL, CTPLLCallTable, CTSetPLLCallTable, SIZE_OF_PLLTABLE ),
#endif
#if defined (AERO_PLUS) || defined(MARS)
CT_ITEM_FUNCTION( "ShowCDAC", CTShowCDAC ),
CT_ITEM_VARIABLE_FUNCTION( "SetCDAC", UINT16_TYPE, DECIMAL, &CTCDACValue, CTSetCDAC ),
CT_ITEM_FUNCTION( "ShowCVARSlope", CTShowCVARSlope ),
CT_ITEM_VARIABLE_FUNCTION( "SetCVARSlope", INT16_TYPE, DECIMAL, &CTCVARSlopeValue, CTSetCVARSlope ),
#endif
CT_ITEM_ARRAY_FUNCTION( "PokeHWNVM", UINT8_TYPE, DECIMAL, GeneralPurposeArray, CTPokeHWNVM, 35 ),
CT_ITEM_ARRAY_FUNCTION( "PeekHWNVM", UINT8_TYPE, DECIMAL, GeneralPurposeArray, CTPeekHWNVM, 3 ),
CT_ITEM_FUNCTION( "UseDefCalData", CTUseDefCalData ),
CT_ITEM_FUNCTION( "ListCalData", CTListCalibrationData ),
CT_ITEM_FUNCTION( "ListDefCalData", CTShowDefaultCalContents ),
CT_ITEM_FUNCTION( "ShowCalData", CTListCalibrationData ),
CT_ITEM_FUNCTION( "ShowDefCalData", CTShowDefaultCalContents ),
CT_ITEM_FUNCTION( "CheckCalDataOK", CTQueryCalChecksum ),
CT_ITEM_FUNCTION( "StoreCalData", CTStoreCalData ),
CT_ITEM_VARIABLE_FUNCTION( "LoadCalData", INT32_TYPE, HEX, &dwCTUserCalDataAddr, CTLoadCalDataFromFlash ),
/*CT_ITEM_VARIABLE_FUNCTION( "DisplayBitmap", UINT8_TYPE, DECIMAL, &CTdummy8, CTDisplayBitmap ),*/
CT_ITEM_VARIABLE_FUNCTION( "ReadADCChannel", UINT8_TYPE, DECIMAL, &CTdummy8, CTReadADCChannel ),
CT_ITEM_ARRAY_FUNCTION( "GetADCAdjust", INT16_TYPE, DECIMAL, &CTADChannelOffset, CTGetADOffset, 3 ),
CT_ITEM_ARRAY_FUNCTION( "ShowADCAdjust", INT16_TYPE, DECIMAL, &CTADChannelOffset, CTGetADOffset, 3 ),
CT_ITEM_ARRAY_FUNCTION( "SetADCAdjust", INT16_TYPE, DECIMAL, &CTADChannelOffset, CTSetupSetADChannelOffset, 3 ),
CT_ITEM_ARRAY_FUNCTION( "DoBattMeas", UINT16_TYPE, DECIMAL, &CTBattSetup, CTDoBatteryMeasurement, 2 ),
#if defined( BRITE4_RF )
CT_ITEM_FUNCTION( "ShowDCROffsetAll", CTShowDCROffsetsAll ),
CT_ITEM_ARRAY_FUNCTION( "SetDCROffsetArea", UINT8_TYPE, DECIMAL, bCTDCROffsetArea, CTSetDCROffsetArea, 2 ),
CT_ITEM_ARRAY_FUNCTION( "SetDCROffsetData", INT16_TYPE, DECIMAL, wCTDCROffsetData, CTSetDCROffsetData, 14 ),
CT_ITEM_FUNCTION( "ShowDCROffsetDec", CTShowDCROffsetsDec ),
CT_ITEM_FUNCTION( "ShowDCROffsetHex", CTShowDCROffsetsHex ),
CT_ITEM_FUNCTION( "ShowDCROffsetArea", CTShowDCRArea ),
CT_ITEM_FUNCTION( "EnableDSPDCROffset", CTEnableDSPDCROffset ),
CT_ITEM_FUNCTION( "ReadDCROffset", CTReadDCROffset ),
#endif
#if defined (RENESAS_RF_B5)
CT_ITEM_FUNCTION( "ShowRxTxFreqOffsetCal", CTShowRxTxFreqOffsetCal ),
CT_ITEM_FUNCTION( "ShowRFConfigCal", CTShowRFConfigCal ),
CT_ITEM_ARRAY_FUNCTION( "SetRxTxFreqOffsetCal", INT16_TYPE, DECIMAL, CTRxTxFreqOffset, CTSetRxTxFreqOffsetCal, 4 ),
CT_ITEM_ARRAY_FUNCTION( "SetRFConfigCal", INT16_TYPE, DECIMAL, &CTRFConfigCal, CTSetRFConfigCal, 17 ),
CT_ITEM_FUNCTION( "ShowRFInit", CTShowRFInit ),
CT_ITEM_ARRAY_FUNCTION( "SetRFInit", INT16_TYPE, DECIMAL, &CTRFInitCal, CTSetRFInit, NO_OF_RFINIT_PARM + 1 ),
CT_ITEM_ARRAY_FUNCTION( "RFInit", INT16_TYPE, DECIMAL, &CTRFInitCal, CTRFInit, NO_OF_RFINIT_PARM + 1 ),
#else
CT_ITEM_FUNCTION( "RFInit", CTRFInit ),
#endif
#if !defined(FFS)
CT_ITEM_HIDDEN_FUNCTION( "ForceNVMGood", CTForceHWNVMValid ),
CT_ITEM_HIDDEN_FUNCTION( "ForceNVMBad", CTForceHWNVMInvalid ),
#endif
/* MZO : intermediate function for DSPTracing */
CT_ITEM_HIDDEN_FUNCTION( "DumpDSP", CTDumpDSP ),
CT_TABLE_END( );
/*-------------------------------- Externs -------------------------------*/
// MSL
#if defined(IMEI_SECURITY_MSL)
#if defined(IMEI_SECURITY_DISABLE_MSL)
UINT8 IsMSLCodeRight = TRUE;
#else
UINT8 IsMSLCodeRight = FALSE;
#endif
#endif
/*---------------------------- Local Functions: --------------------------*/
#if defined(IMEI_SECURITY)
static UINT8 imei_encode_flag = 0;
static UINT8 imei_decode_flag = 0;
static UINT8 check_buff[32];
static void CTimeirandom(void)
{
// char St[32]; //, Ak[60]; //Qu[100],
char St[64]; // add 11
imei_encode_flag = 1;
// IMEI_Encryption();
// MSL
#if defined(IMEI_SECURITY_MSL)
if(IsMSLCodeRight == FALSE)
{
CTSendStringResponse( "IMEIrandom : FAIL (MSLCode is not matched)\n " );
return;
}
#endif
GSMmemset(St, 0, sizeof( St ));
Get_Number( St, check_buff );
//GSMprintf( " [%s], [%s] .\n", St, check_buff);
CTSendStringResponse( " IMEIstart : DONE\n " );
}
static void CTimeiwrite( CTTokenList * CTCmd )
{
UINT8 i;
INT8 *str = ( INT8 * ) GSMMalloc( 32 );
// UINT8 stringLen;
// stringLen = GSMstrlen(CTCmd->Token[1]);
GSMsprintf( str, "%s", CTCmd->Token[1] );
if ( ( imei_encode_flag == 1 ) && ( strcmp( check_buff, str ) == 0 ) )
{
if ( CTCmd->NumTokens == 10 )
{
for ( i = 0; i < (CTCmd->NumTokens - 2) ; i++ )
{
CalDataPtr->GLIMEISV[i] = (UINT8)GSMstrtoul(CTCmd->Token[i+2]);
}
UHNVMEncodeIMEI( CalDataPtr->GLIMEISV );
NVSetIMEI( );
CTSendStringResponse( "IMEIwrite:DONE\n" );
}
else
{
CTSendStringResponse( " IMEI paramater index is not matched .. Retry IMEIstart\n " );
}
}
else
{
CTSendStringResponse( " IMEIcheck value : Failed .. Retry IMEIstart\n " );
}
imei_encode_flag = 0;
GSMmemset(check_buff, 0, sizeof( check_buff ));
GSMFree( str );
}
/*---------------------------------------------------------------------*/
/*
Name: CTSetIMEI
Desc: Sets the IMEI value up in CalDataPtr->GLIMEISV[].
Params:
Returns:
Caveats:
The IMEI given should be in scrambled from. However, the option is available to
customers to pass it to the mobile in descrambled form. Therefore the driver
UHNVMEncodeIMEI() is called here. It will normally do nothing, but can be a matching scrambling
routine for the descrambling routine in UHNVMDecodeIMEI().
*/
#if 0
static void CTSetIMEI( void )
{
UINT8 i;
for ( i = 0; i < 8; i++ )
{
CalDataPtr->GLIMEISV[i] = GeneralPurposeArray[i];
}
/* On phone scrambling could (but shouldn't) happen here */
UHNVMEncodeIMEI( CalDataPtr->GLIMEISV );
NVSetIMEI( );
CTSendStringResponse( "SetIMEI:DONE\n" );
}
#endif
#endif
/*---------------------------------------------------------------------*/
/*
Name: CTShowIMEI
Desc: Shows the content of the IMEI array in the hw calibration data.
Params:
Returns:
Caveats:
*/
static void CTShowIMEI( void )
{
UINT16 i;
STRING s1 = GSM_NEW_STRING( 55 ); /* collect string for output to CT window */
STRING ctout = s1;
UINT8 tempGLIMEISV[8];
/* Copy the scrambled IMEI into a buffer and get it descrambled */
GSMmemcpy( tempGLIMEISV, CalDataPtr->GLIMEISV, 8 );
UHNVMDecodeIMEI( tempGLIMEISV );
ctout += GSMsprintf( s1, "ShowIMEI:RET:" );
ctout += GSMsprintf( ctout, "0x%02x", ( UINT8 ) tempGLIMEISV[0] );
for ( i = 1; i < 8; i++ )
{
ctout += GSMsprintf( ctout, ",0x%02x", ( UINT8 ) tempGLIMEISV[i] );
}
GSMsprintf( ctout, "\n" );
CTSendStringResponse( s1 );
GSMFree( s1 );
}
//MSL
#if defined(IMEI_SECURITY_MSL)
static void CTGetMSLAddr( void )
{
//
STRING sTemp = GSM_NEW_STRING( 55 );
STRING ctout = sTemp;
char MSLAddr[5][2];
UINT8 bTemp = 0, bTemp2 = 0;
//
GSMmemcpy( MSLAddr[0], CalDataPtr->MSLAddress_0, sizeof(CalDataPtr->MSLAddress_0) );
GSMmemcpy( MSLAddr[1], CalDataPtr->MSLAddress_1, sizeof(CalDataPtr->MSLAddress_0) );
GSMmemcpy( MSLAddr[2], CalDataPtr->MSLAddress_2, sizeof(CalDataPtr->MSLAddress_0) );
GSMmemcpy( MSLAddr[3], CalDataPtr->MSLAddress_3, sizeof(CalDataPtr->MSLAddress_0) );
GSMmemcpy( MSLAddr[4], CalDataPtr->MSLAddress_4, sizeof(CalDataPtr->MSLAddress_0) );
//
ctout += GSMsprintf(sTemp, "MSLAddr : ");
for(bTemp=0; bTemp<5; bTemp++)
{
for(bTemp2=0; bTemp2<2; bTemp2++)
{
MSLAddr[bTemp][bTemp2] ^= MSL_ADDR_WEIGHT;
ctout += GSMsprintf(ctout, "%02c", (UINT8)MSLAddr[bTemp][bTemp2]);
}
}
ctout += GSMsprintf(ctout, "\nCTGetMSLAddr : Done");
CTSendStringResponse(sTemp);
GSMFree(sTemp);
}
static void CTSetMSLAddr( CTTokenList * CTCmd )
{
//
UINT8 *pCalDataStart = NULL;
UINT8 bTemp1 = 0, bTemp2 = 0;
char MSLAddr[5][2];
UINT16 FlashResult = 0;
char *strMSLAddr = CTCmd->Token[1];
//
if ( CTCmd->NumTokens != 2 )
{
CTSendStringResponse( " CTSetMSLAddr : MSLAddr paramater index is not matched .. Retry \n " );
return;
}
//
for(bTemp1=0; bTemp1<5; bTemp1++)
{
for(bTemp2=0; bTemp2<2; bTemp2++)
{
MSLAddr[bTemp1][bTemp2] = *(strMSLAddr+bTemp1*2 +bTemp2);
if( GSMislower(MSLAddr[bTemp1][bTemp2]) )
{
MSLAddr[bTemp1][bTemp2] = GSMtoupper(MSLAddr[bTemp1][bTemp2]);
}
MSLAddr[bTemp1][bTemp2] ^= MSL_ADDR_WEIGHT;
}
}
//
GSMmemcpy( CalDataPtr->MSLAddress_0, MSLAddr[0], sizeof(CalDataPtr->MSLAddress_0) );
GSMmemcpy( CalDataPtr->MSLAddress_1, MSLAddr[1], sizeof(CalDataPtr->MSLAddress_0) );
GSMmemcpy( CalDataPtr->MSLAddress_2, MSLAddr[2], sizeof(CalDataPtr->MSLAddress_0) );
GSMmemcpy( CalDataPtr->MSLAddress_3, MSLAddr[3], sizeof(CalDataPtr->MSLAddress_0) );
GSMmemcpy( CalDataPtr->MSLAddress_4, MSLAddr[4], sizeof(CalDataPtr->MSLAddress_0) );
//
CTSendStringResponse( "CTSetMSLAddr : Done");
IsSetMSLAddr = TRUE;
return;
}
static void CTSetMSLCode( CTTokenList * CTCmd )
{
//
UINT8 MSLCode[3];
UINT8 i = 0;
UINT8 *pCalDataStart = NULL;
UINT16 FlashResult = 0;
char *strMSLCode = CTCmd->Token[1];
char strTemp[3];
GSMmemset(strTemp, NULL, sizeof(strTemp));
//
if ( CTCmd->NumTokens != 2 )
{
CTSendStringResponse( " CTSetMSLAddr : CTSetMSLCode paramater index is not matched .. Retry \n " );
return;
}
//
if(CalDataPtr->MSLCode_0 != (0x00^MSL_CODE_WEIGHT) ||
CalDataPtr->MSLCode_1 != (0x00^MSL_CODE_WEIGHT) ||
CalDataPtr->MSLCode_2 != (0x00^MSL_CODE_WEIGHT) )
{
CTSendStringResponse( "CTSetMSLCode : Failed (MSLCode != 000000) ");
return;
}
//
for(i=0; i<3; i++)
{
GSMmemcpy(strTemp, strMSLCode+i*2, 2);
MSLCode[i] = (UINT8)GSMstrtoul(strTemp);
MSLCode[i] ^= MSL_CODE_WEIGHT;
}
CalDataPtr->MSLCode_0 = MSLCode[0];
CalDataPtr->MSLCode_1 = MSLCode[1];
CalDataPtr->MSLCode_2 = MSLCode[2];
//
IsSetMSLCode = TRUE;
CTSendStringResponse( "CTSetMSLCode : Done");
return;
}
static void CTCheckMSL( CTTokenList * CTCmd )
{
//
UINT8 MSLCode[3];
static UINT8 CheckCount = 0;
UINT8 i = 0;
char *strMSLCode = CTCmd->Token[1];
char strTemp[3];
UINT8 InputMSLCode[3];
GSMmemset(strTemp, NULL, sizeof(strTemp));
//
if ( CTCmd->NumTokens != 2 )
{
CTSendStringResponse( " CTCheckMSL : CTCheckMSL paramater index is not matched .. Retry \n " );
return;
}
//
for(i=0; i<3; i++)
{
GSMmemcpy(strTemp, strMSLCode+i*2, 2);
InputMSLCode[i] = (UINT8)GSMstrtoul(strTemp);
}
//
if( CalDataPtr->MSLCode_0 == (0x00^MSL_CODE_WEIGHT) &&
CalDataPtr->MSLCode_1 == (0x00^MSL_CODE_WEIGHT) &&
CalDataPtr->MSLCode_2 == (0x00^MSL_CODE_WEIGHT) )
{
CTSendStringResponse( "CTCheckMSL : TRUE ");
return;
}
//
MSLCode[0] = CalDataPtr->MSLCode_0;
MSLCode[1] = CalDataPtr->MSLCode_1;
MSLCode[2] = CalDataPtr->MSLCode_2;
for ( i = 0; i < 3 ; i++ )
{
MSLCode[i] ^= MSL_CODE_WEIGHT;
if(MSLCode[i] != InputMSLCode[i])
{
CTSendStringResponse( " CTCheckMSL : FALSE" );
CheckCount++;
if(CheckCount == 3)
{
uhSystemReset();
}
return;
}
}
IsMSLCodeRight = TRUE;
CTSendStringResponse( " CTCheckMSL : TRUE" );
}
#if defined(IMEI_SECURITY_DISABLE_MSL)
static void CTMakeUnvalidCal( void )
{
//
CALIBRATION_DATA *CalData = NULL;
UINT16 FlashResult = 0;
//
CalData = ( CALIBRATION_DATA * ) GSMMalloc( sizeof( CALIBRATION_DATA ) );
GSMmemcpy( CalData, CalDataPtr, sizeof( CALIBRATION_DATA ) );
//
if ( HWNVMGetDataSize( ) > CALIBRATION_SECTOR_SIZE )
GSMprintf( "Calibration data too big !!!\n" );
CalData->CheckSum = 0;
FlashResult = FlashUtilWrite( ( UINT32 ) pCalDataInFlash,
sizeof( CALIBRATION_DATA ),
CalData,
FSU_Calibration,
FU_FLAG_PRESERVE | FU_FLAG_ERASE | FU_FLAG_FORCE_USE_HEAP );
//
#define FFS_OK 0
if ( FlashResult == FFS_OK )
{
CTSendStringResponse( "CTMakeUnvalidCal : Done");
}
else
{
CTSendStringResponse( "CTMakeUnvalidCal : Failed (FlashUtilWrite Error)");
GSMFree(CalData);
return;
}
GSMFree(CalData);
return;
}
#endif
#endif
/*---------------------------------------------------------------------*/
/*
Name: CTPokeHWNVM
Desc: Fills the required number of bytes ( up to 32 ) into the HW NVM area.
Params: Are trensfered via the GeneralPurposeArray
Returns:
Caveats: The parameters in the GeneralPurposeArray are (in the given
sequence): high byte of the offset relative to the begining of
the HW NVM Area, low byte of the offset, length, bytes to be
poked into the area. The changed area is finaly stored by the
command 'StoreHW'.
*/
static void CTPokeHWNVM( void )
{
UINT16 Offset = GeneralPurposeArray[0] * 256 + GeneralPurposeArray[1];
UINT8 Length = GeneralPurposeArray[2];
UINT8 *Buffer = ( UINT8 * ) & GeneralPurposeArray[3];
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;
for ( i = 0; i < SIZE_OF_PLLTABLE; i++ )
{
CalDataPtr->PllCallTables[i] = CTPLLCallTable[i];
}
CTSendStringResponse( "SetPLLCallTable:DONE\n" );
}
#endif
#if defined (AERO_PLUS) || defined(MARS)
/*---------------------------------------------------------------------*/
/*
Name: CTShowCDAC
Desc: Shows the currently used value for use in the CDAC
Params:
Returns:
Caveats:
*/
static void CTShowCDAC( void )
{
STRING s1 = GSM_NEW_STRING( 300 );
STRING ctout = s1;
ctout += GSMsprintf( ctout, "ShowCDAC:RET:" );
GSMsprintf( ctout, "%d\n", CalDataPtr->CDAC );
CTSendStringResponse( s1 );
GSMFree( s1 );
}
/*---------------------------------------------------------------------*/
/*
Name: CDACtoDSP
Desc: Set up a new value for rf_config CDAC in DSP
Params:
Returns:
Caveats:
*/
void CDACtoDSP(void) //20050310 cmj for Lindy3 AERO_PLUS
{
UINT16 *x;
if ( ( x = Hw_Read_TX_DXCO( ) ) != NULL )
{
CTResetDSPAction( );
HwSendRFConfig( 1, x );
}
}
/*---------------------------------------------------------------------*/
/*
Name: CTSetCDAC
Desc: Set up a new value for use in the CDAC
Params:
Returns:
Caveats:
*/
static void CTSetCDAC( void )
{
STRING s1 = GSM_NEW_STRING( 300 );
STRING ctout = s1;
CalDataPtr->CDAC = CTCDACValue;
#if defined (AERO_PLUS)
HwSendSetSerialWord( (( CalDataPtr->CDAC * 64 ) + 3) | (0x6000), 0xB0 );
#else
HwSendSetSerialWord( ( CalDataPtr->CDAC * 64 ) + 40, 0xB0 );
#endif
GSMsprintf( ctout, "SetCDAC:DONE\n" );
CTSendStringResponse( s1 );
#if defined (AERO_PLUS)
/*set up new value for rf_config CDAC in DSP*/
CTDSPControl.Action = CDACtoDSP; //20050310 cmj for Lindy3 AERO_PLUS
CTDSPControl.ActionSheduled = TRUE;
#endif
GSMFree( s1 );
}
/*---------------------------------------------------------------------*/
/*
Name: CTShowCDAC
Desc: Shows the currently used value for use in the CDAC
Params:
Returns:
Caveats:
*/
static void CTShowCVARSlope( void )
{
STRING s1 = GSM_NEW_STRING( 300 );
STRING ctout = s1;
ctout += GSMsprintf( ctout, "ShowCVARSlope:RET:" );
GSMsprintf( ctout, "%d\n", CalDataPtr->CVAR_SLOPE );
CTSendStringResponse( s1 );
GSMFree( s1 );
}
/*---------------------------------------------------------------------*/
/*
Name: CTSetCDAC
Desc: Set up a new value for use in the CDAC
Params:
Returns:
Caveats:
*/
static void CTSetCVARSlope( void )
{
STRING s1 = GSM_NEW_STRING( 300 );
STRING ctout = s1;
CalDataPtr->CVAR_SLOPE = CTCVARSlopeValue;
GSMsprintf( ctout, "SetCVARSlope: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 )
{
STRING ctout;
STRING 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_STRING( 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, STRING firstLine )
{
STRING ctout;
UINT8 *Table;
INT16 i,
j;
UINT16 *pRamp,
wRXCalDataOffset;
UINT8 tempGLIMEISV[8],
bBand,
bFirstPCL,
bLastPCL;
#if defined(RENESAS_RF_B5) && defined (RF_GAIN_AREAS)
UINT8 Area;
#endif
#if defined( BRITE4_RF )
UINT16 wBand,
wGain,
wSubband;
#endif
currentReply = 0;
ctout = GSM_NEW_STRING( ( 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" );
}
}
#if defined (RENESAS_RF_B5)
/* TX RAMP DATA */
pRamp = ( UINT16 * ) ( &( listingPtr->PowerRampTables8PSKBand0[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 for 8PSK\n", bBand, j );
for ( i = 0; i < SIZE_OF_GSM_RAMP; i++ )
ctout += GSMsprintf( ctout, ",%u", *pRamp++ );
ctout += GSMsprintf( ctout, "\n" );
}
}
#endif
#if defined (RF_GAIN_AREAS)
/* RX GAIN DATA */
CheckGainSizes( );
/* Check if we have a BB table inside */
if (( listingPtr->Gain_area_sizes[listingPtr->BBTablePosition] > 0 ) &&
(listingPtr->BBTablePosition < MAX_GAIN_AREAS))
{
theFullReply[currentReply++] = ctout;
ctout += GSMsprintf( ctout, "RX Baseband Gain Cal Table:\n" );
/* Set to start of table */
Table = listingPtr->Hw_Rf_Gain_Cal_Table;
for ( i = 0; i < listingPtr->BBTablePosition; i++ )
{
/* Increase pointer until we've reached the BBtable */
Table += listingPtr->Gain_area_sizes[i];
}
for ( i = 0; i < listingPtr->Gain_area_sizes[listingPtr->BBTablePosition]; i++ )
{
ctout += GSMsprintf( ctout, ", %u", Table[i] );
}
ctout += GSMsprintf( ctout, "\n" );
}
Table = listingPtr->Hw_Rf_Gain_Cal_Table;
/* Display the other areas */
for ( Area = 0; Area < MAX_GAIN_AREAS; Area++ )
{
UINT16 k;
/* Check if current area isn't the BB table */
if (( Area != listingPtr->BBTablePosition ) ||
(listingPtr->BBTablePosition > MAX_GAIN_AREAS))
{
theFullReply[currentReply++] = ctout;
ctout += GSMsprintf( ctout, "Area %u Gain Cal Table:\n", Area );
for ( k = 0; k < listingPtr->Gain_area_sizes[Area]; k++ )
{
ctout += GSMsprintf( ctout, ", %u", Table[k] );
}
ctout += GSMsprintf( ctout, "\n" );
}
Table += listingPtr->Gain_area_sizes[Area];
}
#else
/* 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] );
#if (RX_BB_TABLE_SIZE != 0)
for ( i = 0; i < RX_BB_TABLE_SIZE; i++ )
{
ctout += GSMsprintf( ctout, ", %u", Table[i] );
}
ctout += GSMsprintf( ctout, "\n" );
#endif
for ( bBand = 0; bBand < CalibrationBandInfo.bActiveBands; bBand++ )
{
UINT16 k;
wRXCalDataOffset = ( RX_BB_TABLE_SIZE + ( bBand * RX_BAND_TABLE_SIZE ) );
theFullReply[currentReply++] = ctout;
ctout += GSMsprintf( ctout, "Band %u Gain Cal Table:\n", bBand );
for ( k = wRXCalDataOffset; k < wRXCalDataOffset + RX_BAND_TABLE_SIZE; k++ )
{
ctout += GSMsprintf( ctout, ", %u", Table[k] );
}
ctout += GSMsprintf( ctout, "\n" );
}
#endif
/* 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
#if defined( AERO_PLUS ) || defined(MARS)
/* The CVAR_SLOPE - section */
theFullReply[currentReply++] = ctout;
ctout += GSMsprintf( ctout, "CVAR SLOPE, %d\n", listingPtr->CVAR_SLOPE );
/* The CDAC - section */
theFullReply[currentReply++] = ctout;
ctout += GSMsprintf( ctout, "CDAC, %d\n", listingPtr->CDAC );
#endif
#if defined (RENESAS_RF_B5)
/* The RF_CONFIG - section */
theFullReply[currentReply++] = ctout;
ctout += GSMsprintf( ctout, "RFConfigLength, %d\n\n", listingPtr->RFConfigLength );
ctout += GSMsprintf( ctout, "RFConfig " );
for ( i = 0; i < listingPtr->RFConfigLength; i++ )
{
ctout += GSMsprintf( ctout, ",%d", listingPtr->RFConfig[i] );
}
ctout += GSMsprintf( ctout, "\n" );
/* The RxTxFreqOffset - section */
theFullReply[currentReply++] = ctout;
ctout += GSMsprintf( ctout, "RxTxFreqOffset " );
for ( i = 0; i < NO_RF_BANDS; i++ )
{
ctout += GSMsprintf( ctout, ",%d", listingPtr->RxTxFreqOffset[i] );
}
ctout += GSMsprintf( ctout, "\n" );
/* The RF_INIT - section */
theFullReply[currentReply++] = ctout;
ctout += GSMsprintf( ctout, "RFInitDataLength, %d\n\n", listingPtr->RFInitDataLength );
ctout += GSMsprintf( ctout, "RFInitData " );
for ( i = 0; i < listingPtr->RFInitDataLength; i++ )
{
ctout += GSMsprintf( ctout, ",%d", listingPtr->RFInitData[i] );
}
ctout += GSMsprintf( ctout, "\n" );
#endif
#if 0 && defined (POLARIS_II)
/* The PLL Table - section: */
theFullReply[currentReply++] = ctout;
ctout += GSMsprintf( ctout, "PLL Call Table:\n" );
{
INT8 k;
for ( k = 0; k < SIZE_OF_PLLTABLE; k++ )
{
ctout += GSMsprintf( ctout, "%d ", listingPtr->PllCallTables[k] );
}
ctout += GSMsprintf( ctout, "\n" );
}
#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 )
{
STRING s1 = GSM_NEW_STRING( 300 );
STRING 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 )
{
STRING s1 = GSM_NEW_STRING( 300 );
STRING 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:
*/
static void CTDeallocateRAMCalData( void )
{
CalDataPtr = pCalDataInFlash;
GSMFree( HWCalibrationData );/* ... so that the RAM data may be freed. */
SetCTRAMCalDataFlag( FALSE );
#if defined (DEBUG)
CTSendStringResponse( "RAM cal data deallocated\n" );
GSMprintf( "CalDataPtr reset to flash loc 0x%lx\n", CalDataPtr );
#endif
return;
}
/*---------------------------------------------------------------------*/
/*
Name: SetCTRAMCalDataFlag
Desc: Sets the state of the flag used to decide if we need to make a
copy of the cal data in RAM for PTE
Params: RAMCopyExist
Returns: None
Caveats:
*/
void SetCTRAMCalDataFlag( BOOLEAN RAMCopyExist )
{
CTRAMCalDataFlag = RAMCopyExist;
return;
}
/*---------------------------------------------------------------------*/
/*
Name: GetCTRAMCalDataFlag
Desc: Returns the state of the flag used to decide if we need to make a
copy of the cal data in RAM for PTE
Params: None
Returns: Boolean flag
Caveats:
*/
BOOLEAN GetCTRAMCalDataFlag( void )
{
return CTRAMCalDataFlag;
}
/*---------------------------------------------------------------------*/
/*
Name: CTReadADCChannel
Desc: Reads value from the specified ADC channel.
Params: CTdummy8 is the channel number
Returns:
Caveats:
*/
static void CTReadADCChannel( void )
{
STRING s1 = GSM_NEW_STRING( 60 );
#if (defined (PSC2106_SSI) || defined (CSP2200_SSI) || defined (PSC2010)) && ! defined (PSC_USE_STM)
ADCChannel NumADCChannels = ADC_NUM_CHANNELS;
if ( CTdummy8 >= NumADCChannels )
{
CTSendStringResponse( "ReadADCChannel:WRONG:BAD_CHANNEL\n" );
CTdummy8 = 0;
return;
}
#else
GSMsprintf( s1, "ReadADCChannel:WRONG:Not supported on this platform\n" );
#endif
#if defined (PSC2010)
GSMsprintf( s1, "ReadADCChannel:RET:Channel %u, Value %u \n", CTdummy8, UHADCAutorange( ( ADCChannel ) CTdummy8 ) );
#elif (defined (PSC2106_SSI) || defined (CSP2200_SSI)) && ! defined (PSC_USE_STM)
GSMsprintf( s1, "ReadADCChannel:RET:Channel %u, Value %u mV\n", CTdummy8, UHBMSWGetADCRaw( ( ADCChannel ) CTdummy8 ) );
#endif
CTSendStringResponse( s1 );
GSMFree( s1 );
}
/*---------------------------------------------------------------------*/
/*
Name: CTGetADOffset
Desc: Show the offset for the given or current ADC channel as stored in CalDataPtr->
Params:
Returns:
Caveats:
*/
static void CTGetADOffset( void )
{
STRING s1 = GSM_NEW_STRING( 60 );
INT16 result;
if ( CTADChannelOffset.channelNo >= ADC_CAL_CHANNELS )
{
CTSendStringResponse( "GetADAdjust:WRONG:BAD_CHANNEL\n" );
CTADChannelOffset.channelNo = 0;
return;
}
if ( CTADChannelOffset.ADCLevel >= ADC_CAL_POINTS )
{
CTSendStringResponse( "GetADAdjust:WRONG:BAD_LEVEL\n" );
CTADChannelOffset.channelNo = 0;
return;
}
result = CalDataPtr->ADCcal[CTADChannelOffset.ADCLevel][CTADChannelOffset.channelNo];
GSMsprintf( s1, "GetADAdjust:RET:Channel %u, Level %u, Offset %d\n", CTADChannelOffset.channelNo, CTADChannelOffset.ADCLevel, result );
CTSendStringResponse( s1 );
GSMFree( s1 );
return;
}
/*---------------------------------------------------------------------*/
/*
Name: CTSetupSetADChannelOffset
Desc: Make it happen in framer
Params: CTADChannelOffset
Returns:
Caveats:
*/
static void CTSetupSetADChannelOffset( void )
{
if ( CTADChannelOffset.channelNo >= ADC_CAL_CHANNELS )
{
CTSendStringResponse( "SetADChannelAdjust:WRONG:BAD_CHANNEL\n" );
CTADChannelOffset.channelNo = 0;
CTADChannelOffset.offsetValue = 0;
CTADChannelOffset.ADCLevel = 0;
return;
}
CTDSPControl.Action = CTSetADChannelOffset;
CTDSPControl.ActionSheduled = TRUE;
}
/*---------------------------------------------------------------------*/
/*
Name: CTSetADChannelOffset
Desc: Set up given offset for given ADC channel in HWCalibration data
Params: -
Returns: -
Caveats:
Note: this doesn't store it in the NVM! Use StoreUhData or StoreHW.
*/
static void CTSetADChannelOffset( void )
{
char s1[60];
CTDSPControl.ActionSheduled = FALSE;
CalDataPtr->ADCcal[CTADChannelOffset.ADCLevel][CTADChannelOffset.channelNo] = CTADChannelOffset.offsetValue;
GSMsprintf( s1, "SetADChannelAdjust:DONE:Channel %u, Level %u, Value %d\n",
CTADChannelOffset.channelNo, CTADChannelOffset.ADCLevel, CTADChannelOffset.offsetValue );
CTSendStringResponse( s1 );
}
/*---------------------------------------------------------------------*/
/*
Name: CTDoBatteryMeasurement
Desc: Returns a number of samples of the ADC measurement for the battery.
Params: CTBattSetup
Returns:
Caveats:
*/
static void CTDoBatteryMeasurement( void )
{
#if defined (PSC2010)
/* Limit number of samples. User must reissue command for more samples.*/
if ( CTBattSetup.SampleNumber > CT_BATT_SAMPLES )
{
CTSendStringResponse( "DoBattMeas:WRONG:TOO_MANY_SAMPLES\n" );
return;
}
if ( !CTBattSetup.SampleDelay )
CTBattSetup.SampleDelay = 1; /* minimum delay */
if ( !CTBattSetup.SampleNumber )
CTBattSetup.SampleNumber = 1; /* minimum samples of 1 */
CTdummy8 = ( UINT8 ) CTBattSetup.SampleNumber;
CTBattSamples[CTBattSetup.SampleNumber] = UHADCAutorange( ADC_BATT_CHANNEL );
CTBattSetup.SampleNumber--;
GSMStartTimer( CT_MISC_TIMER, MSECS( CTBattSetup.SampleDelay ), CTBattSampling, NULL );
#else
CTSendStringResponse( "DoBattMeas:FAIL:Only PSC2010 supported" );
#endif
}
/*---------------------------------------------------------------------*/
/*
Name: CTBattSampling
Desc: Makes an ADC measurement on each timer sample period
Params: CTBattSamples
Returns:
Caveats:
*/
#if defined (PSC2010)
static void CTBattSampling( void *dummy )
{
/* Take the rest of the samples. */
UNUSED( dummy );
if ( CTBattSetup.SampleNumber > 0 )
{
CTBattSamples[CTBattSetup.SampleNumber] = UHADCAutorange( ADC_BATT_CHANNEL );
CTBattSetup.SampleNumber--;
GSMStartTimer( CT_MISC_TIMER, MSECS( CTBattSetup.SampleDelay ), CTBattSampling, NULL );
}
else
{
STRING s1 = GSM_NEW_STRING( 170 ); /* collect string for output to CT window */
STRING ctout = s1;
UINT16 CTdummyU16;
/* Create the output string. */
ctout += GSMsprintf( ctout, "DoBattMeas:RET:" );
for ( CTdummyU16 = CTdummy8; CTdummyU16 > 0; CTdummyU16-- )
{
ctout += GSMsprintf( ctout, "%u,", ( UINT16 ) CTBattSamples[CTdummyU16] );
}
/* Remove the trailing comma. */
ctout--;
GSMsprintf( ctout, "\n" );
CTSendStringResponse( s1 );
GSMFree( s1 );
}
}
#endif
/*---------------------------------------------------------------------*/
/*
Name: UseOldCalData
Desc: Loads sector 0 cal data into RAM
Params: None
Returns: Acknowledgement
Caveats:
*/
static void CTLoadCalDataFromFlash( void )
{
if ( dwCTUserCalDataAddr )
GSMmemcpy( CalDataPtr, ( UINT8 * ) dwCTUserCalDataAddr, sizeof( CALIBRATION_DATA ) );
else
GSMmemcpy( CalDataPtr, pCalDataInFlash, sizeof( CALIBRATION_DATA ) );
dwCTUserCalDataAddr = 0;
CTSendStringResponse( "LoadCalData:DONE" );
}
#if defined( BRITE4_RF )
/*---------------------------------------------------------------------*/
/*
Name: CTSetDCROffsetArea
Desc: Checks and acknowledges the setting of the bCTDCROffsetArea variables
Params: None
Returns: Acknowledgement
Caveats:
*/
static void CTSetDCROffsetArea( void )
{
if ( bCTDCROffsetArea[0] < NO_RF_BANDS && bCTDCROffsetArea[1] < DCROFFS_SUBBANDS )
CTSendStringResponse( "CTSetDCROffsetArea:DONE" );
else
{
bCTDCROffsetArea[0] = 0;
bCTDCROffsetArea[1] = 0;
CTSendStringResponse( "CTSetDCROffsetArea:FAIL:Bad Parameters." );
}
}
/*---------------------------------------------------------------------*/
/*
Name: CTSetDCROffsetData
Desc: Set the DCR data for I and Q, all gainsettins in the sub band specified by the SetDCROffsetArea command.
Params: None
Returns: Acknowledgement
Caveats:
*/
static void CTSetDCROffsetData( void )
{
INT16 *Src = wCTDCROffsetData,
*Dst = CalDataPtr->DCRRXOffset[bCTDCROffsetArea[0]][bCTDCROffsetArea[1]][0];
UINT16 wSize = sizeof( wCTDCROffsetData );
GSMmemcpy( Dst, Src, wSize );
CTSendStringResponse( "CTSetDCROffsetData:DONE" );
}
/*---------------------------------------------------------------------*/
/*
Name: CTShowDCROffsetsDec
Desc: Displays DCR offsets for the area set by SetDCROffsetArea command.
Params: None
Returns: Acknowledgement and data.
Caveats:
*/
static void CTShowDCROffsetsDec( void )
{
STRING pCTStringWhole = GSM_NEW_STRING( 150 );
STRING pCTStringBuild = pCTStringWhole;
UINT8 bDCRGainSetting;
if ( BShowInHex )
pCTStringBuild += GSMsprintf( pCTStringBuild, "CTShowDCROffsetHex:RET:" );
else
pCTStringBuild += GSMsprintf( pCTStringBuild, "CTShowDCROffsetDec:RET:" );
for ( bDCRGainSetting = 0; bDCRGainSetting < DCROFFS_GAIN_SETTINGS; bDCRGainSetting++ )
{
if ( BShowInHex )
pCTStringBuild += GSMsprintf( pCTStringBuild, "(0x%x, 0x%x), ", CalDataPtr->DCRRXOffset[bCTDCROffsetArea[0]][bCTDCROffsetArea[1]][bDCRGainSetting][0], CalDataPtr->DCRRXOffset[bCTDCROffsetArea[0]][bCTDCROffsetArea[1]][bDCRGainSetting][1] );
else
pCTStringBuild += GSMsprintf( pCTStringBuild, "(%u, %u), ", CalDataPtr->DCRRXOffset[bCTDCROffsetArea[0]][bCTDCROffsetArea[1]][bDCRGainSetting][0], CalDataPtr->DCRRXOffset[bCTDCROffsetArea[0]][bCTDCROffsetArea[1]][bDCRGainSetting][1] );
}
pCTStringBuild -= 2;
pCTStringBuild = "\n";
CTSendStringResponse( pCTStringWhole );
GSMFree( pCTStringWhole );
}
/*---------------------------------------------------------------------*/
/*
Name: CTShowDCROffsetsAll
Desc: Displays all DCR offsets
Params: None
Returns: Acknowledgement and data
Caveats:
*/
static void CTShowDCROffsetsAll( void )
{
bListDCROffsetsOnly = TRUE;
BufSize = DCROFFS_CAL_REPORT_BUF_SIZE;
CTSetUpAFullListing( ( CALIBRATION_DATA * ) CalDataPtr, "ShowDCROffsetAll:RET:" );
}
/*---------------------------------------------------------------------*/
/*
Name: CTShowDCROffsetsHex
Desc: Loads sector 0 cal data into RAM
Params: None
Returns: Acknowledgement
Caveats:
*/
static void CTShowDCROffsetsHex( void )
{
BShowInHex = TRUE;
CTShowDCROffsetsDec( );
BShowInHex = FALSE;
}
/*---------------------------------------------------------------------*/
/*
Name: CTShowDCRArea
Desc: Loads sector 0 cal data into RAM
Params: None
Returns: Acknowledgement
Caveats:
*/
static void CTShowDCRArea( void )
{
char sCTString[30];
GSMsprintf( sCTString, "CTShowDCROffsetArea:RET:%u,%u", bCTDCROffsetArea[0], bCTDCROffsetArea[1] );
CTSendStringResponse( ( INT8 * ) sCTString );
}
/*---------------------------------------------------------------------*/
/*
Name: CTReadDCROffset
Desc: Requests DSP for its DCR offset I and Q offsets
Params: None
Returns: Acknowledgement and results for I and Q phase
Caveats:
*/
/* OCR 3527 */
static void CTReadDCROffsetCallback( MEM_READ_RPT * DCROffsetRpt )
{
STRING sCTString = GSM_NEW_STRING( 30 );
UINT16 wDataIphase,
wDataQphase;
wDataIphase = DCROffsetRpt->read_word[0] & 8191;
wDataQphase = DCROffsetRpt->read_word[1] & 8191;
if ( DCROffsetRpt->valid )
GSMsprintf( sCTString, "ReadDCROffset:RET:%u,%u", wDataIphase, wDataQphase );
else
GSMsprintf( sCTString, "ReadDCROffset:FAILED" );
CTSendStringResponse( ( INT8 * ) sCTString );
GSMFree( sCTString );
}
/* OCR 3527 */
/*
Name: CTReadDCROffset
Desc: Requests DSP for its DCR offset I and Q offsets
Params: None
Returns: Acknowledgement and results for I and Q phase
Caveats:
*/
static void CTReadDCROffset( void )
{
const UINT32 dwAddr = 0xbc048; /* Trident DSP memory location for DCR offset */
CTSendStringResponse( "Quering DSP..." );
( void ) CTInternDSPPeekWithCallback( dwAddr, 2, CTReadDCROffsetCallback );
}
/*---------------------------------------------------------------------*/
/*
Name: CTEnableDSPDCROffset
Desc: Enables DSP reading of DCR offset
Params: None
Returns: Acknowledgement and results for I and Q phase
Caveats:
*/
/* OCR00003872 PTE, CTEnableDSPDCROffset( ) sends garbage response string
Variable sCTString removed (because of not accessed
*/
static void CTEnableDSPDCROffset( void )
{
const UINT32 dwAddr = 0x4198;/* Trident DSP memory location for DCR offset */
UINT16 wData = 0;
if (