Mistake on this page?
Report an issue in GitHub or email us

EventFlags

The EventFlags class is a C++ wrapper over the Keil RTX EventFlags functionality. The EventFlags class provides a mechanism for setting and waiting for flags. It provides a generic way of notifying other threads about conditions or events. You can think of each instance of the EventFlags class as an event channel. There are 31 different flags available for each event. For more information and implementation details, see the Keil CMSIS-RTOS documentation.

EventFlag class reference

Public Member Functions
 EventFlags ()
 EventFlags (const char *name)
uint32_t set (uint32_t flags)
uint32_t clear (uint32_t flags=0x7fffffff)
uint32_t get () const
uint32_t wait_all (uint32_t flags=0, uint32_t timeout=osWaitForever, bool clear=true)
uint32_t wait_any (uint32_t flags=0, uint32_t timeout=osWaitForever, bool clear=true)

EventFlags example

Below is an example of EventFlags usage, where one thread is generating events every 1s, and the second thread is waiting for the events and executing some action.

#include "mbed.h"

EventFlags event;

void worker_f()
{
    while (true) {
        event.wait_all(0x1);

        printf("Got signal!\r\n");
    }
}

int main()
{
    Thread worker;

    worker.start(callback(worker_f));

    while (true) {
        wait(1);
        event.set(0x1);
    }
}
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.