aboutsummaryrefslogtreecommitdiffstats
path: root/src/include
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2008-11-08 10:58:59 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2008-11-08 10:58:59 +0000
commit9336c1fc9fdae776126295737131d0a22b2f05b8 (patch)
tree4b49edb25b0478c4b82583a4f8241f0896094cc5 /src/include
parent86acf7daf6a6f867964e7d736b21ee923ab66ebe (diff)
downloadChibiOS-9336c1fc9fdae776126295737131d0a22b2f05b8.tar.gz
ChibiOS-9336c1fc9fdae776126295737131d0a22b2f05b8.tar.bz2
ChibiOS-9336c1fc9fdae776126295737131d0a22b2f05b8.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@501 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'src/include')
-rw-r--r--src/include/events.h41
-rw-r--r--src/include/threads.h19
2 files changed, 50 insertions, 10 deletions
diff --git a/src/include/events.h b/src/include/events.h
index 28134d483..47d898dad 100644
--- a/src/include/events.h
+++ b/src/include/events.h
@@ -81,20 +81,55 @@ extern "C" {
#endif
void chEvtRegister(EventSource *esp, EventListener *elp, eventid_t eid);
void chEvtUnregister(EventSource *esp, EventListener *elp);
- void chEvtClear(eventmask_t mask);
+ eventmask_t chEvtClear(eventmask_t mask);
+ eventmask_t chEvtPend(eventmask_t mask);
+ eventmask_t chEvtWaitOneTimeout(eventmask_t ewmask, systime_t time);
+ eventmask_t chEvtWaitAnyTimeout(eventmask_t ewmask, systime_t time);
+ eventmask_t chEvtWaitAllTimeout(eventmask_t ewmask, systime_t time);
void chEvtBroadcast(EventSource *esp);
void chEvtBroadcastI(EventSource *esp);
eventid_t chEvtWait(eventmask_t ewmask,
const evhandler_t handlers[]);
-#ifdef CH_USE_EVENTS_TIMEOUT
eventid_t chEvtWaitTimeout(eventmask_t ewmask,
const evhandler_t handlers[],
systime_t time);
-#endif
#ifdef __cplusplus
}
#endif
+/**
+ * A pending event among those specified in \p ewmask is selected, cleared and
+ * its mask returned.
+ * @param ewmask mask of the events that the function should wait for,
+ * \p ALL_EVENTS enables all the events
+ * @return The mask of the lowest id served and cleared event.
+ * @note Only a single event is served in the function, the one with the
+ * lowest event id. The function is meant to be invoked into a loop in
+ * order to serve all the pending events.<br>
+ * This means that Event Listeners with a lower event identifier have
+ * an higher priority.
+ */
+#define chEvtWaitOne(ewmask) chEvtWaitOneTimeout(ewmask, TIME_INFINITE)
+
+/**
+ * Waits for any of the specified events.
+ * The function waits for any event among those specified in \p ewmask to
+ * become pending then the events are cleared and returned.
+ * @param ewmask mask of the events that the function should wait for,
+ * \p ALL_EVENTS enables all the events
+ * @return The mask of the served and cleared events.
+ */
+#define chEvtWaitAny(ewmask) chEvtWaitAnyTimeout(ewmask, TIME_INFINITE)
+
+/**
+ * Waits for all the specified event flags then clears them.
+ * The function waits for all the events specified in \p ewmask to become
+ * pending then the events are cleared and returned.
+ * @param ewmask mask of the event ids that the function should wait for
+ * @return The mask of the served and cleared events.
+ */
+#define chEvtWaitAll(ewmask) chEvtWaitAllTimeout(ewmask, TIME_INFINITE)
+
/*
* Old function names, deprecated, will be removed in some next release.
*/
diff --git a/src/include/threads.h b/src/include/threads.h
index ba136ee85..a0b0b362b 100644
--- a/src/include/threads.h
+++ b/src/include/threads.h
@@ -127,17 +127,22 @@ struct Thread {
/** Thread state: Waiting on a mutex. */
#define PRWTMTX 4
/** Thread state: Waiting in \p chThdSleep() or \p chThdSleepUntil(). */
-#define PRSLEEP 5
+#define PRWTCOND 5
+/** Thread state: Waiting in \p chCondWait(). */
+#define PRSLEEP 6
/** Thread state: Waiting in \p chThdWait(). */
-#define PRWAIT 6
-/** Thread state: Waiting in \p chEvtWait(). */
-#define PRWTEVENT 7
+#define PRWAIT 7
+/** Thread state: Waiting in \p chEvtWaitOneTimeout() or
+ \p chEvtWaitAnyTimeout(). */
+#define PRWTOREVT 8
+/** Thread state: Waiting in \p chEvtWaitAllTimeout(). */
+#define PRWTANDEVT 9
/** Thread state: Waiting in \p chMsgSend(). */
-#define PRSNDMSG 8
+#define PRSNDMSG 10
/** Thread state: Waiting in \p chMsgWait(). */
-#define PRWTMSG 9
+#define PRWTMSG 11
/** Thread state: After termination.*/
-#define PREXIT 10
+#define PREXIT 12
/*
* Various flags into the thread p_flags field.