##### Synopsis

    #include <ctl_api.h>
    unsigned ctl_events_wait(CTL_EVENT_WAIT_TYPE_t waitType,
                             CTL_EVENT_SET_t *eventSet,
                             CTL_EVENT_SET_t events,
                             unsigned use_timeout,
                             CTL_TIME_t timeout);

##### Description

The ctl_events_wait function waits for events to be set (value 1) in *eventSet with an optional timeout applied if use_timeout is non-zero.

The waitType can be one of the following:

- CTL_EVENT_WAIT_ANY_EVENTS — wait for any of the events in *eventSet to be set.
- CTL_EVENT_WAIT_ANY_EVENTS_WITH_AUTO_CLEAR — wait for any of the events in *eventSet to be set and reset (value 0) them.
- CTL_EVENT_WAIT_ALL_EVENTS — wait for all of the events in *eventSet to be set.
- CTL_EVENT_WAIT_ALL_EVENTS_WITH_AUTO_CLEAR — wait for all of the events in *eventSet to be set and reset (value 0) them.

The ctl_events_wait function returns the *eventSet value before any auto clearing occurred or zero if the timeout occured.

##### Restrictions

This function should not be called from an interrupt service routine.

##### Portability

ctl_events_wait is provided in every implementation of the CrossWorks tasking library.

###### See Also

Event Sets