FreeRTOS Addons
Loading...
Searching...
No Matches
event_groups.hpp
1/****************************************************************************
2 *
3 * Copyright (c) 2017, Danilo Pucci Smokovitz (dnlps@hotmail.com)
4 *
5 * This file is part of the FreeRTOS Add-ons project.
6 *
7 * Source Code:
8 * https://github.com/michaelbecker/freertos-addons
9 *
10 * Project Page:
11 * http://michaelbecker.github.io/freertos-addons/
12 *
13 * On-line Documentation:
14 * http://michaelbecker.github.io/freertos-addons/docs/html/index.html
15 *
16 * Permission is hereby granted, free of charge, to any person obtaining a
17 * copy of this software and associated documentation files
18 * (the "Software"), to deal in the Software without restriction, including
19 * without limitation the rights to use, copy, modify, merge, publish,
20 * distribute, sublicense, and/or sell copies of the Software, and to
21 * permit persons to whom the Software is furnished to do so,subject to the
22 * following conditions:
23 *
24 * + The above copyright notice and this permission notice shall be included
25 * in all copies or substantial portions of the Software.
26 * + Credit is appreciated, but not required, if you find this project
27 * useful enough to include in your application, product, device, etc.
28 *
29 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
30 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
31 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
32 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
33 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
34 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
35 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36 *
37 ***************************************************************************/
38#include "freertos-config.h"
39
40#ifndef EVENT_GROUPS_HPP_
41#define EVENT_GROUPS_HPP_
42
50#ifndef CPP_FREERTOS_NO_EXCEPTIONS
51#include <exception>
52#include <string>
53#include <cstdio>
54#ifdef CPP_FREERTOS_NO_CPP_STRINGS
55#error "FreeRTOS-Addons require C++ Strings if you are using exceptions"
56#endif
57#endif
58#include "FreeRTOS.h"
59#include "event_groups.h"
60
61
62namespace cpp_freertos {
63
64
65#ifndef CPP_FREERTOS_NO_EXCEPTIONS
69class EventGroupCreateException : public std::exception {
70
71 public:
76 {
77 sprintf(errorString, "Event Group Constructor Failed");
78 }
79
83 explicit EventGroupCreateException(const char *info)
84 {
85 snprintf(errorString, sizeof(errorString),
86 "Event Group Constructor Failed %s", info);
87 }
88
93 virtual const char *what() const throw()
94 {
95 return errorString;
96 }
97
98 private:
102 char errorString[80];
103};
104#endif
105
106
111
113 //
114 // Public API
115 //
117 public:
118
122 EventGroup();
123
124#if( configSUPPORT_STATIC_ALLOCATION == 1 )
128 EventGroup(StaticEventGroup_t *pxEventGroupBuffer);
129#endif
152 EventBits_t Sync( const EventBits_t uxBitsToSet,
153 const EventBits_t uxBitsToWaitFor,
154 TickType_t xTicksToWait);
155
207 EventBits_t WaitBits( const EventBits_t uxBitsToWaitFor,
208 bool xClearOnExit,
209 bool xWaitForAllBits,
210 TickType_t xTicksToWait);
211
221 EventBits_t ClearBits(const EventBits_t uxBitsToClear);
222
232 BaseType_t ClearBitsFromISR(const EventBits_t uxBitsToClear);
233
241 EventBits_t GetBits();
242
250 EventBits_t GetBitsFromISR();
251
261 EventBits_t SetBits(const EventBits_t uxBitsToSet);
262
263
264 #if ( ( configUSE_TRACE_FACILITY == 1 ) && ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 1 ) )
283 BaseType_t SetBitsFromISR( const EventBits_t uxBitsToSet,
284 BaseType_t *pxHigherPriorityTaskWoken);
285
286 #endif
287
291 virtual ~EventGroup();
292
294 //
295 // Protected API
296 // Not intended for use by application code.
297 //
299 protected:
303 EventGroupHandle_t handle;
304
305};
306
307}
308
309#endif
Definition: event_groups.hpp:69
EventGroupCreateException(const char *info)
Definition: event_groups.hpp:83
EventGroupCreateException()
Definition: event_groups.hpp:75
virtual const char * what() const
Definition: event_groups.hpp:93
Definition: event_groups.hpp:110
EventBits_t GetBitsFromISR()
Definition: cevent_groups.cpp:128
EventBits_t GetBits()
Definition: cevent_groups.cpp:122
EventBits_t Sync(const EventBits_t uxBitsToSet, const EventBits_t uxBitsToWaitFor, TickType_t xTicksToWait)
Definition: cevent_groups.cpp:83
EventBits_t SetBits(const EventBits_t uxBitsToSet)
Definition: cevent_groups.cpp:134
EventBits_t ClearBits(const EventBits_t uxBitsToClear)
Definition: cevent_groups.cpp:110
EventGroup()
Definition: cevent_groups.cpp:44
BaseType_t ClearBitsFromISR(const EventBits_t uxBitsToClear)
Definition: cevent_groups.cpp:116
BaseType_t SetBitsFromISR(const EventBits_t uxBitsToSet, BaseType_t *pxHigherPriorityTaskWoken)
Definition: cevent_groups.cpp:142
EventGroupHandle_t handle
Definition: event_groups.hpp:303
EventBits_t WaitBits(const EventBits_t uxBitsToWaitFor, bool xClearOnExit, bool xWaitForAllBits, TickType_t xTicksToWait)
Definition: cevent_groups.cpp:96
virtual ~EventGroup()
Definition: cevent_groups.cpp:77
Definition: condition_variable.hpp:57