VSF Documented
event_groups.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2026 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18// Clean-room FreeRTOS event_groups.h shim for VSF.
19//
20// Backed by vsf_bmpevt_t (VSF_KERNEL_CFG_SUPPORT_BITMAP_EVENT). Each event
21// group is a 32-bit bitmap; FreeRTOS documents EventBits_t as 24 bits when
22// configUSE_16_BIT_TICKS is 0 with the top 8 reserved for the kernel, but
23// this shim exposes the full 32-bit width since VSF owns the bitmap.
24//
25// Subset covered (MVP):
26// xEventGroupCreate / vEventGroupDelete
27// xEventGroupSetBits / xEventGroupClearBits / xEventGroupGetBits
28// xEventGroupSetBitsFromISR / xEventGroupClearBitsFromISR
29// xEventGroupWaitBits (AND / OR, with optional clear-on-exit)
30//
31// Not covered yet: xEventGroupSync, static allocation, EventGroupHandle_t
32// pending the timer-task deferral that FreeRTOS uses for FromISR paths.
33
34#ifndef __VSF_FREERTOS_EVENT_GROUPS_H__
35#define __VSF_FREERTOS_EVENT_GROUPS_H__
36
37#include "FreeRTOS.h"
38
39#if defined(__VSF_FREERTOS_EVENT_GROUPS_CLASS_IMPLEMENT)
40# undef __VSF_FREERTOS_EVENT_GROUPS_CLASS_IMPLEMENT
41# define __VSF_CLASS_IMPLEMENT__
42#endif
43
44#include "utilities/ooc_class.h"
45
46#ifdef __cplusplus
47extern "C" {
48#endif
49
50/*============================ TYPES =========================================*/
51
53
54// Forward-declared vsf_class. Layout is computed by PLOOC from the
55// private_member list below so the public view carries the correct
56// size/alignment while all fields remain inaccessible to consumers.
59
61 private_member(
62 vsf_bmpevt_t bmp;
63 bool is_static;
64 )
65};
66
67/*============================ PROTOTYPES ====================================*/
68
69// Allocate an event group with all bits cleared. NULL on heap exhaustion.
71
72// Zero-heap variant. The caller owns the buffer; vEventGroupDelete
73// will cancel waiters but will NOT release the storage.
75 StaticEventGroup_t *pxEventGroupBuffer);
76
77// Free an event group. Waiters are cancelled before storage is released.
78extern void vEventGroupDelete(EventGroupHandle_t xEventGroup);
79
80// Atomically set bits and return the bits in the group after the set
81// operation. Pending waiters whose criteria are met are released.
83 const EventBits_t uxBitsToSet);
84
85// ISR-safe variant. FreeRTOS internally defers set to the timer task so it
86// can run from a hard ISR; this shim forwards directly to the set routine
87// (which already performs its own protect-region locking). The
88// pxHigherPriorityTaskWoken output is informational best-effort.
89// Returns pdPASS on success, pdFAIL on invalid args.
91 const EventBits_t uxBitsToSet,
92 BaseType_t *pxHigherPriorityTaskWoken);
93
94// Clear bits and return the bits in the group BEFORE the clear operation.
96 const EventBits_t uxBitsToClear);
97
98// ISR-safe clear. FreeRTOS defers this to the timer task; we forward it
99// directly because vsf_eda_bmpevt_reset is already protect-region safe.
100// Returns pdPASS on success, pdFAIL on invalid args.
102 const EventBits_t uxBitsToClear);
103
104// Read-only sample of the current bits without blocking.
107
108// Wait for bits. If xWaitForAllBits == pdTRUE the caller blocks until ALL
109// requested bits are set; otherwise any single requested bit suffices.
110// Returns the bits snapshot at the time the wait completes (or on timeout).
111// If xClearOnExit == pdTRUE the matched bits are cleared atomically on
112// successful return. 0 ticks implies non-blocking poll.
114 const EventBits_t uxBitsToWaitFor,
115 const BaseType_t xClearOnExit,
116 const BaseType_t xWaitForAllBits,
117 TickType_t xTicksToWait);
118
119#ifdef __cplusplus
120}
121#endif
122
123#endif // __VSF_FREERTOS_EVENT_GROUPS_H__
Definition event_groups.h:60
Definition vsf_eda.h:960
long BaseType_t
Definition esp_ringbuf.h:50
EventGroupHandle_t xEventGroupCreate(void)
Definition freertos_event_groups_port.c:92
EventBits_t xEventGroupWaitBits(EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToWaitFor, const BaseType_t xClearOnExit, const BaseType_t xWaitForAllBits, TickType_t xTicksToWait)
Definition freertos_event_groups_port.c:194
EventBits_t xEventGroupGetBits(EventGroupHandle_t xEventGroup)
Definition freertos_event_groups_port.c:181
void vEventGroupDelete(EventGroupHandle_t xEventGroup)
Definition freertos_event_groups_port.c:112
EventBits_t xEventGroupClearBits(EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear)
Definition freertos_event_groups_port.c:158
uint32_t EventBits_t
Definition event_groups.h:52
EventBits_t xEventGroupSetBits(EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet)
Definition freertos_event_groups_port.c:126
EventGroupHandle_t xEventGroupCreateStatic(StaticEventGroup_t *pxEventGroupBuffer)
Definition freertos_event_groups_port.c:102
BaseType_t xEventGroupClearBitsFromISR(EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear)
Definition freertos_event_groups_port.c:171
EventBits_t xEventGroupGetBitsFromISR(EventGroupHandle_t xEventGroup)
Definition freertos_event_groups_port.c:189
BaseType_t xEventGroupSetBitsFromISR(EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, BaseType_t *pxHigherPriorityTaskWoken)
Definition freertos_event_groups_port.c:139
#define vsf_dcl_class
Definition ooc_class.h:50
#define vsf_class(__name)
Definition ooc_class.h:52
uint32_t TickType_t
Definition rtos_al.h:59
unsigned uint32_t
Definition stdint.h:9
Generated from commit: vsfteam/vsf@015f4d1