FreeRTOS C++ Wrappers  1.6.0
C++ interface to FreeRTOS
event_groups.hpp
Go to the documentation of this file.
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 #ifndef EVENT_GROUPS_HPP_
39 #define EVENT_GROUPS_HPP_
40 
48 #ifndef CPP_FREERTOS_NO_EXCEPTIONS
49 #include <exception>
50 #include <string>
51 #include <cstdio>
52 #ifdef CPP_FREERTOS_NO_CPP_STRINGS
53 #error "FreeRTOS-Addons require C++ Strings if you are using exceptions"
54 #endif
55 #endif
56 #include "FreeRTOS.h"
57 #include "event_groups.h"
58 
59 
60 namespace cpp_freertos {
61 
62 
63 #ifndef CPP_FREERTOS_NO_EXCEPTIONS
64 
67 class EventGroupCreateException : public std::exception {
68 
69  public:
74  {
75  sprintf(errorString, "Event Group Constructor Failed");
76  }
77 
81  explicit EventGroupCreateException(const char *info)
82  {
83  snprintf(errorString, sizeof(errorString),
84  "Event Group Constructor Failed %s", info);
85  }
86 
91  virtual const char *what() const throw()
92  {
93  return errorString;
94  }
95 
96  private:
100  char errorString[80];
101 };
102 #endif
103 
104 
108 class EventGroup {
109 
111  //
112  // Public API
113  //
115  public:
116 
120  EventGroup();
121 
122 #if( configSUPPORT_STATIC_ALLOCATION == 1 )
123 
126  EventGroup(StaticEventGroup_t *pxEventGroupBuffer);
127 #endif
128 
150  EventBits_t Sync( const EventBits_t uxBitsToSet,
151  const EventBits_t uxBitsToWaitFor,
152  TickType_t xTicksToWait);
153 
205  EventBits_t WaitBits( const EventBits_t uxBitsToWaitFor,
206  bool xClearOnExit,
207  bool xWaitForAllBits,
208  TickType_t xTicksToWait);
209 
219  EventBits_t ClearBits(const EventBits_t uxBitsToClear);
220 
230  BaseType_t ClearBitsFromISR(const EventBits_t uxBitsToClear);
231 
239  EventBits_t GetBits();
240 
248  EventBits_t GetBitsFromISR();
249 
259  EventBits_t SetBits(const EventBits_t uxBitsToSet);
260 
261 
262  #if ( ( configUSE_TRACE_FACILITY == 1 ) && ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 1 ) )
263 
281  BaseType_t SetBitsFromISR( const EventBits_t uxBitsToSet,
282  BaseType_t *pxHigherPriorityTaskWoken);
283 
284  #endif
285 
289  virtual ~EventGroup();
290 
292  //
293  // Protected API
294  // Not intended for use by application code.
295  //
297  protected:
301  EventGroupHandle_t handle;
302 
303 };
304 
305 }
306 
307 #endif
EventGroupHandle_t handle
virtual const char * what() const