⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xusbps.h

📁 自学ZedBoard:使用IP通过ARM PS访问FPGA(源代码)
💻 H
📖 第 1 页 / 共 3 页
字号:
* @param	Dir is the direction of the endpoint (bitfield):* 		- XUSBPS_EP_DIRECTION_OUT* 		- XUSBPS_EP_DIRECTION_IN** @note		C-style signature:* 		void XUsbPs_EpDisable(XUsbPs *InstancePtr, u8 EpNum, u8 Dir)*******************************************************************************/#define XUsbPs_EpDisable(InstancePtr, EpNum, Dir) \	XUsbPs_ClrBits(InstancePtr, XUSBPS_EPCRn_OFFSET(EpNum),		 \		((Dir) & XUSBPS_EP_DIRECTION_OUT ? XUSBPS_EPCR_RXE_MASK : 0) | \		((Dir) & XUSBPS_EP_DIRECTION_IN  ? XUSBPS_EPCR_TXE_MASK : 0))/*****************************************************************************//*** This macro stalls the given endpoint for the given direction, and flush* the buffers.** @param	InstancePtr is a pointer to the XUsbPs instance of the*		controller.* @param	EpNum is number of the endpoint to stall.* @param	Dir is the direction of the endpoint (bitfield):* 			- XUSBPS_EP_DIRECTION_OUT* 			- XUSBPS_EP_DIRECTION_IN** @note		C-style signature:*		void XUsbPs_EpStall(XUsbPs *InstancePtr, u8 EpNum, u8 Dir)*******************************************************************************/#define XUsbPs_EpStall(InstancePtr, EpNum, Dir) \	XUsbPs_SetBits(InstancePtr, XUSBPS_EPCRn_OFFSET(EpNum),	 \	((Dir) & XUSBPS_EP_DIRECTION_OUT ? XUSBPS_EPCR_RXS_MASK : 0) | \	((Dir) & XUSBPS_EP_DIRECTION_IN  ? XUSBPS_EPCR_TXS_MASK : 0))/*****************************************************************************//*** This macro unstalls the given endpoint for the given direction.** @param	InstancePtr is a pointer to the XUsbPs instance of the*		controller.* @param	EpNum is the Number of the endpoint to unstall.* @param	Dir is the Direction of the endpoint (bitfield):* 		- XUSBPS_EP_DIRECTION_OUT* 		- XUSBPS_EP_DIRECTION_IN** @note		C-style signature:* 		void XUsbPs_EpUnStall(XUsbPs *InstancePtr, u8 EpNum, u8 Dir)*******************************************************************************/#define XUsbPs_EpUnStall(InstancePtr, EpNum, Dir) \	XUsbPs_ClrBits(InstancePtr, XUSBPS_EPCRn_OFFSET(EpNum),	 \	((Dir) & XUSBPS_EP_DIRECTION_OUT ? XUSBPS_EPCR_RXS_MASK : 0) | \	((Dir) & XUSBPS_EP_DIRECTION_IN  ? XUSBPS_EPCR_TXS_MASK : 0))/*****************************************************************************//*** This macro flush an endpoint upon interface disable** @param	InstancePtr is a pointer to the XUsbPs instance of the*		controller.* @param	EpNum is the number of the endpoint to flush.* @param	Dir is the direction of the endpoint (bitfield):* 			- XUSBPS_EP_DIRECTION_OUT* 			- XUSBPS_EP_DIRECTION_IN** @note		C-style signature:*		void XUsbPs_EpFlush(XUsbPs *InstancePtr, u8 EpNum, u8 Dir)*******************************************************************************/#define XUsbPs_EpFlush(InstancePtr, EpNum, Dir) \	XUsbPs_SetBits(InstancePtr, XUSBPS_EPFLUSH_OFFSET,	\		EpNum << ((Dir) & XUSBPS_EP_DIRECTION_OUT ?		\			XUSBPS_EPFLUSH_RX_SHIFT:XUSBPS_EPFLUSH_TX_SHIFT)) \/*****************************************************************************//*** This macro enables the interrupts defined by the bit mask.** @param	InstancePtr is a pointer to XUsbPs instance of the controller.* @param	IntrMask is the Bit mask of interrupts to be enabled.** @note		C-style signature:*		void XUsbPs_IntrEnable(XUsbPs *InstancePtr, u32 IntrMask)*******************************************************************************/#define XUsbPs_IntrEnable(InstancePtr, IntrMask)	\		XUsbPs_SetBits(InstancePtr, XUSBPS_IER_OFFSET, IntrMask)/*****************************************************************************//*** This function disables the interrupts defined by the bit mask.*** @param	InstancePtr is a pointer to XUsbPs instance of the controller.* @param	IntrMask is a Bit mask of interrupts to be disabled.** @note		C-style signature:* 		void XUsbPs_IntrDisable(XUsbPs *InstancePtr, u32 IntrMask)*******************************************************************************/#define XUsbPs_IntrDisable(InstancePtr, IntrMask)	\		XUsbPs_ClrBits(InstancePtr, XUSBPS_IER_OFFSET, IntrMask)/*****************************************************************************//*** This macro enables the endpoint NAK interrupts defined by the bit mask.** @param	InstancePtr is a pointer to XUsbPs instance of the controller.* @param	NakIntrMask is the Bit mask of endpoint NAK interrupts to be*		enabled.* @note		C-style signature:* 		void XUsbPs_NakIntrEnable(XUsbPs *InstancePtr, u32 NakIntrMask)*******************************************************************************/#define XUsbPs_NakIntrEnable(InstancePtr, NakIntrMask)	\	XUsbPs_SetBits(InstancePtr, XUSBPS_EPNAKIER_OFFSET, NakIntrMask)/*****************************************************************************//*** This macro disables the endpoint NAK interrupts defined by the bit mask.** @param	InstancePtr is a pointer to XUsbPs instance of the controller.* @param	NakIntrMask is a Bit mask of endpoint NAK interrupts to be*		disabled.** @note* 	C-style signature:* 	void XUsbPs_NakIntrDisable(XUsbPs *InstancePtr, u32 NakIntrMask)*******************************************************************************/#define XUsbPs_NakIntrDisable(InstancePtr, NakIntrMask)	\	XUsbPs_ClrBits(InstancePtr, XUSBPS_EPNAKIER_OFFSET, NakIntrMask)/*****************************************************************************//*** This function clears the endpoint NAK interrupts status defined by the* bit mask.** @param	InstancePtr is a pointer to XUsbPs instance of the controller.* @param	NakIntrMask is the Bit mask of endpoint NAK interrupts to be cleared.** @note		C-style signature:* 		void XUsbPs_NakIntrClear(XUsbPs *InstancePtr, u32 NakIntrMask)*******************************************************************************/#define XUsbPs_NakIntrClear(InstancePtr, NakIntrMask)			\	XUsbPs_WriteReg((InstancePtr)->Config.BaseAddress,		\				XUSBPS_EPNAKISR_OFFSET, NakIntrMask)/*****************************************************************************//*** This macro sets the Interrupt Threshold value in the control register** @param	InstancePtr is a pointer to XUsbPs instance of the controller.* @param	Threshold is the Interrupt threshold to be set.* 		Allowed values:*			- XUSBPS_CMD_ITHRESHOLD_0 - Immediate interrupt*			- XUSBPS_CMD_ITHRESHOLD_1 - 1 Frame*			- XUSBPS_CMD_ITHRESHOLD_2 - 2 Frames*			- XUSBPS_CMD_ITHRESHOLD_4 - 4 Frames*			- XUSBPS_CMD_ITHRESHOLD_8 - 8 Frames*			- XUSBPS_CMD_ITHRESHOLD_16 - 16 Frames*			- XUSBPS_CMD_ITHRESHOLD_32 - 32 Frames*			- XUSBPS_CMD_ITHRESHOLD_64 - 64 Frames** @note* 	C-style signature:*	void XUsbPs_SetIntrThreshold(XUsbPs *InstancePtr, u8 Threshold)*******************************************************************************/#define XUsbPs_SetIntrThreshold(InstancePtr, Threshold)		\		XUsbPs_WriteReg((InstancePtr)->Config.BaseAddress,	\					XUSBPS_CMD_OFFSET, (Threshold))\/*****************************************************************************//*** This macro sets the Tripwire bit in the USB command register.** @param	InstancePtr is a pointer to XUsbPs instance of the controller.** @note		C-style signature:*		void XUsbPs_SetTripwire(XUsbPs *InstancePtr)*******************************************************************************/#define XUsbPs_SetTripwire(InstancePtr)				\		XUsbPs_SetBits(InstancePtr, XUSBPS_CMD_OFFSET,	\				XUSBPS_CMD_ATDTW_MASK)/*****************************************************************************//*** This macro clears the Tripwire bit in the USB command register.** @param	InstancePtr is a pointer to XUsbPs instance of the controller.** @note		C-style signature:*		void XUsbPs_ClrTripwire(XUsbPs *InstancePtr)*******************************************************************************/#define XUsbPs_ClrTripwire(InstancePtr)				\		XUsbPs_SetBits(InstancePtr, XUSBPS_CMD_OFFSET,	\				XUSBPS_CMD_ATDTW_MASK)/*****************************************************************************//*** This macro checks if the Tripwire bit in the USB command register is set.** @param	InstancePtr is a pointer to XUsbPs instance of the controller.** @return* 		- TRUE: The tripwire bit is still set.* 		- FALSE: The tripwire bit has been cleared.** @note		C-style signature:*		int XUsbPs_TripwireIsSet(XUsbPs *InstancePtr)*******************************************************************************/#define XUsbPs_TripwireIsSet(InstancePtr)				\		(XUsbPs_ReadReg((InstancePtr)->Config.BaseAddress, 	\				XUSBPS_CMD_OFFSET) &			\				XUSBPS_CMD_ATDTW_MASK ? TRUE : FALSE)/******************************************************************************** GENERAL REGISTER / BIT MANIPULATION MACROS*******************************************************************************//****************************************************************************//*** This macro sets the given bit mask in the register.** @param	InstancePtr is a pointer to XUsbPs instance of the controller.* @param	RegOffset is the register offset to be written.* @param	Bits is the Bits to be set in the register** @return	None.** @note		C-style signature:*		void XUsbPs_SetBits(u32 BaseAddress, u32 RegOffset, u32 Bits)******************************************************************************/#define XUsbPs_SetBits(InstancePtr, RegOffset, Bits) \	XUsbPs_WriteReg((InstancePtr)->Config.BaseAddress, RegOffset,	\		XUsbPs_ReadReg((InstancePtr)->Config.BaseAddress, 	\					RegOffset) | (Bits));/****************************************************************************//**** This macro clears the given bits in the register.** @param	InstancePtr is a pointer to XUsbPs instance of the controller.* @param	RegOffset is the register offset to be written.* @param	Bits are the bits to be cleared in the register** @return	None.** @note* 	C-style signature:*	void XUsbPs_ClrBits(u32 BaseAddress, u32 RegOffset, u32 Bits)******************************************************************************/#define XUsbPs_ClrBits(InstancePtr, RegOffset, Bits) \	XUsbPs_WriteReg((InstancePtr)->Config.BaseAddress, RegOffset,	\		XUsbPs_ReadReg((InstancePtr)->Config.BaseAddress, 	\				RegOffset) & ~(Bits));/************************** Function Prototypes ******************************//** * Setup / Initialize functions. * * Implemented in file xusbps.c */int XUsbPs_CfgInitialize(XUsbPs *InstancePtr,			  const XUsbPs_Config *ConfigPtr, u32 BaseAddress);int XUsbPs_ConfigureDevice(XUsbPs *InstancePtr,				const XUsbPs_DeviceConfig *CfgPtr);u32 XUsbPs_DeviceMemRequired(const XUsbPs_DeviceConfig *CfgPtr);/** * Common functions used for DEVICE/HOST mode. */int XUsbPs_Reset(XUsbPs *InstancePtr);/** * DEVICE mode specific functions. */int XUsbPs_BusReset(XUsbPs *InstancePtr);u32 XUsbPs_DeviceMemRequired(const XUsbPs_DeviceConfig *CfgPtr);int XUsbPs_SetDeviceAddress(XUsbPs *InstancePtr, u8 Address);/** * Handling Suspend and Resume. * * Implemented in xusbps.c */int XUsbPs_Suspend(const XUsbPs *InstancePtr);int XUsbPs_Resume(const XUsbPs *InstancePtr);int XUsbPs_RequestHostResume(const XUsbPs *InstancePtr);/* * Functions for managing Endpoints / Transfers * * Implemented in file xusbps_endpoint.c */int XUsbPs_EpBufferSend(XUsbPs *InstancePtr, u8 EpNum,			const u8 *BufferPtr, u32 BufferLen);int XUsbPs_EpBufferReceive(XUsbPs *InstancePtr, u8 EpNum,			u8 **BufferPtr, u32 *BufferLenPtr, u32 *Handle);void XUsbPs_EpBufferRelease(u32 Handle);int XUsbPs_EpSetHandler(XUsbPs *InstancePtr, u8 EpNum, u8 Direction,			XUsbPs_EpHandlerFunc CallBackFunc,			void *CallBackRef);int XUsbPs_EpGetSetupData(XUsbPs *InstancePtr, int EpNum,			XUsbPs_SetupData *SetupDataPtr);int XUsbPs_EpPrime(XUsbPs *InstancePtr, u8 EpNum, u8 Direction);int XUsbPs_ReconfigureEp(XUsbPs *InstancePtr, XUsbPs_DeviceConfig *CfgPtr,			int EpNum, unsigned short NewDirection, int DirectionChanged);/* * Interrupt handling functions * * Implemented in file xusbps_intr.c */void XUsbPs_IntrHandler(void *InstancePtr);int XUsbPs_IntrSetHandler(XUsbPs *InstancePtr,			   XUsbPs_IntrHandlerFunc CallBackFunc,			   void *CallBackRef, u32 Mask);/* * Helper functions for static configuration. * Implemented in xusbps_sinit.c */XUsbPs_Config *XUsbPs_LookupConfig(u16 DeviceId);#ifdef __cplusplus}#endif#endif /* XUSBPS_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -