source: rtems/c/src/lib/librtems++/rtemsTimer.cc @ 8f35817

4.104.114.84.95
Last change on this file since 8f35817 was 0074691a, checked in by Joel Sherrill <joel.sherrill@…>, on 07/31/97 at 22:13:29

Merged very large and much appreciated patch from Chris Johns
<cjohns@…>. This patch includes the ods68302 bsp,
the RTEMS++ class library, and the rtems++ test.

  • Property mode set to 100644
File size: 1.9 KB
Line 
1/*
2  ------------------------------------------------------------------------
3  $Id$
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  See header file.
17
18  ------------------------------------------------------------------------
19*/
20
21#include <rtems++/rtemsTimer.h>
22
23/* ----
24    rtemsTimer
25*/
26
27rtemsTimer::rtemsTimer(const char* tname)
28  : name(0),
29    repeat(false),
30    id(0)
31{
32  strcpy(name_str, "    ");
33  create(tname);
34}
35
36rtemsTimer::rtemsTimer()
37  : name(0),
38    repeat(false),
39    id(0)
40{
41  strcpy(name_str, "    ");
42}
43
44rtemsTimer::~rtemsTimer()
45{
46  destroy();
47}
48
49void rtemsTimer::make_invalid()
50{
51  strcpy(name_str, "    ");
52  name = 0;
53  id = 0;
54  repeat = false;
55}
56const rtems_status_code rtemsTimer::create(const char* tname)
57{
58  if (id)
59    return set_status_code(RTEMS_ILLEGAL_ON_SELF);
60
61  strcpy(name_str, "    ");
62  for (int c = 0; (c < 4) && (tname[c] != '\0'); c++)
63    name_str[c] = tname[c];
64  name = rtems_build_name(name_str[0],
65                          name_str[1],
66                          name_str[2],
67                          name_str[3]);
68 
69  set_status_code(rtems_timer_create(name, &id));
70
71  if (unsuccessful())
72  {
73    make_invalid();
74  }
75 
76  return last_status_code();
77}
78
79const rtems_status_code rtemsTimer::destroy()
80{
81  if (id)
82  {
83    set_status_code(rtems_timer_delete(id));
84    make_invalid();
85  }
86  else
87    set_status_code(RTEMS_NOT_OWNER_OF_RESOURCE);
88 
89  return last_status_code();
90}
91 
92void rtemsTimer::common_handler(rtems_id , void *user_data)
93{
94  rtemsTimer *timer = (rtemsTimer*) user_data;
95 
96  if (timer->repeat)
97    timer->reset();
98
99  timer->triggered();
100}
Note: See TracBrowser for help on using the repository browser.