David Riley wrote:
OTG really only allows devices to negotiate who is the
master and the
slave, once, at connection time
At connection time it is fixed, not negotiated, based on which kind of
USB plug (A or B) is inserted into the OTG entity's AB receptacle. This
is sensed by the ID pin, which is grounded in a USB A plug, and
unconnected or pulled to Vbus in a USB B plug.
There are three main cases:
1) OTG entity with AB connector is connected to a host. Cable is A
(host) to B (OTG entity). The OTG entity senses via the ID pin that a B
plug is inserted into its AB connector, and enters device role.
2) OTG entity with AB connector is conntected to a device. Cable is A
(OTG entity) to B (device). The OTG entity sense via the ID pin that an
A plug is inserted into its AB connector, and enters host role.
3) Two OTG entities with AB connectors are connected together. Cable
is A to B. The OTG entity sensing via the ID pin that an A plug is
inserted enters host role. The OTG entity sensing via the ID pin that a
B plug is inserted enters device mode. Note that the user could plug
the cable between the two devices in either orientation, and that
determines which OTG entity is configured as host and which as device.
In case 3 *only*, Host Negotiation Protocol (HNP) can be used to allow
the OTG entity in the device role to request that the roles be reversed.
Note that A-A cables or B-B cables are NOT used even for OTG, and are
not allowable cable configurations per the USB standard. Some stores
actually sell passive A male to A male cables, which are completely
useless, and I've never been able to figure out why they are made or why
someone would buy one. There are active A male to A male cables, which
are used for file transfer between two hosts, but these actually contain
electronics that implements device role with respect to each host.
Plugging a passive A male to A male cable into two hosts will not
accomplish anything useful, and could even damage the hosts. On the
other hand, A male to A female or B male to B female cables are at least
useful as extenders, though not permitted by the standard.
It's really a hack to allow two like devices to
connect rather than
anything really useful (like peer-to-peer communications).
It is intended for and supports a lot more than plugging two like
devices together. For instance, it can be used to connect a camera to a
printer. The main limitation is that an embedded host usually is only
able to control a limited selection of devices, which comprise that
host's Targeted Peripheral List (TPL). Unlike a PC, a camera doesn't
usually support the user installing printer drivers, so it probably can
only support specific printer models.