JLab Pipeline TS Library  3v7.1
tsLib.h
Go to the documentation of this file.
1 /*----------------------------------------------------------------------------*
2  * Copyright (c) 2012 Southeastern Universities Research Association, *
3  * Thomas Jefferson National Accelerator Facility *
4  * *
5  * This software was developed under a United States Government license *
6  * described in the NOTICE file included as part of this distribution. *
7  * *
8  * Authors: Bryan Moffit *
9  * moffit@jlab.org Jefferson Lab, MS-12B3 *
10  * Phone: (757) 269-5660 12000 Jefferson Ave. *
11  * Fax: (757) 269-5800 Newport News, VA 23606 *
12  * *
13  *----------------------------------------------------------------------------*
14  *
15  * Description:
16  * Primitive trigger control for VME CPUs using the TJNAF Trigger
17  * Supervisor (TS) card
18  *
19  *----------------------------------------------------------------------------*/
20 #ifndef TSLIB_H
21 #define TSLIB_H
22 
23 #ifndef VXWORKS
24 #include <pthread.h>
25 
26 pthread_mutex_t tsISR_mutex=PTHREAD_MUTEX_INITIALIZER;
27 #else
28 /* #include <intLib.h> */
29 extern int intLock();
30 extern int intUnlock();
31 #endif
32 
33 #ifdef VXWORKS
34 int intLockKeya;
35 #define INTLOCK { \
36  intLockKeya = intLock(); \
37 }
38 
39 #define INTUNLOCK { \
40  intUnlock(intLockKeya); \
41 }
42 #else
43 #define INTLOCK { \
44  vmeBusLock(); \
45 }
46 #define INTUNLOCK { \
47  vmeBusUnlock(); \
48 }
49 #endif
50 
52 {
53  /* 0x00n80 */ volatile unsigned int fp[4];
54  /* 0x00n90 */ volatile unsigned int GTP[8];
55  /* 0x00nB0 */ volatile unsigned int gen[8];
56  /* 0x00nD0 */ volatile unsigned int blank[(0x334-0x1D0)/4];
57 };
58 
60 {
61  /* 0x00n34 */ volatile unsigned int blockBuffer;
62  /* 0x00n38 */ volatile unsigned int triggerRuleMin; // Only on part1 struct
63  /* 0x00n3C */ unsigned int blank0;
64  /* 0x00n40 */ volatile unsigned int fpConfig;
65  /* 0x00n44 */ volatile unsigned int gtpConfig;
66  /* 0x00n48 */ volatile unsigned int genConfig;
67  /* 0x00n4C */ volatile unsigned int triggerTable;
68  /* 0x00n50 */ volatile unsigned int data;
69  /* 0x00n54 */ volatile unsigned int blockBufferInfo;
70  /* 0x00n58 */ volatile unsigned int busyConfig;
71  /* 0x00n5C */ volatile unsigned int busytime;
72  /* 0x00n60 */ volatile unsigned int hel_livetime;
73  /* 0x00n64 */ volatile unsigned int hel_busytime;
74  /* 0x00n68 */ unsigned int blank[(0x180-0x168)/4];
75 };
76 
78 {
79  /* 0x010n0 */ volatile unsigned int GTPTriggerTable;
80  /* 0x010n4 */ volatile unsigned int FPTriggerTable;
81 };
82 
84 {
85  /* 0x00000 */ volatile unsigned int boardID;
86  /* 0x00004 */ volatile unsigned int fiber;
87  /* 0x00008 */ volatile unsigned int intsetup;
88  /* 0x0000C */ volatile unsigned int trigDelay;
89  /* 0x00010 */ volatile unsigned int adr32;
90  /* 0x00014 */ volatile unsigned int blocklevel;
91  /* 0x00018 */ volatile unsigned int dataFormat;
92  /* 0x0001C */ volatile unsigned int vmeControl;
93  /* 0x00020 */ volatile unsigned int trigger;
94  /* 0x00024 */ volatile unsigned int sync;
95  /* 0x00028 */ volatile unsigned int busy;
96  /* 0x0002C */ volatile unsigned int clock;
97  /* 0x00030 */ volatile unsigned int trig1Prescale;
98  /* 0x00034 */ volatile unsigned int blockBuffer;
99  /* 0x00038 */ volatile unsigned int triggerRule;
100  /* 0x0003C */ volatile unsigned int triggerWindow;
101  /* 0x00040 */ volatile unsigned int GTPtrigger;
102  /* 0x00044 */ volatile unsigned int fpInput;
103  /* 0x00048 */ volatile unsigned int genInput;
104  /* 0x0004C */ volatile unsigned int output;
105  /* 0x00050 */ volatile unsigned int fiberSyncDelay;
106  /* 0x00054 */ volatile unsigned int GTPprescale[4];
107  /* 0x00064 */ volatile unsigned int fpInputPrescale[4];
108  /* Duplication Mode: fpInputPrescale[2] -> Local Trigger Table */
109  /* Duplication Mode: fpInputPrescale[3] -> Local Trigger, Fast Clear Setting */
110  /* 0x00074 */ volatile unsigned int specialEvTypes;
111  /* 0x00078 */ volatile unsigned int syncCommand;
112  /* 0x0007C */ volatile unsigned int syncDelay;
113  /* 0x00080 */ volatile unsigned int syncWidth;
114  /* 0x00084 */ volatile unsigned int triggerCommand;
115  /* 0x00088 */ volatile unsigned int randomPulser;
116  /* 0x0008C */ volatile unsigned int fixedPulser1;
117  /* 0x00090 */ volatile unsigned int fixedPulser2;
118  /* 0x00094 */ volatile unsigned int nblocks;
119  /* 0x00098 */ unsigned int blank0;
120  /* 0x0009C */ volatile unsigned int runningMode;
121  /* 0x000A0 */ volatile unsigned int duplBusyTime;
122  /* 0x000A4 */ volatile unsigned int duplBusyStatus;
123  /* 0x000A8 */ volatile unsigned int livetime;
124  /* 0x000AC */ volatile unsigned int busytime;
125  /* 0x000B0 */ volatile unsigned int GTPStatusA;
126  /* 0x000B4 */ volatile unsigned int GTPStatusB;
127  /* 0x000B8 */ volatile unsigned int GTPtriggerBufferLength;
128  /* 0x000BC */ volatile unsigned int inputCounter;
129  /* 0x000C0 */ volatile unsigned int blockStatus[4];
130  /* 0x000D0 */ volatile unsigned int adr24;
131  /* 0x000D4 */ volatile unsigned int syncEventCtrl;
132  /* 0x000D8 */ volatile unsigned int eventNumber_hi;
133  /* 0x000DC */ volatile unsigned int eventNumber_lo;
134  /* 0x000E0 */ volatile unsigned int hfbr_tiID[2];
135  /* 0x000E8 */ volatile unsigned int master_tiID;
136  /* 0x000EC */ unsigned int blank1;
137  /* 0x000F0 */ volatile unsigned int fpScaler;
138  /* 0x000F4 */ volatile unsigned int gtpScaler;
139  /* 0x000F8 */ volatile unsigned int genScaler;
140  /* 0x000FC */ volatile unsigned int blocklimit;
141  /* 0x00100 */ volatile unsigned int reset;
142  /* 0x00104 */ volatile unsigned int fpDelay[11];
143  /* Duplication Mode: fpDelay[5] -> Fast Clear Delay */
144  /* Duplication Mode: fpDelay[6] -> Busy extension settings */
145  /* 0x00130 */ unsigned int blank2;
146  /* 0x00134 */ struct PartitionStruct part1;
147  /* 0x00180 */ struct ScalerStruct Scalers1;
148  /* 0x00340 */ struct PartitionStruct part2;
149  /* 0x00380 */ struct ScalerStruct Scalers2;
150  /* 0x00540 */ struct PartitionStruct part3;
151  /* 0x00580 */ struct ScalerStruct Scalers3;
152  /* 0x00740 */ struct PartitionStruct part4;
153  /* 0x00780 */ struct ScalerStruct Scalers4;
154  /* 0x00934 */ unsigned int blank3[(0x1080-0x934)/4];
155  /* 0x01080 */ volatile unsigned int GTPTriggerTable[(0x1090-0x1080)/4];
156  /* 0x01090 */ volatile unsigned int FPTriggerTable[(0x10A0-0x1090)/4];
157  /* 0x010A0 */ struct PartTrigTableStruct PartTrigTable[4];
158  /* 0x010C0 */ unsigned int blank4[(0xFFFC-0x10C0)/4];
159  /* 0x0FFFC */ volatile unsigned int eJTAGLoad;
160  /* 0x10000 */ volatile unsigned int JTAGPROMBase[(0x20000-0x10000)/4];
161  /* 0x20000 */ volatile unsigned int JTAGFPGABase[(0x30000-0x20000)/4];
162  /* 0x30000 */ volatile unsigned int SWA[(0x40000-0x30000)/4];
163  /* 0x40000 */ volatile unsigned int SWB[(0x50000-0x40000)/4];
164 
165 };
166 
167 /* Define TS Modes of operation: Ext trigger - Interrupt mode 0
168  Ext trigger - polling mode 2 */
169 #define TS_READOUT_EXT_INT 0
170 #define TS_READOUT_EXT_POLL 2
171 
172 /* Firmware Masks */
173 #define TS_FIRMWARE_ID_MASK 0xFFFF0000
174 #define TS_FIRMWARE_TYPE_MASK 0x0000F000
175 #define TS_FIRMWARE_TYPE_PROD 1
176 #define TS_FIRMWARE_TYPE_P 3
177 #define TS_FIRMWARE_MAJOR_VERSION_MASK 0x00000FF0
178 #define TS_FIRWMARE_MINOR_VERSION_MASK 0x0000000F
179 
180 #define TS_SUPPORTED_FIRMWARE 0x71
181 #define TS_SUPPORTED_TYPE TS_FIRMWARE_TYPE_P
182 
183 
184 
185 /* Macros for tsSetTriggerSource arguments */
186 #define TS_TRIGSRC_PULSER 5
187 #define TS_TRIGSRC_EXT 6
188 
189 /* 0x0 boardID bits and masks */
190 #define TS_BOARDID_TYPE_TIDS 0x71D5
191 #define TS_BOARDID_TYPE_TI 0x7100
192 #define TS_BOARDID_TYPE_TS 0x7500
193 #define TS_BOARDID_TYPE_TD 0x7D00
194 #define TS_BOARDID_TYPE_MASK 0xFF000000
195 #define TS_BOARDID_PROD_MASK 0x00FF0000
196 #define TS_BOARDID_GEOADR_MASK 0x00001F00
197 #define TS_BOARDID_CRATEID_MASK 0x000000FF
198 
199 /* 0x4 fiber bits and masks */
200 #define TS_FIBER_LOW_POWER (1<<1)
201 #define TS_FIBER_I2C_ACTIVE (1<<2)
202 #define TS_FIBER_RESET (1<<3)
203 #define TS_FIBER_ENABLE_P0 (1<<8)
204 
205 
206 /* 0x8 intsetup bits and masks */
207 #define TS_INTSETUP_VECTOR_MASK 0x000000FF
208 #define TS_INTSETUP_LEVEL_MASK 0x00000F00
209 #define TS_INTSETUP_ENABLE (1<<16)
210 
211 /* 0xC trigDelay bits and masks */
212 #define TS_TRIGDELAY_TRIG1_DELAY_MASK 0x000000FF
213 #define TS_TRIGDELAY_TRIG1_WIDTH_MASK 0x0000FF00
214 #define TS_TRIGDELAY_TRIG2_DELAY_MASK 0x00FF0000
215 #define TS_TRIGDELAY_TRIG2_WIDTH_MASK 0xFF000000
216 
217 /* 0x10 adr32 bits and masks */
218 #define TS_ADR32_MBLK_ADDR_MAX_MASK 0x000003FE
219 #define TS_ADR32_MBLK_ADDR_MIN_MASK 0x003FC000
220 #define TS_ADR32_BASE_MASK 0xFF800000
221 
222 /* 0x14 blocklevel bits and masks */
223 #define TS_BLOCKLEVEL_MASK 0x000000FF
224 #define TS_BLOCKLEVEL_CURRENT_MASK 0x00FF0000
225 #define TS_BLOCKLEVEL_RECEIVED_MASK 0xFF000000
226 
227 /* 0x18 dataFormat bits and masks */
228 #define TS_DATAFORMAT_TWOBLOCK_PLACEHOLDER (1<<0)
229 #define TS_DATAFORMAT_TIMING_WORD (1<<1)
230 #define TS_DATAFORMAT_HIGHERBITS_WORD (1<<2)
231 #define TS_DATAFORMAT_WORDS_MASK 0x00000007
232 #define TS_DATAFORMAT_GTPINPUT_READOUT (1<<3)
233 #define TS_DATAFORMAT_FPINPUT_READOUT (1<<4)
234 
235 /* 0x1C vmeControl bits and masks */
236 #define TS_VMECONTROL_BERR (1<<0)
237 #define TS_VMECONTROL_TOKEN (1<<1)
238 #define TS_VMECONTROL_MBLK (1<<2)
239 #define TS_VMECONTROL_A32M (1<<3)
240 #define TS_VMECONTROL_A32 (1<<4)
241 #define TS_VMECONTROL_INT (1<<7)
242 #define TS_VMECONTROL_I2CDEV_HACK (1<<8)
243 #define TS_VMECONTROL_TOKEN_HI (1<<9)
244 #define TS_VMECONTROL_FIRST_BOARD (1<<10)
245 #define TS_VMECONTROL_LAST_BOARD (1<<11)
246 #define TS_VMECONTROL_BUFFER_DISABLE (1<<12)
247 #define TS_VMECONTROL_DRIVE_TSIO_EN (1<<20)
248 #define TS_VMECONTROL_BLOCKLEVEL_UPDATE (1<<21)
249 #define TS_VMECONTROL_SLOWER_TRIGGER_RULES (1<<31)
250 
251 /* 0x20 trigger bits and masks */
252 #define TS_TRIGGER_SOURCEMASK 0x000003FF
253 #define TS_TRIGGER_P0 (1<<0)
254 #define TS_TRIGGER_HFBR1 (1<<1)
255 #define TS_TRIGGER_LOOPBACK (1<<2)
256 #define TS_TRIGGER_FPTRG (1<<3)
257 #define TS_TRIGGER_VME (1<<4)
258 #define TS_TRIGGER_TSINPUTS (1<<5)
259 #define TS_TRIGGER_TSREV2 (1<<6)
260 #define TS_TRIGGER_PULSER (1<<7)
261 #define TS_TRIGGER_ENABLE (1<<8)
262 #define TS_TRIGGER_P2BUSY (1<<9)
263 #define TS_TRIGGER_PART(pID) (1<<(pID+11))
264 #define TS_TRIGGER_MONITOR_MASK 0xFFFF0000
265 
266 /* 0x24 sync bits and masks */
267 #define TS_SYNC_SOURCEMASK 0x0000FFFF
268 #define TS_SYNC_P0 (1<<0)
269 #define TS_SYNC_HFBR1 (1<<1)
270 #define TS_SYNC_HFBR5 (1<<2)
271 #define TS_SYNC_FP (1<<3)
272 #define TS_SYNC_LOOPBACK (1<<4)
273 #define TS_SYNC_MONITOR_MASK 0xFFFF0000
274 
275 /* 0x28 busy bits and masks */
276 /* Enable/Disable bits */
277 #define TS_BUSY_SOURCEMASK 0x0000FFFF
278 #define TS_BUSY_SWA (1<<0)
279 #define TS_BUSY_SWB (1<<1)
280 #define TS_BUSY_P2 (1<<2)
281 #define TS_BUSY_FP_FTDC (1<<3)
282 #define TS_BUSY_FP_FADC (1<<4)
283 #define TS_BUSY_FP (1<<5)
284 #define TS_BUSY_P2_TRIGGER_INPUT (1<<6)
285 #define TS_BUSY_LOOPBACK (1<<7)
286 #define TS_BUSY_TI_A (1<<8)
287 #define TS_BUSY_TI_B (1<<9)
288 #define TS_BUSY_HFBR_MASK ((1<<9) | (1<<8))
289 #define TS_BUSY_INT (1<<10)
290 #define TS_BUSY_ALL_BRANCHES (1<<11)
291 #define TS_BUSY_BRANCH1 (1<<12)
292 #define TS_BUSY_BRANCH2 (1<<13)
293 #define TS_BUSY_BRANCH3 (1<<14)
294 #define TS_BUSY_BRANCH4 (1<<15)
295 /* More specific Monitor bits */
296 #define TS_BUSY_MONITOR_SWA (1<<16)
297 #define TS_BUSY_MONITOR_SWB (1<<17)
298 #define TS_BUSY_MONITOR_P2 (1<<18)
299 #define TS_BUSY_MONITOR_FP_FTDC (1<<19)
300 #define TS_BUSY_MONITOR_FP_FADC (1<<20)
301 #define TS_BUSY_MONITOR_FP (1<<21)
302 #define TS_BUSY_MONITOR_LOOPBACK (1<<23)
303 /* MONITOR_TS includes busy from data buffer level */
304 #define TS_BUSY_MONITOR_TS (1<<27)
305 /* MONITOR TI_? is the actual busy level from the fiber, not resulting from buffer level */
306 #define TS_BUSY_MONITOR_TI_A (1<<28)
307 #define TS_BUSY_MONITOR_TI_B (1<<29)
308 #define TS_BUSY_MONITOR_FIBER_BUSY(x) (1<<(x+27))
309 #define TS_BUSY_MONITOR_DUPL (1<<31)
310 #define TS_BUSY_MONITOR_MASK 0xFFFF0000
311 
312 /* 0x2C clock bits and mask */
313 #define TS_CLOCK_INTERNAL (0)
314 #define TS_CLOCK_EXTERNAL (1)
315 #define TS_CLOCK_INPUT_MIX_CONTROL_MASK 0x00000030
316 #define TS_CLOCK_INPUT_MIX_ENABLE (1<<4)
317 
318 /* 0x30 trig1Prescale bits and masks */
319 #define TS_TRIG1PRESCALE_MASK 0x0000FFFF
320 
321 /* 0x34 blockBuffer bits and masks */
322 #define TS_BLOCKBUFFER_BUFFERLEVEL_MASK 0x000000FF
323 #define TS_BLOCKBUFFER_BLOCKS_READY_MASK 0x0000FF00
324 #define TS_BLOCKBUFFER_TRIGGERS_IN_BLOCK 0x00FF0000
325 #define TS_BLOCKBUFFER_BLOCKS_NEEDACK_MASK 0x7F000000
326 #define TS_BLOCKBUFFER_BREADY_INT_MASK 0x0F000000
327 #define TS_BLOCKBUFFER_BUSY_ON_BLOCKLIMIT (1<<28)
328 #define TS_BLOCKBUFFER_SYNCRESET_REQUESTED (1<<30)
329 #define TS_BLOCKBUFFER_SYNCEVENT (1<<31)
330 
331 /* 0x38 triggerRule bits and masks */
332 #define TS_TRIGGERRULE_RULE1_MASK 0x000000FF
333 #define TS_TRIGGERRULE_RULE2_MASK 0x0000FF00
334 #define TS_TRIGGERRULE_RULE3_MASK 0x00FF0000
335 #define TS_TRIGGERRULE_RULE4_MASK 0xFF000000
336 
337 /* 0x3C triggerWindow bits and masks */
338 #define TS_TRIGGERWINDOW_COINC_MASK 0x000000FF
339 #define TS_TRIGGERWINDOW_INHIBIT_MASK 0x0000FF00
340 #define TS_TRIGGERWINDOW_TRIG21_DELAY_MASK 0x00FF0000
341 
342 /* 0x4C output bits and masks */
343 #define TS_OUTPUT_FP_MASK 0x0000003F
344 #define TS_OUTPUT_FP_1 (1<<0)
345 #define TS_OUTPUT_FP_2 (1<<1)
346 #define TS_OUTPUT_FP_3 (1<<2)
347 #define TS_OUTPUT_FP_4 (1<<3)
348 #define TS_OUTPUT_FP_5 (1<<4)
349 #define TS_OUTPUT_FP_6 (1<<5)
350 #define TS_OUTPUT_BLOCKS_FOR_INT_MASK 0xFFFF0000
351 
352 /* 0x50 fiberSyncDelay bits and masks */
353 #define TS_FIBERSYNCDELAY_HFBR1_SYNCDELAY_MASK 0x0000FF00
354 #define TS_FIBERSYNCDELAY_LOOPBACK_SYNCDELAY_MASK 0x00FF0000
355 #define TS_FIBERSYNCDELAY_HFBR5_SYNCDELAY_MASK 0xFF000000
356 
357 /* 0x70 fpInputPrescale[3] Masks (Duplication Mode) */
358 #define TS_DUPL_LOCAL_TRIG_RULE_MASK 0x0000007F
359 #define TS_DUPL_LOCAL_TRIG_WIDTH_MASK 0x0000FF00
360 #define TS_DUPL_FAST_CLEAR_WIDTH_MASK 0x00FF0000
361 #define TS_DUPL_FAST_CLEAR_VETO_WIDTH_MASK 0xFF000000
362 
363 /* 0x74 specialEvTypes masks */
364 #define TS_SPECIALEVTYPES_MULT_GTP_OR_FP_MASK 0x000000FF
365 #define TS_SPECIALEVTYPES_GTP_AND_FP_MASK 0x0000FF00
366 #define TS_SPECIALEVTYPES_VME_MASK 0x00FF0000
367 #define TS_SPECIALEVTYPES_PULSER_MASK 0xFF000000
368 
369 /* 0x78 syncCommand bits and masks */
370 #define TS_SYNCCOMMAND_VME_CLOCKRESET 0x11
371 #define TS_SYNCCOMMAND_CLK250_RESYNC 0x22
372 #define TS_SYNCCOMMAND_AD9510_RESYNC 0x33
373 #define TS_SYNCCOMMAND_GTP_STATUSB_RESET 0x44
374 #define TS_SYNCCOMMAND_TRIGGERLINK_ENABLE 0x55
375 #define TS_SYNCCOMMAND_TRIGGERLINK_DISABLE 0x77
376 #define TS_SYNCCOMMAND_SYNCRESET_HIGH 0x99
377 #define TS_SYNCCOMMAND_TRIGGER_READY_RESET 0xAA
378 #define TS_SYNCCOMMAND_RESET_EVNUM 0xBB
379 #define TS_SYNCCOMMAND_SYNCRESET_LOW 0xCC
380 #define TS_SYNCCOMMAND_SYNCRESET 0xDD
381 #define TS_SYNCCOMMAND_SYNCRESET_4US 0xEE
382 #define TS_SYNCCOMMAND_SYNCCODE_MASK 0x000000FF
383 
384 /* 0x7C syncDelay bits and masks */
385 #define TS_SYNCDELAY_MASK 0x0000007F
386 
387 /* 0x80 syncWidth bits and masks */
388 #define TS_SYNCWIDTH_MASK 0x7F
389 #define TS_SYNCWIDTH_LONGWIDTH_ENABLE (1<<7)
390 
391 /* 0x84 triggerCommand bits and masks */
392 #define TS_TRIGGERCOMMAND_VALUE_MASK 0x000000FF
393 #define TS_TRIGGERCOMMAND_CODE_MASK 0x00000F00
394 #define TS_TRIGGERCOMMAND_TRIG1 0x00000100
395 #define TS_TRIGGERCOMMAND_TRIG2 0x00000200
396 #define TS_TRIGGERCOMMAND_SYNC_EVENT 0x00000300
397 #define TS_TRIGGERCOMMAND_SET_BLOCKLEVEL 0x00000800
398 
399 
400 /* 0x88 randomPulser bits and masks */
401 #define TS_RANDOMPULSER_TRIG1_RATE_MASK 0x0000000F
402 #define TS_RANDOMPULSER_TRIG1_ENABLE (1<<7)
403 #define TS_RANDOMPULSER_TRIG2_RATE_MASK 0x00000F00
404 #define TS_RANDOMPULSER_TRIG2_ENABLE (1<<15)
405 
406 /* 0x8C fixedPulser1 bits and masks */
407 #define TS_FIXEDPULSER1_NTRIGGERS_MASK 0x0000FFFF
408 #define TS_FIXEDPULSER1_PERIOD_MASK 0x7FFF0000
409 #define TS_FIXEDPULSER1_PERIOD_RANGE (1<<31)
410 
411 /* 0x90 fixedPulser2 bits and masks */
412 #define TS_FIXEDPULSER2_NTRIGGERS_MASK 0x0000FFFF
413 #define TS_FIXEDPULSER2_PERIOD_MASK 0x7FFF0000
414 #define TS_FIXEDPULSER2_PERIOD_RANGE (1<<31)
415 
416 /* 0x94 nblocks bits and masks */
417 #define TS_NBLOCKS_COUNT_MASK 0x00FFFFFF
418 #define TS_NBLOCKS_EVENTS_IN_BLOCK_MASK 0xFF000000
419 
420 /* 0xA0 duplBusyTime bits and masks */
421 
422 /* 0xA4 duplBusyStatus bits and masks */
423 
424 /* 0xB0 GTPStatusA bits and masks */
425 #define TS_GTPSTATUSA_RESET_DONE_MASK 0x000000FF
426 #define TS_GTPSTATUSA_PLL_LOCK_MASK 0x00000F00
427 
428 /* 0xB4 GTPStatusB bits and masks */
429 #define TS_GTPSTATUSB_CHANNEL_BONDING_MASK 0x000000FF
430 #define TS_GTPSTATUSB_DATA_ERROR_MASK 0x0000FF00
431 #define TS_GTPSTATUSB_DISPARITY_ERROR_MASK 0x00FF0000
432 #define TS_GTPSTATUSB_DATA_NOT_IN_TABLE_ERROR_MASK 0xFF000000
433 
434 /* 0xB8 GTPtriggerBufferLength bits and masks */
435 #define TS_GTPTRIGGERBUFFERLENGTH_GLOBAL_LENGTH_MASK 0x000007FF
436 #define TS_GTPTRIGGERBUFFERLENGTH_SUBSYS_LENGTH_MASK 0x07FF0000
437 #define TS_GTPTRIGGERBUFFERLENGTH_HFBR1_MGT_ERROR (1<<28)
438 #define TS_GTPTRIGGERBUFFERLENGTH_CLK250_DCM_LOCK (1<<29)
439 #define TS_GTPTRIGGERBUFFERLENGTH_CLK125_DCM_LOCK (1<<30)
440 #define TS_GTPTRIGGERBUFFERLENGTH_VMECLK_DCM_LOCK (1<<31)
441 
442 /* 0xC0 blockStatus bits and masks */
443 #define TS_BLOCKSTATUS_NBLOCKS_READY0 0x000000FF
444 #define TS_BLOCKSTATUS_NBLOCKS_NEEDACK0 0x0000FF00
445 #define TS_BLOCKSTATUS_NBLOCKS_READY1 0x00FF0000
446 #define TS_BLOCKSTATUS_NBLOCKS_NEEDACK1 0xFF000000
447 
448 /* 0xD0 adr24 bits and masks */
449 #define TS_ADR24_ADDRESS_MASK 0x0000001F
450 #define TS_ADR24_HARDWARE_SET_MASK 0x000003E0
451 #define TS_ADR24_TM_NBLOCKS_READY1 0x00FF0000
452 #define TS_ADR24_TM_NBLOCKS_NEEDACK1 0xFF000000
453 
454 /* 0xD4 syncEventCtrl bits and masks */
455 #define TS_SYNCEVENTCTRL_NBLOCKS_MASK 0x00FFFFFF
456 
457 /* 0xD8 eventNumber_hi bits and masks */
458 #define TS_EVENTNUMBER_FIBER_A_ENABLE (1<<0)
459 #define TS_EVENTNUMBER_FIBER_B_ENABLE (1<<1)
460 #define TS_EVENTNUMBER_FIBER_A_TRANSCEIVER_MISSING (1<<4)
461 #define TS_EVENTNUMBER_FIBER_A_INT_NOT_REQUESTED (1<<5)
462 #define TS_EVENTNUMBER_FIBER_B_TRANSCEIVER_MISSING (1<<6)
463 #define TS_EVENTNUMBER_FIBER_B_INT_NOT_REQUESTED (1<<7)
464 #define TS_EVENTNUMBER_HI_MASK 0xFFFF0000
465 
466 /* 0xE0-0xE8 TI ID bits and masks */
467 #define TS_ID_TRIGSRC_ENABLE_MASK 0x000000FF
468 #define TS_ID_CRATEID_MASK 0x0000FF00
469 
470 /* 0x100 reset bits and masks */
471 #define TS_RESET_I2C (1<<1)
472 #define TS_RESET_JTAG (1<<2)
473 #define TS_RESET_SFM (1<<3)
474 #define TS_RESET_SOFT (1<<4)
475 #define TS_RESET_BUSYACK (1<<7)
476 #define TS_RESET_CLK250 (1<<8)
477 #define TS_RESET_CLK200 (1<<8)
478 #define TS_RESET_CLK125 (1<<9)
479 #define TS_RESET_MGT (1<<10)
480 #define TS_RESET_AUTOALIGN_HFBR1_SYNC (1<<11)
481 #define TS_RESET_AUTOALIGN_HFBR5_SYNC (1<<12)
482 #define TS_RESET_RAM_WRITE (1<<12)
483 #define TS_RESET_IODELAY (1<<14)
484 #define TS_RESET_MEASURE_LATENCY (1<<15)
485 #define TS_RESET_TAKE_TOKEN (1<<16)
486 #define TS_RESET_FORCE_SYNCEVENT (1<<20)
487 #define TS_RESET_SYNCRESET_REQUEST (1<<23)
488 #define TS_RESET_LATCH_TIMERS (1<<24)
489 #define TS_RESET_RESET_L1A_NUMBER (1<<25)
490 #define TS_RESET_PART_ACK(pID) (1<<(pID+25))
491 #define TS_RESET_FILL_TO_END_BLOCK (1<<31)
492 
493 /* 0x104 fpDelay Masks */
494 #define TS_FPDELAY_MASK(x) (0x1FF<<(10*(x%3)))
495 
496 /* 0x118 fpDelay[5] -> Duplication Mode fast clear delay */
497 #define TS_DUPL_FAST_CLEAR_DELAY_MASK 0x0007fc00
498 
499 /* 0x11C fpDelay[6] -> Duplication Mode busy extension setting */
500 #define TS_DUPL_LOCAL_TRIG_BUSY_MASK 0x000003FF
501 #define TS_DUPL_FAST_CLEAR_BUSY_MASK 0x3FF00000
502 
503 /* 0x138 triggerRuleMin In partition struct part1 */
504 #define TS_TRIGGERRULEMIN_MIN2_MASK 0x00007F00
505 #define TS_TRIGGERRULEMIN_MIN2_EN (1<<15)
506 #define TS_TRIGGERRULEMIN_MIN3_MASK 0x007F0000
507 #define TS_TRIGGERRULEMIN_MIN3_EN (1<<23)
508 #define TS_TRIGGERRULEMIN_MIN4_MASK 0x7F000000
509 #define TS_TRIGGERRULEMIN_MIN4_EN (1<<31)
510 
511 /* Define default Interrupt vector and level */
512 #define TS_INT_VEC 0xc8
513 #define TS_INT_LEVEL 5
514 
515 /* i2c data masks - 16bit data default */
516 #define TS_I2C_DATA_MASK 0x0000ffff
517 #define TS_I2C_8BIT_DATA_MASK 0x000000ff
518 
519 /* Scaler registers */
520 #define TS_SCALER_SCALE_HI_MSB_MASK 0x0000007f
521 #define TS_SCALER_SCALE_HI_LSB_MASK 0x7fffff80
522 #define TS_SCALER_SCALE_HI (1<<31)
523 
524 /* Partition registers */
525 #define TS_PART_BLOCKBUFFER_EVENTS_LEFT_IN_BLOCK_MASK 0xFF000000
526 #define TS_PART_BLOCKBUFFER_BLOCKS_READY_MASK 0x00FFFF00
527 #define TS_PART_BLOCKBUFFER_BLOCKLEVEL_MASK 0x000000FF
528 
529 #define TS_PART_BLOCKBUFFERINFO_BLOCKS_READY_MASK 0x00FFFF00
530 
531 #define TS_PART_BUSYCONFIG_BUFFERLEVEL_MASK 0xFF000000
532 #define TS_PART_BUSYCONFIG_BUSYSRC_MASK 0x00F00000
533 #define TS_PART_BUSYCONFIG_TI_B (1<<23)
534 #define TS_PART_BUSYCONFIG_TI_A (1<<22)
535 #define TS_PART_BUSYCONFIG_FP (1<<21)
536 #define TS_PART_BUSYCONFIG_SWB (1<<20)
537 #define TS_PART_BUSYCONFIG_BUFFERLEVEL_ENABLE (1<<17)
538 #define TS_PART_BUSYCONFIG_ALMOSTFULL_ENABLE (1<<16)
539 #define TS_PART_BUSYCONFIG_TD_INPUT_MASK 0x0000FFFF
540 
541 #define TS_PART_BUSYTIME_MASK 0x0000FFFF
542 
543 
544 /* Data buffer bits and masks */
545 #define TS_EMPTY_FIFO 0xF545BAD5
546 #define TS_BLOCK_HEADER_CRATEID_MASK 0xFF000000
547 #define TS_BLOCK_HEADER_SLOTS_MASK 0x001F0000
548 #define TS_BLOCK_TRAILER_CRATEID_MASK 0x00FF0000
549 #define TS_BLOCK_TRAILER_SLOTS_MASK 0x1F000000
550 #define TS_DATA_BLKNUM_MASK 0x0000FF00
551 #define TS_DATA_BLKLEVEL_MASK 0x000000FF
552 
553 #define TS_DATAFORMAT_DATA_TYPE_WORD (1<<31)
554 #define TS_DATAFORMAT_TYPE_MASK 0x78000000
555 #define TS_DATAFORMAT_FILLER_WORD_TYPE 0x78000000
556 #define TS_DATAFORMAT_TYPE_BLOCK_HEADER 0
557 #define TS_DATAFORMAT_BLOCKHEADER_SLOT_MASK 0x07C00000
558 #define TS_DATAFORMAT_BLOCKHEADER_MODID_MASK 0x003C0000
559 #define TS_DATAFORMAT_BLOCKHEADER_BLKNUM_MASK 0x0003FF00
560 #define TS_DATAFORMAT_BLOCKHEADER_NEVTS_MASK 0x000000FF
561 #define TS_DATAFORMAT_TYPE_BLOCK_TRAILER 1
562 #define TS_DATAFORMAT_BLOCKTRAILER_SLOT_MASK 0x07C00000
563 #define TS_DATAFORMAT_BLOCKTRAILER_NWORDS_MASK 0x003FFFFF
564 
565 /* tsInit initialization flag bits */
566 #define TS_INIT_NO_INIT (1<<0)
567 #define TS_INIT_SKIP_FIRMWARE_CHECK (1<<2)
568 #define TS_INIT_DUPLICATION_MODE (1<<3)
569 
570 
571 /* Some pre-initialization routine prototypes */
572 int tsSetCrateID_preInit(int cid);
573 
574 /* Function prototypes */
575 int tsInit(unsigned int tAddr, unsigned int mode, int force);
576 unsigned int tsFind();
577 int tsCheckAddresses();
578 void tsStatus(int pflag);
579 void tsSlaveStatus(int pflag);
580 int tsGetPortTrigSrcEnabled(int port);
583 int tsReset();
584 int tsReload();
585 unsigned int tsGetSerialNumber(char **rSN);
586 int tsClockResync();
587 int tsSetCrateID(unsigned int crateID);
588 int tsGetCrateID(int port);
589 int tsSetBlockLevel(int blockLevel);
590 int tsBroadcastNextBlockLevel(int blockLevel);
591 int tsGetNextBlockLevel();
593 int tsSetInstantBlockLevelChange(int enable);
595 int tsSetInputMix(int enable);
596 int tsGetInputMix();
597 int tsSetGTPInput(unsigned int inputmask);
598 int tsSetFPInput(unsigned int inputmask);
599 int tsSetTriggerSource(int trig);
600 int tsSetTriggerSourceMask(int trigmask);
601 int tsDisableTriggerSource(int fflag);
602 int tsSetSyncSource(unsigned int sync);
603 int tsSetEventFormat(int format);
604 int tsSoftTrig(int trigger, unsigned int nevents, unsigned int period_inc, int range);
605 int tsSetRandomTrigger(int trigger, int setting);
607 int tsReadBlock(volatile unsigned int *data, int nwrds, int rflag);
608 int tsReadTriggerBlock(volatile unsigned int *data);
609 int tsReadScalers(volatile unsigned int *data, int choice);
610 int tsPrintScalers(int choice);
611 int tsSetBusySource(unsigned int sourcemask, int rFlag);
612 void tsEnableBusError();
613 void tsDisableBusError();
614 int tsPayloadPort2VMESlot(int payloadport);
615 int tsPayloadPortMask2VMESlotMask(int payloadport_mask);
616 int tsVMESlot2PayloadPort(int vmeslot);
617 int tsVMESlotMask2PayloadPortMask(int vmeslot_mask);
618 int tsSetPrescale(int prescale);
619 int tsGetPrescale();
620 int tsSetTriggerPulse(int trigger, int delay, int width);
621 void tsTrigLinkReset();
622 void tsSetSyncDelayWidth(unsigned int delay, unsigned int width, int widthstep);
623 void tsSyncReset(int blflag);
624 void tsSyncResetResync();
625 void tsClockReset();
626 void tsUserSyncReset(int enable);
627 void tsTriggerReadyReset();
628 int tsSetAdr32(unsigned int a32base);
629 int tsResetEventCounter();
630 unsigned long long int tsGetEventCounter();
631 int tsSetBlockLimit(unsigned int limit);
632 unsigned int tsGetBlockLimit();
634 int tsSetGTPInputReadout(int enable);
635 int tsSetFPInputReadout(int enable);
636 
637 
638 int tsIntPoll();
639 unsigned int tsGetIntCount();
640 int tsIntConnect(unsigned int vector, VOIDFUNCPTR routine, unsigned int arg);
641 int tsIntDisconnect();
642 int tsAckConnect(VOIDFUNCPTR routine, unsigned int arg);
643 void tsIntAck();
644 int tsIntEnable(int iflag);
645 void tsIntDisable();
646 unsigned int tsBReady();
647 int tsGetSyncEventFlag();
649 int tsSetBlockBufferLevel(unsigned int level);
651 
652 
653 
654 int tsTriggerTableConfig(unsigned int **itable);
655 int tsGetTriggerTable(unsigned int **otable);
656 int tsDefineEventType(int inputType, unsigned int trigMask, int hwTrig, int evType);
657 int tsDefineSpecialEventType(int trigOpt, int evType);
658 int tsGetSpecialEventType(int trigOpt);
659 void tsTriggerTableDefault();
660 int tsLoadTriggerTable();
661 void tsPrintTriggerTable(int inputType, int subGroup, int showbits);
662 
663 unsigned int tsGetDaqStatus();
664 int tsSetOutputPort(unsigned int set1, unsigned int set2, unsigned int set3,
665  unsigned int set4, unsigned int set5, unsigned int set6);
666 int tsSetClockSource(unsigned int source);
667 void tsResetIODelay();
668 int tsVmeTrigger1();
669 int tsVmeTrigger2();
670 void tsSetFiberDelay(unsigned int number, unsigned int offset);
671 int tsResetSlaveConfig();
672 int tsAddSlave(unsigned int fiber);
673 int tsRemoveSlave(unsigned int fiber);
674 int tsSetTriggerHoldoff(int rule, unsigned int value, int timestep);
675 int tsGetTriggerHoldoff(int rule);
676 int tsSetTriggerHoldoffMin(int rule, unsigned int value);
677 int tsGetTriggerHoldoffMin(int rule, int pflag);
678 int tsLoadTriggerTable();
679 unsigned int tsGetLiveTime();
680 unsigned int tsGetBusyTime();
681 unsigned int tsGetLiveTime_InputHigh();
682 unsigned int tsGetBusyTime_InputHigh();
683 int tsLive(int sflag);
684 unsigned int tsBlockStatus(int fiber, int pflag);
685 int tsGetBusyStatus(int pflag);
686 int tsSetSyncEventInterval(int blk_interval);
687 int tsForceSyncEvent();
688 int tsSyncResetRequest();
690 int tsFillToEndBlock();
691 int tsCurrentBlockFilled(unsigned short npoll);
692 int tsResetMGT();
693 int tsSetFPDelay(int chan, int delay);
694 int tsGetFPDelay(int chan);
695 int tsPrintFPDelay();
696 int tsSetTSIODrive(int enable);
697 int tsGetTSIODrive();
699 int tsReadScalersMon(volatile unsigned int *data);
700 int tsSetTrigCoinWindow(unsigned int size);
701 int tsGetTrigCoinWindow();
702 int tsSetTrigInhibitWindow(unsigned int size);
704 
705 /* Partition Mode routine prototypes */
706 int tsPartInit(int pID, unsigned int tAddr, unsigned int mode, int iFlag);
707 int tsPartSetBusySource(int busysrc);
708 int tsPartSetBlockBufferLevel(unsigned int bufferlevel);
709 int tsPartSetTDInput(unsigned int tdinput);
710 int tsPartSetFPInput(unsigned short input1, unsigned short input2, unsigned short input3);
711 int tsPartSetGTPInput(unsigned short input1, unsigned short input2, unsigned short input3, unsigned short input4, unsigned short input5);
713 int tsPartReadBlock(volatile unsigned int *data, int nwrds);
714 unsigned int tsPartBReady();
715 void tsPartIntAck();
716 int tsPartIntEnable(int iflag);
717 void tsPartIntDisable();
718 int tsPartIntConnect(VOIDFUNCPTR routine, unsigned int arg);
719 int tsPartIntDisconnect();
720 
721 /* Duplication Mode routine prototypes */
722 int tsDuplMode(int set);
723 int tsDuplSetBranchEnable(int b1, int b2, int b3, int b4);
724 int tsDuplSetLocalTrigComboMask(unsigned int mask);
725 unsigned int tsDuplGetLocalTrigComboMask();
726 int tsDuplSetLocalTrigCombo(unsigned int mask, int set);
727 int tsDuplSetTriggerHoldoff(unsigned int value);
729 int tsPrintTriggerHoldoff(int dflag);
730 int tsDuplSetLocalTriggerWidth(int width);
732 int tsDuplSetFastClearWidth(int width);
734 int tsDuplSetFastClearDelay(int delay);
736 int tsDuplSetFastClearVetoWidth(int width);
738 int tsDuplSetLocalTrigBusy(int value);
740 int tsDuplSetFastClearBusy(int value);
742 int tsDuplGetBusyTime();
743 unsigned int tsDuplGetBusyStatus();
745 
746 #endif /* TSLIB_H */
int tsDuplGetLocalTriggerWidth()
Definition: tsLib.c:7419
int tsSetGTPInput(unsigned int inputmask)
Set which GTP inputs are enabled.
Definition: tsLib.c:1690
int tsIntConnect(unsigned int vector, VOIDFUNCPTR routine, unsigned int arg)
Connect a user routine to the TS Interrupt or latched trigger, if polling.
Definition: tsLib.c:3772
void tsSyncResetResync()
Generate a Sync Reset Resync signal.
Definition: tsLib.c:3261
void tsDisableBusError()
Disable Bus Errors to terminate Block Reads.
Definition: tsLib.c:2761
Definition: tsLib.h:59
volatile unsigned int FPTriggerTable
Definition: tsLib.h:80
int tsSetBusySource(unsigned int sourcemask, int rFlag)
Set the busy source with a given sourcemask sourcemask bits:
Definition: tsLib.c:2685
int tsGetNextBlockLevel()
Get the block level that will be updated on the end of the block readout.
Definition: tsLib.c:1500
volatile unsigned int GTPtriggerBufferLength
Definition: tsLib.h:127
volatile unsigned int data
Definition: tsLib.h:68
void tsTriggerTableDefault()
Configure trigger table to be loaded with a predefined trigger table (mapping GTP and FP inputs to tr...
Definition: tsLib.c:4909
int tsReadTriggerBlock(volatile unsigned int *data)
Read a block from the TS and form it into a CODA Trigger Bank.
Definition: tsLib.c:2355
int tsDuplGetBusyTime()
Definition: tsLib.c:7795
volatile unsigned int triggerRule
Definition: tsLib.h:99
int tsDuplSetLocalTrigBusy(int value)
Definition: tsLib.c:7657
int tsPayloadPort2VMESlot(int payloadport)
Routine to return the VME slot, provided the VXS payload port.
Definition: tsLib.c:2785
volatile unsigned int blockBuffer
Definition: tsLib.h:98
unsigned int tsBReady()
Returns the number of Blocks available for readout.
Definition: tsLib.c:4108
Definition: tsLib.h:83
unsigned int tsGetIntCount()
Return current readout count.
Definition: tsLib.c:3621
volatile unsigned int eJTAGLoad
Definition: tsLib.h:159
volatile unsigned int dataFormat
Definition: tsLib.h:91
unsigned int tsFind()
Find the TS within the prescribed "GEO Slot to A24 VME Address" range from slot 2 to 21...
Definition: tsLib.c:454
volatile unsigned int nblocks
Definition: tsLib.h:118
int tsCheckAddresses()
Definition: tsLib.c:520
volatile unsigned int fpScaler
Definition: tsLib.h:137
volatile unsigned int boardID
Definition: tsLib.h:85
int tsSetSyncSource(unsigned int sync)
Set the Sync source mask.
Definition: tsLib.c:1913
int tsGetSyncResetRequest()
Determine if a TI has requested a Sync Reset.
Definition: tsLib.c:5790
int tsGetTrigInhibitWindow()
Get the trigger inhibit window.
Definition: tsLib.c:6256
volatile unsigned int sync
Definition: tsLib.h:94
int tsGetInstantBlockLevelChange()
Get Status of instant blocklevel change when broadcast is received.
Definition: tsLib.c:1600
Definition: tsLib.h:77
int tsAckConnect(VOIDFUNCPTR routine, unsigned int arg)
Connect a user routine to be executed instead of the default TS interrupt/trigger latching acknowledg...
Definition: tsLib.c:3939
int tsGetTrigCoinWindow()
Get the trigger coincidence window.
Definition: tsLib.c:6201
int tsDuplSetFastClearWidth(int width)
Definition: tsLib.c:7450
int tsSetTSIODrive(int enable)
Enable/Disable the FPGA drive to the TSIO.
Definition: tsLib.c:6001
int tsSetEventFormat(int format)
Set the event format.
Definition: tsLib.c:1949
volatile unsigned int trigDelay
Definition: tsLib.h:88
volatile unsigned int GTPtrigger
Definition: tsLib.h:101
int tsSetClockSource(unsigned int source)
Set the clock to the specified source.
Definition: tsLib.c:4274
int tsReadBlock(volatile unsigned int *data, int nwrds, int rflag)
Read a block of events from the TI.
Definition: tsLib.c:2167
int tsIntDisconnect()
Disable interrupts or kill the polling service thread.
Definition: tsLib.c:3862
void tsSetFiberDelay(unsigned int number, unsigned int offset)
volatile unsigned int trigger
Definition: tsLib.h:93
int tsPartReadBlock(volatile unsigned int *data, int nwrds)
Read a block of events from the current TS partition.
Definition: tsLib.c:6741
volatile unsigned int hel_livetime
Definition: tsLib.h:72
int tsForceSyncEvent()
Force a sync event (type = 0).
Definition: tsLib.c:5741
volatile unsigned int GTP[8]
Definition: tsLib.h:54
unsigned int tsGetSerialNumber(char **rSN)
Get the Module Serial Number.
Definition: tsLib.c:1279
volatile unsigned int blocklimit
Definition: tsLib.h:140
int tsResetEventCounter()
Reset the L1A counter, as incremented by the TS.
Definition: tsLib.c:3430
int tsGetSyncEventReceived()
Return the value of whether or not the sync event has been received.
Definition: tsLib.c:4167
int tsGetCrateID(int port)
Get the crate ID of the selected port.
Definition: tsLib.c:1404
int tsDuplSetLocalTriggerWidth(int width)
Definition: tsLib.c:7381
int tsGetSpecialEventType(int trigOpt)
Get the trigger type for the specified special trigger.
Definition: tsLib.c:5107
int tsDuplGetFastClearWidth()
Definition: tsLib.c:7488
void tsEnableBusError()
Enable Bus Errors to terminate Block Reads.
Definition: tsLib.c:2737
int tsPrintFPDelay()
Print Front Panel Channel Delays to Standard Out.
Definition: tsLib.c:5962
int tsSetInputMix(int enable)
Set option to mix FP and GTP inputs Effectively swaps the FP(16:1) -> GTP&#39;(32:17) and GTP(32:17) -> F...
Definition: tsLib.c:1631
volatile unsigned int fp[4]
Definition: tsLib.h:53
int tsDefineSpecialEventType(int trigOpt, int evType)
Set the trigger type for the specified special trigger.
Definition: tsLib.c:5042
int tsSetTrigInhibitWindow(unsigned int size)
Set the trigger inhibit window.
Definition: tsLib.c:6227
volatile unsigned int duplBusyTime
Definition: tsLib.h:121
int tsGetTrigSrcEnabledFiberMask()
Returns the mask of fiber channels that report a "connected" status from a TI has it&#39;s trigger source...
Definition: tsLib.c:1184
int tsSetTriggerSource(int trig)
Set the trigger source.
Definition: tsLib.c:1743
int tsDuplSetBranchEnable(int b1, int b2, int b3, int b4)
Definition: tsLib.c:7152
volatile unsigned int triggerWindow
Definition: tsLib.h:100
int tsSetCrateID(unsigned int crateID)
Set the crate ID.
Definition: tsLib.c:1368
int tsResetSlaveConfig()
Reset the configuration of TI Slaves on the TS. This routine removes all slaves and resets the fiber ...
Definition: tsLib.c:4345
volatile unsigned int inputCounter
Definition: tsLib.h:128
void tsSlaveStatus(int pflag)
Print a summary of all fiber port connections to potential TI Slaves.
Definition: tsLib.c:1007
void tsPartIntAck()
Acknowledge an interrupt or latched trigger for this partition.
Definition: tsLib.c:6831
int tsVmeTrigger2()
int tsSetBlockLevel(int blockLevel)
Set the number of events per block.
Definition: tsLib.c:1441
int tsDuplGetFastClearVetoWidth()
Definition: tsLib.c:7626
unsigned int tsPartBReady()
Returns the number of Blocks available for readout for this partition.
Definition: tsLib.c:6804
void tsClockReset()
Generate a Clock Reset signal. This signal is sent to the loopback and all configured TI Slaves...
Definition: tsLib.c:3283
volatile unsigned int eventNumber_lo
Definition: tsLib.h:133
unsigned int tsGetLiveTime_InputHigh()
Return the current "live" time of the module.
Definition: tsLib.c:5455
int tsSetTrigCoinWindow(unsigned int size)
Set the trigger coincidence window.
Definition: tsLib.c:6166
volatile unsigned int syncCommand
Definition: tsLib.h:111
int tsPartIntConnect(VOIDFUNCPTR routine, unsigned int arg)
Connect a user routine to the TS Interrupt or latched trigger, if polling.
Definition: tsLib.c:7026
int tsDisableTriggerSource(int fflag)
Disable trigger sources.
Definition: tsLib.c:1871
volatile unsigned int fpConfig
Definition: tsLib.h:64
int tsBroadcastNextBlockLevel(int blockLevel)
Broadcast the next block level (to be changed at the end of the next sync event, or during a call to ...
Definition: tsLib.c:1458
unsigned int blank2
Definition: tsLib.h:145
volatile unsigned int syncDelay
Definition: tsLib.h:112
volatile unsigned int fixedPulser2
Definition: tsLib.h:117
volatile unsigned int adr32
Definition: tsLib.h:89
unsigned int tsGetDaqStatus()
int tsVMESlotMask2PayloadPortMask(int vmeslot_mask)
int tsGetTriggerHoldoff(int rule)
Get the value for a specified trigger rule.
Definition: tsLib.c:4585
int tsSetOutputPort(unsigned int set1, unsigned int set2, unsigned int set3, unsigned int set4, unsigned int set5, unsigned int set6)
Set (or unset) high level for the user controllable output ports on the front panel.
Definition: tsLib.c:4233
volatile unsigned int syncWidth
Definition: tsLib.h:113
int tsSyncResetRequest()
Sync Reset Request is sent to TI-Master or TS.
Definition: tsLib.c:5768
int tsDuplGetLocalTrigBusy()
Definition: tsLib.c:7695
int tsDuplGetFastClearBusy()
Definition: tsLib.c:7764
int tsPartIntEnable(int iflag)
Enable interrupts or latching triggers for this partition.
Definition: tsLib.c:6927
int tsGetTriggerTable(unsigned int **otable)
Get the current trigger table stored in local memory (not necessarily on TS).
Definition: tsLib.c:4884
volatile unsigned int master_tiID
Definition: tsLib.h:135
int tsVmeTrigger1()
int tsSoftTrig(int trigger, unsigned int nevents, unsigned int period_inc, int range)
Set and enable the "software" trigger.
Definition: tsLib.c:2013
int tsDuplGetFastClearDelay()
Definition: tsLib.c:7557
int tsResetMGT()
Reset the MGT.
Definition: tsLib.c:5871
int tsGetBusyStatus(int pflag)
Returns the bits that are contributing to the current busy state.
Definition: tsLib.c:5619
int tsPartSetBusySource(int busysrc)
Set the busy source for this partition.
Definition: tsLib.c:6485
int tsVMESlot2PayloadPort(int vmeslot)
Routine to return the VXS payload port, provided the VME Slot.
Definition: tsLib.c:2822
int tsDuplPrintBusyStatus()
Definition: tsLib.c:7857
int tsDisableRandomTrigger()
Disable random trigger generation.
Definition: tsLib.c:2138
volatile unsigned int blockBuffer
Definition: tsLib.h:61
unsigned long long int tsGetEventCounter()
Returns the event counter (48 bit)
Definition: tsLib.c:3452
volatile unsigned int eventNumber_hi
Definition: tsLib.h:132
unsigned int blank0
Definition: tsLib.h:63
volatile unsigned int busyConfig
Definition: tsLib.h:70
volatile unsigned int fixedPulser1
Definition: tsLib.h:116
int tsDuplSetLocalTrigCombo(unsigned int mask, int set)
Definition: tsLib.c:7259
int tsDuplMode(int set)
Enable/Disable Duplication Mode.
Definition: tsLib.c:7126
int tsSetFPDelay(int chan, int delay)
Set the input delay for teh specified front panel input (0-31)
Definition: tsLib.c:5895
volatile unsigned int specialEvTypes
Definition: tsLib.h:110
Definition: tsLib.h:51
pthread_mutex_t tsISR_mutex
Definition: tsLib.h:26
volatile unsigned int triggerRuleMin
Definition: tsLib.h:62
volatile unsigned int output
Definition: tsLib.h:104
int tsLive(int sflag)
Calculate the live time (percentage) from the live and busy time scalers.
Definition: tsLib.c:5505
int tsDuplSetFastClearVetoWidth(int width)
Definition: tsLib.c:7588
int tsIntEnable(int iflag)
Enable interrupts or latching triggers (depending on set TS mode)
Definition: tsLib.c:4008
unsigned int blank1
Definition: tsLib.h:136
unsigned int blank0
Definition: tsLib.h:119
volatile unsigned int vmeControl
Definition: tsLib.h:92
int tsLoadTriggerTable()
Load up the default trigger lookup table for the TS.
Definition: tsLib.c:5226
int tsCurrentBlockFilled(unsigned short npoll)
Poll the TS to determine status of current block, for specified number of times. Return immediately w...
Definition: tsLib.c:5839
unsigned int tsGetBusyTime()
Return the current "busy" time of the module.
Definition: tsLib.c:5431
void tsIntDisable()
Disable interrupts or latching triggers.
Definition: tsLib.c:4082
volatile unsigned int trig1Prescale
Definition: tsLib.h:97
void tsPrintTriggerTable(int inputType, int subGroup, int showbits)
Print trigger table to standard out.
Definition: tsLib.c:5257
int tsTriggerTableConfig(unsigned int **itable)
Configure trigger table to be loaded with a user provided array.
Definition: tsLib.c:4857
void tsStatus(int pflag)
Print some status information of the TS to standard out.
Definition: tsLib.c:682
volatile unsigned int fiber
Definition: tsLib.h:86
unsigned int tsGetBlockLimit()
Returns the value that is currently programmed as the block limit.
Definition: tsLib.c:3502
volatile unsigned int randomPulser
Definition: tsLib.h:115
volatile unsigned int syncEventCtrl
Definition: tsLib.h:131
int tsPartIntDisconnect()
Disable interrupts or kill the polling service thread.
Definition: tsLib.c:7068
unsigned int tsGetBusyTime_InputHigh()
Return the current "busy" time of the module.
Definition: tsLib.c:5479
int tsPrintTriggerHoldoff(int dflag)
Definition: tsLib.c:4630
int tsSetInstantBlockLevelChange(int enable)
Set TS to instantly change blocklevel when broadcast is received.
Definition: tsLib.c:1572
volatile unsigned int triggerCommand
Definition: tsLib.h:114
int tsPartSetBlockBufferLevel(unsigned int bufferlevel)
Set up the Block Buffer Level.
Definition: tsLib.c:6543
volatile unsigned int genConfig
Definition: tsLib.h:66
int tsFillToEndBlock()
Generate non-physics triggers until the current block is filled. This feature is useful for "end of r...
Definition: tsLib.c:5814
void tsSetSyncDelayWidth(unsigned int delay, unsigned int width, int widthstep)
Set the delay time and width of the Sync signal.
Definition: tsLib.c:3102
int tsReset()
Perform a soft reset of the TS.
Definition: tsLib.c:1346
int tsGetCurrentBlockLevel()
Get the current block level.
Definition: tsLib.c:1529
int tsInit(unsigned int tAddr, unsigned int mode, int force)
Initialize the TSp register space into local memory, and setup registers given user input...
Definition: tsLib.c:188
int tsSetBlockBufferLevel(unsigned int level)
Set the block buffer level for the number of blocks in the system that need to be read out...
Definition: tsLib.c:4197
void tsPartIntDisable()
Disable interrupts or latching triggers for this partition.
Definition: tsLib.c:6988
volatile unsigned int busytime
Definition: tsLib.h:124
volatile unsigned int busytime
Definition: tsLib.h:71
int tsGetTSIODrive()
Return the Enable/Disable status the FPGA drive to the TSIO.
Definition: tsLib.c:6031
volatile unsigned int gtpScaler
Definition: tsLib.h:138
int tsSetTriggerPulse(int trigger, int delay, int width)
Set the characteristics of a specified trigger.
Definition: tsLib.c:3045
int tsSetSyncEventInterval(int blk_interval)
Set the value of the syncronization event interval.
Definition: tsLib.c:5713
volatile unsigned int duplBusyStatus
Definition: tsLib.h:122
int tsSetTriggerSourceMask(int trigmask)
Set trigger sources with specified trigmask.
Definition: tsLib.c:1805
int tsGetSyncEventFlag()
Return the value of the Synchronization flag, obtained from tsBReady. i.e. Return the value of the Sy...
Definition: tsLib.c:4146
volatile unsigned int fpInput
Definition: tsLib.h:102
int tsDuplGetTriggerHoldoff()
Definition: tsLib.c:7350
volatile unsigned int GTPTriggerTable
Definition: tsLib.h:79
unsigned int tsBlockStatus(int fiber, int pflag)
Show block Status of specified fiber.
Definition: tsLib.c:5558
int tsPartLoadTriggerTable()
Load the trigger table for current partition.
Definition: tsLib.c:6710
int tsGetFPDelay(int chan)
Get the input delay for teh specified front panel input (0-31)
Definition: tsLib.c:5933
void tsTriggerReadyReset()
Reset the registers that record the triggers enabled status of TI Slaves.
Definition: tsLib.c:3337
int tsGetInputMix()
Get option to mix FP and GTP inputs Effectively swaps the FP(16:1) -> GTP&#39;(32:17) and GTP(32:17) -> F...
Definition: tsLib.c:1660
int tsSetAdr32(unsigned int a32base)
Routine to set the A32 Base.
Definition: tsLib.c:3359
volatile unsigned int blockBufferInfo
Definition: tsLib.h:69
volatile unsigned int blank[(0x334-0x1D0)/4]
Definition: tsLib.h:56
int tsGetPortTrigSrcEnabled(int port)
Get the trigger sources enabled bits of the selected port.
Definition: tsLib.c:1147
volatile unsigned int genScaler
Definition: tsLib.h:139
volatile unsigned int busy
Definition: tsLib.h:95
volatile unsigned int intsetup
Definition: tsLib.h:87
int tsDuplSetFastClearDelay(int delay)
Definition: tsLib.c:7519
void tsIntAck()
Acknowledge an interrupt or latched trigger. This "should" effectively release the "Busy" state of th...
Definition: tsLib.c:3965
volatile unsigned int triggerTable
Definition: tsLib.h:67
unsigned int tsDuplGetBusyStatus()
Definition: tsLib.c:7826
int tsGetBlockLimitStatus()
Get the current status of the block limit.
Definition: tsLib.c:3526
int tsSetTriggerHoldoffMin(int rule, unsigned int value)
Set the value for the minimum time of specified trigger rule.
Definition: tsLib.c:4728
int tsDuplSetFastClearBusy(int value)
Definition: tsLib.c:7726
int tsDuplSetLocalTrigComboMask(unsigned int mask)
Definition: tsLib.c:7191
int tsSetFPInputReadout(int enable)
Set whether or not the latched pattern of FP Inputs in block readout.
Definition: tsLib.c:3590
int tsReload()
Reload the firmware on the FPGA.
Definition: tsLib.c:1250
int tsClockResync()
Resync the 250 MHz Clock.
Definition: tsLib.c:1320
void tsResetIODelay()
Reset the IO Delay on the TS.
Definition: tsLib.c:4322
volatile unsigned int blocklevel
Definition: tsLib.h:90
int tsSetRandomTrigger(int trigger, int setting)
Set the parameters of the random internal trigger.
Definition: tsLib.c:2088
int tsSetBlockLimit(unsigned int limit)
Set the block number at which triggers will be disabled automatically.
Definition: tsLib.c:3480
volatile unsigned int adr24
Definition: tsLib.h:130
volatile unsigned int GTPStatusB
Definition: tsLib.h:126
volatile unsigned int livetime
Definition: tsLib.h:123
int tsSetCrateID_preInit(int cid)
Set the CrateID to be used during initialization.
Definition: tsLib.c:154
volatile unsigned int gen[8]
Definition: tsLib.h:55
void tsSyncReset(int blflag)
Generate a Sync Reset signal.
Definition: tsLib.c:3229
volatile unsigned int reset
Definition: tsLib.h:141
int tsReadScalersMon(volatile unsigned int *data)
Readout input scalers Returned data: bit 31 0: As stored 1: Shifted by 7 bits (must multiply by 2**7)...
Definition: tsLib.c:6073
int tsGetFirmwareVersion()
Get the Firmware Version.
Definition: tsLib.c:1212
unsigned int tsDuplGetLocalTrigComboMask()
Definition: tsLib.c:7228
void tsTrigLinkReset()
Reset the trigger link.
Definition: tsLib.c:3148
int tsGetTriggerHoldoffMin(int rule, int pflag)
Get the value for a specified trigger rule minimum busy.
Definition: tsLib.c:4796
int tsSetGTPInputReadout(int enable)
Set whether or not the latched pattern of GTP Inputs in block readout.
Definition: tsLib.c:3558
int tsPartSetGTPInput(unsigned short input1, unsigned short input2, unsigned short input3, unsigned short input4, unsigned short input5)
Set the GTP Inputs for this partition.
Definition: tsLib.c:6667
int tsRemoveSlave(unsigned int fiber)
Remove a TI Slave for the TS.
Definition: tsLib.c:4417
volatile unsigned int genInput
Definition: tsLib.h:103
int tsIntPoll()
volatile unsigned int fiberSyncDelay
Definition: tsLib.h:105
volatile unsigned int gtpConfig
Definition: tsLib.h:65
void tsUserSyncReset(int enable)
Control level of the SyncReset signal.
Definition: tsLib.c:3306
int tsSetTriggerHoldoff(int rule, unsigned int value, int timestep)
Set the value for a specified trigger rule.
Definition: tsLib.c:4484
int tsGetDriverSupportedVersion()
Return the Firmware Version that is Supported by the Library.
Definition: tsLib.c:6053
int tsPartInit(int pID, unsigned int tAddr, unsigned int mode, int iFlag)
Initialize a TS partition.
Definition: tsLib.c:6295
int tsPrintScalers(int choice)
Print input scalers to standard out.
Definition: tsLib.c:2620
int tsDuplSetTriggerHoldoff(unsigned int value)
Definition: tsLib.c:7312
int tsAddSlave(unsigned int fiber)
Add and configurate a TI Slave.
Definition: tsLib.c:4373
volatile unsigned int clock
Definition: tsLib.h:96
int tsPartSetFPInput(unsigned short input1, unsigned short input2, unsigned short input3)
Set the FP Inputs for this partition.
Definition: tsLib.c:6623
int tsReadScalers(volatile unsigned int *data, int choice)
Readout input scalers Returned data: bit 31 0: As stored 1: Shifted by 7 bits (must multiply by 2**7)...
Definition: tsLib.c:2512
int tsSetupFiberLoopback()
int tsSetFPInput(unsigned int inputmask)
Set which FP inputs are enabled.
Definition: tsLib.c:1714
unsigned int tsGetLiveTime()
Return the current "live" time of the module.
Definition: tsLib.c:5407
int tsDefineEventType(int inputType, unsigned int trigMask, int hwTrig, int evType)
Define a specific trigger pattern as a hardware trigger (trig1/trig2/syncevent) and Event Type...
Definition: tsLib.c:4962
volatile unsigned int runningMode
Definition: tsLib.h:120
int tsPartSetTDInput(unsigned int tdinput)
Select the input that has the TD Busy.
Definition: tsLib.c:6584
volatile unsigned int GTPStatusA
Definition: tsLib.h:125
volatile unsigned int hel_busytime
Definition: tsLib.h:73
int tsGetPrescale()
Get the current prescale factor.
Definition: tsLib.c:2883
int tsSetPrescale(int prescale)
Set the prescale factor for the external trigger.
Definition: tsLib.c:2855
int tsPayloadPortMask2VMESlotMask(int payloadport_mask)