oveRTOS C API
Embedded RTOS framework — build system, configuration, and portable C API
Loading...
Searching...
No Matches
eventgroup.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2026 Kamil Lulko <kamil.lulko@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 *
6 * This file is part of oveRTOS.
7 */
8
30#ifndef OVE_EVENTGROUP_H
31#define OVE_EVENTGROUP_H
32
33#include "ove/types.h"
34#include "ove_config.h"
35#include "ove/storage.h"
36#include "ove/time.h"
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
49#define OVE_EG_WAIT_ALL 0x01
50
59#define OVE_EG_CLEAR_ON_EXIT 0x02
60
61#ifdef CONFIG_OVE_EVENTGROUP
62
74int ove_eventgroup_init(ove_eventgroup_t *eg, ove_eventgroup_storage_t *storage);
75
86
96#ifdef OVE_HEAP_EVENTGROUP
98
109#endif /* OVE_HEAP_EVENTGROUP */
110
125
139
162 uint64_t timeout_ns, ove_eventbits_t *result);
163
184 uint32_t flags, uint64_t deadline_ns,
185 ove_eventbits_t *result)
186{
187 return ove_eventgroup_wait_bits(eg, bits, flags,
188 ove_time_deadline_to_timeout_ns(deadline_ns), result);
189}
190
204
215
221
222#else /* !CONFIG_OVE_EVENTGROUP */
223
224/* P0-3: _init/_deinit stubs so OVE_EVENTGROUP_DEFINE_STATIC links cleanly
225 * when CONFIG_OVE_EVENTGROUP=n. */
226static inline int ove_eventgroup_init(ove_eventgroup_t *eg, ove_eventgroup_storage_t *s)
227{
228 (void)eg;
229 (void)s;
231}
232static inline void ove_eventgroup_deinit(ove_eventgroup_t eg)
233{
234 (void)eg;
235}
236
237static inline int ove_eventgroup_create(ove_eventgroup_t *eg)
238{
239 (void)eg;
241}
242static inline void ove_eventgroup_destroy(ove_eventgroup_t eg)
243{
244 (void)eg;
245}
247{
248 (void)eg;
249 (void)bits;
250 return 0;
251}
253{
254 (void)eg;
255 (void)bits;
256 return 0;
257}
259 uint32_t flags, uint64_t timeout_ns,
260 ove_eventbits_t *result)
261{
262 (void)eg;
263 (void)bits;
264 (void)flags;
265 (void)timeout_ns;
266 (void)result;
268}
270 ove_eventbits_t bits)
271{
272 (void)eg;
273 (void)bits;
274 return 0;
275}
277{
278 (void)eg;
279 return 0;
280}
281static inline int ove_eventgroup_set_notify(ove_eventgroup_t eg, ove_notify_cb cb, void *ud)
282{
283 (void)eg;
284 (void)cb;
285 (void)ud;
287}
288
289#endif /* CONFIG_OVE_EVENTGROUP */
290
291#ifdef __cplusplus
292}
293#endif
294
/* end of ove_eventgroup group */
296
297#endif /* OVE_EVENTGROUP_H */
int ove_eventgroup_wait_bits(ove_eventgroup_t eg, ove_eventbits_t bits, uint32_t flags, uint64_t timeout_ns, ove_eventbits_t *result)
Block until one or all of the requested bits are set.
ove_eventbits_t ove_eventgroup_set_bits_from_isr(ove_eventgroup_t eg, ove_eventbits_t bits)
Set bits in the event group from an ISR.
static int ove_eventgroup_wait_bits_until(ove_eventgroup_t eg, ove_eventbits_t bits, uint32_t flags, uint64_t deadline_ns, ove_eventbits_t *result)
Deadline-based variant of ove_eventgroup_wait_bits.
Definition eventgroup.h:183
void ove_eventgroup_deinit(ove_eventgroup_t eg)
Deinitialise a statically-allocated event group.
void ove_eventgroup_destroy(ove_eventgroup_t eg)
Destroy a heap-allocated event group.
ove_eventbits_t ove_eventgroup_clear_bits(ove_eventgroup_t eg, ove_eventbits_t bits)
Clear one or more bits in the event group.
ove_eventbits_t ove_eventgroup_get_bits(ove_eventgroup_t eg)
Read the current bit value of the event group without blocking.
int ove_eventgroup_init(ove_eventgroup_t *eg, ove_eventgroup_storage_t *storage)
Initialise an event group using caller-provided static storage.
int ove_eventgroup_create(ove_eventgroup_t *eg)
Allocate and initialise a heap-backed event group.
int ove_eventgroup_set_notify(ove_eventgroup_t eg, ove_notify_cb cb, void *user_data)
Register a notify callback fired after every successful set of one or more bits. See set_notify famil...
ove_eventbits_t ove_eventgroup_set_bits(ove_eventgroup_t eg, ove_eventbits_t bits)
Set one or more bits in the event group from task context.
static uint64_t ove_time_deadline_to_timeout_ns(uint64_t deadline_ns)
Convert a steady-clock deadline to a duration suitable for the existing timeout_ns-taking APIs.
Definition time.h:162
struct ove_eventgroup * ove_eventgroup_t
Opaque handle for an event-group (bit-field) object.
Definition types.h:223
uint32_t ove_eventbits_t
Bit-mask type used by the event-group API.
Definition types.h:279
void(* ove_notify_cb)(void *user_data)
Notify-callback signature used by the _set_notify variants of the comm primitives (stream / queue / e...
Definition types.h:298
@ OVE_ERR_NOT_SUPPORTED
Definition types.h:98