You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/en/api-reference/peripherals/usb_host.rst
+49-5Lines changed: 49 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,17 +34,23 @@ The Host Library has the following features:
34
34
- Allows multiple class drivers to run simultaneously, i.e., multiple clients of the Host Library.
35
35
- A single device can be used by multiple clients simultaneously, e.g., composite devices.
36
36
- The Host Library itself and the underlying Host Stack does not internally instantiate any OS tasks. The number of tasks is entirely controlled by how the Host Library interface is used. However, a general rule of thumb regarding the number of tasks is ``(the number of host class drivers running + 1)``.
37
+
- Allows single Hub support (If option :ref:`CONFIG_USB_HOST_HUBS_SUPPORTED` is enabled).
38
+
- Allows multiple Hubs support (If option :ref:`CONFIG_USB_HOST_HUB_MULTI_LEVEL` is enabled).
37
39
38
40
Currently, the Host Library and the underlying Host Stack has the following limitations:
39
41
40
42
.. list::
41
43
42
-
- Only supports a single device, but the Host Library's API is designed for multiple device support.
43
44
- Only supports Asynchronous transfers.
44
45
- Only supports using one configuration. Changing to other configurations after enumeration is not supported yet.
45
46
- Transfer timeouts are not supported yet.
46
47
:esp32p4: - {IDF_TARGET_NAME} contains two USB-OTG peripherals USB 2.0 OTG High-Speed and USB 2.0 OTG Full-Speed. Only the High-Speed instance is supported now.
- The External Hub Driver: Supports only devices with the same speed as upstream port speed (e.g., Low-speed device won't work through Full-speed external Hub).
49
+
- The External Hub Driver: Remote Wakeup feature is not supported (External Hubs are active, even if there are no devices inserted).
50
+
- The External Hub Driver: Doesn't handle error cases (overcurrent handling, errors during initialization etc. are not implemented yet).
51
+
- The External Hub Driver: No Interface selection. The Driver uses the first available Interface with Hub Class code (09h).
52
+
- The External Port Driver: No downstream port debounce mechanism (not implemented yet)
53
+
:esp32p4: - The External Hub Driver: No Transaction Translator layer (No FS/LS Devices support when a Hub is attached to HS Host).
@@ -97,7 +103,7 @@ Therefore, in addition to the client tasks, the Host Library also requires a tas
97
103
Devices
98
104
^^^^^^^
99
105
100
-
The Host Library shields clients from the details of device handling, encompassing details such as connection, memory allocation, and enumeration. The clients are provided only with a list of already connected and enumerated devices to choose from. By default during enumeration, each device is automatically configured to use the first configuration found, namely, the first configuration descriptor returned on a Get Configuration Descriptor request. For most standard devices, the first configuration will have a ``bConfigurationValue`` of ``1``. If option :ref:`CONFIG_USB_HOST_ENABLE_ENUM_FILTER_CALLBACK` is enabled, a different ``bConfigurationValue`` can be selected, see `Multiple configuration Support`_ for more details.
106
+
The Host Library shields clients from the details of device handling, encompassing details such as connection, memory allocation, and enumeration. The clients are provided only with a list of already connected and enumerated devices to choose from. By default during enumeration, each device is automatically configured to use the first configuration found, namely, the first configuration descriptor returned on a Get Configuration Descriptor request. For most standard devices, the first configuration will have a ``bConfigurationValue`` of ``1``. If option :ref:`CONFIG_USB_HOST_ENABLE_ENUM_FILTER_CALLBACK` is enabled, a different ``bConfigurationValue`` can be selected, see `Multiple Configuration Support`_ for more details.
101
107
102
108
It is possible for two or more clients to simultaneously communicate with the same device as long as they are not communicating to the same interface. However, multiple clients can simultaneously communicate with the same device's default endpoint (i.e., EP0), which will result in their control transfers being serialized.
103
109
@@ -166,8 +172,8 @@ Lifecycle
166
172
167
173
The graph above illustrates the typical lifecycle of the Host Library with multiple clients and devices. Specifically, the example involves:
168
174
169
-
- two registered clients (Client 1 and Client 2).
170
-
- two connected devices (Device 1 and Device 2), where Client 1 communicates with Device 1 and Client 2 communicates with Device 2.
175
+
- Two registered clients (Client 1 and Client 2).
176
+
- Two connected devices (Device 1 and Device 2), where Client 1 communicates with Device 1 and Client 2 communicates with Device 2.
171
177
172
178
With reference to the graph above, the typical lifecycle involves the following key stages.
173
179
@@ -438,6 +444,44 @@ Configurable parameters of the USB host stack can be configured with multiple op
438
444
* For reset recovery interval, refer to :ref:`CONFIG_USB_HOST_RESET_RECOVERY_MS`.
439
445
* For ``SetAddress()`` recovery interval, refer to :ref:`CONFIG_USB_HOST_SET_ADDR_RECOVERY_MS`.
440
446
447
+
Downstream Port Configuration
448
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
449
+
450
+
When external Hubs feature is supported, there are several parameters which could be configured for the external Hubs port.
451
+
452
+
Each external Hub has a Hub Descriptor which describes the device characteristics.
453
+
454
+
.. note::
455
+
456
+
For detailed information about Hub Descriptor, please refer to `USB 2.0 Specification <https://www.usb.org/document-library/usb-20-specification>`_ > Chapter 11.23.2.1 *Hub Descriptor*.
457
+
458
+
Configurable parameters of the downstream port can be configured with multiple options via Menuconfig.
459
+
460
+
* For custom value to stabilize the power after powering on the port (PwrOn2PwrGood value), refer to :ref:`CONFIG_USB_HOST_EXT_PORT_CUSTOM_POWER_ON_DELAY_MS`.
461
+
* For reset recovery interval, refer to :ref:`CONFIG_USB_HOST_EXT_PORT_RESET_RECOVERY_DELAY_MS`.
462
+
463
+
.. note::
464
+
465
+
The specification claims, that for a hub with no power switches, PwrOn2PwrGood must be set to zero. Meanwhile, for some devices, this value could be increased to give extra time for device to power-up. To enable this feature, refer to :ref:`CONFIG_USB_HOST_EXT_PORT_CUSTOM_POWER_ON_DELAY_ENABLE`.
466
+
467
+
Host Channels
468
+
"""""""""""""
469
+
470
+
When external Hubs support feature is enabled (:ref:`CONFIG_USB_HOST_HUBS_SUPPORTED`), the amount of Host channels plays important role, as each downstream device requires vacant channel.
471
+
472
+
To handle each attached device, different amount of channels are required. This amount does depend on the device class (EPs number).
473
+
474
+
Supported amount of channels for {IDF_TARGET_NAME} is {OTG_NUM_HOST_CHAN}.
475
+
476
+
.. note::
477
+
478
+
- One free channel is required to enumerate the device.
479
+
480
+
- From 1 to N (when N - number of EPs) free channels are required to claim the interface.
481
+
482
+
- When there are no more free Host channels available, the device could not be enumerated and its interface cannot be claimed.
The External Port Driver (henceforth referred to as Ext Port Driver) isolates the handling process for downstream facing ports, which are provided by the Ext Hub Driver.
8
+
9
+
.. note::
10
+
11
+
For more detailed information, please refer to `USB 2.0 Specification <https://www.usb.org/document-library/usb-20-specification>`_ > Chapter 11.5 **Downstream Facing Ports**.
12
+
13
+
Requirements
14
+
------------
15
+
16
+
Host Stack Requirements
17
+
^^^^^^^^^^^^^^^^^^^^^^^
18
+
19
+
The Ext Port Driver takes into consideration the requirements set for the overall Host Stack (see :doc:`./usb_host_notes_design`):
20
+
21
+
- The Ext Port Driver must not instantiate any tasks/threads
22
+
- The Ext Port Driver must be event driven, providing event callbacks and an event processing function
23
+
- The Ext Port Driver must use only API from underlying layer (The Ext Hub Driver)
24
+
25
+
Implementation & Usage
26
+
----------------------
27
+
28
+
Host Stack Interaction
29
+
^^^^^^^^^^^^^^^^^^^^^^
30
+
31
+
The Ext Port Driver is a part of The Ext Hub Driver, so the interaction and hierarchical place in USB Host Stack is the same as for the Ext Hub Driver. The Ext Hub and the Ext Port Drivers were split into two Drivers to achieve the goal of logic distinguishing between external Hubs and Downstream Facing Ports handling.
32
+
33
+
Ports handling
34
+
^^^^^^^^^^^^^^^
35
+
36
+
The Ext Port Driver can be installed via ``ext_port_install()`` call and uninstalled via ``ext_port_uninstall()`` call.
37
+
38
+
After installation, the Ext Port Driver API could be requested via ``ext_port_get_driver()`` call.
39
+
40
+
The Ext Port Driver API
41
+
-----------------------
42
+
43
+
The Ext Port Driver provides an API, which could be split into three groups: object control, device control and general.
44
+
45
+
The Ext Port Driver: Object Control
46
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
47
+
48
+
- Create object
49
+
- Delete object
50
+
51
+
The Ext Port Driver: Port Control
52
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
53
+
54
+
- Reset
55
+
- Disable
56
+
- Recycle
57
+
- Activate
58
+
- Get Speed
59
+
- Get status
60
+
- Set status
61
+
- Gone
62
+
63
+
The Ext Port Driver: General Purpose
64
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
65
+
66
+
- Request processing
67
+
68
+
Events & Processing
69
+
-------------------
70
+
71
+
The Ext Port Driver is completely event driven and all event handling is done via the ``ext_port_process()`` function. The ``ext_port_driver_config_t.proc_req_cb`` callback provided on the Ext Port Driver installation will be called when processing is required. Typically, ``ext_port_process()`` will be called from the Hub Driver ``hub_process()`` processing function.
72
+
73
+
The Ext Port Driver exposes the following events via ``ext_port_driver_config_t.event_cb``:
74
+
75
+
- ``EXT_PORT_CONNECTED`` Downstream facing port has a device connection event
76
+
- ``EXT_PORT_RESET_COMPLETED`` Downstream facing port has a device and completed the port reset
77
+
- ``EXT_PORT_DISCONNECTED`` Downstream facing port has a device disconnection event
78
+
79
+
The Ext Port Driver ports processing is based on the Hub class-specific request ``Get Port Status``.
80
+
81
+
After successful completion of the class-specific request ``Get Port Status`` and setting the new port status, the Ext Port Driver continues the port handling while it is required by ports' state and status.
82
+
83
+
.. note::
84
+
85
+
For more detailed information, please refer to `USB 2.0 Specification <https://www.usb.org/document-library/usb-20-specification>`_ > Chapter 11.24.2.7 **Get Port Status**
Copy file name to clipboardExpand all lines: docs/en/api-reference/peripherals/usb_host/usb_host_notes_index.rst
+1-18Lines changed: 1 addition & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,6 +24,7 @@ This document is split into the following sections:
24
24
usb_host_notes_usbh
25
25
usb_host_notes_enum
26
26
usb_host_notes_ext_hub
27
+
usb_host_notes_ext_port
27
28
28
29
Todo:
29
30
@@ -40,21 +41,3 @@ Introduction
40
41
The ESP-IDF USB Host Stack allows the {IDF_TARGET_NAME} to operate as a USB Host. Operating as a USB Host allows the {IDF_TARGET_NAME} to communicate with a wide range of USB devices. However, most USB Host Stack implementations do not run on embedded hardware (i.e., runs on PCs and smartphones), thus have comparatively more resources (i.e., memory and CPU speed).
41
42
42
43
The implementation of the ESP-IDF USB Host Stack (henceforth referred to as the Host Stack) takes into account the embedded nature of the {IDF_TARGET_NAME} which is reflected in various aspects of the Host Stack's design.
43
-
44
-
Features & Limitations
45
-
^^^^^^^^^^^^^^^^^^^^^^
46
-
47
-
**The Host Stack currently supports the following notable features:**
48
-
49
-
.. only:: esp32p4
50
-
51
-
- Supports HS (High Speed)
52
-
53
-
- Supports FS (Full Speed) and LS (Low Speed) devices
54
-
- Supports all transfer types (Control, Bulk, Isochronous, and Interrupt)
55
-
- Automatically enumerates connected devices
56
-
- Allows multiple class drivers (i.e., Clients of the USB Host Library) to run simultaneously and share the same device (i.e., composite devices)
57
-
58
-
**The Host Stack currently has the following notable limitations:**
59
-
60
-
- No Hub support (currently only supports a single device)
0 commit comments