Skip to content

Commit 11b16dd

Browse files
committed
Adds support to change LoopTask Stack size
1 parent 39b9e1e commit 11b16dd

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

cores/esp32/Arduino.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ uint16_t makeWord(uint8_t h, uint8_t l);
179179

180180
#define word(...) makeWord(__VA_ARGS__)
181181

182+
#define ESP_LOOP_TASK_STACK_SIZE(sz) \
183+
size_t getArduinoLoopTaskStackSize(void) { \
184+
return sz; \
185+
}
186+
182187
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);
183188
unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);
184189

cores/esp32/main.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ void yieldIfNecessary(void){
3333

3434
bool loopTaskWDTEnabled;
3535

36+
__attribute__((weak)) size_t getArduinoLoopTaskStackSize(void) {
37+
return ARDUINO_LOOP_STACK_SIZE;
38+
}
39+
3640
void loopTask(void *pvParameters)
3741
{
3842
setup();
@@ -64,7 +68,7 @@ extern "C" void app_main()
6468
#endif
6569
loopTaskWDTEnabled = false;
6670
initArduino();
67-
xTaskCreateUniversal(loopTask, "loopTask", ARDUINO_LOOP_STACK_SIZE, NULL, 1, &loopTaskHandle, ARDUINO_RUNNING_CORE);
71+
xTaskCreateUniversal(loopTask, "loopTask", getArduinoLoopTaskStackSize(), NULL, 1, &loopTaskHandle, ARDUINO_RUNNING_CORE);
6872
}
6973

7074
#endif

0 commit comments

Comments
 (0)