upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
timer.h
1 /**************************************************************************
2 *
3 * Copyright (C) 2009 Steve Karg <skarg@users.sourceforge.net>
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 *********************************************************************/
24 #ifndef TIMER_H
25 #define TIMER_H
26 
27 #include <stdbool.h>
28 #include <stdint.h>
29 #include <sys/time.h> /* for timeval */
30 
31 /* Timer Module */
32 #ifndef MAX_MILLISECOND_TIMERS
33 #define TIMER_SILENCE 0
34 #define MAX_MILLISECOND_TIMERS 1
35 #endif
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif /* __cplusplus */
40  uint32_t timeGetTime(
41  void);
42 
43  void timer_init(
44  void);
45  uint32_t timer_milliseconds(
46  unsigned index);
47  bool timer_elapsed_milliseconds(
48  unsigned index,
49  uint32_t value);
50  bool timer_elapsed_seconds(
51  unsigned index,
52  uint32_t value);
53  bool timer_elapsed_minutes(
54  unsigned index,
55  uint32_t seconds);
56  uint32_t timer_milliseconds_set(
57  unsigned index,
58  uint32_t value);
59  uint32_t timer_reset(
60  unsigned index);
61 
62 #ifdef __cplusplus
63 }
64 #endif /* __cplusplus */
65 #endif