FreeRTOScpp
FreeRTOScpp::BinarySemaphore Class Reference

Binary Semaphore Wrapper. More...

#include <SemaphoreCPP.h>

Inheritance diagram for FreeRTOScpp::BinarySemaphore:
Collaboration diagram for FreeRTOScpp::BinarySemaphore:

Public Member Functions

 BinarySemaphore (char const *name=nullptr)
 Constructor. More...
 
 ~BinarySemaphore ()
 Destructor. More...
 
bool give () override
 Give the Semaphore. More...
 
bool give_ISR (portBASE_TYPE &waswoken)
 Give the Semaphore inside an ISR. More...
 
bool take (TickType_t delay=portMAX_DELAY) override
 Take the semaphore. More...
 
bool take (Time_ms delay)
 Take the semaphore. More...
 
bool take_ISR (portBASE_TYPE &waswoken)
 

Private Member Functions

 BinarySemaphore (BinarySemaphore const &)=delete
 We are not copyable. More...
 
void operator= (BinarySemaphore const &)=delete
 We are not assignable. More...
 

Private Attributes

SemaphoreHandle_t sema
 

Detailed Description

Binary Semaphore Wrapper.

Example Usage:

Semaphore sema("MySema");
// In some task
sema.give();
// In some other task
sema.take();
// In some ISR
portBASE_TYPE woken = 0;
...
sema.give_ISR(woken);
...
portYIELD_FROM_ISR(woken);
return;

Constructor & Destructor Documentation

◆ BinarySemaphore() [1/2]

FreeRTOScpp::BinarySemaphore::BinarySemaphore ( char const *  name = nullptr)
inline

Constructor.

Parameters
nameName to give semaphore, used for Debug Registry if setup

References sema.

◆ ~BinarySemaphore()

FreeRTOScpp::BinarySemaphore::~BinarySemaphore ( )
inline

Destructor.

Delete the semaphore.

References sema.

◆ BinarySemaphore() [2/2]

FreeRTOScpp::BinarySemaphore::BinarySemaphore ( BinarySemaphore const &  )
privatedelete

We are not copyable.

Member Function Documentation

◆ give()

bool FreeRTOScpp::BinarySemaphore::give ( )
inlineoverridevirtual

Give the Semaphore.

Implements FreeRTOScpp::Lockable.

References sema.

◆ give_ISR()

bool FreeRTOScpp::BinarySemaphore::give_ISR ( portBASE_TYPE &  waswoken)
inline

Give the Semaphore inside an ISR.

Parameters
waswokenThe flag variable used to indicate if we need to run the scheduler when we exit the ISR.

References sema.

◆ operator=()

void FreeRTOScpp::BinarySemaphore::operator= ( BinarySemaphore const &  )
privatedelete

We are not assignable.

◆ take() [1/2]

bool FreeRTOScpp::BinarySemaphore::take ( TickType_t  delay = portMAX_DELAY)
inlineoverridevirtual

Take the semaphore.

Parameters
delayThe number of ticks to wait for the semaphore

Implements FreeRTOScpp::Lockable.

References sema.

◆ take() [2/2]

bool FreeRTOScpp::BinarySemaphore::take ( Time_ms  delay)
inline

Take the semaphore.

Parameters
delayThe number of ticks to wait for the semaphore

References FreeRTOScpp::ms2ticks(), and sema.

Here is the call graph for this function:

◆ take_ISR()

bool FreeRTOScpp::BinarySemaphore::take_ISR ( portBASE_TYPE &  waswoken)
inline

References sema.

Member Data Documentation

◆ sema

SemaphoreHandle_t FreeRTOScpp::BinarySemaphore::sema
private

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