|
| 1 | +| Supported Targets | ESP32-P4 | ESP32-S2 | ESP32-S3 | |
| 2 | +| ----------------- | -------- | -------- | -------- | |
| 3 | + |
| 4 | +# CherryUSB Host Example |
| 5 | + |
| 6 | +(See the README.md file in the upper level 'examples' directory for more information about examples.) |
| 7 | + |
| 8 | +This example demonstrates how to use the CherryUSB host driver. Currently, this example supports communication with HID devices (such as Keyboard and Mouse) and serial port devices (such as CDC_ACM, CH34x, CP210x, PL2303, FTDI FT23x/FT423x devices). |
| 9 | + |
| 10 | +## How to use example |
| 11 | + |
| 12 | +If you need to enable support for FTDI, please enable the following configuration |
| 13 | +Run `idf.py menuconfig` and in `Component config → CherryUSB Configuration → Enable usb host mode → Enable usb ftdi driver` enable. |
| 14 | + |
| 15 | +### Hardware Required |
| 16 | +* Development board with USB-OTG support |
| 17 | +* A USB cable for Power supply and programming |
| 18 | +* USB OTG Cable |
| 19 | + |
| 20 | +#### Pin Assignment |
| 21 | + |
| 22 | +Follow instruction in [examples/usb/README.md](../../../README.md) for specific hardware setup. |
| 23 | + |
| 24 | +### Build and Flash |
| 25 | + |
| 26 | +Build the project and flash it to the board, then run monitor tool to view serial output: |
| 27 | + |
| 28 | +```bash |
| 29 | +idf.py -p PORT flash monitor |
| 30 | +``` |
| 31 | + |
| 32 | +(Replace PORT with the name of the serial port to use.) |
| 33 | + |
| 34 | +(To exit the serial monitor, type ``Ctrl-]``.) |
| 35 | + |
| 36 | +See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects. |
| 37 | + |
| 38 | +## Example output |
| 39 | + |
| 40 | +When running, the example will print the following output: |
| 41 | + |
| 42 | +``` |
| 43 | +I (264) main_task: Started on CPU0 |
| 44 | +I (304) main_task: Calling app_main() |
| 45 | +[I/USB] cherryusb, version: v1.5.0 |
| 46 | +[I/USB] ========== dwc2 hcd params ========== |
| 47 | +[I/USB] CID:00000000 |
| 48 | +[I/USB] GSNPSID:4f54400a |
| 49 | +[I/USB] GHWCFG1:00000000 |
| 50 | +[I/USB] GHWCFG2:215fffd0 |
| 51 | +[I/USB] GHWCFG3:03805eb5 |
| 52 | +[I/USB] GHWCFG4:dff1a030 |
| 53 | +[I/USB] dwc2 has 16 channels and dfifo depth(32-bit words) is 896 |
| 54 | +I (334) HOST: Init usb |
| 55 | +I (334) main_task: Returned from app_main() |
| 56 | +[I/usbh_hub] New low-speed device on Bus 0, Hub 1, Port 1 connected |
| 57 | +[I/usbh_core] New device found,idVendor:413c,idProduct:2113,bcdDevice:0110 |
| 58 | +[I/usbh_core] The device has 1 bNumConfigurations |
| 59 | +[I/usbh_core] The device has 2 interfaces |
| 60 | +[I/usbh_core] Enumeration success, start loading class driver |
| 61 | +[I/usbh_core] Loading hid class driver |
| 62 | +[I/usbh_hid] Ep=81 Attr=03 Mps=8 Interval=10 Mult=00 |
| 63 | +[I/usbh_hid] Register HID Class:/dev/input0 |
| 64 | +I (1054) HID: intf 0, SubClass 1, Protocol 1 |
| 65 | +[I/usbh_core] Loading hid class driver |
| 66 | +[W/usbh_hid] Do not support set idle |
| 67 | +[I/usbh_hid] Ep=82 Attr=03 Mps=3 Interval=10 Mult=00 |
| 68 | +[I/usbh_hid] Register HID Class:/dev/input1 |
| 69 | +I (1074) HID: intf 1, SubClass 0, Protocol 0 |
| 70 | +
|
| 71 | +Keyboard |
| 72 | +xiaodou |
| 73 | +``` |
0 commit comments