mikaelpatel / Arduino-Scheduler

Portable Cooperative Multi-tasking Scheduler for Arduino

Home Page:https://mikaelpatel.github.io/Arduino-Scheduler/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

thread safe sleep()

Sylensky opened this issue · comments

Hi,

Is it possible to add a popular sleep(ms) function back to the scheduler? I am looking for a similiar approach to a vTaskDelay(ms) from FreeRTOS for example.

So far there is just a yield() which context-switches to the next task immediately.

@Sylensky
Thanks for the question. Actually the Arduino core function delay(ms) uses yield() and thus gives the coroutine/thread version of sleep().

https://github.com/arduino/ArduinoCore-avr/blob/42fa4a1ea1b1b11d1cc0a60298e529d37f9d14bd/cores/arduino/wiring.c#L106

Cheers, Mikael

Oh thanks, this just pointed me into the direction of a bug in my code.