MCPcopy Create free account
hub / github.com/TactilityProject/Tactility / ensureDriverInstalled

Function ensureDriverInstalled

Tactility/Source/hal/usb/UsbTusb.cpp:123–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121}
122
123static 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
164bool tusbIsSupported() { return true; }
165

Callers 2

Calls 1

errorMethod · 0.80

Tested by

no test coverage detected