usb
Vitis Drivers API Documentation
Overview

Data Structures

struct  XUsb_EpConfig
 The XUsb_EpConfig structure is used to configure endpoints. More...
 
struct  XUsb_DeviceConfig
 The XUsb_DeviceConfig structure contains the configuration information to configure the USB controller for DEVICE mode. More...
 
struct  XUsb_Config
 The XUsb_Config structure contains configuration information for the USB controller. More...
 
struct  XUsb
 The XUsb driver instance data. More...
 

Macros

#define XUSB_DMA_BRR_CTRL   0x40000000
 DMA bufready ctrl bit. More...
 
#define XUsb_ReadReg(BaseAddress, RegOffset)   XUsb_In32((BaseAddress) + (RegOffset))
 Read from the specified USB device register. More...
 
#define XUsb_WriteReg(BaseAddress, RegOffset, RegisterValue)   XUsb_Out32((BaseAddress) + (RegOffset), (RegisterValue))
 Write to the specified USB device register. More...
 

Typedefs

typedef void(* XUsb_EpHandlerFunc )(void *CallBackRef, u8 EpNum, u32 EventType)
 This data type defines the callback function to be used for Endpoint handlers. More...
 
typedef void(* XUsb_IntrHandlerFunc )(void *CallBackRef, u32 InterruptType)
 This data type defines the callback function to be used for the general interrupt handler. More...
 

Functions

int XUsb_CfgInitialize (XUsb *InstancePtr, XUsb_Config *ConfigPtr, UINTPTR EffectiveAddr)
 This function initializes a XUsb instance/driver. More...
 
int XUsb_ConfigureDevice (XUsb *InstancePtr, XUsb_DeviceConfig *CfgPtr)
 This function initializes USB End points. More...
 
void XUsb_Start (XUsb *InstancePtr)
 This function starts the USB Device. More...
 
void XUsb_Stop (XUsb *InstancePtr)
 This function stops the USB device. More...
 
u32 XUsb_GetFrameNum (const XUsb *InstancePtr)
 This function returns the current frame number. More...
 
int XUsb_SetDeviceAddress (XUsb *InstancePtr, u8 Address)
 This function sets the USB device address. More...
 
void XUsb_SetTestMode (XUsb *InstancePtr, u8 TestMode, u8 *BufPtr)
 This function sets the USB device into a given test mode. More...
 
void XUsb_DmaReset (XUsb *InstancePtr)
 This function resets the DMA module of the USB device. More...
 
void XUsb_DmaTransfer (XUsb *InstancePtr, UINTPTR *SrcAddr, UINTPTR *DstAddr, u16 Length)
 This function sets the DMA registers with the given values to initiate a DMA data transfer. More...
 
void XUsb_ReadErrorCounters (XUsb *InstancePtr, u8 *BitStuffErrors, u8 *PidErrors, u8 *CrcErrors)
 This function reads the USB error counter register and returns the error counters information. More...
 
u8 XUsb_UlpiPhyReadRegister (XUsb *InstancePtr, u8 RegAddr)
 This function initiates the USB ULPI PHY register read transaction. More...
 
int XUsb_UlpiPhyWriteRegister (XUsb *InstancePtr, u8 RegAddr, u8 UlpiPhyRegData)
 This function initiates the USB ULPI PHY register write transaction. More...
 
void XUsb_SieReset (XUsb *InstancePtr)
 This function resets the Serial Interface Engine. More...
 
void XUsb_EpEnable (const XUsb *InstancePtr, u8 EpNum)
 This function enables the specified endpoint for all operations. More...
 
void XUsb_EpDisable (const XUsb *InstancePtr, u8 EpNum)
 This function disables the specified endpoint for all operations. More...
 
void XUsb_EpConfigure (XUsb *InstancePtr, u8 EpNum, XUsb_EpConfig *EpCfgPtr)
 This function configures a specific end point with the given configuration data. More...
 
int XUsb_EpDataSend (XUsb *InstancePtr, u8 EpNum, u8 *BufferPtr, u32 BufferLen)
 This function copies the transmit data to the end point buffer and enables the buffer for transmission. More...
 
int XUsb_EpDataRecv (XUsb *InstancePtr, u8 EpNum, u8 *BufferPtr, u32 BufferLen)
 This function copies the received data from end point buffer to the buffer passed and then makes the device ready for receiving data again into the same end point buffer. More...
 
void XUsb_EpStall (const XUsb *InstancePtr, u8 EpNum)
 This function stalls operations for the specified endpoint. More...
 
void XUsb_EpUnstall (const XUsb *InstancePtr, u8 EpNum)
 This function unstalls operations for the specified endpoint. More...
 
void XUsb_EpIsoTransferConfigure (XUsb *InstancePtr, u8 EpNum, u8 NoOfTransfers)
 This function sets the number of isochronous transfers in a microframe for a given endpoint. More...
 
void XUsb_IntrEnable (XUsb *InstancePtr, u32 Mask)
 This function enables the specified interrupts. More...
 
void XUsb_IntrDisable (XUsb *InstancePtr, u32 Mask)
 This function disables the specified interrupts. More...
 
void XUsb_IntrHandler (void *InstancePtr)
 This function is the interrupt handler for the USB driver. More...
 
void XUsb_IntrSetHandler (XUsb *InstancePtr, void *CallBackFunc, void *CallBackRef)
 This function installs an asynchronous callback function for the general interrupt (interrupts other than the endpoint and error interrupts). More...
 
void XUsb_EpSetHandler (XUsb *InstancePtr, u8 EpNum, XUsb_EpHandlerFunc *CallBackFunc, void *CallBackRef)
 This function sets the handler for endpoint events. More...
 
void XUsb_ErrIntrSetHandler (XUsb *InstancePtr, void *CallBackFunc, void *CallBackRef)
 This function installs an asynchronous callback function for the error events. More...
 
void XUsb_DmaIntrSetHandler (XUsb *InstancePtr, void *CallBackFunc, void *CallBackRef)
 This function installs an asynchronous callback function for the DMA events. More...
 
void XUsb_UlpiIntrSetHandler (XUsb *InstancePtr, void *CallBackFunc, void *CallBackRef)
 This function installs an asynchronous callback function for the ULPI PHY events. More...
 
XUsb_ConfigXUsb_LookupConfig (u16 DeviceId)
 Looks up the device configuration based on the unique device ID. More...
 

Variables

XUsb_Config XUsb_ConfigTable [XPAR_XUSB_NUM_INSTANCES]
 This table contains the configuration information for each of the USB devices in the system. More...
 
XUsb_Config XUsb_ConfigTable []
 This table contains the configuration information for each of the USB devices in the system. More...
 

Endpoint Direction

Definitions to be used with Endpoint related function that require a 'Direction' parameter.

NOTE: The direction is always defined from the perspective of the HOST! This means that an IN endpoint on the device is used for sending data while the OUT endpoint on the device is used for receiving data.

#define XUSB_EP_DIRECTION_IN   1
 Endpoint direction IN. More...
 
#define XUSB_EP_DIRECTION_OUT   0
 Endpoint direction OUT. More...
 

Speed

Definitions to be used with speed.

#define XUSB_EP_HIGH_SPEED   1
 High Speed. More...
 
#define XUSB_EP_FULL_SPEED   0
 Full Speed. More...
 

USB device specific global configuration constants.

#define XUSB_MAX_ENDPOINTS   8
 Maximum End Points. More...
 
#define XUSB_EP_NUMBER_ZERO   0
 End point Zero. More...
 
#define XUSB_DEVICEADDR_MAX   127
 Max device address. More...
 

USB device disconnect state

#define XUSB_DISCONNECTED   0x1
 Disconnected state. More...
 
#define XUSB_RESET   0x0
 Reset State. More...
 

Test Modes (Set Feature)

#define TEST_J   1
 Chirp J Test. More...
 
#define TEST_K   2
 Chirp K Test. More...
 
#define TEST_SE0_NAK   3
 Chirp SE0 Test. More...
 
#define TEST_PKT   4
 Packet Test. More...
 

Register Map

Register offsets for the USB device.

#define XUSB_EP0_CONFIG_OFFSET   0x0000
 EP0 Config Reg Offset. More...
 
#define XUSB_EP1_CONFIG_OFFSET   0x4000
 EP1 Config Reg Offset. More...
 
#define XUSB_SETUP_PKT_ADDR_OFFSET   0x0080
 Setup Packet Address. More...
 
#define XUSB_EP0_RAMBASE_OFFSET   0x0088
 EP0 RAM buffer Register. More...
 
#define XUSB_ADDRESS_OFFSET   0x0100
 Address Register. More...
 
#define XUSB_CONTROL_OFFSET   0x0104
 Control Register. More...
 
#define XUSB_STATUS_OFFSET   0x0108
 Status Register. More...
 
#define XUSB_FRAMENUM_OFFSET   0x010C
 Frame Number Register. More...
 
#define XUSB_IER_OFFSET   0x0110
 Interrupt Enable Reg. More...
 
#define XUSB_BUFFREADY_OFFSET   0x0114
 Buffer Ready Register. More...
 
#define XUSB_TESTMODE_OFFSET   0x0118
 Test Mode Register. More...
 
#define XUSB_ECR_OFFSET   0x011C
 USB Error Count Reg. More...
 
#define XUSB_UPAR_OFFSET   0x0120
 USB ULPI PHY Access Reg. More...
 
#define XUSB_DMA_RESET_OFFSET   0x0200
 DMA Soft Reset Register. More...
 
#define XUSB_DMA_CONTROL_OFFSET   0x0204
 DMA Control Register. More...
 
#define XUSB_DMA_DSAR_ADDR_OFFSET   0x0208
 DMA source Address Reg. More...
 
#define XUSB_DMA_DSAR_ADDR_OFFSET_LSB   0x0308
 DMA source Address Reg for LSB. More...
 
#define XUSB_DMA_DSAR_ADDR_OFFSET_MSB   0x030C
 DMA source Address Reg for MSB. More...
 
#define XUSB_DMA_DDAR_ADDR_OFFSET   0x020C
 DMA destination Addr Reg. More...
 
#define XUSB_DMA_DDAR_ADDR_OFFSET_LSB   0x0310
 DMA destination Addr Reg LSB. More...
 
#define XUSB_DMA_DDAR_ADDR_OFFSET_MSB   0x0314
 DMA destination Addr Reg MSB. More...
 
#define XUSB_DMA_LENGTH_OFFSET   0x0210
 DMA Length Register. More...
 
#define XUSB_DMA_STATUS_OFFSET   0x0214
 DMA Status Register. More...
 

Address Register

#define XUSB_ADDRESS_ADDR_MASK   0x7F
 Address Mask. More...
 

Control Register

#define XUSB_CONTROL_USB_READY_MASK   0x80000000
 USB ready Mask. More...
 
#define XUSB_REMOTE_WAKEUP_MASK   0x40000000
 Remote Wakeup Mask. More...
 
#define XUSB_CONTROL_SIE_RESET_MASK   0x20000000
 Soft Reset Mask. More...
 

Status Register and Interrupt Enable Register

Status Register

This register holds the status flags for the USB device.

Interrupt Enable Register

This register is used to enable interrupt sources for the USB device. Writing a '1' to a bit in this register enables the corresponding Interrupt. Writing a '0' to a bit in this register disables the corresponding Interrupt.

Both these registers have the same bit definitions and are only defined once.

#define XUSB_STATUS_GLOBAL_INTR_MASK   0x80000000
 Global Intr Enable. More...
 
#define XUSB_STATUS_PHY_ACCESS_MASK   0x40000000
 PHY access complete. More...
 
#define XUSB_STATUS_BITSTUFF_ERR_MASK   0x20000000
 USB Bit stuff error. More...
 
#define XUSB_STATUS_PID_ERR_MASK   0x10000000
 USB PID error. More...
 
#define XUSB_STATUS_CRC_ERR_MASK   0x08000000
 USB CRC error. More...
 
#define XUSB_STATUS_DMA_DONE_MASK   0x04000000
 DMA done. More...
 
#define XUSB_STATUS_DMA_ERROR_MASK   0x02000000
 DMA error. More...
 
#define XUSB_STATUS_RESUME_MASK   0x01000000
 USB resume Mask. More...
 
#define XUSB_STATUS_RESET_MASK   0x00800000
 USB Reset Mask. More...
 
#define XUSB_STATUS_SUSPEND_MASK   0x00400000
 USB Suspend Mask. More...
 
#define XUSB_STATUS_DISCONNECT_MASK   0x00200000
 USB Disconnect Mask. More...
 
#define XUSB_STATUS_FIFO_BUFF_RDY_MASK   0x00100000
 FIFO Buff Ready Mask. More...
 
#define XUSB_STATUS_FIFO_BUFF_FREE_MASK   0x00080000
 FIFO Buff Free Mask. More...
 
#define XUSB_STATUS_SETUP_PACKET_MASK   0x00040000
 Setup packet received. More...
 
#define XUSB_STATUS_SOF_PACKET_MASK   0x00020000
 SOF packet received. More...
 
#define XUSB_STATUS_HIGH_SPEED_MASK   0x00010000
 USB Speed Mask. More...
 
#define XUSB_STATUS_EP7_BUFF2_COMP_MASK   0x00008000
 EP 7 Buff 2 Processed. More...
 
#define XUSB_STATUS_EP6_BUFF2_COMP_MASK   0x00004000
 EP 6 Buff 2 Processed. More...
 
#define XUSB_STATUS_EP5_BUFF2_COMP_MASK   0x00002000
 EP 5 Buff 2 Processed. More...
 
#define XUSB_STATUS_EP4_BUFF2_COMP_MASK   0x00001000
 EP 4 Buff 2 Processed. More...
 
#define XUSB_STATUS_EP3_BUFF2_COMP_MASK   0x00000800
 EP 3 Buff 2 Processed. More...
 
#define XUSB_STATUS_EP2_BUFF2_COMP_MASK   0x00000400
 EP 2 Buff 2 Processed. More...
 
#define XUSB_STATUS_EP1_BUFF2_COMP_MASK   0x00000200
 EP 1 Buff 2 Processed. More...
 
#define XUSB_STATUS_EP7_BUFF1_COMP_MASK   0x00000080
 EP 7 Buff 1 Processed. More...
 
#define XUSB_STATUS_EP6_BUFF1_COMP_MASK   0x00000040
 EP 6 Buff 1 Processed. More...
 
#define XUSB_STATUS_EP5_BUFF1_COMP_MASK   0x00000020
 EP 5 Buff 1 Processed. More...
 
#define XUSB_STATUS_EP4_BUFF1_COMP_MASK   0x00000010
 EP 4 Buff 1 Processed. More...
 
#define XUSB_STATUS_EP3_BUFF1_COMP_MASK   0x00000008
 EP 3 Buff 1 Processed. More...
 
#define XUSB_STATUS_EP2_BUFF1_COMP_MASK   0x00000004
 EP 2 Buff 1 Processed. More...
 
#define XUSB_STATUS_EP1_BUFF1_COMP_MASK   0x00000002
 EP 1 Buff 1 Processed. More...
 
#define XUSB_STATUS_EP0_BUFF1_COMP_MASK   0x00000001
 EP 0 Buff 1 Processed. More...
 
#define XUSB_STATUS_EP_BUFF2_SHIFT   8
 EP buffer offset. More...
 

Frame Number Register

#define XUSB_FRAMENUM_FRAME_MASK   0x00007FF8
 Frame Number Mask. More...
 
#define XUSB_FRAMENUM_MICRO_FRAME_MASK   0x00000007
 Micro Frame Mask. More...
 
#define XUSB_FRAMENUM_FRAME_SHIFT   0x3
 Frame Number Shift. More...
 

Buffer Ready Register

#define XUSB_BUFFREADY_EP7_BUFF2_MASK   0x00008000
 EP 7 Buff 2 Ready. More...
 
#define XUSB_BUFFREADY_EP6_BUFF2_MASK   0x00004000
 EP 6 Buff 2 Ready. More...
 
#define XUSB_BUFFREADY_EP5_BUFF2_MASK   0x00002000
 EP 5 Buff 2 Ready. More...
 
#define XUSB_BUFFREADY_EP4_BUFF2_MASK   0x00001000
 EP 4 Buff 2 Ready. More...
 
#define XUSB_BUFFREADY_EP3_BUFF2_MASK   0x00000800
 EP 3 Buff 2 Ready. More...
 
#define XUSB_BUFFREADY_EP2_BUFF2_MASK   0x00000400
 EP 2 Buff 2 Ready. More...
 
#define XUSB_BUFFREADY_EP1_BUFF2_MASK   0x00000200
 EP 1 Buff 2 Ready. More...
 
#define XUSB_BUFFREADY_EP7_BUFF1_MASK   0x00000080
 EP 7 Buff 1 Ready. More...
 
#define XUSB_BUFFREADY_EP6_BUFF1_MASK   0x00000040
 EP 6 Buff 1 Ready. More...
 
#define XUSB_BUFFREADY_EP5_BUFF1_MASK   0x00000020
 EP 5 Buff 1 Ready. More...
 
#define XUSB_BUFFREADY_EP4_BUFF1_MASK   0x00000010
 EP 4 Buff 1 Ready. More...
 
#define XUSB_BUFFREADY_EP3_BUFF1_MASK   0x00000008
 EP 3 Buff 1 Ready. More...
 
#define XUSB_BUFFREADY_EP2_BUFF1_MASK   0x00000004
 EP 2 Buff 1 Ready. More...
 
#define XUSB_BUFFREADY_EP1_BUFF1_MASK   0x00000002
 EP 1 Buff 1 Ready. More...
 
#define XUSB_BUFFREADY_EP0_BUFF_MASK   0x00000001
 EP 0 Buffer Ready. More...
 
#define XUSB_STATUS_INTR_EVENT_MASK
 
#define XUSB_STATUS_INTR_BUFF_COMP_ALL_MASK
 
#define XUSB_STATUS_DMA_EVENT_MASK
 
#define XUSB_STATUS_ERROR_EVENT_MASK
 
#define XUSB_STATUS_INTR_ALL_MASK   0xFFFFFEFF
 All Interrupts Mask. More...
 

Test Mode Register

#define XUSB_TESTMODE_J_MASK   0x00000001
 Test Mode J. More...
 
#define XUSB_TESTMODE_K_MASK   0x00000002
 Test Mode K. More...
 
#define XUSB_TESTMODE_SE0_NAK_MASK   0x00000003
 Test Mode SE0 NAK. More...
 
#define XUSB_TESTMODE_TEST_PKT_MASK   0x00000004
 Test Packet Mode. More...
 

Error Counter Register

#define XUSB_ECR_BITSTUFF_ERRCNT_MASK   0xFF000000
 Bit Stuff error counter. More...
 
#define XUSB_ECR_PID_ERRCNT_MASK   0x00FF0000
 PID error counter. More...
 
#define XUSB_ECR_CRC_ERRCNT_MASK   0x0000FF00
 CRC error counter. More...
 
#define XUSB_ECR_BITSTUFF_ERRCNT_SHIFT   24
 
#define XUSB_ECR_PID_ERRCNT_SHIFT   16
 
#define XUSB_ECR_CRC_ERRCNT_SHIFT   8
 

ULPI PHY Access Register

#define XUSB_UPAR_REG_DATA_MASK   0x0000FF00
 PHY Data register. More...
 
#define XUSB_UPAR_REG_ADDR_MASK   0x0000003F
 PHY Address register. More...
 
#define XUSB_UPAR_READ_WRITE_MASK   0x00000040
 PHY Read/Write Transaction selection bit. More...
 
#define XUSB_UPAR_BUSY_MASK   0x80000000
 PHY access enable. More...
 
#define XUSB_UPAR_REG_DATA_SHIFT   8
 

Endpoint Configuration Space offsets

#define XUSB_EP_CFGSTATUS_OFFSET   0x00
 Endpoint Config Status. More...
 
#define XUSB_EP_BUF0COUNT_OFFSET   0x08
 Buffer 0 Count. More...
 
#define XUSB_EP_BUF1COUNT_OFFSET   0x0C
 Buffer 1 Count. More...
 

Endpoint Configuration Status Register

#define XUSB_EP_CFG_VALID_MASK   0x80000000
 Endpoint Valid bit. More...
 
#define XUSB_EP_CFG_STALL_MASK   0x40000000
 Endpoint Stall bit. More...
 
#define XUSB_EP_CFG_OUT_IN_MASK   0x20000000
 Endpoint OUT/IN cfg. More...
 
#define XUSB_EP_CFG_ISO_MASK   0x10000000
 Endpoint ISO config. More...
 
#define XUSB_EP_CFG_DATA_TOGGLE_MASK   0x08000000
 Endpoint Data toggle. More...
 
#define XUSB_EP_CFG_BUF_SELECT_MASK   0x04000000
 Endpoint Buff Select. More...
 
#define XUSB_EP_CFG_PACKET_SIZE_MASK   0x03ff8000
 Endpoint Packet Size. More...
 
#define XUBS_EP_CFG_ISOTRANS_MASK   0x00006000
 Isochronous Transfer. More...
 
#define XUSB_EP_CFG_BASE_MASK   0x00001fff
 Endpoint Base Mask. More...
 
#define XUSB_EP_CFG_VALID_SHIFT   31
 Endpoint Valid bit Shift. More...
 
#define XUSB_EP_CFG_STALL_SHIFT   30
 Endpoint Stall bit Shift. More...
 
#define XUSB_EP_CFG_OUT_IN_SHIFT   29
 Endpoint OUT/IN config. More...
 
#define XUSB_EP_CFG_ISO_SHIFT   28
 Endpoint ISO config Shft. More...
 
#define XUSB_EP_CFG_DATA_TOGGLE_SHIFT   27
 Endpoint Data toggle. More...
 
#define XUSB_EP_CFG_BUF_SELECT_SHIFT   26
 Endpoint Buf Select Shft. More...
 
#define XUSB_EP_CFG_PACKET_SIZE_SHIFT   15
 Endpoint Pkt Size Shift. More...
 
#define XUSB_EP_CFG_ISOTRANS_SHIFT   13
 Endpoint Isotrans Shift. More...
 

DMA Reset/Control and Status register bits

#define XUSB_DMA_RESET_VALUE   0x0000000A
 DMA Reset value. More...
 
#define XUSB_DMA_WRITE_TO_DPRAM   0
 DPRAM is the destination address for DMA transfer. More...
 
#define XUSB_DMA_READ_FROM_DPRAM   0x80000000
 DPRAM is the source address for DMA transfer. More...
 
#define XUSB_DMA_DMASR_BUSY   0x80000000
 DMA busy. More...
 
#define XUSB_DMA_DMASR_ERROR   0x40000000
 DMA Error. More...
 
#define XUSB_DMA_DMACR_DIR_MASK   0x80000000
 DMA direction. More...
 

HSIC PHY Registers

User need not program HSIC PHY registers for normal operation.

These are provided to test the PHY access only.

#define XUSB_HSIC_CONTROL_REGISTER   0x28
 HSIC Control Register. More...
 
#define XUSB_HSIC_STATUS_REGISTER   0x29
 HSIC Status Register. More...
 
#define XUSB_HSIC_STROBE_REGISTER   0x2A
 HSIC Strobe Register. More...
 
#define XUSB_HSIC_DATA_REGISTER   0x2B
 HSIC Data Register. More...
 
#define XUSB_HSIC_CR_SOFTRESET_MASK   0x00000001
 PHY Soft reset mask. More...
 
#define XUSB_HSIC_CR_CONNECT_MASK   0x00000002
 PHY issues connect mask. More...
 
#define XUSB_HSIC_CR_REMOTEWKP_ENABLE_MASK   0x00000004
 Enable Remote Wake-up signal forwarding to HSIC. More...
 
#define XUSB_HSIC_SR_LINKSTATUS_MASK   0x00000003
 Link Status. More...
 
#define XUSB_HSIC_SR_VBUSSTATE_MASK   0x00000004
 VBUS State. More...
 
#define XUSB_HSIC_SR_CONNECT_MASK   0x00000008
 Connect signaling issued from device to host. More...
 
#define XUSB_HSIC_SR_CDERR_MASK   0x00000010
 Carrier Detect Error. More...
 
#define XUSB_HSIC_SR_FRAMEERR_MASK   0x00000020
 Frame decoding Error. More...
 
#define XUSB_HSIC_SR_TXFIFO_UNDERRUN_MASK   0x00000040
 PHY Transmit FIFO underrun mask. More...
 
#define XUSB_HSIC_SR_ELFIFO_OVERRUN_MASK   0x00000080
 Elasticity FIFO overrun mask. More...
 
#define XUSB_HSIC_STROBE_IDELAY_MASK   0x0000001F
 IDELAY value for HSIC strobe input for receive. More...
 
#define XUSB_HSIC_STROBE_READY_MASK   0x00000020
 IDELAY block ready mask. More...
 
#define XUSB_HSIC_DATA_IDELAY_MASK   0x0000001F
 IDELAY value for HSIC data input for receive. More...
 
#define XUSB_HSIC_DATA_READY_MASK   0x00000020
 IDELAY block ready mask. More...
 

Macro Definition Documentation

#define TEST_J   1

Chirp J Test.

Referenced by EP0ProcessInToken(), and XUsb_SetTestMode().

#define TEST_K   2

Chirp K Test.

Referenced by XUsb_SetTestMode().

#define TEST_PKT   4

Packet Test.

Referenced by XUsb_SetTestMode().

#define TEST_SE0_NAK   3

Chirp SE0 Test.

Referenced by XUsb_SetTestMode().

#define XUBS_EP_CFG_ISOTRANS_MASK   0x00006000

Isochronous Transfer.

#define XUSB_ADDRESS_ADDR_MASK   0x7F

Address Mask.

#define XUSB_ADDRESS_OFFSET   0x0100

Address Register.

Referenced by XUsb_SetDeviceAddress().

#define XUSB_BUFFREADY_EP0_BUFF_MASK   0x00000001

EP 0 Buffer Ready.

Referenced by Ep0IntrHandler().

#define XUSB_BUFFREADY_EP1_BUFF1_MASK   0x00000002

EP 1 Buff 1 Ready.

Referenced by Ep1IntrHandler().

#define XUSB_BUFFREADY_EP1_BUFF2_MASK   0x00000200

EP 1 Buff 2 Ready.

Referenced by Ep1IntrHandler().

#define XUSB_BUFFREADY_EP2_BUFF1_MASK   0x00000004

EP 2 Buff 1 Ready.

Referenced by Ep2IntrHandler().

#define XUSB_BUFFREADY_EP2_BUFF2_MASK   0x00000400

EP 2 Buff 2 Ready.

Referenced by Ep2IntrHandler().

#define XUSB_BUFFREADY_EP3_BUFF1_MASK   0x00000008

EP 3 Buff 1 Ready.

#define XUSB_BUFFREADY_EP3_BUFF2_MASK   0x00000800

EP 3 Buff 2 Ready.

#define XUSB_BUFFREADY_EP4_BUFF1_MASK   0x00000010

EP 4 Buff 1 Ready.

#define XUSB_BUFFREADY_EP4_BUFF2_MASK   0x00001000

EP 4 Buff 2 Ready.

#define XUSB_BUFFREADY_EP5_BUFF1_MASK   0x00000020

EP 5 Buff 1 Ready.

#define XUSB_BUFFREADY_EP5_BUFF2_MASK   0x00002000

EP 5 Buff 2 Ready.

#define XUSB_BUFFREADY_EP6_BUFF1_MASK   0x00000040

EP 6 Buff 1 Ready.

#define XUSB_BUFFREADY_EP6_BUFF2_MASK   0x00004000

EP 6 Buff 2 Ready.

#define XUSB_BUFFREADY_EP7_BUFF1_MASK   0x00000080

EP 7 Buff 1 Ready.

#define XUSB_BUFFREADY_EP7_BUFF2_MASK   0x00008000

EP 7 Buff 2 Ready.

#define XUSB_CONTROL_OFFSET   0x0104

Control Register.

Referenced by XUsb_SieReset(), XUsb_Start(), and XUsb_Stop().

#define XUSB_CONTROL_SIE_RESET_MASK   0x20000000

Soft Reset Mask.

Referenced by XUsb_SieReset().

#define XUSB_CONTROL_USB_READY_MASK   0x80000000

USB ready Mask.

Referenced by XUsb_Start(), and XUsb_Stop().

#define XUSB_DEVICEADDR_MAX   127

Max device address.

Referenced by XUsb_SetDeviceAddress().

#define XUSB_DISCONNECTED   0x1

Disconnected state.

Referenced by DmaIntrHandler(), ProcessRxCmd(), Read10(), and Write10().

#define XUSB_DMA_BRR_CTRL   0x40000000

DMA bufready ctrl bit.

Referenced by XUsb_EpDataRecv(), and XUsb_EpDataSend().

#define XUSB_DMA_CONTROL_OFFSET   0x0204

DMA Control Register.

Referenced by XUsb_EpDataRecv(), and XUsb_EpDataSend().

#define XUSB_DMA_DDAR_ADDR_OFFSET   0x020C

DMA destination Addr Reg.

Referenced by XUsb_DmaTransfer().

#define XUSB_DMA_DDAR_ADDR_OFFSET_LSB   0x0310

DMA destination Addr Reg LSB.

Referenced by XUsb_DmaTransfer().

#define XUSB_DMA_DDAR_ADDR_OFFSET_MSB   0x0314

DMA destination Addr Reg MSB.

Referenced by XUsb_DmaTransfer().

#define XUSB_DMA_DMACR_DIR_MASK   0x80000000

DMA direction.

#define XUSB_DMA_DMASR_BUSY   0x80000000
#define XUSB_DMA_DMASR_ERROR   0x40000000

DMA Error.

#define XUSB_DMA_DSAR_ADDR_OFFSET   0x0208

DMA source Address Reg.

Referenced by XUsb_DmaTransfer().

#define XUSB_DMA_DSAR_ADDR_OFFSET_LSB   0x0308

DMA source Address Reg for LSB.

Referenced by XUsb_DmaTransfer().

#define XUSB_DMA_DSAR_ADDR_OFFSET_MSB   0x030C

DMA source Address Reg for MSB.

Referenced by XUsb_DmaTransfer().

#define XUSB_DMA_LENGTH_OFFSET   0x0210

DMA Length Register.

Referenced by XUsb_DmaTransfer().

#define XUSB_DMA_READ_FROM_DPRAM   0x80000000

DPRAM is the source address for DMA transfer.

Referenced by XUsb_EpDataRecv().

#define XUSB_DMA_RESET_OFFSET   0x0200

DMA Soft Reset Register.

Referenced by XUsb_DmaReset().

#define XUSB_DMA_RESET_VALUE   0x0000000A

DMA Reset value.

Referenced by XUsb_DmaReset().

#define XUSB_DMA_STATUS_OFFSET   0x0214

DMA Status Register.

Referenced by Ep1IntrHandler(), Ep2IntrHandler(), main(), ProcessRxCmd(), Read10(), and Write10().

#define XUSB_DMA_WRITE_TO_DPRAM   0

DPRAM is the destination address for DMA transfer.

#define XUSB_ECR_BITSTUFF_ERRCNT_MASK   0xFF000000

Bit Stuff error counter.

Referenced by XUsb_ReadErrorCounters().

#define XUSB_ECR_CRC_ERRCNT_MASK   0x0000FF00

CRC error counter.

Referenced by XUsb_ReadErrorCounters().

#define XUSB_ECR_OFFSET   0x011C

USB Error Count Reg.

Referenced by XUsb_ReadErrorCounters().

#define XUSB_ECR_PID_ERRCNT_MASK   0x00FF0000

PID error counter.

Referenced by XUsb_ReadErrorCounters().

#define XUSB_EP0_CONFIG_OFFSET   0x0000

EP0 Config Reg Offset.

Referenced by XUsb_CfgInitialize().

#define XUSB_EP0_RAMBASE_OFFSET   0x0088

EP0 RAM buffer Register.

#define XUSB_EP1_CONFIG_OFFSET   0x4000

EP1 Config Reg Offset.

#define XUSB_EP_BUF1COUNT_OFFSET   0x0C

Buffer 1 Count.

Referenced by Ep1IntrHandler(), XUsb_EpConfigure(), and XUsb_EpDataSend().

#define XUSB_EP_CFG_BASE_MASK   0x00001fff

Endpoint Base Mask.

#define XUSB_EP_CFG_BUF_SELECT_MASK   0x04000000

Endpoint Buff Select.

#define XUSB_EP_CFG_BUF_SELECT_SHIFT   26

Endpoint Buf Select Shft.

#define XUSB_EP_CFG_DATA_TOGGLE_MASK   0x08000000
#define XUSB_EP_CFG_DATA_TOGGLE_SHIFT   27

Endpoint Data toggle.

#define XUSB_EP_CFG_ISO_MASK   0x10000000

Endpoint ISO config.

#define XUSB_EP_CFG_ISO_SHIFT   28

Endpoint ISO config Shft.

Referenced by XUsb_EpConfigure().

#define XUSB_EP_CFG_ISOTRANS_SHIFT   13

Endpoint Isotrans Shift.

Referenced by XUsb_EpIsoTransferConfigure().

#define XUSB_EP_CFG_OUT_IN_MASK   0x20000000

Endpoint OUT/IN cfg.

#define XUSB_EP_CFG_OUT_IN_SHIFT   29

Endpoint OUT/IN config.

Referenced by XUsb_EpConfigure().

#define XUSB_EP_CFG_PACKET_SIZE_MASK   0x03ff8000

Endpoint Packet Size.

#define XUSB_EP_CFG_PACKET_SIZE_SHIFT   15

Endpoint Pkt Size Shift.

Referenced by XUsb_EpConfigure().

#define XUSB_EP_CFG_STALL_MASK   0x40000000

Endpoint Stall bit.

Referenced by GetStatus(), XUsb_EpStall(), and XUsb_EpUnstall().

#define XUSB_EP_CFG_STALL_SHIFT   30

Endpoint Stall bit Shift.

Referenced by GetStatus().

#define XUSB_EP_CFG_VALID_MASK   0x80000000

Endpoint Valid bit.

Referenced by XUsb_EpDisable(), and XUsb_EpEnable().

#define XUSB_EP_CFG_VALID_SHIFT   31

Endpoint Valid bit Shift.

#define XUSB_EP_CFGSTATUS_OFFSET   0x00

Endpoint Config Status.

#define XUSB_EP_DIRECTION_IN   1

Endpoint direction IN.

Referenced by InitUsbInterface().

#define XUSB_EP_DIRECTION_OUT   0

Endpoint direction OUT.

Referenced by InitUsbInterface(), and SetConfiguration().

#define XUSB_EP_FULL_SPEED   0

Full Speed.

Referenced by XUsb_CfgInitialize(), and XUsb_IntrHandler().

#define XUSB_EP_HIGH_SPEED   1
#define XUSB_EP_NUMBER_ZERO   0

End point Zero.

Referenced by XUsb_IntrHandler().

#define XUSB_FRAMENUM_FRAME_MASK   0x00007FF8

Frame Number Mask.

#define XUSB_FRAMENUM_FRAME_SHIFT   0x3

Frame Number Shift.

#define XUSB_FRAMENUM_MICRO_FRAME_MASK   0x00000007

Micro Frame Mask.

#define XUSB_FRAMENUM_OFFSET   0x010C

Frame Number Register.

Referenced by XUsb_GetFrameNum().

#define XUSB_HSIC_CONTROL_REGISTER   0x28

HSIC Control Register.

#define XUSB_HSIC_CR_CONNECT_MASK   0x00000002

PHY issues connect mask.

#define XUSB_HSIC_CR_REMOTEWKP_ENABLE_MASK   0x00000004

Enable Remote Wake-up signal forwarding to HSIC.

#define XUSB_HSIC_CR_SOFTRESET_MASK   0x00000001

PHY Soft reset mask.

#define XUSB_HSIC_DATA_IDELAY_MASK   0x0000001F

IDELAY value for HSIC data input for receive.

#define XUSB_HSIC_DATA_READY_MASK   0x00000020

IDELAY block ready mask.

#define XUSB_HSIC_DATA_REGISTER   0x2B

HSIC Data Register.

#define XUSB_HSIC_SR_CDERR_MASK   0x00000010

Carrier Detect Error.

#define XUSB_HSIC_SR_CONNECT_MASK   0x00000008

Connect signaling issued from device to host.

#define XUSB_HSIC_SR_ELFIFO_OVERRUN_MASK   0x00000080

Elasticity FIFO overrun mask.

#define XUSB_HSIC_SR_FRAMEERR_MASK   0x00000020

Frame decoding Error.

#define XUSB_HSIC_SR_LINKSTATUS_MASK   0x00000003

Link Status.

#define XUSB_HSIC_SR_TXFIFO_UNDERRUN_MASK   0x00000040

PHY Transmit FIFO underrun mask.

#define XUSB_HSIC_SR_VBUSSTATE_MASK   0x00000004

VBUS State.

#define XUSB_HSIC_STATUS_REGISTER   0x29

HSIC Status Register.

#define XUSB_HSIC_STROBE_IDELAY_MASK   0x0000001F

IDELAY value for HSIC strobe input for receive.

#define XUSB_HSIC_STROBE_READY_MASK   0x00000020

IDELAY block ready mask.

#define XUSB_HSIC_STROBE_REGISTER   0x2A

HSIC Strobe Register.

#define XUSB_IER_OFFSET   0x0110

Interrupt Enable Reg.

Referenced by XUsb_IntrDisable(), XUsb_IntrEnable(), and XUsb_IntrHandler().

#define XUsb_ReadReg (   BaseAddress,
  RegOffset 
)    XUsb_In32((BaseAddress) + (RegOffset))

Read from the specified USB device register.

Parameters
BaseAddresscontains the base address of the device.
RegOffsetcontains the offset from the 1st register of the device to select the specific register.
Returns
The value read from the register.
Note
C-Style signature: u32 XUsb_ReadReg(u32 BaseAddress, u32 RegOffset);

Referenced by Ep0IntrHandler(), EP0ProcessInToken(), EP0ProcessOutToken(), Ep1IntrHandler(), Ep2IntrHandler(), GetStatus(), main(), ProcessRxCmd(), Read10(), SetClearFeature(), SetupControlWriteStatusStage(), Write10(), XUsb_EpDisable(), XUsb_EpEnable(), XUsb_EpIsoTransferConfigure(), XUsb_EpStall(), XUsb_EpUnstall(), XUsb_GetFrameNum(), XUsb_IntrDisable(), XUsb_IntrEnable(), XUsb_IntrHandler(), XUsb_ReadErrorCounters(), XUsb_SieReset(), XUsb_Stop(), XUsb_UlpiPhyReadRegister(), and XUsb_UlpiPhyWriteRegister().

#define XUSB_REMOTE_WAKEUP_MASK   0x40000000

Remote Wakeup Mask.

#define XUSB_RESET   0x0

Reset State.

Referenced by InitUsbInterface(), and UsbIfIntrHandler().

#define XUSB_SETUP_PKT_ADDR_OFFSET   0x0080

Setup Packet Address.

Referenced by Chapter9().

#define XUSB_STATUS_BITSTUFF_ERR_MASK   0x20000000

USB Bit stuff error.

#define XUSB_STATUS_CRC_ERR_MASK   0x08000000

USB CRC error.

#define XUSB_STATUS_DISCONNECT_MASK   0x00200000

USB Disconnect Mask.

Referenced by Ep0IntrHandler(), main(), UsbIfIntrHandler(), UsbKbdExample(), and UsbMouseExample().

#define XUSB_STATUS_DMA_DONE_MASK   0x04000000

DMA done.

Referenced by DmaIntrHandler().

#define XUSB_STATUS_DMA_ERROR_MASK   0x02000000

DMA error.

Referenced by DmaIntrHandler().

#define XUSB_STATUS_EP0_BUFF1_COMP_MASK   0x00000001

EP 0 Buff 1 Processed.

Referenced by main(), UsbKbdExample(), UsbMouseExample(), and XUsb_IntrHandler().

#define XUSB_STATUS_EP1_BUFF1_COMP_MASK   0x00000002

EP 1 Buff 1 Processed.

Referenced by main(), UsbKbdExample(), UsbMouseExample(), and XUsb_IntrHandler().

#define XUSB_STATUS_EP1_BUFF2_COMP_MASK   0x00000200

EP 1 Buff 2 Processed.

Referenced by main(), UsbKbdExample(), UsbMouseExample(), and XUsb_IntrHandler().

#define XUSB_STATUS_EP2_BUFF1_COMP_MASK   0x00000004

EP 2 Buff 1 Processed.

Referenced by main().

#define XUSB_STATUS_EP2_BUFF2_COMP_MASK   0x00000400

EP 2 Buff 2 Processed.

Referenced by main().

#define XUSB_STATUS_EP3_BUFF1_COMP_MASK   0x00000008

EP 3 Buff 1 Processed.

#define XUSB_STATUS_EP3_BUFF2_COMP_MASK   0x00000800

EP 3 Buff 2 Processed.

#define XUSB_STATUS_EP4_BUFF1_COMP_MASK   0x00000010

EP 4 Buff 1 Processed.

#define XUSB_STATUS_EP4_BUFF2_COMP_MASK   0x00001000

EP 4 Buff 2 Processed.

#define XUSB_STATUS_EP5_BUFF1_COMP_MASK   0x00000020

EP 5 Buff 1 Processed.

#define XUSB_STATUS_EP5_BUFF2_COMP_MASK   0x00002000

EP 5 Buff 2 Processed.

#define XUSB_STATUS_EP6_BUFF1_COMP_MASK   0x00000040

EP 6 Buff 1 Processed.

#define XUSB_STATUS_EP6_BUFF2_COMP_MASK   0x00004000

EP 6 Buff 2 Processed.

#define XUSB_STATUS_EP7_BUFF1_COMP_MASK   0x00000080

EP 7 Buff 1 Processed.

#define XUSB_STATUS_EP7_BUFF2_COMP_MASK   0x00008000

EP 7 Buff 2 Processed.

#define XUSB_STATUS_EP_BUFF2_SHIFT   8
#define XUSB_STATUS_FIFO_BUFF_FREE_MASK   0x00080000

FIFO Buff Free Mask.

Referenced by Ep0IntrHandler(), main(), UsbKbdExample(), and UsbMouseExample().

#define XUSB_STATUS_FIFO_BUFF_RDY_MASK   0x00100000

FIFO Buff Ready Mask.

Referenced by Ep0IntrHandler(), main(), UsbKbdExample(), and UsbMouseExample().

#define XUSB_STATUS_GLOBAL_INTR_MASK   0x80000000

Global Intr Enable.

Referenced by main(), UsbKbdExample(), and UsbMouseExample().

#define XUSB_STATUS_HIGH_SPEED_MASK   0x00010000

USB Speed Mask.

Referenced by XUsb_IntrHandler().

#define XUSB_STATUS_INTR_ALL_MASK   0xFFFFFEFF

All Interrupts Mask.

Referenced by XUsb_IntrDisable(), and XUsb_IntrEnable().

#define XUSB_STATUS_OFFSET   0x0108

Status Register.

Referenced by Ep2IntrHandler(), main(), and XUsb_IntrHandler().

#define XUSB_STATUS_PHY_ACCESS_MASK   0x40000000

PHY access complete.

Referenced by main(), UsbIfPhyIntrHandler(), and XUsb_IntrHandler().

#define XUSB_STATUS_PID_ERR_MASK   0x10000000

USB PID error.

#define XUSB_STATUS_RESET_MASK   0x00800000
#define XUSB_STATUS_RESUME_MASK   0x01000000

USB resume Mask.

#define XUSB_STATUS_SETUP_PACKET_MASK   0x00040000

Setup packet received.

Referenced by Ep0IntrHandler().

#define XUSB_STATUS_SOF_PACKET_MASK   0x00020000

SOF packet received.

#define XUSB_STATUS_SUSPEND_MASK   0x00400000
#define XUSB_TESTMODE_J_MASK   0x00000001

Test Mode J.

#define XUSB_TESTMODE_K_MASK   0x00000002

Test Mode K.

#define XUSB_TESTMODE_OFFSET   0x0118

Test Mode Register.

Referenced by XUsb_SetTestMode().

#define XUSB_TESTMODE_SE0_NAK_MASK   0x00000003

Test Mode SE0 NAK.

#define XUSB_TESTMODE_TEST_PKT_MASK   0x00000004

Test Packet Mode.

#define XUSB_UPAR_BUSY_MASK   0x80000000

PHY access enable.

Referenced by XUsb_UlpiPhyReadRegister(), and XUsb_UlpiPhyWriteRegister().

#define XUSB_UPAR_OFFSET   0x0120

USB ULPI PHY Access Reg.

Referenced by XUsb_UlpiPhyReadRegister(), and XUsb_UlpiPhyWriteRegister().

#define XUSB_UPAR_READ_WRITE_MASK   0x00000040

PHY Read/Write Transaction selection bit.

Referenced by XUsb_UlpiPhyWriteRegister().

#define XUSB_UPAR_REG_ADDR_MASK   0x0000003F

PHY Address register.

#define XUSB_UPAR_REG_DATA_MASK   0x0000FF00

PHY Data register.

Referenced by XUsb_UlpiPhyReadRegister().

#define XUsb_WriteReg (   BaseAddress,
  RegOffset,
  RegisterValue 
)    XUsb_Out32((BaseAddress) + (RegOffset), (RegisterValue))

Write to the specified USB device register.

Parameters
BaseAddresscontains the base address of the device.
RegOffsetcontains the offset from the 1st register of the device to select the specific register.
RegisterValueis the value to be written to the register.
Returns
None.
Note
C-Style signature: void XUsb_WriteReg(u32 BaseAddress, u32 RegOffset, u32 RegisterValue);

Referenced by Ep0IntrHandler(), EP0ProcessInToken(), EP0ProcessOutToken(), GetConfiguration(), GetInterface(), GetMaxLUN(), GetStatus(), InitUsbInterface(), LoadEP0(), SetClearFeature(), SetConfiguration(), SetupControlWriteStatusStage(), UsbIfIntrHandler(), XUsb_DmaReset(), XUsb_DmaTransfer(), XUsb_EpConfigure(), XUsb_EpDataRecv(), XUsb_EpDataSend(), XUsb_EpDisable(), XUsb_EpEnable(), XUsb_EpIsoTransferConfigure(), XUsb_EpStall(), XUsb_EpUnstall(), XUsb_IntrDisable(), XUsb_IntrEnable(), XUsb_SetDeviceAddress(), XUsb_SetTestMode(), XUsb_SieReset(), XUsb_Start(), XUsb_Stop(), XUsb_UlpiPhyReadRegister(), and XUsb_UlpiPhyWriteRegister().

Typedef Documentation

typedef void(* XUsb_EpHandlerFunc)(void *CallBackRef, u8 EpNum, u32 EventType)

This data type defines the callback function to be used for Endpoint handlers.

Parameters
CallBackRefis the Callback reference passed in by the upper layer when setting the handler, and is passed back to the upper layer when the handler is called.
EpNumis the endpoint that caused the event.
EventTypeis the type of the event that occurred on that endpoint.
typedef void(* XUsb_IntrHandlerFunc)(void *CallBackRef, u32 InterruptType)

This data type defines the callback function to be used for the general interrupt handler.

Parameters
CallBackRefis the Callback reference passed in by the upper layer when setting the handler, and is passed back to the upper layer when the handler is called.
InterruptTypeis the type of the event that caused the interrupt.

Function Documentation

int XUsb_CfgInitialize ( XUsb InstancePtr,
XUsb_Config ConfigPtr,
UINTPTR  EffectiveAddr 
)

This function initializes a XUsb instance/driver.

Setup / Initialize and DMA functions.

The initialization entails:

  • Initialize all members of the XUsb structure.
Parameters
InstancePtris a pointer to the XUsb instance of the USB device.
ConfigPtris a pointer to a XUsb_Config configuration structure. This structure will contain the requested configuration for the device. Typically, this is a local structure and the content of which will be copied into the configuration structure within XUsb.
EffectiveAddris 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.
Returns
  • XST_SUCCESS no errors occurred.
  • XST_FAILURE an error occurred during initialization.
Note
After calling XUsb_CfgInitialize() the USB device IS NOT READY for use. Before the USB device can be used its parameters must be configured. See xusb.h for details.

Implemented in the file xusb.c

References XUsb_Config::AddrWidth, XUsb_Config::BaseAddress, XUsb::Config, XUsb_DeviceConfig::CurrentSpeed, XUsb::DeviceConfig, XUsb_Config::DeviceId, XUsb_Config::DmaEnabled, XUsb::EndPointOffset, XUsb::HandlerFunc, XUsb::IsReady, XUsb_DeviceConfig::NumEndpoints, XUSB_EP0_CONFIG_OFFSET, XUSB_EP_FULL_SPEED, and XUSB_MAX_ENDPOINTS.

Referenced by main(), UsbKbdExample(), and UsbMouseExample().

int XUsb_ConfigureDevice ( XUsb InstancePtr,
XUsb_DeviceConfig CfgPtr 
)

This function initializes USB End points.

Parameters
InstancePtris a pointer to the XUsb instance.
CfgPtris pointer to a XUsb_Config configuration structure. This structure will contain the requested configuration for the device. Typically, this is a local structure and the content of which will be copied into the configuration structure within XUsb.
Returns
  • XST_SUCCESS no errors occurred.
  • XST_FAILURE an error occurred during initialization.
Note
None.

References XUsb_EpConfig::Buffer0Count, XUsb_EpConfig::Buffer0Ready, XUsb_EpConfig::Buffer1Count, XUsb_EpConfig::Buffer1Ready, XUsb_EpConfig::CurBufNum, XUsb::DeviceConfig, XUsb_DeviceConfig::Ep, XUsb_EpConfig::EpType, XUsb_DeviceConfig::NumEndpoints, XUsb_EpConfig::OutIn, XUsb_EpConfig::RamBase, XUsb_EpConfig::Size, and XUsb_EpConfigure().

Referenced by InitUsbInterface().

void XUsb_DmaIntrSetHandler ( XUsb InstancePtr,
void *  CallBackFunc,
void *  CallBackRef 
)

This function installs an asynchronous callback function for the DMA events.

Parameters
InstancePtris a pointer to the XUsb instance.
CallBackFuncis the address of the callback function.
CallBackRefis a user data item that will be passed to the callback function when it is invoked.
Returns
None.
Note
Invoking this function for a handler that already has been installed replaces it with the new handler. The user can disable a handler by setting the callback function pointer to NULL.

References XUsb::IsReady.

Referenced by main().

void XUsb_DmaReset ( XUsb InstancePtr)

This function resets the DMA module of the USB device.

Parameters
InstancePtris a pointer to the XUsb instance.
Returns
None.
Note
After the DMA reset, only the DMA related logic part of the USB device will be reset and all the DMA related registers will be reset to the default values. Upon DMA Reset, any DMA transfer in progress will be stopped.

References XUsb_Config::BaseAddress, XUsb::Config, XUSB_DMA_RESET_OFFSET, XUSB_DMA_RESET_VALUE, and XUsb_WriteReg.

void XUsb_DmaTransfer ( XUsb InstancePtr,
UINTPTR *  SrcAddr,
UINTPTR *  DstAddr,
u16  Length 
)

This function sets the DMA registers with the given values to initiate a DMA data transfer.

This function is called by the XUsb_EpDataSend and XUsb_EpDataRecv functions.

Parameters
InstancePtris a pointer to the XUsb instance.
SrcAddris the source address from where the data is to be read.
DstAddris the destination address to where the data is to be written.
Lengthis the amount of data that can be transferred. The maximum data transfer can be 1024.
Returns
None.
Note
This function doesn't guarantee that the transfer is done successfully. This function only initiates the DMA transfer.

References XUsb_Config::AddrWidth, XUsb_Config::BaseAddress, XUsb::Config, XUSB_DMA_DDAR_ADDR_OFFSET, XUSB_DMA_DDAR_ADDR_OFFSET_LSB, XUSB_DMA_DDAR_ADDR_OFFSET_MSB, XUSB_DMA_DSAR_ADDR_OFFSET, XUSB_DMA_DSAR_ADDR_OFFSET_LSB, XUSB_DMA_DSAR_ADDR_OFFSET_MSB, XUSB_DMA_LENGTH_OFFSET, and XUsb_WriteReg.

Referenced by XUsb_EpDataRecv(), and XUsb_EpDataSend().

void XUsb_EpConfigure ( XUsb InstancePtr,
u8  EpNum,
XUsb_EpConfig EpCfgPtr 
)

This function configures a specific end point with the given configuration data.

Parameters
InstancePtris a pointer to the XUsb instance.
EpNumis the endpoint number which has to be configured.
EpCfgPtris a pointer to the endpoint configuration structure.
Returns
None.
Note
None.

References XUsb_Config::BaseAddress, XUsb_EpConfig::Buffer0Count, XUsb_EpConfig::Buffer0Ready, XUsb_EpConfig::Buffer1Count, XUsb_EpConfig::Buffer1Ready, XUsb::Config, XUsb::EndPointOffset, XUsb_EpConfig::EpType, XUsb_EpConfig::OutIn, XUsb_EpConfig::RamBase, XUsb_EpConfig::Size, XUSB_BUFFREADY_OFFSET, XUSB_EP_BUF0COUNT_OFFSET, XUSB_EP_BUF1COUNT_OFFSET, XUSB_EP_CFG_ISO_SHIFT, XUSB_EP_CFG_OUT_IN_SHIFT, XUSB_EP_CFG_PACKET_SIZE_SHIFT, XUSB_MAX_ENDPOINTS, XUSB_STATUS_EP_BUFF2_SHIFT, and XUsb_WriteReg.

Referenced by XUsb_ConfigureDevice().

int XUsb_EpDataRecv ( XUsb InstancePtr,
u8  EpNum,
u8 *  BufferPtr,
u32  BufferLen 
)

This function copies the received data from end point buffer to the buffer passed and then makes the device ready for receiving data again into the same end point buffer.

Parameters
InstancePtris a pointer to the XUsb instance.
EpNumis the endpoint number.
BufferPtris a pointer to buffer where data is to be copied.
BufferLenis the number of data bytes to be received.
Returns
  • XST_SUCCESS if successful.
  • XST_FAILURE if there is no received data in any of the ping pong buffers.
Note
None

References XUsb_Config::BaseAddress, XUsb_EpConfig::Buffer0Ready, XUsb_EpConfig::Buffer1Ready, XUsb::Config, XUsb_EpConfig::CurBufNum, XUsb::DeviceConfig, XUsb_Config::DmaEnabled, XUsb_DeviceConfig::Ep, XUsb::IsReady, XUSB_BUFFREADY_OFFSET, XUSB_DMA_BRR_CTRL, XUSB_DMA_CONTROL_OFFSET, XUSB_DMA_READ_FROM_DPRAM, XUsb_DmaTransfer(), XUSB_MAX_ENDPOINTS, XUSB_STATUS_EP_BUFF2_SHIFT, and XUsb_WriteReg.

Referenced by Ep2IntrHandler(), main(), Write10(), and WriteTransfer().

int XUsb_EpDataSend ( XUsb InstancePtr,
u8  EpNum,
u8 *  BufferPtr,
u32  BufferLen 
)

This function copies the transmit data to the end point buffer and enables the buffer for transmission.

Parameters
InstancePtris a pointer to the XUsb instance.
EpNumis the endpoint number.
BufferPtris a pointer to buffer containing the data to be sent.
BufferLenis the number of data bytes to be sent.
Returns
  • XST_SUCCESS if successful.
  • XST_FAILURE if the send operation could not be performed due to non availability of the ping pong buffers in the DPRAM.
Note
Success doesn't imply that the data is actually transmitted, it only confirms that the DPRAM buffer is updated with send data and the core is enabled for transmitting the data.

References XUsb_Config::BaseAddress, XUsb_EpConfig::Buffer0Ready, XUsb_EpConfig::Buffer1Ready, XUsb::Config, XUsb_EpConfig::CurBufNum, XUsb::DeviceConfig, XUsb_Config::DmaEnabled, XUsb::EndPointOffset, XUsb_DeviceConfig::Ep, XUsb::IsReady, XUSB_BUFFREADY_OFFSET, XUSB_DMA_BRR_CTRL, XUSB_DMA_CONTROL_OFFSET, XUsb_DmaTransfer(), XUSB_EP_BUF0COUNT_OFFSET, XUSB_EP_BUF1COUNT_OFFSET, XUSB_MAX_ENDPOINTS, XUSB_STATUS_EP_BUFF2_SHIFT, and XUsb_WriteReg.

Referenced by DmaIntrHandler(), Ep1IntrHandler(), Ep2IntrHandler(), GpioIsr(), main(), ProcessRxCmd(), Read10(), ReadTransfer(), and WriteTransfer().

void XUsb_EpDisable ( const XUsb InstancePtr,
u8  EpNum 
)

This function disables the specified endpoint for all operations.

Parameters
InstancePtris a pointer to the XUsb instance.
EpNumis the endpoint number which has to be disabled for operations.
Returns
None.
Note
None.

References XUsb_Config::BaseAddress, XUsb::Config, XUsb::EndPointOffset, XUsb::IsReady, XUSB_EP_CFG_VALID_MASK, XUSB_MAX_ENDPOINTS, XUsb_ReadReg, and XUsb_WriteReg.

void XUsb_EpEnable ( const XUsb InstancePtr,
u8  EpNum 
)

This function enables the specified endpoint for all operations.

Parameters
InstancePtris a pointer to the XUsb instance.
EpNumis the endpoint number which has to be enabled for operations.
Returns
None.
Note
None.

References XUsb_Config::BaseAddress, XUsb::Config, XUsb::EndPointOffset, XUsb::IsReady, XUSB_EP_CFG_VALID_MASK, XUSB_MAX_ENDPOINTS, XUsb_ReadReg, and XUsb_WriteReg.

Referenced by InitUsbInterface().

void XUsb_EpIsoTransferConfigure ( XUsb InstancePtr,
u8  EpNum,
u8  NoOfTransfers 
)

This function sets the number of isochronous transfers in a microframe for a given endpoint.

Parameters
InstancePtris a pointer to the XUsb instance.
EpNumis the endpoint number.
NoOfTransfersis the number of transfers in a microframe.
Returns
None
Note
The values allowed for number of transfers is 1, 2 and 3. This function should be called after all the endpoints are configured. The allowed value for EpNum is 1 to 7

References XUsb_Config::BaseAddress, XUsb::Config, XUsb::EndPointOffset, XUsb::IsReady, XUSB_EP_CFG_ISOTRANS_SHIFT, XUSB_MAX_ENDPOINTS, XUsb_ReadReg, and XUsb_WriteReg.

void XUsb_EpSetHandler ( XUsb InstancePtr,
u8  EpNum,
XUsb_EpHandlerFunc CallBackFunc,
void *  CallBackRef 
)

This function sets the handler for endpoint events.

Parameters
InstancePtris a Pointer to the XUsb instance.
EpNumis the Number of the endpoint.
CallBackFuncis the address of the callback function. It can be NULL if the user wants to disable the handler entry.
CallBackRefis a user data item that will be passed to the callback function when it is invoked. This can be NULL.
Returns
None.
Note
Invoking this function for a handler that already has been installed replaces it with the new handler. The user can disable a handler by setting the callback function pointer to NULL.

References XUsb::DeviceConfig, XUsb_DeviceConfig::Ep, XUsb_EpConfig::HandlerFunc, and XUsb_EpConfig::HandlerRef.

Referenced by main(), UsbKbdExample(), and UsbMouseExample().

void XUsb_EpStall ( const XUsb InstancePtr,
u8  EpNum 
)

This function stalls operations for the specified endpoint.

Parameters
InstancePtris a pointer to the XUsb instance.
EpNumis the endpoint number which has to be stalled for operations.
Returns
None.
Note
This function does not guaranty the Stall operation, it only sets the Stall bit in the Endpoint configuration register.

References XUsb_Config::BaseAddress, XUsb::Config, XUsb::EndPointOffset, XUsb::IsReady, XUSB_EP_CFG_STALL_MASK, XUSB_MAX_ENDPOINTS, XUsb_ReadReg, and XUsb_WriteReg.

Referenced by Ep0IntrHandler(), ExecuteCommand(), GetDescriptor(), GetInterface(), GetStatus(), SetClearFeature(), SetConfiguration(), SetDescriptor(), and SetInterface().

void XUsb_EpUnstall ( const XUsb InstancePtr,
u8  EpNum 
)

This function unstalls operations for the specified endpoint.

Parameters
InstancePtris a pointer to the XUsb instance.
EpNumis the endpoint number for which the unstall operations are to be carried out.
Returns
None.
Note
This function does not guaranty the Stall operation, it only sets the Stall bit in the Endpoint configuration register.

References XUsb_Config::BaseAddress, XUsb::Config, XUsb::EndPointOffset, XUsb::IsReady, XUSB_EP_CFG_STALL_MASK, XUSB_MAX_ENDPOINTS, XUsb_ReadReg, and XUsb_WriteReg.

Referenced by SetClearFeature().

void XUsb_ErrIntrSetHandler ( XUsb InstancePtr,
void *  CallBackFunc,
void *  CallBackRef 
)

This function installs an asynchronous callback function for the error events.

Parameters
InstancePtris a pointer to the XUsb instance.
CallBackFuncis the address of the callback function.
CallBackRefis a user data item that will be passed to the callback function when it is invoked.
Returns
None.
Note
Invoking this function for a handler that already has been installed replaces it with the new handler. The user can disable a handler by setting the callback function pointer to NULL.

References XUsb::IsReady.

u32 XUsb_GetFrameNum ( const XUsb InstancePtr)

This function returns the current frame number.

Parameters
InstancePtris a pointer to the XUsb instance.
Returns
The current frame number..
Note
None.

References XUsb_Config::BaseAddress, XUsb::Config, XUsb::IsReady, XUSB_FRAMENUM_OFFSET, and XUsb_ReadReg.

void XUsb_IntrDisable ( XUsb InstancePtr,
u32  Mask 
)

This function disables the specified interrupts.

Parameters
InstancePtris a pointer to the XUsb instance.
Maskis the bit-mask of the interrupts to be disabled. Bit positions of 1 will be enabled. Bit positions of 0 will keep the previous setting. This mask is formed by OR'ing XUSB_STATUS_*_MASK bits defined in xusb_l.h.
Returns
None.
Note
None.

References XUsb_Config::BaseAddress, XUsb::Config, XUsb::IsReady, XUSB_IER_OFFSET, XUsb_ReadReg, XUSB_STATUS_INTR_ALL_MASK, and XUsb_WriteReg.

Referenced by UsbIfIntrHandler().

void XUsb_IntrEnable ( XUsb InstancePtr,
u32  Mask 
)

This function enables the specified interrupts.

Parameters
InstancePtris a pointer to the XUsb instance.
Maskis the bit-mask of the interrupts to be enabled. Bit positions of 1 will be enabled. Bit positions of 0 will keep the previous setting. This mask is formed by OR'ing XUSB_STATUS_*_MASK bits defined in xusb_l.h.
Returns
None.
Note
None.

References XUsb_Config::BaseAddress, XUsb::Config, XUsb::IsReady, XUSB_IER_OFFSET, XUsb_ReadReg, XUSB_STATUS_INTR_ALL_MASK, and XUsb_WriteReg.

Referenced by Ep0IntrHandler(), main(), UsbIfIntrHandler(), UsbKbdExample(), and UsbMouseExample().

void XUsb_IntrHandler ( void *  InstancePtr)

This function is the interrupt handler for the USB driver.

This function is the first-level interrupt handler for the USB core. All USB interrupts will be handled here. Depending on the type of the interrupt, second level interrupt handler may be called. Second level interrupt handlers will be registered by the user using the XUsb_IntrSetHandler() and/or XUsb_EpSetHandler() functions.

This handler reads the interrupt status from the Interrupt Status Register, determines the source of the interrupts, calls the corresponding callbacks and finally clears the interrupts.

The interrupt from the USB driver has to be connected to the interrupt controller and the handler has to be registered with the interrupt system.

Applications using this driver are responsible for providing the callbacks to handle interrupts and installing the callbacks using XUsb_SetHandler() during the initialization phase.

Parameters
InstancePtris a pointer to the XUsb instance that just interrupted.
Returns
None.
Note
No user handler is defined for the DMA interrupts. The DMA interrupt status is updated in the DMA status variables defined under the USB driver instance.

References XUsb_Config::BaseAddress, XUsb::Config, XUsb_DeviceConfig::CurrentSpeed, XUsb::DeviceConfig, XUsb_Config::DmaEnabled, XUsb_DeviceConfig::Ep, XUsb_EpConfig::HandlerFunc, XUsb::HandlerFunc, XUsb_EpConfig::HandlerRef, XUsb_DeviceConfig::NumEndpoints, XUSB_EP_FULL_SPEED, XUSB_EP_HIGH_SPEED, XUSB_EP_NUMBER_ZERO, XUSB_IER_OFFSET, XUsb_ReadReg, XUSB_STATUS_EP0_BUFF1_COMP_MASK, XUSB_STATUS_EP1_BUFF1_COMP_MASK, XUSB_STATUS_EP1_BUFF2_COMP_MASK, XUSB_STATUS_HIGH_SPEED_MASK, XUSB_STATUS_OFFSET, and XUSB_STATUS_PHY_ACCESS_MASK.

Referenced by main(), UsbKbdExample(), and UsbMouseExample().

void XUsb_IntrSetHandler ( XUsb InstancePtr,
void *  CallBackFunc,
void *  CallBackRef 
)

This function installs an asynchronous callback function for the general interrupt (interrupts other than the endpoint and error interrupts).

Parameters
InstancePtris a pointer to the XUsb instance.
CallBackFuncis the address of the callback function.
CallBackRefis a user data item that will be passed to the callback function when it is invoked.
Returns
None.
Note
Invoking this function for a handler that already has been installed replaces it with the new handler. The user can disable a handler by setting the callback function pointer to NULL.

References XUsb::HandlerFunc, and XUsb::IsReady.

Referenced by main(), UsbKbdExample(), and UsbMouseExample().

XUsb_Config * XUsb_LookupConfig ( u16  DeviceId)

Looks up the device configuration based on the unique device ID.

A table contains the configuration info for each device in the system.

Parameters
DeviceIdcontains the ID of the device for which the device configuration pointer is to be returned.
Returns
  • A pointer to the configuration found.
  • NULL if the specified device ID was not found.

Referenced by main(), UsbKbdExample(), and UsbMouseExample().

void XUsb_ReadErrorCounters ( XUsb InstancePtr,
u8 *  BitStuffErrors,
u8 *  PidErrors,
u8 *  CrcErrors 
)

This function reads the USB error counter register and returns the error counters information.

Parameters
InstancePtris a pointer to the XUsb instance.
BitStuffErrorsis a pointer to the 8 bit bitstuff error counter.
PidErrorsis a pointer to the 8 bit pid error counter.
CrcErrorsis a pointer to the 8 bit crc error counter.
Returns
None.
Note
None.

References XUsb_Config::BaseAddress, XUsb::Config, XUSB_ECR_BITSTUFF_ERRCNT_MASK, XUSB_ECR_CRC_ERRCNT_MASK, XUSB_ECR_OFFSET, XUSB_ECR_PID_ERRCNT_MASK, and XUsb_ReadReg.

int XUsb_SetDeviceAddress ( XUsb InstancePtr,
u8  Address 
)

This function sets the USB device address.

Parameters
InstancePtris a pointer to the XUsb instance.
Addressis the device address to be set.
Returns
  • XST_SUCCESS: Address set successfully.
  • XST_INVALID_PARAM: Invalid parameter passed.
Note
None.

References XUsb_Config::BaseAddress, XUsb::Config, XUsb::IsReady, XUSB_ADDRESS_OFFSET, XUSB_DEVICEADDR_MAX, and XUsb_WriteReg.

Referenced by EP0ProcessInToken(), main(), UsbIfIntrHandler(), UsbKbdExample(), and UsbMouseExample().

void XUsb_SetTestMode ( XUsb InstancePtr,
u8  TestMode,
u8 *  BufPtr 
)

This function sets the USB device into a given test mode.

Parameters
InstancePtris a pointer to the XUsb instance.
TestModeis the type of test to be performed.
BufPtris a pointer to the buffer containing the test packet.
Returns
None.
Note
If the test mode is Test packet(TEST_PKT), then user needs to pass the address of the buffer containing the test packet. In other cases, the BufPtr parameter is not used and the user can send a NULL or any value. BufPtr parameter should be 32 bit aligned.

References XUsb_Config::BaseAddress, XUsb::Config, XUsb::IsReady, TEST_J, TEST_K, TEST_PKT, TEST_SE0_NAK, XUsb_Start(), XUsb_Stop(), XUSB_TESTMODE_OFFSET, and XUsb_WriteReg.

Referenced by EP0ProcessInToken().

void XUsb_SieReset ( XUsb InstancePtr)

This function resets the Serial Interface Engine.

Parameters
InstancePtris a pointer to the XUsb instance.
Returns
None.
Note
After the SIE reset, only the SIE state machine logic part of the USB device will be reset and starts from Init state.

References XUsb_Config::BaseAddress, XUsb::Config, XUSB_CONTROL_OFFSET, XUSB_CONTROL_SIE_RESET_MASK, XUsb_ReadReg, and XUsb_WriteReg.

void XUsb_Start ( XUsb InstancePtr)

This function starts the USB Device.

Parameters
InstancePtris a pointer to the XUsb instance.
Returns
None.
Note
None.

References XUsb_Config::BaseAddress, XUsb::Config, XUsb::IsReady, XUSB_CONTROL_OFFSET, XUSB_CONTROL_USB_READY_MASK, and XUsb_WriteReg.

Referenced by main(), UsbIfIntrHandler(), UsbKbdExample(), UsbMouseExample(), and XUsb_SetTestMode().

void XUsb_Stop ( XUsb InstancePtr)

This function stops the USB device.

Parameters
InstancePtris a pointer to the XUsb instance.
Returns
None.
Note
None.

References XUsb_Config::BaseAddress, XUsb::Config, XUsb::IsReady, XUSB_CONTROL_OFFSET, XUSB_CONTROL_USB_READY_MASK, XUsb_ReadReg, and XUsb_WriteReg.

Referenced by UsbIfIntrHandler(), and XUsb_SetTestMode().

void XUsb_UlpiIntrSetHandler ( XUsb InstancePtr,
void *  CallBackFunc,
void *  CallBackRef 
)

This function installs an asynchronous callback function for the ULPI PHY events.

Parameters
InstancePtris a pointer to the XUsb instance.
CallBackFuncis the address of the callback function.
CallBackRefis a user data item that will be passed to the callback function when it is invoked.
Returns
None.
Note
Invoking this function for a handler that already has been installed replaces it with the new handler. The user can disable a handler by setting the callback function pointer to NULL.

References XUsb::IsReady.

Referenced by main().

u8 XUsb_UlpiPhyReadRegister ( XUsb InstancePtr,
u8  RegAddr 
)

This function initiates the USB ULPI PHY register read transaction.

This function returns the busy status if the earlier transaction is still in progress and returns the PHY register data upon successful read transaction.

Parameters
InstancePtris a pointer to the XUsb instance.
RegAddris the address of the PHY register.
Returns
  • Register data
  • XST_DEVICE_BUSY: The previous PHY transaction is still in progress.
Note
This function waits till the BUSY bit is cleared in the ULPI PHY resgiter and then reads the register. The user of this API should note that the PHY interrupt should be ignored during read operation.

References XUsb_Config::BaseAddress, XUsb::Config, XUsb_ReadReg, XUSB_UPAR_BUSY_MASK, XUSB_UPAR_OFFSET, XUSB_UPAR_REG_DATA_MASK, and XUsb_WriteReg.

Referenced by main().

int XUsb_UlpiPhyWriteRegister ( XUsb InstancePtr,
u8  RegAddr,
u8  UlpiPhyRegData 
)

This function initiates the USB ULPI PHY register write transaction.

This function returns the busy status if the earlier transaction is still in progress and returns a success upon successful write transaction initiation.

Parameters
InstancePtris a pointer to the XUsb instance.
RegAddris the address of the PHY register. counter.
UlpiPhyRegDatais the data to be written to PHY register.
Returns
  • XST_SUCCESS: Read transaction initiated successfully.
  • XST_DEVICE_BUSY: The previous PHY transaction is still in progress.
Note
None.

References XUsb_Config::BaseAddress, XUsb::Config, XUsb_ReadReg, XUSB_UPAR_BUSY_MASK, XUSB_UPAR_OFFSET, XUSB_UPAR_READ_WRITE_MASK, and XUsb_WriteReg.

Referenced by main().

Variable Documentation

XUsb_Config XUsb_ConfigTable[]

This table contains the configuration information for each of the USB devices in the system.

XUsb_Config XUsb_ConfigTable[XPAR_XUSB_NUM_INSTANCES]
Initial value:
= {
{
XPAR_USB_0_DEVICE_ID,
XPAR_USB_0_BASEADDR,
XPAR_USB_0_INCLUDE_DMA
}
}

This table contains the configuration information for each of the USB devices in the system.