blob: a817d53e6ee3567deca82ae9094e161d58ed3356 [file] [log] [blame]
adamdunkels02784352005-02-07 22:45:14 +00001/**
2 * \addtogroup timer
3 * @{
4 */
5
6/**
7 * \file
8 * Timer library header file.
9 * \author
10 * Adam Dunkels <adam@sics.se>
11 */
12
adamdunkelsa2f3c422004-09-12 20:24:53 +000013/*
14 * Copyright (c) 2004, Swedish Institute of Computer Science.
15 * All rights reserved.
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions
19 * are met:
20 * 1. Redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer.
22 * 2. Redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution.
25 * 3. Neither the name of the Institute nor the names of its contributors
26 * may be used to endorse or promote products derived from this software
27 * without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
30 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
33 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 * SUCH DAMAGE.
40 *
41 * This file is part of the Contiki operating system.
42 *
43 * Author: Adam Dunkels <adam@sics.se>
44 *
adamdunkels02784352005-02-07 22:45:14 +000045 * $Id: timer.h,v 1.4 2005/02/07 22:45:15 adamdunkels Exp $
adamdunkelsa2f3c422004-09-12 20:24:53 +000046 */
adamdunkelsd106ecc2004-06-06 06:09:31 +000047#ifndef __TIMER_H__
48#define __TIMER_H__
49
50#include "clock.h"
51
adamdunkels02784352005-02-07 22:45:14 +000052/**
53 * A timer.
54 *
55 * This structure is used for declaring a timer. The timer must be set
56 * with timer_set() before it can be used.
57 *
58 * \hideinitializer
59 */
adamdunkelsd106ecc2004-06-06 06:09:31 +000060struct timer {
adamdunkels123ab1c2004-09-01 19:05:21 +000061 clock_time_t start;
adamdunkelsd106ecc2004-06-06 06:09:31 +000062 clock_time_t interval;
63};
64
65void timer_set(struct timer *t, clock_time_t interval);
66void timer_reset(struct timer *t);
adamdunkels02784352005-02-07 22:45:14 +000067void timer_restart(struct timer *t);
adamdunkelsd106ecc2004-06-06 06:09:31 +000068int timer_expired(struct timer *t);
69
70#endif /* __TIMER_H__ */