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
+79-5Lines changed: 79 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -81,7 +81,7 @@ The default installation automatically configures the port (High-speed if suppor
81
81
82
82
Default descriptors are provided for the following USB classes: CDC, MSC, and NCM.
83
83
84
-
> **⚠️ Important:** For demonstration purposes, all error handling logic has been removed from the code examples. Do not ignore proper error handling in actual development.
84
+
> ⚠️ For demonstration purposes, all error handling logic has been removed from the code examples. Do not ignore proper error handling in actual development.
85
85
86
86
```c
87
87
#include"tinyusb_default_config.h"
@@ -208,10 +208,12 @@ Values of default descriptors could be configured via `menuconfig`.
208
208
209
209
### USB PHY configuration & Self-Powered Device
210
210
211
-
For self-powered devices, monitoring the VBUS voltage is required. To do this:
211
+
For self-powered USB devices, the peripheral must be able to detect the VBUS voltage to know when it is connected to, or disconnected from, a USB host.
212
212
213
-
- Configure a GPIO pin as an input, using an external voltage divider or comparator to detect the VBUS state.
214
-
- Set `self_powered = true` and assign the VBUS monitor GPIO in the `tinyusb_config_t` structure.
213
+
To enable this:
214
+
215
+
- Connect VBUS to a GPIO input (typically through a voltage divider or external comparator).
216
+
- Set `self_powered = true` and assign the VBUS monitor GPIO in `tinyusb_config_t`.
215
217
216
218
```c
217
219
#include"tinyusb_default_config.h"
@@ -226,7 +228,79 @@ For self-powered devices, monitoring the VBUS voltage is required. To do this:
226
228
tinyusb_driver_install(&tusb_cfg);
227
229
}
228
230
```
229
-
If external PHY is used:
231
+
232
+
#### ESP32-P4 (USB OTG 2.0, High-Speed)
233
+
234
+
> **⚠️ Important:**
235
+
>
236
+
> On **USB OTG 1.1** (`TINYUSB_PORT_FULL_SPEED_0`), the VBUS **BVALID** signal is handled in hardware.
237
+
>
238
+
> On **USB OTG 2.0** (`TINYUSB_PORT_HIGH_SPEED_0`), there is no hardware **BVALID** detection – it is implemented in the driver.
239
+
240
+
For the high-speed port, the driver uses a combination of ISR-driven GPIO state detection plus a software debounce timer on the VBUS monitor GPIO. This filters glitches and cable plug/unplug noise.
241
+
242
+
- The debounce interval is controlled by `vbus_monitor_debounce_ms` in `tinyusb_config_t`.
243
+
- If not set explicitly, the default debounce time is 250 ms.
244
+
245
+
> **Note:**
246
+
>
247
+
> The `vbus_monitor_debounce_ms` member also exists in `tinyusb_config_t` when using `TINYUSB_PORT_FULL_SPEED_0`, but it is not used by the driver in that mode because VBUS is already handled in hardware.
248
+
249
+
You can override the debounce interval in the driver configuration:
tusb_cfg.phy.vbus_monitor_debounce_ms = 350; // new debounce value
261
+
262
+
tinyusb_driver_install(&tusb_cfg);
263
+
}
264
+
```
265
+
266
+
> **🔧 GPIO ISR requirement**:
267
+
>
268
+
> When VBUS monitoring is enabled with `TINYUSB_PORT_HIGH_SPEED_0` (ESP32-P4 USB OTG 2.0), the GPIO driver ISR service **must be installed before** calling `tinyusb_driver_install()`.
The driver can also **skip PHY configuration** if you need to initialize and manage the USB PHY externally (for example, when using a custom or external PHY).
0 commit comments