From 96d6da4e252b06dcfdc041e7df23e86161c33007 Mon Sep 17 00:00:00 2001 From: rihab kouki Date: Tue, 28 Jul 2020 11:24:49 +0100 Subject: Official ARM version: v5.6.0 --- .../RTOS2/html/group__CMSIS__RTOS__EventFlags.html | 179 ++++++++++----------- 1 file changed, 83 insertions(+), 96 deletions(-) (limited to 'docs/RTOS2/html/group__CMSIS__RTOS__EventFlags.html') diff --git a/docs/RTOS2/html/group__CMSIS__RTOS__EventFlags.html b/docs/RTOS2/html/group__CMSIS__RTOS__EventFlags.html index 9d7271b..cfc501e 100644 --- a/docs/RTOS2/html/group__CMSIS__RTOS__EventFlags.html +++ b/docs/RTOS2/html/group__CMSIS__RTOS__EventFlags.html @@ -174,50 +174,62 @@ Refer to Event Flags Conf Simple event communication

The following steps are required to use event flags:

    -
  1. In the thread that is supposed to send a event with id sig1_id, call the set function:
    osDelay (1000); // wait for 1 second
    -
    osEventFlagsSet (sig1_id, 0x0001U); // set the flag 0x0001U for event sig1_id
    +
  2. In the thread that is supposed to send a event with id sig1_id, call the set function:
    osDelay(1000U); // wait for 1 second
    +
    osEventFlagsSet(sig1_id, 0x0001U); // set the flag 0x0001U for event sig1_id
  3. -
  4. In another thread (or threads) that are supposed to wait for the event, call the wait function:
    osEventFlagsWait (sig1_id, 0x0001U, NULL, osWaitForever); // wait forever for any flag
    +
  5. In another thread (or threads) that are supposed to wait for the event, call the wait function:
    osEventFlagsWait(sig1_id, 0x0001U, NULL, osWaitForever); // wait forever for any flag

The following complete example code can be directly used with the "CMSIS-RTOS2 main template" and is also provided as a stand-alone template for RTX5:

Code Example

-
void Thread_EventSender (void *argument); // thread function 1
-
void Thread_EventReceiver (void *argument); // thread function 2
-
osThreadId_t tid_Thread_EventSender; // thread id 1
-
osThreadId_t tid_Thread_EventReceiver; // thread id 2
+
#include "cmsis_os2.h" // CMSIS RTOS header file
-
osEventFlagsId_t evt_id; // message queue id
+
/*----------------------------------------------------------------------------
+
* Event Flags creation & usage
+
*---------------------------------------------------------------------------*/
-
#define FLAGS_MSK1 0x00000001ul
+
#define FLAGS_MSK1 0x00000001U
-
void app_main (void)
-
{
-
tid_Thread_EventSender = osThreadNew (Thread_EventSender, NULL, NULL);
+
osEventFlagsId_t evt_id; // event flags id
+
+
osThreadId_t tid_Thread_EventSender; // thread id 1
+
osThreadId_t tid_Thread_EventReceiver; // thread id 2
+
+
void Thread_EventSender (void *argument); // thread function 1
+
void Thread_EventReceiver (void *argument); // thread function 2
+
+
int Init_Events (void) {
+
+
evt_id = osEventFlagsNew(NULL);
+
if (evt_id == NULL) {
+
; // Event Flags object not created, handle failure
+
}
+
+
tid_Thread_EventSender = osThreadNew(Thread_EventSender, NULL, NULL);
if (tid_Thread_EventSender == NULL) {
-
; // do something
+
return(-1);
}
-
tid_Thread_EventReceiver = osThreadNew (Thread_EventReceiver, NULL, NULL);
+
tid_Thread_EventReceiver = osThreadNew(Thread_EventReceiver, NULL, NULL);
if (tid_Thread_EventReceiver == NULL) {
-
; // do something
+
return(-1);
}
-
; // do something
+
+
return(0);
}
-
void Thread_EventSender (void *argument)
-
{
-
evt_id = osEventFlagsNew(NULL);
+
void Thread_EventSender (void *argument) {
+
while (1) {
osEventFlagsSet(evt_id, FLAGS_MSK1);
-
osDelay (1000); // suspend thread
+
osThreadYield(); // suspend thread
}
}
-
void Thread_EventReceiver (void *argument)
-
{
+
void Thread_EventReceiver (void *argument) {
uint32_t flags;
+
while (1) {
-
flags = osEventFlagsWait (evt_id,FLAGS_MSK1,osFlagsWaitAny, osWaitForever);
+
flags = osEventFlagsWait(evt_id, FLAGS_MSK1, osFlagsWaitAny, osWaitForever);
//handle event
}
}
@@ -244,31 +256,31 @@ Simple event communication
name -name of the event flags

Pointer to a string with a human readable name of the event object.
-Default: NULL.

+name of the event flags

Pointer to a constant string with a human readable name (displayed during debugging) of the event flag object.

+

Default: NULL no name specified.

uint32_t attr_bits -attribute bits

Reserved for future use (set to '0').
-Default: 0.

+attribute bits

Reserved for future use (must be set to '0' for future compatibility).

void * cb_mem -memory for control block

Pointer to a memory location for the event control block object. This can optionally be used for custom memory management systems.
-Default: NULL (uses kernel memory management).

+memory for control block

Pointer to a memory for the event flag control block object. Refer to Static Object Memory for more information.

+

Default: NULL to use Automatic Dynamic Allocation for the event flag control block.

uint32_t cb_size -size of provided memory for control block

The size of the memory block passed with cb_mem. Must be the size of an event control block object or larger.

+size of provided memory for control block

The size (in bytes) of memory block passed with cb_mem. For RTX, the minimum value is defined with osRtxEventFlagsCbSize (higher values are permitted).

+

Default: 0 as the default is no memory provided with cb_mem.

@@ -317,27 +329,19 @@ size of provided memory for control block

The size of the memory block passed

The parameter attr sets the event flags attributes (refer to osEventFlagsAttr_t). Default attributes will be used if set to NULL, i.e. kernel memory allocation is used for the event control block.

Note
Cannot be called from Interrupt Service Routines.

Code Example

-
#include "cmsis_os2.h" // CMSIS RTOS header file
+
#include "cmsis_os2.h" // CMSIS RTOS header file
-
osEventFlagsId_t evt_id; // message queue id
+
osEventFlagsId_t evt_id; // message queue id
-
void Thread_EventSender (void *argument)
-
{
-
evt_id = osEventFlagsNew(NULL);
-
while (1) {
-
osEventFlagsSet(evt_id, FLAGS_MSK1);
-
osThreadYield (); // suspend thread
-
}
-
}
+
int Init_Events (void) {
-
void Thread_EventReceiver (void *argument)
-
{
-
uint32_t flags;
-
-
while (1) {
-
flags = osEventFlagsWait (evt_id,FLAGS_MSK1,osFlagsWaitAny, osWaitForever);
-
//handle event
+
evt_id = osEventFlagsNew(NULL);
+
if (evt_id == NULL) {
+
; // Event Flags object not created, handle failure
+
return(-1);
}
+
+
return(0);
}
@@ -376,32 +380,21 @@ size of provided memory for control block

The size of the memory block passed

The function osEventFlagsSet sets the event flags specified by the parameter flags in an event flags object specified by parameter ef_id. All threads waiting for the flag set will be notified to resume from BLOCKED state. The function returns the event flags after setting or an error code (highest bit is set, refer to Flags Functions Error Codes).

Possible Flags Functions Error Codes return values:

Note
This function may be called from Interrupt Service Routines.

Code Example

-
#include "cmsis_os2.h" // CMSIS RTOS header file
+
#include "cmsis_os2.h" // CMSIS RTOS header file
-
osEventFlagsId_t evt_id; // message queue id
+
osEventFlagsId_t evt_id; // event flasg id
-
void Thread_EventSender (void *argument)
-
{
-
evt_id = osEventFlagsNew(NULL);
-
while (1) {
-
osEventFlagsSet(evt_id, FLAGS_MSK1);
-
osThreadYield (); // suspend thread
-
}
-
}
+
void Thread_EventSender (void *argument) {
-
void Thread_EventReceiver (void *argument)
-
{
-
uint32_t flags;
-
-
while (1) {
-
flags = osEventFlagsWait (evt_id,FLAGS_MSK1,osFlagsWaitAny, osWaitForever);
-
//handle event
+
while (1) {
+
osEventFlagsSet(evt_id, 0x00000001U);
+
osThreadYield(); // suspend thread
}
}
@@ -441,9 +434,9 @@ size of provided memory for control block

The size of the memory block passed

The function osEventFlagsClear clears the event flags specified by the parameter flags in an event flags object specified by parameter ef_id. The function returns the event flags before clearing or an error code (highest bit is set, refer to Flags Functions Error Codes).

Possible Flags Functions Error Codes return values:

Note
This function may be called from Interrupt Service Routines.
@@ -541,32 +534,22 @@ size of provided memory for control block

The size of the memory block passed

The function returns the event flags before clearing or an error code (highest bit is set, refer to Flags Functions Error Codes).

Possible Flags Functions Error Codes return values:

Note
May be called from Interrupt Service Routines if the parameter timeout is set to 0.

Code Example

-
#include "cmsis_os2.h" // CMSIS RTOS header file
+
#include "cmsis_os2.h" // CMSIS RTOS header file
-
osEventFlagsId_t evt_id; // message queue id
+
osEventFlagsId_t evt_id; // event flasg id
-
void Thread_EventSender (void *argument)
-
{
-
evt_id = osEventFlagsNew(NULL);
-
while (1) {
-
osEventFlagsSet(evt_id, FLAGS_MSK1);
-
osThreadYield (); // suspend thread
-
}
-
}
-
-
void Thread_EventReceiver (void *argument)
-
{
-
uint32_t flags;
+
void Thread_EventReceiver (void *argument) {
+
uint32_t flags;
while (1) {
-
flags = osEventFlagsWait (evt_id,FLAGS_MSK1,osFlagsWaitAny, osWaitForever);
+
flags = osEventFlagsWait(evt_id, 0x00000001U, osFlagsWaitAny, osWaitForever);
//handle event
}
}
@@ -598,8 +581,8 @@ size of provided memory for control block

The size of the memory block passed

  • osOK: the specified event flags object has been deleted.
  • osErrorISR: osEventFlagsDelete cannot be called from interrupt service routines.
  • -
  • osErrorParameter: the value of the parameter ef_id is incorrect.
  • -
  • osErrorResource: parameter ef_id is NULL or wrong.
  • +
  • osErrorParameter: parameter ef_id is NULL or invalid.
  • +
  • osErrorResource: the event flags object is in an invalid state.
Note
This function cannot be called from Interrupt Service Routines.
@@ -628,11 +611,15 @@ size of provided memory for control block

The size of the memory block passed

The function osEventFlagsGetName returns the pointer to the name string of the event flags object identified by parameter ef_id or NULL in case of an error.

Note
This function cannot be called from Interrupt Service Routines.

Code Example

-
void EvtFlagsGetName_example (void) {
-
char id; // id of the event flags object
+
#include "cmsis_os2.h" // CMSIS RTOS header file
+
+
osEventFlagsId_t evt_id; // event flasg id
+
+
void EvtFlagsGetName_example (void) {
+
char *name;
- -
if (id == NULL) {
+
name = osEventFlagsGetName(evt_id);
+
if (name == NULL) {
// Failed to get the event flags object name
}
}
@@ -644,7 +631,7 @@ size of provided memory for control block

The size of the memory block passed