Merge branch 'docs/update_app_examples_to_usb_host_device' into 'master'

docs: Add or update application examples for usb_host and usb_device

See merge request espressif/esp-idf!33275
This commit is contained in:
Ren Peiying 2024-09-18 11:59:36 +08:00
commit a360c737ea
4 changed files with 32 additions and 48 deletions

View File

@ -270,23 +270,15 @@ If the MSC ``CONFIG_TINYUSB_MSC_ENABLED`` option is enabled in Menuconfig, the E
Application Examples Application Examples
-------------------- --------------------
The table below describes the code examples available in the directory :example:`peripherals/usb/device`: The examples can be found in the directory :example:`peripherals/usb/device`.
.. list-table:: - :example:`peripherals/usb/device/tusb_console` demonstrates how to set up {IDF_TARGET_NAME} to get log output via a Serial Device connection using the TinyUSB component, applicable for any Espressif boards that support USB-OTG.
:widths: 35 65 - :example:`peripherals/usb/device/tusb_serial_device` demonstrates how to set up {IDF_TARGET_NAME} to function as a USB Serial Device using the TinyUSB component, with the ability to be configured as a double serial device.
:header-rows: 1 - :example:`peripherals/usb/device/tusb_midi` demonstrates how to set up {IDF_TARGET_NAME} to function as a USB MIDI Device, outputting a MIDI note sequence via the native USB port using the TinyUSB component.
- :example:`peripherals/usb/device/tusb_hid` demonstrates how to implement a USB keyboard and mouse using the TinyUSB component, which sends 'key a/A pressed & released' events and moves the mouse in a square trajectory upon connection to a USB host.
- :example:`peripherals/usb/device/tusb_msc` demonstrates how to use the USB capabilities to create a Mass Storage Device that can be recognized by USB-hosts, allowing access to its internal data storage, with support for SPI Flash and SD MMC Card storage media.
- :example:`peripherals/usb/device/tusb_composite_msc_serialdevice` demonstrates how to set up {IDF_TARGET_NAME} to function simultaneously as both a USB Serial Device and an MSC device (SPI-Flash as the storage media) using the TinyUSB component.
* - Code Example .. only:: not esp32p4
- Description
* - :example:`peripherals/usb/device/tusb_console` - :example:`peripherals/usb/device/tusb_ncm` demonstrates how to transmit Wi-Fi data to a Linux or Windows host via USB using the Network Control Model (NCM), a sub-class of Communication Device Class (CDC) USB Device for Ethernet-over-USB applications, with the help of a TinyUSB component.
- How to set up {IDF_TARGET_NAME} chip to get log output via Serial Device connection
* - :example:`peripherals/usb/device/tusb_serial_device`
- How to set up {IDF_TARGET_NAME} chip to work as a USB Serial Device
* - :example:`peripherals/usb/device/tusb_midi`
- How to set up {IDF_TARGET_NAME} chip to work as a USB MIDI Device
* - :example:`peripherals/usb/device/tusb_hid`
- How to set up {IDF_TARGET_NAME} chip to work as a USB Human Interface Device
* - :example:`peripherals/usb/device/tusb_msc`
- How to set up {IDF_TARGET_NAME} chip to work as a USB Mass Storage Device
* - :example:`peripherals/usb/device/tusb_composite_msc_serialdevice`
- How to set up {IDF_TARGET_NAME} chip to work as a Composite USB Device (MSC + CDC)

View File

@ -365,7 +365,7 @@ Examples
Host Library Examples Host Library Examples
^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^
The :example:`peripherals/usb/host/usb_host_lib` demonstrates basic usage of the USB Host Library's API to implement a pseudo-class driver. - :example:`peripherals/usb/host/usb_host_lib` demonstrates how to use the USB Host Library API to install and register a client, wait for a device connection, print the device's information, handle disconnection, and repeat these steps until a user quits the application.
Class Driver Examples Class Driver Examples
^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^
@ -376,27 +376,27 @@ CDC-ACM
""""""" """""""
* A host class driver for the Communication Device Class (Abstract Control Model) is distributed as a managed component via the `ESP Component Registry <https://components.espressif.com/component/espressif/usb_host_cdc_acm>`__. * A host class driver for the Communication Device Class (Abstract Control Model) is distributed as a managed component via the `ESP Component Registry <https://components.espressif.com/component/espressif/usb_host_cdc_acm>`__.
* The :example:`peripherals/usb/host/cdc/cdc_acm_host` example uses the CDC-ACM host driver component to communicate with CDC-ACM devices. * :example:`peripherals/usb/host/cdc/cdc_acm_host` demonstrates how to use the CDC-ACM Host Driver to enable communication between {IDF_TARGET_NAME} and a USB CDC-ACM device.
* The :example:`peripherals/usb/host/cdc/cdc_acm_vcp` example shows how can you extend the CDC-ACM host driver to interface Virtual COM Port devices. * :example:`peripherals/usb/host/cdc/cdc_acm_vcp` demonstrates how to extend the CDC-ACM driver for Virtual Communication Port (VCP) devices like CP210x, FTDI FT23x or CH34x devices, and how to control the device and send data using the CDC-ACM API.
* The CDC-ACM driver is also used in `esp_modem examples <https://github.com/espressif/esp-protocols/tree/master/components/esp_modem/examples>`__, where it is used for communication with cellular modems. * The CDC-ACM driver is also used in `esp_modem examples <https://github.com/espressif/esp-protocols/tree/master/components/esp_modem/examples>`__, where it is used for communication with cellular modems.
MSC MSC
""" """
* A host class driver for the Mass Storage Class (Bulk-Only Transport) is deployed to `ESP Component Registry <https://components.espressif.com/component/espressif/usb_host_msc>`__. * A host class driver for the Mass Storage Class (Bulk-Only Transport) is deployed to `ESP Component Registry <https://components.espressif.com/component/espressif/usb_host_msc>`__.
* The :example:`peripherals/usb/host/msc` example demonstrates the usage of the MSC host driver to read and write to a USB flash drive. * :example:`peripherals/usb/host/msc` demonstrates how to use USB Mass Storage Class to access, read, write, and perform operations on a USB flash drive, including handling USB reconnections and deinitializing the USB Host Stack.
HID HID
""" """
* A host class driver for the HID (Human interface device) is distributed as a managed component via the `ESP Component Registry <https://components.espressif.com/components/espressif/usb_host_hid>`__. * A host class driver for the HID (Human interface device) is distributed as a managed component via the `ESP Component Registry <https://components.espressif.com/components/espressif/usb_host_hid>`__.
* The :example:`peripherals/usb/host/hid` example demonstrates the possibility to receive reports from a USB HID device with several interfaces. * :example:`peripherals/usb/host/hid` demonstrates how to implement a basic USB Host HID Class Driver on {IDF_TARGET_NAME}, enabling communication with USB HID devices like keyboards and mice, and continuously scans for their connection, fetching HID reports once connected.
UVC UVC
""" """
* A host class driver for the USB Video Device Class is distributed as a managed component via the `ESP Component Registry <https://components.espressif.com/component/espressif/usb_host_uvc>`__. * A host class driver for the USB Video Device Class is distributed as a managed component via the `ESP Component Registry <https://components.espressif.com/component/espressif/usb_host_uvc>`__.
* The :example:`peripherals/usb/host/uvc` example demonstrates the usage of the UVC host driver to receive a video stream from a USB camera and optionally forward that stream over Wi-Fi. * :example:`peripherals/usb/host/uvc` demonstrates how to capture video from a USB camera using the `libuvc` library and stream the video over Wi-Fi by hosting a TCP server, with the option to visualize the captured video on a PC using the provided `player.py` script.
.. ---------------------------------------------- USB Host Menuconfig -------------------------------------------------- .. ---------------------------------------------- USB Host Menuconfig --------------------------------------------------

View File

@ -270,23 +270,15 @@ USB 大容量存储设备 (MSC)
应用示例 应用示例
-------------------- --------------------
下表列出了 :example:`peripherals/usb/device` 目录下的代码示例: 如需查看相关示例,请前往目录 :example:`peripherals/usb/device`
.. list-table:: - :example:`peripherals/usb/device/tusb_console` 演示了如何使用 TinyUSB 组件配置 {IDF_TARGET_NAME},以通过串行设备连接获取和输出日志,适用于任何支持 USB-OTG 的乐鑫开发板。
:widths: 35 65 - :example:`peripherals/usb/device/tusb_serial_device` 演示了如何使用 TinyUSB 组件将 {IDF_TARGET_NAME} 配置为 USB 串行设备,还支持配置为双串行设备。
:header-rows: 1 - :example:`peripherals/usb/device/tusb_midi` 演示了如何使用 TinyUSB 组件将 {IDF_TARGET_NAME} 配置为 USB MIDI 设备,从而通过本地 USB 端口输出 MIDI 音符序列。
- :example:`peripherals/usb/device/tusb_hid` 演示了如何使用 TinyUSB 组件实现 USB 键盘和鼠标,在连接到 USB 主机时发送 “按下和释放 key a/A” 事件,并使鼠标沿方形轨迹移动。
- :example:`peripherals/usb/device/tusb_msc` 演示了如何使用 USB 功能创建一个可以被 USB 主机识别的大容量存储设备,允许访问其内部数据存储,支持 SPI Flash 和 SD MMC 卡存储介质。
- :example:`peripherals/usb/device/tusb_composite_msc_serialdevice` 演示了如何使用 TinyUSB 组件将 {IDF_TARGET_NAME} 同时配置为 USB 串行设备和 MSC 设备(存储介质为 SPI-Flash运行。
* - 代码示例 .. only:: not esp32p4
- 描述
* - :example:`peripherals/usb/device/tusb_console` - :example:`peripherals/usb/device/tusb_ncm` 演示了使用 TinyUSB 组件,借助网络控制模型 (NCM) 将 Wi-Fi 数据通过 USB 传输到 Linux 或 Windows 主机。NCM 是通信设备类 (CDC) USB 设备的一个子类,专用于 Ethernet-over-USB 应用。
- 设置 {IDF_TARGET_NAME} 芯片,通过串行设备连接获取日志输出
* - :example:`peripherals/usb/device/tusb_serial_device`
- 设置 {IDF_TARGET_NAME} 芯片,将其作为 USB 串行设备使用
* - :example:`peripherals/usb/device/tusb_midi`
- 设置 {IDF_TARGET_NAME} 芯片,将其作为 USB MIDI 设备使用
* - :example:`peripherals/usb/device/tusb_hid`
- 设置 {IDF_TARGET_NAME} 芯片,将其作为 USB 人机界面设备使用
* - :example:`peripherals/usb/device/tusb_msc`
- 设置 {IDF_TARGET_NAME} 芯片,将其作为 USB 大容量存储设备使用
* - :example:`peripherals/usb/device/tusb_composite_msc_serialdevice`
- 设置 {IDF_TARGET_NAME} 芯片,将其作为复合 USB 设备使用 (MSC + CDC)

View File

@ -365,7 +365,7 @@ USB 主机库(以下简称主机库)是 USB 主机栈的最底层,提供
主机库示例 主机库示例
^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^
:example:`peripherals/usb/host/usb_host_lib` 展示了 USB 主机库 API 的基本用法,用于创建伪 Class 驱动程序。 :example:`peripherals/usb/host/usb_host_lib` 演示了如何使用 USB 主机库 API 来安装和注册客户端、等待设备连接、打印设备信息和处理断开连接,并重复这些步骤,直到退出应用程序。
Class 驱动程序示例 Class 驱动程序示例
^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^
@ -376,27 +376,27 @@ CDC-ACM
""""""" """""""
* 通信设备 Class抽象控制模型的主机 Class 驱动程序通过 `乐鑫组件注册表 <https://components.espressif.com/component/espressif/usb_host_cdc_acm>`__ 作为受管理的组件分发。 * 通信设备 Class抽象控制模型的主机 Class 驱动程序通过 `乐鑫组件注册表 <https://components.espressif.com/component/espressif/usb_host_cdc_acm>`__ 作为受管理的组件分发。
* 示例 :example:`peripherals/usb/host/cdc/cdc_acm_host` 使用 CDC-ACM 主机驱动程序组件,与 CDC-ACM 设备通信。 * 示例 :example:`peripherals/usb/host/cdc/cdc_acm_host` 演示了使用 CDC-ACM 主机驱动程序组件,实现 {IDF_TARGET_NAME} USB CDC-ACM 设备通信。
* 示例 :example:`peripherals/usb/host/cdc/cdc_acm_vcp` 展示了如何扩展 CDC-ACM 主机驱动程序,与虚拟串口设备交互 * 示例 :example:`peripherals/usb/host/cdc/cdc_acm_vcp` 演示了如何扩展 CDC-ACM 的主机驱动程序,以支持 VCP 设备(即虚拟通信端口设备,如 CP210x、FTDI FT23x 或 CH34x以及如何使用 CDC-ACM API 控制设备并发送数据
* 示例 `esp_modem <https://github.com/espressif/esp-protocols/tree/master/components/esp_modem/examples>`__ 中也使用了 CDC-ACM 驱动程序,该程序在这些示例中与蜂窝模块通信。 * 示例 `esp_modem <https://github.com/espressif/esp-protocols/tree/master/components/esp_modem/examples>`__ 中也使用了 CDC-ACM 驱动程序,该程序在这些示例中与蜂窝模块通信。
MSC MSC
""" """
* 大容量存储 Class仅支持批量传输的主机 Class 驱动程序已部署到 `乐鑫组件注册表 <https://components.espressif.com/component/espressif/usb_host_msc>`__ * 大容量存储 Class仅支持批量传输的主机 Class 驱动程序已部署到 `乐鑫组件注册表 <https://components.espressif.com/component/espressif/usb_host_msc>`__
* 示例 :example:`peripherals/usb/host/msc` 展示了如何使用 MSC 主机驱动程序读写 USB flash 驱动 * 示例 :example:`peripherals/usb/host/msc` 演示了如何使用 USB 大容量存储类来访问、读取、写入和操作 USB 闪存驱动器,包括处理 USB 重新连接和反初始化 USB 主机堆栈
HID HID
""" """
* HID人机接口设备的主机 class 驱动作为托管组件通过 `乐鑫组件注册表 <https://components.espressif.com/components/espressif/usb_host_hid>`__ 分发。 * HID人机接口设备的主机 class 驱动作为托管组件通过 `乐鑫组件注册表 <https://components.espressif.com/components/espressif/usb_host_hid>`__ 分发。
* 示例 :example:`peripherals/usb/host/hid` 展示了从具有多个接口的 USB HID 设备接收报告的可能性 * 示例 :example:`peripherals/usb/host/hid` 演示了如何在 {IDF_TARGET_NAME} 上实现基本的 USB 主机 HID 类驱动,以便与 USB HID 设备(如键盘和鼠标)进行通信,并持续扫描设备的连接状态。一旦连接成功,即获取 HID 报告
UVC UVC
""" """
* USB 视频设备 Class 的主机 Class 驱动程序作为托管组件通过 `乐鑫组件注册表 <https://components.espressif.com/component/espressif/usb_host_uvc>`__ 分发。 * USB 视频设备 Class 的主机 Class 驱动程序作为托管组件通过 `乐鑫组件注册表 <https://components.espressif.com/component/espressif/usb_host_uvc>`__ 分发。
* 示例 :example:`peripherals/usb/host/uvc` 展示了如何使用 UVC 主机驱动程序接收来自 USB 摄像头的视频流,并可选择将该流通过 Wi-Fi 转发 * 示例 :example:`peripherals/usb/host/uvc` 演示了如何使用 `libuvc` 库从 USB 摄像头捕获视频,并通过托管 TCP 服务器将视频流通过 Wi-Fi 传输,同时提供了使用 ``player.py`` 脚本在 PC 上查看捕获视频的选项
.. ---------------------------------------------- USB Host Menuconfig -------------------------------------------------- .. ---------------------------------------------- USB Host Menuconfig --------------------------------------------------