📄 xusbps.h
字号:
XUsbPs_dTD *dTDCurr; /**< Buffer to the currently processed descriptor. */ u8 *dTDBufs; /**< Pointer to the first buffer of the buffer list for this * endpoint. */ XUsbPs_EpHandlerFunc HandlerFunc; /**< Handler function for this endpoint. */ void *HandlerRef; /**< User data reference for the handler. */} XUsbPs_EpOut;/** * The following data structure represents IN endpoint. */typedef struct { XUsbPs_dQH *dQH; /**< Pointer to the Queue Head structure of the endpoint. */ XUsbPs_dTD *dTDs; /**< List of pointers to the Transfer Descriptors of the * endpoint. */ XUsbPs_dTD *dTDHead; /**< Buffer to the next available descriptor in the list. */ XUsbPs_dTD *dTDTail; /**< Buffer to the last unsent descriptor in the list*/ XUsbPs_EpHandlerFunc HandlerFunc; /**< Handler function for this endpoint. */ void *HandlerRef; /**< User data reference for the handler. */} XUsbPs_EpIn;/** * The following data structure represents an endpoint used internally * by the L0/L1 driver. */typedef struct { /* Each endpoint has an OUT and an IN component. */ XUsbPs_EpOut Out; /**< OUT endpoint structure */ XUsbPs_EpIn In; /**< IN endpoint structure */} XUsbPs_Endpoint;/** * The following structure is used by the user to receive Setup Data from an * endpoint. Using this structure simplifies the process of interpreting the * setup data in the core's data fields. * * The naming scheme for the members of this structure is different from the * naming scheme found elsewhere in the code. The members of this structure are * defined in the Chapter 9 USB reference guide. Using this naming scheme makes * it easier for people familiar with the standard to read the code. */typedef struct { u8 bmRequestType; /**< bmRequestType in setup data */ u8 bRequest; /**< bRequest in setup data */ u16 wValue; /**< wValue in setup data */ u16 wIndex; /**< wIndex in setup data */ u16 wLength; /**< wLength in setup data */}XUsbPs_SetupData;/** * Data structures used to configure endpoints. */typedef struct { u32 Type; /**< Endpoint type: - XUSBPS_EP_TYPE_CONTROL - XUSBPS_EP_TYPE_ISOCHRONOUS - XUSBPS_EP_TYPE_BULK - XUSBPS_EP_TYPE_INTERRUPT */ u32 NumBufs; /**< Number of buffers to be handled by this endpoint. */ u32 BufSize; /**< Buffer size. Only relevant for OUT (receive) Endpoints. */ u16 MaxPacketSize; /**< Maximum packet size for this endpoint. This number will * define the maximum number of bytes sent on the wire per * transaction. Range: 0..1024 */} XUsbPs_EpSetup;/** * Endpoint configuration structure. */typedef struct { XUsbPs_EpSetup Out; /**< OUT component of endpoint. */ XUsbPs_EpSetup In; /**< IN component of endpoint. */} XUsbPs_EpConfig;/** * The XUsbPs_DeviceConfig structure contains the configuration information to * configure the USB controller for DEVICE mode. This data structure is used * with the XUsbPs_ConfigureDevice() function call. */typedef struct { u8 NumEndpoints; /**< Number of Endpoints for the controller. This number depends on the runtime configuration of driver. The driver may configure fewer endpoints than are available in the core. */ XUsbPs_EpConfig EpCfg[XUSBPS_MAX_ENDPOINTS]; /**< List of endpoint configurations. */ u32 DMAMemVirt; /**< Virtual base address of DMAable memory allocated for the driver. */ u32 DMAMemPhys; /**< Physical base address of DMAable memory allocated for the driver. */ /* The following members are used internally by the L0/L1 driver. They * MUST NOT be accesses and/or modified in any way by the upper layers. * * The reason for having these members is that we generally try to * avoid allocating memory in the L0/L1 driver as we want to be OS * independent. In order to avoid allocating memory for this data * structure wihin L0/L1 we put it into the XUsbPs_DeviceConfig * structure which is allocated by the caller. */ XUsbPs_Endpoint Ep[XUSBPS_MAX_ENDPOINTS]; /**< List of endpoint metadata structures. */ u32 PhysAligned; /**< 64 byte aligned base address of the DMA memory block. Will be computed and set by the L0/L1 driver. */} XUsbPs_DeviceConfig;/** * The XUsbPs_Config structure contains configuration information for the USB * controller. * * This structure only contains the basic configuration for the controller. The * caller also needs to initialize the controller for the DEVICE mode * using the XUsbPs_DeviceConfig data structures with the * XUsbPs_ConfigureDevice() function call */typedef struct { u16 DeviceID; /**< Unique ID of controller. */ u32 BaseAddress; /**< Core register base address. */} XUsbPs_Config;/** * The XUsbPs driver instance data. The user is required to allocate a * variable of this type for every USB controller in the system. A pointer to a * variable of this type is then passed to the driver API functions. */typedef struct { XUsbPs_Config Config; /**< Configuration structure */ int CurrentAltSetting; /**< Current alternative setting of interface */ void *UserDataPtr; /**< Data pointer to be used by upper layers to store application dependent data structures. The upper layers are responsible to allocated and free the memory. The driver will not mofidy this data pointer. */ /** * The following structures hold the configuration for DEVICE mode * of the controller. They are initialized using the * XUsbPs_ConfigureDevice() function call. */ XUsbPs_DeviceConfig DeviceConfig; /**< Configuration for the DEVICE mode. */ XUsbPs_IntrHandlerFunc HandlerFunc; /**< Handler function for the controller. */ void *HandlerRef; /**< User data reference for the handler. */ u32 HandlerMask; /**< User interrupt mask. Defines which interrupts will cause * the callback to be called. */} XUsbPs;/***************** Macros (Inline Functions) Definitions *********************//****************************************************************************** * * USB CONTROLLER RELATED MACROS * ******************************************************************************//*****************************************************************************//** * This macro returns the current frame number. * * @param InstancePtr is a pointer to the XUsbPs instance of the * controller. * * @return The current frame number. * * @note C-style signature: * u32 XUsbPs_GetFrameNum(const XUsbPs *InstancePtr) * ******************************************************************************/#define XUsbPs_GetFrameNum(InstancePtr) \ XUsbPs_ReadReg((InstancePtr)->Config.BaseAddress, XUSBPS_FRAME_OFFSET)/*****************************************************************************//** * This macro starts the USB engine. * * @param InstancePtr is a pointer to the XUsbPs instance of the * controller. * * @note C-style signature: * void XUsbPs_Start(XUsbPs *InstancePtr) * ******************************************************************************/#define XUsbPs_Start(InstancePtr) \ XUsbPs_SetBits(InstancePtr, XUSBPS_CMD_OFFSET, XUSBPS_CMD_RS_MASK)/*****************************************************************************//** * This macro stops the USB engine. * * @param InstancePtr is a pointer to the XUsbPs instance of the * controller. * * @note C-style signature: * void XUsbPs_Stop(XUsbPs *InstancePtr) * ******************************************************************************/#define XUsbPs_Stop(InstancePtr) \ XUsbPs_ClrBits(InstancePtr, XUSBPS_CMD_OFFSET, XUSBPS_CMD_RS_MASK)/*****************************************************************************//** * This macro forces the USB engine to be in Full Speed (FS) mode. * * @param InstancePtr is a pointer to the XUsbPs instance of the * controller. * * @note C-style signature: * void XUsbPs_ForceFS(XUsbPs *InstancePtr) * ******************************************************************************/#define XUsbPs_ForceFS(InstancePtr) \ XUsbPs_SetBits(InstancePtr, XUSBPS_PORTSCR1_OFFSET, \ XUSBPS_PORTSCR_PFSC_MASK)/*****************************************************************************//** * This macro starts the USB Timer 0, with repeat option for period of * one second. * * @param InstancePtr is a pointer to XUsbPs instance of the controller. * @param Interval is the interval for Timer0 to generate an interrupt * * @note C-style signature: * void XUsbPs_StartTimer0(XUsbPs *InstancePtr, u32 Interval) * ******************************************************************************/#define XUsbPs_StartTimer0(InstancePtr, Interval) \{ \ XUsbPs_WriteReg((InstancePtr)->Config.BaseAddress, \ XUSBPS_TIMER0_LD_OFFSET, (Interval)); \ XUsbPs_SetBits(InstancePtr, XUSBPS_TIMER0_CTL_OFFSET, \ XUSBPS_TIMER_RUN_MASK | \ XUSBPS_TIMER_RESET_MASK | \ XUSBPS_TIMER_REPEAT_MASK); \} \/*****************************************************************************//*** This macro stops Timer 0.** @param InstancePtr is a pointer to XUsbPs instance of the controller.** @note C-style signature:* void XUsbPs_StopTimer0(XUsbPs *InstancePtr)*******************************************************************************/#define XUsbPs_StopTimer0(InstancePtr) \ XUsbPs_ClrBits(InstancePtr, XUSBPS_TIMER0_CTL_OFFSET, \ XUSBPS_TIMER_RUN_MASK)/*****************************************************************************//*** This macro reads Timer 0.** @param InstancePtr is a pointer to XUsbPs instance of the controller.** @note C-style signature:* void XUsbPs_ReadTimer0(XUsbPs *InstancePtr)*******************************************************************************/#define XUsbPs_ReadTimer0(InstancePtr) \ XUsbPs_ReadReg((InstancePtr)->Config.BaseAddress, \ XUSBPS_TIMER0_CTL_OFFSET) & \ XUSBPS_TIMER_COUNTER_MASK/*****************************************************************************//*** This macro force remote wakeup on host** @param InstancePtr is a pointer to XUsbPs instance of the controller.** @note C-style signature:* void XUsbPs_RemoteWakeup(XUsbPs *InstancePtr)*******************************************************************************/#define XUsbPs_RemoteWakeup(InstancePtr) \ XUsbPs_SetBits(InstancePtr, XUSBPS_PORTSCR1_OFFSET, \ XUSBPS_PORTSCR_FPR_MASK)/****************************************************************************** * * ENDPOINT RELATED MACROS * ******************************************************************************//*****************************************************************************//*** This macro enables the given endpoint for the given direction.** @param InstancePtr is a pointer to the XUsbPs instance of the* controller.* @param EpNum is number of the endpoint to enable.* @param Dir is direction of the endpoint (bitfield):* - XUSBPS_EP_DIRECTION_OUT* - XUSBPS_EP_DIRECTION_IN** @note C-style signature:* void XUsbPs_EpEnable(XUsbPs *InstancePtr, u8 EpNum, u8 Dir)*******************************************************************************/#define XUsbPs_EpEnable(InstancePtr, EpNum, Dir) \ XUsbPs_SetBits(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 disables 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 disable.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -