| 121 | } |
| 122 | |
| 123 | static bool ensureDriverInstalled() { |
| 124 | if (driverInstalled) { |
| 125 | return true; |
| 126 | } |
| 127 | |
| 128 | #if CONFIG_IDF_TARGET_ESP32P4 |
| 129 | // Tab5's USB-C port is wired to FSLS PHY0, but the USB_WRAP (FS/FSLS) controller |
| 130 | // used by TinyUSB device mode defaults to FSLS PHY1. Route it to PHY0 before |
| 131 | // installing the TinyUSB driver. |
| 132 | usb_wrap_ll_phy_select(&USB_WRAP, 0); |
| 133 | #endif |
| 134 | |
| 135 | const tinyusb_config_t tusb_cfg = { |
| 136 | .device_descriptor = &descriptor_config, |
| 137 | .string_descriptor = string_desc_arr, |
| 138 | .string_descriptor_count = sizeof(string_desc_arr) / sizeof(string_desc_arr[0]), |
| 139 | .external_phy = false, |
| 140 | #if (TUD_OPT_HIGH_SPEED) |
| 141 | .fs_configuration_descriptor = msc_fs_configuration_desc, |
| 142 | .hs_configuration_descriptor = msc_hs_configuration_desc, |
| 143 | .qualifier_descriptor = &device_qualifier, |
| 144 | #else |
| 145 | .configuration_descriptor = msc_fs_configuration_desc, |
| 146 | #endif // TUD_OPT_HIGH_SPEED |
| 147 | .self_powered = false, |
| 148 | .vbus_monitor_io = 0 |
| 149 | }; |
| 150 | |
| 151 | if (tinyusb_driver_install(&tusb_cfg) != ESP_OK) { |
| 152 | LOGGER.error("Failed to install TinyUSB driver"); |
| 153 | #if CONFIG_IDF_TARGET_ESP32P4 |
| 154 | // Roll back routing when TinyUSB did not start. |
| 155 | usb_wrap_ll_phy_select(&USB_WRAP, 1); |
| 156 | #endif |
| 157 | return false; |
| 158 | } |
| 159 | |
| 160 | driverInstalled = true; |
| 161 | return true; |
| 162 | } |
| 163 | |
| 164 | bool tusbIsSupported() { return true; } |
| 165 |
no test coverage detected