JLab Pipeline TI Library  3v6.1
tiLib.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 (TI) card
18  *
19  *----------------------------------------------------------------------------*/
20 #ifndef TILIB_H
21 #define TILIB_H
22 
23 #ifndef VXWORKS
24 #include <pthread.h>
25 
26 pthread_mutex_t tiISR_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 { volatile unsigned int boardID; volatile unsigned int fiber; volatile unsigned int intsetup; volatile unsigned int trigDelay; volatile unsigned int adr32; volatile unsigned int blocklevel; volatile unsigned int dataFormat; volatile unsigned int vmeControl; volatile unsigned int trigsrc; volatile unsigned int sync; volatile unsigned int busy; volatile unsigned int clock; volatile unsigned int trig1Prescale; volatile unsigned int blockBuffer; volatile unsigned int triggerRule; volatile unsigned int triggerWindow; unsigned int blank0; volatile unsigned int tsInput; unsigned int blank1; volatile unsigned int output; volatile unsigned int fiberSyncDelay; unsigned int blank2[(0x64-0x54)/4]; volatile unsigned int inputPrescale; unsigned int blank3[(0x74-0x68)/4]; volatile unsigned int pulserEvType; volatile unsigned int syncCommand; volatile unsigned int syncDelay; volatile unsigned int syncWidth; volatile unsigned int triggerCommand; volatile unsigned int randomPulser; volatile unsigned int fixedPulser1; volatile unsigned int fixedPulser2; volatile unsigned int nblocks; volatile unsigned int syncHistory; volatile unsigned int runningMode; volatile unsigned int fiberLatencyMeasurement; volatile unsigned int fiberAlignment; volatile unsigned int livetime; volatile unsigned int busytime; volatile unsigned int GTPStatusA; volatile unsigned int GTPStatusB; volatile unsigned int GTPtriggerBufferLength; volatile unsigned int inputCounter; volatile unsigned int blockStatus[4]; volatile unsigned int adr24; volatile unsigned int syncEventCtrl; volatile unsigned int eventNumber_hi; volatile unsigned int eventNumber_lo; unsigned int blank4[(0xEC-0xE0)/4]; volatile unsigned int rocEnable; unsigned int blank5[(0xFC-0xF0)/4]; volatile unsigned int blocklimit; volatile unsigned int reset; volatile unsigned int fpDelay[2]; unsigned int blank6[(0x110-0x10C)/4]; unsigned int busy_scaler1[7]; unsigned int blank7[(0x138-0x12C)/4]; volatile unsigned int triggerRuleMin; unsigned int blank8; volatile unsigned int trigTable[(0x180-0x140)/4]; volatile unsigned int ts_scaler[6]; unsigned int blank9; volatile unsigned int busy_scaler2[9]; unsigned int blank10[(0x1D0-0x1C0)/4]; volatile unsigned int hfbr_tiID[8]; volatile unsigned int master_tiID; unsigned int blank11[(0x2000-0x1F4)/4]; volatile unsigned int SWB_status[(0x2200-0x2000)/4]; unsigned int blank12[(0x2800-0x2200)/4]; volatile unsigned int SWA_status[(0x3000-0x2800)/4]; unsigned int blank13[(0xFFFC-0x3000)/4]; volatile unsigned int eJTAGLoad; volatile unsigned int JTAGPROMBase[(0x20000-0x10000)/4]; volatile unsigned int JTAGFPGABase[(0x30000-0x20000)/4]; volatile unsigned int SWA[(0x40000-0x30000)/4]; volatile unsigned int SWB[(0x50000-0x40000)/4];
129 };
130 
131 /* Define TI Modes of operation: Ext trigger - Interrupt mode 0
132  TS trigger - Interrupt mode 1
133  Ext trigger - polling mode 2
134  TS trigger - polling mode 3 */
135 #define TI_READOUT_EXT_INT 0
136 #define TI_READOUT_TS_INT 1
137 #define TI_READOUT_EXT_POLL 2
138 #define TI_READOUT_TS_POLL 3
139 
140 /* Supported firmware version */
141 #define TI_SUPPORTED_FIRMWARE 0x061
142 #define TI_SUPPORTED_TYPE 3
143 
144 /* Firmware Masks */
145 #define TI_FIRMWARE_ID_MASK 0xFFFF0000
146 #define TI_FIRMWARE_TYPE_MASK 0x0000F000
147 #define TI_FIRMWARE_TYPE_REV2 0
148 #define TI_FIRMWARE_TYPE_PROD 1
149 #define TI_FIRMWARE_TYPE_MODTI 2
150 #define TI_FIRMWARE_TYPE_PROD2 3
151 #define TI_FIRMWARE_MAJOR_VERSION_MASK 0x00000FF0
152 #define TI_FIRWMARE_MINOR_VERSION_MASK 0x0000000F
153 
154 /* 0x0 boardID bits and masks */
155 #define TI_BOARDID_TYPE_TIDS 0x71D5
156 #define TI_BOARDID_TYPE_TI 0x7100
157 #define TI_BOARDID_TYPE_TS 0x7500
158 #define TI_BOARDID_TYPE_TD 0x7D00
159 #define TI_BOARDID_TYPE_MASK 0xFF000000
160 #define TI_BOARDID_PROD_MASK 0x00FF0000
161 #define TI_BOARDID_GEOADR_MASK 0x00001F00
162 #define TI_BOARDID_CRATEID_MASK 0x000000FF
163 
164 /* 0x4 fiber bits and masks */
165 #define TI_FIBER_1 (1<<0)
166 #define TI_FIBER_2 (1<<1)
167 #define TI_FIBER_3 (1<<2)
168 #define TI_FIBER_4 (1<<3)
169 #define TI_FIBER_5 (1<<4)
170 #define TI_FIBER_6 (1<<5)
171 #define TI_FIBER_7 (1<<6)
172 #define TI_FIBER_8 (1<<7)
173 #define TI_FIBER_ENABLE_P0 (1<<8)
174 #define TI_FIBER_ENABLED(x) (1<<(x+1))
175 #define TI_FIBER_MASK 0x000000FF
176 #define TI_FIBER_CONNECTED_1 (1<<16)
177 #define TI_FIBER_CONNECTED_2 (1<<17)
178 #define TI_FIBER_CONNECTED_3 (1<<18)
179 #define TI_FIBER_CONNECTED_4 (1<<19)
180 #define TI_FIBER_CONNECTED_5 (1<<20)
181 #define TI_FIBER_CONNECTED_6 (1<<21)
182 #define TI_FIBER_CONNECTED_7 (1<<22)
183 #define TI_FIBER_CONNECTED_8 (1<<23)
184 #define TI_FIBER_CONNECTED_TI(x) (1<<(x+15))
185 #define TI_FIBER_CONNECTED_MASK 0x00FF0000
186 #define TI_FIBER_TRIGSRC_ENABLED_1 (1<<24)
187 #define TI_FIBER_TRIGSRC_ENABLED_2 (1<<25)
188 #define TI_FIBER_TRIGSRC_ENABLED_3 (1<<26)
189 #define TI_FIBER_TRIGSRC_ENABLED_4 (1<<27)
190 #define TI_FIBER_TRIGSRC_ENABLED_5 (1<<28)
191 #define TI_FIBER_TRIGSRC_ENABLED_6 (1<<29)
192 #define TI_FIBER_TRIGSRC_ENABLED_7 (1<<30)
193 #define TI_FIBER_TRIGSRC_ENABLED_8 (1<<31)
194 #define TI_FIBER_TRIGSRC_ENABLED_TI(x) (1<<(x+23))
195 #define TI_FIBER_TRIGSRC_ENABLED_MASK 0xFF000000
196 
197 /* 0x8 intsetup bits and masks */
198 #define TI_INTSETUP_VECTOR_MASK 0x000000FF
199 #define TI_INTSETUP_LEVEL_MASK 0x00000F00
200 #define TI_INTSETUP_ENABLE (1<<16)
201 
202 /* 0xC trigDelay bits and masks */
203 #define TI_TRIGDELAY_TRIG1_DELAY_MASK 0x000000FF
204 #define TI_TRIGDELAY_TRIG1_WIDTH_MASK 0x0000FF00
205 #define TI_TRIGDELAY_TRIG2_DELAY_MASK 0x00FF0000
206 #define TI_TRIGDELAY_TRIG2_WIDTH_MASK 0xFF000000
207 #define TI_TRIGDELAY_TRIG1_64NS_STEP (1<<7)
208 #define TI_TRIGDELAY_TRIG2_64NS_STEP (1<<23)
209 
210 /* 0x10 adr32 bits and masks */
211 #define TI_ADR32_MBLK_ADDR_MAX_MASK 0x000003FE
212 #define TI_ADR32_MBLK_ADDR_MIN_MASK 0x003FC000
213 #define TI_ADR32_BASE_MASK 0xFF800000
214 
215 /* 0x14 blocklevel bits and masks */
216 #define TI_BLOCKLEVEL_MASK 0x000000FF
217 #define TI_BLOCKLEVEL_CURRENT_MASK 0x00FF0000
218 #define TI_BLOCKLEVEL_RECEIVED_MASK 0xFF000000
219 
220 
221 /* 0x18 dataFormat bits and masks */
222 #define TI_DATAFORMAT_TWOBLOCK_PLACEHOLDER (1<<0)
223 #define TI_DATAFORMAT_TIMING_WORD (1<<1)
224 #define TI_DATAFORMAT_HIGHERBITS_WORD (1<<2)
225 #define TI_DATAFORMAT_FPINPUT_READOUT (1<<3)
226 
227 /* 0x1C vmeControl bits and masks */
228 #define TI_VMECONTROL_BERR (1<<0)
229 #define TI_VMECONTROL_TOKEN_TESTMODE (1<<1)
230 #define TI_VMECONTROL_MBLK (1<<2)
231 #define TI_VMECONTROL_A32M (1<<3)
232 #define TI_VMECONTROL_A32 (1<<4)
233 #define TI_VMECONTROL_ERROR_INT (1<<7)
234 #define TI_VMECONTROL_I2CDEV_HACK (1<<8)
235 #define TI_VMECONTROL_TOKENOUT_HI (1<<9)
236 #define TI_VMECONTROL_FIRST_BOARD (1<<10)
237 #define TI_VMECONTROL_LAST_BOARD (1<<11)
238 #define TI_VMECONTROL_BUFFER_DISABLE (1<<15)
239 #define TI_VMECONTROL_BLOCKLEVEL_UPDATE (1<<21)
240 #define TI_VMECONTROL_SLOWER_TRIGGER_RULES (1<<31)
241 
242 /* 0x20 trigsrc bits and masks */
243 #define TI_TRIGSRC_SOURCEMASK 0x0000F3FF
244 #define TI_TRIGSRC_P0 (1<<0)
245 #define TI_TRIGSRC_HFBR1 (1<<1)
246 #define TI_TRIGSRC_LOOPBACK (1<<2)
247 #define TI_TRIGSRC_FPTRG (1<<3)
248 #define TI_TRIGSRC_VME (1<<4)
249 #define TI_TRIGSRC_TSINPUTS (1<<5)
250 #define TI_TRIGSRC_TSREV2 (1<<6)
251 #define TI_TRIGSRC_PULSER (1<<7)
252 #define TI_TRIGSRC_HFBR5 (1<<10)
253 #define TI_TRIGSRC_TRIG21 (1<<11)
254 #define TI_TRIGSRC_PART_1 (1<<12)
255 #define TI_TRIGSRC_PART_2 (1<<13)
256 #define TI_TRIGSRC_PART_3 (1<<14)
257 #define TI_TRIGSRC_PART_4 (1<<15)
258 #define TI_TRIGSRC_MONITOR_MASK 0xFFFF0000
259 
260 /* 0x24 sync bits and masks */
261 #define TI_SYNC_SOURCEMASK 0x000000FF
262 #define TI_SYNC_P0 (1<<0)
263 #define TI_SYNC_HFBR1 (1<<1)
264 #define TI_SYNC_HFBR5 (1<<2)
265 #define TI_SYNC_FP (1<<3)
266 #define TI_SYNC_LOOPBACK (1<<4)
267 #define TI_SYNC_USER_SYNCRESET_ENABLED (1<<7)
268 #define TI_SYNC_HFBR1_CODE_MASK 0x00000F00
269 #define TI_SYNC_HFBR5_CODE_MASK 0x0000F000
270 #define TI_SYNC_LOOPBACK_CODE_MASK 0x000F0000
271 #define TI_SYNC_HISTORY_FIFO_MASK 0x00700000
272 #define TI_SYNC_HISTORY_FIFO_EMPTY (1<<20)
273 #define TI_SYNC_HISTORY_FIFO_HALF_FULL (1<<21)
274 #define TI_SYNC_HISTORY_FIFO_FULL (1<<22)
275 #define TI_SYNC_MONITOR_MASK 0xFF000000
276 
277 /* 0x28 busy bits and masks */
278 #define TI_BUSY_SOURCEMASK 0x0000FFFF
279 #define TI_BUSY_SWA (1<<0)
280 #define TI_BUSY_SWB (1<<1)
281 #define TI_BUSY_P2 (1<<2)
282 #define TI_BUSY_FP_FTDC (1<<3)
283 #define TI_BUSY_FP_FADC (1<<4)
284 #define TI_BUSY_FP (1<<5)
285 #define TI_BUSY_TRIGGER_LOCK (1<<6)
286 #define TI_BUSY_LOOPBACK (1<<7)
287 #define TI_BUSY_HFBR1 (1<<8)
288 #define TI_BUSY_HFBR2 (1<<9)
289 #define TI_BUSY_HFBR3 (1<<10)
290 #define TI_BUSY_HFBR4 (1<<11)
291 #define TI_BUSY_HFBR5 (1<<12)
292 #define TI_BUSY_HFBR6 (1<<13)
293 #define TI_BUSY_HFBR7 (1<<14)
294 #define TI_BUSY_HFBR8 (1<<15)
295 #define TI_BUSY_MONITOR_MASK 0xFFFF0000
296 #define TI_BUSY_MONITOR_SWA (1<<16)
297 #define TI_BUSY_MONITOR_SWB (1<<17)
298 #define TI_BUSY_MONITOR_P2 (1<<18)
299 #define TI_BUSY_MONITOR_FP_FTDC (1<<19)
300 #define TI_BUSY_MONITOR_FP_FADC (1<<20)
301 #define TI_BUSY_MONITOR_FP (1<<21)
302 #define TI_BUSY_MONITOR_TRIG_LOST (1<<22)
303 #define TI_BUSY_MONITOR_LOOPBACK (1<<23)
304 #define TI_BUSY_MONITOR_FIBER_BUSY(x) (1<<(x+23))
305 #define TI_BUSY_MONITOR_HFBR1 (1<<24)
306 #define TI_BUSY_MONITOR_HFBR2 (1<<25)
307 #define TI_BUSY_MONITOR_HFBR3 (1<<26)
308 #define TI_BUSY_MONITOR_HFBR4 (1<<27)
309 #define TI_BUSY_MONITOR_HFBR5 (1<<28)
310 #define TI_BUSY_MONITOR_HFBR6 (1<<29)
311 #define TI_BUSY_MONITOR_HFBR7 (1<<30)
312 #define TI_BUSY_MONITOR_HFBR8 (1<<31)
313 
314 /* 0x2C clock bits and mask */
315 #define TI_CLOCK_INTERNAL (0)
316 #define TI_CLOCK_HFBR5 (1)
317 #define TI_CLOCK_HFBR1 (2)
318 #define TI_CLOCK_FP (3)
319 #define TI_CLOCK_MASK 0x0000000F
320 
321 /* 0x30 trig1Prescale bits and masks */
322 #define TI_TRIG1PRESCALE_MASK 0x0000FFFF
323 
324 /* 0x34 blockBuffer bits and masks */
325 #define TI_BLOCKBUFFER_BUFFERLEVEL_MASK 0x000000FF
326 #define TI_BLOCKBUFFER_BLOCKS_READY_MASK 0x0000FF00
327 #define TI_BLOCKBUFFER_TRIGGERS_IN_BLOCK 0x00FF0000
328 #define TI_BLOCKBUFFER_RO_NEVENTS_MASK 0x07000000
329 #define TI_BLOCKBUFFER_BLOCKS_NEEDACK_MASK 0x7F000000
330 #define TI_BLOCKBUFFER_BREADY_INT_MASK 0x0F000000
331 #define TI_BLOCKBUFFER_BUSY_ON_BLOCKLIMIT (1<<28)
332 #define TI_BLOCKBUFFER_SYNCRESET_REQUESTED (1<<30)
333 #define TI_BLOCKBUFFER_SYNCEVENT (1<<31)
334 
335 /* 0x38 triggerRule bits and masks */
336 #define TI_TRIGGERRULE_RULE1_MASK 0x000000FF
337 #define TI_TRIGGERRULE_RULE2_MASK 0x0000FF00
338 #define TI_TRIGGERRULE_RULE3_MASK 0x00FF0000
339 #define TI_TRIGGERRULE_RULE4_MASK 0xFF000000
340 
341 /* 0x3C triggerWindow bits and masks */
342 #define TI_TRIGGERWINDOW_COINC_MASK 0x000000FF
343 #define TI_TRIGGERWINDOW_INHIBIT_MASK 0x0000FF00
344 #define TI_TRIGGERWINDOW_TRIG21_MASK 0x01FF0000
345 #define TI_TRIGGERWINDOW_LEVEL_LATCH (1<<31)
346 
347 /* 0x48 tsInput bits and masks */
348 #define TI_TSINPUT_MASK 0x0000003F
349 #define TI_TSINPUT_1 (1<<0)
350 #define TI_TSINPUT_2 (1<<1)
351 #define TI_TSINPUT_3 (1<<2)
352 #define TI_TSINPUT_4 (1<<3)
353 #define TI_TSINPUT_5 (1<<4)
354 #define TI_TSINPUT_6 (1<<5)
355 #define TI_TSINPUT_ALL (0x3F)
356 
357 
358 /* 0x4C output bits and masks */
359 #define TI_OUTPUT_MASK 0x0000FFFF
360 #define TI_OUTPUT_BLOCKS_READY_MASK 0x00FF0000
361 #define TI_OUTPUT_EVENTS_IN_BLOCK_MASK 0xFF000000
362 
363 /* 0x50 fiberSyncDelay bits and masks */
364 #define TI_FIBERSYNCDELAY_HFBR1_SYNCPHASE_MASK 0x000000FF
365 #define TI_FIBERSYNCDELAY_HFBR1_SYNCDELAY_MASK 0x0000FF00
366 #define TI_FIBERSYNCDELAY_LOOPBACK_SYNCDELAY_MASK 0x00FF0000
367 #define TI_FIBERSYNCDELAY_HFBR5_SYNCDELAY_MASK 0xFF000000
368 
369 /* 0x74 inputPrescale bits and masks */
370 #define TI_INPUTPRESCALE_FP1_MASK 0x0000000F
371 #define TI_INPUTPRESCALE_FP2_MASK 0x000000F0
372 #define TI_INPUTPRESCALE_FP3_MASK 0x00000F00
373 #define TI_INPUTPRESCALE_FP4_MASK 0x0000F000
374 #define TI_INPUTPRESCALE_FP5_MASK 0x000F0000
375 #define TI_INPUTPRESCALE_FP6_MASK 0x00F00000
376 #define TI_INPUTPRESCALE_FP_MASK(x) (0xF<<4*((x-1)))
377 
378 /* 0x78 syncCommand bits and masks */
379 #define TI_SYNCCOMMAND_VME_CLOCKRESET 0x11
380 #define TI_SYNCCOMMAND_CLK250_RESYNC 0x22
381 #define TI_SYNCCOMMAND_AD9510_RESYNC 0x33
382 #define TI_SYNCCOMMAND_GTP_STATUSB_RESET 0x44
383 #define TI_SYNCCOMMAND_TRIGGERLINK_ENABLE 0x55
384 #define TI_SYNCCOMMAND_TRIGGERLINK_DISABLE 0x77
385 #define TI_SYNCCOMMAND_SYNCRESET_HIGH 0x99
386 #define TI_SYNCCOMMAND_TRIGGER_READY_RESET 0xAA
387 #define TI_SYNCCOMMAND_RESET_EVNUM 0xBB
388 #define TI_SYNCCOMMAND_SYNCRESET_LOW 0xCC
389 #define TI_SYNCCOMMAND_SYNCRESET 0xDD
390 #define TI_SYNCCOMMAND_SYNCRESET_4US 0xEE
391 #define TI_SYNCCOMMAND_SYNCCODE_MASK 0x000000FF
392 
393 /* 0x7C syncDelay bits and masks */
394 #define TI_SYNCDELAY_MASK 0x0000007F
395 
396 /* 0x80 syncWidth bits and masks */
397 #define TI_SYNCWIDTH_MASK 0x7F
398 #define TI_SYNCWIDTH_LONGWIDTH_ENABLE (1<<7)
399 
400 /* 0x84 triggerCommand bits and masks */
401 #define TI_TRIGGERCOMMAND_VALUE_MASK 0x000000FF
402 #define TI_TRIGGERCOMMAND_CODE_MASK 0x00000F00
403 #define TI_TRIGGERCOMMAND_TRIG1 0x00000100
404 #define TI_TRIGGERCOMMAND_TRIG2 0x00000200
405 #define TI_TRIGGERCOMMAND_SYNC_EVENT 0x00000300
406 #define TI_TRIGGERCOMMAND_SET_BLOCKLEVEL 0x00000800
407 
408 /* 0x88 randomPulser bits and masks */
409 #define TI_RANDOMPULSER_TRIG1_RATE_MASK 0x0000000F
410 #define TI_RANDOMPULSER_TRIG1_ENABLE (1<<7)
411 #define TI_RANDOMPULSER_TRIG2_RATE_MASK 0x00000F00
412 #define TI_RANDOMPULSER_TRIG2_ENABLE (1<<15)
413 
414 /* 0x8C fixedPulser1 bits and masks */
415 #define TI_FIXEDPULSER1_NTRIGGERS_MASK 0x0000FFFF
416 #define TI_FIXEDPULSER1_PERIOD_MASK 0x7FFF0000
417 #define TI_FIXEDPULSER1_PERIOD_RANGE (1<<31)
418 
419 /* 0x90 fixedPulser2 bits and masks */
420 #define TI_FIXEDPULSER2_NTRIGGERS_MASK 0x0000FFFF
421 #define TI_FIXEDPULSER2_PERIOD_MASK 0x7FFF0000
422 #define TI_FIXEDPULSER2_PERIOD_RANGE (1<<31)
423 
424 /* 0x94 nblocks bits and masks */
425 #define TI_NBLOCKS_COUNT_MASK 0x00FFFFFF
426 #define TI_NBLOCKS_EVENTS_IN_BLOCK_MASK 0xFF000000
427 
428 /* 0x98 syncHistory bits and masks */
429 #define TI_SYNCHISTORY_HFBR1_CODE_MASK 0x0000000F
430 #define TI_SYNCHISTORY_HFBR1_CODE_VALID (1<<4)
431 #define TI_SYNCHISTORY_HFBR5_CODE_MASK 0x000001E0
432 #define TI_SYNCHISTORY_HFBR5_CODE_VALID (1<<9)
433 #define TI_SYNCHISTORY_LOOPBACK_CODE_MASK 0x00003C00
434 #define TI_SYNCHISTORY_LOOPBACK_CODE_VALID (1<<14)
435 #define TI_SYNCHISTORY_TIMESTAMP_OVERFLOW (1<<15)
436 #define TI_SYNCHISTORY_TIMESTAMP_MASK 0xFFFF0000
437 
438 /* 0x9C runningMode settings */
439 #define TI_RUNNINGMODE_ENABLE 0x71
440 #define TI_RUNNINGMODE_DISABLE 0x0
441 
442 /* 0xA0 fiberLatencyMeasurement bits and masks */
443 #define TI_FIBERLATENCYMEASUREMENT_CARRYCHAIN_MASK 0x0000FFFF
444 #define TI_FIBERLATENCYMEASUREMENT_IODELAY_MASK 0x007F0000
445 #define TI_FIBERLATENCYMEASUREMENT_DATA_MASK 0xFF800000
446 
447 /* 0xA4 fiberAlignment bits and masks */
448 #define TI_FIBERALIGNMENT_HFBR1_IODELAY_MASK 0x000000FF
449 #define TI_FIBERALIGNMENT_HFBR1_SYNCDELAY_MASK 0x0000FF00
450 #define TI_FIBERALIGNMENT_HFBR5_IODELAY_MASK 0x00FF0000
451 #define TI_FIBERALIGNMENT_HFBR5_SYNCDELAY_MASK 0xFF000000
452 
453 /* 0xC0 blockStatus bits and masks */
454 #define TI_BLOCKSTATUS_NBLOCKS_READY0 0x000000FF
455 #define TI_BLOCKSTATUS_NBLOCKS_NEEDACK0 0x0000FF00
456 #define TI_BLOCKSTATUS_NBLOCKS_READY1 0x00FF0000
457 #define TI_BLOCKSTATUS_NBLOCKS_NEEDACK1 0xFF000000
458 
459 /* 0xD0 adr24 bits and masks */
460 #define TI_ADR24_ADDRESS_MASK 0x0000001F
461 #define TI_ADR24_HARDWARE_SET_MASK 0x000003E0
462 #define TI_ADR24_GEOADDR_MASK 0x00007C00
463 #define TI_ADR24_TM_NBLOCKS_READY1 0x00FF0000
464 #define TI_ADR24_TM_NBLOCKS_NEEDACK1 0xFF000000
465 
466 /* 0xD4 syncEventCtrl bits and masks */
467 #define TI_SYNCEVENTCTRL_NBLOCKS_MASK 0x00FFFFFF
468 
469 /* 0xD8 eventNumber_hi bits and masks */
470 #define TI_PROMPT_TRIG_WIDTH_MASK 0x0000007F
471 #define TI_EVENTNUMBER_HI_MASK 0xFFFF0000
472 
473 
474 /* 0xEC rocEnable bits and masks */
475 #define TI_ROCENABLE_MASK 0x000000FF
476 #define TI_ROCENABLE_ROC(x) (1<<(x))
477 #define TI_ROCENABLE_SYNCRESET_REQUEST_ENABLE_MASK 0x0007FC00
478 #define TI_ROCENABLE_SYNCRESET_REQUEST_MONITOR_MASK 0x1FF00000
479 
480 /* 0x100 reset bits and masks */
481 #define TI_RESET_I2C (1<<1)
482 #define TI_RESET_JTAG (1<<2)
483 #define TI_RESET_SFM (1<<3)
484 #define TI_RESET_SOFT (1<<4)
485 #define TI_RESET_SYNC_HISTORY (1<<6)
486 #define TI_RESET_BUSYACK (1<<7)
487 #define TI_RESET_CLK250 (1<<8)
488 #define TI_RESET_CLK200 (1<<8)
489 #define TI_RESET_CLK125 (1<<9)
490 #define TI_RESET_MGT (1<<10)
491 #define TI_RESET_AUTOALIGN_HFBR1_SYNC (1<<11)
492 #define TI_RESET_AUTOALIGN_HFBR5_SYNC (1<<12)
493 #define TI_RESET_RAM_WRITE (1<<12)
494 #define TI_RESET_FIBER_AUTO_ALIGN (1<<13)
495 #define TI_RESET_IODELAY (1<<14)
496 #define TI_RESET_MEASURE_LATENCY (1<<15)
497 #define TI_RESET_TAKE_TOKEN (1<<16)
498 #define TI_RESET_BLOCK_READOUT (1<<17)
499 #define TI_RESET_FORCE_SYNCEVENT (1<<20)
500 #define TI_RESET_MGT_RX_RESET (1<<22)
501 #define TI_RESET_SYNCRESET_REQUEST (1<<23)
502 #define TI_RESET_SCALERS_LATCH (1<<24)
503 #define TI_RESET_SCALERS_RESET (1<<25)
504 #define TI_RESET_FILL_TO_END_BLOCK (1<<31)
505 
506 /* 0x104 fpDelay Masks */
507 #define TI_FPDELAY_MASK(x) (0x1FF<<(10*(x%3)))
508 
509 /* 0x138 triggerRuleMin bits and masks */
510 #define TI_TRIGGERRULEMIN_MIN2_MASK 0x00007F00
511 #define TI_TRIGGERRULEMIN_MIN2_EN (1<<15)
512 #define TI_TRIGGERRULEMIN_MIN3_MASK 0x007F0000
513 #define TI_TRIGGERRULEMIN_MIN3_EN (1<<23)
514 #define TI_TRIGGERRULEMIN_MIN4_MASK 0x7F000000
515 #define TI_TRIGGERRULEMIN_MIN4_EN (1<<31)
516 
517 /* 0x1D0-0x1F0 TI ID bits and masks */
518 #define TI_ID_TRIGSRC_ENABLE_MASK 0x000000FF
519 #define TI_ID_CRATEID_MASK 0x0000FF00
520 #define TI_ID_BLOCKLEVEL_MASK 0x00FF0000
521 
522 /* Trigger Sources, used by tiSetTriggerSource */
523 #define TI_TRIGGER_P0 0
524 #define TI_TRIGGER_HFBR1 1
525 #define TI_TRIGGER_FPTRG 2
526 #define TI_TRIGGER_TSINPUTS 3
527 #define TI_TRIGGER_TSREV2 4
528 #define TI_TRIGGER_RANDOM 5
529 #define TI_TRIGGER_PULSER 5
530 #define TI_TRIGGER_PART_1 6
531 #define TI_TRIGGER_PART_2 7
532 #define TI_TRIGGER_PART_3 8
533 #define TI_TRIGGER_PART_4 9
534 #define TI_TRIGGER_HFBR5 10
535 #define TI_TRIGGER_TRIG21 11
536 
537 /* Define default Interrupt vector and level */
538 #define TI_INT_VEC 0xec
539 /* #define TI_INT_VEC 0xc8 */
540 #define TI_INT_LEVEL 5
541 
542 /* i2c data masks - 16bit data default */
543 #define TI_I2C_DATA_MASK 0x0000ffff
544 #define TI_I2C_8BIT_DATA_MASK 0x000000ff
545 
546 /* Data buffer bits and masks */
547 #define TI_DATA_TYPE_DEFINE_MASK 0x80000000
548 #define TI_WORD_TYPE_MASK 0x78000000
549 #define TI_FILLER_WORD_TYPE 0x78000000
550 #define TI_BLOCK_HEADER_WORD_TYPE 0x00000000
551 #define TI_BLOCK_TRAILER_WORD_TYPE 0x08000000
552 #define TI_EMPTY_FIFO 0xF0BAD0F0
553 #define TI_BLOCK_HEADER_CRATEID_MASK 0xFF000000
554 #define TI_BLOCK_HEADER_SLOTS_MASK 0x001F0000
555 #define TI_BLOCK_TRAILER_CRATEID_MASK 0x00FF0000
556 #define TI_BLOCK_TRAILER_SLOTS_MASK 0x1F000000
557 #define TI_DATA_BLKNUM_MASK 0x0000FF00
558 #define TI_DATA_BLKLEVEL_MASK 0x000000FF
559 
560 /* tiInit initialization flag bits */
561 #define TI_INIT_NO_INIT (1<<0)
562 #define TI_INIT_SLAVE_FIBER_5 (1<<1)
563 #define TI_INIT_SKIP_FIRMWARE_CHECK (1<<2)
564 
565 /* Some pre-initialization routine prototypes */
567 int tiSetCrateID_prIinit(int cid);
568 
569 /* Function prototypes */
570 int tiInit(unsigned int tAddr, unsigned int mode, int force);
571 unsigned int tiFind();
572 int tiCheckAddresses();
573 void tiStatus(int pflag);
574 int tiSetSlavePort(int port);
575 int tiGetSlavePort();
576 void tiSlaveStatus(int pflag);
578 int tiReload();
579 unsigned int tiGetSerialNumber(char **rSN);
580 int tiClockResync();
581 int tiReset();
582 int tiSetCrateID(unsigned int crateID);
583 int tiGetCrateID(int port);
584 int tiGetPortTrigSrcEnabled(int port);
585 int tiGetSlaveBlocklevel(int port);
586 int tiSetBlockLevel(int blockLevel);
587 int tiBroadcastNextBlockLevel(int blockLevel);
588 int tiGetNextBlockLevel();
590 int tiSetInstantBlockLevelChange(int enable);
592 int tiSetTriggerSource(int trig);
593 int tiSetTriggerSourceMask(int trigmask);
595 int tiDisableTriggerSource(int fflag);
596 int tiSetSyncSource(unsigned int sync);
597 int tiSetEventFormat(int format);
598 int tiSetFPInputReadout(int enable);
599 int tiSoftTrig(int trigger, unsigned int nevents, unsigned int period_inc, int range);
600 int tiSetRandomTrigger(int trigger, int setting);
602 int tiReadBlock(volatile unsigned int *data, int nwrds, int rflag);
603 int tiReadTriggerBlock(volatile unsigned int *data);
604 int tiCheckTriggerBlock(volatile unsigned int *data);
605 int tiDecodeTriggerType(volatile unsigned int *data, int data_len, int event);
606 int tiEnableFiber(unsigned int fiber);
607 int tiDisableFiber(unsigned int fiber);
608 int tiSetBusySource(unsigned int sourcemask, int rFlag);
609 int tiSetTriggerLock(int enable);
610 int tiGetTriggerLock();
611 void tiEnableBusError();
612 void tiDisableBusError();
613 int tiPayloadPort2VMESlot(int payloadport);
614 unsigned int tiPayloadPortMask2VMESlotMask(unsigned int ppmask);
615 int tiVMESlot2PayloadPort(int vmeslot);
616 unsigned int tiVMESlotMask2PayloadPortMask(unsigned int vmemask);
617 int tiSetPrescale(int prescale);
618 int tiGetPrescale();
619 int tiSetInputPrescale(int input, int prescale);
620 int tiGetInputPrescale(int input);
621 int tiSetTriggerPulse(int trigger, int delay, int width, int delay_step);
622 int tiSetPromptTriggerWidth(int width);
624 void tiSetSyncDelayWidth(unsigned int delay, unsigned int width, int widthstep);
625 void tiTrigLinkReset();
626 int tiSetSyncResetType(int type);
627 void tiSyncReset(int bflag);
628 void tiSyncResetResync();
629 void tiClockReset();
630 int tiSetAdr32(unsigned int a32base);
631 int tiDisableA32();
632 int tiResetEventCounter();
633 unsigned long long int tiGetEventCounter();
634 int tiSetBlockLimit(unsigned int limit);
635 unsigned int tiGetBlockLimit();
636 unsigned int tiBReady();
637 int tiGetSyncEventFlag();
639 int tiGetReadoutEvents();
640 int tiEnableVXSSignals();
641 int tiDisableVXSSignals();
642 int tiSetBlockBufferLevel(unsigned int level);
643 int tiEnableTSInput(unsigned int inpMask);
644 int tiDisableTSInput(unsigned int inpMask);
645 int tiSetOutputPort(unsigned int set1, unsigned int set2, unsigned int set3, unsigned int set4);
646 int tiSetClockSource(unsigned int source);
647 int tiGetClockSource();
648 void tiSetFiberDelay(unsigned int delay, unsigned int offset);
649 int tiAddSlave(unsigned int fiber);
650 int tiSetTriggerHoldoff(int rule, unsigned int value, int timestep);
651 int tiGetTriggerHoldoff(int rule);
652 int tiPrintTriggerHoldoff(int dflag);
653 int tiSetTriggerHoldoffMin(int rule, unsigned int value);
654 int tiGetTriggerHoldoffMin(int rule, int pflag);
655 
657 int tiEnableDataReadout();
658 void tiResetBlockReadout();
659 
660 int tiTriggerTableConfig(unsigned int *itable);
661 int tiGetTriggerTable(unsigned int *otable);
662 int tiTriggerTablePredefinedConfig(int mode);
663 int tiDefineEventType(int trigMask, int hwTrig, int evType);
664 int tiDefinePulserEventType(int fixed_type, int random_type);
665 int tiLoadTriggerTable(int mode);
666 void tiPrintTriggerTable(int showbits);
667 int tiSetTriggerWindow(int window_width);
668 int tiGetTriggerWindow();
669 int tiSetTriggerInhibitWindow(int window_width);
671 int tiSetTrig21Delay(int delay);
672 int tiGetTrig21Delay();
673 int tiSetTriggerLatchOnLevel(int enable);
675 int tiLatchTimers();
676 unsigned int tiGetLiveTime();
677 unsigned int tiGetBusyTime();
678 int tiLive(int sflag);
679 unsigned int tiGetTSscaler(int input, int latch);
680 unsigned int tiBlockStatus(int fiber, int pflag);
681 
683 int tiSetUserSyncResetReceive(int enable);
684 int tiGetLastSyncCodes(int pflag);
685 int tiGetSyncHistoryBufferStatus(int pflag);
686 void tiResetSyncHistory();
687 void tiUserSyncReset(int enable, int pflag);
688 void tiPrintSyncHistory();
689 int tiSetSyncEventInterval(int blk_interval);
691 int tiForceSyncEvent();
692 int tiSyncResetRequest();
694 int tiEnableSyncResetRequest(unsigned int portMask, int self);
695 int tiSyncResetRequestStatus(int pflag);
696 void tiTriggerReadyReset();
697 int tiFillToEndBlock();
698 int tiResetMGT();
699 int tiSetTSInputDelay(int chan, int delay);
700 int tiGetTSInputDelay(int chan);
701 int tiPrintTSInputDelay();
702 unsigned int tiGetGTPBufferLength(int pflag);
703 unsigned int tiGetSWAStatus(int reg);
704 unsigned int tiGetSWBStatus(int reg);
705 int tiGetGeoAddress();
706 
707 /* Library Interrupt/Polling routine prototypes */
708 int tiIntConnect(unsigned int vector, VOIDFUNCPTR routine, unsigned int arg);
709 int tiIntDisconnect();
710 int tiAckConnect(VOIDFUNCPTR routine, unsigned int arg);
711 void tiIntAck();
712 int tiIntEnable(int iflag);
713 void tiIntDisable();
714 unsigned int tiGetIntCount();
715 unsigned int tiGetAckCount();
716 
717 int tiGetSWBBusy(int pflag);
718 unsigned int tiGetBusyCounter(int busysrc);
719 int tiPrintBusyCounters();
720 
721 /* Some token testing routines */
722 int tiSetTokenTestMode(int mode);
723 int tiSetTokenOutTest(int level);
724 
725 int tiRocEnable(int roc);
726 int tiRocEnableMask(int rocmask);
727 int tiGetRocEnableMask();
728 #endif /* TILIB_H */
int tiEnableVXSSignals()
Enable trigger and sync signals sent through the VXS to the Signal Distribution (SD) module...
Definition: tiLib.c:4290
volatile unsigned int trigTable[(0x180-0x140)/4]
Definition: tiLib.h:112
volatile unsigned int vmeControl
Definition: tiLib.h:60
volatile unsigned int syncWidth
Definition: tiLib.h:80
int tiGetSWBBusy(int pflag)
Return status of Busy from SWB.
Definition: tiLib.c:7613
int tiSetTriggerHoldoffMin(int rule, unsigned int value)
Set the value for the minimum time of specified trigger rule.
Definition: tiLib.c:5009
int tiRocEnableMask(int rocmask)
Definition: tiLib.c:7822
volatile unsigned int runningMode
Definition: tiLib.h:87
volatile unsigned int blockStatus[4]
Definition: tiLib.h:96
int tiGetFirmwareVersion()
Get the Firmware Version.
Definition: tiLib.c:1496
void tiResetBlockReadout()
Decrement the hardware counter for blocks available, effectively simulating a readout from the data f...
Definition: tiLib.c:5194
int tiGetLastSyncCodes(int pflag)
Return last SyncCommand received.
Definition: tiLib.c:6209
volatile unsigned int nblocks
Definition: tiLib.h:85
int tiEnableTSInput(unsigned int inpMask)
Enable/Disable trigger inputs labelled TS#1-6 on the Front Panel.
Definition: tiLib.c:4393
int tiGetTriggerHoldoff(int rule)
Get the value for a specified trigger rule.
Definition: tiLib.c:4865
int tiCheckTriggerBlock(volatile unsigned int *data)
Definition: tiLib.c:2912
volatile unsigned int boardID
Definition: tiLib.h:53
unsigned int blank7[(0x138-0x12C)/4]
Definition: tiLib.h:109
void tiSetFiberDelay(unsigned int delay, unsigned int offset)
Set the fiber delay required to align the sync and triggers for all crates.
Definition: tiLib.c:4594
volatile unsigned int JTAGPROMBase[(0x20000-0x10000)/4]
Definition: tiLib.h:125
int tiAddSlave(unsigned int fiber)
Add and configurate a TI Slave for the TI Master.
Definition: tiLib.c:4652
int tiDefineEventType(int trigMask, int hwTrig, int evType)
Define a specific trigger pattern as a hardware trigger (trig1/trig2/syncevent) and Event Type...
Definition: tiLib.c:5369
int tiVMESlot2PayloadPort(int vmeslot)
Routine to return the VXS payload port, provided the VME Slot.
Definition: tiLib.c:3442
int tiGetGeoAddress()
Return geographic address as provided from a VME-64X crate.
Definition: tiLib.c:7030
int tiGetSyncEventReceived()
Return the value of whether or not the sync event has been received.
Definition: tiLib.c:4247
int tiDisableA32()
Disable A32.
Definition: tiLib.c:4037
int tiPrintTSInputDelay()
Print Front Panel TSinput Delays to Standard Out.
Definition: tiLib.c:6853
int tiDisableFiber(unsigned int fiber)
Disnable Fiber transceiver.
Definition: tiLib.c:3172
int tiBroadcastNextBlockLevel(int blockLevel)
Broadcast the next block level (to be changed at the end of the next sync event, or during a call to ...
Definition: tiLib.c:1829
void tiUserSyncReset(int enable, int pflag)
Control level of the SyncReset signal.
Definition: tiLib.c:6315
int tiSetTriggerHoldoff(int rule, unsigned int value, int timestep)
Set the value for a specified trigger rule.
Definition: tiLib.c:4764
volatile unsigned int SWB_status[(0x2200-0x2000)/4]
Definition: tiLib.h:120
int tiSetTSInputDelay(int chan, int delay)
Set the input delay for the specified front panel TSinput (1-6)
Definition: tiLib.c:6784
volatile unsigned int syncHistory
Definition: tiLib.h:86
volatile unsigned int eventNumber_lo
Definition: tiLib.h:100
unsigned int blank12[(0x2800-0x2200)/4]
Definition: tiLib.h:121
int tiReload()
Reload the firmware on the FPGA.
Definition: tiLib.c:1535
int tiSetSyncEventInterval(int blk_interval)
Set the value of the syncronization event interval.
Definition: tiLib.c:6408
int tiResetEventCounter()
Reset the L1A counter, as incremented by the TI.
Definition: tiLib.c:4061
unsigned int tiGetSerialNumber(char **rSN)
Get the Module Serial Number.
Definition: tiLib.c:1564
volatile unsigned int inputCounter
Definition: tiLib.h:95
int tiSetBlockBufferLevel(unsigned int level)
Set the block buffer level for the number of blocks in the system that need to be read out...
Definition: tiLib.c:4354
volatile unsigned int syncEventCtrl
Definition: tiLib.h:98
int tiIntEnable(int iflag)
Enable interrupts or latching triggers (depending on set TI mode)
Definition: tiLib.c:7472
int tiGetSyncResetRequest()
Determine if a TI has requested a Sync Reset.
Definition: tiLib.c:6525
int tiReadTriggerBlock(volatile unsigned int *data)
Read a block from the TI and form it into a CODA Trigger Bank.
Definition: tiLib.c:2767
void tiDisableBusError()
Disable Bus Errors to terminate Block Reads.
Definition: tiLib.c:3360
int tiEnableSyncResetRequest(unsigned int portMask, int self)
Configure which ports (and self) to enable response of a SyncReset request.
Definition: tiLib.c:6557
volatile unsigned int GTPStatusB
Definition: tiLib.h:93
int tiPrintTriggerHoldoff(int dflag)
Definition: tiLib.c:4910
int tiAckConnect(VOIDFUNCPTR routine, unsigned int arg)
Connect a user routine to be executed instead of the default TI interrupt/trigger latching acknowledg...
Definition: tiLib.c:7395
volatile unsigned int clock
Definition: tiLib.h:64
unsigned int tiFind()
Find the TI within the prescribed "GEO Slot to A24 VME Address" range from slot 3 to 21...
Definition: tiLib.c:637
volatile unsigned int JTAGFPGABase[(0x30000-0x20000)/4]
Definition: tiLib.h:126
volatile unsigned int trigsrc
Definition: tiLib.h:61
int tiGetSyncEventInterval()
Get the SyncEvent Block interval.
Definition: tiLib.c:6442
volatile unsigned int randomPulser
Definition: tiLib.h:82
void tiIntAck()
Acknowledge an interrupt or latched trigger. This "should" effectively release the "Busy" state of th...
Definition: tiLib.c:7421
int tiSetSlavePort(int port)
This routine provides the ability to switch the port that the TI Slave receives its Clock...
Definition: tiLib.c:1244
int tiGetPrescale()
Get the current prescale factor.
Definition: tiLib.c:3525
unsigned int tiGetAckCount()
Return current acknowledge count.
Definition: tiLib.c:7589
volatile unsigned int syncCommand
Definition: tiLib.h:78
void tiResetSyncHistory()
Reset the SyncCommand history buffer.
Definition: tiLib.c:6289
int tiSetTriggerInhibitWindow(int window_width)
Set the width of the input trigger inhibit window.
Definition: tiLib.c:5615
int tiSetSyncResetType(int type)
Set type of SyncReset to send to TI Slaves.
Definition: tiLib.c:3828
int tiDisableTriggerSource(int fflag)
Disable trigger sources.
Definition: tiLib.c:2235
volatile unsigned int fpDelay[2]
Definition: tiLib.h:106
unsigned int blank5[(0xFC-0xF0)/4]
Definition: tiLib.h:103
int tiSetTriggerPulse(int trigger, int delay, int width, int delay_step)
Set the characteristics of a specified trigger.
Definition: tiLib.c:3626
volatile unsigned int SWB[(0x50000-0x40000)/4]
Definition: tiLib.h:128
unsigned int tiGetBusyTime()
Return the current "busy" time of the module.
Definition: tiLib.c:5835
unsigned int tiBReady()
Returns the number of Blocks available for readout.
Definition: tiLib.c:4187
unsigned int tiGetTSscaler(int input, int latch)
Get the current counter for the specified TS Input.
Definition: tiLib.c:5923
unsigned int blank4[(0xEC-0xE0)/4]
Definition: tiLib.h:101
int tiSetBlockLimit(unsigned int limit)
Set the block number at which triggers will be disabled automatically.
Definition: tiLib.c:4111
int tiSetUserSyncResetReceive(int enable)
Enable/Disable operation of User SyncReset.
Definition: tiLib.c:6181
int tiSetFiberLatencyOffset_preInit(int flo)
Set the Fiber Latency Offset to be used during initialization.
Definition: tiLib.c:169
volatile unsigned int livetime
Definition: tiLib.h:90
int tiSoftTrig(int trigger, unsigned int nevents, unsigned int period_inc, int range)
Set and enable the "software" trigger.
Definition: tiLib.c:2409
int tiSetBlockLevel(int blockLevel)
Set the number of events per block.
Definition: tiLib.c:1811
volatile unsigned int SWA_status[(0x3000-0x2800)/4]
Definition: tiLib.h:122
volatile unsigned int syncDelay
Definition: tiLib.h:79
int tiEnableTriggerSource()
Enable trigger sources Enable trigger sources set by tiSetTriggerSource(...) or tiSetTriggerSourceMas...
Definition: tiLib.c:2202
void tiIntDisable()
Disable interrupts or latching triggers.
Definition: tiLib.c:7549
void tiSetSyncDelayWidth(unsigned int delay, unsigned int width, int widthstep)
Set the delay time and width of the Sync signal.
Definition: tiLib.c:3748
int tiGetInputPrescale(int input)
Get the current prescale factor for the selected input.
Definition: tiLib.c:3593
unsigned int tiVMESlotMask2PayloadPortMask(unsigned int vmemask)
Routine to return the VXS Payload Port Mask, provided the VME Slot Mask.
Definition: tiLib.c:3471
unsigned int tiGetSWBStatus(int reg)
Return the value from the SWB fast link register.
Definition: tiLib.c:7000
unsigned int blank10[(0x1D0-0x1C0)/4]
Definition: tiLib.h:116
int tiReadBlock(volatile unsigned int *data, int nwrds, int rflag)
Read a block of events from the TI.
Definition: tiLib.c:2566
volatile unsigned int eJTAGLoad
Definition: tiLib.h:124
int tiEnableDataReadout()
Enable readout the TI for every block.
Definition: tiLib.c:5166
volatile unsigned int fiberLatencyMeasurement
Definition: tiLib.h:88
unsigned int blank2[(0x64-0x54)/4]
Definition: tiLib.h:74
int tiSetCrateID(unsigned int crateID)
Set the crate ID.
Definition: tiLib.c:1656
int tiSetTriggerSourceMask(int trigmask)
Set trigger sources with specified trigmask This routine is for special use when tiSetTriggerSource(...
Definition: tiLib.c:2168
int tiGetCrateID(int port)
Get the crate ID of the selected port.
Definition: tiLib.c:1692
int tiLoadTriggerTable(int mode)
Load a predefined trigger table (mapping TS inputs to trigger types).
Definition: tiLib.c:5472
unsigned int blank3[(0x74-0x68)/4]
Definition: tiLib.h:76
void tiSyncReset(int bflag)
Generate a Sync Reset signal. This signal is sent to the loopback and all configured TI Slaves...
Definition: tiLib.c:3853
int tiSetTriggerSource(int trig)
Set the trigger source This routine will set a library variable to be set in the TI registers at a ca...
Definition: tiLib.c:2015
unsigned int blank0
Definition: tiLib.h:69
int tiGetTriggerTable(unsigned int *otable)
Get the current trigger table stored in local memory (not necessarily on TI).
Definition: tiLib.c:5244
int tiSetTokenOutTest(int level)
Set the level of the token out signal.
Definition: tiLib.c:7773
volatile unsigned int eventNumber_hi
Definition: tiLib.h:99
void tiPrintTriggerTable(int showbits)
Print trigger table to standard out.
Definition: tiLib.c:5509
int tiGetCurrentBlockLevel()
Get the current block level.
Definition: tiLib.c:1907
int tiSetClockSource(unsigned int source)
Set the clock to the specified source.
Definition: tiLib.c:4504
int tiGetTriggerLock()
Get the current setting of the trigger lock mode.
Definition: tiLib.c:3305
volatile unsigned int busy
Definition: tiLib.h:63
volatile unsigned int SWA[(0x40000-0x30000)/4]
Definition: tiLib.h:127
volatile unsigned int tsInput
Definition: tiLib.h:70
volatile unsigned int fiber
Definition: tiLib.h:54
int tiGetTriggerInhibitWindow()
Get the width of the input trigger inhibit window.
Definition: tiLib.c:5645
volatile unsigned int triggerRule
Definition: tiLib.h:67
void tiPrintSyncHistory()
Print to standard out the history buffer of Sync Commands received.
Definition: tiLib.c:6348
int tiCheckAddresses()
Definition: tiLib.c:702
int tiIntDisconnect()
Disable interrupts or kill the polling service thread.
Definition: tiLib.c:7316
int tiSetPrescale(int prescale)
Set the prescale factor for the external trigger.
Definition: tiLib.c:3496
void tiEnableBusError()
Enable Bus Errors to terminate Block Reads.
Definition: tiLib.c:3336
int tiDisableVXSSignals()
Disable trigger and sync signals sent through the VXS to the Signal Distribution (SD) module...
Definition: tiLib.c:4320
unsigned int tiPayloadPortMask2VMESlotMask(unsigned int ppmask)
Routine to return the VME slot Mask, provided the VXS payload port Mask.
Definition: tiLib.c:3421
volatile unsigned int fiberSyncDelay
Definition: tiLib.h:73
int tiForceSyncEvent()
Force a sync event (type = 0).
Definition: tiLib.c:6470
unsigned long long int tiGetEventCounter()
Returns the event counter (48 bit)
Definition: tiLib.c:4083
void tiClockReset()
Generate a Clock Reset signal. This signal is sent to the loopback and all configured TI Slaves...
Definition: tiLib.c:3906
int tiGetPromptTriggerWidth()
Get the width of the prompt trigger from OT#2.
Definition: tiLib.c:3722
int tiFillToEndBlock()
Generate non-physics triggers until the current block is filled. This feature is useful for "end of r...
Definition: tiLib.c:6706
unsigned int blank13[(0xFFFC-0x3000)/4]
Definition: tiLib.h:123
volatile unsigned int triggerRuleMin
Definition: tiLib.h:110
int tiSetBusySource(unsigned int sourcemask, int rFlag)
Set the busy source with a given sourcemask sourcemask bits:
Definition: tiLib.c:3223
int tiSetOutputPort(unsigned int set1, unsigned int set2, unsigned int set3, unsigned int set4)
Set (or unset) high level for the output ports on the front panel labelled as O#1-4.
Definition: tiLib.c:4465
volatile unsigned int busytime
Definition: tiLib.h:91
int tiSetTriggerLatchOnLevel(int enable)
Set the trigger latch pattern readout in the data stream to include the Level of the input trigger OR...
Definition: tiLib.c:5732
int tiTriggerTableConfig(unsigned int *itable)
Configure trigger table to be loaded with a user provided array.
Definition: tiLib.c:5218
int tiSetTokenTestMode(int mode)
Turn on Token out test mode.
Definition: tiLib.c:7742
unsigned int blank11[(0x2000-0x1F4)/4]
Definition: tiLib.h:119
void tiSyncResetResync()
Generate a Sync Reset Resync signal. This signal is sent to the loopback and all configured TI Slaves...
Definition: tiLib.c:3885
unsigned int tiGetBusyCounter(int busysrc)
Return BUSY counter for specified Busy Source.
Definition: tiLib.c:7654
int tiGetNextBlockLevel()
Get the block level that will be updated on the end of the block readout.
Definition: tiLib.c:1878
int tiSetFPInputReadout(int enable)
Set whether or not the latched pattern of FP Inputs in block readout.
Definition: tiLib.c:2374
volatile unsigned int inputPrescale
Definition: tiLib.h:75
volatile unsigned int GTPtriggerBufferLength
Definition: tiLib.h:94
int tiInit(unsigned int tAddr, unsigned int mode, int force)
Initialize the TIp register space into local memory, and setup registers given user input...
Definition: tiLib.c:257
unsigned int blank8
Definition: tiLib.h:111
volatile unsigned int blocklevel
Definition: tiLib.h:58
int tiLive(int sflag)
Calculate the live time (percentage) from the live and busy time scalers.
Definition: tiLib.c:5861
int tiResetMGT()
Reset the MGT.
Definition: tiLib.c:6733
int tiDefinePulserEventType(int fixed_type, int random_type)
Define the event type for the TI Master&#39;s fixed and random internal trigger.
Definition: tiLib.c:5417
int tiSetAdr32(unsigned int a32base)
Routine to set the A32 Base.
Definition: tiLib.c:3949
int tiGetTSInputDelay(int chan)
Get the input delay for the specified front panel TSinput (1-6)
Definition: tiLib.c:6823
volatile unsigned int fiberAlignment
Definition: tiLib.h:89
unsigned int tiGetIntCount()
Return current readout count.
Definition: tiLib.c:7573
volatile unsigned int triggerCommand
Definition: tiLib.h:81
int tiGetTriggerWindow()
Get the window of the input trigger coincidence window.
Definition: tiLib.c:5592
int tiGetInstantBlockLevelChange()
Get Status of instant blocklevel change when broadcast is received.
Definition: tiLib.c:1977
int tiPayloadPort2VMESlot(int payloadport)
Routine to return the VME slot, provided the VXS payload port.
Definition: tiLib.c:3384
volatile unsigned int triggerWindow
Definition: tiLib.h:68
int tiSyncResetRequest()
Sync Reset Request is sent to TI-Master or TS.
Definition: tiLib.c:6503
int tiSetSyncSource(unsigned int sync)
Set the Sync source mask.
Definition: tiLib.c:2277
unsigned int blank6[(0x110-0x10C)/4]
Definition: tiLib.h:107
int tiGetTriggerLatchOnLevel()
Get the trigger latch pattern readout in the data stream to include the Level of the input trigger OR...
Definition: tiLib.c:5760
void tiStatus(int pflag)
Print some status information of the TI to standard out.
Definition: tiLib.c:788
int tiTriggerTablePredefinedConfig(int mode)
Configure trigger tabled to be loaded with a predefined trigger table (mapping TS inputs to trigger t...
Definition: tiLib.c:5287
int tiIntConnect(unsigned int vector, VOIDFUNCPTR routine, unsigned int arg)
Connect a user routine to the TI Interrupt or latched trigger, if polling.
Definition: tiLib.c:7225
unsigned int tiGetGTPBufferLength(int pflag)
Return value of buffer length from GTP.
Definition: tiLib.c:6889
int tiSetPromptTriggerWidth(int width)
Set the width of the prompt trigger from OT#2.
Definition: tiLib.c:3691
int tiSetInstantBlockLevelChange(int enable)
Set TS to instantly change blocklevel when broadcast is received.
Definition: tiLib.c:1949
int tiGetSyncEventFlag()
Return the value of the Synchronization flag, obtained from tiBReady. i.e. Return the value of the Sy...
Definition: tiLib.c:4226
int tiRocEnable(int roc)
Definition: tiLib.c:7798
volatile unsigned int rocEnable
Definition: tiLib.h:102
int tiDisableRandomTrigger()
Disable random trigger generation.
Definition: tiLib.c:2537
unsigned int tiGetLiveTime()
Return the current "live" time of the module.
Definition: tiLib.c:5811
int tiSetTriggerLock(int enable)
Set the the trigger lock mode.
Definition: tiLib.c:3272
int tiGetRocEnableMask()
Definition: tiLib.c:7845
int tiGetClockSource()
Get the current clock source.
Definition: tiLib.c:4572
volatile unsigned int hfbr_tiID[8]
Definition: tiLib.h:117
void tiTrigLinkReset()
Reset the trigger link.
Definition: tiLib.c:3794
void tiSlaveStatus(int pflag)
Print a summary of all fiber port connections to potential TI Slaves.
Definition: tiLib.c:1356
volatile unsigned int master_tiID
Definition: tiLib.h:118
unsigned int blank9
Definition: tiLib.h:114
volatile unsigned int reset
Definition: tiLib.h:105
Definition: tiLib.h:51
int tiSetTrig21Delay(int delay)
Set the delay of Trig1 relative to Trig2 when trigger source is 11.
Definition: tiLib.c:5672
unsigned int tiBlockStatus(int fiber, int pflag)
Show block Status of specified fiber.
Definition: tiLib.c:5972
int tiPrintBusyCounters()
Print the BUSY counters for all busy sources.
Definition: tiLib.c:7681
volatile unsigned int busy_scaler2[9]
Definition: tiLib.h:115
int tiSetEventFormat(int format)
Set the event format.
Definition: tiLib.c:2314
volatile unsigned int sync
Definition: tiLib.h:62
int tiGetFiberLatencyMeasurement()
Return measured fiber length.
Definition: tiLib.c:6165
volatile unsigned int trig1Prescale
Definition: tiLib.h:65
int tiSetInputPrescale(int input, int prescale)
Set the prescale factor for the selected input.
Definition: tiLib.c:3552
volatile unsigned int blockBuffer
Definition: tiLib.h:66
int tiSyncResetRequestStatus(int pflag)
Status of SyncReset Request received bits.
Definition: tiLib.c:6600
volatile unsigned int adr32
Definition: tiLib.h:57
int tiGetPortTrigSrcEnabled(int port)
Get the trigger sources enabled bits of the selected port.
Definition: tiLib.c:1742
volatile unsigned int fixedPulser2
Definition: tiLib.h:84
int tiSetCrateID_prIinit(int cid)
unsigned int busy_scaler1[7]
Definition: tiLib.h:108
pthread_mutex_t tiISR_mutex
Definition: tiLib.h:26
int tiGetReadoutEvents()
Return the value of the number of readout events accepted.
Definition: tiLib.c:4265
int tiGetSlavePort()
Returns the port of which the TI Slave has been configured (or will be)
Definition: tiLib.c:1340
int tiDisableTSInput(unsigned int inpMask)
Disable trigger inputs labelled TS#1-6 on the Front Panel.
Definition: tiLib.c:4431
int tiGetSlaveBlocklevel(int port)
Get the blocklevel of the TI-Slave on the selected port.
Definition: tiLib.c:1781
volatile unsigned int dataFormat
Definition: tiLib.h:59
volatile unsigned int output
Definition: tiLib.h:72
int tiGetTriggerHoldoffMin(int rule, int pflag)
Get the value for a specified trigger rule minimum busy.
Definition: tiLib.c:5077
int tiDisableDataReadout()
Disable the necessity to readout the TI for every block.
Definition: tiLib.c:5139
unsigned int tiGetBlockLimit()
Returns the value that is currently programmed as the block limit.
Definition: tiLib.c:4134
int tiEnableFiber(unsigned int fiber)
Enable Fiber transceiver.
Definition: tiLib.c:3129
int tiClockResync()
Resync the 250 MHz Clock.
Definition: tiLib.c:1608
volatile unsigned int intsetup
Definition: tiLib.h:55
volatile unsigned int pulserEvType
Definition: tiLib.h:77
volatile unsigned int adr24
Definition: tiLib.h:97
int tiGetSyncHistoryBufferStatus(int pflag)
Get the status of the SyncCommand History Buffer.
Definition: tiLib.c:6247
volatile unsigned int GTPStatusA
Definition: tiLib.h:92
unsigned int tiGetSWAStatus(int reg)
Return the value from the SWa fast link register.
Definition: tiLib.c:6970
int tiReset()
Perform a soft reset of the TI.
Definition: tiLib.c:1634
void tiTriggerReadyReset()
Reset the registers that record the triggers enabled status of TI Slaves.
Definition: tiLib.c:6661
int tiGetTrig21Delay()
Get the delay of Trig1 relative to Trig2 when trigger source is 11.
Definition: tiLib.c:5703
int tiSetRandomTrigger(int trigger, int setting)
Set the parameters of the random internal trigger.
Definition: tiLib.c:2485
unsigned int blank1
Definition: tiLib.h:71
int tiSetTriggerWindow(int window_width)
Set the window of the input trigger coincidence window.
Definition: tiLib.c:5562
volatile unsigned int blocklimit
Definition: tiLib.h:104
volatile unsigned int fixedPulser1
Definition: tiLib.h:83
int tiLatchTimers()
Latch the Busy and Live Timers.
Definition: tiLib.c:5788
volatile unsigned int trigDelay
Definition: tiLib.h:56
int tiDecodeTriggerType(volatile unsigned int *data, int data_len, int event)
Definition: tiLib.c:3032
volatile unsigned int ts_scaler[6]
Definition: tiLib.h:113