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