rtai-core/include/xenomai/timer.h

00001 /*
00002  * Copyright (C) 2001,2002,2003 Philippe Gerum <rpm@xenomai.org>.
00003  *
00004  * Xenomai is free software; you can redistribute it and/or modify it
00005  * under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008  *
00009  * Xenomai is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with Xenomai; if not, write to the Free Software Foundation,
00016  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  *
00018  * As a special exception, the RTAI project gives permission
00019  * for additional uses of the text contained in its release of
00020  * Xenomai.
00021  *
00022  * The exception is that, if you link the Xenomai libraries with other
00023  * files to produce an executable, this does not by itself cause the
00024  * resulting executable to be covered by the GNU General Public License.
00025  * Your use of that executable is in no way restricted on account of
00026  * linking the Xenomai libraries code into it.
00027  *
00028  * This exception does not however invalidate any other reasons why
00029  * the executable file might be covered by the GNU General Public
00030  * License.
00031  *
00032  * This exception applies only to the code released by the
00033  * RTAI project under the name Xenomai.  If you copy code from other
00034  * RTAI project releases into a copy of Xenomai, as the General Public
00035  * License permits, the exception does not apply to the code that you
00036  * add in this way.  To avoid misleading anyone as to the status of
00037  * such modified files, you must delete this exception notice from
00038  * them.
00039  *
00040  * If you write modifications of your own for Xenomai, it is your
00041  * choice whether to permit this exception to apply to your
00042  * modifications. If you do not wish that, delete this exception
00043  * notice.
00044  */
00045 
00046 #ifndef _xenomai_timer_h
00047 #define _xenomai_timer_h
00048 
00049 #include "xenomai/queue.h"
00050 
00051 #define XNPOD_APERIODIC_TICK       0
00052 
00053 /* Number of outstanding timers (hint only) -- must be ^2 */
00054 #define XNTIMER_WHEELSIZE 128
00055 #define XNTIMER_WHEELMASK (XNTIMER_WHEELSIZE - 1)
00056 
00057 #define XNTIMER_ENABLED   0x00000001
00058 #define XNTIMER_DEQUEUED  0x00000002
00059 #define XNTIMER_KILLED    0x00000004
00060 
00061 /* These flags are available to the real-time interfaces */
00062 #define XNTIMER_SPARE0  0x01000000
00063 #define XNTIMER_SPARE1  0x02000000
00064 #define XNTIMER_SPARE2  0x04000000
00065 #define XNTIMER_SPARE3  0x08000000
00066 #define XNTIMER_SPARE4  0x10000000
00067 #define XNTIMER_SPARE5  0x20000000
00068 #define XNTIMER_SPARE6  0x40000000
00069 #define XNTIMER_SPARE7  0x80000000
00070 
00071 typedef struct xntimer {
00072 
00073     xnholder_t link;
00074 
00075 #define link2timer(laddr) \
00076 ((xntimer_t *)(((char *)laddr) - (int)(&((xntimer_t *)0)->link)))
00077 
00078     xnflags_t status;
00079 
00080     xnticks_t date;             /* Timeout date (in ticks) */
00081 
00082     xnticks_t interval;         /* Periodic interval (in ticks, 0 == one shot) */
00083 
00084     void (*handler)(void *cookie); /* Timeout handler */
00085 
00086     void *cookie;       /* Cookie to pass to the timeout handler */
00087 
00088     XNARCH_DECL_DISPLAY_CONTEXT();
00089 
00090 } xntimer_t;
00091 
00092 #define xntimer_date(t)           ((t)->date)
00093 #define xntimer_interval(t)       ((t)->interval)
00094 #define xntimer_set_cookie(t,c)   ((t)->cookie = (c))
00095 
00096 static inline int xntimer_active_p (xntimer_t *timer) {
00097     return !testbits(timer->status,XNTIMER_DEQUEUED);
00098 }
00099 
00100 #ifdef __cplusplus
00101 extern "C" {
00102 #endif
00103 
00104 void xntimer_init(xntimer_t *timer,
00105                   void (*handler)(void *cookie),
00106                   void *cookie);
00107 
00108 void xntimer_destroy(xntimer_t *timer);
00109 
00110 void xntimer_do_timers(int incr);
00111 
00112 int xntimer_start(xntimer_t *timer,
00113                   xnticks_t value,
00114                   xnticks_t interval);
00115 
00116 void xntimer_stop(xntimer_t *timer);
00117 
00118 xnticks_t xntimer_get_date(xntimer_t *timer);
00119 
00120 xnticks_t xntimer_get_timeout(xntimer_t *timer);
00121 
00122 void xntimer_freeze(void);
00123 
00124 #ifdef __cplusplus
00125 }
00126 #endif
00127 
00128 #endif /* !_xenomai_timer_h */

Generated on Sat Jul 24 19:36:04 2004 for RTAI API by doxygen 1.3.4