Loading...
Searching...
No Matches
periodic.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2021 Inria
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
36#ifndef EVENT_PERIODIC_H
37#define EVENT_PERIODIC_H
38
39#include "event.h"
40#include "ztimer/periodic.h"
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
49#define EVENT_PERIODIC_FOREVER 0
50
60
73 event_queue_t *queue, event_t *event);
74
89static inline void event_periodic_start(event_periodic_t *event_periodic, uint32_t interval)
90{
91 event_periodic->timer.interval = interval;
92 ztimer_periodic_start(&event_periodic->timer);
93}
94
102static inline void event_periodic_set_count(event_periodic_t *event_periodic, uint32_t count)
103{
104 unsigned state = irq_disable();
105
106 event_periodic->count = count;
107 irq_restore(state);
108}
109
124static inline void event_periodic_stop(event_periodic_t *event_periodic)
125{
126 ztimer_periodic_stop(&event_periodic->timer);
127}
128
129#ifdef __cplusplus
130}
131#endif
132#endif /* EVENT_PERIODIC_H */
static void event_periodic_stop(event_periodic_t *event_periodic)
Stop a periodic timeout event.
Definition periodic.h:124
static void event_periodic_set_count(event_periodic_t *event_periodic, uint32_t count)
Set the amount of times the periodic event should repeat itself.
Definition periodic.h:102
static void event_periodic_start(event_periodic_t *event_periodic, uint32_t interval)
Starts a periodic timeout.
Definition periodic.h:89
void event_periodic_init(event_periodic_t *event_periodic, ztimer_clock_t *clock, event_queue_t *queue, event_t *event)
Initialize a periodic event timeout.
MAYBE_INLINE void irq_restore(unsigned state)
This function restores the IRQ disable bit in the status register to the value contained within passe...
MAYBE_INLINE unsigned irq_disable(void)
This function sets the IRQ disable bit in the status register.
event queue structure
Definition event.h:156
Timeout Event structure.
Definition periodic.h:54
event_t * event
event to post after timeout
Definition periodic.h:57
event_queue_t * queue
event queue to post event to
Definition periodic.h:56
ztimer_periodic_t timer
ztimer object used for timeout
Definition periodic.h:55
uint32_t count
times the event should repeat itself
Definition periodic.h:58
event structure
Definition event.h:148
ztimer device structure
Definition ztimer.h:383
ztimer periodic structure
Definition periodic.h:94
uint32_t interval
interval of this timer
Definition periodic.h:97
Periodic ztimer API.
void ztimer_periodic_stop(ztimer_periodic_t *timer)
Stop a periodic timer.
void ztimer_periodic_start(ztimer_periodic_t *timer)
Start or restart a periodic timer.