Introduction to USB with STM32

Under construction.png Coming soon

1. What is the Universal Serial Bus (USB)

The large diversity of ports (parallel, serial, midi, joystick, etc) with their specific requirements and the lack of plug-and-play feature were almost the main reasons that pushed the most known companies in the technology domain to seek for a substitution. These companies developed the USB and formed the USB Implementers Forum.
The USB is the most successful serial interface having the following characteristics:
- simplicity and flexibility (plug-and-play)
- bi-directionality
- increasing speeds
- low cost
Since developed, the USB has been continuously ameliorated always keeping compatibility with the new technologies evolution and requirements.
The STM32 USB hardware and software are compliant with USB1.1 and USB2.0 specifications and all the following sections will speak about these standard devices.

1.1. USB 2.0 Standard overview

This section focuses on the USB2.0 standard and provides a general overview about the rich characteristics of this standard.

1.1.1. Speed

The USB2.0 supports three speeds:

      - Low speed: the data bandwidth varies from 10 to 100 Kb/s. This speed is mainly
dedicated to interactive devices (mouse, keyboard, etc)
- Full speed: the data bandwidth varies from 500 Kb/s to 10 Mb/s. This speed is mainly
dedicated to phone and audio devices (microphone, speaker, etc)
- High speed: the data bandwidth varies from 500 Kb/s to 10 Mb/s. This speed is mainly
dedicated to video and storage devices (printer, camera, etc)

At protocol level, the USB grants a very high compatibility, so users can not see big differences
between dealing with different speeds

1.1.2. USB interconnect components

The USB interconnect has three main components:

       - Host or Root Hub: it is unique for every USB system. It is responsible of initiating
all transactions. - Function or Device: the final point in the interconnect ensuring the user's required
roles (keyboard, mouse, microphone, etc) - Hub: a bridge ensuring the communication between the host and many devices. It has
one upstream port to be connected directly (point to point connection through USB cable)
or indirectly (connection through another hub) to the host and many downstream ports to be
connected directly or indirectly to the USB Functions.

The previous components can be connected to each other through USB cables with a maximum length of 5 meters.

1.1.3. USB interconnect topology

The USB physical interconnect is characterized by a tired star topology. Each star has a hub at the center with one upstream
connection directly or indirectly with the host and one or more downstream connection(s) with function or other hub.
A maximum of 127 devices (functions or hubs) can be connected to one host (root hub) with a maximum of 5 hubs
connected in series.

1.1.4. Power

Generally, the host (root hub) provides power for functions direct connection. Some hubs may supply power for directly connected downstream functions. For the functions, there are two types:

 - Bus powered functions: these devices rely totally on the bus power coming from the upstream
hub. - Self powered functions: these devices are capable of providing their own power independently
from the bus.

1.1.5. System configuration

The USB system has an intelligent mechanism to detect the device attachment and detachment at any time.

 - Device attachment: the host can detect at any time the detachment of a device by continuously
querying a bit for all the connected hub ports. Once a device is attached, the host enables
the port and gives the device a unique address then establish a communication with this newly
connected device to conclude if it is a function or a hub. - Device detachment: once a device is detached, the corresponding port will be disabled. If a
hub is detached, all the downstream devices' ports that were attached
to the removed hub will be disabled and the detached hub's upstream port will be disabled. - Bus enumeration: it is a set of hardware and software events allowing the host to continuously detect and address and recognize the newly connected device. It includes also the set of events ensuring the removal of a device.

1.1.6. USB Data transfers

USB communication is based on four main transfer types:

 - Control transfer: mainly used for the configuration data of the newly attached device.
 - Bulk transfer: used for large amounts of data transmission or reception.
 - Interrupt transfer: used for limited data transmission with minimal latency.
 - Isochronous transfer: used for data transfer with real-time requirements.

More detailed explanations of the USB characteristics and data flow will be explained with code in the following pages.

2. Getting started with STM32 and USB

'

3. Video related to Name of your tech domain

All videos related to your tech domain

pc videol.png

Getting started with STM32 Motor control SDK5.0

4. STM32 compliant with Name of your tech domain

The place to put a table with all STM32 compliant with the feature

5. Specific tools

Links and explanations for the tech domain dedicated tools

6. STMicroelectronics Resources

The place for AN, UM... direct links

7. Examples

The area where FAE's, collab... can put examples (linked to Github)



[[Category:]]