FreeRTOS C++ Wrappers  1.6.0
C++ interface to FreeRTOS
cevent_groups.cpp
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 #include "event_groups.hpp"
39 
40 
41 using namespace cpp_freertos;
42 
43 
45 {
46  handle = xEventGroupCreate();
47 
48  if (handle == NULL) {
49 #ifndef CPP_FREERTOS_NO_EXCEPTIONS
51 #else
52  configASSERT(!"EventGroup Constructor Failed");
53 #endif
54  }
55 
56 }
57 
58 
59 #if( configSUPPORT_STATIC_ALLOCATION == 1 )
60 
61 EventGroup::EventGroup(StaticEventGroup_t *pxEventGroupBuffer)
62 {
63  handle = xEventGroupCreateStatic(pxEventGroupBuffer);
64 
65  if (handle == NULL) {
66 #ifndef CPP_FREERTOS_NO_EXCEPTIONS
68 #else
69  configASSERT(!"EventGroup Constructor Failed");
70 #endif
71  }
72 }
73 
74 #endif /* configSUPPORT_STATIC_ALLOCATION */
75 
76 
78 {
79  vEventGroupDelete(handle);
80 }
81 
82 
83 EventBits_t EventGroup::Sync( const EventBits_t uxBitsToSet,
84  const EventBits_t uxBitsToWaitFor,
85  TickType_t xTicksToWait)
86 {
87 
88  return xEventGroupSync( handle,
89  uxBitsToSet,
90  uxBitsToWaitFor,
91  xTicksToWait);
92 
93 }
94 
95 
96 EventBits_t EventGroup::WaitBits( const EventBits_t uxBitsToWaitFor,
97  bool xClearOnExit,
98  bool xWaitForAllBits,
99  TickType_t xTicksToWait)
100 {
101 
102  return xEventGroupWaitBits( handle,
103  uxBitsToWaitFor,
104  xClearOnExit ? pdTRUE : pdFALSE,
105  xWaitForAllBits ? pdTRUE : pdFALSE,
106  xTicksToWait);
107 }
108 
109 
110 EventBits_t EventGroup::ClearBits(const EventBits_t uxBitsToClear)
111 {
112  return xEventGroupClearBits(handle, uxBitsToClear);
113 }
114 
115 
116 BaseType_t EventGroup::ClearBitsFromISR(const EventBits_t uxBitsToClear)
117 {
118  return xEventGroupClearBitsFromISR(handle, uxBitsToClear);
119 }
120 
121 
122 EventBits_t EventGroup::GetBits()
123 {
124  return xEventGroupGetBits(handle);
125 }
126 
127 
129 {
130  return xEventGroupGetBitsFromISR(handle);
131 }
132 
133 
134 EventBits_t EventGroup::SetBits(const EventBits_t uxBitsToSet)
135 {
136  return xEventGroupSetBits(handle, uxBitsToSet);
137 }
138 
139 
140 #if ( ( configUSE_TRACE_FACILITY == 1 ) && ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 1 ) )
141 
142 BaseType_t EventGroup::SetBitsFromISR(const EventBits_t uxBitsToSet, BaseType_t *pxHigherPriorityTaskWoken)
143 {
144  return xEventGroupSetBitsFromISR(handle, uxBitsToSet, pxHigherPriorityTaskWoken);
145 }
146 
147 #endif
148 
149 
EventGroupHandle_t handle
BaseType_t ClearBitsFromISR(const EventBits_t uxBitsToClear)
EventBits_t Sync(const EventBits_t uxBitsToSet, const EventBits_t uxBitsToWaitFor, TickType_t xTicksToWait)
EventBits_t SetBits(const EventBits_t uxBitsToSet)
EventBits_t WaitBits(const EventBits_t uxBitsToWaitFor, bool xClearOnExit, bool xWaitForAllBits, TickType_t xTicksToWait)
EventBits_t ClearBits(const EventBits_t uxBitsToClear)