Skip to content

Commit 9875e37

Browse files
feat(usb): global event task stack size normalization (#11895)
* feat(usb): global event task stack size normalization * feat(usb): global event task stack size normalization * feat(usb): global event task stack priority normalization * feat(usb): global event task priority normalization * ci(pre-commit): Apply automatic fixes --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent b8b32ea commit 9875e37

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

cores/esp32/HWCDC.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "USB.h"
1515
#if SOC_USB_SERIAL_JTAG_SUPPORTED
1616

17+
#include "Arduino.h" // defines ARDUINO_SERIAL_EVENT_TASK_STACK_SIZE and ARDUINO_SERIAL_EVENT_TASK_PRIORITY
1718
#include "esp32-hal.h"
1819
#include "esp32-hal-periman.h"
1920
#include "HWCDC.h"
@@ -60,7 +61,11 @@ static esp_err_t
6061
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) {
6162
if (!arduino_hw_cdc_event_loop_handle) {
6263
esp_event_loop_args_t event_task_args = {
63-
.queue_size = 5, .task_name = "arduino_hw_cdc_events", .task_priority = 5, .task_stack_size = 2048, .task_core_id = tskNO_AFFINITY
64+
.queue_size = 5,
65+
.task_name = "arduino_hw_cdc_events",
66+
.task_priority = ARDUINO_SERIAL_EVENT_TASK_PRIORITY,
67+
.task_stack_size = ARDUINO_SERIAL_EVENT_TASK_STACK_SIZE,
68+
.task_core_id = tskNO_AFFINITY
6469
};
6570
if (esp_event_loop_create(&event_task_args, &arduino_hw_cdc_event_loop_handle) != ESP_OK) {
6671
log_e("esp_event_loop_create failed");

cores/esp32/USB.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include "esp_event.h"
2323
#include "USBCDC.h"
24+
#include "Arduino.h" // defines ARDUINO_SERIAL_EVENT_TASK_STACK_SIZE and ARDUINO_SERIAL_EVENT_TASK_PRIORITY
2425

2526
#define ARDUINO_USB_ON_BOOT (ARDUINO_USB_CDC_ON_BOOT | ARDUINO_USB_MSC_ON_BOOT | ARDUINO_USB_DFU_ON_BOOT)
2627

@@ -43,7 +44,7 @@ typedef union {
4344

4445
class ESPUSB {
4546
public:
46-
ESPUSB(size_t event_task_stack_size = 2048, uint8_t event_task_priority = 5);
47+
ESPUSB(size_t event_task_stack_size = ARDUINO_SERIAL_EVENT_TASK_STACK_SIZE, uint8_t event_task_priority = ARDUINO_SERIAL_EVENT_TASK_PRIORITY);
4748
~ESPUSB();
4849

4950
void onEvent(esp_event_handler_t callback);

0 commit comments

Comments
 (0)