Arm Mbed OS support forum

Are we able to reuse Event flag?

Hi there

Would like to ask if we are able to reuse the Eventflag to execute the function again after the flag is set from the first call? or it can only be done once ?

Hello Rosey,

Yes, we can reuse EventFlags. To employ that the wait_... group of member functions has a clear parameter. The default value is true but we can pass a false if we want to keep the flags after waiting for them:

    /** Wait for all of the specified event flags to become signaled.
      @param   flags    the flags to wait for (default: 0 -- no flags).
      @param   millisec timeout value (default: osWaitForever).
      @param   clear    clear specified event flags after waiting for them (default: true).
      @return  event flags before clearing or error code if highest bit set (see @a osFlagsError for details).

      @note You may call this function from ISR context if the millisec parameter is set to 0.
    uint32_t wait_all(uint32_t flags = 0, uint32_t millisec = osWaitForever, bool clear = true);

There are 31 different flags available for each eventflag.