emaclite
Vitis Drivers API Documentation
|
Data Structures | |
struct | XEmacLite_Config |
This typedef contains configuration information for a device. More... | |
struct | XEmacLite |
The XEmacLite driver instance data. More... | |
Macros | |
#define | XEmacLite_NextTransmitAddr(InstancePtr) |
Return the next expected Transmit Buffer's address. More... | |
#define | XEmacLite_NextReceiveAddr(InstancePtr) |
Return the next expected Receive Buffer's address. More... | |
#define | XEmacLite_IsMdioConfigured(InstancePtr) ((InstancePtr)->EmacLiteConfig.MdioInclude == 1) |
This macro determines if the device is currently configured for MDIO. More... | |
#define | XEmacLite_IsLoopbackConfigured(InstancePtr) ((InstancePtr)->EmacLiteConfig.Loopback == 1) |
This macro determines if the device is currently configured for internal loopback. More... | |
#define | XEmacLite_GetTxActive(BaseAddress) (XEmacLite_ReadReg((BaseAddress), XEL_TSR_OFFSET)) |
Get the TX active location to check status. More... | |
#define | XEmacLite_SetTxActive(BaseAddress, Mask) (XEmacLite_WriteReg((BaseAddress), XEL_TSR_OFFSET, (Mask))) |
Set the TX active location to update status. More... | |
#define | XEL_TXBUFF_OFFSET (0x00000000) |
Register offsets for the Ethernet MAC. More... | |
#define | XEL_MDIOADDR_OFFSET (XEL_TXBUFF_OFFSET + 0x07E4) |
MDIO Address offset register. More... | |
#define | XEL_MDIOWR_OFFSET (XEL_TXBUFF_OFFSET + 0x07E8) |
MDIO write data register offset. More... | |
#define | XEL_MDIORD_OFFSET (XEL_TXBUFF_OFFSET + 0x07EC) |
MDIO read data register offset. More... | |
#define | XEL_MDIOCNTR_OFFSET (XEL_TXBUFF_OFFSET + 0x07F0) |
MDIO Control Register offset. More... | |
#define | XEL_GIER_OFFSET (XEL_TXBUFF_OFFSET + 0x07F8) |
Offset for the GIE Register. More... | |
#define | XEL_TSR_OFFSET (XEL_TXBUFF_OFFSET + 0x07FC) |
Tx status. More... | |
#define | XEL_TPLR_OFFSET (XEL_TXBUFF_OFFSET + 0x07F4) |
Tx packet length. More... | |
#define | XEL_RXBUFF_OFFSET (0x00001000) |
Receive Buffer. More... | |
#define | XEL_RSR_OFFSET (XEL_RXBUFF_OFFSET + 0x07FC) |
Rx status. More... | |
#define | XEL_RPLR_OFFSET (XEL_RXBUFF_OFFSET + 0x0C) |
Rx packet length. More... | |
#define | XEL_MAC_HI_OFFSET (XEL_TXBUFF_OFFSET + 0x14) |
MAC address hi offset. More... | |
#define | XEL_MAC_LO_OFFSET (XEL_TXBUFF_OFFSET) |
MAC address lo offset. More... | |
#define | XEL_BUFFER_OFFSET (0x00000800) |
Next buffer's offset same for both TX and RX. More... | |
#define | XEL_MDIO_ADDRESS_MASK 0x00003E0 |
MDIO Address/Write Data/Read Data Register Bit Masks. More... | |
#define | XEL_MDIO_ADDRESS_SHIFT 0x5 |
PHY Address shift. More... | |
#define | XEL_MDIO_OP_MASK 0x00000400 |
PHY read access. More... | |
#define | XEL_MDIOCNTR_STATUS_MASK 0x00000001 |
MDIO Control Register Bit Masks. More... | |
#define | XEL_MDIOCNTR_ENABLE_MASK 0x00000008 |
MDIO Enable. More... | |
#define | XEL_GIER_GIE_MASK 0x80000000 |
Global Interrupt Enable Register (GIER) Bit Masks. More... | |
#define | XEL_TSR_XMIT_BUSY_MASK 0x00000001 |
Transmit Status Register (TSR) Bit Masks. More... | |
#define | XEL_TSR_PROGRAM_MASK 0x00000002 |
Program the MAC address. More... | |
#define | XEL_TSR_XMIT_IE_MASK 0x00000008 |
Xmit interrupt enable bit. More... | |
#define | XEL_TSR_LOOPBACK_MASK 0x00000010 |
Loop back enable bit. More... | |
#define | XEL_TSR_XMIT_ACTIVE_MASK 0x80000000 |
Buffer is active, SW bit only. More... | |
#define | XEL_TSR_PROG_MAC_ADDR (XEL_TSR_XMIT_BUSY_MASK | XEL_TSR_PROGRAM_MASK) |
define for programming the MAC address into the EmacLite More... | |
#define | XEL_RSR_RECV_DONE_MASK 0x00000001 |
Receive Status Register (RSR) More... | |
#define | XEL_RSR_RECV_IE_MASK 0x00000008 |
Recv interrupt enable bit. More... | |
#define | XEL_TPLR_LENGTH_MASK_HI 0x0000FF00 |
Transmit Packet Length Register (TPLR) More... | |
#define | XEL_TPLR_LENGTH_MASK_LO 0x000000FF |
Transmit packet length lower byte. More... | |
#define | XEL_RPLR_LENGTH_MASK_HI 0x0000FF00 |
Receive Packet Length Register (RPLR) More... | |
#define | XEL_RPLR_LENGTH_MASK_LO 0x000000FF |
Receive packet length lower byte. More... | |
#define | XEL_HEADER_SIZE 14 |
Size of header in bytes. More... | |
#define | XEL_MTU_SIZE 1500 |
Max size of data in frame. More... | |
#define | XEL_FCS_SIZE 4 |
Size of CRC. More... | |
#define | XEL_HEADER_OFFSET 12 |
Offset to length field. More... | |
#define | XEL_HEADER_SHIFT 16 |
Right shift value to align length. More... | |
#define | XEL_MAX_FRAME_SIZE (XEL_HEADER_SIZE+XEL_MTU_SIZE+ XEL_FCS_SIZE) |
Max length of Rx frame used if length/type field contains the type (> 1500) More... | |
#define | XEL_MAX_TX_FRAME_SIZE (XEL_HEADER_SIZE + XEL_MTU_SIZE) |
Max length of Tx frame. More... | |
#define | XEL_MAC_ADDR_SIZE 6 |
length of MAC address More... | |
#define | XEL_ETHER_PROTO_TYPE_IP 0x0800 |
IP Protocol. More... | |
#define | XEL_ETHER_PROTO_TYPE_ARP 0x0806 |
ARP Protocol. More... | |
#define | XEL_ETHER_PROTO_TYPE_VLAN 0x8100 |
VLAN Tagged. More... | |
#define | XEL_ARP_PACKET_SIZE 28 |
Max ARP packet size. More... | |
#define | XEL_HEADER_IP_LENGTH_OFFSET 16 |
IP Length Offset. More... | |
#define | XEL_VLAN_TAG_SIZE 4 |
VLAN Tag Size. More... | |
#define | XEmacLite_ReadReg(BaseAddress, RegOffset) XEmacLite_In32((BaseAddress) + (RegOffset)) |
Read from the specified EmacLite device register. More... | |
#define | XEmacLite_WriteReg(BaseAddress, RegOffset, RegisterValue) XEmacLite_Out32((BaseAddress) + (RegOffset), (RegisterValue)) |
Write to the specified EmacLite device register. More... | |
#define | XEmacLite_GetTxStatus(BaseAddress) (XEmacLite_ReadReg((BaseAddress), XEL_TSR_OFFSET)) |
Get the Tx Status Register Contents. More... | |
#define | XEmacLite_SetTxStatus(BaseAddress, Data) (XEmacLite_WriteReg((BaseAddress), XEL_TSR_OFFSET, (Data))) |
Set the Tx Status Register Contents. More... | |
#define | XEmacLite_GetRxStatus(BaseAddress) (XEmacLite_ReadReg((BaseAddress), XEL_RSR_OFFSET)) |
Get the Rx Status Register Contents. More... | |
#define | XEmacLite_SetRxStatus(BaseAddress, Data) (XEmacLite_WriteReg((BaseAddress), XEL_RSR_OFFSET, (Data))) |
Set the Rx Status Register Contents. More... | |
#define | XEmacLite_IsTxDone(BaseAddress) |
Check to see if the transmission is complete. More... | |
#define | XEmacLite_IsRxEmpty(BaseAddress) |
Check to see if the receive is empty. More... | |
Functions | |
int | XEmacLite_CfgInitialize (XEmacLite *InstancePtr, XEmacLite_Config *EmacLiteConfigPtr, UINTPTR EffectiveAddr) |
Initialize a specific XEmacLite instance/driver. More... | |
int | XEmacLite_Send (XEmacLite *InstancePtr, u8 *FramePtr, unsigned ByteCount) |
Send an Ethernet frame. More... | |
u16 | XEmacLite_Recv (XEmacLite *InstancePtr, u8 *FramePtr) |
Receive a frame. More... | |
void | XEmacLite_SetMacAddress (XEmacLite *InstancePtr, u8 *AddressPtr) |
Set the MAC address for this device. More... | |
void | StubHandler (void *CallBackRef) |
This is a stub for the send and receive callbacks. More... | |
int | XEmacLite_TxBufferAvailable (XEmacLite *InstancePtr) |
Determine if there is a transmit buffer available. More... | |
void | XEmacLite_FlushReceive (XEmacLite *InstancePtr) |
Flush the Receive buffers. More... | |
int | XEmacLite_PhyRead (XEmacLite *InstancePtr, u32 PhyAddress, u32 RegNum, u16 *PhyDataPtr) |
Read the specified PHY register. More... | |
int | XEmacLite_PhyWrite (XEmacLite *InstancePtr, u32 PhyAddress, u32 RegNum, u16 PhyData) |
Write the given data to the specified register in the PHY device. More... | |
void | XEmacLite_EnableLoopBack (XEmacLite *InstancePtr) |
Enable Internal loop back functionality. More... | |
void | XEmacLite_DisableLoopBack (XEmacLite *InstancePtr) |
Disable Internal loop back functionality. More... | |
XEmacLite_Config * | XEmacLite_LookupConfig (u16 DeviceId) |
Lookup the device configuration based on the unique device ID. More... | |
int | XEmacLite_Initialize (XEmacLite *InstancePtr, u16 DeviceId) |
Initialize a specific XEmacLite instance/driver. More... | |
int | XEmacLite_EnableInterrupts (XEmacLite *InstancePtr) |
Enable the EmacLite Interrupts. More... | |
void | XEmacLite_DisableInterrupts (XEmacLite *InstancePtr) |
Disables the interrupts from the device (the higher layer software is responsible for disabling interrupts at the interrupt controller). More... | |
void | XEmacLite_InterruptHandler (void *InstancePtr) |
Interrupt handler for the EmacLite driver. More... | |
void | XEmacLite_SetRecvHandler (XEmacLite *InstancePtr, void *CallBackRef, XEmacLite_Handler FuncPtr) |
Sets the callback function for handling received frames in interrupt mode. More... | |
void | XEmacLite_SetSendHandler (XEmacLite *InstancePtr, void *CallBackRef, XEmacLite_Handler FuncPtr) |
Sets the callback function for handling transmitted frames in interrupt mode. More... | |
int | XEmacLite_SelfTest (XEmacLite *InstancePtr) |
Performs a SelfTest on the EmacLite device as follows: More... | |
void | XEmacLite_AlignedWrite (void *SrcPtr, UINTPTR *DestPtr, unsigned ByteCount) |
This function aligns the incoming data and writes it out to a 32-bit aligned destination address range. More... | |
void | XEmacLite_AlignedRead (UINTPTR *SrcPtr, void *DestPtr, unsigned ByteCount) |
This function reads from a 32-bit aligned source address range and aligns the writes to the provided destination pointer alignment. More... | |
void | XEmacLite_SendFrame (UINTPTR BaseAddress, u8 *FramePtr, unsigned ByteCount) |
Send an Ethernet frame. More... | |
u16 | XEmacLite_RecvFrame (UINTPTR BaseAddress, u8 *FramePtr) |
Receive a frame. More... | |
Variables | |
XEmacLite_Config | XEmacLite_ConfigTable [XPAR_XEMACLITE_NUM_INSTANCES] |
This table contains configuration information for each EmacLite device in the system. More... | |
XEmacLite_Config | XEmacLite_ConfigTable [] |
This table contains configuration information for each EmacLite device in the system. More... | |
XEmacLite_Config | XEmacLite_ConfigTable [] |
This table contains configuration information for each EmacLite device in the system. More... | |
#define XEL_ARP_PACKET_SIZE 28 |
Max ARP packet size.
Referenced by XEmacLite_Recv().
#define XEL_BUFFER_OFFSET (0x00000800) |
Next buffer's offset same for both TX and RX.
Referenced by XEmacLite_CfgInitialize(), XEmacLite_FlushReceive(), XEmacLite_InterruptHandler(), XEmacLite_Recv(), XEmacLite_SelfTest(), XEmacLite_Send(), and XEmacLite_TxBufferAvailable().
#define XEL_ETHER_PROTO_TYPE_ARP 0x0806 |
ARP Protocol.
Referenced by XEmacLite_Recv().
#define XEL_ETHER_PROTO_TYPE_IP 0x0800 |
IP Protocol.
Referenced by XEmacLite_Recv().
#define XEL_ETHER_PROTO_TYPE_VLAN 0x8100 |
VLAN Tagged.
#define XEL_FCS_SIZE 4 |
Size of CRC.
Referenced by XEmacLite_Recv(), and XEmacLite_RecvFrame().
#define XEL_GIER_GIE_MASK 0x80000000 |
Global Interrupt Enable Register (GIER) Bit Masks.
Global Enable
Referenced by XEmacLite_EnableInterrupts().
#define XEL_GIER_OFFSET (XEL_TXBUFF_OFFSET + 0x07F8) |
Offset for the GIE Register.
Referenced by XEmacLite_DisableInterrupts(), and XEmacLite_EnableInterrupts().
#define XEL_HEADER_IP_LENGTH_OFFSET 16 |
IP Length Offset.
Referenced by XEmacLite_Recv().
#define XEL_HEADER_OFFSET 12 |
Offset to length field.
#define XEL_HEADER_SHIFT 16 |
Right shift value to align length.
Referenced by XEmacLite_Recv().
#define XEL_HEADER_SIZE 14 |
Size of header in bytes.
Referenced by XEmacLite_Recv(), and XEmacLite_RecvFrame().
#define XEL_MAC_ADDR_SIZE 6 |
length of MAC address
Referenced by XEmacLite_SetMacAddress().
#define XEL_MAC_HI_OFFSET (XEL_TXBUFF_OFFSET + 0x14) |
MAC address hi offset.
#define XEL_MAC_LO_OFFSET (XEL_TXBUFF_OFFSET) |
MAC address lo offset.
#define XEL_MAX_FRAME_SIZE (XEL_HEADER_SIZE+XEL_MTU_SIZE+ XEL_FCS_SIZE) |
Max length of Rx frame used if length/type field contains the type (> 1500)
Referenced by XEmacLite_Recv(), and XEmacLite_RecvFrame().
#define XEL_MAX_TX_FRAME_SIZE (XEL_HEADER_SIZE + XEL_MTU_SIZE) |
Max length of Tx frame.
Referenced by XEmacLite_Send().
#define XEL_MDIO_ADDRESS_MASK 0x00003E0 |
MDIO Address/Write Data/Read Data Register Bit Masks.
PHY Address mask
Referenced by XEmacLite_PhyRead(), and XEmacLite_PhyWrite().
#define XEL_MDIO_ADDRESS_SHIFT 0x5 |
PHY Address shift.
Referenced by XEmacLite_PhyRead(), and XEmacLite_PhyWrite().
#define XEL_MDIO_OP_MASK 0x00000400 |
PHY read access.
Referenced by XEmacLite_PhyRead(), and XEmacLite_PhyWrite().
#define XEL_MDIOADDR_OFFSET (XEL_TXBUFF_OFFSET + 0x07E4) |
MDIO Address offset register.
Referenced by XEmacLite_PhyRead(), and XEmacLite_PhyWrite().
#define XEL_MDIOCNTR_ENABLE_MASK 0x00000008 |
MDIO Enable.
Referenced by XEmacLite_PhyRead(), and XEmacLite_PhyWrite().
#define XEL_MDIOCNTR_OFFSET (XEL_TXBUFF_OFFSET + 0x07F0) |
MDIO Control Register offset.
Referenced by XEmacLite_PhyRead(), and XEmacLite_PhyWrite().
#define XEL_MDIOCNTR_STATUS_MASK 0x00000001 |
MDIO Control Register Bit Masks.
MDIO transfer in Progress
Referenced by XEmacLite_PhyRead(), and XEmacLite_PhyWrite().
#define XEL_MDIORD_OFFSET (XEL_TXBUFF_OFFSET + 0x07EC) |
MDIO read data register offset.
Referenced by XEmacLite_PhyRead().
#define XEL_MDIOWR_OFFSET (XEL_TXBUFF_OFFSET + 0x07E8) |
MDIO write data register offset.
Referenced by XEmacLite_PhyWrite().
#define XEL_MTU_SIZE 1500 |
Max size of data in frame.
Referenced by EmacLiteIntrLoopbackExample(), and EmacLitePhyLoopbackExample().
#define XEL_RPLR_LENGTH_MASK_HI 0x0000FF00 |
Receive Packet Length Register (RPLR)
Receive packet length upper byte
Referenced by XEmacLite_Recv(), and XEmacLite_RecvFrame().
#define XEL_RPLR_LENGTH_MASK_LO 0x000000FF |
Receive packet length lower byte.
Referenced by XEmacLite_Recv(), and XEmacLite_RecvFrame().
#define XEL_RPLR_OFFSET (XEL_RXBUFF_OFFSET + 0x0C) |
Rx packet length.
Referenced by XEmacLite_RecvFrame().
#define XEL_RSR_OFFSET (XEL_RXBUFF_OFFSET + 0x07FC) |
Rx status.
#define XEL_RSR_RECV_DONE_MASK 0x00000001 |
Receive Status Register (RSR)
Recv complete
Referenced by XEmacLite_Recv(), and XEmacLite_RecvFrame().
#define XEL_RSR_RECV_IE_MASK 0x00000008 |
Recv interrupt enable bit.
Referenced by XEmacLite_DisableInterrupts(), XEmacLite_EnableInterrupts(), and XEmacLite_FlushReceive().
#define XEL_RXBUFF_OFFSET (0x00001000) |
Receive Buffer.
Referenced by XEmacLite_Recv(), XEmacLite_RecvFrame(), and XEmacLite_SelfTest().
#define XEL_TPLR_LENGTH_MASK_HI 0x0000FF00 |
Transmit Packet Length Register (TPLR)
Transmit packet length upper byte
Referenced by XEmacLite_Send(), and XEmacLite_SendFrame().
#define XEL_TPLR_LENGTH_MASK_LO 0x000000FF |
Transmit packet length lower byte.
Referenced by XEmacLite_Send(), and XEmacLite_SendFrame().
#define XEL_TPLR_OFFSET (XEL_TXBUFF_OFFSET + 0x07F4) |
Tx packet length.
Referenced by XEmacLite_Send(), XEmacLite_SendFrame(), and XEmacLite_SetMacAddress().
#define XEL_TSR_LOOPBACK_MASK 0x00000010 |
Loop back enable bit.
Referenced by XEmacLite_DisableLoopBack(), and XEmacLite_EnableLoopBack().
#define XEL_TSR_OFFSET (XEL_TXBUFF_OFFSET + 0x07FC) |
Tx status.
Referenced by XEmacLite_CfgInitialize(), XEmacLite_DisableLoopBack(), and XEmacLite_EnableLoopBack().
#define XEL_TSR_PROG_MAC_ADDR (XEL_TSR_XMIT_BUSY_MASK | XEL_TSR_PROGRAM_MASK) |
define for programming the MAC address into the EmacLite
Referenced by XEmacLite_SetMacAddress().
#define XEL_TSR_PROGRAM_MASK 0x00000002 |
Program the MAC address.
#define XEL_TSR_XMIT_ACTIVE_MASK 0x80000000 |
Buffer is active, SW bit only.
This is not documented in the HW spec
Referenced by XEmacLite_InterruptHandler(), XEmacLite_Send(), and XEmacLite_TxBufferAvailable().
#define XEL_TSR_XMIT_BUSY_MASK 0x00000001 |
Transmit Status Register (TSR) Bit Masks.
Xmit complete
Referenced by XEmacLite_InterruptHandler(), XEmacLite_Send(), XEmacLite_SendFrame(), and XEmacLite_TxBufferAvailable().
#define XEL_TSR_XMIT_IE_MASK 0x00000008 |
Xmit interrupt enable bit.
Referenced by XEmacLite_DisableInterrupts(), XEmacLite_EnableInterrupts(), and XEmacLite_Send().
#define XEL_TXBUFF_OFFSET (0x00000000) |
#define XEL_VLAN_TAG_SIZE 4 |
VLAN Tag Size.
#define XEmacLite_GetRxStatus | ( | BaseAddress | ) | (XEmacLite_ReadReg((BaseAddress), XEL_RSR_OFFSET)) |
Get the Rx Status Register Contents.
BaseAddress | is the base address of the device |
Referenced by XEmacLite_DisableInterrupts(), XEmacLite_EnableInterrupts(), XEmacLite_FlushReceive(), XEmacLite_Recv(), and XEmacLite_RecvFrame().
#define XEmacLite_GetTxActive | ( | BaseAddress | ) | (XEmacLite_ReadReg((BaseAddress), XEL_TSR_OFFSET)) |
Get the TX active location to check status.
This is used to check if the TX buffer is currently active. There isn't any way in the hardware to implement this but the register is fully populated so the driver can set the bit in the send routine and the ISR can clear the bit when the handler is complete. This mimics the correct operation of the hardware if it was possible to do this in hardware.
BaseAddress | is the base address of the device |
#define XEmacLite_GetTxStatus | ( | BaseAddress | ) | (XEmacLite_ReadReg((BaseAddress), XEL_TSR_OFFSET)) |
Get the Tx Status Register Contents.
BaseAddress | is the base address of the device |
Referenced by XEmacLite_DisableInterrupts(), XEmacLite_EnableInterrupts(), XEmacLite_InterruptHandler(), XEmacLite_Send(), XEmacLite_SendFrame(), XEmacLite_SetMacAddress(), and XEmacLite_TxBufferAvailable().
#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. |
Referenced by EmacLiteIntrExample(), EmacLitePhyLoopbackExample(), and EmacLitePolledExample().
#define XEmacLite_IsRxEmpty | ( | BaseAddress | ) |
Check to see if the receive is empty.
BaseAddress | is the base address of the device |
Referenced by XEmacLite_InterruptHandler(), and XEmacLite_RecvFrame().
#define XEmacLite_IsTxDone | ( | BaseAddress | ) |
Check to see if the transmission is complete.
BaseAddress | is the base address of the device |
Referenced by XEmacLite_SendFrame().
#define XEmacLite_NextReceiveAddr | ( | InstancePtr | ) |
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.
Referenced by XEmacLite_Recv().
#define XEmacLite_NextTransmitAddr | ( | InstancePtr | ) |
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.
Referenced by XEmacLite_Send(), and XEmacLite_SetMacAddress().
#define XEmacLite_ReadReg | ( | BaseAddress, | |
RegOffset | |||
) | XEmacLite_In32((BaseAddress) + (RegOffset)) |
Read from the specified EmacLite device register.
BaseAddress | contains the base address of the device. |
RegOffset | contains the offset from the 1st register of the device to select the specific register. |
Referenced by XEmacLite_DisableLoopBack(), XEmacLite_EnableLoopBack(), XEmacLite_PhyRead(), XEmacLite_PhyWrite(), XEmacLite_Recv(), and XEmacLite_RecvFrame().
#define XEmacLite_SetRxStatus | ( | BaseAddress, | |
Data | |||
) | (XEmacLite_WriteReg((BaseAddress), XEL_RSR_OFFSET, (Data))) |
Set the Rx Status Register Contents.
BaseAddress | is the base address of the device |
Data | is the value to be written to the Register. |
Referenced by XEmacLite_DisableInterrupts(), XEmacLite_EnableInterrupts(), XEmacLite_FlushReceive(), XEmacLite_Recv(), and XEmacLite_RecvFrame().
#define XEmacLite_SetTxActive | ( | BaseAddress, | |
Mask | |||
) | (XEmacLite_WriteReg((BaseAddress), XEL_TSR_OFFSET, (Mask))) |
Set the TX active location to update status.
This is used to set the bit indicating which TX buffer is currently active. There isn't any way in the hardware to implement this but the register is fully populated so the driver can set the bit in the send routine and the ISR can clear the bit when the handler is complete. This mimics the correct operation of the hardware if it was possible to do this in hardware.
BaseAddress | is the base address of the device |
Mask | is the data to be written |
#define XEmacLite_SetTxStatus | ( | BaseAddress, | |
Data | |||
) | (XEmacLite_WriteReg((BaseAddress), XEL_TSR_OFFSET, (Data))) |
Set the Tx Status Register Contents.
BaseAddress | is the base address of the device |
Data | is the value to be written to the Register. |
Referenced by XEmacLite_DisableInterrupts(), XEmacLite_EnableInterrupts(), XEmacLite_InterruptHandler(), XEmacLite_Send(), XEmacLite_SendFrame(), and XEmacLite_SetMacAddress().
#define XEmacLite_WriteReg | ( | BaseAddress, | |
RegOffset, | |||
RegisterValue | |||
) | XEmacLite_Out32((BaseAddress) + (RegOffset), (RegisterValue)) |
Write to the specified EmacLite device register.
BaseAddress | contains the base address of the device. |
RegOffset | contains the offset from the 1st register of the device to select the specific register. |
RegisterValue | is the value to be written to the register. |
Referenced by XEmacLite_CfgInitialize(), XEmacLite_DisableInterrupts(), XEmacLite_DisableLoopBack(), XEmacLite_EnableInterrupts(), XEmacLite_EnableLoopBack(), XEmacLite_PhyRead(), XEmacLite_PhyWrite(), XEmacLite_Send(), XEmacLite_SendFrame(), and XEmacLite_SetMacAddress().
void StubHandler | ( | void * | CallBackRef | ) |
This is a stub for the send and receive callbacks.
The stub is here in case the upper layers forget to set the handlers.
CallBackRef | is a pointer to the upper layer callback reference. |
Referenced by XEmacLite_CfgInitialize(), and XEmacLite_EnableInterrupts().
void XEmacLite_AlignedRead | ( | UINTPTR * | SrcPtr, |
void * | DestPtr, | ||
unsigned | ByteCount | ||
) |
This function reads from a 32-bit aligned source address range and aligns the writes to the provided destination pointer alignment.
SrcPtr | is a pointer to incoming data of 32-bit alignment. |
DestPtr | is a pointer to outgoing data of any alignment. |
ByteCount | is the number of bytes to read. |
Referenced by XEmacLite_Recv(), XEmacLite_RecvFrame(), and XEmacLite_SelfTest().
void XEmacLite_AlignedWrite | ( | void * | SrcPtr, |
UINTPTR * | DestPtr, | ||
unsigned | ByteCount | ||
) |
This function aligns the incoming data and writes it out to a 32-bit aligned destination address range.
SrcPtr | is a pointer to incoming data of any alignment. |
DestPtr | is a pointer to outgoing data of 32-bit alignment. |
ByteCount | is the number of bytes to write. |
Referenced by XEmacLite_SelfTest(), XEmacLite_Send(), XEmacLite_SendFrame(), and XEmacLite_SetMacAddress().
int XEmacLite_CfgInitialize | ( | XEmacLite * | InstancePtr, |
XEmacLite_Config * | EmacLiteConfigPtr, | ||
UINTPTR | 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. |
References XEmacLite_Config::BaseAddress, XEmacLite_Config::DeviceId, XEmacLite_Config::Loopback, XEmacLite_Config::MdioInclude, XEmacLite_Config::RxPingPong, StubHandler(), XEmacLite_Config::TxPingPong, XEL_BUFFER_OFFSET, XEL_TSR_OFFSET, and XEmacLite_WriteReg.
Referenced by EmacLiteIntrExample(), EmacLiteIntrLoopbackExample(), EmacLitePhyLoopbackExample(), EmacLitePolledExample(), EMACLiteSelfTestExample(), and XEmacLite_Initialize().
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 . |
References XEmacLite_Config::BaseAddress, XEL_GIER_OFFSET, XEL_RSR_RECV_IE_MASK, XEL_TSR_XMIT_IE_MASK, XEmacLite_GetRxStatus, XEmacLite_GetTxStatus, XEmacLite_SetRxStatus, XEmacLite_SetTxStatus, and XEmacLite_WriteReg.
Referenced by EmacLiteIntrExample(), EmacLiteIntrLoopbackExample(), and EmacLitePhyLoopbackExample().
void XEmacLite_DisableLoopBack | ( | XEmacLite * | InstancePtr | ) |
Disable Internal loop back functionality.
InstancePtr | is the pointer to the instance of the driver. |
References XEmacLite_Config::BaseAddress, XEmacLite_Config::Loopback, XEL_TSR_LOOPBACK_MASK, XEL_TSR_OFFSET, XEmacLite_ReadReg, and XEmacLite_WriteReg.
Referenced by EmacLiteIntrLoopbackExample().
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. |
References XEmacLite_Config::BaseAddress, StubHandler(), XEL_GIER_GIE_MASK, XEL_GIER_OFFSET, XEL_RSR_RECV_IE_MASK, XEL_TSR_XMIT_IE_MASK, XEmacLite_GetRxStatus, XEmacLite_GetTxStatus, XEmacLite_SetRxStatus, XEmacLite_SetTxStatus, and XEmacLite_WriteReg.
Referenced by EmacLiteIntrExample(), EmacLiteIntrLoopbackExample(), and EmacLitePhyLoopbackExample().
void XEmacLite_EnableLoopBack | ( | XEmacLite * | InstancePtr | ) |
Enable Internal loop back functionality.
InstancePtr | is the pointer to the instance of the driver. |
References XEmacLite_Config::BaseAddress, XEmacLite_Config::Loopback, XEL_TSR_LOOPBACK_MASK, XEL_TSR_OFFSET, XEmacLite_ReadReg, and XEmacLite_WriteReg.
Referenced by EmacLiteIntrLoopbackExample().
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. |
References XEmacLite_Config::BaseAddress, XEmacLite_Config::RxPingPong, XEL_BUFFER_OFFSET, XEL_RSR_RECV_IE_MASK, XEmacLite_GetRxStatus, and XEmacLite_SetRxStatus.
Referenced by EmacLiteIntrExample(), EmacLiteIntrLoopbackExample(), EmacLitePhyLoopbackExample(), and EmacLitePolledExample().
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. |
References XEmacLite_Config::BaseAddress, XEmacLite_CfgInitialize(), and XEmacLite_LookupConfig().
void XEmacLite_InterruptHandler | ( | void * | InstancePtr | ) |
Interrupt handler for the EmacLite driver.
It performs the following processing:
- Get the interrupt status from the registers to determine the source of the interrupt. - Call the appropriate handler based on the source of the interrupt.
InstancePtr | contains a pointer to the EmacLite device instance for the interrupt. |
References XEmacLite_Config::BaseAddress, XEL_BUFFER_OFFSET, XEL_TSR_XMIT_ACTIVE_MASK, XEL_TSR_XMIT_BUSY_MASK, XEmacLite_GetTxStatus, XEmacLite_IsRxEmpty, and XEmacLite_SetTxStatus.
Referenced by EmacLiteIntrExample(), EmacLiteIntrLoopbackExample(), and EmacLitePhyLoopbackExample().
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. |
Referenced by EmacLiteIntrExample(), EmacLiteIntrLoopbackExample(), EmacLitePhyLoopbackExample(), EmacLitePolledExample(), EMACLiteSelfTestExample(), and XEmacLite_Initialize().
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. |
References XEmacLite_Config::BaseAddress, XEmacLite_Config::MdioInclude, XEL_MDIO_ADDRESS_MASK, XEL_MDIO_ADDRESS_SHIFT, XEL_MDIO_OP_MASK, XEL_MDIOADDR_OFFSET, XEL_MDIOCNTR_ENABLE_MASK, XEL_MDIOCNTR_OFFSET, XEL_MDIOCNTR_STATUS_MASK, XEL_MDIORD_OFFSET, XEmacLite_ReadReg, and XEmacLite_WriteReg.
Referenced by EmacLiteDisablePhyLoopBack(), and EmacLitePhyDetect().
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. |
References XEmacLite_Config::BaseAddress, XEmacLite_Config::MdioInclude, XEL_MDIO_ADDRESS_MASK, XEL_MDIO_ADDRESS_SHIFT, XEL_MDIO_OP_MASK, XEL_MDIOADDR_OFFSET, XEL_MDIOCNTR_ENABLE_MASK, XEL_MDIOCNTR_OFFSET, XEL_MDIOCNTR_STATUS_MASK, XEL_MDIOWR_OFFSET, XEmacLite_ReadReg, and XEmacLite_WriteReg.
Referenced by EmacLiteDisablePhyLoopBack(), and EmacLiteEnablePhyLoopBack().
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.
References XEmacLite_Config::RxPingPong, XEL_ARP_PACKET_SIZE, XEL_BUFFER_OFFSET, XEL_ETHER_PROTO_TYPE_ARP, XEL_ETHER_PROTO_TYPE_IP, XEL_FCS_SIZE, XEL_HEADER_IP_LENGTH_OFFSET, XEL_HEADER_SHIFT, XEL_HEADER_SIZE, XEL_MAX_FRAME_SIZE, XEL_RPLR_LENGTH_MASK_HI, XEL_RPLR_LENGTH_MASK_LO, XEL_RSR_RECV_DONE_MASK, XEL_RXBUFF_OFFSET, XEmacLite_AlignedRead(), XEmacLite_GetRxStatus, XEmacLite_NextReceiveAddr, XEmacLite_ReadReg, and XEmacLite_SetRxStatus.
Referenced by EmacLitePolledExample().
u16 XEmacLite_RecvFrame | ( | UINTPTR | BaseAddress, |
u8 * | FramePtr | ||
) |
Receive a frame.
Wait for a frame to arrive.
BaseAddress | is the base address of the device |
FramePtr | is a pointer to a buffer where the frame will be stored. |
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.
This function call is blocking in nature, i.e. it will wait until a frame arrives.
If the ping buffer is the source of the data, the argument should be DeviceAddress + XEL_RXBUFF_OFFSET. If the pong buffer is the source of the data, the argument should be DeviceAddress + XEL_RXBUFF_OFFSET + XEL_BUFFER_OFFSET. The function does not take the different buffers into consideration.
References XEL_FCS_SIZE, XEL_HEADER_SIZE, XEL_MAX_FRAME_SIZE, XEL_RPLR_LENGTH_MASK_HI, XEL_RPLR_LENGTH_MASK_LO, XEL_RPLR_OFFSET, XEL_RSR_RECV_DONE_MASK, XEL_RXBUFF_OFFSET, XEmacLite_AlignedRead(), XEmacLite_GetRxStatus, XEmacLite_IsRxEmpty, XEmacLite_ReadReg, and XEmacLite_SetRxStatus.
int XEmacLite_SelfTest | ( | XEmacLite * | InstancePtr | ) |
Performs a SelfTest on the EmacLite device as follows:
InstancePtr | is a pointer to the XEmacLite instance . |
References XEmacLite_Config::BaseAddress, XEmacLite_Config::RxPingPong, XEmacLite_Config::TxPingPong, XEL_BUFFER_OFFSET, XEL_RXBUFF_OFFSET, XEL_TXBUFF_OFFSET, XEmacLite_AlignedRead(), and XEmacLite_AlignedWrite().
Referenced by EMACLiteSelfTestExample().
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.
References XEmacLite_Config::BaseAddress, XEmacLite_Config::TxPingPong, XEL_BUFFER_OFFSET, XEL_MAX_TX_FRAME_SIZE, XEL_TPLR_LENGTH_MASK_HI, XEL_TPLR_LENGTH_MASK_LO, XEL_TPLR_OFFSET, XEL_TSR_XMIT_ACTIVE_MASK, XEL_TSR_XMIT_BUSY_MASK, XEL_TSR_XMIT_IE_MASK, XEmacLite_AlignedWrite(), XEmacLite_GetTxStatus, XEmacLite_NextTransmitAddr, XEmacLite_SetTxStatus, and XEmacLite_WriteReg.
void XEmacLite_SendFrame | ( | UINTPTR | BaseAddress, |
u8 * | FramePtr, | ||
unsigned | ByteCount | ||
) |
Send an Ethernet frame.
The size is the total frame size, including header. This function blocks waiting for the frame to be transmitted.
BaseAddress | is the base address of the device |
FramePtr | is a pointer to frame |
ByteCount | is the size, in bytes, of the frame |
This function call is blocking in nature, i.e. it will wait until the frame is transmitted. This function can hang and not exit if the hardware is not configured properly.
If the ping buffer is the destination of the data, the argument should be DeviceAddress + XEL_TXBUFF_OFFSET. If the pong buffer is the destination of the data, the argument should be DeviceAddress + XEL_TXBUFF_OFFSET + XEL_BUFFER_OFFSET. The function does not take the different buffers into consideration.
References XEL_TPLR_LENGTH_MASK_HI, XEL_TPLR_LENGTH_MASK_LO, XEL_TPLR_OFFSET, XEL_TSR_XMIT_BUSY_MASK, XEmacLite_AlignedWrite(), XEmacLite_GetTxStatus, XEmacLite_IsTxDone, XEmacLite_SetTxStatus, and XEmacLite_WriteReg.
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 |
- TX must be idle and RX should be idle for deterministic results. It is recommended that this function should be called after the initialization and before transmission of any packets from the device. - Function will not return if hardware is absent or not functioning properly. - The MAC address can be programmed using any of the two transmit buffers (if configured).
References XEL_MAC_ADDR_SIZE, XEL_TPLR_OFFSET, XEL_TSR_PROG_MAC_ADDR, XEmacLite_AlignedWrite(), XEmacLite_GetTxStatus, XEmacLite_NextTransmitAddr, XEmacLite_SetTxStatus, and XEmacLite_WriteReg.
Referenced by EmacLiteIntrExample(), EmacLiteIntrLoopbackExample(), EmacLitePhyLoopbackExample(), and EmacLitePolledExample().
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. |
Referenced by EmacLiteIntrExample(), EmacLiteIntrLoopbackExample(), and EmacLitePhyLoopbackExample().
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. |
Referenced by EmacLiteIntrExample(), EmacLiteIntrLoopbackExample(), and EmacLitePhyLoopbackExample().
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. |
References XEmacLite_Config::TxPingPong, XEL_BUFFER_OFFSET, XEL_TSR_XMIT_ACTIVE_MASK, XEL_TSR_XMIT_BUSY_MASK, and XEmacLite_GetTxStatus.
Referenced by EmacLiteIntrExample(), EmacLiteIntrLoopbackExample(), EmacLitePhyLoopbackExample(), and EmacLitePolledExample().
XEmacLite_Config XEmacLite_ConfigTable[] |
This table contains configuration information for each EmacLite device in the system.
XEmacLite_Config XEmacLite_ConfigTable[XPAR_XEMACLITE_NUM_INSTANCES] |
This table contains configuration information for each EmacLite device in the system.
XEmacLite_Config XEmacLite_ConfigTable[] |
This table contains configuration information for each EmacLite device in the system.