source: drsdaq/VME/atlas/include/rcc_time_stamp/tstamp.h@ 154

Last change on this file since 154 was 22, checked in by ogrimm, 16 years ago
First commit of drsdaq program
  • Property svn:executable set to *
File size: 5.6 KB
Line 
1/************************************************************************/
2/* */
3/* file: tstamplib.h */
4/* author: Markus Joos, CERN-EP/ESS */
5/* */
6/* This is the header of the timestamping library. */
7/* */
8/* History: */
9/* 22.Sep.98 MAJO created */
10/* 3.Mar.99 MAJO major rewrite; macros added */
11/* 5.Mar.99 MAJO default handles and include statement for */
12/* event symbols added */
13/* 27.Jul.99 JOP move my_ts_events.h out */
14/* 16.Jul.02 MAJO Ported to RCC environment */
15/* */
16/*******Copyright Ecosoft 2007 - Made from 80% recycled bytes************/
17
18#include <sys/types.h>
19#include "rcc_error/rcc_error.h"
20
21#ifndef _TSTAMPLIB_H
22 #define _TSTAMPLIB_H
23
24 typedef struct tstamp
25 {
26 u_int high;
27 u_int low;
28 u_int data;
29 } tstamp;
30
31 typedef u_int TS_ErrorCode_t;
32
33
34 #define TS_DUMMY 0
35 #define TS_MODE_NORING 0
36 #define TS_MODE_RING 1
37
38 #ifdef TSTAMP
39 // Constants
40 #define FREQUENCY_LOW 16500000.0
41 #define FREQUENCY_HIGH (1.0/256.0)
42 #define TS_FULL 1
43 #define TS_STOP_TS 2
44 #define TS_START_TS ~TS_STOP_TS
45 #define MAX_OPENS 10
46
47 enum
48 {
49 TS_H1 = 1,
50 TS_H2,
51 TS_H3,
52 TS_H4,
53 TS_H5,
54 TS_H6,
55 TS_H7,
56 TS_H8,
57 TS_H9,
58 TS_H10
59 };
60
61 // Macros
62 static int tstamp_ret;
63
64 #define TS_OPEN(size, ts_handle)\
65 {\
66 tstamp_ret = ts_open(size, ts_handle);\
67 if (tstamp_ret)\
68 rcc_error_print(stdout, tstamp_ret);\
69 }
70
71 #define TS_SAVE(handle, name)\
72 {\
73 tstamp_ret=ts_save(handle, name);\
74 if (tstamp_ret)\
75 rcc_error_print(stdout, tstamp_ret);\
76 }
77
78 #define TS_CLOSE(handle)\
79 {\
80 tstamp_ret = ts_close(handle);\
81 if (tstamp_ret)\
82 rcc_error_print(stdout, tstamp_ret);\
83 }
84
85 #define TS_RECORD(handle, udata) ts_record(handle, udata)
86 #define TS_START(handle) ts_start(handle)
87 #define TS_SETT0 ts_sett0()
88 #define TS_PAUSE(handle) ts_pause(handle)
89 #define TS_RESUME(handle) ts_resume(handle)
90 #define TS_DURATION( t1, t2) ts_duration(t1, t2)
91 #define TS_CLOCK(time) ts_clock(time)
92 #define TS_DELAY(time) ts_delay(time)
93 #define TS_MODE(handle, mode) ts_mode(handle, mode)
94 #define TS_COMPARE(t1, t2) ts_compare(t1, t2)
95 #define TS_OFFSET(ts, usecs) ts_offset(ts, usecs)
96 #define TS_WAIT_UNTIL(target, nyield) ts_wait_until(target, nyield)
97 #else
98 #define TS_OPEN(size, ts_handle)
99 #define TS_SAVE(handle, name)
100 #define TS_CLOSE(handle)
101 #define TS_RECORD(handle,udata)
102 #define TS_START(handle)
103 #define TS_PAUSE(handle)
104 #define TS_RESUME(handle)
105 #define TS_DURATION(t1, t2)
106 #define TS_CLOCK(time)
107 #define TS_DELAY(time)
108 #define TS_MODE(handle, mode)
109 #define TS_COMPARE(t1, t2)
110 #define TS_OFFSET(ts, usecs)
111 #define TS_WAIT_UNTIL(target, nyield)
112 #define TS_SETT0
113 #endif
114
115 // Error codes
116 enum
117 {
118 TSE_OK = 0,
119 TSE_IS_CLOSED = (P_ID_TS << 8) + 1,
120 TSE_WHAT,
121 TSE_SMEM,
122 TSE_NO_FREQ,
123 TSE_FILE,
124 TSE_ILL_HANDLE,
125 TSE_ILL_SIZE,
126 TSE_PFILE,
127 TSE_NO_REF,
128 TSE_ERROR_FAIL,
129 TSE_ILL_MODE,
130 TSE_NOCODE
131 };
132
133 #define TSE_OK_STR "No error"
134 #define TSE_NO_FREQ_STR "Failed to set frequency"
135 #define TSE_FILE_STR "Failed to open /proc/cpuinfo"
136 #define TSE_ILL_HANDLE_STR "Parameter >handle< is out of range"
137 #define TSE_IS_CLOSED_STR "The library has not been opened"
138 #define TSE_ILL_SIZE_STR "Parameter >size< is out of range"
139 #define TSE_PFILE_STR "Failed to open/close data file"
140 #define TSE_NO_REF_STR "Reference time missing (ts_sett0)"
141 #define TSE_ERROR_FAIL_STR "Failed to initialise the error system"
142 #define TSE_ILL_MODE_STR "Parameter >mode< is out of range"
143 #define TSE_NOCODE_STR "Unknown error code"
144
145 #ifdef __cplusplus
146 extern "C" {
147 #endif
148
149 /*prototypes*/
150 float ts_duration(tstamp t1, tstamp t2);
151 int ts_compare(tstamp t1, tstamp t2);
152 TS_ErrorCode_t ts_offset(tstamp *ts, u_int usecs);
153 TS_ErrorCode_t ts_open(int size, int handle);
154 TS_ErrorCode_t ts_close(int handle);
155 TS_ErrorCode_t ts_save(int handle, char *name);
156 TS_ErrorCode_t ts_elapsed (tstamp t1, float *time);
157 TS_ErrorCode_t ts_get_freq(void);
158 TS_ErrorCode_t ts_record(int handle, int udata);
159 TS_ErrorCode_t ts_sett0(void);
160 TS_ErrorCode_t ts_start(int handle);
161 TS_ErrorCode_t ts_pause(int handle);
162 TS_ErrorCode_t ts_resume(int handle);
163 TS_ErrorCode_t ts_clock(tstamp *time);
164 TS_ErrorCode_t ts_delay(u_int usecs);
165 TS_ErrorCode_t ts_mode(int handle, u_int mode);
166 TS_ErrorCode_t ts_wait(u_int usecs, u_int *nyield);
167 TS_ErrorCode_t ts_wait_until(tstamp target, u_int *nyield);
168 TS_ErrorCode_t packTS_err_get (err_pack err, err_str pid_str, err_str en_str);
169
170 #ifdef __cplusplus
171 }
172 #endif
173#endif
174
175
Note: See TracBrowser for help on using the repository browser.