Skip to content

Commit ed33e15

Browse files
gonzabruscoSuGliderme-no-dev
authored
Adjustable Serial Event Task Stack Size And Priority (#6685)
* Adjustable Serial Event Task Stack Size And Priority * Added options to Kconfig * Added Core Affinity * Added CONFIG_FREERTOS_UNICORE * Removed _CONFIG from FREERTOS_UNICORE * Fixing Core choice for OnReceive() Makes it alligned to changes in #6718 Also eliminates conflict with #6718 for merging Co-authored-by: Rodrigo Garcia <[email protected]> Co-authored-by: Me No Dev <[email protected]>
1 parent 5482315 commit ed33e15

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

Diff for: Kconfig.projbuild

+36
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,42 @@ config ARDUINO_EVENT_RUNNING_CORE
7373
default 1 if ARDUINO_EVENT_RUN_CORE1
7474
default -1 if ARDUINO_EVENT_RUN_NO_AFFINITY
7575

76+
choice ARDUINO_SERIAL_EVENT_TASK_RUNNING_CORE
77+
bool "Core on which Arduino's Serial Event task is running"
78+
default ARDUINO_SERIAL_EVENT_RUN_CORE0 if FREERTOS_UNICORE
79+
default ARDUINO_SERIAL_EVENT_RUN_NO_AFFINITY if !FREERTOS_UNICORE
80+
help
81+
Select on which core Arduino's Serial Event task run
82+
83+
config ARDUINO_SERIAL_EVENT_RUN_CORE0
84+
bool "CORE 0"
85+
config ARDUINO_SERIAL_EVENT_RUN_CORE1
86+
bool "CORE 1"
87+
depends on !FREERTOS_UNICORE
88+
config ARDUINO_SERIAL_EVENT_RUN_NO_AFFINITY
89+
bool "BOTH"
90+
depends on !FREERTOS_UNICORE
91+
92+
endchoice
93+
94+
config ARDUINO_SERIAL_EVENT_TASK_RUNNING_CORE
95+
int
96+
default 0 if ARDUINO_SERIAL_EVENT_RUN_CORE0
97+
default 1 if ARDUINO_SERIAL_EVENT_RUN_CORE1
98+
default -1 if ARDUINO_SERIAL_EVENT_RUN_NO_AFFINITY
99+
100+
config ARDUINO_SERIAL_EVENT_TASK_STACK_SIZE
101+
int "Serial Event task stack size"
102+
default 2048
103+
help
104+
Amount of stack available for the Serial Event task.
105+
106+
config ARDUINO_SERIAL_EVENT_TASK_PRIORITY
107+
int "Priority of the Serial Event task"
108+
default 24
109+
help
110+
Select at what priority you want the Serial Event task to run.
111+
76112
choice ARDUINO_UDP_RUNNING_CORE
77113
bool "Core on which Arduino's UDP is running"
78114
default ARDUINO_UDP_RUN_CORE0

Diff for: cores/esp32/HardwareSerial.cpp

+13-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@
99
#include "driver/uart.h"
1010
#include "freertos/queue.h"
1111

12+
#ifndef ARDUINO_SERIAL_EVENT_TASK_STACK_SIZE
13+
#define ARDUINO_SERIAL_EVENT_TASK_STACK_SIZE 2048
14+
#endif
15+
16+
#ifndef ARDUINO_SERIAL_EVENT_TASK_PRIORITY
17+
#define ARDUINO_SERIAL_EVENT_TASK_PRIORITY (configMAX_PRIORITIES-1)
18+
#endif
19+
20+
#ifndef ARDUINO_SERIAL_EVENT_TASK_RUNNING_CORE
21+
#define ARDUINO_SERIAL_EVENT_TASK_RUNNING_CORE -1
22+
#endif
23+
1224
#ifndef SOC_RX0
1325
#if CONFIG_IDF_TARGET_ESP32
1426
#define SOC_RX0 3
@@ -159,7 +171,7 @@ HardwareSerial::~HardwareSerial()
159171
void HardwareSerial::_createEventTask(void *args)
160172
{
161173
// Creating UART event Task
162-
xTaskCreate(_uartEventTask, "uart_event_task", 2048, this, configMAX_PRIORITIES - 1, &_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);
163175
if (_eventTask == NULL) {
164176
log_e(" -- UART%d Event Task not Created!", _uart_nr);
165177
}

0 commit comments

Comments
 (0)