AlcapDAQ  1
CAENVMEtypes.h
Go to the documentation of this file.
1 /*
2  -----------------------------------------------------------------------------
3 
4  --- CAEN SpA - Computing Systems Division ---
5 
6  -----------------------------------------------------------------------------
7 
8  CAENVMEtypes.h
9 
10  -----------------------------------------------------------------------------
11 
12  Author: Stefano Coluccini (s.coluccini@caen.it)
13 
14  Created: March 2004
15 
16  -----------------------------------------------------------------------------
17 */
18 #ifndef __CAENVMETYPES_H
19 #define __CAENVMETYPES_H
20 
21 #ifdef LINUX
22 #define CAEN_BYTE unsigned char
23 #define CAEN_BOOL int
24 #else
25 #define CAEN_BYTE byte
26 #define CAEN_BOOL VARIANT_BOOL
27 #endif
28 
29 /*
30  CAEN VME bridges.
31 */
32 typedef enum CVBoardTypes {
33  cvV1718 = 0, /* CAEN V1718 USB-VME bridge */
34  cvV2718 = 1, /* V2718 PCI-VME bridge with optical link */
35  cvA2818 = 2, /* PCI board with optical link */
36  cvA2719 = 3, /* Optical link piggy-back */
37  cvA3818 = 4 /* PCIe board with up to 4 optical links */
38 } CVBoardTypes;
39 
40 /*
41  VME cycles data width.
42  Ver. 2.2 - Added byte-swapping data widths
43 */
44 typedef enum CVDataWidth {
45  cvD8 = 0x01, /* 8 bit */
46  cvD16 = 0x02, /* 16 bit */
47  cvD32 = 0x04, /* 32 bit */
48  cvD64 = 0x08, /* 64 bit */
49  cvD16_swapped = 0x12, /* 16 bit swapped */
50  cvD32_swapped = 0x14, /* 32 bit swapped */
51  cvD64_swapped = 0x18 /* 64 bit swapped */
52 } CVDataWidth;
53 
54 /*
55  VME cycles address modifiers
56 */
57 typedef enum CVAddressModifier {
58  cvA16_S = 0x2D, /* A16 supervisory access */
59  cvA16_U = 0x29, /* A16 non-privileged */
60  cvA16_LCK = 0x2C, /* A16 lock command */
61 
62  cvA24_S_BLT = 0x3F, /* A24 supervisory block transfer */
63  cvA24_S_PGM = 0x3E, /* A24 supervisory program access */
64  cvA24_S_DATA = 0x3D, /* A24 supervisory data access */
65  cvA24_S_MBLT = 0x3C, /* A24 supervisory 64-bit block trnsfer */
66  cvA24_U_BLT = 0x3B, /* A24 non-privileged block transfer */
67  cvA24_U_PGM = 0x3A, /* A24 non-privileged program access */
68  cvA24_U_DATA = 0x39, /* A24 non-privileged data access */
69  cvA24_U_MBLT = 0x38, /* A24 non-privileged 64-bit block trnsfer */
70  cvA24_LCK = 0x32, /* A24 lock command */
71 
72  cvA32_S_BLT = 0x0F, /* A32 supervisory block transfer */
73  cvA32_S_PGM = 0x0E, /* A32 supervisory program access */
74  cvA32_S_DATA = 0x0D, /* A32 supervisory data access */
75  cvA32_S_MBLT = 0x0C, /* A32 supervisory 64-bit block trnsfer */
76  cvA32_U_BLT = 0x0B, /* A32 non-privileged block transfer */
77  cvA32_U_PGM = 0x0A, /* A32 non-privileged program access */
78  cvA32_U_DATA = 0x09, /* A32 non-privileged data access */
79  cvA32_U_MBLT = 0x08, /* A32 non-privileged 64-bit block trnsfer */
80  cvA32_LCK = 0x05, /* A32 lock command */
81 
82  cvCR_CSR = 0x2F, /* CR/CSR space */
83 
84 /*
85  The following address modifiers are not yet implemented.
86 */
87 
88  cvA40_BLT = 0x37, /* A40 block transfer (MD32) */
89  cvA40_LCK = 0x35, /* A40 lock command */
90  cvA40 = 0x34, /* A40 access */
91 
92  cvA64 = 0x01, /* A64 single trnsfer access */
93  cvA64_BLT = 0x03, /* A64 block transfer */
94  cvA64_MBLT = 0x00, /* A64 64-bit block transfer */
95  cvA64_LCK = 0x04, /* A64 lock command */
96 
97  cvA3U_2eVME = 0x21, /* 2eVME for 3U modules */
98  cvA6U_2eVME = 0x20 /* 2eVME for 6U modules */
100 
101 /*
102  Error codes returned by the exported functions.
103 */
104 typedef enum CVErrorCodes {
105  cvSuccess = 0, /* Operation completed successfully */
106  cvBusError = -1, /* VME bus error during the cycle */
107  cvCommError = -2, /* Communication error */
108  cvGenericError = -3, /* Unspecified error */
109  cvInvalidParam = -4, /* Invalid parameter */
110  cvTimeoutError = -5, /* Timeout error */
111 } CVErrorCodes;
112 
113 /*
114  Pulser selection.
115 */
116 typedef enum CVPulserSelect {
117  cvPulserA = 0, /* Identifies the pulser 'A' */
118  cvPulserB = 1 /* Identifies the pulser 'B' */
120 
121 /*
122  Output selection.
123 */
124 typedef enum CVOutputSelect {
125  cvOutput0 = 0, /* Identifies the output line 0 */
126  cvOutput1 = 1, /* Identifies the output line 1 */
127  cvOutput2 = 2, /* Identifies the output line 2 */
128  cvOutput3 = 3, /* Identifies the output line 3 */
129  cvOutput4 = 4 /* Identifies the output line 4 */
131 
132 /*
133  Input selection.
134 */
135 typedef enum CVInputSelect {
136  cvInput0 = 0, /* Identifies the input line 0 */
137  cvInput1 = 1 /* Identifies the input line 1 */
138 } CVInputSelect;
139 
140 /*
141  Signal sources.
142 */
143 typedef enum CVIOSources {
144  cvManualSW = 0, /* Manual (button) or software controlled */
145  cvInputSrc0 = 1, /* Input line 0 */
146  cvInputSrc1 = 2, /* Input line 1 */
147  cvCoincidence = 3, /* Inputs coincidence */
148  cvVMESignals = 4, /* Signals from VME bus */
149  cvMiscSignals = 6 /* Various internal signals */
150 } CVIOSources;
151 
152 /*
153  Time base units to specify pulses period and width.
154 */
155 typedef enum CVTimeUnits {
156  cvUnit25ns = 0, /* Time unit is 25 nanoseconds */
157  cvUnit1600ns = 1, /* Time unit is 1.6 microseconds */
158  cvUnit410us = 2, /* Time unit is 410 microseconds */
159  cvUnit104ms = 3 /* Time unit is 104 milliseconds */
160 } CVTimeUnits;
161 
162 /*
163  Polarity for LED emitting.
164 */
165 typedef enum CVLEDPolarity {
166  cvActiveHigh = 0, /* LED emits on signal high level */
167  cvActiveLow = 1 /* LED emits on signal low level */
168 } CVLEDPolarity;
169 
170 /*
171  Input and Output signal polarity.
172 */
173 typedef enum CVIOPolarity {
174  cvDirect = 0, /* Normal polarity */
175  cvInverted = 1 /* Inverted polarity */
176 } CVIOPolarity;
177 
178 /*
179  Accessible registers.
180 */
181 typedef enum CVRegisters {
182  cvStatusReg = 0x00, /* Status register */
183  cvVMEControlReg = 0x01, /* VME Control register */
184  cvFwRelReg = 0x02, /* Firmware Release register */
185  cvFwDldReg = 0x03, /* Firmware Download register */
186  cvFlenaReg = 0x04, /* Flash Enable */
187  cvVMEIRQEnaReg = 0x06, /* VME IRQ Lines Enable */
188  cvInputReg = 0x08, /* Input register */
189  cvOutRegSet = 0x0A, /* Output register */
190  cvInMuxRegSet = 0x0B, /* Input Multiplexer */
191  cvOutMuxRegSet = 0x0C, /* Output Multiplexer */
192  cvLedPolRegSet = 0x0D, /* Led Polarity */
193  cvOutRegClear = 0x10, /* Output register */
194  cvInMuxRegClear = 0x11, /* Input Multiplexer */
195  cvOutMuxRegClear = 0x12, /* Output Multiplexer */
196  cvLedPolRegClear = 0x13, /* Led Polarity */
197  cvPulserA0 = 0x16, /* Period and width of Pulser A */
198  cvPulserA1 = 0x17, /* Num pulses and range of Pulser A */
199  cvPulserB0 = 0x19, /* Period and width of Pulser B */
200  cvPulserB1 = 0x1A, /* Num pulses and range of Pulser B */
201  cvScaler0 = 0x1C, /* Limit and Autores of Scaler A */
202  cvScaler1 = 0x1D, /* Counter value of Scaler A */
203  cvDispADL = 0x20, /* Display AD[15:0] */
204  cvDispADH = 0x21, /* Display AD[31:16] */
205  cvDispDTL = 0x22, /* Display DT[15:0] */
206  cvDispDTH = 0x23, /* Display DT[31:16] */
207  cvDispC1 = 0x24, /* Display Control left bar */
208  cvDispC2 = 0x25, /* Display Control left bar */
209  cvLMADL = 0x28, /* Loc. Mon. AD[15:0] */
210  cvLMADH = 0x29, /* Loc. Mon. AD[31:16] */
211  cvLMC = 0x2C /* Loc. Mon. Controls */
212 } CVRegisters;
213 
214 /*
215  Bits for status register decoding.
216 */
217 typedef enum CVStatusRegisterBits {
218  cvSYSRES = 0x0001, /* VME is in system reset state */
219  cvSYSCTRL = 0x0002, /* The bridge is the VME system controller */
220  cvDTACK = 0x0010, /* Last access has generated a DTACK signal */
221  cvBERR = 0x0020, /* Last access has generated a bus error */
222  cvDIP0 = 0x0100, /* Dip Switch position 0 state */
223  cvDIP1 = 0x0200, /* Dip Switch position 1 state */
224  cvDIP2 = 0x0400, /* Dip Switch position 2 state */
225  cvDIP3 = 0x0800, /* Dip Switch position 3 state */
226  cvDIP4 = 0x1000, /* Dip Switch position 4 state */
227  cvUSBTYPE = 0x8000 /* USB Speed: 0 = Full; 1 = High */
229 
230 /*
231  Bits for input register decoding.
232 */
233 typedef enum CVInputRegisterBits {
234  cvIn0Bit = 0x0001, /* Input line 0 signal level. */
235  cvIn1Bit = 0x0002, /* Input line 1 signal level. */
236  cvCoincBit = 0x0004, /* Coincidence of input signal level. */
237  cvPulsAOutBit = 0x0008, /* Pulser A output signal level. */
238  cvPulsBOutBit = 0x0010, /* Pulser B output signal level. */
239  cvScalEndCntBit = 0x0020, /* Scaler end counter signal level. */
240  cvLocMonBit = 0x0040, /* Location monitor signal level. */
242 
243 /*
244  Bits for input register decoding.
245 */
246 typedef enum CVOutputRegisterBits {
247  cvPulsAStartBit = 0x0001, /* Pulser A start signal level. */
248  cvPulsAResetBit = 0x0002, /* Pulser A reset signal level. */
249  cvPulsBStartBit = 0x0004, /* Pulser B start signal level. */
250  cvPulsBResetBit = 0x0008, /* Pulser B reset signal level. */
251  cvScalGateBit = 0x0010, /* Scaler gate signal level. */
252  cvScalResetBit = 0x0020, /* Scaler reset counter signal level. */
253  cvOut0Bit = 0x0040, /* Output line 0 signal level. */
254  cvOut1Bit = 0x0080, /* Output line 1 signal level. */
255  cvOut2Bit = 0x0100, /* Output line 2 signal level. */
256  cvOut3Bit = 0x0200, /* Output line 3 signal level. */
257  cvOut4Bit = 0x0400, /* Output line 4 signal level. */
259 
260 /*
261  Types of VME Arbiter.
262 */
263 typedef enum CVArbiterTypes {
264  cvPriorized = 0, /* Priority Arbiter */
265  cvRoundRobin = 1 /* Round-Robin Arbiter */
267 
268 /*
269  Types of VME Bus Requester.
270 */
271 typedef enum CVRequesterTypes {
272  cvFair = 0, /* Fair bus requester */
273  cvDemand = 1 /* On demand bus requester */
275 
276 /*
277  Types of VME Bus release.
278 */
279 typedef enum CVReleaseTypes {
280  cvRWD = 0, /* Release When Done */
281  cvROR = 1 /* Release On Request */
283 
284 /*
285  VME bus request levels.
286 */
287 typedef enum CVBusReqLevels {
288  cvBR0 = 0, /* Bus request level 0 */
289  cvBR1 = 1, /* Bus request level 1 */
290  cvBR2 = 2, /* Bus request level 2 */
291  cvBR3 = 3 /* Bus request level 3 */
293 
294 /*
295  VME Interrupt levels.
296 */
297 typedef enum CVIRQLevels {
298  cvIRQ1 = 0x01, /* Interrupt level 1 */
299  cvIRQ2 = 0x02, /* Interrupt level 2 */
300  cvIRQ3 = 0x04, /* Interrupt level 3 */
301  cvIRQ4 = 0x08, /* Interrupt level 4 */
302  cvIRQ5 = 0x10, /* Interrupt level 5 */
303  cvIRQ6 = 0x20, /* Interrupt level 6 */
304  cvIRQ7 = 0x40 /* Interrupt level 7 */
305 } CVIRQLevels;
306 
307 /*
308  VME bus timeouts.
309 */
310 typedef enum CVVMETimeouts {
311  cvTimeout50us = 0, /* Timeout is 50 microseconds */
312  cvTimeout400us = 1 /* Timeout is 400 microseconds */
313 } CVVMETimeouts;
314 
315 /*
316  Data type to store the front panel display last access data.
317 */
318 typedef struct CVDisplay {
319  long cvAddress; /* VME Address */
320  long cvData; /* VME Data */
321  long cvAM; /* Address modifier */
322  long cvIRQ; /* IRQ levels */
323  CAEN_BOOL cvDS0; /* Data Strobe 0 signal */
324  CAEN_BOOL cvDS1; /* Data Strobe 1 signal */
325  CAEN_BOOL cvAS; /* Address Strobe signal */
326  CAEN_BOOL cvIACK; /* Interrupt Acknowledge signal */
327  CAEN_BOOL cvWRITE; /* Write signal */
328  CAEN_BOOL cvLWORD; /* Long Word signal */
329  CAEN_BOOL cvDTACK; /* Data Acknowledge signal */
330  CAEN_BOOL cvBERR; /* Bus Error signal */
331  CAEN_BOOL cvSYSRES; /* System Reset signal */
332  CAEN_BOOL cvBR; /* Bus Request signal */
333  CAEN_BOOL cvBG; /* Bus Grant signal */
334 } CVDisplay;
335 
336 #endif // __CAENVMETYPES_H