Xenomai API
2.5.6.1
|
00001 00029 #ifndef _XENO_TIMER_H 00030 #define _XENO_TIMER_H 00031 00032 #include <native/types.h> 00033 00034 #define TM_ONESHOT XN_APERIODIC_TICK 00035 00040 typedef struct rt_timer_info { 00041 00042 RTIME period; /* !< Current status (unset, aperiodic, period). */ 00043 RTIME date; /* !< Current wallclock time. */ 00044 RTIME tsc; /* !< Current tsc count. */ 00045 00046 } RT_TIMER_INFO; 00047 00048 #if defined(__KERNEL__) || defined(__XENO_SIM__) 00049 00050 #include <nucleus/timer.h> 00051 #ifdef __KERNEL__ 00052 #include <asm-generic/xenomai/timeconv.h> 00053 #endif 00054 00055 extern xntbase_t *__native_tbase; 00056 00057 #endif /* __KERNEL__ || __XENO_SIM__ */ 00058 00059 #ifdef __cplusplus 00060 extern "C" { 00061 #endif 00062 00063 #if (defined(__KERNEL__) || defined(__XENO_SIM__)) && !defined(DOXYGEN_CPP) 00064 static inline SRTIME rt_timer_ns2tsc(SRTIME ns) 00065 { 00066 return xnarch_ns_to_tsc(ns); 00067 } 00068 00069 static inline SRTIME rt_timer_tsc2ns(SRTIME ticks) 00070 { 00071 return xnarch_tsc_to_ns(ticks); 00072 } 00073 00074 static inline RTIME rt_timer_tsc(void) 00075 { 00076 return xnarch_get_cpu_tsc(); 00077 } 00078 00079 static inline RTIME rt_timer_read(void) 00080 { 00081 return xntbase_get_time(__native_tbase); 00082 } 00083 00084 static inline SRTIME rt_timer_ns2ticks(SRTIME ns) 00085 { 00086 return xntbase_ns2ticks(__native_tbase, ns); 00087 } 00088 00089 static inline SRTIME rt_timer_ticks2ns(SRTIME ticks) 00090 { 00091 return xntbase_ticks2ns(__native_tbase, ticks); 00092 } 00093 00094 #else /* !(__KERNEL__ || __XENO_SIM__) */ 00095 00119 SRTIME rt_timer_ns2tsc(SRTIME ns); 00120 00144 SRTIME rt_timer_tsc2ns(SRTIME ticks); 00145 00167 RTIME rt_timer_tsc(void); 00168 00193 RTIME rt_timer_read(void); 00194 00218 SRTIME rt_timer_ns2ticks(SRTIME ns); 00219 00243 SRTIME rt_timer_ticks2ns(SRTIME ticks); 00244 00245 #endif /* !(__KERNEL__ || __XENO_SIM__) */ 00246 00247 int rt_timer_inquire(RT_TIMER_INFO *info); 00248 00249 RTIME rt_timer_read(void); 00250 00251 void rt_timer_spin(RTIME ns); 00252 00253 int rt_timer_set_mode(RTIME nstick); 00254 00255 #ifdef __cplusplus 00256 } 00257 #endif 00258 00261 #endif /* !_XENO_TIMER_H */