diff --git a/cores/esp32/HWCDC.cpp b/cores/esp32/HWCDC.cpp index 062317d9f53..e15afc99ac2 100644 --- a/cores/esp32/HWCDC.cpp +++ b/cores/esp32/HWCDC.cpp @@ -14,6 +14,7 @@ #include "USB.h" #if SOC_USB_SERIAL_JTAG_SUPPORTED +#include "Arduino.h" // defines ARDUINO_SERIAL_EVENT_TASK_STACK_SIZE and ARDUINO_SERIAL_EVENT_TASK_PRIORITY #include "esp32-hal.h" #include "esp32-hal-periman.h" #include "HWCDC.h" @@ -60,7 +61,7 @@ static esp_err_t arduino_hw_cdc_event_handler_register_with(esp_event_base_t event_base, int32_t event_id, esp_event_handler_t event_handler, void *event_handler_arg) { if (!arduino_hw_cdc_event_loop_handle) { esp_event_loop_args_t event_task_args = { - .queue_size = 5, .task_name = "arduino_hw_cdc_events", .task_priority = 5, .task_stack_size = 2048, .task_core_id = tskNO_AFFINITY + .queue_size = 5, .task_name = "arduino_hw_cdc_events", .task_priority = ARDUINO_SERIAL_EVENT_TASK_PRIORITY, .task_stack_size = ARDUINO_SERIAL_EVENT_TASK_STACK_SIZE, .task_core_id = tskNO_AFFINITY }; if (esp_event_loop_create(&event_task_args, &arduino_hw_cdc_event_loop_handle) != ESP_OK) { log_e("esp_event_loop_create failed"); diff --git a/cores/esp32/USB.h b/cores/esp32/USB.h index 6d284937e00..782121e6d50 100644 --- a/cores/esp32/USB.h +++ b/cores/esp32/USB.h @@ -21,6 +21,7 @@ #include "esp_event.h" #include "USBCDC.h" +#include "Arduino.h" // defines ARDUINO_SERIAL_EVENT_TASK_STACK_SIZE and ARDUINO_SERIAL_EVENT_TASK_PRIORITY #define ARDUINO_USB_ON_BOOT (ARDUINO_USB_CDC_ON_BOOT | ARDUINO_USB_MSC_ON_BOOT | ARDUINO_USB_DFU_ON_BOOT) @@ -43,7 +44,7 @@ typedef union { class ESPUSB { public: - ESPUSB(size_t event_task_stack_size = 2048, uint8_t event_task_priority = 5); + ESPUSB(size_t event_task_stack_size = ARDUINO_SERIAL_EVENT_TASK_STACK_SIZE, uint8_t event_task_priority = ARDUINO_SERIAL_EVENT_TASK_PRIORITY); ~ESPUSB(); void onEvent(esp_event_handler_t callback);