42.6 Host Mode Operation Examples
The following sections illustrate the steps required to perform USB host functions using
the USB-FS core. While it is useful to understand the interaction of the hardware and the
software at a detailed level, an understanding of the interactions at this level is not
required to write host applications using the API software.
To enable host mode and discover a connected device:
1. Enable Host Mode (CTL[HOST_MODE_EN]=1). The pull-down resistors are
enabled, and pull-up disabled. Start of Frame (SOF) generation begins. SOF counter
loaded with 12,000. Disable SOF packet generation to eliminate noise on the USB by
writing the USB enable bit to 0 (CTL[USB_EN]=0).
2. Enable the ATTACH interrupt (INT_ENB[ATTACH]=1).
3. Wait for ATTACH interrupt (INT_STAT[ATTACH]). Signaled by USB Target pull-
up resistor changing the state of DPLUS or DMINUS from 0 to 1 (SE0 to J or K
state).
4. Check the state of the JSTATE and SE0 bits in the control register. If the connecting
device is low speed (JSTATE bit is 0), set the low-speed bit in the address registers
(ADDR[LS_EN]=1) and the Host Without Hub bit in endpoint 0 register control
(ENDPT0[HOSTWOHUB]=1).
5. Enable RESET (CTL[RESET]=1) for 10 ms.
6. Enable SOF packet to keep the connected device from going to suspend
(CTL[USB_EN=1]).
7. Enumerate the attached device by sending the appropriate commands to the default
control pipe of the connected device. See the Universal Serial Bus Revision 2.0
specification,
"Chapter 9 USB Device Framework" (http://www.usb.org/developers/
docs).
To complete a control transaction to a connected device:
1. Complete all the steps to discover a connected device
2. Set up the endpoint control register for bidirectional control transfers ENDPT0[4:0]
= 0x0d.
Host Mode Operation Examples
K22F Sub-Family Reference Manual , Rev. 3, 7/2014
1028
Freescale Semiconductor, Inc.