Skip to content

Commit

Permalink
Hopefullty the task stack is not empty now
Browse files Browse the repository at this point in the history
  • Loading branch information
NeroReflex committed Jun 19, 2018
1 parent 6a3173b commit 73dbdaa
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions cores/freertos/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ void setupUSB() __attribute__((weak));
void setupUSB() { }

aDefineStaticTask(Serial, (15 + configMINIMAL_STACK_SIZE)); // smallest tested: +15
aDefineStaticTask(Main, (15 + configMINIMAL_STACK_SIZE)); // smallest tested: +15

void SerialEvents(void *pvParameters);
void MainLoop(void *pvParameters);

int main(void)
{
Expand All @@ -49,6 +51,9 @@ int main(void)
// Create a task used specifically for serial stuff with MINIMAL priority
aCreateTask(Serial, SerialEvents, NULL, (configMAX_PRIORITIES - 3));

// Create the default task with middle priority to retain sketch compatibility
aCreateTask(Main, MainLoop, NULL, (configMAX_PRIORITIES - 2));

// Start the real time scheduler.
vTaskStartScheduler();

Expand All @@ -59,14 +64,26 @@ int main(void)
return 0;
}

TickType_t xLastWakeTime_SerialEvents;


void MainLoop(void *pvParameters __attribute__((unused))) {
TickType_t xLastWakeTime = xTaskGetTickCount();

for (;;) {
// A few seconds delay to call the idle task (it frees memory somehow..... somewhere.....)
vTaskDelayUntil(&xLastWakeTime, pdMSTOTICKS( 50 ));

loop();
}
}


void SerialEvents(void *pvParameters __attribute__((unused))) {
xLastWakeTime_SerialEvents = xTaskGetTickCount();
TickType_t xLastWakeTime = xTaskGetTickCount();

for (;;) {
// A few seconds delay to call the idle task (it frees memory somehow..... somewhere.....)
vTaskDelayUntil(&xLastWakeTime_SerialEvents, pdMSTOTICKS( 25 ));
vTaskDelayUntil(&xLastWakeTime, pdMSTOTICKS( 25 ));

if (serialEventRun) serialEventRun();
}
Expand Down

0 comments on commit 73dbdaa

Please sign in to comment.