OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [librtems++/] [include/] [rtems++/] [rtemsEvent.h] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
2
  ------------------------------------------------------------------------
3
  $Id: rtemsEvent.h,v 1.2 2001-09-27 12:02:05 chris Exp $
4
  ------------------------------------------------------------------------
5
 
6
  COPYRIGHT (c) 1997
7
  Objective Design Systems Ltd Pty (ODS)
8
  All rights reserved (R) Objective Design Systems Ltd Pty
9
 
10
  The license and distribution terms for this file may be found in the
11
  file LICENSE in this distribution or at
12
  http://www.OARcorp.com/rtems/license.html.
13
 
14
  ------------------------------------------------------------------------
15
 
16
  rtemsEvent class.
17
 
18
  This class allows the user to send and receive RTEMS events to a task.
19
 
20
  ------------------------------------------------------------------------ */
21
 
22
#if !defined(_rtemsEvent_h_)
23
#define _rtemsEvent_h_
24
 
25
#include <rtems++/rtemsStatusCode.h>
26
#include <rtems++/rtemsTask.h>
27
 
28
/* ----
29
    rtemsEvent
30
*/
31
 
32
class rtemsEvent
33
  : public rtemsStatusCode
34
{
35
public:
36
  // attribute a task can have
37
 
38
  enum WaitMode { wait = RTEMS_WAIT,
39
                  no_wait = RTEMS_NO_WAIT};
40
  enum Condition { any = RTEMS_EVENT_ANY,
41
                   all = RTEMS_EVENT_ALL};
42
 
43
  // only the first 4 characters of the name are taken  
44
 
45
  // connect to a task
46
  rtemsEvent(const char* name, rtems_unsigned32 node = RTEMS_SEARCH_ALL_NODES);
47
 
48
  // copy and default constructors
49
  rtemsEvent(const rtemsEvent& event);
50
  rtemsEvent();
51
 
52
  virtual ~rtemsEvent();
53
 
54
  // connect to an existing task object, will not be the owner
55
  const rtemsEvent& operator=(const rtemsEvent& event);
56
  virtual const rtems_status_code connect(const char *name,
57
                                          const rtems_unsigned32 node = RTEMS_SEARCH_ALL_NODES);
58
 
59
  // send an event
60
  inline const rtems_status_code send(const rtems_id task,
61
                                      const rtems_event_set events);
62
  inline const rtems_status_code send(const rtemsTask& task,
63
                                      const rtems_event_set events) ;
64
  inline const rtems_status_code send(const rtems_event_set events);
65
 
66
  // receive an event, can block a task if no events waiting
67
  inline const rtems_status_code receive(const rtems_event_set event_in,
68
                                         rtems_event_set& event_out,
69
                                         const rtems_interval micro_secs = 0,
70
                                         const WaitMode wait = wait,
71
                                         const Condition condition = any);
72
 
73
  // object id, and name
74
  const rtems_id task_id_is() const { return id; }
75
  const rtems_name task_name_is() const { return name; }
76
 
77
private:
78
  // task name
79
  rtems_name name;
80
 
81
  // the rtems task id, object handle
82
  rtems_id id;
83
 
84
};
85
 
86
const rtems_status_code rtemsEvent::send(const rtems_id task,
87
                                         const rtems_event_set events)
88
{
89
  set_status_code(rtems_event_send(task, events));
90
  return last_status_code();
91
}
92
 
93
const rtems_status_code rtemsEvent::send(const rtemsTask& task,
94
                                         const rtems_event_set events)
95
{
96
  set_status_code(rtems_event_send(task.id_is(), events));
97
  return last_status_code();
98
}
99
 
100
const rtems_status_code rtemsEvent::send(const rtems_event_set events)
101
{
102
  set_status_code(rtems_event_send(id, events));
103
  return last_status_code();
104
}
105
 
106
const rtems_status_code rtemsEvent::receive(const rtems_event_set event_in,
107
                                            rtems_event_set& event_out,
108
                                            const rtems_interval micro_secs,
109
                                            const WaitMode wait,
110
                                            const Condition condition)
111
{
112
  rtems_interval usecs =
113
    micro_secs && (micro_secs < _TOD_Microseconds_per_tick) ?
114
    _TOD_Microseconds_per_tick : micro_secs;
115
  set_status_code(rtems_event_receive(event_in,
116
                                      wait | condition,
117
                                      TOD_MICROSECONDS_TO_TICKS(usecs),
118
                                      &event_out));
119
  return last_status_code();
120
}
121
 
122
#endif  // _rtemsEvent_h_
123
 
124
 
125
 
126
 
127
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.