1 |
606 |
jeremybenn |
/** \addtogroup sys
|
2 |
|
|
* @{
|
3 |
|
|
*/
|
4 |
|
|
|
5 |
|
|
/**
|
6 |
|
|
* \defgroup clock Clock library
|
7 |
|
|
*
|
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.
|
13 |
|
|
*
|
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.
|
17 |
|
|
*
|
18 |
|
|
* \sa \ref timer "Timer library"
|
19 |
|
|
* \sa \ref etimer "Event timers"
|
20 |
|
|
*
|
21 |
|
|
* @{
|
22 |
|
|
*/
|
23 |
|
|
|
24 |
|
|
/*
|
25 |
|
|
* Copyright (c) 2004, Swedish Institute of Computer Science.
|
26 |
|
|
* All rights reserved.
|
27 |
|
|
*
|
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.
|
39 |
|
|
*
|
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.
|
51 |
|
|
*
|
52 |
|
|
* This file is part of the Contiki operating system.
|
53 |
|
|
*
|
54 |
|
|
* Author: Adam Dunkels <adam@sics.se>
|
55 |
|
|
*
|
56 |
|
|
* $Id: clock.h 2 2011-07-17 20:13:17Z filepang@gmail.com $
|
57 |
|
|
*/
|
58 |
|
|
#ifndef __CLOCK_H__
|
59 |
|
|
#define __CLOCK_H__
|
60 |
|
|
|
61 |
|
|
#include "net/clock-arch.h"
|
62 |
|
|
|
63 |
|
|
//_RB_#include "contiki-conf.h"
|
64 |
|
|
#if 0 /* XXX problems with signedness and use in timer_expired(). #if:ed it out for now. */
|
65 |
|
|
|
66 |
|
|
/**
|
67 |
|
|
* Check if a clock time value is less than another clock time value.
|
68 |
|
|
*
|
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.
|
72 |
|
|
*
|
73 |
|
|
*/
|
74 |
|
|
#define CLOCK_LT( a, b ) ( (clock_time_t) ((a) - (b)) < ((clock_time_t) (~((clock_time_t) 0)) >> 1) )
|
75 |
|
|
#endif /* 0 */
|
76 |
|
|
|
77 |
|
|
/**
|
78 |
|
|
* Initialize the clock library.
|
79 |
|
|
*
|
80 |
|
|
* This function initializes the clock library and should be called
|
81 |
|
|
* from the main() function of the system.
|
82 |
|
|
*
|
83 |
|
|
*/
|
84 |
|
|
void clock_init( void );
|
85 |
|
|
|
86 |
|
|
/**
|
87 |
|
|
* Get the current clock time.
|
88 |
|
|
*
|
89 |
|
|
* This function returns the current system clock time.
|
90 |
|
|
*
|
91 |
|
|
* \return The current clock time, measured in system ticks.
|
92 |
|
|
*/
|
93 |
|
|
CCIF clock_time_t clock_time( void );
|
94 |
|
|
|
95 |
|
|
void clock_delay( unsigned int );
|
96 |
|
|
|
97 |
|
|
/**
|
98 |
|
|
* A second, measured in system clock time.
|
99 |
|
|
*
|
100 |
|
|
* \hideinitializer
|
101 |
|
|
*/
|
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 );
|
109 |
|
|
|
110 |
|
|
CCIF unsigned long clock_seconds( void );
|
111 |
|
|
#endif /* __CLOCK_H__ */
|
112 |
|
|
|
113 |
|
|
/** @} */
|
114 |
|
|
|
115 |
|
|
/** @} */
|