]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/Common/ethernet/FreeTCPIP/sys/clock.h
Add FreeRTOS-Plus directory.
[freertos] / FreeRTOS / Demo / Common / ethernet / FreeTCPIP / sys / clock.h
1 /** \addtogroup sys\r
2  * @{\r
3  */\r
4 \r
5 /**\r
6  * \defgroup clock Clock library\r
7  *\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
12  * time.\r
13  *\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
17  *\r
18  * \sa \ref timer "Timer library"\r
19  * \sa \ref etimer "Event timers"\r
20  *\r
21  * @{\r
22  */\r
23 \r
24 /*\r
25  * Copyright (c) 2004, Swedish Institute of Computer Science.\r
26  * All rights reserved.\r
27  *\r
28  * Redistribution and use in source and binary forms, with or without\r
29  * modification, are permitted provided that the following conditions\r
30  * are met:\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
39  *\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
50  * SUCH DAMAGE.\r
51  *\r
52  * This file is part of the Contiki operating system.\r
53  *\r
54  * Author: Adam Dunkels <adam@sics.se>\r
55  *\r
56  * $Id: clock.h,v 1.11 2009/01/24 15:20:11 adamdunkels Exp $\r
57  */\r
58 #ifndef __CLOCK_H__\r
59 #define __CLOCK_H__\r
60 \r
61 #include "net/clock-arch.h"\r
62 \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
65 \r
66 /**\r
67  * Check if a clock time value is less than another clock time value.\r
68  *\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
72  *\r
73  */\r
74 #define CLOCK_LT( a, b )        ( (clock_time_t) ((a) - (b)) < ((clock_time_t) (~((clock_time_t) 0)) >> 1) )\r
75 #endif /* 0 */\r
76 \r
77 /**\r
78  * Initialize the clock library.\r
79  *\r
80  * This function initializes the clock library and should be called\r
81  * from the main() function of the system.\r
82  *\r
83  */\r
84 void                            clock_init( void );\r
85 \r
86 /**\r
87  * Get the current clock time.\r
88  *\r
89  * This function returns the current system clock time.\r
90  *\r
91  * \return The current clock time, measured in system ticks.\r
92  */\r
93 CCIF clock_time_t       clock_time( void );\r
94 \r
95 void                            clock_delay( unsigned int );\r
96 \r
97 /**\r
98  * A second, measured in system clock time.\r
99  *\r
100  * \hideinitializer\r
101  */\r
102 #ifdef CLOCK_CONF_SECOND\r
103 #define CLOCK_SECOND    CLOCK_CONF_SECOND\r
104 #else\r
105 #define CLOCK_SECOND    ( clock_time_t ) 32\r
106 #endif\r
107 int                                     clock_fine_max( void );\r
108 unsigned short          clock_fine( void );\r
109 \r
110 CCIF unsigned long      clock_seconds( void );\r
111 #endif /* __CLOCK_H__ */\r
112 \r
113 /** @} */\r
114 \r
115 /** @} */\r