adamdunkels | 0278435 | 2005-02-07 22:45:14 +0000 | [diff] [blame] | 1 | /** |
| 2 | * \addtogroup timer |
| 3 | * @{ |
| 4 | */ |
| 5 | |
| 6 | /** |
| 7 | * \file |
| 8 | * Timer library header file. |
| 9 | * \author |
| 10 | * Adam Dunkels <adam@sics.se> |
| 11 | */ |
| 12 | |
adamdunkels | a2f3c42 | 2004-09-12 20:24:53 +0000 | [diff] [blame] | 13 | /* |
| 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 | * |
adamdunkels | 0278435 | 2005-02-07 22:45:14 +0000 | [diff] [blame] | 45 | * $Id: timer.h,v 1.4 2005/02/07 22:45:15 adamdunkels Exp $ |
adamdunkels | a2f3c42 | 2004-09-12 20:24:53 +0000 | [diff] [blame] | 46 | */ |
adamdunkels | d106ecc | 2004-06-06 06:09:31 +0000 | [diff] [blame] | 47 | #ifndef __TIMER_H__ |
| 48 | #define __TIMER_H__ |
| 49 | |
| 50 | #include "clock.h" |
| 51 | |
adamdunkels | 0278435 | 2005-02-07 22:45:14 +0000 | [diff] [blame] | 52 | /** |
| 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 | */ |
adamdunkels | d106ecc | 2004-06-06 06:09:31 +0000 | [diff] [blame] | 60 | struct timer { |
adamdunkels | 123ab1c | 2004-09-01 19:05:21 +0000 | [diff] [blame] | 61 | clock_time_t start; |
adamdunkels | d106ecc | 2004-06-06 06:09:31 +0000 | [diff] [blame] | 62 | clock_time_t interval; |
| 63 | }; |
| 64 | |
| 65 | void timer_set(struct timer *t, clock_time_t interval); |
| 66 | void timer_reset(struct timer *t); |
adamdunkels | 0278435 | 2005-02-07 22:45:14 +0000 | [diff] [blame] | 67 | void timer_restart(struct timer *t); |
adamdunkels | d106ecc | 2004-06-06 06:09:31 +0000 | [diff] [blame] | 68 | int timer_expired(struct timer *t); |
| 69 | |
| 70 | #endif /* __TIMER_H__ */ |