3. Place a copy of the device framework setup command in a memory buffer. See the
Universal Serial Bus Revision 2.0 specification,
"Chapter 9 USB Device Framework"
(http://www.usb.org/developers/docs).
4. Initialize current even or odd TX EP0 BDT to transfer the 8 bytes of command data
for a device framework command (for example, a GET DEVICE DESCRIPTOR).
• Set the BDT command word to 0x00080080 –Byte count to 8, OWN bit to 1.
• Set the BDT buffer address field to the start address of the 8 byte command
buffer.
5. Set the USB device address of the target device in the address register (ADDR[6:0]).
After the USB bus reset, the device USB address is zero. It is set to some other value
usually 1 by the Set Address device framework command.
6. Write the TOKEN register with a SETUP to Endpoint 0, the target device default
control pipe (TOKEN=0xD0). This initiates a setup token on the bus followed by a
data packet. The device handshake is returned in the BDT PID field after the packets
complete. When the BDT is written, a Token Done (ISTAT[TOKDNE]) interrupt is
asserted. This completes the setup phase of the setup transaction. See the Universal
Serial Bus Revision 2.0 specification,
"Chapter 9 USB Device Framework" (http://
www.usb.org/developers/docs).
7. To initiate the data phase of the setup transaction (that is, get the data for the GET
DEVICE DESCRIPTOR command), set up a buffer in memory for the data to be
transferred.
8. Initialize the current even or odd TX EP0 BDT to transfer the data.
• Set the BDT command word to 0x004000C0 – BC to 64 (the byte count of the
data buffer in this case), OWN bit to 1, Data toggle to Data1.
• Set the BDT buffer address field to the start address of the data buffer
9. Write the TOKEN register with an IN or OUT token to Endpoint 0, the target device
default control pipe, an IN token for a GET DEVICE DESCRIPTOR command
(TOKEN=0x90). This initiates an IN token on the bus followed by a data packet
from the device to the host. When the data packet completes, the BDT is written and
a Token Done (ISTAT[DNE]) interrupt is asserted. For control transfers with a single
packet data phase this completes the data phase of the setup transaction. See the
Universal Serial Bus Revision 2.0 specification,
"Chapter 9 USB Device Framework"
(http://www.usb.org/developers/docs).
10. To initiate the status phase of the setup transaction, set up a buffer in memory to
receive or send the zero length status phase data packet.
Chapter 42 Universal Serial Bus Full Speed OTG Controller (USBFSOTG)
K22F Sub-Family Reference Manual , Rev. 3, 7/2014
Freescale Semiconductor, Inc.
1029