📄 xusbps_endpoint.h
字号:
/*****************************************************************************//** * * This macro clears the Terminate bit for the given Transfer Descriptor. * * @param dTDPtr is a pointer to the dTD element. * * @note C-style signature: * void XUsbPs_dTDClrTerminate(u32 dTDPtr) * ******************************************************************************/#define XUsbPs_dTDClrTerminate(dTDPtr) \ XUsbPs_WritedTD(dTDPtr, XUSBPS_dTDNLP, \ XUsbPs_ReaddTD(dTDPtr, XUSBPS_dTDNLP) & \ ~XUSBPS_dTDNLP_T_MASK)/*****************************************************************************//** * * This macro checks if the given descriptor is active. * * @param dTDPtr is a pointer to the dTD element. * * @return * - TRUE: The buffer is active. * - FALSE: The buffer is not active. * * @note C-style signature: * int XUsbPs_dTDIsActive(u32 dTDPtr) * ******************************************************************************/#define XUsbPs_dTDIsActive(dTDPtr) \ ((XUsbPs_ReaddTD(dTDPtr, XUSBPS_dTDTOKEN) & \ XUSBPS_dTDTOKEN_ACTIVE_MASK) ? TRUE : FALSE)/*****************************************************************************//** * * This macro sets the Active bit for the given Transfer Descriptor. * * @param dTDPtr is a pointer to the dTD element. * * @note C-style signature: * void XUsbPs_dTDSetActive(u32 dTDPtr) * ******************************************************************************/#define XUsbPs_dTDSetActive(dTDPtr) \ XUsbPs_WritedTD(dTDPtr, XUSBPS_dTDTOKEN, \ XUsbPs_ReaddTD(dTDPtr, XUSBPS_dTDTOKEN) | \ XUSBPS_dTDTOKEN_ACTIVE_MASK)/*****************************************************************************//** * * This macro reads the content of a field in a Transfer Descriptor. * * @param dTDPtr is a pointer to the dTD element. * @param Id is the field ID inside the dTD element to read. * * @note C-style signature: * u32 XUsbPs_ReaddTD(u32 dTDPtr, u32 Id) * ******************************************************************************/#define XUsbPs_ReaddTD(dTDPtr, Id) (*(u32 *)((u32)(dTDPtr) + (u32)(Id)))/*****************************************************************************//** * * This macro writes a value to a field in a Transfer Descriptor. * * @param dTDPtr is pointer to the dTD element. * @param Id is the field ID inside the dTD element to read. * @param Val is the value to write to the field. * * @note C-style signature: * u32 XUsbPs_WritedTD(u32 dTDPtr, u32 Id, u32 Val) * ******************************************************************************/#define XUsbPs_WritedTD(dTDPtr, Id, Val) \ (*(u32 *) ((u32)(dTDPtr) + (u32)(Id)) = (u32)(Val))/******************************************************************************//** * Endpoint Device Queue Head * * Device queue heads are arranged in an array in a continuous area of memory * pointed to by the ENDPOINTLISTADDR pointer. The device controller will index * into this array based upon the endpoint number received from the USB bus. * All information necessary to respond to transactions for all primed * transfers is contained in this list so the Device Controller can readily * respond to incoming requests without having to traverse a linked list. * * The device Endpoint Queue Head (dQH) is where all transfers are managed. The * dQH is a 48-byte data structure, but must be aligned on a 64-byte boundary. * During priming of an endpoint, the dTD (device transfer descriptor) is * copied into the overlay area of the dQH, which starts at the nextTD pointer * DWord and continues through the end of the buffer pointers DWords. After a * transfer is complete, the dTD status DWord is updated in the dTD pointed to * by the currentTD pointer. While a packet is in progress, the overlay area of * the dQH is used as a staging area for the dTD so that the Device Controller * can access needed information with little minimal latency. * * @note * Software must ensure that no interface data structure reachable by the * Device Controller spans a 4K-page boundary. The first element of the * Endpoint Queue Head List must be aligned on a 4K boundary. */#define XUSBPS_dQHCFG 0x00 /**< dQH Configuration */#define XUSBPS_dQHCPTR 0x04 /**< dQH Current dTD Pointer */#define XUSBPS_dQHdTDNLP 0x08 /**< dTD Next Link Ptr in dQH overlay */#define XUSBPS_dQHdTDTOKEN 0x0C /**< dTD Token in dQH overlay */#define XUSBPS_dQHSUB0 0x28 /**< USB dQH Setup Buffer 0 */#define XUSBPS_dQHSUB1 0x2C /**< USB dQH Setup Buffer 1 *//** @name dQH Configuration (dQHCFG) bit positions. * @{ */#define XUSBPS_dQHCFG_IOS_MASK 0x00008000 /**< USB dQH Interrupt on Setup Bit */#define XUSBPS_dQHCFG_MPL_MASK 0x07FF0000 /**< USB dQH Maximum Packet Length * Field [10:0] */#define XUSBPS_dQHCFG_MPL_SHIFT 16#define XUSBPS_dQHCFG_ZLT_MASK 0x20000000 /**< USB dQH Zero Length Termination * Select Bit */#define XUSBPS_dQHCFG_MULT_MASK 0xC0000000 /* USB dQH Number of Transactions Field * [1:0] */#define XUSBPS_dQHCFG_MULT_SHIFT 30/* @} *//*****************************************************************************//** * * This macro sets the Maximum Packet Length field of the give Queue Head. * * @param dQHPtr is a pointer to the dQH element. * @param Len is the length to be set. * * @note C-style signature: * void XUsbPs_dQHSetMaxPacketLen(u32 dQHPtr, u32 Len) * ******************************************************************************/#define XUsbPs_dQHSetMaxPacketLen(dQHPtr, Len) \ XUsbPs_WritedQH(dQHPtr, XUSBPS_dQHCFG, \ (XUsbPs_ReaddQH(dQHPtr, XUSBPS_dQHCFG) & \ ~XUSBPS_dQHCFG_MPL_MASK) | ((Len) << 16))/*****************************************************************************//** * * This macro sets the Interrupt On Setup (IOS) bit for an endpoint. * * @param dQHPtr is a pointer to the dQH element. * * @note C-style signature: * void XUsbPs_dQHSetIOS(u32 dQHPtr) * ******************************************************************************/#define XUsbPs_dQHSetIOS(dQHPtr) \ XUsbPs_WritedQH(dQHPtr, XUSBPS_dQHCFG, \ XUsbPs_ReaddQH(dQHPtr, XUSBPS_dQHCFG) | \ XUSBPS_dQHCFG_IOS_MASK)/*****************************************************************************//** * * This macro clears the Interrupt On Setup (IOS) bit for an endpoint. * * @param dQHPtr is a pointer to the dQH element. * * @note C-style signature: * void XUsbPs_dQHClrIOS(u32 dQHPtr) * ******************************************************************************/#define XUsbPs_dQHClrIOS(dQHPtr) \ XUsbPs_WritedQH(dQHPtr, XUSBPS_dQHCFG, \ XUsbPs_ReaddQH(dQHPtr, XUSBPS_dQHCFG) & \ ~XUSBPS_dQHCFG_IOS_MASK)/*****************************************************************************//** * * This macro enables Zero Length Termination for the endpoint. * * @param dQHPtr is a pointer to the dQH element. * * @note C-style signature: * void XUsbPs_dQHEnableZLT(u32 dQHPtr) * * ******************************************************************************/#define XUsbPs_dQHEnableZLT(dQHPtr) \ XUsbPs_WritedQH(dQHPtr, XUSBPS_dQHCFG, \ XUsbPs_ReaddQH(dQHPtr, XUSBPS_dQHCFG) & \ ~XUSBPS_dQHCFG_ZLT_MASK)/*****************************************************************************//** * * This macro disables Zero Length Termination for the endpoint. * * @param dQHPtr is a pointer to the dQH element. * * @note C-style signature: * void XUsbPs_dQHDisableZLT(u32 dQHPtr) * * ******************************************************************************/#define XUsbPs_dQHDisableZLT(dQHPtr) \ XUsbPs_WritedQH(dQHPtr, XUSBPS_dQHCFG, \ XUsbPs_ReaddQH(dQHPtr, XUSBPS_dQHCFG) | \ XUSBPS_dQHCFG_ZLT_MASK)/*****************************************************************************//** * * This macro reads the content of a field in a Queue Head. * * @param dQHPtr is a pointer to the dQH element. * @param Id is the Field ID inside the dQH element to read. * * @note C-style signature: * u32 XUsbPs_ReaddQH(u32 dQHPtr, u32 Id) * ******************************************************************************/#define XUsbPs_ReaddQH(dQHPtr, Id) (*(u32 *)((u32)(dQHPtr) + (u32) (Id)))/*****************************************************************************//** * * This macro writes a value to a field in a Queue Head. * * @param dQHPtr is a pointer to the dQH element. * @param Id is the Field ID inside the dQH element to read. * @param Val is the Value to write to the field. * * @note C-style signature: * u32 XUsbPs_WritedQH(u32 dQHPtr, u32 Id, u32 Val) * ******************************************************************************/#define XUsbPs_WritedQH(dQHPtr, Id, Val) \ (*(u32 *) ((u32)(dQHPtr) + (u32)(Id)) = (u32)(Val))#ifdef __cplusplus}#endif#endif /* XUSBPS_ENDPOINT_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -