XilinxProcessorIPLib/drivers/axiethernet/examples/avb/xavb_ptp_packets.c
char XAvb_ConvertDurationToLogMean(u16 fractionalVal) {

  char logMeanVal = 0;
  u8    numShifts = 0;

  /** just in case fractionalVal is not a power of 2, we'll
   *  only look at the most significant bit
   *  Count how many shifts it takes for most significant set bit
   *  to be in the highest (16th) bit location
   */
  while( !(fractionalVal & 0x8000) ) {
    fractionalVal <<= 1;
    numShifts++;
  }

  /** logMeanVal = 0 = 2^0 = 128/128 would give us a numShifts
   *  result of 8, so 8 will be our base
   */
  logMeanVal = 8 - numShifts;

  return logMeanVal;
}
/****************************************************************************/
/**
*
* A function to convert a fraction of 128 value that is compatible with
* Signalling data into a logMean (power of 2) value;
*
* @param  fractionalVal is the Signalling data value that is to be converted

* @return fractionalVal represented as logMean (power of 2) value
*
* @note   None.
*
*****************************************************************************/
A function to convert a fraction of 128 value that is compatible with
Signalling data into a logMean (power of 2) value.
A function to convert a fraction of 128 value that is compatible with Signalling data into a logMean ( power of 2 ) value .
char XAvb_ConvertDurationToLogMean(u16 fractionalVal) {
  char logMeanVal = 0;
  u8    numShifts = 0;
  while( !(fractionalVal & 0x8000) ) {
    fractionalVal <<= 1;
    numShifts++;
  }
  logMeanVal = 8 - numShifts;
  return logMeanVal;
}
char XAvb_ConvertDurationToLogMean ( u16 fractionalVal ) { char logMeanVal = 0 ; u8 numShifts = 0 ; while ( ! ( fractionalVal & 0x8000 ) ) { fractionalVal <<= 1 ; numShifts ++ ; } logMeanVal = 8 - numShifts ; return logMeanVal ; }
A function to convert a fraction of 128 value that is compatible with
Signalling data into a logMean (power of 2) value;
A function to convert a fraction of 128 value that is compatible with Signalling data into a logMean ( power of 2 ) value ;
/** just in case fractionalVal is not a power of 2, we'll
   *  only look at the most significant bit
   *  Count how many shifts it takes for most significant set bit
   *  to be in the highest (16th) bit location
   */ /** logMeanVal = 0 = 2^0 = 128/128 would give us a numShifts
   *  result of 8, so 8 will be our base
   */