Something about USB on-the-go

Source: Internet
Author: User
USB on-the-go What is

USBThe interface devices are now everywhere, and almost all consumer electronic devices, such as printers, cameras, mobile phones, and MP3, have USB interfaces. The fast USB transmission rate, simple interface, and support for hot swapping make it stand out among many interfaces, making it even more unified. However, the traditional USB protocol (USB) limits that a host must be used as the master in this large device group, usually a PC. The data exchange between the two peripherals can be completed only through the master and sub-transit, which is inefficient and inconvenient. With the explosive growth of embedded devices, there is a growing demand for direct data exchange between two USB devices. USB on-the-go came into being. Some manufacturers of mobile phones, PDAs, and mobile devices have developed USB on-the-go (OTG) based on USB ). Usb otg first solves the problem of point-to-point data exchange between USB devices, avoiding the cumbersome attach to USB host. For example, with usb otg, a digital camera can print the photos directly through a printer, instead of copying the photos to a PC, and then controlling the printer to print the photos.

USB OTGThere are also the following features:

NThe interface is smaller, effectively reducing the volume of electronic products

NIt can act as both a host and a device, that is, DRD (dual-role-devices)

NOTGThe device can still be connected to the PC and used as a general peripheral, that is, the pod (peripheral-only device)

NLow Power Consumption to extend the standby time of USB devices powered by battery

USB OTG Interface

Traditional USB devices include a and B. The device of the ainterface provides the power vbus, which is used as the master node. B interfaces are used as peripherals during communication. Although there are some differences in shape between interfaces A, B, and mini, the pins used follow the following definitions:

1Foot: VCC Power Supply

2Foot: D-differential negative pole

3Foot: D + differential positive electrode

4Pin: Gnd grounding

USB OTGAn ID pin is added. Its Interface (mini-AB) is defined as follows:

1Foot: vbus

2Foot: D-

3Foot: D +

4Foot: ID

5Foot: Gnd

USB OTGThe ID signal line is used to identify whether the plug is Mini A or mini B. For ease of use, different connectors have different colors: Mini A is white, mini B is black, and mini AB is gray.

USB OTG Protocol description

USB OTGIntroduced two new protocols, SRP (Session Request Protocol) and HNP (host negotiation protocol), namely the Session Request protocol and host communication protocol.

SRPB requests a device to establish a session and use the bus. The a device in the OTG system is generally powered by a battery. Therefore, the power management of the OTG system is very important. To reduce the power consumption of the OTG system, OTG requires that a can turn off the power of vbus when there is no bus activity. In this way, after a device B is connected to device A, it initializes the SRP and sends it to device A, requesting that device a provide current support on vbus for communication. In OTG, DRD can be either A or B. Therefore, DRD must support SRP initialization and response SRP. pods can only be B, so only SRP can be initialized. Device B can send requests to device a in two ways, requiring the establishment of SRP: Data-line pulsing (vbus pulsing), and vbus pulsing (vbus pulsing ). Any device a only needs to be able to respond to one SRP method, while Device B must be able to initialize two SRP methods. This ensures that device B can use another SRP method when Device B initializes a SRP and device a cannot respond.

HNPUsed for role switching when two OTG devices are connected. To implement HNP, device a must first allow Device B to control the bus through the set_feature command defined by OTG. Once the request is accepted by device A, Device B can control the bus. If device a wants to give Device B a chance to control the bus, it suspends the operation on the bus and suspends the bus. Then Device B pulls D + down to terminate the previous connection. Then, device a activates the up-pull register at D + to complete the conversion. Later, Device B will be used as the master device, and device A will be used as the peripheral device. Similarly, Device B can also suspend the bus and activate the D + pull register. After device a detects changes on the bus, clear the D + upstream register and use it as the master device again. In short, when two OTG devices are connected, the Master/Slave status can be negotiated through the HNP protocol.

WinCE Overview of usb otg driver

USB OTGThe software structure includes three parts:

UOTGController Driver: including SRP and HNP

UOTGPeripheral drive: to implement a standard USB class to implement specific USB peripheral functions

UOTGSystem host driver: includes the host driver, operating system support software, and class libraries supporting peripherals.

For drivers porting this part, pay attention to the ID detection signal and vbus control signal. These two signals are generally connected to the gpio of the MCU and are modified according to the hardware, SRP and HNP are generally completed by the vendor without modification. The main problem I encountered during debugging was that after inserting a USB flash drive, the OTG Driver detected the USB flash drive insertion and provided the vbus power supply, but immediately stopped communication, the USB flash disk cannot be used normally. After further debugging, it was found that the power supply of MCU otg_vbus was less than 5 V, and the voltage was about V when it was unavailable. After being connected to 5 V, there was no problem, currently, usb otg supports USB flash drives, and USB mouse keys cannot be used.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.