Base class that provides the standard mutex interface to FreeRTOS::Mutex, FreeRTOS::StaticMutex, FreeRTOS::RecursiveMutex, and FreeRTOS::StaticRecursiveMutex.
More...
#include <FreeRTOS/Mutex.hpp>
|
|
| MutexBase (const MutexBase &)=delete |
| |
|
MutexBase & | operator= (const MutexBase &)=delete |
| |
| bool | isValid () const |
| | Function that checks if the underlying semaphore handle is not NULL. This should be used to ensure a semaphore has been created correctly.
|
| |
| bool | lock (const TickType_t ticksToWait=portMAX_DELAY) const |
| | Function that calls xSemaphoreTake( SemaphoreHandle_t
xSemaphore, TickType_t xTicksToWait )
|
| |
| bool | lockFromISR (bool &higherPriorityTaskWoken) const |
| | Function that calls xSemaphoreTakeFromISR ( SemaphoreHandle_t xSemaphore, signed BaseType_t *pxHigherPriorityTaskWoken )
|
| |
| bool | lockFromISR () const |
| | Function that calls xSemaphoreTakeFromISR ( SemaphoreHandle_t xSemaphore, signed BaseType_t *pxHigherPriorityTaskWoken )
|
| |
| bool | unlock () const |
| | Function that calls xSemaphoreGive( SemaphoreHandle_t xSemaphore
)
|
| |
|
|
static void * | operator new (size_t)=delete |
| |
|
static void * | operator new[] (size_t)=delete |
| |
|
static void * | operator new (size_t, void *ptr) |
| |
|
static void * | operator new[] (size_t, void *ptr) |
| |
|
|
SemaphoreHandle_t | handle = NULL |
| | Handle used to refer to the semaphore when using the FreeRTOS interface.
|
| |
|
|
class | Mutex |
| |
|
class | StaticMutex |
| |
|
class | RecursiveMutexBase |
| |
|
class | RecursiveMutex |
| |
|
class | StaticRecursiveMutex |
| |
◆ ~MutexBase()
| FreeRTOS::MutexBase::~MutexBase |
( |
| ) |
|
|
inlineprivate |
◆ isValid()
| bool FreeRTOS::MutexBase::isValid |
( |
| ) |
const |
|
inline |
Function that checks if the underlying semaphore handle is not NULL. This should be used to ensure a semaphore has been created correctly.
Mutex.hpp
- Return values
-
| true | the handle is not NULL. |
| false | the handle is NULL. |
◆ lock()
| bool FreeRTOS::MutexBase::lock |
( |
const TickType_t |
ticksToWait = portMAX_DELAY | ) |
const |
|
inline |
Function that calls xSemaphoreTake( SemaphoreHandle_t
xSemaphore, TickType_t xTicksToWait )
Mutex.hpp
- See also
- https://www.freertos.org/a00122.html
- Parameters
-
| ticksToWait | The time in ticks to wait for the mutex to become available. The macro portTICK_PERIOD_MS can be used to convert this to a real time. A block time of zero can be used to poll the mutex. |
- Return values
-
| true | If the mutex was locked. |
| false | If ticksToWait expired without the mutex becoming available. |
Example Usage
#include <FreeRTOS/Mutex.hpp>
#include <FreeRTOS/Task.hpp>
public:
void taskFunction() final;
};
class MyOtherTask : public FreeRTOS::
Task {
public:
void taskFunction() final;
};
void MyTask::taskFunction() {
}
void MyOtherTask::taskFunction() {
if (mutex.isValid()) {
if (mutex.lock()) {
} else {
}
}
}
bool unlock() const
Function that calls xSemaphoreGive( SemaphoreHandle_t xSemaphore )
Definition Mutex.hpp:164
Class that encapsulates the functionality of a FreeRTOS mutex.
Definition Mutex.hpp:417
Class that encapsulates the functionality of a FreeRTOS task.
Definition Task.hpp:1427
◆ lockFromISR() [1/2]
| bool FreeRTOS::MutexBase::lockFromISR |
( |
| ) |
const |
|
inline |
Function that calls xSemaphoreTakeFromISR ( SemaphoreHandle_t xSemaphore, signed BaseType_t *pxHigherPriorityTaskWoken )
Mutex.hpp
- See also
- https://www.freertos.org/xSemaphoreTakeFromISR.html
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
◆ lockFromISR() [2/2]
| bool FreeRTOS::MutexBase::lockFromISR |
( |
bool & |
higherPriorityTaskWoken | ) |
const |
|
inline |
Function that calls xSemaphoreTakeFromISR ( SemaphoreHandle_t xSemaphore, signed BaseType_t *pxHigherPriorityTaskWoken )
Mutex.hpp
- See also
- https://www.freertos.org/xSemaphoreTakeFromISR.html
- Parameters
-
| higherPriorityTaskWoken | It is possible (although unlikely, and dependent on the semaphore type) that a mutex will have one or more tasks blocked on it waiting to give the mutex. Calling lockFromISR() will make a task that was blocked waiting to give the mutex leave the Blocked state. If calling the API function causes a task to leave the Blocked state, and the unblocked task has a priority equal to or higher than the currently executing task (the task that was interrupted), then, internally, the API function will set higherPriorityTaskWoken to true. |
- Returns
- true If the mutex was successfully locked.
-
false If the mutex was not successfully locked because it was not available.
◆ unlock()
| bool FreeRTOS::MutexBase::unlock |
( |
| ) |
const |
|
inline |
Function that calls xSemaphoreGive( SemaphoreHandle_t xSemaphore
)
Mutex.hpp
- See also
- https://www.freertos.org/a00123.html
- Warning
- This must not be used from an ISR.
- Returns
- true If the mutex was unlocked.
-
false If an error occurred. Mutexes (semaphores) are implemented using queues. An error can occur if there is no space on the queue to post a message indicating that the mutex was not first locked correctly.
Example Usage
#include <FreeRTOS/Mutex.hpp>
#include <FreeRTOS/Task.hpp>
public:
void taskFunction() final;
};
void MyTask::taskFunction() {
}
}
}
}
}
bool lock(const TickType_t ticksToWait=portMAX_DELAY) const
Function that calls xSemaphoreTake( SemaphoreHandle_t xSemaphore, TickType_t xTicksToWait )
Definition Mutex.hpp:99
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
The documentation for this class was generated from the following file:
- /home/runner/work/FreeRTOS-Cpp/FreeRTOS-Cpp/FreeRTOS-Cpp/include/FreeRTOS/Mutex.hpp