Introduction

The Texas Instruments® USB Library is a set of data types and functions for creating USB device, host or On-The-Go (OTG) applications. The contents of the USB library and its associated header files fall into four main groups: general purpose functions, device mode specific functions, host mode specific functions, and mode detection and control functions.

The set of general purpose functions are those that are to be used in device, host, and dual mode applications. These include functions to parse USB descriptors and configure features of the USB library. The device specific functions provide the class-independent features required by all USB device applications such as host connection signaling and responding to standard descriptor requests. The USB library also contains a set of modules that handle the class specific requests from the USB host as well as a layer to interact with an application. The USB library provides a set of lower level class-independent host functions required by all USB host applications such as device detection and enumeration, and endpoint management. This lower layer remains mostly invisible to the application, but can be exposed to the application via class specific USB host modules. Like the device mode layer, the host mode class specific modules provide an interface to allow the lower level USB library code to communicate directly over the USB bus and also has a higher level interface that interacts with the application. The USB library also provides functions to configure how the USB controller handles switching between host and device mode operation. The modes and the functions that control them are described in the next section.

Operating Modes

There are five modes that the USB Library can function in and they are set by application. The run time operating mode of the USB controller is set by the way the USB controller is configured to detect the USB connection to another device. This mode detection can be automatic by using full OTG operation, manual by using dual mode operation, or fixed to either host or device mode. In all cases these modes control how the USB controller interacts with the USB VBUS and USB ID pins.

When an application only needs to run in USB host mode it can choose how the device powers VBUS, the detection of over current, the automatic monitoring of VBUS. These are controlled at initialization time by calls to USBStackModeSet() with one of the eUSBMode* values defined in the tUSBMode type definition. The application uses the eUSBModeForceHost option if the application has no need to monitor VBUS. This still provides the ability to control VBUS power and the over current detection but does not allow for monitoring VBUS. The application uses the eUSBModeHost setting when the application requires the ability to be able to monitor VBUS. This setting also requires that the ID pin be externally tied low as it does not fully disable the OTG mode of operation for mode detection.

If an application only needs to run in device mode there are two options to control how device mode is entered. The USBStackModeSet() function is still used to control device mode operation. The application uses eUSBModeForceDevice when the application needs to free up the VBUS and ID pins or does not want VBUS to be monitored. The impact of this is that the application is not informed of USB disconnection events because it can no longer monitor VBUS. This is only a problem for self powered applications and can be handled by monitoring VBUS on a separate pin. If the application needs to receive disconnect events it uses the eUSBModeDevice setting and must connect the VBUS pin to the USB connector and leave the ID pin unconnected.

Some application also need to run as either host or device and the USB library provides two methods to handle switching modes on the fly. The first is to use the normal USB OTG signaling to control mode switching which requires both the ID and VBUS pins to be connected to the USB connector and using the eUSBModeOTG setting with USBStackModeSet(). This is designed to work with a single USB AB connector. See the USB OTG section of this document for further details on operating in OTG mode. Another method of switching operating mode is to allow the application to choose the operating mode of the USB controller manually. This is more useful when the application is using a host and a device connector and can detect when it needs to manually switch the USB operating mode. The APIs and further description is in the dual mode section of this document.

File Structure

The following is an overview of the organization of the USB library source code, along with references to where each portion is described in detail.

Location

Description

source/ti/usblib/msp432e4/

The main directory in the SDK that contains the usblib source files and headers for functions and data types which are of general use to device and host applications.

source/ti/usblib/msp432e4/device/

This directory contains source code and header files relating to operation as a USB device.

source/ti/usblib/msp432e4/host/

This directory contains source code and header files relating to operation as a USB host.