Skip to content

Commit 7c20528

Browse files
Jason2866me-no-devgonzabruscoSuGlider
authored
update 14052022 (#139)
* Update Kconfig to autoselect the proper running core (espressif#6718) * Update Kconfig to autoselect the proper cunning core * Always run UDP on Core0 by default * Change SPI::transfer signature to match official Arduino API (espressif#6734) * Adjustable Serial Event Task Stack Size And Priority (espressif#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 espressif#6718 Also eliminates conflict with espressif#6718 for merging Co-authored-by: Rodrigo Garcia <[email protected]> Co-authored-by: Me No Dev <[email protected]> Co-authored-by: Me No Dev <[email protected]> Co-authored-by: Gonzalo Brusco <[email protected]> Co-authored-by: Rodrigo Garcia <[email protected]>
1 parent 98e212f commit 7c20528

File tree

4 files changed

+70
-13
lines changed

4 files changed

+70
-13
lines changed

Kconfig.projbuild

+54-9
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,19 @@ config AUTOSTART_ARDUINO
2121

2222
choice ARDUINO_RUNNING_CORE
2323
bool "Core on which Arduino's setup() and loop() are running"
24-
default ARDUINO_RUN_CORE1
24+
default ARDUINO_RUN_CORE0 if FREERTOS_UNICORE
25+
default ARDUINO_RUN_CORE1 if !FREERTOS_UNICORE
2526
help
2627
Select on which core Arduino's setup() and loop() functions run
2728

2829
config ARDUINO_RUN_CORE0
2930
bool "CORE 0"
3031
config ARDUINO_RUN_CORE1
3132
bool "CORE 1"
33+
depends on !FREERTOS_UNICORE
3234
config ARDUINO_RUN_NO_AFFINITY
3335
bool "BOTH"
36+
depends on !FREERTOS_UNICORE
3437

3538
endchoice
3639

@@ -48,16 +51,19 @@ config ARDUINO_LOOP_STACK_SIZE
4851

4952
choice ARDUINO_EVENT_RUNNING_CORE
5053
bool "Core on which Arduino's event handler is running"
51-
default ARDUINO_EVENT_RUN_CORE1
54+
default ARDUINO_EVENT_RUN_CORE0 if FREERTOS_UNICORE
55+
default ARDUINO_EVENT_RUN_CORE1 if !FREERTOS_UNICORE
5256
help
5357
Select on which core Arduino's WiFi.onEvent() run
5458

5559
config ARDUINO_EVENT_RUN_CORE0
5660
bool "CORE 0"
5761
config ARDUINO_EVENT_RUN_CORE1
5862
bool "CORE 1"
63+
depends on !FREERTOS_UNICORE
5964
config ARDUINO_EVENT_RUN_NO_AFFINITY
6065
bool "BOTH"
66+
depends on !FREERTOS_UNICORE
6167

6268
endchoice
6369

@@ -67,33 +73,71 @@ config ARDUINO_EVENT_RUNNING_CORE
6773
default 1 if ARDUINO_EVENT_RUN_CORE1
6874
default -1 if ARDUINO_EVENT_RUN_NO_AFFINITY
6975

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+
70112
choice ARDUINO_UDP_RUNNING_CORE
71113
bool "Core on which Arduino's UDP is running"
72-
default ARDUINO_UDP_RUN_CORE1
114+
default ARDUINO_UDP_RUN_CORE0
73115
help
74116
Select on which core Arduino's UDP run
75117

76118
config ARDUINO_UDP_RUN_CORE0
77119
bool "CORE 0"
78120
config ARDUINO_UDP_RUN_CORE1
79121
bool "CORE 1"
122+
depends on !FREERTOS_UNICORE
80123
config ARDUINO_UDP_RUN_NO_AFFINITY
81124
bool "BOTH"
125+
depends on !FREERTOS_UNICORE
82126

83127
endchoice
84128

85-
config ARDUINO_UDP_TASK_PRIORITY
86-
int "Priority of the UDP task"
87-
default 3
88-
help
89-
Select at what priority you want the UDP task to run.
90-
91129
config ARDUINO_UDP_RUNNING_CORE
92130
int
93131
default 0 if ARDUINO_UDP_RUN_CORE0
94132
default 1 if ARDUINO_UDP_RUN_CORE1
95133
default -1 if ARDUINO_UDP_RUN_NO_AFFINITY
96134

135+
config ARDUINO_UDP_TASK_PRIORITY
136+
int "Priority of the UDP task"
137+
default 3
138+
help
139+
Select at what priority you want the UDP task to run.
140+
97141
config ARDUINO_ISR_IRAM
98142
bool "Run interrupts in IRAM"
99143
default "n"
@@ -356,3 +400,4 @@ config ARDUINO_SELECTIVE_Wire
356400

357401

358402
endmenu
403+

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
}

libraries/SPI/src/SPI.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,9 @@ void SPIClass::writeBytes(const uint8_t * data, uint32_t size)
265265
spiEndTransaction(_spi);
266266
}
267267

268-
void SPIClass::transfer(uint8_t * data, uint32_t size)
268+
void SPIClass::transfer(void * data, uint32_t size)
269269
{
270-
transferBytes(data, data, size);
270+
transferBytes((const uint8_t *)data, (uint8_t *)data, size);
271271
}
272272

273273
/**

libraries/SPI/src/SPI.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class SPIClass
7373

7474
void beginTransaction(SPISettings settings);
7575
void endTransaction(void);
76-
void transfer(uint8_t * data, uint32_t size);
76+
void transfer(void * data, uint32_t size);
7777
uint8_t transfer(uint8_t data);
7878
uint16_t transfer16(uint16_t data);
7979
uint32_t transfer32(uint32_t data);

0 commit comments

Comments
 (0)