FreeRTOS-Cpp
Public Member Functions | Private Attributes | List of all members
FreeRTOS::StaticCountingSemaphore Class Reference
Inheritance diagram for FreeRTOS::StaticCountingSemaphore:
Inheritance graph
[legend]
Collaboration diagram for FreeRTOS::StaticCountingSemaphore:
Collaboration graph
[legend]

Public Member Functions

 StaticCountingSemaphore (const UBaseType_t maxCount, const UBaseType_t initialCount=0)
 Construct a new StaticCountingSemaphore object by calling SemaphoreHandle_t xSemaphoreCreateCountingStatic( UBaseType_t uxMaxCount, UBaseType_t uxInitialCount, StaticSemaphore_t *pxSemaphoreBuffer ) More...
 
 StaticCountingSemaphore (const StaticCountingSemaphore &)=delete
 
StaticCountingSemaphoreoperator= (const StaticCountingSemaphore &)=delete
 
 StaticCountingSemaphore (StaticCountingSemaphore &&) noexcept=default
 
StaticCountingSemaphoreoperator= (StaticCountingSemaphore &&) noexcept=default
 
- Public Member Functions inherited from FreeRTOS::SemaphoreBase
 SemaphoreBase (const SemaphoreBase &)=delete
 
SemaphoreBaseoperator= (const SemaphoreBase &)=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. More...
 
UBaseType_t getCount () const
 Function that calls UBaseType_t uxSemaphoreGetCount( SemaphoreHandle_t xSemaphore ) More...
 
bool take (const TickType_t ticksToWait=portMAX_DELAY) const
 Function that calls xSemaphoreTake( SemaphoreHandle_t xSemaphore, TickType_t xTicksToWait ) More...
 
bool takeFromISR (bool &higherPriorityTaskWoken) const
 Function that calls xSemaphoreTakeFromISR( SemaphoreHandle_t xSemaphore, signed BaseType_t *pxHigherPriorityTaskWoken) More...
 
bool takeFromISR () const
 Function that calls xSemaphoreTakeFromISR( SemaphoreHandle_t xSemaphore, signed BaseType_t *pxHigherPriorityTaskWoken) More...
 
bool give () const
 Function that calls xSemaphoreGive( SemaphoreHandle_t xSemaphore ) More...
 
bool giveFromISR (bool &higherPriorityTaskWoken) const
 Function that calls xSemaphoreGiveFromISR( SemaphoreHandle_t xSemaphore, signed BaseType_t *pxHigherPriorityTaskWoken ) More...
 
bool giveFromISR () const
 Function that calls xSemaphoreGiveFromISR( SemaphoreHandle_t xSemaphore, signed BaseType_t *pxHigherPriorityTaskWoken ) More...
 

Private Attributes

StaticSemaphore_t staticCountingSemaphore
 

Additional Inherited Members

- Static Public Member Functions inherited from FreeRTOS::SemaphoreBase
static void * operator new (size_t, void *ptr)
 
static void * operator new[] (size_t, void *ptr)
 
static void * operator new (size_t)=delete
 
static void * operator new[] (size_t)=delete
 

Constructor & Destructor Documentation

◆ StaticCountingSemaphore()

FreeRTOS::StaticCountingSemaphore::StaticCountingSemaphore ( const UBaseType_t  maxCount,
const UBaseType_t  initialCount = 0 
)
inlineexplicit

Construct a new StaticCountingSemaphore object by calling SemaphoreHandle_t xSemaphoreCreateCountingStatic( UBaseType_t uxMaxCount, UBaseType_t uxInitialCount, StaticSemaphore_t *pxSemaphoreBuffer )

See also
https://www.freertos.org/xSemaphoreCreateCountingStatic.html
Warning
This class contains the storage buffer for the counting semaphore, so the user should create this object as a global object or with the static storage specifier so that the object instance is not on the stack.
Parameters
maxCountThe maximum count value that can be reached. When the semaphore reaches this value it can no longer be 'given'.
initialCountThe count value assigned to the semaphore when it is created.

Example Usage

#include <FreeRTOS/Semaphore.hpp>
#include <FreeRTOS/Task.hpp>
class MyTask : public FreeRTOS::Task {
public:
void taskFunction() final;
};
// Create a counting semaphore that has a maximum count of 10 and an initial
// count of 0.
static FreeRTOS::StaticCountingSemaphore countingSemaphore(10);
void MyTask::taskFunction() {
// Use the semaphore.
// Rest of task code.
}
Class that encapsulates the functionality of a FreeRTOS task.
Definition: Task.hpp:1323

The documentation for this class was generated from the following file: