clock.h

00001 /** \addtogroup sys
00002  * @{
00003  */
00004 
00005 /**
00006  * \defgroup clock Clock library
00007  *
00008  * The clock library is the interface between Contiki and the platform
00009  * specific clock functionality. The clock library performs a single
00010  * function: measuring time. Additionally, the clock library provides
00011  * a macro, CLOCK_SECOND, which corresponds to one second of system
00012  * time.
00013  *
00014  * \note The clock library need in many cases not be used
00015  * directly. Rather, the \ref timer "timer library" or the \ref etimer
00016  * "event timers" should be used.
00017  *
00018  * \sa \ref timer "Timer library"
00019  * \sa \ref etimer "Event timers"
00020  *
00021  * @{
00022  */
00023 
00024 /*
00025  * Copyright (c) 2004, Swedish Institute of Computer Science.
00026  * All rights reserved.
00027  *
00028  * Redistribution and use in source and binary forms, with or without
00029  * modification, are permitted provided that the following conditions
00030  * are met:
00031  * 1. Redistributions of source code must retain the above copyright
00032  *    notice, this list of conditions and the following disclaimer.
00033  * 2. Redistributions in binary form must reproduce the above copyright
00034  *    notice, this list of conditions and the following disclaimer in the
00035  *    documentation and/or other materials provided with the distribution.
00036  * 3. Neither the name of the Institute nor the names of its contributors
00037  *    may be used to endorse or promote products derived from this software
00038  *    without specific prior written permission.
00039  *
00040  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
00041  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00042  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00043  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
00044  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00045  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00046  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00047  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00048  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00049  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00050  * SUCH DAMAGE.
00051  *
00052  * This file is part of the Contiki operating system.
00053  *
00054  * Author: Adam Dunkels <adam@sics.se>
00055  *
00056  * $Id: clock.h,v 1.11 2009/01/24 15:20:11 adamdunkels Exp $
00057  */
00058 #ifndef __CLOCK_H__
00059 #define __CLOCK_H__
00060 
00061 #include "contiki-conf.h"
00062 
00063 #if 0 /* XXX problems with signedness and use in timer_expired(). #if:ed it out for now. */
00064 /**
00065  * Check if a clock time value is less than another clock time value.
00066  *
00067  * This macro checks if a clock time value is less than another clock
00068  * time value. This macro is needed to correctly handle wrap-around of
00069  * clock time values.
00070  *
00071  */
00072 #define CLOCK_LT(a, b) ((clock_time_t)((a) - (b)) < ((clock_time_t)(~((clock_time_t)0)) >> 1))
00073 #endif /* 0 */
00074 
00075 /**
00076  * Initialize the clock library.
00077  *
00078  * This function initializes the clock library and should be called
00079  * from the main() function of the system.
00080  *
00081  */
00082 void clock_init(void);
00083 
00084 /**
00085  * Get the current clock time.
00086  *
00087  * This function returns the current system clock time.
00088  *
00089  * \return The current clock time, measured in system ticks.
00090  */
00091 CCIF clock_time_t clock_time(void);
00092 
00093 void clock_delay(unsigned int);
00094 
00095 /**
00096  * A second, measured in system clock time.
00097  *
00098  * \hideinitializer
00099  */
00100 #ifdef CLOCK_CONF_SECOND
00101 #define CLOCK_SECOND CLOCK_CONF_SECOND
00102 #else
00103 #define CLOCK_SECOND (clock_time_t)32
00104 #endif
00105 
00106 int clock_fine_max(void);
00107 unsigned short clock_fine(void);
00108 
00109 CCIF unsigned long clock_seconds(void);
00110 
00111 
00112 #endif /* __CLOCK_H__ */
00113 
00114 /** @} */
00115 /** @} */

Generated on Mon Apr 11 14:23:33 2011 for Contiki 2.5 by  doxygen 1.6.1