Xenomai API  2.6.5
timer.h
Go to the documentation of this file.
1 
29 #ifndef _XENO_TIMER_H
30 #define _XENO_TIMER_H
31 
32 #include <native/types.h>
33 
34 #define TM_ONESHOT XN_APERIODIC_TICK
35 
40 typedef struct rt_timer_info {
41 
42  RTIME period; /* !< Current status (unset, aperiodic, period). */
43  RTIME date; /* !< Current wallclock time. */
44  RTIME tsc; /* !< Current tsc count. */
45 
47 
48 #if defined(__KERNEL__) || defined(__XENO_SIM__)
49 
50 #include <nucleus/timer.h>
51 #ifdef __KERNEL__
52 #include <asm-generic/xenomai/timeconv.h>
53 #endif
54 
55 extern xntbase_t *__native_tbase;
56 
57 #endif /* __KERNEL__ || __XENO_SIM__ */
58 
59 #ifdef __cplusplus
60 extern "C" {
61 #endif
62 
63 #if (defined(__KERNEL__) || defined(__XENO_SIM__)) && !defined(DOXYGEN_CPP)
64 static inline SRTIME rt_timer_ns2tsc(SRTIME ns)
65 {
66  return xnarch_ns_to_tsc(ns);
67 }
68 
69 static inline SRTIME rt_timer_tsc2ns(SRTIME ticks)
70 {
71  return xnarch_tsc_to_ns(ticks);
72 }
73 
74 static inline RTIME rt_timer_tsc(void)
75 {
76  return xnarch_get_cpu_tsc();
77 }
78 
79 static inline RTIME rt_timer_read(void)
80 {
81  return xntbase_get_time(__native_tbase);
82 }
83 
84 static inline SRTIME rt_timer_ns2ticks(SRTIME ns)
85 {
86  return xntbase_ns2ticks(__native_tbase, ns);
87 }
88 
89 static inline SRTIME rt_timer_ticks2ns(SRTIME ticks)
90 {
91  return xntbase_ticks2ns(__native_tbase, ticks);
92 }
93 
94 #else /* !(__KERNEL__ || __XENO_SIM__) */
95 
119 SRTIME rt_timer_ns2tsc(SRTIME ns);
120 
144 SRTIME rt_timer_tsc2ns(SRTIME ticks);
145 
167 RTIME rt_timer_tsc(void);
168 
193 RTIME rt_timer_read(void);
194 
218 SRTIME rt_timer_ns2ticks(SRTIME ns);
219 
243 SRTIME rt_timer_ticks2ns(SRTIME ticks);
244 
245 #endif /* !(__KERNEL__ || __XENO_SIM__) */
246 
248 
249 RTIME rt_timer_read(void);
250 
251 void rt_timer_spin(RTIME ns);
252 
253 int rt_timer_set_mode(RTIME nstick);
254 
255 #ifdef __cplusplus
256 }
257 #endif
258 
261 #endif /* !_XENO_TIMER_H */
SRTIME rt_timer_ns2tsc(SRTIME ns)
Convert nanoseconds to local CPU clock ticks.
Definition: timer.c:70
static xnticks_t xntbase_get_time(xntbase_t *base)
Get the clock time for a given time base.
Definition: timebase.h:301
void rt_timer_spin(RTIME ns)
Busy wait burning CPU cycles.
Definition: timer.c:124
int rt_timer_inquire(RT_TIMER_INFO *info)
Inquire about the timer.
Definition: timer.c:73
Structure containing timer-information useful to users.
Definition: timer.h:40
int rt_timer_set_mode(RTIME nstick)
Set the system clock rate.
Definition: timer.c:173
SRTIME rt_timer_tsc2ns(SRTIME ticks)
Convert local CPU clock ticks to nanoseconds.
Definition: timer.c:75
RTIME rt_timer_tsc(void)
Return the current TSC value.
Definition: timer.c:41
SRTIME rt_timer_ns2ticks(SRTIME ns)
Convert nanoseconds to internal clock ticks.
Definition: timer.c:54
This file is part of the Xenomai project.
SRTIME rt_timer_ticks2ns(SRTIME ticks)
Convert internal clock ticks to nanoseconds.
Definition: timer.c:62
RTIME rt_timer_read(void)
Return the current system time.
Definition: timer.c:33
struct rt_timer_info RT_TIMER_INFO
Structure containing timer-information useful to users.