28#ifndef FREERTOS_MUTEX_HPP
29#define FREERTOS_MUTEX_HPP
58 static void*
operator new(size_t) =
delete;
59 static void*
operator new[](size_t) =
delete;
61 static void*
operator new(size_t,
void* ptr) {
65 static void*
operator new[](size_t,
void* ptr) {
99 inline bool lock(
const TickType_t ticksToWait = portMAX_DELAY)
const {
100 return (xSemaphoreTake(
handle, ticksToWait) == pdTRUE);
124 BaseType_t taskWoken = pdFALSE;
125 const bool result = (xSemaphoreTakeFromISR(
handle, &taskWoken) == pdTRUE);
126 if (taskWoken == pdTRUE) {
127 higherPriorityTaskWoken =
true;
143 return (xSemaphoreTakeFromISR(
handle, NULL) == pdTRUE);
165 return (xSemaphoreGive(
handle) == pdTRUE);
183 vSemaphoreDelete(this->
handle);
215 static void*
operator new(size_t,
void*);
216 static void*
operator new[](size_t,
void*);
217 static void*
operator new(size_t) =
delete;
218 static void*
operator new[](size_t) =
delete;
239 inline bool lock(
const TickType_t ticksToWait = portMAX_DELAY)
const {
240 return (xSemaphoreTakeRecursive(
handle, ticksToWait) == pdTRUE);
264 return (xSemaphoreGiveRecursive(
handle) == pdTRUE);
275#if (configSUPPORT_DYNAMIC_ALLOCATION == 1)
321 this->
handle = xSemaphoreCreateMutex();
376 this->
handle = xSemaphoreCreateRecursiveMutex();
389#if (configSUPPORT_STATIC_ALLOCATION == 1)
436 this->handle = xSemaphoreCreateMutexStatic(&staticMutex);
447 StaticSemaphore_t staticMutex;
495 this->handle = xSemaphoreCreateRecursiveMutexStatic(&staticRecursiveMutex);
506 StaticSemaphore_t staticRecursiveMutex;
Base class that provides the standard mutex interface to FreeRTOS::Mutex, FreeRTOS::StaticMutex,...
Definition Mutex.hpp:47
bool lockFromISR(bool &higherPriorityTaskWoken) const
Function that calls xSemaphoreTakeFromISR ( SemaphoreHandle_t xSemaphore, signed BaseType_t *pxHigher...
Definition Mutex.hpp:123
bool lockFromISR() const
Function that calls xSemaphoreTakeFromISR ( SemaphoreHandle_t xSemaphore, signed BaseType_t *pxHigher...
Definition Mutex.hpp:142
SemaphoreHandle_t handle
Handle used to refer to the semaphore when using the FreeRTOS interface.
Definition Mutex.hpp:193
bool lock(const TickType_t ticksToWait=portMAX_DELAY) const
Function that calls xSemaphoreTake( SemaphoreHandle_t xSemaphore, TickType_t xTicksToWait )
Definition Mutex.hpp:99
~MutexBase()
Destroy the MutexBase object by calling void vSemaphoreDelete( SemaphoreHandle_t xSemaphore )
Definition Mutex.hpp:182
bool unlock() const
Function that calls xSemaphoreGive( SemaphoreHandle_t xSemaphore )
Definition Mutex.hpp:164
bool isValid() const
Function that checks if the underlying semaphore handle is not NULL. This should be used to ensure a ...
Definition Mutex.hpp:78
Class that encapsulates the functionality of a FreeRTOS mutex.
Definition Mutex.hpp:303
Mutex()
Construct a new Mutex object by calling SemaphoreHandle_t xSemaphoreCreateMutex( void )
Definition Mutex.hpp:320
Base class that provides the recursive mutex interface to FreeRTOS::RecursiveMutex and FreeRTOS::Stat...
Definition Mutex.hpp:207
bool unlock() const
Function that calls xSemaphoreGiveRecursive( SemaphoreHandle_t xSemaphore )
Definition Mutex.hpp:263
bool lock(const TickType_t ticksToWait=portMAX_DELAY) const
Function that calls xSemaphoreTakeRecursive( SemaphoreHandle_t xMutex, TickType_t xTicksToWait )
Definition Mutex.hpp:239
Class that encapsulates the functionality of a FreeRTOS recursive mutex.
Definition Mutex.hpp:358
RecursiveMutex()
Construct a new RecursiveMutex object by calling SemaphoreHandle_t xSemaphoreCreateRecursiveMutex( vo...
Definition Mutex.hpp:375
Class that encapsulates the functionality of a FreeRTOS mutex.
Definition Mutex.hpp:417
StaticMutex()
Construct a new StaticMutex object by calling SemaphoreHandle_t xSemaphoreCreateMutexStatic( StaticSe...
Definition Mutex.hpp:435
Class that encapsulates the functionality of a FreeRTOS recursive mutex.
Definition Mutex.hpp:476
StaticRecursiveMutex()
Construct a new StaticRecursiveMutex object by calling SemaphoreHandle_t xSemaphoreCreateRecursiveMut...
Definition Mutex.hpp:494