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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [librtems++/] [src/] [rtemsTimer.cc] - Blame information for rev 773

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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