#include "xenv.h"
#include "xil_types.h"
#include "xil_assert.h"
#include "xstatus.h"
#include "xemaclite_l.h"
Classes | |
struct | XEmacLite_Config |
struct | XEmacLite |
Defines | |
#define | XEMACLITE_H |
#define | XEL_DEVICE_NAME "xemaclite" |
#define | XEL_DEVICE_DESC "Xilinx Ethernet Lite 10/100 MAC" |
#define | XEmacLite_NextTransmitAddr(InstancePtr) |
#define | XEmacLite_NextReceiveAddr(InstancePtr) |
#define | XEmacLite_IsMdioConfigured(InstancePtr) ((InstancePtr)->EmacLiteConfig.MdioInclude == 1) |
#define | XEmacLite_IsLoopbackConfigured(InstancePtr) ((InstancePtr)->EmacLiteConfig.Loopback == 1) |
Typedefs | |
typedef void(* | XEmacLite_Handler )(void *CallBackRef) |
Functions | |
int | XEmacLite_CfgInitialize (XEmacLite *InstancePtr, XEmacLite_Config *EmacLiteConfigPtr, u32 EffectiveAddr) |
void | XEmacLite_SetMacAddress (XEmacLite *InstancePtr, u8 *AddressPtr) |
int | XEmacLite_TxBufferAvailable (XEmacLite *InstancePtr) |
void | XEmacLite_FlushReceive (XEmacLite *InstancePtr) |
int | XEmacLite_Send (XEmacLite *InstancePtr, u8 *FramePtr, unsigned ByteCount) |
u16 | XEmacLite_Recv (XEmacLite *InstancePtr, u8 *FramePtr) |
int | XEmacLite_PhyRead (XEmacLite *InstancePtr, u32 PhyAddress, u32 RegNum, u16 *PhyDataPtr) |
int | XEmacLite_PhyWrite (XEmacLite *InstancePtr, u32 PhyAddress, u32 RegNum, u16 PhyData) |
void | XEmacLite_EnableLoopBack (XEmacLite *InstancePtr) |
void | XEmacLite_DisableLoopBack (XEmacLite *InstancePtr) |
XEmacLite_Config * | XEmacLite_LookupConfig (u16 DeviceId) |
int | XEmacLite_Initialize (XEmacLite *InstancePtr, u16 DeviceId) |
int | XEmacLite_EnableInterrupts (XEmacLite *InstancePtr) |
void | XEmacLite_DisableInterrupts (XEmacLite *InstancePtr) |
void | XEmacLite_InterruptHandler (void *InstancePtr) |
void | XEmacLite_SetRecvHandler (XEmacLite *InstancePtr, void *CallBackRef, XEmacLite_Handler FuncPtr) |
void | XEmacLite_SetSendHandler (XEmacLite *InstancePtr, void *CallBackRef, XEmacLite_Handler FuncPtr) |
int | XEmacLite_SelfTest (XEmacLite *InstancePtr) |
#define XEL_DEVICE_DESC "Xilinx Ethernet Lite 10/100 MAC" |
#define XEL_DEVICE_NAME "xemaclite" |
#define XEMACLITE_H |
#define XEmacLite_IsLoopbackConfigured | ( | InstancePtr | ) | ((InstancePtr)->EmacLiteConfig.Loopback == 1) |
This macro determines if the device is currently configured for internal loopback.
InstancePtr | is the pointer to the instance of the EmacLite driver. |
#define XEmacLite_IsMdioConfigured | ( | InstancePtr | ) | ((InstancePtr)->EmacLiteConfig.MdioInclude == 1) |
This macro determines if the device is currently configured for MDIO.
InstancePtr | is the pointer to the instance of the EmacLite driver. |
#define XEmacLite_NextReceiveAddr | ( | InstancePtr | ) |
((InstancePtr)->EmacLiteConfig.BaseAddress + \ (InstancePtr)->NextRxBufferToUse)
Return the next expected Receive Buffer's address.
InstancePtr | is the pointer to the instance of the driver to be worked on |
This macro returns the address of the next receive buffer to read data from. This is the expected receive buffer address if the driver is in sync.
#define XEmacLite_NextTransmitAddr | ( | InstancePtr | ) |
((InstancePtr)->EmacLiteConfig.BaseAddress + \ (InstancePtr)->NextTxBufferToUse) + XEL_TXBUFF_OFFSET
Return the next expected Transmit Buffer's address.
InstancePtr | is the pointer to the instance of the driver to be worked on |
This macro returns the address of the next transmit buffer to put data into. This is used to determine the destination of the next transmit data frame.
typedef void(* XEmacLite_Handler)(void *CallBackRef) |
int XEmacLite_CfgInitialize | ( | XEmacLite * | InstancePtr, | |
XEmacLite_Config * | EmacLiteConfigPtr, | |||
u32 | EffectiveAddr | |||
) |
Initialize a specific XEmacLite instance/driver. The initialization entails:
The driver defaults to polled mode operation.
InstancePtr | is a pointer to the XEmacLite instance. | |
EmacLiteConfigPtr | points to the XEmacLite device configuration structure. | |
EffectiveAddr | is the device base address in the virtual memory address space. If the address translation is not used then the physical address is passed. Unexpected errors may occur if the address mapping is changed after this function is invoked. |
void XEmacLite_DisableInterrupts | ( | XEmacLite * | InstancePtr | ) |
Disables the interrupts from the device (the higher layer software is responsible for disabling interrupts at the interrupt controller).
To start using the device again, _EnableInterrupts must be called.
InstancePtr | is a pointer to the XEmacLite instance . |
void XEmacLite_DisableLoopBack | ( | XEmacLite * | InstancePtr | ) |
Disable Internal loop back functionality.
InstancePtr | is the pointer to the instance of the driver. |
int XEmacLite_EnableInterrupts | ( | XEmacLite * | InstancePtr | ) |
Enable the EmacLite Interrupts.
This function must be called before other functions to send or receive data in interrupt driven mode. The user should have connected the interrupt handler of the driver to an interrupt source such as an interrupt controller or the processor interrupt prior to this function being called.
InstancePtr | is a pointer to the XEmacLite instance. |
void XEmacLite_EnableLoopBack | ( | XEmacLite * | InstancePtr | ) |
Enable Internal loop back functionality.
InstancePtr | is the pointer to the instance of the driver. |
void XEmacLite_FlushReceive | ( | XEmacLite * | InstancePtr | ) |
Flush the Receive buffers. All data will be lost.
InstancePtr | is the pointer to the instance of the driver to be worked on. |
int XEmacLite_Initialize | ( | XEmacLite * | InstancePtr, | |
u16 | DeviceId | |||
) |
Initialize a specific XEmacLite instance/driver. The initialization entails:
The driver defaults to polled mode operation.
InstancePtr | is a pointer to the XEmacLite instance. | |
DeviceId | is the unique id of the device controlled by this XEmacLite instance. Passing in a device id associates the generic XEmacLite instance to a specific device, as chosen by the caller or application developer. |
void XEmacLite_InterruptHandler | ( | void * | InstancePtr | ) |
Interrupt handler for the EmacLite driver. It performs the following processing:
InstancePtr | contains a pointer to the EmacLite device instance for the interrupt. |
XEmacLite_Config* XEmacLite_LookupConfig | ( | u16 | DeviceId | ) |
Lookup the device configuration based on the unique device ID. The table XEmacLite_ConfigTable contains the configuration info for each device in the system.
DeviceId | is the unique device ID of the device being looked up. |
int XEmacLite_PhyRead | ( | XEmacLite * | InstancePtr, | |
u32 | PhyAddress, | |||
u32 | RegNum, | |||
u16 * | PhyDataPtr | |||
) |
Read the specified PHY register.
InstancePtr | is the pointer to the instance of the driver. | |
PhyAddress | is the address of the PHY device. The valid range is is from 0 to 31. | |
RegNum | is the register number in the PHY device which is to be read. The valid range is is from 0 to 31. | |
PhyDataPtr | is a pointer to the data in which the data read from the PHY device is returned. |
int XEmacLite_PhyWrite | ( | XEmacLite * | InstancePtr, | |
u32 | PhyAddress, | |||
u32 | RegNum, | |||
u16 | PhyData | |||
) |
Write the given data to the specified register in the PHY device.
InstancePtr | is the pointer to the instance of the driver. | |
PhyAddress | is the address of the PHY device. The valid range is is from 0 to 31. | |
RegNum | is the register number in the PHY device which is to be written. The valid range is is from 0 to 31. | |
PhyData | is the data to be written to the specified register in the PHY device. |
u16 XEmacLite_Recv | ( | XEmacLite * | InstancePtr, | |
u8 * | FramePtr | |||
) |
Receive a frame. Intended to be called from the interrupt context or with a wrapper which waits for the receive frame to be available.
InstancePtr | is a pointer to the XEmacLite instance. | |
FramePtr | is a pointer to a buffer where the frame will be stored. The buffer must be at least XEL_MAX_FRAME_SIZE bytes. For optimal performance, a 32-bit aligned buffer should be used but it is not required, the function will align the data if necessary. |
The type/length field of the frame received. When the type/length field contains the type, XEL_MAX_FRAME_SIZE bytes will be copied out of the buffer and it is up to the higher layers to sort out the frame. Function returns 0 if there is no data waiting in the receive buffer or the pong buffer if configured.
This function call is not blocking in nature, i.e. it will not wait until a frame arrives.
int XEmacLite_SelfTest | ( | XEmacLite * | InstancePtr | ) |
Performs a SelfTest on the EmacLite device as follows:
InstancePtr | is a pointer to the XEmacLite instance . |
int XEmacLite_Send | ( | XEmacLite * | InstancePtr, | |
u8 * | FramePtr, | |||
unsigned | ByteCount | |||
) |
Send an Ethernet frame. The ByteCount is the total frame size, including header.
InstancePtr | is a pointer to the XEmacLite instance. | |
FramePtr | is a pointer to frame. For optimal performance, a 32-bit aligned buffer should be used but it is not required, the function will align the data if necessary. | |
ByteCount | is the size, in bytes, of the frame |
This function call is not blocking in nature, i.e. it will not wait until the frame is transmitted.
void XEmacLite_SetMacAddress | ( | XEmacLite * | InstancePtr, | |
u8 * | AddressPtr | |||
) |
Set the MAC address for this device. The address is a 48-bit value.
InstancePtr | is a pointer to the XEmacLite instance. | |
AddressPtr | is a pointer to a 6-byte MAC address. the format of the MAC address is major octet to minor octet |
void XEmacLite_SetRecvHandler | ( | XEmacLite * | InstancePtr, | |
void * | CallBackRef, | |||
XEmacLite_Handler | FuncPtr | |||
) |
Sets the callback function for handling received frames in interrupt mode. The upper layer software should call this function during initialization. The callback is called when a frame is received. The callback function should communicate the data to a thread such that the processing is not performed in an interrupt context.
The callback is invoked by the driver within interrupt context, so it needs to do its job quickly. If there are other potentially slow operations within the callback, these should be done at task-level.
InstancePtr | is a pointer to the XEmacLite instance.. | |
CallBackRef | is a reference pointer to be passed back to the application in the callback. This helps the application correlate the callback to a particular driver. | |
FuncPtr | is the pointer to the callback function. |
void XEmacLite_SetSendHandler | ( | XEmacLite * | InstancePtr, | |
void * | CallBackRef, | |||
XEmacLite_Handler | FuncPtr | |||
) |
Sets the callback function for handling transmitted frames in interrupt mode. The upper layer software should call this function during initialization. The callback is called when a frame is transmitted. The callback function should communicate the data to a thread such that the processing is not performed in an interrupt context.
The callback is invoked by the driver within interrupt context, so it needs to do its job quickly. If there are other potentially slow operations within the callback, these should be done at task-level.
InstancePtr | is a pointer to the XEmacLite instance. | |
CallBackRef | is a reference pointer to be passed back to the application in the callback. This helps the application correlate the callback to a particular driver. | |
FuncPtr | is the pointer to the callback function. |
int XEmacLite_TxBufferAvailable | ( | XEmacLite * | InstancePtr | ) |
Determine if there is a transmit buffer available.
InstancePtr | is the pointer to the instance of the driver to be worked on. |
Copyright © 1995-2014 Xilinx, Inc. All rights reserved.