emacps: xemacps_ieee1588_example.c File Reference

| emacps Xilinx SDK Drivers API Documentation

- Overview
- Data Structures
- APIs
- File List
- Examples

Functions
xemacps_ieee1588_example.c File Reference

## Overview

This is top level c file for the IEEE1588 (PTP) standalone example.

It has the following functionalities. It uses SCUTimer to transmit PTP packets at regular intervals.

- Contains the main routine for the PTP protocol example.
- Initializes the SCUGIC, SCUTimer
- Initializes the EmacPs hardware for packet transfer.
- Initializes the buffer descriptors for the PTP packet transfer.
- Initializes and handles the buffers that receive the PTP packets and whose address goes in the buffer descriptors.
- Contains the interrupt handlers for Ethernet Tx and Ethernet Rx.
- Contains the Timer interrupt handlers.
- Implements the top level state machine for the PTP protocol.
- Contains routines that initiate the PTP Tx.
- Initializes the some fields in the PTP Tx packets. These fields are fixed and its entries do not change with time.
- Contains various helper routines, e.g. routines for endian conversion.

    MODIFICATION HISTORY:

    Ver   Who  Date     Changes

    1.00a asa  09/16/11 First release based on the AVB driver.
    1.01a asa  03/03/12 Support for Zynq is added. BD handling is changed.
    3.3   asa  05/19/16 Fix for CR#951152. Made following changes.

    Removed code specific for PEEP.
    Ensured that each buffer in RxBuf array is cache
                          line aligned. The Rxbuf array itself is made cache
                          line aligned.
    The XEMACPS_PACKET_LEN is changed from 1538 to 1598.
                          Though the packet length can never be 1598 for
                          non-jumbo ethernet packets, it is changes to ensure
                          that each Rx buffer becomes cache line aligned.
                          If a Rx buffer is not cache line aligned, the
                          A9 based invalidation logic flushes the first cache
                          line to ensure that other data faling in this cache
                          line are not lost when the buffer in invalidated
                          upon reception of a packet. But that will also mean
                          the data received in this cache line is lost.
                          By making this change we always ensure that when an
                          invalidation happens no flushing takes place and no
                          incoming data is lost.
    Changes made not to disable and enable back the MMU
                          when we change the attribute of BD space to make it
                          strongly ordered.
          ms   04/05/17   Added tabspace for return statements in functions for
                          proper documentation while generating doxygen.
    3.9   hk   03/20/19   Fix alignment pragmas for IAR compiler.

## Functions
int | XEmacPs_InitScuTimer (void)
| This function initializes the SCUTimer. More...
void | XEmacPs_PHYSetup (XEmacPs *EmacPsInstancePtr)
| This function configures the PHY with proper speed settings and set up the PHY to be used subsequently. More...
int | XEmacPs_SetupIntrSystem (XScuGic *IntcInstancePtr, XEmacPs *EmacPsInstancePtr, XScuTimer *TimerInstancePtr, u16 EmacPsIntrId, u16 TimerIntrId)
| This function sets up interrupts. More...
void | XEmacPs_RunIEEE1588Protocol (XEmacPs *EmacInstance)
| This function implements the main state machine. More...
void | XEmacPs_InitializeEmacPsDma (XEmacPs_Ieee1588 *InstancePntr)
| This function initializes the EmacPs DMA buffer descriptors. More...
void | XEmacPs_InitializeProtocolData (XEmacPs_Ieee1588 *InstancePntr)
| This function does various initializations. More...
void | XEmacPs_HandleRecdPTPPacket (XEmacPs_Ieee1588 *InstancePtr)
| This function is processes the received packets. More...
void | XEmacPs_PtpTxInterruptHandler (XEmacPs_Ieee1588 *InstancePtr)
| This function is the Tx Done interrupt callback invoked from the EmacPs driver. More...
void | XEmacPs_SetDfltTxFrms (XEmacPs_Ieee1588 *InstancePtr)
| This function is used to populate the PTP Tx buffers. More...
u8 | XEmacPs_GetMsgType (u8 *PacketBuf)
| This function extracts PTP messgae type information from the PTP packet. More...
void | XEmacPs_PtpTxDoFurtherProcessing (XEmacPs_Ieee1588 *InstancePtr, u8 *PacketBuf)
| This function is invoked from the TxDone callback. More...
void | XEmacPs_TimerInterruptHandler (XEmacPs_Ieee1588 *InstancePtr)
| This function is the timer ISR that is invoked every 500 mseconds. More...
void | XEmacPs_PtpErrorInterruptHandler (XEmacPs_Ieee1588 *InstancePtr, u8 Direction, u32 ErrorWord)
| This function is the Error interrupt callback invoked from the EmacPs driver. More...
int | main (void)
| This is the main function for the IEEE1588 (PTP) standalone example. More...
unsigned int | XEmacPs_TsuCalcClk (u32 Freq)
| Calculate clock configuration register values for indicated input clock. More...
unsigned long | XEmacPs_DetectPHY (XEmacPs *EmacPsInstancePtr)
| This function finds out if a PHY is connected or not and if connected what is the PHY address of the connected PHY. More...
void | XEmacPs_ResetIeee1588Protocol (XEmacPs_Ieee1588 *InstancePtr)
| This function is used when PTP node is initialized once again. More...
void | XEmacPs_PtpRxInterruptHandler (XEmacPs_Ieee1588 *InstancePtr)
| This function is the EmacPs Rx interrupt callback invoked from the EmacPs driver. More...
int | XEmacPs_PtpTxPacket (XEmacPs_Ieee1588 *InstancePtr, u8 *PacketBuf, int PacketLen)
| This function is initiates a PTP Tx. More...
u32 | XEmacPs_IsRxFramePTP (u8 *PacketBuf)
| This function extracts length/type information from the Ethernet packet. More...
u32 | XEmacPs_ComparePortIdentity (XEmacPs_PortIdentity Identity1, XEmacPs_PortIdentity Identity2)
| A function to compare two PortIdentity values. More...
u32 | XEmacPs_CompareClockIdentity (XEmacPs_ClockIdentity Identity1, XEmacPs_ClockIdentity Identity2)
| A function to compare two ClockIdentity values. More...
void | XEmacPs_GetPortIdentity (u8 *PacketBuf, XEmacPs_PortIdentity *portID)
| A function to extract portIdentity information from a received PTP frame. More...
u16 | XEmacPs_GetSequenceId (u8 *PacketBuf)
| A function to extract SequenceId information from a received PTP frame. More...
u16 | XEmacPs_IncSequenceId (u8 *PacketBuf)
| A function to increment sequence ID in a PTP frames. More...
u32 | XEmacPs_htonll (unsigned long long int n)
| A function to do endian conversion for long long int type. More...
u32 | XEmacPs_ntohll (long long int n)
| A function to do endian conversion for long long int type. More...

## Function Documentation

int main | ( | void |  | ) |

This is the main function for the IEEE1588 (PTP) standalone example.

It calls routines to initialize ScuTimer and EmacPs. It enables interrupts at the end of all initializations and calls XEmacPs_RunIEEE1588Protocol that runs the protocol state machine.

Parameters

  None. |

Returns
  - XST_SUCCESS to indicate success.
  - XST_FAILURE to indicate failure

Note
  None.

References XEmacPs_Config::BaseAddress, XEMACPS_1588_INC_OFFSET, XEmacPs_CfgInitialize(), XEmacPs_InitScuTimer(), XEmacPs_LookupConfig(), XEmacPs_PHYSetup(), XEMACPS_PROMISC_OPTION, XEmacPs_PtpErrorInterruptHandler(), XEmacPs_PtpRxInterruptHandler(), XEmacPs_PtpTxInterruptHandler(), XEmacPs_RunIEEE1588Protocol(), XEmacPs_SetHandler(), XEmacPs_SetMacAddress(), XEmacPs_SetMdioDivisor(), XEmacPs_SetOperatingSpeed(), XEmacPs_SetOptions(), XEmacPs_SetupIntrSystem(), XEmacPs_TsuCalcClk(), and XEmacPs_WriteReg.

u32 XEmacPs_CompareClockIdentity | ( | XEmacPs_ClockIdentity | Identity1,
|  | XEmacPs_ClockIdentity | Identity2
| ) |  |

A function to compare two ClockIdentity values.

Parameters

  Identity1 | is the first ClockIdentity to be compared
  Identity2 | is the second ClockIdentity to be compared

Returns
  - 1 if the two values are equal
  - 0 if not equal

Note
  None.

Referenced by XEmacPs_DecodeRxAnnounceFrame().

u32 XEmacPs_ComparePortIdentity | ( | XEmacPs_PortIdentity | Identity1,
|  | XEmacPs_PortIdentity | Identity2
| ) |  |

A function to compare two PortIdentity values.

Parameters

  Identity1 | is the first sourcePortIdentity to be compared
  Identity2 | is the second sourcePortIdentity to be compared

Returns
  - 1 if the two values are equal
  - 0 if not equal

Note
  None.

Referenced by XEmacPs_DecodeRxAnnounceFrame(), XEmacPs_DecodeRxFollowUp(), XEmacPs_DecodeRxPDelayResp(), XEmacPs_DecodeRxPDelayRespFollowUp(), and XEmacPs_DecodeRxSync().

unsigned long XEmacPs_DetectPHY | ( | XEmacPs * | EmacPsInstancePtr | ) |

This function finds out if a PHY is connected or not and if connected what is the PHY address of the connected PHY.

Parameters

  EmacPsInstancePtr | is a pointer to the instance of the EmacPs.

Returns
  - Detected PHY address if successful.
  - 0 if no PHY is connected.

Note
  None.

References XEmacPs_PhyRead().

Referenced by XEmacPs_PHYSetup().

u8 XEmacPs_GetMsgType | ( | u8 * | PacketBuf | ) |

This function extracts PTP messgae type information from the PTP packet.

Parameters

  PacketBuf | contains the Ethernet packet.

Returns
  None.

Note
  None.

Referenced by XEmacPs_HandleRecdPTPPacket(), and XEmacPs_PtpTxDoFurtherProcessing().

void XEmacPs_GetPortIdentity | ( | u8 * | PacketBuf,
|  | XEmacPs_PortIdentity * | portID
| ) |  |

A function to extract portIdentity information from a received PTP frame.

This can be any portIdentity field (header portIdentity, requestingPortIdentity etc...)

Parameters

  PacketBuf | contains the PTP buffer from which the portIdentity is to be extracted.
  portID | is the address of type XEmacPs_PortIdentity is which the extracted port identity is put.

Returns
  None.

Note
  None.

Referenced by XEmacPs_DecodeRxFollowUp(), XEmacPs_DecodeRxPDelayResp(), XEmacPs_DecodeRxPDelayRespFollowUp(), XEmacPs_DecodeRxSync(), XEmacPs_ReadAnnounceFrame(), XEmacPs_SendPDelayResp(), and XEmacPs_SendPDelayRespFollowUp().

u16 XEmacPs_GetSequenceId | ( | u8 * | PacketBuf | ) |

A function to extract SequenceId information from a received PTP frame.

Parameters

  PacketBuf | contains the PTP buffer from which the portIdentity is to be extracted.

Returns
  The extracted sequence ID.

Note
  None.

Referenced by XEmacPs_DecodeRxFollowUp(), XEmacPs_DecodeRxPDelayResp(), XEmacPs_DecodeRxPDelayRespFollowUp(), XEmacPs_DecodeRxSync(), XEmacPs_PtpTxDoFurtherProcessing(), XEmacPs_SendPDelayResp(), and XEmacPs_SendPDelayRespFollowUp().

void XEmacPs_HandleRecdPTPPacket | ( | XEmacPs_Ieee1588 * | InstancePtr | ) |

This function is processes the received packets.

This is invoked from XEmacPs_RunIEEE1588Protocol. It copies the received packet from the RxBuf to the corresponding buffer in XEmacPs_Ieee1588 structure instance.It then identifies the type of PTP packet received and calls the corresponding handlers to do further processing. It then frees the corresponding BD, does a allocation of the freed BD and populates the BD with appropriate buffer address (RxBuf).

Parameters

  InstancePntr | is a pointer to the instance of the XEmacPs_Ieee1588.

Returns
  None.

Note
  None.

References XEmacPs_BdGetBufAddr, XEmacPs_BdGetLength, XEmacPs_BdRingAlloc(), XEmacPs_BdRingFree(), XEmacPs_BdRingFromHwRx(), XEmacPs_BdRingGetFreeCnt, XEmacPs_BdRingNext, XEmacPs_BdRingToHw(), XEmacPs_BdSetAddressRx, XEmacPs_DecodeRxAnnounceFrame(), XEmacPs_DecodeRxFollowUp(), XEmacPs_DecodeRxPDelayResp(), XEmacPs_DecodeRxPDelayRespFollowUp(), XEmacPs_DecodeRxSignaling(), XEmacPs_DecodeRxSync(), XEmacPs_GetMsgType(), XEmacPs_GetRxRing, XEmacPs_GetTxRing, XEmacPs_IsRxFramePTP(), XEMACPS_RXBUF_NEW_MASK, XEMACPS_RXBUF_WRAP_MASK, and XEmacPs_SendPDelayResp().

Referenced by XEmacPs_RunIEEE1588Protocol().

u32 XEmacPs_htonll | ( | unsigned long long int | n | ) |

A function to do endian conversion for long long int type.

This is for little to big endian conversion.

Parameters

  Parameter | whose endian conversion is needed

Returns
  The endian converted value.

Note
  None.

Referenced by XEmacPs_ntohll().

u16 XEmacPs_IncSequenceId | ( | u8 * | PacketBuf | ) |

A function to increment sequence ID in a PTP frames.

It first extracts the sequence ID and then increments and puts it back in the PTP frame.

Parameters

  PacketBuf | contains the PTP buffer from which the portIdentity is to be extracted.

Returns
  The incremented sequence ID.

Note
  None.

Referenced by XEmacPs_MasterSendAnnounce(), XEmacPs_MasterSendSync(), and XEmacPs_SendPDelayReq().

void XEmacPs_InitializeEmacPsDma | ( | XEmacPs_Ieee1588 * | InstancePntr | ) |

This function initializes the EmacPs DMA buffer descriptors.

16 BDs are used on the Tx path and 16 on the Rx path. On the Rx path a 2-dimensional array RxBuf[16][1540] is used. The last byte in each of the buffers is used to mark whether the RxBuf is already submitted or not. For example, if the location RxBuf[1][1539] is 1, then it means the RxBuf[1] is already submitted. During initialization, for 16 BDs, 16 RxBufs are submitted (RxBuf[0, RxBuf[1], ... RxBuf[15]]) and the corresponding entries RxBuf[0][1539], RxBuf[1][1539], ... RxBuf[15][1539] are marked as 1. On the Rx path, all 16 BDs are submitted to the hardware. Once that is done, the timer is started and so is the EmacPs.

Parameters

  EmacPsInstancePtr | is a pointer to the instance of the EmacPs.

Returns
  None.

Note
  None.

References XEmacPs_BdClear, XEmacPs_BdRingAlloc(), XEmacPs_BdRingClone(), XEmacPs_BdRingCreate(), XEmacPs_BdRingNext, XEmacPs_BdRingToHw(), XEmacPs_BdSetAddressRx, XEmacPs_BdSetLast, XEmacPs_BdSetStatus, XEmacPs_GetRxRing, XEmacPs_GetTxRing, XEMACPS_RECV, XEMACPS_SEND, XEmacPs_Start(), and XEMACPS_TXBUF_USED_MASK.

Referenced by XEmacPs_RunIEEE1588Protocol().

void XEmacPs_InitializeProtocolData | ( | XEmacPs_Ieee1588 * | InstancePntr | ) |

This function does various initializations.

- It initializes the Local Port Identity. Clock Identity is initialized with 000A35FFFE010203 and port number as 1.
- It initializes some of the fields of Tx PTP buffers. These fields remain constant over time and hence are initialized at one place.
- It initializes signalling frame data. Since signalling frames are not implemented, the entries in the structure SignallingFrameData are hard coded.
- The entries in the structure instance PtpCounters are initialized to 0.
- The variable PtpIsRunning is made as 1 so that PTP packets Tx can be initiated in the Timer ISR.
- The PTP node is made as Master to start with.
- The Peer Ieee1588v2 capability is made as 0 which means the peer is not Ieee1588v2 capable.

Parameters

  InstancePntr | is a pointer to the instance of the XEmacPs_Ieee1588.

Returns
  None.

Note
  None.

References XEmacPs_BecomeRtcMaster(), XEmacPs_ChangePeerIeee1588v2Capability(), XEmacPs_DecodeTxAnnounceFrame(), and XEmacPs_SetDfltTxFrms().

Referenced by XEmacPs_ResetIeee1588Protocol(), and XEmacPs_RunIEEE1588Protocol().

int XEmacPs_InitScuTimer | ( | void |  | ) |

This function initializes the SCUTimer.

Parameters

  None. |

Returns
  - XST_SUCCESS to indicate success.
  - XST_FAILURE to indicate failure

Note
  None.

Referenced by main(), and XEmacPs_PtpErrorInterruptHandler().

u32 XEmacPs_IsRxFramePTP | ( | u8 * | PacketBuf | ) |

This function extracts length/type information from the Ethernet packet.

Parameters

  PacketBuf | contains the Ethernet packet.

Returns
  None.

Note
  None.

Referenced by XEmacPs_HandleRecdPTPPacket().

u32 XEmacPs_ntohll | ( | long long int | n | ) |

A function to do endian conversion for long long int type.

This is for big to little endian conversion.

Parameters

  Parameter | whose endian conversion is needed

Returns
  The endian converted value.

Note
  None.

References XEmacPs_htonll().

void XEmacPs_PHYSetup | ( | XEmacPs * | EmacPsInstancePtr | ) |

This function configures the PHY with proper speed settings and set up the PHY to be used subsequently.

Parameters

  EmacPsInstancePtr | is a pointer to the instance of the EmacPs.

Returns
  None.

Note
  None.

References XEmacPs_DetectPHY(), XEmacPs_PhyRead(), and XEmacPs_PhyWrite().

Referenced by main(), and XEmacPs_PtpErrorInterruptHandler().

void XEmacPs_PtpErrorInterruptHandler | ( | XEmacPs_Ieee1588 * | InstancePtr,
|  | u8 | Direction,
|  | u32 | ErrorWord
| ) |  |

This function is the Error interrupt callback invoked from the EmacPs driver.

Parameters

  InstancePntr | is a pointer to the instance of the XEmacPs_Ieee1588.
  Direction | can be Rx or Tx
  ErrorWord | gives further information about the exact error type.

Returns
  None.

Note
  This function needs to be revisited. Probably upon an error we need to reset the EmacPs hardware and reinitialize the BDs. However further study is needed. Whether for all errors we need to reset or some errors can be ignored.

References XEmacPs_Config::BaseAddress, XEMACPS_1588_INC_OFFSET, XEmacPs_CfgInitialize(), XEmacPs_InitScuTimer(), XEmacPs_LookupConfig(), XEmacPs_PHYSetup(), XEMACPS_PROMISC_OPTION, XEmacPs_PtpRxInterruptHandler(), XEmacPs_PtpTxInterruptHandler(), XEmacPs_RunIEEE1588Protocol(), XEmacPs_SetHandler(), XEmacPs_SetMacAddress(), XEmacPs_SetMdioDivisor(), XEmacPs_SetOperatingSpeed(), XEmacPs_SetOptions(), XEmacPs_SetupIntrSystem(), XEmacPs_Stop(), XEmacPs_TsuCalcClk(), and XEmacPs_WriteReg.

Referenced by main().

void XEmacPs_PtpRxInterruptHandler | ( | XEmacPs_Ieee1588 * | InstancePtr | ) |

This function is the EmacPs Rx interrupt callback invoked from the EmacPs driver.

Here we set the flag PtpNewPktRecd to true. This flag is checked for in the function XEmacPs_RunIEEE1588Protocol for further processing of packets.

Parameters

  InstancePntr | is a pointer to the instance of the XEmacPs_Ieee1588.

Returns
  None.

Note
  None.

Referenced by main(), and XEmacPs_PtpErrorInterruptHandler().

void XEmacPs_PtpTxDoFurtherProcessing | ( | XEmacPs_Ieee1588 * | InstancePtr,
|  | u8 * | PacketBuf
| ) |  |

This function is invoked from the TxDone callback.

For sync frame it obtains the time stamp and populates the FollowUp frame Tx buffer. For PDelayReq and PDelayResp frames it obtains the time stamp and stores it is appropriate buffers.

Parameters

  InstancePntr | is a pointer to the instance of the XEmacPs_Ieee1588.
  PacketBuf | which contains the buffer just transmitted

Returns
  None.

Note
  None.

References XEmacPs_GetMsgType(), XEmacPs_GetSequenceId(), XEMACPS_PTP_TXNANOSEC_OFFSET, XEMACPS_PTP_TXSEC_OFFSET, XEMACPS_PTPP_TXNANOSEC_OFFSET, XEMACPS_PTPP_TXSEC_OFFSET, and XEmacPs_ReadReg.

Referenced by XEmacPs_PtpTxInterruptHandler().

void XEmacPs_PtpTxInterruptHandler | ( | XEmacPs_Ieee1588 * | InstancePtr | ) |

This function is the Tx Done interrupt callback invoked from the EmacPs driver.

For some PTP packets, upon getting a Tx done interrupt some actions need to be taked. For example, when SYNC frame is successfully sent and Tx Done interrupt is received, the time stamp for the SYNC frame needs to be stored. For all such processing the function XEmacPs_PtpTxDoFurtherProcessing is invoked from here.

Parameters

  InstancePntr | is a pointer to the instance of the XEmacPs_Ieee1588.

Returns
  None.

Note
  None.

References XEmacPs_BdGetBufAddr, XEmacPs_BdGetLength, XEmacPs_BdRingFree(), XEmacPs_BdRingFromHwTx(), XEmacPs_BdRingNext, XEmacPs_GetTxRing, XEmacPs_PtpTxDoFurtherProcessing(), XEMACPS_TXBUF_USED_MASK, and XEMACPS_TXBUF_WRAP_MASK.

Referenced by main(), and XEmacPs_PtpErrorInterruptHandler().

int XEmacPs_PtpTxPacket | ( | XEmacPs_Ieee1588 * | InstancePtr,
|  | u8 * | PacketBuf,
|  | int | PacketLen
| ) |  |

This function is initiates a PTP Tx.

This is called from various places.

Parameters

  InstancePntr | is a pointer to the instance of the XEmacPs_Ieee1588.
  PacketBuf | is the buffer that contains the packet to be Txed
  PacketLen | is the length of the packet to be Txed.

Returns
  None.

Note
  None.

References XEmacPs_BdClearTxUsed, XEmacPs_BdRingAlloc(), XEmacPs_BdRingToHw(), XEmacPs_BdSetAddressTx, XEmacPs_BdSetLast, XEmacPs_BdSetLength, XEmacPs_GetTxRing, XEmacPs_ReadReg, XEmacPs_Transmit, and XEMACPS_TXSR_OFFSET.

Referenced by XEmacPs_MasterSendAnnounce(), XEmacPs_MasterSendFollowUp(), XEmacPs_RunIEEE1588Protocol(), and XEmacPs_SendPDelayRespFollowUp().

void XEmacPs_ResetIeee1588Protocol | ( | XEmacPs_Ieee1588 * | InstancePtr | ) |

This function is used when PTP node is initialized once again.

Parameters

  InstancePntr | is a pointer to the instance of the XEmacPs_Ieee1588.

Returns
  None.

Note
  This function needs to be revisited as it is partially developed as of now..

References XEmacPs_InitializeProtocolData().

void XEmacPs_RunIEEE1588Protocol | ( | XEmacPs * | EmacInstance | ) |

This function implements the main state machine.

After initializing the EmacPs DMA and initializing some protocol data structures it enters into a while(1) loop. Here it repeatedly checks if a new packet has been received or not. If received (the ISR marks the variable PtpNewPktRecd as true), then it calls XEmacPs_HandleRecdPTPPacket for further processing. Similarly if a packet needs to be sent out (as marked by the bits in variable PTPSendPacket, it sends it out.

Parameters

  EmacPsInstancePtr | is a pointer to the instance of the EmacPs.

Returns
  None.

Note
  None.

References XEmacPs_HandleRecdPTPPacket(), XEmacPs_InitializeEmacPsDma(), XEmacPs_InitializeProtocolData(), XEmacPs_MasterSendFollowUp(), XEmacPs_PtpTxPacket(), XEmacPs_SendPDelayRespFollowUp(), and XEmacPs_Stop().

Referenced by main(), and XEmacPs_PtpErrorInterruptHandler().

void XEmacPs_SetDfltTxFrms | ( | XEmacPs_Ieee1588 * | InstancePtr | ) |

This function is used to populate the PTP Tx buffers.

Some of the entries in a PTP Tx packet do not change with time and are constants over time for this PTP standalone example. Those entries are populated here.

Parameters

  InstancePntr | is a pointer to the instance of the XEmacPs_Ieee1588.

Returns
  None.

Note
  None.

Referenced by XEmacPs_InitializeProtocolData().

int XEmacPs_SetupIntrSystem | ( | XScuGic * | IntcInstancePtr,
|  | XEmacPs * | EmacPsInstancePtr,
|  | XScuTimer * | TimerInstancePtr,
|  | u16 | EmacPsIntrId,
|  | u16 | TimerIntrId
| ) |  |

This function sets up interrupts.

It registers interrupt handlers and then enables them..

Parameters

  IntcInstancePtr | is a pointer to the instance of the SCUGic..
  EmacPsInstancePtr | is a pointer to the instance of the EmacPs.
  TimerInstancePtr | is a pointer to the instance of the SCUTimer.
  EmacPsIntrId | is the Interrupt ID for EmacPs and the value used is taken from xparameters_ps.h.
  TimerIntrId | is the Interrupt ID for SCUTimer and the value used is taken from xparameters_ps.h.

Returns
  - XST_SUCCESS to indicate success.
  - XST_FAILURE to indicate failure

Note
  None.

References XEmacPs_IntrHandler(), and XEmacPs_TimerInterruptHandler().

Referenced by main(), and XEmacPs_PtpErrorInterruptHandler().

void XEmacPs_TimerInterruptHandler | ( | XEmacPs_Ieee1588 * | InstancePtr | ) |

This function is the timer ISR that is invoked every 500 mseconds.

The Tx of PTP packets are initiated from here at appropriate intervals. When the PTP node is Master, the Tx of SYNC frame is triggered from here. Similarly Announce frame and PDelayReq frame Tx are triggered from here. When the PTP node is Slave, the PDelayReq frame Tx is triggered from here.

Parameters

  InstancePntr | is a pointer to the instance of the XEmacPs_Ieee1588.

Returns
  None.

Note
  The intervals at which SYNC, ANNOUNCE and PDelayReq are triggered are hard coded to 1 sec, 5 seconds and 4 seconds respectively. When signalling frames are implemented the hardcoded values can be replaced with proper signalling frame values.

References XEmacPs_BecomeRtcMaster(), XEmacPs_ChangePeerIeee1588v2Capability(), XEmacPs_MasterSendAnnounce(), XEmacPs_MasterSendSync(), and XEmacPs_SendPDelayReq().

Referenced by XEmacPs_SetupIntrSystem().

unsigned int XEmacPs_TsuCalcClk | ( | u32 | Freq | ) |

Calculate clock configuration register values for indicated input clock.

Parameters

  - | Freq

Returns
  - XST_SUCCESS to indicate success.
  - XST_FAILURE to indicate failure

Note
  None.

Referenced by main(), XEmacPs_BecomeRtcMaster(), and XEmacPs_PtpErrorInterruptHandler().