XilinxProcessorIPLib/drivers/axiethernet/examples/avb/xavb_ptp_packets.c
void XAvb_WriteToMultipleTxPtpFrames(u32 BaseAddress,
                                     u32 PtpFieldAddress,
                                     u32 Data,
                                     u32 DataBitEnable,
                                     u8  BufferEnable) {
  u32 PtpBufferPointer = 0;
  u32 LocalData        = 0;
  u32 LocalAddr        = 0;

  /** Write to all 8 PTP frame templates */
  for (PtpBufferPointer= 0; PtpBufferPointer < 8; PtpBufferPointer++) {

    /** Only write to selected buffers */
    if ( ((BufferEnable >> PtpBufferPointer) & 0x1) == 0x1) {

      LocalAddr = (PtpBufferPointer<<8) + XAVB_PTP_TX_SYNC_OFFSET;

      /** Read the current value */
      LocalData = XAvb_ReadPtpBuffer(BaseAddress,
                                      LocalAddr,
                                      PtpFieldAddress);

      /** Only change the selected data bits */
      LocalData = LocalData | (Data & DataBitEnable);

      /** Write the updated value */
      XAvb_WritePtpBuffer(BaseAddress,
                           LocalAddr,
                           PtpFieldAddress,
                           LocalData);
#ifdef DEBUG_XAVB_LEVEL3
      xil_printf("\r\nWriteToMultipleTxPtpFrames read/mod(PtpBufferPointer = %x) ", PtpBufferPointer);
      xil_printf("\r\n PTPAddress = %x ", LocalAddr);
      xil_printf("\r\n PtpFieldAddress = %x ", PtpFieldAddress);
      xil_printf("\r\n LocalData = %x ", LocalData);
#endif
    }
  }
}
/****************************************************************************/
/**
*
* A function to write common data (eg the Source Address) to all PTP frames
* stored in the Tx PTP Packet buffer
*
* @param  BaseAddress is the base address of the device
* @param  PtpFieldAddress is the offset address of the relevant field in PTP
*         frames.
* @param  Data is the common data to be written to all Tx PTP frame templates
* @param  DataBitEnable allows only selected bits of the 32-bit Data word to
*         be modified.
* @param  BufferEnable allows the selected buffer to be selected: there are 8
*         PTP buffers - these are encoded as one-hot.  For example, 0x3F will
*         write the selected data to the first 6 buffers only.
*
* @return None.  But the Tx PTP Packet Buffer is written to as requested
*
* @note   None.
*
*****************************************************************************/
A function to write common data  to all PTP frames
stored in the Tx PTP Packet buffer
A function to write common data to all PTP frames stored in the Tx PTP Packet buffer
void XAvb_WriteToMultipleTxPtpFrames(u32 BaseAddress,
                                     u32 PtpFieldAddress,
                                     u32 Data,
                                     u32 DataBitEnable,
                                     u8  BufferEnable) {
  u32 PtpBufferPointer = 0;
  u32 LocalData        = 0;
  u32 LocalAddr        = 0;
  for (PtpBufferPointer= 0; PtpBufferPointer < 8; PtpBufferPointer++) {
    if ( ((BufferEnable >> PtpBufferPointer) & 0x1) == 0x1) {
      LocalAddr = (PtpBufferPointer<<8) + XAVB_PTP_TX_SYNC_OFFSET;
      LocalData = XAvb_ReadPtpBuffer(BaseAddress,
                                      LocalAddr,
                                      PtpFieldAddress);
      LocalData = LocalData | (Data & DataBitEnable);
      XAvb_WritePtpBuffer(BaseAddress,
                           LocalAddr,
                           PtpFieldAddress,
                           LocalData);
#ifdef DEBUG_XAVB_LEVEL3
      xil_printf("\r\nWriteToMultipleTxPtpFrames read/mod(PtpBufferPointer = %x) ", PtpBufferPointer);
      xil_printf("\r\n PTPAddress = %x ", LocalAddr);
      xil_printf("\r\n PtpFieldAddress = %x ", PtpFieldAddress);
      xil_printf("\r\n LocalData = %x ", LocalData);
#endif
    }
  }
}
void XAvb_WriteToMultipleTxPtpFrames ( u32 BaseAddress , u32 PtpFieldAddress , u32 Data , u32 DataBitEnable , u8 BufferEnable ) { u32 PtpBufferPointer = 0 ; u32 LocalData = 0 ; u32 LocalAddr = 0 ; for ( PtpBufferPointer = 0 ; PtpBufferPointer < 8 ; PtpBufferPointer ++ ) { if ( ( ( BufferEnable >> PtpBufferPointer ) & 0x1 ) == 0x1 ) { LocalAddr = ( PtpBufferPointer << 8 ) + XAVB_PTP_TX_SYNC_OFFSET ; LocalData = XAvb_ReadPtpBuffer ( BaseAddress , LocalAddr , PtpFieldAddress ) ; LocalData = LocalData | ( Data & DataBitEnable ) ; XAvb_WritePtpBuffer ( BaseAddress , LocalAddr , PtpFieldAddress , LocalData ) ; #ifdef DEBUG_XAVB_LEVEL3 xil_printf ( " \r \n " , PtpBufferPointer ) ; xil_printf ( " \r \n " , LocalAddr ) ; xil_printf ( " \r \n " , PtpFieldAddress ) ; xil_printf ( " \r \n " , LocalData ) ; #endif } } }
A function to write common data (eg the Source Address) to all PTP frames
stored in the Tx PTP Packet buffer
A function to write common data ( eg the Source Address ) to all PTP frames stored in the Tx PTP Packet buffer
/** Write to all 8 PTP frame templates */ /** Only write to selected buffers */ /** Read the current value */ /** Only change the selected data bits */ /** Write the updated value */