An event flag is a bitmask. Waiting tasks can specify a subset of the bitmask as events of interest. They can either wait for ALL of the events to occur or ANY of the events to occur.
NOTE: Always initialize before use.
eflag_t notification; // Previously initialized #define ALERT0 0x01 #define ALERT1 0x02 void task1(void *dummy) { int8_t rc; while(1) { rc = eflag_wait( ¬ification, ALERT0, 0, 0, ); if (rc == SUCCESS) { do_something(); } } } void task2(void *dummy) { int8_t rc; while(1) { // Trigger event rc = eflag_set(¬ification, ALERT0|ALERT1, O_EFLAG_TRIGGER); do_other_stuff(); } } *
Functions | |
void | eflag_init (eflag_t *ef, flag_t initval) |
int8_t | eflag_set (eflag_t *ef, flag_t setbits, uint8_t options) |
flag_t | eflag_get (eflag_t *ef) |
int8_t | eflag_wait (eflag_t *ef, flag_t checkbits, const trtime_t *timeout, uint8_t options) |
Initialize an event flag.
*
Calling Context:
ef | Pointer to the event flag. | |
initval | Initial value for the event flag |
Set an event flag.
Calling Context:
ef | Pointer to the event flag. | |
setbits | The new bitvalues to be set or cleared. | |
options | [O_EFLAG_CLEAR, O_EFLAG_TRIGGER] O_EFLAG_CLEAR : Clear the specified bits. Default is to set them. O_EFLAG_TRIGGER : Just pulse the values in the prescribed fashion. Don't set them permanently. If any of the flag values were set before the trigger, they stay set after the call. |
Peek at the value of an event flag.
This can be used for polling.
Calling Context:
ef | Pointer to the flag. |
Wait for an event flag.
A blocking call from an ISR will result in an error. So, there is usually no need to call this from an ISR. eflag_get may be preferable.
Calling Context:
ef | Pointer to the event flag. | |
checkbits | Bits to be checked. | |
[in] | timeout | Timeout. This can be 0 for infinite timeout. |
options | [O_NONBLOCKING | O_RELATIVE_TIME | O_EFLAG_AND | O_EFLAG_OR ]. |