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

📄 ctcaldat.c

📁 free sources for gsm
💻 C
📖 第 1 页 / 共 5 页
字号:
      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 );
   CTSendStringRespon

⌨️ 快捷键说明

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