Merge branch 'docs/usb_host_set_device_config' into 'master'

feat(docs): added usb host enumeration filter description

See merge request espressif/esp-idf!28310
This commit is contained in:
Peter Marcisovsky 2024-01-29 16:40:53 +08:00
commit 6b41ae3ef9
2 changed files with 31 additions and 1 deletions

View File

@ -428,7 +428,22 @@ Configurable parameters of the USB host stack can be configured with multiple op
* For debounce delay, refer to :ref:`CONFIG_USB_HOST_DEBOUNCE_DELAY_MS`.
* For reset hold interval, refer to :ref:`CONFIG_USB_HOST_RESET_HOLD_MS`.
* For reset recovery interval, refer to :ref:`CONFIG_USB_HOST_RESET_RECOVERY_MS`.
* Fer ``SetAddress()`` recovery interval, refer to :ref:`CONFIG_USB_HOST_SET_ADDR_RECOVERY_MS`.
* For ``SetAddress()`` recovery interval, refer to :ref:`CONFIG_USB_HOST_SET_ADDR_RECOVERY_MS`.
Multiple Configuration Support
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
To support USB devices that have more than one configuration, it is possible to specify the desired configuration number during a device's enumeration process.
Enumeration Filter
""""""""""""""""""
The enumeration filter is a callback function of type :cpp:type:`usb_host_enum_filter_cb_t` called at the beginning of the enumeration process once a device descriptor is read from a newly attached USB device. Consequently, the user is provided with the obtained device descriptor. Through this callback, the user can:
* Select the configuration of the USB device.
* Filter which USB devices should be enumerated.
To use the enumeration filter, users should enable the :ref:`CONFIG_USB_HOST_ENABLE_ENUM_FILTER_CALLBACK` option using menuconfig. Users can specify the callback by setting :cpp:member:`usb_host_config_t::enum_filter_cb` which is then passed to the Host Library when calling :cpp:func:`usb_host_install`.
.. -------------------------------------------------- API Reference ----------------------------------------------------

View File

@ -430,6 +430,21 @@ USB 设备可能是热插拔的,因此必须配置电源开关和设备连接
* :ref:`CONFIG_USB_HOST_RESET_RECOVERY_MS` 用于配置重置恢复时间。
* :ref:`CONFIG_USB_HOST_SET_ADDR_RECOVERY_MS` 用于配置 ``SetAddress()`` 恢复时间。
多项配置支持
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
对于具有多项配置的 USB 设备,可以在设备枚举过程中指定所需的配置编号。
枚举过滤器
""""""""""""""""""
枚举过滤器是类型为 :cpp:type:`usb_host_enum_filter_cb_t` 的回调函数。从新连接的 USB 设备上读取设备描述符后USB 主机栈会在枚举过程开始时调用枚举过滤器,从而为用户提供读取的设备描述符。借助此回调,用户得以:
* 选择 USB 设备的配置。
* 过滤应该进行枚举的 USB 设备。
在 menuconfig 中启用 :ref:`CONFIG_USB_HOST_ENABLE_ENUM_FILTER_CALLBACK` 选项即可启用枚举过滤器。可以通过设置 :cpp:member:`usb_host_config_t::enum_filter_cb` 来指定回调函数,该函数会在调用 :cpp:func:`usb_host_install` 时传递至主机库。
.. -------------------------------------------------- API Reference ----------------------------------------------------
API 参考