Wrapper class around FreeRTOS's implementation of a event_group. More...

#include <mn_eventgroup.hpp>

+ Inheritance diagram for mn::basic_event_group:
+ Collaboration diagram for mn::basic_event_group:

Public Member Functions

 basic_event_group (const char *strName="unamed")
 Consruct a new event group. More...
 
 basic_event_group (EventGroupHandle_t handle)
 Consruct from a FreeRTOS created event group. More...
 
virtual ~basic_event_group ()
 Delete an event group. More...
 
int create ()
 Create the event group. More...
 
EventBits_t sync (const EventBits_t uxBitsToSet, const EventBits_t uxBitsToWaitFor, TickType_t xTicksToWait)
 Allow two or more tasks to use an event group to sync each other. More...
 
bool is_bit (const EventBits_t uxBitToWaitFor, uint32_t timeout)
 Block to wait for one bit to be set within a previously created event group. More...
 
EventBits_t wait (const EventBits_t uxBitsToWaitFor, bool xClearOnExit, bool xWaitForAllBits, uint32_t timeout)
 Block to wait for one or more bits to be set within a previously created event group. More...
 
EventBits_t clear (const EventBits_t uxBitsToClear)
 Clear bits (flags) within an event group. More...
 
EventBits_t get ()
 Returns the current value of the event bits (event flags) in an event group. More...
 
EventBits_t set (const EventBits_t uxBitsToSet)
 Set bits (flags) within an event group. More...
 
EventGroupHandle_t get_handle ()
 Get the FreeRTOS Event Group handle. More...
 
bool is_init ()
 Is the basic_event_group initilisiert? More...
 
const char * get_name ()
 Get the debug name. More...
 
void set_name (const char *strName)
 Set a new debug name for this event group. More...
 

Private Member Functions

void init_internal ()
 Initialisert the eventgroup. More...
 

Private Attributes

EventGroupHandle_t m_pHandle
 
char m_strName [16]
 

Detailed Description

Wrapper class around FreeRTOS's implementation of a event_group.

Constructor & Destructor Documentation

◆ basic_event_group() [1/2]

mn::basic_event_group::basic_event_group ( const char *  strName = "unamed")

Consruct a new event group.

Parameters
strNameThe name for this event group, only for debugging.
Note
Although event groups are not related to ticks, for internal implementation reasons the number of bits available for use in an event group is dependent on the configUSE_16_BIT_TICKS setting in FreeRTOSConfig.h. If configUSE_16_BIT_TICKS is 1 then each event group contains 8 usable bits (bit 0 to bit 7). If configUSE_16_BIT_TICKS is set to 0 then each event group has 24 usable bits (bit 0 to bit 23). The EventBits_t type is used to store event bits within an event group.
Version >2.30 call create after this!

◆ basic_event_group() [2/2]

mn::basic_event_group::basic_event_group ( EventGroupHandle_t  handle)

Consruct from a FreeRTOS created event group.

◆ ~basic_event_group()

mn::basic_event_group::~basic_event_group ( )
virtual

Delete an event group.

Note
Tasks that are blocked on the event group will be unblocked and obtain 0 as the event group's value.

Member Function Documentation

◆ clear()

EventBits_t mn::basic_event_group::clear ( const EventBits_t  uxBitsToClear)

Clear bits (flags) within an event group.

Parameters
uxBitsToClearA bitwise value that indicates the bit or bits to clear in the event group.
Returns
The value of the event group before the specified bits were cleared.

◆ create()

int mn::basic_event_group::create ( )

Create the event group.

Returns
  • ERR_MNTHREAD_NULL: Error on create the event group.
  • NO_ERROR: The event group are sucessfull created

◆ get()

EventBits_t mn::basic_event_group::get ( void  )

Returns the current value of the event bits (event flags) in an event group.

Returns
The value of the event bits in the event group at the time basic_event_group::get was called.

◆ get_handle()

EventGroupHandle_t mn::basic_event_group::get_handle ( )
inline

Get the FreeRTOS Event Group handle.

Returns
The FreeRTOS Event Group handle.

◆ get_name()

const char* mn::basic_event_group::get_name ( )
inline

Get the debug name.

Returns
The debug name of this event group.

◆ init_internal()

void mn::basic_event_group::init_internal ( )
private

Initialisert the eventgroup.

◆ is_bit()

bool mn::basic_event_group::is_bit ( const EventBits_t  uxBitToWaitFor,
uint32_t  timeout 
)

Block to wait for one bit to be set within a previously created event group.

This function cannot be called from an interrupt.

Parameters
uxBitToWaitForA bitwise value that indicates the bit or bits to test inside the event group.
xTicksToWaitThe maximum amount of time (specified in 'ticks') to wait for one/all (depending on the xWaitForAllBits value) of the bits specified by uxBitToWaitFor to become set.
Returns
If true then was set the bit and false if not.

◆ is_init()

bool mn::basic_event_group::is_init ( )
inline

Is the basic_event_group initilisiert?

Returns
True The basic_event_group is initilisiert and false if not.

◆ set()

EventBits_t mn::basic_event_group::set ( const EventBits_t  uxBitsToSet)

Set bits (flags) within an event group.

Parameters
uxBitsToSetA bitwise value that indicates the bit or bits to set in the event group.
Returns
The value of the event group at the time the call to basic_event_group::set returns

◆ set_name()

void mn::basic_event_group::set_name ( const char *  strName)

Set a new debug name for this event group.

Parameters
strNameThe name of this class.

◆ sync()

EventBits_t mn::basic_event_group::sync ( const EventBits_t  uxBitsToSet,
const EventBits_t  uxBitsToWaitFor,
TickType_t  xTicksToWait 
)

Allow two or more tasks to use an event group to sync each other.

Parameters
uxBitsToSetThe bits to set in the event group before determining if, and possibly waiting for, all the bits specified by the uxBitsToWait parameter are set.
uxBitsToWaitForA bitwise value that indicates the bit or bits to test inside the event group. For example, to wait for bit 0 and bit 2 set uxBitsToWaitFor to 0x05. To wait for bits 0 and bit 1 and bit 2 set uxBitsToWaitFor to 0x07. Etc.
xTicksToWaitThe maximum amount of time (specified in 'ticks') to wait for all of the bits specified by uxBitsToWaitFor to become set.
Returns
The value of the event group at the time either the bits being waited for became set, or the block time expired. Test the return value to know which bits were set. If xEventGroupSync() returned because its timeout expired then not all the bits being waited for will be set. If xEventGroupSync() returned because all the bits it was waiting for were set then the returned value is the event group value before any bits were automatically cleared.

◆ wait()

EventBits_t mn::basic_event_group::wait ( const EventBits_t  uxBitsToWaitFor,
bool  xClearOnExit,
bool  xWaitForAllBits,
uint32_t  timeout 
)

Block to wait for one or more bits to be set within a previously created event group.

This function cannot be called from an interrupt.

Parameters
uxBitsToWaitForA bitwise value that indicates the bit or bits to test inside the event group.
xClearOnExitIf xClearOnExit is set to true then any bits set in the value passed as the uxBitsToWaitFor parameter will be cleared in the event group before basic_event_group::wait returns if basic_event_group::wait returns for any reason other than a timeout. The timeout value is set by the xTicksToWait parameter. If xClearOnExit is set to false then the bits set in the event group are not altered when the call to basic_event_group::wait returns.
xWaitForAllBitsis used to create either a logical AND test (where all bits must be set) or a logical OR test (where one or more bits must be set) as follows:
@par    If xWaitForAllBits is set to true then
        basic_event_group::wait will return when either all the
        bits set in the value passed as the uxBitsToWaitFor
        parameter are set in the event group or the specified
        block time expires.

@par   If xWaitForAllBits is set to false then
        basic_event_group::wait will return when any of the bits
        set in the value passed as the uxBitsToWaitFor
        parameter are set in the event group or the specified
        block time expires.
xTicksToWaitThe maximum amount of time (specified in 'ticks') to wait for one/all (depending on the xWaitForAllBits value) of the bits specified by uxBitsToWaitFor to become set.
Returns
The value of the event group at the time either the event bits being waited for became set, or the block time expired. The current value of the event bits in an event group will be different to the returned value if a higher priority task or interrupt changed the value of an event bit between the calling task leaving the Blocked state and exiting the basic_event_group::wait function. Test the return value to know which bits were set. If basic_event_group::wait returned because its timeout expired then not all the bits being waited for will be set. If basic_event_group::wait returned because the bits it was waiting for were set then the returned value is the event group value before any bits were automatically cleared because the xClearOnExit parameter was set to true.

Member Data Documentation

◆ m_pHandle

EventGroupHandle_t mn::basic_event_group::m_pHandle
private

FreeRTOS Event Group handle.

◆ m_strName

char mn::basic_event_group::m_strName[16]
private

The name of this event group, for debuging.


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