38#ifndef SEMAPHORE_CPP_H
39#define SEMAPHORE_CPP_H
46#if FREERTOSCPP_USE_NAMESPACE
84#if( configSUPPORT_STATIC_ALLOCATION == 1 )
85 sema = xSemaphoreCreateBinaryStatic(&semaBuffer);
87 sema = xSemaphoreCreateBinary();
89#if configQUEUE_REGISTRY_SIZE > 0
91 vQueueAddToRegistry(sema, name);
106 return xSemaphoreGive(sema);
114 bool take(TickType_t delay = portMAX_DELAY)
override {
115 return xSemaphoreTake(sema, delay);
118 return xSemaphoreTakeFromISR(sema, &waswoken);
121 #if FREERTOSCPP_USE_CHRONO
127 bool take(Time_ms delay){
128 return xSemaphoreTake(sema, ms2ticks(delay));
138 return xSemaphoreGiveFromISR(sema, &waswoken);
143#if __cplusplus < 201101L
151#if( configSUPPORT_STATIC_ALLOCATION == 1 )
152 StaticSemaphore_t semaBuffer;
158#if FREERTOSCPP_USE_NAMESPACE
BinarySemaphore Semaphore
Definition SemaphoreCPP.h:157
Binary Semaphore Wrapper.
Definition SemaphoreCPP.h:77
bool take_ISR(portBASE_TYPE &waswoken)
Definition SemaphoreCPP.h:117
bool give() override
Give the Semaphore.
Definition SemaphoreCPP.h:105
BinarySemaphore(char const *name=nullptr)
Constructor.
Definition SemaphoreCPP.h:83
bool take(TickType_t delay=portMAX_DELAY) override
Take the semaphore.
Definition SemaphoreCPP.h:114
BinarySemaphore(BinarySemaphore const &)=delete
We are not copyable.
~BinarySemaphore()
Destructor.
Definition SemaphoreCPP.h:99
SemaphoreHandle_t sema
Definition SemaphoreCPP.h:141
bool give_ISR(portBASE_TYPE &waswoken)
Give the Semaphore inside an ISR.
Definition SemaphoreCPP.h:137
A Base class to provide block based locking capability.
Definition Lock.h:58
Definition FreeRTOScpp.h:74