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: device/esp_tinyusb/README.md
+138-4Lines changed: 138 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,10 +12,6 @@ It contains:
12
12
* VBUS monitoring for self-powered devices
13
13
* SPI Flash or sd-card access via MSC USB device Class.
14
14
15
-
## Documentation and examples
16
-
You can find documentation in [ESP-IDF Programming Guide](https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/api-reference/peripherals/usb_device.html).
17
-
18
-
You can find examples in [ESP-IDF on GitHub](https://github.com/espressif/esp-idf/tree/master/examples/peripherals/usb/device).
19
15
## How to use?
20
16
21
17
This component is distributed via [IDF component manager](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-component-manager.html). Just add `idf_component.yml` file to your main component with the following content:
@@ -30,3 +26,141 @@ Or simply run:
30
26
```
31
27
idf.py add-dependency esp_tinyusb~1.0.0
32
28
```
29
+
30
+
## Documentation
31
+
32
+
Hardware-related documentation could be found in [ESP-IDF Programming Guide](https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/api-reference/peripherals/usb_device.html).
33
+
34
+
### Device Stack Structure
35
+
36
+
The Device Stack is built on top of TinyUSB and provides:
37
+
38
+
- Custom USB descriptor support
39
+
- Serial device (CDC-ACM) support
40
+
- Standard stream redirection through the serial device
41
+
- Storage media support (SPI-Flash and SD-Card) for USB MSC Class
42
+
- A dedicated task for TinyUSB servicing
43
+
44
+
### Configuration Options
45
+
46
+
Configure the Device Stack using `menuconfig`:
47
+
48
+
- TinyUSB log verbosity
49
+
- Device Stack task options
50
+
- Default device/string descriptor options
51
+
- Class-specific options
52
+
53
+
### Descriptor Configuration
54
+
55
+
Configure USB descriptors using the `tinyusb_config_t` structure:
56
+
57
+
-`device_descriptor`
58
+
-`string_descriptor`
59
+
-`configuration_descriptor` (full-speed)
60
+
- For high-speed devices: `fs_configuration_descriptor`, `hs_configuration_descriptor`, `qualifier_descriptor`
61
+
62
+
If any descriptor field is set to `NULL`, default descriptors (based on menuconfig) are used.
63
+
64
+
### Installation
65
+
66
+
Install the Device Stack by calling `tinyusb_driver_install` with a `tinyusb_config_t` structure. Members set to `0` or `NULL` use default values.
67
+
68
+
```c
69
+
consttinyusb_config_t partial_init = {
70
+
.device_descriptor = NULL,
71
+
.string_descriptor = NULL,
72
+
.external_phy = false,
73
+
#if (TUD_OPT_HIGH_SPEED)
74
+
.fs_configuration_descriptor = NULL,
75
+
.hs_configuration_descriptor = NULL,
76
+
.qualifier_descriptor = NULL,
77
+
#else
78
+
.configuration_descriptor = NULL,
79
+
#endif
80
+
};
81
+
```
82
+
83
+
### Self-Powered Device
84
+
85
+
Self-powered devices must monitor VBUS voltage. Use a GPIO pin with a voltage divider or comparator to detect VBUS state. Set `self_powered = true` and assign the VBUS monitor GPIO in `tinyusb_config_t`.
86
+
87
+
### USB Serial Device (CDC-ACM)
88
+
89
+
If enabled, initialize the USB Serial Device with `tusb_cdc_acm_init` and a `tinyusb_config_cdcacm_t` structure:
90
+
91
+
```c
92
+
consttinyusb_config_cdcacm_t acm_cfg = {
93
+
.usb_dev = TINYUSB_USBDEV_0,
94
+
.cdc_port = TINYUSB_CDC_ACM_0,
95
+
.rx_unread_buf_sz = 64,
96
+
.callback_rx = NULL,
97
+
.callback_rx_wanted_char = NULL,
98
+
.callback_line_state_changed = NULL,
99
+
.callback_line_coding_changed = NULL
100
+
};
101
+
tusb_cdc_acm_init(&acm_cfg);
102
+
```
103
+
104
+
Redirect standard I/O streams to USB with `esp_tusb_init_console` and revert with `esp_tusb_deinit_console`.
0 commit comments