Skip to content

Commit 1138329

Browse files
committed
Support user config looptask stack size
1 parent 7bc9edb commit 1138329

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

cores/esp32/Arduino.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ uint16_t makeWord(byte h, byte l);
166166

167167
#define word(...) makeWord(__VA_ARGS__)
168168

169+
size_t getArduinoLoopTaskStackSize(void);
170+
#define SET_LOOP_TASK_STACK_SIZE(sz) size_t getArduinoLoopTaskStackSize() { return sz;}
171+
169172
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);
170173
unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);
171174

cores/esp32/main.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
33
#include "esp_task_wdt.h"
44
#include "Arduino.h"
55

6+
#ifndef ARDUINO_LOOP_STACK_SIZE
67
#ifndef CONFIG_ARDUINO_LOOP_STACK_SIZE
7-
#define CONFIG_ARDUINO_LOOP_STACK_SIZE 8192
8+
#define ARDUINO_LOOP_STACK_SIZE 8192
9+
#else
10+
#define ARDUINO_LOOP_STACK_SIZE CONFIG_ARDUINO_LOOP_STACK_SIZE
11+
#endif
812
#endif
913

1014
TaskHandle_t loopTaskHandle = NULL;
@@ -29,7 +33,7 @@ extern "C" void app_main()
2933
{
3034
loopTaskWDTEnabled = false;
3135
initArduino();
32-
xTaskCreateUniversal(loopTask, "loopTask", CONFIG_ARDUINO_LOOP_STACK_SIZE, NULL, 1, &loopTaskHandle, CONFIG_ARDUINO_RUNNING_CORE);
36+
xTaskCreateUniversal(loopTask, "loopTask", getArduinoLoopTaskStackSize(), NULL, 1, &loopTaskHandle, CONFIG_ARDUINO_RUNNING_CORE);
3337
}
3438

3539
#endif

0 commit comments

Comments
 (0)