User manual

Table Of Contents
Zynq-7000 AP SoC Technical Reference Manual www.xilinx.com 425
UG585 (v1.11) September 27, 2016
Chapter 15: USB Host, Device, and OTG Controller
Setup Packet Handling using the Tripwire
Disable setup lockout by writing 1 to setup lockout mode, usb.USBMODE [SLOM] bit field; once at
initialization. Setup lockout is not necessary when using the tripwire as described in the example
below.
Example: Setup Packet Handing using the Tripwire
After receiving an interrupt and inspecting usb.ENDPTSETUPSTAT register to determine that a setup
packet was received on a particular pipe (i.e., the dQH was written to memory by the hardware):
1. Setup the Tripwire Mechanism: Write 1 to usb.USBCMD [SUTW].
2. Read the Setup Buffer: Copy the contents of dQH.SetupBuffer into local software byte array.
3. Test to see if another Setup Packet was received. Read the tripwire bit [SUTW] again.
a. If [SUTW] = 1 (not received), then continue to step 4 and process the setup buffer.
b. If [SUTW] = 0 (another packet received), then go to step 1 and copy that setup buffer, too.
4. Clear the Interrupt: Write 1 to clear corresponding usb.ENDPTSETUPSTAT register bit.
A poll loop should be used to wait until usb.ENDPTSETUPSTAT transitions to 0 and before
priming for the status/handshake phases.
The time from writing a 1 to usb.ENDPTSETUPSTAT register and reading back a 0 is very short
(approximately 1 to 2 microsecond) so a poll loop in the DCD should not be harmful in most
systems.
5. Clear the Tripwire: Write 0 to clear setup tripwire bit usb.USBCMD [SUTW].
6. Process setup packet: Use the local software byte array copy and execute status/handshake
phases.
7. Check Endpoint status: Before priming for status/handshake phases, ensure that the
usb.ENDPTSETUPSTAT bit is = 0.
Note: After receiving a new setup packet, the status and/or handshake phases might still be
pending from a previous control sequence. These should be flushed and deallocated before linking
a new status and/or handshake dTD for the most recent setup packet.
Data Phase
Following the setup phase, the DCD must create a device transfer descriptor for the data phase and
prime the transfer.
After priming the packet, the DCD must verify a new setup packet has not been received by reading
the usb.ENDPTSETUPSTAT register immediately verifying that the prime had completed. A prime
completes when the associated bit in the usb.ENDPTPRIME register is 0 and the associated bit in the
usb.ENDPTSTATUS register is a 1. If a prime fails, i.e., the usb.ENDPTPRIME bit goes to 0 and the
usb.ENDPTSTATUS bit is not set, then the prime has failed. This can only be due to improper setup of
the dQH, dTD or a setup arriving during the prime operation. If a new setup packet is indicated after
the endpoint prime bit is cleared, then the transfer descriptor can be freed and the DCD must
reinterpret the setup packet.