XilinxProcessorIPLib/drivers/axiethernet/examples/avb/xavb_rtc_sync.c
u32 XAvb_CaptureNanoSec(u32 BaseAddress, u32 PtpFrameBaseAddr) {
  u32 Timestamp   = 0;
  u32 BufferWordA = 0;
  u32 BufferWordB = 0;

  /** The timestamp is located over several 32-bit Words of the PTP frame buffer
   *  Read the relevant Words containing the ns timestamp: */
  BufferWordA = XAvb_ReadPtpBuffer(BaseAddress,
                                    PtpFrameBaseAddr,
                                    XAVB_PTP_RX_PKT_TIMESTAMP_MID_OFFSET);

  BufferWordB = XAvb_ReadPtpBuffer(BaseAddress,
                                    PtpFrameBaseAddr,
                                    XAVB_PTP_RX_PKT_TIMESTAMP_LOWER_OFFSET);

  /** Now re-arrange the data from the Words to obtain the required ns Timestamp
   *  in binrary format */
  Timestamp = (XAvb_ReorderWord(BufferWordA)<<16) |
              (XAvb_ReorderWord(BufferWordB)>>16);

  return Timestamp;

}
/*****************************************************************************/
/***
*
* A function to capture the nanosecond timestamp field from a received PTP frame
*
* @param  BaseAddress is the base address of the device
* @param  PtpFrameBaseAddr is the base address of the received Announce Packet
*         in the Rx PTP Packet Buffer
*
* @return The Nanoseconds Timestamp field, captured from an Rx PTP frame
*
* @note   None.
*
*****************************************************************************/
A function to capture the nanosecond timestamp field from a received PTP frame
A function to capture the nanosecond timestamp field from a received PTP frame
u32 XAvb_CaptureNanoSec(u32 BaseAddress, u32 PtpFrameBaseAddr) {
  u32 Timestamp   = 0;
  u32 BufferWordA = 0;
  u32 BufferWordB = 0;
  BufferWordA = XAvb_ReadPtpBuffer(BaseAddress,
                                    PtpFrameBaseAddr,
                                    XAVB_PTP_RX_PKT_TIMESTAMP_MID_OFFSET);
  BufferWordB = XAvb_ReadPtpBuffer(BaseAddress,
                                    PtpFrameBaseAddr,
                                    XAVB_PTP_RX_PKT_TIMESTAMP_LOWER_OFFSET);
  Timestamp = (XAvb_ReorderWord(BufferWordA)<<16) |
              (XAvb_ReorderWord(BufferWordB)>>16);
  return Timestamp;
}
u32 XAvb_CaptureNanoSec ( u32 BaseAddress , u32 PtpFrameBaseAddr ) { u32 Timestamp = 0 ; u32 BufferWordA = 0 ; u32 BufferWordB = 0 ; BufferWordA = XAvb_ReadPtpBuffer ( BaseAddress , PtpFrameBaseAddr , XAVB_PTP_RX_PKT_TIMESTAMP_MID_OFFSET ) ; BufferWordB = XAvb_ReadPtpBuffer ( BaseAddress , PtpFrameBaseAddr , XAVB_PTP_RX_PKT_TIMESTAMP_LOWER_OFFSET ) ; Timestamp = ( XAvb_ReorderWord ( BufferWordA ) << 16 ) | ( XAvb_ReorderWord ( BufferWordB ) >> 16 ) ; return Timestamp ; }
A function to capture the nanosecond timestamp field from a received PTP frame
A function to capture the nanosecond timestamp field from a received PTP frame
/** The timestamp is located over several 32-bit Words of the PTP frame buffer
   *  Read the relevant Words containing the ns timestamp: */ /** Now re-arrange the data from the Words to obtain the required ns Timestamp
   *  in binrary format */