1. 函数
在这个阶段,计时器根据定时器政策选择(单触发vs周期)以适当的周期运行,它允许设置一个实时任务定期调度。这可以用以下API实现:
int rt_task_make_periodic (RT_TASK *task, RTIME start_time, RTTIME period);
int rt_task_make_periodic (RT_TASK *task, RTIME start_delay, RTTIME period);
2.参数
task:任务指针,之前由rt_task_init()创建的,当rt_task_wait_period()被调用时,以period为周期执行。
start_time:第一次执行时间,是一个以clock ticks测量的绝对值。
start_delay:第一次执行时间,相对于当前时间,以纳秒测量。
period:任务循环周期。
3. 注意
- 为了更方便的处理clock ticks和纳秒,在rtai_sched.h中有两个宏定义能帮助你,RTIME count2nano(RTIME timercounts);RTIME nano2count (RTIME nanosecs),它们只转换时间单位,但是你要记住,计数单位与选择的时间模式(单触发/周期)相关。
- Recall that the term clock ticks depends on the mode in which the hard timer runs. So if the hard timer was set as periodic a clock tick will last as the period set in start_rt_timer,while if oneshot mode is used a clock tick will last as the inverse of the runningfrequency of the hard timer in use and irrespective of any period used in the call tostart_rt_timer.