MCPcopy Create free account
hub / github.com/OpenEPaperLink/OpenEPaperLink / usbFlasherTask

Function usbFlasherTask

ESP32_AP-Flasher/src/usbflasher.cpp:706–748  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

704
705#ifdef HAS_USB
706void usbFlasherTask(void* parameter) {
707 flasherCmdQueue = xQueueCreate(10, sizeof(struct flasherCommand*));
708
709#ifndef ARDUINO_USB_MODE
710#error This ESP32 SoC has no Native USB interface
711#elif ARDUINO_USB_MODE == 1
712#warning This sketch should be used when USB is in OTG mode. Wrong USB mode is in use, check settings in platformio.ini
713#endif
714 USB.onEvent(usbEventCallback);
715 cmdSerial.onEvent(usbEventCallback);
716 cmdSerial.setTimeout(1000);
717 USB.productName("OpenEpaperLink-flasher");
718 USB.begin();
719 cmdSerial.begin();
720 Serial.println("Task started");
721 uint32_t notificationValue;
722 struct flasherCommand* cmd = nullptr;
723 while (true) {
724 while (serialPassthroughState) {
725 tagDebugPassthrough();
726 vTaskDelay(1 / portTICK_PERIOD_MS);
727 }
728
729 BaseType_t queuereceive = xQueueReceive(flasherCmdQueue, &cmd, 1000 / portTICK_PERIOD_MS); // timeout every second to make sure the timeout gets triggered after a while
730 if (queuereceive == pdTRUE) {
731 processFlasherCommand(cmd, TRANSPORT_USB);
732 lastCmdTimeStamp = millis();
733 if (cmd->data != nullptr) {
734 free(cmd->data);
735 cmd->data = nullptr;
736 }
737 delete cmd;
738 cmd = nullptr;
739 } else {
740 if (lastCmdTimeStamp) {
741 if (millis() - lastCmdTimeStamp > USBFLASHER_CONNECTION_TIMEOUT)
742 flasherCommandTimeout();
743 }
744 }
745
746 vTaskDelay(50 / portTICK_PERIOD_MS);
747 }
748}
749#endif
750

Callers

nothing calls this directly

Calls 5

printlnMethod · 0.80
tagDebugPassthroughFunction · 0.70
processFlasherCommandFunction · 0.70
flasherCommandTimeoutFunction · 0.70
beginMethod · 0.45

Tested by

no test coverage detected