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

📄 ctcaldat.c

📁 free sources for gsm
💻 C
📖 第 1 页 / 共 4 页
字号:

/*---------------------------- Local Functions: --------------------------*/


/*---------------------------------------------------------------------*/
/*
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().
*/
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" );
   }


/*---------------------------------------------------------------------*/
/*
Name: CTShowIMEI
Desc: Shows the content of the IMEI array in the hw calibration data.
Params:
Returns:
Caveats:
*/
static void CTShowIMEI( void )
   {
   UINT16 i;
   INT8 *s1 = GSM_NEW_ARRAY( INT8, 55 );  /* collect string for output to CT window */
   INT8 *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 );
   }

/*---------------------------------------------------------------------*/
/*
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];
   INT8 *s1 = GSM_NEW_ARRAY( INT8, 150 ); /* collect string for output to CT window */
   INT8 *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( ( INT8 * ) tokenList->Token[1] ) >= sizeof( CalDataPtr->Version ) )
      CTSendStringResponse( "SetCalDataVerText:FAIL:String too long.\n" );
   else
      {
      GSMstrncpy( ( INT8 * ) 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 )
   {
   INT8 *s1 = GSM_NEW_ARRAY( INT8, 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;
   INT8 *s1 = GSM_NEW_ARRAY( INT8, 55 );  /* collect string for output to CT window */
   INT8 *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 )
   {
   INT8 *s1 = GSM_NEW_ARRAY( INT8, 300 ); /* collect string for output to CT window */
   INT8 *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(  ) );
   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, "Last 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 )
   {
   INT8 *s1 = GSM_NEW_ARRAY( INT8, 300 );
   INT8 *ctout = s1;

   ctout += GSMsprintf( ctout, "ShowAFCDAC:RET:" );
   GSMsprintf( ctout, "%d\n", CalDataPtr->AFCDACStartValue );

   CTSendStringResponse( s1 );
   GSMFree( s1 );
   }

/* FFR/031126: BEGIN of SETAFCDAC modification */

/*---------------------------------------------------------------------*/
/*
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;

⌨️ 快捷键说明

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