27 return xTaskCreatePinnedToCore(&Esp32UsbTaskPin::swap,
"usbPin", 3072,
this, 5,
nullptr, core) == pdPASS;
31 bool pinned()
const {
return pinned_; }
35 volatile bool pinned_ =
false;
37 static void usbdTask(
void*) {
41 static void swap(
void* arg) {
42 Esp32UsbTaskPin* s = (Esp32UsbTaskPin*)arg;
43 for (
int tries = 0; tries < 200 && !s->pinned_; tries++) {
44 vTaskDelay(pdMS_TO_TICKS(50));
45 TaskHandle_t h = xTaskGetHandle(
"usbd");
48 if (eTaskGetState(h) != eBlocked)
continue;
51 if (xTaskCreatePinnedToCore(&Esp32UsbTaskPin::usbdTask,
"usbd", 4096,
nullptr, configMAX_PRIORITIES - 1,
nullptr,
52 s->core_) != pdPASS) {
53 TWD_LOGGER.error(
"USB: could not restart the USB task on core %d; USB is dead", s->core_);
58 if (!s->pinned_)
TWD_LOGGER.
warning(
"USB: the USB task was not pinned to core %d; send stalls are more likely", s->core_);