source: rtems/c/src/librtems++/include/rtems++/rtemsTimer.h @ f68401e

4.115
Last change on this file since f68401e was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 3.9 KB
Line 
1/*
2  ------------------------------------------------------------------------
3
4  COPYRIGHT (c) 1997
5  Objective Design Systems Ltd Pty (ODS)
6  All rights reserved (R) Objective Design Systems Ltd Pty
7
8  The license and distribution terms for this file may be found in the
9  file LICENSE in this distribution or at
10  http://www.rtems.com/license/LICENSE.
11
12  ------------------------------------------------------------------------
13
14  rtemsTimer class.
15
16  This class allows the user to create a RTEMS timer.
17
18  The trigger method is called when the timer expires. The method is
19  called using the thread which calls the RTEMS 'rtems_clock_tick'
20  method.
21
22  Timers are always local to a node.
23
24  ------------------------------------------------------------------------ */
25
26#if !defined(_rtemsTimer_h_)
27#define _rtemsTimer_h_
28
29#include <rtems++/rtemsStatusCode.h>
30
31/* ----
32    rtemsTimer
33*/
34
35class rtemsTimer
36  : public rtemsStatusCode
37{
38public:
39  // only the first 4 characters of the name are taken,
40
41  // create a timer object
42  rtemsTimer(const char* name);
43  rtemsTimer();
44
45  // destroies the actual object
46  virtual ~rtemsTimer();
47
48  // create or destroy (delete) the timer
49  virtual const rtems_status_code create(const char* name);
50  virtual const rtems_status_code destroy();
51
52  // timer control
53  inline const rtems_status_code fire_after(const rtems_interval micro_secs);
54  inline const rtems_status_code repeat_fire_at(const rtems_interval micro_secs);
55  inline const rtems_status_code fire_when(const rtems_time_of_day& when);
56
57  inline const rtems_status_code cancel();
58  inline const rtems_status_code reset();
59
60  // object id, and name
61  const rtems_id id_is() const { return id; }
62  const rtems_name name_is() const { return name; }
63  const char *name_string() const { return name_str; }
64
65protected:
66
67  // triggered method is called when the timer fires
68  virtual void triggered() = 0;
69
70private:
71  // not permitted
72  rtemsTimer(const rtemsTimer& timer);
73  rtemsTimer& operator=(const rtemsTimer& timer);
74
75  // make this object reference an invalid RTEMS object
76  void make_invalid();
77
78  // semaphore name
79  rtems_name name;
80  char name_str[5];
81
82  // repeat true restart the timer when it fires
83  bool repeat;
84
85  // the rtems id, object handle
86  rtems_id id;
87
88  // common timer handler
89  static void common_handler(rtems_id id, void *user_data);
90};
91
92const rtems_status_code rtemsTimer::fire_after(const rtems_interval micro_secs)
93{
94  repeat = false;
95  rtems_interval usecs = micro_secs &&
96    (micro_secs < rtems_configuration_get_microseconds_per_tick()) ?
97    rtems_configuration_get_microseconds_per_tick()  : micro_secs;
98  return set_status_code(rtems_timer_fire_after(id,
99                                                RTEMS_MICROSECONDS_TO_TICKS(usecs),
100                                                common_handler,
101                                                this));
102}
103
104const rtems_status_code rtemsTimer::repeat_fire_at(const rtems_interval micro_secs)
105{
106  repeat = true;
107  rtems_interval usecs = micro_secs &&
108    (micro_secs < rtems_configuration_get_microseconds_per_tick()) ?
109    rtems_configuration_get_microseconds_per_tick()  : micro_secs;
110  return set_status_code(rtems_timer_fire_after(id,
111                                                RTEMS_MICROSECONDS_TO_TICKS(usecs),
112                                                common_handler,
113                                                this));
114}
115
116const rtems_status_code rtemsTimer::fire_when(const rtems_time_of_day& when)
117{
118  return set_status_code(rtems_timer_fire_when(id,
119                                               (rtems_time_of_day*) &when,
120                                               common_handler,
121                                               this));
122}
123
124const rtems_status_code rtemsTimer::cancel()
125{
126  repeat = false;
127  return set_status_code(rtems_timer_cancel(id));
128}
129
130const rtems_status_code rtemsTimer::reset()
131{
132  return set_status_code(rtems_timer_reset(id));
133}
134
135#endif  // _rtemsTimer_h_
Note: See TracBrowser for help on using the repository browser.