| emaclite Vitis Drivers API Documentation

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

Functions
xemaclite_example_util.c File Reference

## Overview

This file implements the utility functions for the EmacLite example code.

     MODIFICATION HISTORY:

     Ver   Who  Date     Changes

     2.00a  ktn 04/13/09 First release
     2.00a  ktn 06/13/09 Changed the EmacLitePhyDetect function so that
                          the function is not in an infinite loop in case of a
                          faulty Phy device.
     3.03a  bss 09/01/12 Moved the declarations of RecvFrameLength,
                         TransmitComplete, EmacLiteInstance
                          TxFrame[XEL_MAX_FRAME_SIZE], RxFrame[XEL_MAX_FRAME_SIZE]
                          from the xemaclite_example.h
                          to this file for fixing C++ compilation errors
     4.9    ml  11/15/23 Fix compilation errors reported with -std=c2x compiler flag

## Functions
u32 | EmacLitePhyDetect (XEmacLite *InstancePtr)
| This function detects the PHY address by looking for successful MII status register contents (PHY register 1). More...
int | EmacLiteEnablePhyLoopBack (XEmacLite *InstancePtr, u32 PhyAddress)
| This function enables the MAC loopback on the PHY. More...
int | EmacLiteDisablePhyLoopBack (XEmacLite *InstancePtr, u32 PhyAddress)
| This function disables the MAC loopback on the PHY. More...
void | EmacLitePhyDelay (unsigned int Seconds)
| For PPC we use a usleep call, for Microblaze we use an assembly loop that is roughly the same regardless of optimization level, although caches and memory access time can make the delay vary. More...

## Function Documentation

int EmacLiteDisablePhyLoopBack | ( | XEmacLite * | InstancePtr,
|  | u32 | PhyAddress
| ) |  |

This function disables the MAC loopback on the PHY.

Parameters

  InstancePtr | is the pointer to the instance of EmacLite driver.
  PhyAddress | is the address of the Phy device.

Returns
  - XST_SUCCESS if the loop back was disabled.
  - XST_FAILURE if the loop back was not disabled.

Note
  None.

References XEmacLite_PhyRead(), and XEmacLite_PhyWrite().

Referenced by EmacLiteIntrExample(), EmacLitePhyLoopbackExample(), and EmacLitePolledExample().

int EmacLiteEnablePhyLoopBack | ( | XEmacLite * | InstancePtr,
|  | u32 | PhyAddress
| ) |  |

This function enables the MAC loopback on the PHY.

Parameters

  InstancePtr | is the pointer to the instance of EmacLite driver.
  PhyAddress | is the address of the Phy device.

Returns
  - XST_SUCCESS if the loop back is enabled.
  - XST_FAILURE if the loop back was not enabled.

Note
  None.

References EmacLitePhyDelay(), and XEmacLite_PhyWrite().

Referenced by EmacLiteIntrExample(), EmacLitePhyLoopbackExample(), and EmacLitePolledExample().

void EmacLitePhyDelay | ( | unsigned int | Seconds | ) |

For PPC we use a usleep call, for Microblaze we use an assembly loop that is roughly the same regardless of optimization level, although caches and memory access time can make the delay vary.

Just keep in mind that after resetting or updating the PHY modes, the PHY typically needs time to recover.

Returns
  None

Note
  None

Referenced by EmacLiteEnablePhyLoopBack().

u32 EmacLitePhyDetect | ( | XEmacLite * | InstancePtr | ) |

This function detects the PHY address by looking for successful MII status register contents (PHY register 1).

It looks for a PHY that supports auto-negotiation and 10Mbps full-duplex and half-duplex. So, this code won't work for PHYs that don't support those features, but it's a bit more general purpose than matching a specific PHY manufacturer ID.

Note also that on some (older) Xilinx ML4xx boards, PHY address 0 does not properly respond to this query. But, since the default is 0 and assuming no other address responds, then it seems to work OK.

Parameters

  InstancePtr | is the pointer to the instance of EmacLite driver.

Returns
  The address of the PHY device detected (returns 0 if not detected).

Note
  The bit mask (0x1808) of the MII status register (PHY Register 1) used in this function are: 0x1000: 10Mbps full duplex support. 0x0800: 10Mbps half duplex support. 0x0008: Auto-negotiation support.

References XEmacLite_PhyRead().

Referenced by EmacLiteIntrExample(), EmacLitePhyLoopbackExample(), and EmacLitePolledExample().