Skip to content

Commit 8d1de72

Browse files
committed
Added Core Affinity
1 parent db57d13 commit 8d1de72

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

Diff for: Kconfig.projbuild

+21
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,27 @@ choice ARDUINO_UDP_RUNNING_CORE
8282

8383
endchoice
8484

85+
choice ARDUINO_SERIAL_EVENT_TASK_RUNNING_CORE
86+
bool "Core on which Arduino's Serial Event task is running"
87+
default ARDUINO_SERIAL_EVENT_RUN_NO_AFFINITY
88+
help
89+
Select on which core Arduino's Serial Event task run
90+
91+
config ARDUINO_SERIAL_EVENT_RUN_CORE0
92+
bool "CORE 0"
93+
config ARDUINO_SERIAL_EVENT_RUN_CORE1
94+
bool "CORE 1"
95+
config ARDUINO_SERIAL_EVENT_RUN_NO_AFFINITY
96+
bool "BOTH"
97+
98+
endchoice
99+
100+
config ARDUINO_SERIAL_EVENT_TASK_RUNNING_CORE
101+
int
102+
default 0 if ARDUINO_SERIAL_EVENT_RUN_CORE0
103+
default 1 if ARDUINO_SERIAL_EVENT_RUN_CORE1
104+
default -1 if ARDUINO_SERIAL_EVENT_RUN_NO_AFFINITY
105+
85106
config ARDUINO_SERIAL_EVENT_TASK_STACK_SIZE
86107
int "Serial Event task stack size"
87108
default 2048

Diff for: cores/esp32/HardwareSerial.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
#define ARDUINO_SERIAL_EVENT_TASK_PRIORITY (configMAX_PRIORITIES-1)
1818
#endif
1919

20+
#ifndef ARDUINO_SERIAL_EVENT_TASK_RUNNING_CORE
21+
#define ARDUINO_SERIAL_EVENT_TASK_RUNNING_CORE -1
22+
#endif
23+
2024
#ifndef SOC_RX0
2125
#if CONFIG_IDF_TARGET_ESP32
2226
#define SOC_RX0 3
@@ -167,7 +171,7 @@ HardwareSerial::~HardwareSerial()
167171
void HardwareSerial::_createEventTask(void *args)
168172
{
169173
// Creating UART event Task
170-
xTaskCreate(_uartEventTask, "uart_event_task", ARDUINO_SERIAL_EVENT_TASK_STACK_SIZE, this, ARDUINO_SERIAL_EVENT_TASK_PRIORITY, &_eventTask);
174+
xTaskCreateUniversal(_uartEventTask, "uart_event_task", ARDUINO_SERIAL_EVENT_TASK_STACK_SIZE, this, ARDUINO_SERIAL_EVENT_TASK_PRIORITY, &_eventTask, ARDUINO_SERIAL_EVENT_TASK_RUNNING_CORE);
171175
if (_eventTask == NULL) {
172176
log_e(" -- UART%d Event Task not Created!", _uart_nr);
173177
}

0 commit comments

Comments
 (0)