9.2.3.1.3 USB OTG Mode (Dual Role)

In this mode, the SmartFusion 2 USB OTG controller must be configured in OTG mode by using the USB controller register. Based on the type of the plug connected to the PHY through the USB OTG receptacle, the controller plays a role as either the USB device or the USB host. If the plug/device with type microA is connected, the corresponding interrupt generated to the USB controller and the firmware configures the USB OTG controller into the USB Host mode. If the plug/device with microB is connected, the corresponding USB interrupt will be generated to the Cortex-M3 processor and the firmware ISR will configure the USB OTG controller into the USB Device mode.

In OTG mode, whether the USB controller expects to behave as a host or as a peripheral, depends on the way the devices are cabled together. Following list explains the USB cable, how the USB OTG controller decides the role (device/host):

  • USB Cable end types: Each USB cable has an A / microA / miniA end and a B / microB / miniB end.
  • Entering into host mode: If the micro A end of the cable is plugged into the SmartFusion 2 device through the external PHY, the USB controller will take the role of the host and go into Host mode.
  • Entering into device mode: If the micro B end of the cable is plugged in, the USB controller will go instead into Peripheral mode and Host mode bit will be set to 0.
  • Changing the role which out swapping the cable ends: Where the USB controller is connected to a single device that contains a dual-role controller, signaling can be used to switch the roles of the two devices—with no need to switch the cable between the devices. The conditions under which the USB controller may switch between a peripheral role and a host role are explained in the OTG specification.

The following figure shows the flowchart of the overall operation in the USB OTG (dual role) mode.

Figure 9-7. Basic USB Flow Diagram when USB Controller is in OTG Mode