6 * \defgroup clock Clock library
\r
8 * The clock library is the interface between Contiki and the platform
\r
9 * specific clock functionality. The clock library performs a single
\r
10 * function: measuring time. Additionally, the clock library provides
\r
11 * a macro, CLOCK_SECOND, which corresponds to one second of system
\r
14 * \note The clock library need in many cases not be used
\r
15 * directly. Rather, the \ref timer "timer library" or the \ref etimer
\r
16 * "event timers" should be used.
\r
18 * \sa \ref timer "Timer library"
\r
19 * \sa \ref etimer "Event timers"
\r
25 * Copyright (c) 2004, Swedish Institute of Computer Science.
\r
26 * All rights reserved.
\r
28 * Redistribution and use in source and binary forms, with or without
\r
29 * modification, are permitted provided that the following conditions
\r
31 * 1. Redistributions of source code must retain the above copyright
\r
32 * notice, this list of conditions and the following disclaimer.
\r
33 * 2. Redistributions in binary form must reproduce the above copyright
\r
34 * notice, this list of conditions and the following disclaimer in the
\r
35 * documentation and/or other materials provided with the distribution.
\r
36 * 3. Neither the name of the Institute nor the names of its contributors
\r
37 * may be used to endorse or promote products derived from this software
\r
38 * without specific prior written permission.
\r
40 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
\r
41 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
\r
42 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
\r
43 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
\r
44 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
\r
45 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
\r
46 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
\r
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
\r
48 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
\r
49 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
\r
52 * This file is part of the Contiki operating system.
\r
54 * Author: Adam Dunkels <adam@sics.se>
\r
56 * $Id: clock.h,v 1.11 2009/01/24 15:20:11 adamdunkels Exp $
\r
61 #include "net/clock-arch.h"
\r
63 //_RB_#include "contiki-conf.h"
\r
64 #if 0 /* XXX problems with signedness and use in timer_expired(). #if:ed it out for now. */
\r
67 * Check if a clock time value is less than another clock time value.
\r
69 * This macro checks if a clock time value is less than another clock
\r
70 * time value. This macro is needed to correctly handle wrap-around of
\r
71 * clock time values.
\r
74 #define CLOCK_LT( a, b ) ( (clock_time_t) ((a) - (b)) < ((clock_time_t) (~((clock_time_t) 0)) >> 1) )
\r
78 * Initialize the clock library.
\r
80 * This function initializes the clock library and should be called
\r
81 * from the main() function of the system.
\r
84 void clock_init( void );
\r
87 * Get the current clock time.
\r
89 * This function returns the current system clock time.
\r
91 * \return The current clock time, measured in system ticks.
\r
93 CCIF clock_time_t clock_time( void );
\r
95 void clock_delay( unsigned int );
\r
98 * A second, measured in system clock time.
\r
102 #ifdef CLOCK_CONF_SECOND
\r
103 #define CLOCK_SECOND CLOCK_CONF_SECOND
\r
105 #define CLOCK_SECOND ( clock_time_t ) 32
\r
107 int clock_fine_max( void );
\r
108 unsigned short clock_fine( void );
\r
110 CCIF unsigned long clock_seconds( void );
\r
111 #endif /* __CLOCK_H__ */
\r