ELEC-C7222
Libraries for ELEC C7222 Course Work
Loading...
Searching...
No Matches
c7222::FreeRtosBinarySemaphore Class Reference

Ownership-based wrapper for a FreeRTOS-style binary semaphore. More...

#include <freertos_semaphore.hpp>

Inheritance diagram for c7222::FreeRtosBinarySemaphore:
Inheritance graph
Collaboration diagram for c7222::FreeRtosBinarySemaphore:
Collaboration graph

Public Member Functions

 FreeRtosBinarySemaphore ()=default
 Construct an uninitialized semaphore wrapper.
 
 FreeRtosBinarySemaphore (bool initially_given)
 Construct and initialize a binary semaphore.
 
bool Initialize (bool initially_given=false)
 Initialize (or re-initialize) the semaphore.
 
 ~FreeRtosBinarySemaphore ()
 Destroy semaphore resources if initialized.
 
bool Take (std::uint32_t ticks_to_wait=0)
 Take the semaphore.
 
bool Give ()
 Give the semaphore from task context.
 
bool GiveFromISR ()
 Give the semaphore from ISR context.
 
bool IsValid () const
 
- Public Member Functions inherited from c7222::NonCopyable
 NonCopyable (const NonCopyable &)=delete
 
NonCopyableoperator= (const NonCopyable &)=delete
 
 NonCopyable (NonCopyable &&)=default
 
NonCopyableoperator= (NonCopyable &&)=default
 
- Public Member Functions inherited from c7222::NonMovable
 NonMovable (const NonMovable &)=default
 
NonMovableoperator= (const NonMovable &)=default
 
 NonMovable (NonMovable &&)=delete
 
NonMovableoperator= (NonMovable &&)=delete
 

Additional Inherited Members

- Protected Member Functions inherited from c7222::NonCopyableNonMovable
 NonCopyableNonMovable ()=default
 
 ~NonCopyableNonMovable ()=default
 
- Protected Member Functions inherited from c7222::NonCopyable
 NonCopyable ()=default
 
 ~NonCopyable ()=default
 
- Protected Member Functions inherited from c7222::NonMovable
 NonMovable ()=default
 
 ~NonMovable ()=default
 

Detailed Description

Ownership-based wrapper for a FreeRTOS-style binary semaphore.

Typical usage is event signaling between execution contexts (task-to-task or ISR-to-task). Unlike a mutex, binary semaphores do not provide ownership tracking or priority inheritance. Take/give is explicit.

Typical usage:

// Producer task/ISR:
(void)ready.Give();
// Consumer task:
if(ready.Take(50)) {
// proceed after signal
}
Ownership-based wrapper for a FreeRTOS-style binary semaphore.
Definition freertos_semaphore.hpp:35

Constructor & Destructor Documentation

◆ FreeRtosBinarySemaphore() [1/2]

c7222::FreeRtosBinarySemaphore::FreeRtosBinarySemaphore ( )
default

Construct an uninitialized semaphore wrapper.

◆ FreeRtosBinarySemaphore() [2/2]

c7222::FreeRtosBinarySemaphore::FreeRtosBinarySemaphore ( bool  initially_given)
explicit

Construct and initialize a binary semaphore.

Parameters
initially_givenIf true, semaphore starts in the available state.

◆ ~FreeRtosBinarySemaphore()

c7222::FreeRtosBinarySemaphore::~FreeRtosBinarySemaphore ( )

Destroy semaphore resources if initialized.

Member Function Documentation

◆ Give()

bool c7222::FreeRtosBinarySemaphore::Give ( )

Give the semaphore from task context.

Returns
true on success.

◆ GiveFromISR()

bool c7222::FreeRtosBinarySemaphore::GiveFromISR ( )

Give the semaphore from ISR context.

Returns
true on success.

◆ Initialize()

bool c7222::FreeRtosBinarySemaphore::Initialize ( bool  initially_given = false)

Initialize (or re-initialize) the semaphore.

Parameters
initially_givenIf true, semaphore starts in the available state.
Returns
true on success.

◆ IsValid()

bool c7222::FreeRtosBinarySemaphore::IsValid ( ) const
Returns
true if the wrapper owns a valid semaphore handle.

◆ Take()

bool c7222::FreeRtosBinarySemaphore::Take ( std::uint32_t  ticks_to_wait = 0)

Take the semaphore.

Parameters
ticks_to_waitMax ticks to wait (0 = non-blocking).
Returns
true if acquired.

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