Contiki 2.6

stimer.h

Go to the documentation of this file.
00001 /** \addtogroup sys
00002  * @{ */
00003 
00004 /**
00005  * \defgroup stimer Seconds timer library
00006  *
00007  * The stimer library provides functions for setting, resetting and
00008  * restarting timers, and for checking if a timer has expired. An
00009  * application must "manually" check if its timers have expired; this
00010  * is not done automatically.
00011  *
00012  * A timer is declared as a \c struct \c stimer and all access to the
00013  * timer is made by a pointer to the declared timer.
00014  *
00015  * \note The stimer library is not able to post events when a timer
00016  * expires. The \ref etimer "Event timers" should be used for this
00017  * purpose.
00018  *
00019  * \note The stimer library uses the \ref clock "Clock library" to
00020  * measure time. Intervals should be specified in the seconds.
00021  *
00022  * \sa \ref etimer "Event timers"
00023  *
00024  * @{
00025  */
00026 
00027 
00028 /**
00029  * \file
00030  * Second timer library header file.
00031  * \author
00032  * Adam Dunkels <adam@sics.se>, Nicolas Tsiftes <nvt@sics.se>
00033  */
00034 
00035 /*
00036  * Copyright (c) 2004, 2008, Swedish Institute of Computer Science.
00037  * All rights reserved.
00038  *
00039  * Redistribution and use in source and binary forms, with or without
00040  * modification, are permitted provided that the following conditions
00041  * are met:
00042  * 1. Redistributions of source code must retain the above copyright
00043  *    notice, this list of conditions and the following disclaimer.
00044  * 2. Redistributions in binary form must reproduce the above copyright
00045  *    notice, this list of conditions and the following disclaimer in the
00046  *    documentation and/or other materials provided with the distribution.
00047  * 3. Neither the name of the Institute nor the names of its contributors
00048  *    may be used to endorse or promote products derived from this software
00049  *    without specific prior written permission.
00050  *
00051  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
00052  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00053  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00054  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
00055  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00056  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00057  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00058  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00059  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00060  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00061  * SUCH DAMAGE.
00062  *
00063  * This file is part of the Contiki operating system.
00064  *
00065  * Author: Adam Dunkels <adam@sics.se>, Nicolas Tsiftes <nvt@sics.se>
00066  *
00067  * $Id: stimer.h,v 1.4 2010/03/15 15:53:57 joxe Exp $
00068  */
00069 #ifndef __STIMER_H__
00070 #define __STIMER_H__
00071 
00072 #include "sys/clock.h"
00073 
00074 /**
00075  * A timer.
00076  *
00077  * This structure is used for declaring a timer. The timer must be set
00078  * with stimer_set() before it can be used.
00079  *
00080  * \hideinitializer
00081  */
00082 struct stimer {
00083   unsigned long start;
00084   unsigned long interval;
00085 };
00086 
00087 void stimer_set(struct stimer *t, unsigned long interval);
00088 void stimer_reset(struct stimer *t);
00089 void stimer_restart(struct stimer *t);
00090 int stimer_expired(struct stimer *t);
00091 unsigned long stimer_remaining(struct stimer *t);
00092 unsigned long stimer_elapsed(struct stimer *t);
00093 
00094 
00095 #endif /* __STIMER_H__ */
00096 
00097 /** @} */
00098 /** @} */