Contiki-Inga 3.x
Main Page
Related Pages
Modules
Data Structures
Files
Examples
File List
Globals
core
sys
clock.h
1
/** \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 defines a macro,
10
* CLOCK_SECOND, to convert seconds into the tick resolution of the platform.
11
* Typically this is 1-10 milliseconds, e.g. 4*CLOCK_SECOND could be 512.
12
* A 16 bit counter would thus overflow every 1-10 minutes.
13
* Platforms use the tick interrupt to maintain a long term count
14
* of seconds since startup.
15
*
16
* Platforms may also implement rtimers for greater time resolution
17
* and for real-time interrupts, These use a corresponding RTIMER_SECOND.
18
*
19
* \note These timers do not necessarily have a common divisor or are phase locked.
20
* One may be crystal controlled and the other may not. Low power operation
21
* or sleep will often use one for wake and disable the other, then give
22
* it a tick correction after wakeup.
23
*
24
* \note The clock library need in many cases not be used
25
* directly. Rather, the \ref timer "timer library", \ref etimer
26
* "event timers", or \ref trimer "rtimer library" should be used.
27
*
28
* \sa \ref timer "Timer library"
29
* \sa \ref etimer "Event timers"
30
* \sa \ref rtimer "Realtime library"
31
*
32
* @{
33
*/
34
35
/*
36
* Copyright (c) 2004, Swedish Institute of Computer Science.
37
* All rights reserved.
38
*
39
* Redistribution and use in source and binary forms, with or without
40
* modification, are permitted provided that the following conditions
41
* are met:
42
* 1. Redistributions of source code must retain the above copyright
43
* notice, this list of conditions and the following disclaimer.
44
* 2. Redistributions in binary form must reproduce the above copyright
45
* notice, this list of conditions and the following disclaimer in the
46
* documentation and/or other materials provided with the distribution.
47
* 3. Neither the name of the Institute nor the names of its contributors
48
* may be used to endorse or promote products derived from this software
49
* without specific prior written permission.
50
*
51
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
52
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
53
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
54
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
55
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
56
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
57
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
58
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
59
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
60
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
61
* SUCH DAMAGE.
62
*
63
* This file is part of the Contiki operating system.
64
*
65
* Author: Adam Dunkels <adam@sics.se>
66
*
67
*/
68
#ifndef CLOCK_H_
69
#define CLOCK_H_
70
71
#include "contiki-conf.h"
72
73
/**
74
* A second, measured in system clock time.
75
*
76
* \hideinitializer
77
*/
78
#ifdef CLOCK_CONF_SECOND
79
#define CLOCK_SECOND CLOCK_CONF_SECOND
80
#else
81
#define CLOCK_SECOND (clock_time_t)32
82
#endif
83
84
/**
85
* Initialize the clock library.
86
*
87
* This function initializes the clock library and should be called
88
* from the main() function of the system.
89
*
90
*/
91
void
clock_init
(
void
);
92
93
/**
94
* Get the current clock time.
95
*
96
* This function returns the current system clock time.
97
*
98
* \return The current clock time, measured in system ticks.
99
*/
100
CCIF
clock_time_t
clock_time
(
void
);
101
102
/**
103
* Get the current value of the platform seconds.
104
*
105
* This could be the number of seconds since startup, or
106
* since a standard epoch.
107
*
108
* \return The value.
109
*/
110
CCIF
unsigned
long
clock_seconds
(
void
);
111
112
/**
113
* Set the value of the platform seconds.
114
* \param sec The value to set.
115
*
116
*/
117
void
clock_set_seconds
(
unsigned
long
sec);
118
119
/**
120
* Wait for a given number of ticks.
121
* \param t How many ticks.
122
*
123
*/
124
void
clock_wait
(clock_time_t t);
125
126
/**
127
* Delay a given number of microseconds.
128
* \param dt How many microseconds to delay.
129
*
130
* \note Interrupts could increase the delay by a variable amount.
131
*/
132
void
clock_delay_usec
(uint16_t dt);
133
134
/**
135
* Deprecated platform-specific routines.
136
*
137
*/
138
int
clock_fine_max
(
void
);
139
unsigned
short
clock_fine(
void
);
140
void
clock_delay
(
unsigned
int
delay);
141
142
#endif
/* CLOCK_H_ */
143
144
/** @} */
145
/** @} */
Generated on Thu Apr 24 2014 16:26:13 for Contiki-Inga 3.x by
1.8.3.1