<h1>usb v5_0</h1><p>This file contains the implementation of the <aclass="el"href="struct_x_usb.html">XUsb</a> component. It is the driver for the USB device controller.</p>
<p>The USB device controller supports the following features:</p>
<li>7 Configurable Endpoints, which can be configured as IN or OUT , and configurable as Interrupt or Bulk or Isochronous</li>
</ul>
</li>
<li>2 Ping Pong Buffers for all the endpoints except the Control Endpoint</li>
</ul>
<p><b>Initialization & Configuration</b></p>
<p>The device driver enables higher layer software (e.g., an application) to communicate to the USB device. Apart from transmission and reception of USB frames the driver also handles the configuration of the device. A single device driver can support multiple USB devices.</p>
<p><aclass="el"href="xusb_8c.html#a05f262f5c35f642fefc16b7912086265">XUsb_CfgInitialize()</a> API is used to initialize the USB device. The user needs to first call the <aclass="el"href="xusb_8h.html#a9d684fb058664dc90720ea41cd59d6b0">XUsb_LookupConfig()</a> API which returns the Configuration structure pointer which is passed as a parameter to the <aclass="el"href="xusb_8c.html#a05f262f5c35f642fefc16b7912086265">XUsb_CfgInitialize()</a> API.</p>
<ul>
<li>Configuration of the DEVICE endpoints: The endpoints of the device need to be configured using the <aclass="el"href="xusb_8h.html#a265f540fba1a12b0e310052d4cfa5a2d">XUsb_EpConfigure()</a> function call. After configuration is complete, the endpoints need to be initialized using the XUsb_EpInitializeAll() function call.</li>
</ul>
<p><b> PHY Communication </b></p>
<p>As the H/W doesn't give any provision for the driver to configure the PHY, the driver doesn't provide any mechanism for directly programming the PHY.</p>
<p><b> DMA </b></p>
<p>The USB device has an inbuilt DMA. It's a simple DMA for data transfer between endpoint buffer memory and the external memory. The driver has two APIs for DMA operation. one API is used for resetting the DMA module of the USB device. The other API is for initiating the DMA transfer. The DMA transfer API is internal to the driver and is used by the USB endpoint data send and data receive functions. Upon completion of DMA transfer the USB device sets the buffer ready bit of the endpoint for which the DMA transfer is initiated. Setting of the buffer ready bit enables transmission/reception of an endpoint data. To enable the USB device to know to which endpoint the current DMA transfer is initiated, the driver writes the buffer ready mask to the DMA control register.</p>
<p>The DMA in the device can be enabled or disabled only during the system build time.</p>
<p><b> Interrupts </b></p>
<p>The driver provides an interrupt handler XUsb_IntrHandler for handling the interrupt from the USB device. The users of this driver have to register this handler with the interrupt system and provide the callback functions. The interrupt handlers and associated callback functions for the USB device have to be registered by the user using the <aclass="el"href="xusb_8h.html#ada7caf770f82936ab7493b67d143b9a9">XUsb_IntrSetHandler()</a> function and/or <aclass="el"href="xusb_8h.html#ae7fef0669e6d6094cc2af067195cc04d">XUsb_EpSetHandler()</a> function.</p>
<p><aclass="el"href="xusb_8h.html#ada7caf770f82936ab7493b67d143b9a9">XUsb_IntrSetHandler()</a> function installs an asynchronous callback function for the general interrupts (interrupts other than the endpoint interrupts).</p>
<p><aclass="el"href="xusb_8h.html#ae7fef0669e6d6094cc2af067195cc04d">XUsb_EpSetHandler()</a> function installs the callback functions for the interrupts related to the endpoint events. A separate callback function has to be installed for each of the endpoints.</p>
<p><b> Virtual Memory </b></p>
<p>This driver supports Virtual Memory. The RTOS is responsible for calculating the correct device base address in Virtual Memory space.</p>
<p><b> Threads </b></p>
<p>This driver is not thread safe. Any needs for threads or thread mutual exclusion must be satisfied by the layer above this driver.</p>
<p><b> Asserts </b></p>
<p>Asserts are used within all Xilinx drivers to enforce constraints on argument values. Asserts can be turned off on a system-wide basis by defining, at compile time, the NDEBUG identifier. By default, asserts are turned on and it is recommended that users leave asserts on during development.</p>
<p><b> Building the driver </b></p>
<p>The <aclass="el"href="struct_x_usb.html">XUsb</a> driver is composed of several source files. This allows the user to build and link only those parts of the driver that are necessary.</p>