RTAI API---Timer functions

Timer functions:

rt_set_oneshot_mode
rt_set_periodic_mode
start_rt_timer
stop_rt_timer
count2nano
nano2count
rt_get_time  
rt_get_time_ns  
rt_get_cpu_time_ns  
next_period

please refer to: https://www.rtai.org/userfiles/documentation/magma/html/api

**********************************************************************************************

NAME
rt_set_oneshot_mode, rt_set_periodic_mode - set timer mode


SYNOPSIS
#include "rtai_sched.h"
void rt_set_oneshot_mode (void);
void rt_set_periodic_mode (void);


DESCRIPTION
rt_set_oneshot_mode sets the oneshot mode for the timer. It consists in a variable timing based on the cpu clock frequency. This allows task to be timed arbitrarily. It must be called before using any time related function, including conversions.
rt_set_periodic_mode sets the periodic mode for the timer. It consists of a fixed frequency timing of the tasks in multiple of the period set with a call to start_rt_timer. The resolution is that of the 8254 frequency (1193180 hz). Any timing request not an integer multiple of the period is satisfied at the closest period tick. It is the default mode when no call is made to set the oneshot mode.

Oneshot mode can be set initially also with OneShot command line parameter of the rtai_sched module.

NOTE
Stopping the timer by stop_rt_timer sets the timer back into its defult (periodic) mode. Call rt_set_oneshot_mode before each start_rt_timer if it required.
*************************************************************************************************

NAME
start_rt_timer, stop_rt_timer - start/stop timer


SYNOPSIS
#include "rtai_sched.h"
RTIME start_rt_timer (int period);
void stop_rt_timer (void);


DESCRIPTION
start_rt_timer starts the timer with a period period. The period is in internal count units and is required only for the periodic mode. In the oneshot the parameter value is ignored.
stop_rt_timer stops the timer. The timer mode is set to periodic.

RETURN VALUE
The period in internal count units.
************************************************************************************************
NAME
count2nano, nano2count - convert internal count units to nanosecs and back
SYNOPSIS

#include "rtai_sched.h"
RTIME count2nano (RTIME timercounts);
RTIME nano2count (RTIME nanosecs);

DESCRIPTION
count2nano converts the time of timercounts internal count units into nanoseconds.
nano2count converts the time of nanosecs nanoseconds into internal counts units.


Remember that the count units are related to the cpu frequency in oneshot mode and to the 8254 frequency (1193180 Hz) in periodic mode.

RETURN VALUE
The given time in nanoseconds/internal count units is returned.

************************************************************************************************

NAME
rt_get_time, rt_get_time_ns, rt_get_cpu_time_ns - get the current time


SYNOPSIS
#include "rtai_sched.h"
RTIME rt_get_time (void);
RTIME rt_get_time_ns (void);
RTIME rt_get_cpu_time_ns (void);


DESCRIPTION
rt_get_time returns the number of real time clock ticks since RT_TIMER bootup (whatever this means). This number is multiple of the 8254 period in periodic mode, while is multiple of cpu clock period in oneshot mode.
rt_get_time_ns is the same as rt_get_time but the returned time is converted to nanoseconds.

rt_get_cpu_time_ns ???

RETURN VALUE
The current time in internal count units/nanoseconds is returned.
****************************************************************************************************
NAME
next_period - get the time of next run


SYNOPSIS

#include "rtai_sched.h"
RTIME next_period (void);

DESCRIPTION
next_period returns the time when the caller task will run next.


RETURN VALUE
Next period time in internal count units.
**************************************************************************************************
NAME
rt_busy_sleep, rt_sleep, rt_sleep_until - delay/suspend execution for a while


SYNOPSIS
#include "rtai_sched.h"
void rt_busy_sleep (int nanosecs);
void rt_sleep (RTIME delay);
void rt_sleep_until (RTIME time);


DESCRIPTION
rt_busy_sleep delays the execution of the caller task without giving back the control to the scheduler. This function burns away CPU cycles in a busy wait loop It may be used for very short synchronization delays only. 
nanosecs is the number of nanoseconds to wait.
rt_sleep suspends execution of the caller task for a time of delay internal count units. During this time the CPU is used by other tasks.

rt_sleep_until is similar to rt_sleep but the parameter time is the absolute time till the task have to be suspended. If the given time is already passed this call has no effect.

Note: a higher priority task or interrupt handler can run during wait so the actual time spent in these functions may be longer than the specified.

NOTE

A higher priority task or interrupt handler can run during wait so the actual time spent in these functions may be longer than the specified.

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值