2009-08-16 13:07:24 +00:00
|
|
|
/*
|
2010-02-21 07:24:53 +00:00
|
|
|
ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio.
|
2009-08-16 13:07:24 +00:00
|
|
|
|
|
|
|
This file is part of ChibiOS/RT.
|
|
|
|
|
|
|
|
ChibiOS/RT is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
ChibiOS/RT is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2010-02-06 10:55:53 +00:00
|
|
|
* @file chevents.c
|
|
|
|
* @brief Events code.
|
|
|
|
*
|
2009-08-30 06:59:43 +00:00
|
|
|
* @addtogroup events
|
2009-08-16 13:07:24 +00:00
|
|
|
* @{
|
|
|
|
*/
|
2009-12-08 17:37:49 +00:00
|
|
|
#include "ch.h"
|
2009-08-16 13:07:24 +00:00
|
|
|
|
|
|
|
#if CH_USE_EVENTS
|
|
|
|
/**
|
2010-02-06 10:55:53 +00:00
|
|
|
* @brief Registers an Event Listener on an Event Source.
|
|
|
|
* @note Multiple Event Listeners can specify the same bits to be pended.
|
2009-08-16 13:07:24 +00:00
|
|
|
*
|
2010-02-06 10:55:53 +00:00
|
|
|
* @param[in] esp pointer to the @p EventSource structure
|
|
|
|
* @param[in] elp pointer to the @p EventListener structure
|
|
|
|
* @param[in] mask the mask of event flags to be pended to the thread when
|
|
|
|
* the event source is broadcasted
|
2009-08-16 13:07:24 +00:00
|
|
|
*/
|
2010-02-06 10:55:53 +00:00
|
|
|
void chEvtRegisterMask(EventSource *esp, EventListener *elp, eventmask_t mask) {
|
2009-08-16 13:07:24 +00:00
|
|
|
|
|
|
|
chDbgCheck((esp != NULL) && (elp != NULL), "chEvtRegisterMask");
|
|
|
|
|
|
|
|
chSysLock();
|
|
|
|
elp->el_next = esp->es_next;
|
|
|
|
esp->es_next = elp;
|
|
|
|
elp->el_listener = currp;
|
2010-02-06 10:55:53 +00:00
|
|
|
elp->el_mask = mask;
|
2009-08-16 13:07:24 +00:00
|
|
|
chSysUnlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-02-06 10:55:53 +00:00
|
|
|
* @brief Unregisters an Event Listener from its Event Source.
|
|
|
|
* @note If the event listener is not registered on the specified event
|
|
|
|
* source then the function does nothing.
|
|
|
|
* @note For optimal performance it is better to perform the unregister
|
|
|
|
* operations in inverse order of the register operations (elements
|
|
|
|
* are found on top of the list).
|
2009-08-16 13:07:24 +00:00
|
|
|
*
|
2010-02-06 10:55:53 +00:00
|
|
|
* @param[in] esp pointer to the @p EventSource structure
|
|
|
|
* @param[in] elp pointer to the @p EventListener structure
|
2009-08-16 13:07:24 +00:00
|
|
|
*/
|
|
|
|
void chEvtUnregister(EventSource *esp, EventListener *elp) {
|
|
|
|
EventListener *p;
|
|
|
|
|
|
|
|
chDbgCheck((esp != NULL) && (elp != NULL), "chEvtUnregister");
|
|
|
|
|
|
|
|
p = (EventListener *)esp;
|
|
|
|
chSysLock();
|
|
|
|
while (p->el_next != (EventListener *)esp) {
|
|
|
|
if (p->el_next == elp) {
|
|
|
|
p->el_next = elp->el_next;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
p = p->el_next;
|
|
|
|
}
|
|
|
|
chSysUnlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-02-06 10:55:53 +00:00
|
|
|
* @brief Clears the pending events specified in the mask.
|
2009-08-16 13:07:24 +00:00
|
|
|
*
|
2010-02-06 10:55:53 +00:00
|
|
|
* @param[in] mask the events to be cleared
|
|
|
|
* @return The pending events that were cleared.
|
2009-08-16 13:07:24 +00:00
|
|
|
*/
|
|
|
|
eventmask_t chEvtClear(eventmask_t mask) {
|
|
|
|
eventmask_t m;
|
|
|
|
|
|
|
|
chSysLock();
|
|
|
|
|
|
|
|
m = currp->p_epending & mask;
|
|
|
|
currp->p_epending &= ~mask;
|
|
|
|
|
|
|
|
chSysUnlock();
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-02-06 10:55:53 +00:00
|
|
|
* @brief Pends a set of event flags on the current thread, this is @b much
|
|
|
|
* faster than using @p chEvtBroadcast() or @p chEvtSignal().
|
2009-08-16 13:07:24 +00:00
|
|
|
*
|
2010-02-06 10:55:53 +00:00
|
|
|
* @param[in] mask the events to be pended
|
|
|
|
* @return The current pending events mask.
|
2009-08-16 13:07:24 +00:00
|
|
|
*/
|
|
|
|
eventmask_t chEvtPend(eventmask_t mask) {
|
|
|
|
|
|
|
|
chSysLock();
|
|
|
|
|
|
|
|
mask = (currp->p_epending |= mask);
|
|
|
|
|
|
|
|
chSysUnlock();
|
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-02-06 10:55:53 +00:00
|
|
|
* @brief Pends a set of event flags on the specified @p Thread.
|
2009-08-16 13:07:24 +00:00
|
|
|
*
|
2010-02-06 10:55:53 +00:00
|
|
|
* @param[in] tp the thread to be signaled
|
|
|
|
* @param[in] mask the event flags set to be pended
|
2009-08-16 13:07:24 +00:00
|
|
|
*/
|
|
|
|
void chEvtSignal(Thread *tp, eventmask_t mask) {
|
|
|
|
|
|
|
|
chDbgCheck(tp != NULL, "chEvtSignal");
|
|
|
|
|
|
|
|
chSysLock();
|
|
|
|
chEvtSignalI(tp, mask);
|
|
|
|
chSysUnlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-02-06 10:55:53 +00:00
|
|
|
* @brief Pends a set of event flags on the specified @p Thread.
|
2009-08-16 13:07:24 +00:00
|
|
|
*
|
2010-02-06 10:55:53 +00:00
|
|
|
* @param[in] tp the thread to be signaled
|
|
|
|
* @param[in] mask the event flags set to be pended
|
2009-08-16 13:07:24 +00:00
|
|
|
*/
|
|
|
|
void chEvtSignalI(Thread *tp, eventmask_t mask) {
|
|
|
|
|
|
|
|
chDbgCheck(tp != NULL, "chEvtSignalI");
|
|
|
|
|
|
|
|
tp->p_epending |= mask;
|
|
|
|
/* Test on the AND/OR conditions wait states.*/
|
2010-01-20 14:39:34 +00:00
|
|
|
if (((tp->p_state == THD_STATE_WTOREVT) &&
|
|
|
|
((tp->p_epending & tp->p_u.ewmask) != 0)) ||
|
|
|
|
((tp->p_state == THD_STATE_WTANDEVT) &&
|
|
|
|
((tp->p_epending & tp->p_u.ewmask) == tp->p_u.ewmask)))
|
|
|
|
chSchReadyI(tp)->p_u.rdymsg = RDY_OK;
|
2009-08-16 13:07:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-02-06 10:55:53 +00:00
|
|
|
* @brief Signals all the Event Listeners registered on the specified Event
|
|
|
|
* Source.
|
2009-08-16 13:07:24 +00:00
|
|
|
*
|
2010-02-06 10:55:53 +00:00
|
|
|
* @param[in] esp pointer to the @p EventSource structure
|
2009-08-16 13:07:24 +00:00
|
|
|
*/
|
|
|
|
void chEvtBroadcast(EventSource *esp) {
|
|
|
|
|
|
|
|
chSysLock();
|
|
|
|
chEvtBroadcastI(esp);
|
|
|
|
chSchRescheduleS();
|
|
|
|
chSysUnlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-02-06 10:55:53 +00:00
|
|
|
* @brief Signals all the Event Listeners registered on the specified Event
|
|
|
|
* Source.
|
2009-08-16 13:07:24 +00:00
|
|
|
*
|
2010-02-06 10:55:53 +00:00
|
|
|
* @param[in] esp pointer to the @p EventSource structure
|
2009-08-16 13:07:24 +00:00
|
|
|
*/
|
|
|
|
void chEvtBroadcastI(EventSource *esp) {
|
|
|
|
EventListener *elp;
|
|
|
|
|
|
|
|
chDbgCheck(esp != NULL, "chEvtBroadcastI");
|
|
|
|
|
|
|
|
elp = esp->es_next;
|
|
|
|
while (elp != (EventListener *)esp) {
|
|
|
|
chEvtSignalI(elp->el_listener, elp->el_mask);
|
|
|
|
elp = elp->el_next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-02-06 10:55:53 +00:00
|
|
|
* @brief Invokes the event handlers associated to an event flags mask.
|
2009-08-16 13:07:24 +00:00
|
|
|
*
|
2010-02-06 10:55:53 +00:00
|
|
|
* @param[in] mask mask of the events to be dispatched
|
|
|
|
* @param[in] handlers an array of @p evhandler_t. The array must have size
|
|
|
|
* equal to the number of bits in eventmask_t.
|
2009-08-16 13:07:24 +00:00
|
|
|
*/
|
2010-02-24 10:41:11 +00:00
|
|
|
void chEvtDispatch(const evhandler_t *handlers, eventmask_t mask) {
|
2009-08-16 13:07:24 +00:00
|
|
|
eventid_t eid;
|
|
|
|
|
|
|
|
chDbgCheck(handlers != NULL, "chEvtDispatch");
|
|
|
|
|
|
|
|
eid = 0;
|
|
|
|
while (mask) {
|
|
|
|
if (mask & EVENT_MASK(eid)) {
|
|
|
|
chDbgAssert(handlers[eid] != NULL,
|
|
|
|
"chEvtDispatch(), #1",
|
|
|
|
"null handler");
|
|
|
|
mask &= ~EVENT_MASK(eid);
|
|
|
|
handlers[eid](eid);
|
|
|
|
}
|
|
|
|
eid++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if CH_OPTIMIZE_SPEED || !CH_USE_EVENTS_TIMEOUT || defined(__DOXYGEN__)
|
|
|
|
/**
|
2010-02-06 10:55:53 +00:00
|
|
|
* @brief Waits for exactly one of the specified events.
|
2009-08-16 13:07:24 +00:00
|
|
|
* @details The function waits for one event among those specified in
|
2010-02-06 10:55:53 +00:00
|
|
|
* @p mask to become pending then the event is cleared and returned.
|
|
|
|
* @note One and only one 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.
|
2009-08-16 13:07:24 +00:00
|
|
|
*
|
2010-02-06 10:55:53 +00:00
|
|
|
* @param[in] mask 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.
|
2009-08-16 13:07:24 +00:00
|
|
|
*/
|
2010-02-06 10:55:53 +00:00
|
|
|
eventmask_t chEvtWaitOne(eventmask_t mask) {
|
2010-01-21 19:57:30 +00:00
|
|
|
Thread *ctp = currp;
|
2009-08-16 13:07:24 +00:00
|
|
|
eventmask_t m;
|
|
|
|
|
|
|
|
chSysLock();
|
|
|
|
|
2010-02-06 10:55:53 +00:00
|
|
|
if ((m = (ctp->p_epending & mask)) == 0) {
|
|
|
|
ctp->p_u.ewmask = mask;
|
2010-01-20 14:39:34 +00:00
|
|
|
chSchGoSleepS(THD_STATE_WTOREVT);
|
2010-02-06 10:55:53 +00:00
|
|
|
m = ctp->p_epending & mask;
|
2009-08-16 13:07:24 +00:00
|
|
|
}
|
|
|
|
m &= -m;
|
2010-01-21 19:57:30 +00:00
|
|
|
ctp->p_epending &= ~m;
|
2009-08-16 13:07:24 +00:00
|
|
|
|
|
|
|
chSysUnlock();
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-02-06 10:55:53 +00:00
|
|
|
* @brief Waits for any of the specified events.
|
2009-08-16 13:07:24 +00:00
|
|
|
* @details The function waits for any event among those specified in
|
2010-02-06 10:55:53 +00:00
|
|
|
* @p mask to become pending then the events are cleared and returned.
|
2009-08-16 13:07:24 +00:00
|
|
|
*
|
2010-02-06 10:55:53 +00:00
|
|
|
* @param[in] mask 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.
|
2009-08-16 13:07:24 +00:00
|
|
|
*/
|
2010-02-06 10:55:53 +00:00
|
|
|
eventmask_t chEvtWaitAny(eventmask_t mask) {
|
2010-01-21 19:57:30 +00:00
|
|
|
Thread *ctp = currp;
|
2009-08-16 13:07:24 +00:00
|
|
|
eventmask_t m;
|
|
|
|
|
|
|
|
chSysLock();
|
|
|
|
|
2010-02-06 10:55:53 +00:00
|
|
|
if ((m = (ctp->p_epending & mask)) == 0) {
|
|
|
|
ctp->p_u.ewmask = mask;
|
2010-01-20 14:39:34 +00:00
|
|
|
chSchGoSleepS(THD_STATE_WTOREVT);
|
2010-02-06 10:55:53 +00:00
|
|
|
m = ctp->p_epending & mask;
|
2009-08-16 13:07:24 +00:00
|
|
|
}
|
2010-01-21 19:57:30 +00:00
|
|
|
ctp->p_epending &= ~m;
|
2009-08-16 13:07:24 +00:00
|
|
|
|
|
|
|
chSysUnlock();
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-02-06 10:55:53 +00:00
|
|
|
* @brief Waits for all the specified events.
|
|
|
|
* @details The function waits for all the events specified in @p mask to
|
2009-08-16 13:07:24 +00:00
|
|
|
* become pending then the events are cleared and returned.
|
|
|
|
*
|
2010-02-06 10:55:53 +00:00
|
|
|
* @param[in] mask mask of the event ids that the function should wait for
|
|
|
|
* @return The mask of the served and cleared events.
|
2009-08-16 13:07:24 +00:00
|
|
|
*/
|
2010-02-06 10:55:53 +00:00
|
|
|
eventmask_t chEvtWaitAll(eventmask_t mask) {
|
2010-01-21 19:57:30 +00:00
|
|
|
Thread *ctp = currp;
|
2009-08-16 13:07:24 +00:00
|
|
|
|
|
|
|
chSysLock();
|
|
|
|
|
2010-02-06 10:55:53 +00:00
|
|
|
if ((ctp->p_epending & mask) != mask) {
|
|
|
|
ctp->p_u.ewmask = mask;
|
2010-01-20 14:39:34 +00:00
|
|
|
chSchGoSleepS(THD_STATE_WTANDEVT);
|
2009-08-16 13:07:24 +00:00
|
|
|
}
|
2010-02-06 10:55:53 +00:00
|
|
|
ctp->p_epending &= ~mask;
|
2009-08-16 13:07:24 +00:00
|
|
|
|
|
|
|
chSysUnlock();
|
2010-02-06 10:55:53 +00:00
|
|
|
return mask;
|
2009-08-16 13:07:24 +00:00
|
|
|
}
|
|
|
|
#endif /* CH_OPTIMIZE_SPEED || !CH_USE_EVENTS_TIMEOUT */
|
|
|
|
|
|
|
|
#if CH_USE_EVENTS_TIMEOUT
|
|
|
|
/**
|
2010-02-06 10:55:53 +00:00
|
|
|
* @brief Waits for exactly one of the specified events.
|
2009-08-16 13:07:24 +00:00
|
|
|
* @details The function waits for one event among those specified in
|
2010-02-06 10:55:53 +00:00
|
|
|
* @p mask to become pending then the event is cleared and returned.
|
|
|
|
* @note One and only one 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.
|
2009-08-16 13:07:24 +00:00
|
|
|
*
|
2010-02-06 10:55:53 +00:00
|
|
|
* @param[in] mask mask of the events that the function should wait for,
|
|
|
|
* @p ALL_EVENTS enables all the events
|
|
|
|
* @param[in] time the number of ticks before the operation timeouts,
|
|
|
|
* the following special values are allowed:
|
|
|
|
* - @a TIME_IMMEDIATE immediate timeout.
|
|
|
|
* - @a TIME_INFINITE no timeout.
|
|
|
|
* .
|
|
|
|
* @return The mask of the lowest id served and cleared event.
|
|
|
|
* @retval 0 if the specified timeout expired.
|
2009-08-16 13:07:24 +00:00
|
|
|
*/
|
2010-02-06 10:55:53 +00:00
|
|
|
eventmask_t chEvtWaitOneTimeout(eventmask_t mask, systime_t time) {
|
2010-01-21 19:57:30 +00:00
|
|
|
Thread *ctp = currp;
|
2009-08-16 13:07:24 +00:00
|
|
|
eventmask_t m;
|
|
|
|
|
|
|
|
chSysLock();
|
|
|
|
|
2010-02-06 10:55:53 +00:00
|
|
|
if ((m = (ctp->p_epending & mask)) == 0) {
|
2009-08-16 13:07:24 +00:00
|
|
|
if (TIME_IMMEDIATE == time)
|
|
|
|
return (eventmask_t)0;
|
2010-02-06 10:55:53 +00:00
|
|
|
ctp->p_u.ewmask = mask;
|
2010-01-20 14:39:34 +00:00
|
|
|
if (chSchGoSleepTimeoutS(THD_STATE_WTOREVT, time) < RDY_OK)
|
2009-08-16 13:07:24 +00:00
|
|
|
return (eventmask_t)0;
|
2010-02-06 10:55:53 +00:00
|
|
|
m = ctp->p_epending & mask;
|
2009-08-16 13:07:24 +00:00
|
|
|
}
|
|
|
|
m &= -m;
|
2010-01-21 19:57:30 +00:00
|
|
|
ctp->p_epending &= ~m;
|
2009-08-16 13:07:24 +00:00
|
|
|
|
|
|
|
chSysUnlock();
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-02-06 10:55:53 +00:00
|
|
|
* @brief Waits for any of the specified events.
|
2009-08-16 13:07:24 +00:00
|
|
|
* @details The function waits for any event among those specified in
|
2010-02-06 10:55:53 +00:00
|
|
|
* @p mask to become pending then the events are cleared and
|
2009-08-16 13:07:24 +00:00
|
|
|
* returned.
|
|
|
|
*
|
2010-02-06 10:55:53 +00:00
|
|
|
* @param[in] mask mask of the events that the function should wait for,
|
|
|
|
* @p ALL_EVENTS enables all the events
|
|
|
|
* @param[in] time the number of ticks before the operation timeouts,
|
|
|
|
* the following special values are allowed:
|
|
|
|
* - @a TIME_IMMEDIATE immediate timeout.
|
|
|
|
* - @a TIME_INFINITE no timeout.
|
|
|
|
* .
|
|
|
|
* @return The mask of the served and cleared events.
|
|
|
|
* @retval 0 if the specified timeout expired.
|
2009-08-16 13:07:24 +00:00
|
|
|
*/
|
2010-02-06 10:55:53 +00:00
|
|
|
eventmask_t chEvtWaitAnyTimeout(eventmask_t mask, systime_t time) {
|
2010-01-21 19:57:30 +00:00
|
|
|
Thread *ctp = currp;
|
2009-08-16 13:07:24 +00:00
|
|
|
eventmask_t m;
|
|
|
|
|
|
|
|
chSysLock();
|
|
|
|
|
2010-02-06 10:55:53 +00:00
|
|
|
if ((m = (ctp->p_epending & mask)) == 0) {
|
2009-08-16 13:07:24 +00:00
|
|
|
if (TIME_IMMEDIATE == time)
|
|
|
|
return (eventmask_t)0;
|
2010-02-06 10:55:53 +00:00
|
|
|
ctp->p_u.ewmask = mask;
|
2010-01-20 14:39:34 +00:00
|
|
|
if (chSchGoSleepTimeoutS(THD_STATE_WTOREVT, time) < RDY_OK)
|
2009-08-16 13:07:24 +00:00
|
|
|
return (eventmask_t)0;
|
2010-02-06 10:55:53 +00:00
|
|
|
m = ctp->p_epending & mask;
|
2009-08-16 13:07:24 +00:00
|
|
|
}
|
2010-01-21 19:57:30 +00:00
|
|
|
ctp->p_epending &= ~m;
|
2009-08-16 13:07:24 +00:00
|
|
|
|
|
|
|
chSysUnlock();
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-02-06 10:55:53 +00:00
|
|
|
* @brief Waits for all the specified events.
|
|
|
|
* @details The function waits for all the events specified in @p mask to
|
2009-08-16 13:07:24 +00:00
|
|
|
* become pending then the events are cleared and returned.
|
|
|
|
*
|
2010-02-06 10:55:53 +00:00
|
|
|
* @param[in] mask mask of the event ids that the function should wait for
|
|
|
|
* @param[in] time the number of ticks before the operation timeouts,
|
|
|
|
* the following special values are allowed:
|
|
|
|
* - @a TIME_IMMEDIATE immediate timeout.
|
|
|
|
* - @a TIME_INFINITE no timeout.
|
|
|
|
* .
|
|
|
|
* @return The mask of the served and cleared events.
|
|
|
|
* @retval 0 if the specified timeout expired.
|
2009-08-16 13:07:24 +00:00
|
|
|
*/
|
2010-02-06 10:55:53 +00:00
|
|
|
eventmask_t chEvtWaitAllTimeout(eventmask_t mask, systime_t time) {
|
2010-01-21 19:57:30 +00:00
|
|
|
Thread *ctp = currp;
|
2009-08-16 13:07:24 +00:00
|
|
|
|
|
|
|
chSysLock();
|
|
|
|
|
2010-02-06 10:55:53 +00:00
|
|
|
if ((ctp->p_epending & mask) != mask) {
|
2009-08-16 13:07:24 +00:00
|
|
|
if (TIME_IMMEDIATE == time)
|
|
|
|
return (eventmask_t)0;
|
2010-02-06 10:55:53 +00:00
|
|
|
ctp->p_u.ewmask = mask;
|
2010-01-20 14:39:34 +00:00
|
|
|
if (chSchGoSleepTimeoutS(THD_STATE_WTANDEVT, time) < RDY_OK)
|
2009-08-16 13:07:24 +00:00
|
|
|
return (eventmask_t)0;
|
|
|
|
}
|
2010-02-06 10:55:53 +00:00
|
|
|
ctp->p_epending &= ~mask;
|
2009-08-16 13:07:24 +00:00
|
|
|
|
|
|
|
chSysUnlock();
|
2010-02-06 10:55:53 +00:00
|
|
|
return mask;
|
2009-08-16 13:07:24 +00:00
|
|
|
}
|
|
|
|
#endif /* CH_USE_EVENTS_TIMEOUT */
|
|
|
|
|
|
|
|
#endif /* CH_USE_EVENTS */
|
|
|
|
|
|
|
|
/** @} */
|