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
41#ifndef EVTIMER_H
42#define EVTIMER_H
43
44#include <stdint.h>
45#include "modules.h"
46
47#include "ztimer.h"
48
49#ifdef __cplusplus
50extern "C" {
51#endif
52
56typedef struct evtimer_event {
58 uint32_t offset;
60
65
69typedef struct {
71 uint32_t base;
75} evtimer_t;
76
88
96
104
110void evtimer_print(const evtimer_t *evtimer);
111
115static inline uint32_t evtimer_now_msec(void)
116{
117 return ztimer_now(ZTIMER_MSEC);
118}
119
120#ifdef __cplusplus
121}
122#endif
123
124#endif /* EVTIMER_H */
struct evtimer_event evtimer_event_t
Generic event.
void evtimer_print(const evtimer_t *evtimer)
Print overview of current state of an event timer.
void evtimer_init(evtimer_t *evtimer, evtimer_callback_t handler)
Initializes an event timer.
void(* evtimer_callback_t)(evtimer_event_t *event)
Event timer callback type.
Definition: evtimer.h:64
void evtimer_del(evtimer_t *evtimer, evtimer_event_t *event)
Removes an event from an event timer.
static uint32_t evtimer_now_msec(void)
Return the current system time in msec.
Definition: evtimer.h:115
void evtimer_add(evtimer_t *evtimer, evtimer_event_t *event)
Adds event to an event timer.
static ztimer_now_t ztimer_now(ztimer_clock_t *clock)
Get the current time from a clock.
Definition: ztimer.h:680
ztimer_clock_t *const ZTIMER_MSEC
Default ztimer millisecond clock.
Common macros and compiler attributes/pragmas configuration.
event structure
Definition: event.h:148
Generic event.
Definition: evtimer.h:56
uint32_t offset
offset in milliseconds from previous event
Definition: evtimer.h:58
struct evtimer_event * next
the next event in the queue
Definition: evtimer.h:57
Event timer.
Definition: evtimer.h:69
uint32_t base
Absolute time the first event is built on.
Definition: evtimer.h:71
evtimer_callback_t callback
Handler function for this evtimer's event type.
Definition: evtimer.h:72
ztimer_t timer
Timer.
Definition: evtimer.h:70
evtimer_event_t * events
Event queue.
Definition: evtimer.h:74
ztimer structure
Definition: ztimer.h:332
ztimer API