summaryrefslogtreecommitdiffstats
path: root/c/src/lib/librtems++/rtemsTimer.cc
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1997-07-31 22:13:29 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1997-07-31 22:13:29 +0000
commit0074691a67f857c9b3f880fb581e0af1d5673337 (patch)
treef80fd23129ad62236ee4f64eeaf537f53bbaa0b8 /c/src/lib/librtems++/rtemsTimer.cc
parentMerged very large and much appreciated patch from Chris Johns (diff)
downloadrtems-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 '')
-rw-r--r--c/src/lib/librtems++/rtemsTimer.cc100
1 files changed, 100 insertions, 0 deletions
diff --git a/c/src/lib/librtems++/rtemsTimer.cc b/c/src/lib/librtems++/rtemsTimer.cc
new file mode 100644
index 0000000000..b87ffd5e80
--- /dev/null
+++ b/c/src/lib/librtems++/rtemsTimer.cc
@@ -0,0 +1,100 @@
+/*
+ ------------------------------------------------------------------------
+ $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.
+
+ ------------------------------------------------------------------------
+
+ See header file.
+
+ ------------------------------------------------------------------------
+*/
+
+#include <rtems++/rtemsTimer.h>
+
+/* ----
+ rtemsTimer
+*/
+
+rtemsTimer::rtemsTimer(const char* tname)
+ : name(0),
+ repeat(false),
+ id(0)
+{
+ strcpy(name_str, " ");
+ create(tname);
+}
+
+rtemsTimer::rtemsTimer()
+ : name(0),
+ repeat(false),
+ id(0)
+{
+ strcpy(name_str, " ");
+}
+
+rtemsTimer::~rtemsTimer()
+{
+ destroy();
+}
+
+void rtemsTimer::make_invalid()
+{
+ strcpy(name_str, " ");
+ name = 0;
+ id = 0;
+ repeat = false;
+}
+const rtems_status_code rtemsTimer::create(const char* tname)
+{
+ if (id)
+ return set_status_code(RTEMS_ILLEGAL_ON_SELF);
+
+ strcpy(name_str, " ");
+ for (int c = 0; (c < 4) && (tname[c] != '\0'); c++)
+ name_str[c] = tname[c];
+ name = rtems_build_name(name_str[0],
+ name_str[1],
+ name_str[2],
+ name_str[3]);
+
+ set_status_code(rtems_timer_create(name, &id));
+
+ if (unsuccessful())
+ {
+ make_invalid();
+ }
+
+ return last_status_code();
+}
+
+const rtems_status_code rtemsTimer::destroy()
+{
+ if (id)
+ {
+ set_status_code(rtems_timer_delete(id));
+ make_invalid();
+ }
+ else
+ set_status_code(RTEMS_NOT_OWNER_OF_RESOURCE);
+
+ return last_status_code();
+}
+
+void rtemsTimer::common_handler(rtems_id , void *user_data)
+{
+ rtemsTimer *timer = (rtemsTimer*) user_data;
+
+ if (timer->repeat)
+ timer->reset();
+
+ timer->triggered();
+}