📄 xemacps.h
字号:
/**< Generate FCS field and add PAD automatically for outgoing frames. * This option defaults to disabled (cleared) */#define XEMACPS_LENTYPE_ERR_OPTION 0x00000080/**< Enable Length/Type error checking for incoming frames. When this option is * set, the MAC will filter frames that have a mismatched type/length field * and if XEMACPS_REPORT_RXERR_OPTION is set, the user is notified when these * types of frames are encountered. When this option is cleared, the MAC will * allow these types of frames to be received. * * This option defaults to disabled (cleared) */#define XEMACPS_TRANSMITTER_ENABLE_OPTION 0x00000100/**< Enable the transmitter. * This option defaults to enabled (set) */#define XEMACPS_RECEIVER_ENABLE_OPTION 0x00000200/**< Enable the receiver * This option defaults to enabled (set) */#define XEMACPS_BROADCAST_OPTION 0x00000400/**< Allow reception of the broadcast address * This option defaults to enabled (set) */#define XEMACPS_MULTICAST_OPTION 0x00000800/**< Allows reception of multicast addresses programmed into hash * This option defaults to disabled (clear) */#define XEMACPS_RX_CHKSUM_ENABLE_OPTION 0x00001000/**< Enable the RX checksum offload * This option defaults to enabled (set) */#define XEMACPS_TX_CHKSUM_ENABLE_OPTION 0x00002000/**< Enable the TX checksum offload * This option defaults to enabled (set) */#define XEMACPS_DEFAULT_OPTIONS \ (XEMACPS_FLOW_CONTROL_OPTION | \ XEMACPS_FCS_INSERT_OPTION | \ XEMACPS_FCS_STRIP_OPTION | \ XEMACPS_BROADCAST_OPTION | \ XEMACPS_LENTYPE_ERR_OPTION | \ XEMACPS_TRANSMITTER_ENABLE_OPTION | \ XEMACPS_RECEIVER_ENABLE_OPTION | \ XEMACPS_RX_CHKSUM_ENABLE_OPTION | \ XEMACPS_TX_CHKSUM_ENABLE_OPTION)/**< Default options set when device is initialized or reset *//*@}*//** @name Callback identifiers * * These constants are used as parameters to XEmacPs_SetHandler() * @{ */#define XEMACPS_HANDLER_DMASEND 1#define XEMACPS_HANDLER_DMARECV 2#define XEMACPS_HANDLER_ERROR 3/*@}*//* Constants to determine the configuration of the hardware device. They are * used to allow the driver to verify it can operate with the hardware. */#define XEMACPS_MDIO_DIV_DFT MDC_DIV_32 /**< Default MDIO clock divisor *//* The next few constants help upper layers determine the size of memory * pools used for Ethernet buffers and descriptor lists. */#define XEMACPS_MAC_ADDR_SIZE 6 /* size of Ethernet header */#define XEMACPS_MTU 1500 /* max MTU size of Ethernet frame */#define XEMACPS_HDR_SIZE 14 /* size of Ethernet header */#define XEMACPS_HDR_VLAN_SIZE 18 /* size of Ethernet header with VLAN */#define XEMACPS_TRL_SIZE 4 /* size of Ethernet trailer (FCS) */#define XEMACPS_MAX_FRAME_SIZE (XEMACPS_MTU + XEMACPS_HDR_SIZE + \ XEMACPS_TRL_SIZE)#define XEMACPS_MAX_VLAN_FRAME_SIZE (XEMACPS_MTU + XEMACPS_HDR_SIZE + \ XEMACPS_HDR_VLAN_SIZE + XEMACPS_TRL_SIZE)/**************************** Type Definitions ******************************//** @name Typedefs for callback functions * * These callbacks are invoked in interrupt context. * @{ *//** * Callback invoked when frame(s) have been sent or received in interrupt * driven DMA mode. To set the send callback, invoke XEmacPs_SetHandler(). * * @param CallBackRef is user data assigned when the callback was set. * * @note * See xemacps_hw.h for bitmasks definitions and the device hardware spec for * further information on their meaning. * */typedef void (*XEmacPs_Handler) (void *CallBackRef);/** * Callback when an asynchronous error occurs. To set this callback, invoke * XEmacPs_SetHandler() with XEMACPS_HANDLER_ERROR in the HandlerType * paramter. * * @param CallBackRef is user data assigned when the callback was set. * @param Direction defines either receive or transmit error(s) has occurred. * @param ErrorWord definition varies with Direction * */typedef void (*XEmacPs_ErrHandler) (void *CallBackRef, u8 Direction, u32 ErrorWord);/*@}*//** * This typedef contains configuration information for a device. */typedef struct { u16 DeviceId; /**< Unique ID of device */ u32 BaseAddress;/**< Physical base address of IPIF registers */} XEmacPs_Config;/** * The XEmacPs driver instance data. The user is required to allocate a * structure of this type for every XEmacPs device in the system. A pointer * to a structure of this type is then passed to the driver API functions. */typedef struct XEmacPs { XEmacPs_Config Config; /* Hardware configuration */ u32 IsStarted; /* Device is currently started */ u32 IsReady; /* Device is initialized and ready */ u32 Options; /* Current options word */ XEmacPs_BdRing TxBdRing; /* Transmit BD ring */ XEmacPs_BdRing RxBdRing; /* Receive BD ring */ XEmacPs_Handler SendHandler; XEmacPs_Handler RecvHandler; void *SendRef; void *RecvRef; XEmacPs_ErrHandler ErrorHandler; void *ErrorRef;} XEmacPs;/***************** Macros (Inline Functions) Definitions ********************//****************************************************************************//*** Retrieve the Tx ring object. This object can be used in the various Ring* API functions.** @param InstancePtr is the DMA channel to operate on.** @return TxBdRing attribute** @note* C-style signature:* XEmacPs_BdRing XEmacPs_GetTxRing(XEmacPs *InstancePtr)******************************************************************************/#define XEmacPs_GetTxRing(InstancePtr) ((InstancePtr)->TxBdRing)/****************************************************************************//*** Retrieve the Rx ring object. This object can be used in the various Ring* API functions.** @param InstancePtr is the DMA channel to operate on.** @return RxBdRing attribute** @note* C-style signature:* XEmacPs_BdRing XEmacPs_GetRxRing(XEmacPs *InstancePtr)******************************************************************************/#define XEmacPs_GetRxRing(InstancePtr) ((InstancePtr)->RxBdRing)/****************************************************************************//**** Enable interrupts specified in <i>Mask</i>. The corresponding interrupt for* each bit set to 1 in <i>Mask</i>, will be enabled.** @param InstancePtr is a pointer to the instance to be worked on.* @param Mask contains a bit mask of interrupts to enable. The mask can* be formed using a set of bitwise or'd values.** @note* The state of the transmitter and receiver are not modified by this function.* C-style signature* void XEmacPs_IntEnable(XEmacPs *InstancePtr, u32 Mask)******************************************************************************/#define XEmacPs_IntEnable(InstancePtr, Mask) \ XEmacPs_WriteReg((InstancePtr)->Config.BaseAddress, \ XEMACPS_IER_OFFSET, \ (Mask & XEMACPS_IXR_ALL_MASK));/****************************************************************************//**** Disable interrupts specified in <i>Mask</i>. The corresponding interrupt for* each bit set to 1 in <i>Mask</i>, will be enabled.** @param InstancePtr is a pointer to the instance to be worked on.* @param Mask contains a bit mask of interrupts to disable. The mask can* be formed using a set of bitwise or'd values.** @note* The state of the transmitter and receiver are not modified by this function.* C-style signature* void XEmacPs_IntDisable(XEmacPs *InstancePtr, u32 Mask)******************************************************************************/#define XEmacPs_IntDisable(InstancePtr, Mask) \ XEmacPs_WriteReg((InstancePtr)->Config.BaseAddress, \ XEMACPS_IDR_OFFSET, \ (Mask & XEMACPS_IXR_ALL_MASK));/****************************************************************************//**** This macro triggers trasmit circuit to send data currently in TX buffer(s).** @param InstancePtr is a pointer to the XEmacPs instance to be worked on.** @return** @note** Signature: void XEmacPs_Transmit(XEmacPs *InstancePtr)******************************************************************************/#define XEmacPs_Transmit(InstancePtr) \ XEmacPs_WriteReg(InstancePtr->Config.BaseAddress, \ XEMACPS_NWCTRL_OFFSET, \ (XEmacPs_ReadReg(InstancePtr->Config.BaseAddress, \ XEMACPS_NWCTRL_OFFSET) | XEMACPS_NWCTRL_STARTTX_MASK))/****************************************************************************//**** This macro determines if the device is configured with checksum offloading* on the receive channel** @param InstancePtr is a pointer to the XEmacPs instance to be worked on.** @return** Boolean TRUE if the device is configured with checksum offloading, or* FALSE otherwise.** @note** Signature: u32 XEmacPs_IsRxCsum(XEmacPs *InstancePtr)******************************************************************************/#define XEmacPs_IsRxCsum(InstancePtr) \ ((XEmacPs_ReadReg((InstancePtr)->Config.BaseAddress, \ XEMACPS_NWCFG_OFFSET) & XEMACPS_NWCFG_RXCHKSUMEN_MASK) \ ? TRUE : FALSE)/****************************************************************************//**** This macro determines if the device is configured with checksum offloading* on the transmit channel** @param InstancePtr is a pointer to the XEmacPs instance to be worked on.** @return** Boolean TRUE if the device is configured with checksum offloading, or* FALSE otherwise.** @note** Signature: u32 XEmacPs_IsTxCsum(XEmacPs *InstancePtr)******************************************************************************/#define XEmacPs_IsTxCsum(InstancePtr) \ ((XEmacPs_ReadReg((InstancePtr)->Config.BaseAddress, \ XEMACPS_DMACR_OFFSET) & XEMACPS_DMACR_TCPCKSUM_MASK) \ ? TRUE : FALSE)/************************** Function Prototypes *****************************//* * Initialization functions in xemacps.c */int XEmacPs_CfgInitialize(XEmacPs *InstancePtr, XEmacPs_Config *CfgPtr, u32 EffectiveAddress);void XEmacPs_Start(XEmacPs *InstancePtr);void XEmacPs_Stop(XEmacPs *InstancePtr);void XEmacPs_Reset(XEmacPs *InstancePtr);/* * Lookup configuration in xemacps_sinit.c */XEmacPs_Config *XEmacPs_LookupConfig(u16 DeviceId);/* * Interrupt-related functions in xemacps_intr.c * DMA only and FIFO is not supported. This DMA does not support coalescing. */int XEmacPs_SetHandler(XEmacPs *InstancePtr, u32 HandlerType, void *FuncPtr, void *CallBackRef);void XEmacPs_IntrHandler(void *InstancePtr);/* * MAC configuration/control functions in XEmacPs_control.c */int XEmacPs_SetOptions(XEmacPs *InstancePtr, u32 Options);int XEmacPs_ClearOptions(XEmacPs *InstancePtr, u32 Options);u32 XEmacPs_GetOptions(XEmacPs *InstancePtr);int XEmacPs_SetMacAddress(XEmacPs *InstancePtr, void *AddressPtr, u8 Index);void XEmacPs_GetMacAddress(XEmacPs *InstancePtr, void *AddressPtr, u8 Index);int XEmacPs_SetHash(XEmacPs *InstancePtr, void *AddressPtr);void XEmacPs_ClearHash(XEmacPs *InstancePtr);void XEmacPs_GetHash(XEmacPs *InstancePtr, void *AddressPtr);void XEmacPs_SetMdioDivisor(XEmacPs *InstancePtr, XEmacPs_MdcDiv Divisor);void XEmacPs_SetOperatingSpeed(XEmacPs *InstancePtr, u16 Speed);u16 XEmacPs_GetOperatingSpeed(XEmacPs *InstancePtr);int XEmacPs_PhyRead(XEmacPs *InstancePtr, u32 PhyAddress, u32 RegisterNum, u16 *PhyDataPtr);int XEmacPs_PhyWrite(XEmacPs *InstancePtr, u32 PhyAddress, u32 RegisterNum, u16 PhyData);int XEmacPs_SetTypeIdCheck(XEmacPs *InstancePtr, u32 Id_Check, u8 Index);int XEmacPs_SendPausePacket(XEmacPs *InstancePtr);#ifdef __cplusplus}#endif#endif /* end of protection macro */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -