evtimer.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016-17 Kaspar Schleiser <kaspar@schleiser.de>
3  * 2017 Freie Universit├Ąt Berlin
4  *
5  * This file is subject to the terms and conditions of the GNU Lesser
6  * General Public License v2.1. See the file LICENSE in the top level
7  * directory for more details.
8  */
9 
43 #ifndef EVTIMER_H
44 #define EVTIMER_H
45 
46 #include <stdint.h>
47 
48 #include "xtimer.h"
49 #include "timex.h"
50 
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54 
58 typedef struct evtimer_event {
59  struct evtimer_event *next;
60  uint32_t offset;
62 
67 
71 typedef struct {
76 } evtimer_t;
77 
84 void evtimer_init(evtimer_t *evtimer, evtimer_callback_t handler);
85 
93 
100 void evtimer_del(evtimer_t *evtimer, evtimer_event_t *event);
101 
107 void evtimer_print(const evtimer_t *evtimer);
108 
112 static inline uint32_t evtimer_now_msec(void)
113 {
114  return xtimer_now_usec64() / US_PER_MS;
115 }
116 
120 static inline uint32_t evtimer_now_min(void)
121 {
123 }
124 
125 #ifdef __cplusplus
126 }
127 #endif
128 
129 #endif /* EVTIMER_H */
130 
void evtimer_init(evtimer_t *evtimer, evtimer_callback_t handler)
Initializes an event timer.
static uint64_t xtimer_now_usec64(void)
get the current system time in microseconds since start
#define SEC_PER_MIN
The number of seconds per minute.
Definition: timex.h:39
void evtimer_del(evtimer_t *evtimer, evtimer_event_t *event)
Removes an event from an event timer.
void evtimer_add(evtimer_t *evtimer, evtimer_event_t *event)
Adds event to an event timer.
event structure
Definition: event.h:139
xtimer_t timer
Timer.
Definition: evtimer.h:72
struct evtimer_event * next
the next event in the queue
Definition: evtimer.h:59
uint32_t offset
offset in milliseconds from previous event
Definition: evtimer.h:60
static uint32_t evtimer_now_msec(void)
Return the current system time in msec.
Definition: evtimer.h:112
void evtimer_print(const evtimer_t *evtimer)
Print overview of current state of an event timer.
Utility library for comparing and computing timestamps.
evtimer_event_t * events
Event queue.
Definition: evtimer.h:75
Event timer.
Definition: evtimer.h:71
xtimer interface definitions
struct evtimer_event evtimer_event_t
Generic event.
evtimer_callback_t callback
Handler function for this evtimer&#39;s event type.
Definition: evtimer.h:73
static uint32_t evtimer_now_min(void)
Return the current system time in minutes.
Definition: evtimer.h:120
#define US_PER_SEC
The number of microseconds per second.
Definition: timex.h:34
xtimer timer structure
Definition: xtimer.h:81
#define US_PER_MS
The number of microseconds per millisecond.
Definition: timex.h:54
void(* evtimer_callback_t)(evtimer_event_t *event)
Event timer callback type.
Definition: evtimer.h:66
Generic event.
Definition: evtimer.h:58