28 lines
626 B
C
28 lines
626 B
C
#include <rt/task.h>
|
|
|
|
#include <rt/log.h>
|
|
#include <rt/syscall.h>
|
|
|
|
void rt_task_sleep(unsigned long ticks)
|
|
{
|
|
if (ticks == 0)
|
|
{
|
|
return;
|
|
}
|
|
rt_logf("%s sleep for %lu ticks\n", rt_task_name(), ticks);
|
|
rt_syscall_sleep(ticks);
|
|
}
|
|
|
|
void rt_task_sleep_periodic(unsigned long *last_wake_tick, unsigned long period)
|
|
{
|
|
if (period == 0)
|
|
{
|
|
return;
|
|
}
|
|
const unsigned long last = *last_wake_tick;
|
|
*last_wake_tick = last + period;
|
|
rt_logf("%s sleep periodic, last wake = %lu, period = %lu\n",
|
|
rt_task_name(), last, period);
|
|
rt_syscall_sleep_periodic(last, period);
|
|
}
|