Partager via


USB Driver Interface Functions (Windows CE 5.0)

Send Feedback

USB device drivers interact with the peripherals that they control by using the USB driver interface functions. These functions, which are provided by the USB driver module, constitute the core of a USB device driver's functionality. There are several categories of USB driver interface functions, each related to a different aspect of interacting with a USB device, including transfer, pipe, frame, and configuration functions, as well as functions for performing other miscellaneous tasks.

Transfer functions are the most important category because they handle sending data to and receiving data from a USB device. There are four basic types of transfer: control, bulk, interrupt, and isochronous. There are several special transfer functions that provide common types of control transfer, such as device configuration and setup requests. All transfer functions have an optional callback parameter. If a callback function is provided, the transfer functions return immediately, or asynchronously, without waiting for the transfer request to complete. When the transfer request finishes, the USB driver module invokes the function pointed to by the callback parameter. Additionally, a USB device driver can use the USB_NO_WAIT flag to cause the transfer functions to return asynchronously, even if no callback is specified. USB device drivers typically do this in situations when they queue several requests to the device and wait for only the last one to finish. In such cases, the device driver is still responsible for closing all transfer handles. If the USB device driver provides no callback function and does not use the USB_NO_WAIT flag, the transfer function blocks until the transfer is complete. If a transfer request fails, possibly even before the transfer is issued, then the transfer function will return FALSE immediately and will not invoke any callback functions.

The USB driver module calls the callback function in a context that might block other USB operations. These callback functions should perform very minimal processing, preferably just setting some state variables and signaling an event so that any substantial post-processing can be handled by another thread; such callback functions cannot call any USB driver interface functions. In particular, callback functions that handle notifications from AbortTransfer must not call the CloseTransferHandle function. See the HID sample driver for examples of using callback functions.

HCD implementations generally have an internal contiguous buffer of memory, which is used as a temporary staging location for data during transfers. Copying data into and out of this buffer might impose an unacceptable limit on the performance of a USB device driver. In such cases, the driver might pass an optional physical memory address that the USB system uses directly for data transfers. A driver-specific buffer used in this way must be contiguous within 4 KB segments and must not be accessed by the USB device driver during transfer operations.

See Also

USB Host Controller Driver Reference | USB Host Driver Reference | USB Host Controller Driver Architecture

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.