µracoli Manual Version foo

- µracoli
- User Guide
- Reference Guide

timer.h
1 /* Copyright (c) 2007 Axel Wachtler
2 All rights reserved.
3
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions
6 are met:
7
8 * Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright
11 notice, this list of conditions and the following disclaimer in the
12 documentation and/or other materials provided with the distribution.
13 * Neither the name of the authors nor the names of its contributors
14 may be used to endorse or promote products derived from this software
15 without specific prior written permission.
16
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 POSSIBILITY OF SUCH DAMAGE. */
28
29 /*$Id$ */
38 #ifndef TIMER_H
39 #define TIMER_H
40 /* === includes ============================================================ */
41 #include <stdint.h>
42
43 /* === macros ============================================================== */
48 #define MSEC(v) ((time_t)(v / (1.0e3 * TIMER_TICK)))
49
50 #define USEC(v) ((time_t)(v / (1.0e6 * TIMER_TICK)))
51
52
53
54 /* === types =============================================================== */
55
56 /* === prototypes ========================================================== */
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60
64 typedef uint32_t time_t;
65
66
70 typedef struct time_stamp_tag
71 {
72 time_t time_sec;
73 time_t time_usec;
74 } time_stamp_t;
75
76
80 typedef uint32_t timer_arg_t;
81
86 typedef uint16_t timer_hdl_t;
87
95 typedef time_t (timer_handler_t)(timer_arg_t p);
96
98 #define NONE_TIMER (0)
99
100 /* === Prototypes ================================ */
107 void timer_init(void);
108
127 timer_hdl_t timer_start(timer_handler_t *thfunc, time_t duration,
128 timer_arg_t arg);
129
130
146 timer_hdl_t timer_restart(timer_hdl_t th, time_t duration);
147
158 timer_hdl_t timer_stop(timer_hdl_t th);
159
163 time_t timer_systime(void);
164
165
169 void timer_set_systime(time_t sec);
170
180 void timer_get_tstamp(time_stamp_t *ts);
181
182 #ifdef __cplusplus
183 } /* extern "C" */
184 #endif
185
188 #endif /* TIMER_H */
timer_handler_t
time_t( timer_handler_t)(timer_arg_t p)
Definition: timer.h:95
timer_restart
timer_hdl_t timer_restart(timer_hdl_t th, time_t duration)
Restarting a running timer.
time_stamp_t
Definition: timer.h:70
time_t
uint32_t time_t
Definition: timer.h:64
timer_systime
time_t timer_systime(void)
Return the current system time in ticks.
timer_set_systime
void timer_set_systime(time_t sec)
Set the current system time given in seconds since 1.1.1970.
timer_stop
timer_hdl_t timer_stop(timer_hdl_t th)
Stop a running timer.
timer_get_tstamp
void timer_get_tstamp(time_stamp_t *ts)
timer_hdl_t
uint16_t timer_hdl_t
Definition: timer.h:86
timer_init
void timer_init(void)
Initialization of the timer module.
timer_arg_t
uint32_t timer_arg_t
Definition: timer.h:80
timer_start
timer_hdl_t timer_start(timer_handler_t *thfunc, time_t duration, timer_arg_t arg)
Start a timer with a given handler function.