diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 1997-07-31 22:13:29 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 1997-07-31 22:13:29 +0000 |
commit | 0074691a67f857c9b3f880fb581e0af1d5673337 (patch) | |
tree | f80fd23129ad62236ee4f64eeaf537f53bbaa0b8 /c/src/lib/include/rtems++/rtemsEvent.h | |
parent | Merged very large and much appreciated patch from Chris Johns (diff) | |
download | rtems-0074691a67f857c9b3f880fb581e0af1d5673337.tar.bz2 |
Merged very large and much appreciated patch from Chris Johns
<cjohns@plessey.com.au>. This patch includes the ods68302 bsp,
the RTEMS++ class library, and the rtems++ test.
Diffstat (limited to 'c/src/lib/include/rtems++/rtemsEvent.h')
-rw-r--r-- | c/src/lib/include/rtems++/rtemsEvent.h | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/c/src/lib/include/rtems++/rtemsEvent.h b/c/src/lib/include/rtems++/rtemsEvent.h new file mode 100644 index 0000000000..3cc19eeb32 --- /dev/null +++ b/c/src/lib/include/rtems++/rtemsEvent.h @@ -0,0 +1,127 @@ +/* + ------------------------------------------------------------------------ + $Id$ + ------------------------------------------------------------------------ + + COPYRIGHT (c) 1997 + Objective Design Systems Ltd Pty (ODS) + All rights reserved (R) Objective Design Systems Ltd Pty + + The license and distribution terms for this file may be found in the + file LICENSE in this distribution or at + http://www.OARcorp.com/rtems/license.html. + + ------------------------------------------------------------------------ + + rtemsEvent class. + + This class allows the user to send and receive RTEMS events to a task. + + ------------------------------------------------------------------------ */ + +#if !defined(_rtemsEvent_h_) +#define _rtemsEvent_h_ + +#include <rtems++/rtemsStatusCode.h> +#include <rtems++/rtemsTask.h> + +/* ---- + rtemsEvent +*/ + +class rtemsEvent + : public rtemsStatusCode +{ +public: + // attribute a task can have + + enum WaitMode { wait = RTEMS_WAIT, + no_wait = RTEMS_NO_WAIT}; + enum Condition { any = RTEMS_EVENT_ANY, + all = RTEMS_EVENT_ALL}; + + // only the first 4 characters of the name are taken + + // connect to a task + rtemsEvent(const char* name, rtems_unsigned32 node = RTEMS_SEARCH_ALL_NODES); + + // copy and default constructors + rtemsEvent(const rtemsEvent& event); + rtemsEvent(); + + virtual ~rtemsEvent(); + + // connect to an existing task object, will not be the owner + const rtemsEvent& operator=(const rtemsEvent& event); + virtual const rtems_status_code connect(const char *name, + const rtems_unsigned32 node = RTEMS_SEARCH_ALL_NODES); + + // send an event + inline const rtems_status_code send(const rtems_id task, + const rtems_event_set events); + inline const rtems_status_code send(const rtemsTask& task, + const rtems_event_set events) ; + inline const rtems_status_code send(const rtems_event_set events); + + // receive an event, can block a task if no events waiting + inline const rtems_status_code receive(const rtems_event_set event_in, + rtems_event_set& event_out, + const rtems_interval micro_secs = 0, + const WaitMode wait = wait, + const Condition condition = any); + + // object id, and name + const rtems_id task_id_is() const { return id; } + const rtems_name task_name_is() const { return name; } + +private: + // task name + rtems_name name; + + // the rtems task id, object handle + rtems_id id; + +}; + +const rtems_status_code rtemsEvent::send(const rtems_id task, + const rtems_event_set events) +{ + set_status_code(rtems_event_send(task, events)); + return last_status_code(); +} + +const rtems_status_code rtemsEvent::send(const rtemsTask& task, + const rtems_event_set events) +{ + set_status_code(rtems_event_send(task.id_is(), events)); + return last_status_code(); +} + +const rtems_status_code rtemsEvent::send(const rtems_event_set events) +{ + set_status_code(rtems_event_send(id, events)); + return last_status_code(); +} + +const rtems_status_code rtemsEvent::receive(const rtems_event_set event_in, + rtems_event_set& event_out, + const rtems_interval micro_secs, + const WaitMode wait, + const Condition condition) +{ + rtems_interval usecs = + micro_secs && (micro_secs < _TOD_Microseconds_per_tick) ? + _TOD_Microseconds_per_tick : micro_secs; + set_status_code(rtems_event_receive(event_in, + wait | condition, + TOD_MICROSECONDS_TO_TICKS(usecs), + &event_out)); + return last_status_code(); +} + +#endif // _rtemsEvent_h_ + + + + + |