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