Skip to content

Make yield() overridable #2991

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Oct 4, 2019
Merged
Next Next commit
Make delay() and yield() overridable, and add pluggable loop_end()
  • Loading branch information
dok-net committed Oct 1, 2019
commit 414ed09763a265cbe692128ac4097cfaffc78d56
8 changes: 6 additions & 2 deletions cores/esp32/esp32-hal-misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ float temperatureRead()
return (temprature_sens_read() - 32) / 1.8;
}

void yield()
void __yield()
{
vPortYield();
}

void yield() __attribute__ ((weak, alias("__yield")));

#if CONFIG_AUTOSTART_ARDUINO

extern TaskHandle_t loopTaskHandle;
Expand Down Expand Up @@ -139,11 +141,13 @@ unsigned long IRAM_ATTR millis()
return (unsigned long) (esp_timer_get_time() / 1000ULL);
}

void delay(uint32_t ms)
void __delay(uint32_t ms)
{
vTaskDelay(ms / portTICK_PERIOD_MS);
}

void delay(uint32_t ms) __attribute__ ((weak, alias("__delay")));

void IRAM_ATTR delayMicroseconds(uint32_t us)
{
uint32_t m = micros();
Expand Down
8 changes: 8 additions & 0 deletions cores/esp32/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ TaskHandle_t loopTaskHandle = NULL;

bool loopTaskWDTEnabled;

extern "C" void __loop_end(void)
{
/* do nothing by default */
}

extern "C" void loop_end(void) __attribute__((weak, alias("__loop_end")));

void loopTask(void *pvParameters)
{
setup();
Expand All @@ -17,6 +24,7 @@ void loopTask(void *pvParameters)
esp_task_wdt_reset();
}
loop();
loop_end();
}
}

Expand Down