Loading...
Searching...
No Matches
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
10#pragma once
11
42
43#include <stdint.h>
44#include "modules.h"
45
46#include "ztimer.h"
47
48#ifdef __cplusplus
49extern "C" {
50#endif
51
55typedef struct evtimer_event {
57 uint32_t offset;
59
64
75
87
95
103
109void evtimer_print(const evtimer_t *evtimer);
110
114static inline uint32_t evtimer_now_msec(void)
115{
116 return ztimer_now(ZTIMER_MSEC);
117}
118
119#ifdef __cplusplus
120}
121#endif
122
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:63
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:114
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:683
ztimer_clock_t *const ZTIMER_MSEC
Default ztimer millisecond clock.
Common macros and compiler attributes/pragmas configuration.
event structure
Definition event.h:145
Generic event.
Definition evtimer.h:55
uint32_t offset
offset in milliseconds from previous event
Definition evtimer.h:57
struct evtimer_event * next
the next event in the queue
Definition evtimer.h:56
Event timer.
Definition evtimer.h:68
uint32_t base
Absolute time the first event is built on.
Definition evtimer.h:70
evtimer_callback_t callback
Handler function for this evtimer's event type.
Definition evtimer.h:71
ztimer_t timer
Timer.
Definition evtimer.h:69
evtimer_event_t * events
Event queue.
Definition evtimer.h:73
ztimer structure
Definition ztimer.h:319
ztimer API