JLab Pipeline TD Library  3v6.1
tdLib.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  * Software driver for the JLab Trigger Distribution Module
17  *
18  *----------------------------------------------------------------------------*/
19 #ifndef TDLIB_H
20 #define TDLIB_H
21 
23 {
24  /* 0x00000 */ volatile unsigned int boardID;
25  /* 0x00004 */ volatile unsigned int fiber;
26  /* 0x00008 */ volatile unsigned int intsetup;
27  /* 0x0000C */ volatile unsigned int trigDelay;
28  /* 0x00010 */ volatile unsigned int adr32;
29  /* 0x00014 */ volatile unsigned int blocklevel;
30  /* 0x00018 */ volatile unsigned int dataFormat;
31  /* 0x0001C */ volatile unsigned int vmeControl;
32  /* 0x00020 */ volatile unsigned int trigsrc;
33  /* 0x00024 */ volatile unsigned int sync;
34  /* 0x00028 */ volatile unsigned int busy;
35  /* 0x0002C */ volatile unsigned int fiber_busy;
36  /* 0x00030 */ volatile unsigned int trig1Prescale;
37  /* 0x00034 */ volatile unsigned int blockBuffer;
38  /* 0x00038 */ volatile unsigned int triggerRule;
39  /* 0x0003C */ volatile unsigned int triggerWindow;
40  /* 0x00040 */ unsigned int blank0;
41  /* 0x00044 */ volatile unsigned int tsInput;
42  /* 0x00048 */ unsigned int blank1;
43  /* 0x0004C */ volatile unsigned int output;
44  /* 0x00050 */ volatile unsigned int fiberSyncDelay;
45  /* 0x00054 */ volatile unsigned int rocAckRead[2];
46  /* 0x0005C */ unsigned int blank2[(0x64-0x5C)/4];
47  /* 0x00064 */ volatile unsigned int inputPrescale;
48  /* 0x00068 */ unsigned int blank3[(0x74-0x68)/4];
49  /* 0x00074 */ volatile unsigned int fp_prescale;
50  /* 0x00078 */ volatile unsigned int syncCommand;
51  /* 0x0007C */ volatile unsigned int syncDelay;
52  /* 0x00080 */ volatile unsigned int syncWidth;
53  /* 0x00084 */ volatile unsigned int triggerCommand;
54  /* 0x00088 */ volatile unsigned int randomPulser;
55  /* 0x0008C */ volatile unsigned int fixedPulser1;
56  /* 0x00090 */ volatile unsigned int fixedPulser2;
57  /* 0x00094 */ volatile unsigned int nblocks;
58  /* 0x00098 */ volatile unsigned int trigCount;
59  /* 0x0009C */ volatile unsigned int runningMode;
60  /* 0x000A0 */ unsigned int blank4[(0xA8-0xA0)/4];
61  /* 0x000A8 */ volatile unsigned int livetime;
62  /* 0x000AC */ volatile unsigned int busytime;
63  /* 0x000B0 */ volatile unsigned int GTPStatusA;
64  /* 0x000B4 */ volatile unsigned int GTPStatusB;
65  /* 0x000B8 */ volatile unsigned int GTPtriggerBufferLength;
66  /* 0x000BC */ volatile unsigned int inputCounter;
67  /* 0x000C0 */ volatile unsigned int blockStatus[4];
68  /* 0x000D0 */ volatile unsigned int adr24;
69  /* 0x000D4 */ volatile unsigned int syncEventCtrl;
70  /* 0x000D8 */ volatile unsigned int eventNumber_hi;
71  /* 0x000DC */ volatile unsigned int eventNumber_lo;
72  /* 0x000E0 */ unsigned int blank5[(0xEC-0xE0)/4];
73  /* 0x000EC */ volatile unsigned int rocEnable;
74  /* 0x000F0 */ unsigned int blank6[(0xFC-0xF0)/4];
75  /* 0x000FC */ volatile unsigned int blocklimit;
76  /* 0x00100 */ volatile unsigned int reset;
77  /* 0x00104 */ volatile unsigned int fpDelay[2];
78  /* 0x0010C */ unsigned int blank7[(0x128-0x10C)/4];
79  /* 0x00128 */ volatile unsigned int fpBusy;
80  /* 0x0012C */ unsigned int blank8[(0x138-0x12C)/4];
81  /* 0x00138 */ volatile unsigned int triggerRuleMin;
82  /* 0x0013C */ unsigned int blank9;
83  /* 0x00140 */ volatile unsigned int trigTable[(0x180-0x140)/4];
84  /* 0x00180 */ volatile unsigned int busy_scaler1[7];
85  /* 0x0019C */ volatile unsigned int busy_scaler2[9];
86  /* 0x001C0 */ unsigned int blank10[(0x1D0-0x1C0)/4];
87  /* 0x001D0 */ volatile unsigned int hfbr_tiID[8];
88  /* 0x001F0 */ volatile unsigned int master_tiID;
89  /* 0x001F4 */ unsigned int blank11[(0xDC00-0x1F4)/4];
90  /* 0x0DC00 */ volatile unsigned int sysMon[(0xDE00-0xDC00)/4];
91  /* 0x0DE00 */ unsigned int blank12[(0xFFFC-0xDE00)/4];
92  /* 0x0FFFC */ volatile unsigned int eJTAGLoad;
93  /* 0x10000 */ volatile unsigned int JTAGPROMBase[(0x20000-0x10000)/4];
94  /* 0x20000 */ volatile unsigned int JTAGFPGABase[(0x30000-0x20000)/4];
95 };
96 
97 #define TD_MAX_VME_SLOTS 21
98 #define TD_MAX_FIBER_PORTS 8
99 #define TD_MAX_PORTNAME_CHARS 20
100 
101 /* Firmware Masks */
102 #define TD_FIRMWARE_ID_MASK 0xFFFF0000
103 #define TD_FIRMWARE_TYPE_MASK 0x0000F000
104 #define TD_FIRMWARE_TYPE_PROD 1
105 #define TD_FIRMWARE_TYPE_P 3
106 #define TD_FIRMWARE_MAJOR_VERSION_MASK 0x00000FF0
107 #define TD_FIRWMARE_MINOR_VERSION_MASK 0x0000000F
108 
109 #define TD_SUPPORTED_FIRMWARE 0x61
110 #define TD_SUPPORTED_TYPE TD_FIRMWARE_TYPE_P
111 
112 /* 0x0 boardID bits and masks */
113 #define TD_BOARDID_TYPE_TIDS 0x71D5
114 #define TD_BOARDID_TYPE_TI 0x7100
115 #define TD_BOARDID_TYPE_TS 0x7500
116 #define TD_BOARDID_TYPE_TD 0x7D00
117 #define TD_BOARDID_TYPE_MASK 0xFF000000
118 #define TD_BOARDID_PROD_MASK 0x00FF0000
119 #define TD_BOARDID_GEOADR_MASK 0x00001F00
120 #define TD_BOARDID_CRATEID_MASK 0x000000FF
121 
122 /* 0x4 fiber bits and masks */
123 #define TD_FIBER_1 (1<<0)
124 #define TD_FIBER_2 (1<<1)
125 #define TD_FIBER_3 (1<<2)
126 #define TD_FIBER_4 (1<<3)
127 #define TD_FIBER_5 (1<<4)
128 #define TD_FIBER_6 (1<<5)
129 #define TD_FIBER_7 (1<<6)
130 #define TD_FIBER_8 (1<<7)
131 #define TD_FIBER_ENABLED(x) (1<<(x+1))
132 #define TD_FIBER_MASK 0x000000FF
133 #define TD_FIBER_CONNECTED_1 (1<<16)
134 #define TD_FIBER_CONNECTED_2 (1<<17)
135 #define TD_FIBER_CONNECTED_3 (1<<18)
136 #define TD_FIBER_CONNECTED_4 (1<<19)
137 #define TD_FIBER_CONNECTED_5 (1<<20)
138 #define TD_FIBER_CONNECTED_6 (1<<21)
139 #define TD_FIBER_CONNECTED_7 (1<<22)
140 #define TD_FIBER_CONNECTED_8 (1<<23)
141 #define TD_FIBER_CONNECTED_TI(x) (1<<(x+15))
142 #define TD_FIBER_CONNECTED_MASK 0x00FF0000
143 #define TD_FIBER_TRIGSRC_ENABLED_1 (1<<24)
144 #define TD_FIBER_TRIGSRC_ENABLED_2 (1<<25)
145 #define TD_FIBER_TRIGSRC_ENABLED_3 (1<<26)
146 #define TD_FIBER_TRIGSRC_ENABLED_4 (1<<27)
147 #define TD_FIBER_TRIGSRC_ENABLED_5 (1<<28)
148 #define TD_FIBER_TRIGSRC_ENABLED_6 (1<<29)
149 #define TD_FIBER_TRIGSRC_ENABLED_7 (1<<30)
150 #define TD_FIBER_TRIGSRC_ENABLED_8 (1<<31)
151 #define TD_FIBER_TRIGSRC_ENABLED_TI(x) (1<<(x+23))
152 #define TD_FIBER_TRIGSRC_ENABLED_MASK 0xFF000000
153 
154 /* 0x8 intsetup bits and masks */
155 #define TD_INTSETUP_VECTOR_MASK 0x000000FF
156 #define TD_INTSETUP_LEVEL_MASK 0x00000F00
157 #define TD_INTSETUP_ENABLE (1<<16)
158 
159 /* 0xC trigDelay bits and masks */
160 #define TD_TRIGDELAY_TRIG1_DELAY_MASK 0x000000FF
161 #define TD_TRIGDELAY_TRIG1_WIDTH_MASK 0x0000FF00
162 #define TD_TRIGDELAY_TRIG2_DELAY_MASK 0x00FF0000
163 #define TD_TRIGDELAY_TRIG2_WIDTH_MASK 0xFF000000
164 
165 /* 0x10 adr32 bits and masks */
166 #define TD_ADR32_MBLK_ADDR_MAX_MASK 0x000003FE
167 #define TD_ADR32_MBLK_ADDR_MIN_MASK 0x003FC000
168 #define TD_ADR32_BASE_MASK 0xFF800000
169 
170 /* 0x14 blocklevel bits and masks */
171 #define TD_BLOCKLEVEL_MASK 0x000000FF
172 
173 /* 0x18 dataFormat bits and masks */
174 #define TD_DATAFORMAT_TWOBLOCK_PLACEHOLDER (1<<0)
175 #define TD_DATAFORMAT_TIMING_WORD (1<<1)
176 #define TD_DATAFORMAT_STATUS_WORD (1<<2)
177 
178 /* 0x1C vmeControl bits and masks */
179 #define TD_VMECONTROL_BERR (1<<0)
180 #define TD_VMECONTROL_TOKEN (1<<1)
181 #define TD_VMECONTROL_MBLK (1<<2)
182 #define TD_VMECONTROL_A32M (1<<3)
183 #define TD_VMECONTROL_A32 (1<<4)
184 #define TD_VMECONTROL_ERROR_INT (1<<7)
185 #define TD_VMECONTROL_I2CDEV_HACK (1<<8)
186 #define TD_VMECONTROL_TOKEN_HI (1<<9)
187 #define TD_VMECONTROL_FIRST_BOARD (1<<10)
188 #define TD_VMECONTROL_LAST_BOARD (1<<11)
189 #define TD_VMECONTROL_BUFFER_DISABLE (1<<15)
190 
191 /* 0x20 trigsrc bits and masks */
192 #define TD_TRIGSRC_SOURCEMASK 0x0000F3FF
193 #define TD_TRIGSRC_P0 (1<<0)
194 #define TD_TRIGSRC_HFBR1 (1<<1)
195 #define TD_TRIGSRC_LOOPBACK (1<<2)
196 #define TD_TRIGSRC_FPTRG (1<<3)
197 #define TD_TRIGSRC_VME (1<<4)
198 #define TD_TRIGSRC_TSINPUTS (1<<5)
199 #define TD_TRIGSRC_TSREV2 (1<<6)
200 #define TD_TRIGSRC_PULSER (1<<7)
201 #define TD_TRIGSRC_ENABLE (1<<8)
202 #define TD_TRIGSRC_P2BUSY (1<<9)
203 #define TD_TRIGSRC_PART_1 (1<<12)
204 #define TD_TRIGSRC_PART_2 (1<<13)
205 #define TD_TRIGSRC_PART_3 (1<<14)
206 #define TD_TRIGSRC_PART_4 (1<<15)
207 #define TD_TRIGSRC_MONITOR_MASK 0xFFFF0000
208 
209 /* 0x24 sync bits and masks */
210 #define TD_SYNC_SOURCEMASK 0x0000FFFF
211 #define TD_SYNC_P0 (1<<0)
212 #define TD_SYNC_HFBR1 (1<<1)
213 #define TD_SYNC_HFBR5 (1<<2)
214 #define TD_SYNC_FP (1<<3)
215 #define TD_SYNC_LOOPBACK (1<<4)
216 #define TD_SYNC_MONITOR_MASK 0xFFFF0000
217 
218 /* 0x28 busy bits and masks */
219 #define TD_BUSY_SOURCEMASK 0x0000FFFF
220 #define TD_BUSY_P2 (1<<2)
221 #define TD_BUSY_TRIGGER_LOCK (1<<6)
222 #define TD_BUSY_LOOPBACK (1<<7)
223 #define TD_BUSY_HFBR1 (1<<8)
224 #define TD_BUSY_HFBR2 (1<<9)
225 #define TD_BUSY_HFBR3 (1<<10)
226 #define TD_BUSY_HFBR4 (1<<11)
227 #define TD_BUSY_HFBR5 (1<<12)
228 #define TD_BUSY_HFBR6 (1<<13)
229 #define TD_BUSY_HFBR7 (1<<14)
230 #define TD_BUSY_HFBR8 (1<<15)
231 #define TD_BUSY_HFBR_MASK 0x0000FF00
232 #define TD_BUSY_MONITOR_MASK 0xFFFF0000
233 #define TD_BUSY_MONITOR_P2 (1<<18)
234 #define TD_BUSY_MONITOR_TRIG_LOST (1<<22)
235 #define TD_BUSY_MONITOR_LOOPBACK (1<<23)
236 #define TD_BUSY_MONITOR_HFBR1 (1<<24)
237 #define TD_BUSY_MONITOR_HFBR2 (1<<25)
238 #define TD_BUSY_MONITOR_HFBR3 (1<<26)
239 #define TD_BUSY_MONITOR_HFBR4 (1<<27)
240 #define TD_BUSY_MONITOR_HFBR5 (1<<28)
241 #define TD_BUSY_MONITOR_HFBR6 (1<<29)
242 #define TD_BUSY_MONITOR_HFBR7 (1<<30)
243 #define TD_BUSY_MONITOR_HFBR8 (1<<31)
244 #define TD_BUSY_MONITOR_FIBER_BUSY(i) (1<<(23+i))
245 
246 /* 0x2c fiber_busy bits and masks */
247 #define TD_FIBER_BUSY_HFBR1 (1<<16)
248 #define TD_FIBER_BUSY_HFBR2 (1<<17)
249 #define TD_FIBER_BUSY_HFBR3 (1<<18)
250 #define TD_FIBER_BUSY_HFBR4 (1<<19)
251 #define TD_FIBER_BUSY_HFBR5 (1<<20)
252 #define TD_FIBER_BUSY_HFBR6 (1<<21)
253 #define TD_FIBER_BUSY_HFBR7 (1<<22)
254 #define TD_FIBER_BUSY_HFBR8 (1<<23)
255 #define TD_FIBER_BUSY(i) (1<<(15+i))
256 
257 /* 0x34 blockBuffer bits and masks */
258 #define TD_BLOCKBUFFER_BUFFERLEVEL_MASK 0x0000FFFF
259 #define TD_BLOCKBUFFER_BLOCKS_READY_MASK 0x0000FF00
260 #define TD_BLOCKBUFFER_BLOCKS_NEEDACK_MASK 0xFF000000
261 
262 /* 0x4C output bits and masks */
263 #define TD_OUTPUT_MASK 0x0000FFFF
264 #define TD_OUTPUT_BLOCKS_READY_MASK 0x00FF0000
265 #define TD_OUTPUT_EVENTS_IN_BLOCK_MASK 0xFF000000
266 
267 /* 0x78 syncCommand bits and masks */
268 #define TD_SYNCCOMMAND_VME_CLOCKRESET 0x11
269 #define TD_SYNCCOMMAND_CLK250_RESYNC 0x22
270 #define TD_SYNCCOMMAND_AD9510_RESYNC 0x33
271 #define TD_SYNCCOMMAND_GTP_STATUSB_RESET 0x44
272 #define TD_SYNCCOMMAND_TRIGGERLINK_ENABLE 0x55
273 #define TD_SYNCCOMMAND_TRIGGERLINK_DISABLE 0x77
274 #define TD_SYNCCOMMAND_TRIGGER_READY_RESET 0xAA
275 #define TD_SYNCCOMMAND_SYNCRESET 0xDD
276 #define TD_SYNCCOMMAND_SYNCCODE_MASK 0x000000FF
277 
278 /* 0x7C syncDelay bits and masks */
279 #define TD_SYNCDELAY_MASK 0x0000007F
280 
281 /* 0x80 syncWidth bits and masks */
282 #define TD_SYNCWIDTH_MASK 0x7F
283 #define TD_SYNCWIDTH_LONGWIDTH_ENABLE (1<<7)
284 
285 /* 0x94 nblocks bits and masks */
286 #define TD_NBLOCKS_BLOCK_COUNT_MASK 0x00FFFFFF
287 
288 /* 0x9C runningMode settings */
289 #define TD_RUNNINGMODE_ENABLE 0x71
290 #define TD_RUNNINGMODE_DISABLE 0x0
291 
292 /* 0xA0 fiberLatencyMeasurement bits and masks */
293 #define TD_FIBERLATENCYMEASUREMENT_CARRYCHAIN_MASK 0x0000FFFF
294 #define TD_FIBERLATENCYMEASUREMENT_IODELAY_MASK 0x00FF0000
295 #define TD_FIBERLATENCYMEASUREMENT_DATA_MASK 0xFF000000
296 
297 /* 0xA4 fiberAlignment bits and masks */
298 #define TD_FIBERALIGNMENT_HFBR1_IODELAY_MASK 0x000000FF
299 #define TD_FIBERALIGNMENT_HFBR1_SYNCDELAY_MASK 0x0000FF00
300 #define TD_FIBERALIGNMENT_HFBR5_IODELAY_MASK 0x00FF0000
301 #define TD_FIBERALIGNMENT_HFBR5_SYNCDELAY_MASK 0xFF000000
302 
303 /* 0xC0 blockStatus bits and masks */
304 #define TD_BLOCKSTATUS_NBLOCKS_READY0 0x000000FF
305 #define TD_BLOCKSTATUS_NBLOCKS_NEEDACK0 0x0000FF00
306 #define TD_BLOCKSTATUS_NBLOCKS_READY1 0x00FF0000
307 #define TD_BLOCKSTATUS_NBLOCKS_NEEDACK1 0xFF000000
308 
309 /* 0xD0 adr24 bits and masks */
310 #define TD_ADR24_ADDRESS_MASK 0x0000001F
311 #define TD_ADR24_HARDWARE_SET_MASK 0x000003E0
312 #define TD_ADR24_TM_NBLOCKS_READY1 0x00FF0000
313 #define TD_ADR24_TM_NBLOCKS_NEEDACK1 0xFF000000
314 
315 /* 0xEC rocEnable bits and masks */
316 #define TD_ROCENABLE_MASK 0x000000FF
317 #define TD_ROCENABLE_ROC(x) (1<<(x))
318 #define TD_ROCENABLE_SYNCRESET_REQUEST_ENABLE_MASK 0x0007FC00
319 #define TD_ROCENABLE_SYNCRESET_REQUEST_MONITOR_MASK 0x1FF00000
320 
321 
322 /* 0x100 reset bits and masks */
323 #define TD_RESET_I2C (1<<1)
324 #define TD_RESET_JTAG (1<<2)
325 #define TD_RESET_SFM (1<<3)
326 #define TD_RESET_SOFT (1<<4)
327 #define TD_RESET_BUSYACK (1<<7)
328 #define TD_RESET_CLK250 (1<<8)
329 #define TD_RESET_CLK200 (1<<8)
330 #define TD_RESET_CLK125 (1<<9)
331 #define TD_RESET_MGT (1<<10)
332 #define TD_RESET_AUTOALIGN_P0_SYNC (1<<11)
333 #define TD_RESET_AUTOALIGN_HFBR1_SYNC (1<<11)
334 #define TD_RESET_AUTOALIGN_HFBR5_SYNC (1<<12)
335 #define TD_RESET_RAM_WRITE (1<<12)
336 #define TD_RESET_FIBER_AUTO_ALIGN (1<<13)
337 #define TD_RESET_IODELAY (1<<14)
338 #define TD_RESET_MEASURE_LATENCY (1<<15)
339 #define TD_RESET_TAKE_TOKEN (1<<16)
340 #define TD_RESET_BLOCK_READOUT (1<<17)
341 #define TD_RESET_MGT_RX_RESET (1<<22)
342 #define TD_RESET_LATCH_TIMERS (1<<24)
343 
344 /* 0x1D0-0x1EC TI ID bits and masks */
345 #define TD_ID_TRIGSRC_ENABLE_MASK 0x000000FF
346 #define TD_ID_CRATEID_MASK 0x0000FF00
347 #define TD_ID_BLOCKLEVEL_MASK 0x00FF0000
348 
349 
350 /* Slaves, used by tdAddSlaveMask */
351 #define TD_SLAVE_1 (1<<1)
352 #define TD_SLAVE_2 (1<<2)
353 #define TD_SLAVE_3 (1<<3)
354 #define TD_SLAVE_4 (1<<4)
355 #define TD_SLAVE_5 (1<<5)
356 #define TD_SLAVE_6 (1<<6)
357 #define TD_SLAVE_7 (1<<7)
358 #define TD_SLAVE_8 (1<<8)
359 
360 /* Define default Interrupt vector and level */
361 #define TD_INT_VEC 0xc8
362 #define TD_INT_LEVEL 5
363 
364 /* i2c data masks - 16bit data default */
365 #define TD_I2C_DATA_MASK 0x0000ffff
366 #define TD_I2C_8BIT_DATA_MASK 0x000000ff
367 
368 /* tdInit initialization flag bits */
369 #define TD_INIT_NO_INIT (1<<0)
370 #define TD_INIT_SKIP_FIRMWARE_CHECK (1<<2)
371 #define TD_INIT_USE_ADDR_LIST (1<<3)
372 
373 #ifndef MAX_VME_SLOTS
374 
375 #define MAX_VME_SLOTS 21
376 #endif
377 
378 /* Function prototypes */
379 STATUS tdInit(UINT32 addr, UINT32 addr_inc, int nfind, int iFlag);
380 int tdSlot(unsigned int i);
381 unsigned int tdSlotMask();
382 int tdCheckAddresses();
383 void tdStatus(int id, int pflag);
384 void tdInitPortNames();
385 int tdSetPortName(int id, int iport, char *name);
386 int tdGetPortName(int id, int iport, char **name);
387 int tdSavePortNames(char *filename);
388 int tdLoadPortNames(char *filename);
389 void tdPrintPortNames();
390 void tdGStatus(int pflag);
391 int tdSetBlockLevel(int id, unsigned int blockLevel);
392 int tdGSetBlockLevel(unsigned int blockLevel);
393 int tdSetBlockBufferLevel(int id, unsigned int level);
394 int tdGSetBlockBufferLevel(unsigned int level);
395 int tdGetFirmwareVersion(int id);
396 int tdEnableFiber(int id, unsigned int fiber);
397 int tdDisableFiber(int id, unsigned int fiber);
398 int tdSetFiberMask(int id, unsigned int fibermask);
399 int tdSetBusySource(int id, unsigned int sourcemask, int rFlag);
400 int tdSetTriggerLock(int id, int enable);
401 int tdGSetTriggerLock(int enable);
402 int tdGetTriggerLock(int id);
403 int tdSetSyncSource(int id, unsigned int sync);
404 int tdSetTriggerSource(int id, int trigmask);
405 int tdResetSlaveConfig(int id);
406 int tdAddSlave(int id, unsigned int fiber);
407 int tdRemoveSlave(int id, unsigned int fiber);
408 int tdAddSlaveMask(int id, unsigned int fibermask);
409 int tdAutoAlignSync(int id);
410 unsigned int tdGetSerialNumber(int id, char **rSN);
411 int tdLatchTimers(int id);
412 unsigned int tdGetLiveTime(int id);
413 unsigned int tdGetBusyTime(int id);
414 int tdEnableSyncResetRequest(int id, unsigned int portMask);
415 int tdSyncResetRequestStatus(int id, int pflag);
416 int tdGetConnectedFiberMask(int id);
417 int tdGetTrigSrcEnabledFiberMask(int id);
418 int tdTriggerReadyReset(int id);
419 int tdGetCrateID(int id, int port);
420 int tdSetPortNamesFromCrateID(int id);
422 int tdGetPortTrigSrcEnabled(int id, int port);
423 int tdGetSlaveBlocklevel(int id, int port);
424 int tdResetMGT(int id);
425 int tdResetMGTRx(int id);
426 void tdSlaveStatus(int id, int pflag);
427 unsigned int tdGetBlockStatus(int id, int port, int pflag);
428 int tdGetBusyStatus(int id, int port, int pflag);
429 int tdSetOutputPort(int id, unsigned int set1, unsigned int set2, unsigned int set3, unsigned int set4);
430 unsigned int tdGetTrigCount(int id);
431 unsigned int tdGetBusyCounter(int id, int busysrc);
432 int tdPrintBusyCounters(int id);
433 
434 #endif /* TDLIB_H */
volatile unsigned int trigTable[(0x180-0x140)/4]
Definition: tdLib.h:83
volatile unsigned int hfbr_tiID[8]
Definition: tdLib.h:87
unsigned int blank1
Definition: tdLib.h:42
volatile unsigned int fiberSyncDelay
Definition: tdLib.h:44
int tdLoadPortNames(char *filename)
Load the Port Names as specified in a file.
Definition: tdLib.c:922
volatile unsigned int GTPStatusA
Definition: tdLib.h:63
volatile unsigned int rocEnable
Definition: tdLib.h:73
int tdEnableFiber(int id, unsigned int fiber)
Enable Fiber transceiver.
Definition: tdLib.c:1363
volatile unsigned int sync
Definition: tdLib.h:33
int tdSlot(unsigned int i)
Convert an index into a slot number, where the index is the element of an array of TDs in the order i...
Definition: tdLib.c:370
volatile unsigned int fpBusy
Definition: tdLib.h:79
volatile unsigned int trig1Prescale
Definition: tdLib.h:36
unsigned int blank8[(0x138-0x12C)/4]
Definition: tdLib.h:80
volatile unsigned int fiber_busy
Definition: tdLib.h:35
int tdAddSlave(int id, unsigned int fiber)
Add and configure a TI Slave for the TD.
Definition: tdLib.c:1749
volatile unsigned int syncWidth
Definition: tdLib.h:52
int tdSetSyncSource(int id, unsigned int sync)
Set the Sync source mask.
Definition: tdLib.c:1636
volatile unsigned int blocklevel
Definition: tdLib.h:29
int tdCheckAddresses()
Test of register map.
Definition: tdLib.c:411
int tdSetTriggerSource(int id, int trigmask)
Set trigger sources with specified trigmask.
Definition: tdLib.c:1681
int tdGetConnectedFiberMask(int id)
Returns the mask of fiber channels that report a "connected" status from a TI.
Definition: tdLib.c:2131
unsigned int blank5[(0xEC-0xE0)/4]
Definition: tdLib.h:72
int tdGetTrigSrcEnabledFiberMask(int id)
Returns the mask of fiber channels that report a "connected" status from a TI has it&#39;s trigger source...
Definition: tdLib.c:2159
void tdSlaveStatus(int id, int pflag)
Print a summary of all fiber port connections to potential TI Slaves.
Definition: tdLib.c:2430
volatile unsigned int eJTAGLoad
Definition: tdLib.h:92
int tdSyncResetRequestStatus(int id, int pflag)
Status of SyncReset Request received bits.
Definition: tdLib.c:2079
volatile unsigned int fixedPulser2
Definition: tdLib.h:56
int tdRemoveSlave(int id, unsigned int fiber)
Remove a TI Slave for the TD.
Definition: tdLib.c:1791
unsigned int tdGetBusyCounter(int id, int busysrc)
Return BUSY counter for specified Busy Source.
Definition: tdLib.c:2723
volatile unsigned int inputPrescale
Definition: tdLib.h:47
unsigned int blank2[(0x64-0x5C)/4]
Definition: tdLib.h:46
unsigned int blank0
Definition: tdLib.h:40
unsigned int tdGetSerialNumber(int id, char **rSN)
Get the Module Serial Number.
Definition: tdLib.c:1915
int tdResetSlaveConfig(int id)
Reset the configuration of TI Slaves on the TD.
Definition: tdLib.c:1718
volatile unsigned int busy_scaler2[9]
Definition: tdLib.h:85
int tdAddSlaveMask(int id, unsigned int fibermask)
Add and configure TI Slaves by using a mask for the TD.
Definition: tdLib.c:1843
void tdInitPortNames()
Initialize portName array with default names in the form: Slot%2d - Portd.
Definition: tdLib.c:751
int tdResetMGT(int id)
Reset the MGT.
Definition: tdLib.c:2378
int tdGSetBlockLevel(unsigned int blockLevel)
Set the block level for all initialized TDs.
Definition: tdLib.c:1228
volatile unsigned int fixedPulser1
Definition: tdLib.h:55
volatile unsigned int busytime
Definition: tdLib.h:62
unsigned int blank3[(0x74-0x68)/4]
Definition: tdLib.h:48
int tdGetSlaveBlocklevel(int id, int port)
Get the blocklevel of the TI Slave on the selected port.
Definition: tdLib.c:2348
int tdPrintBusyCounters(int id)
Print the BUSY counters for all busy sources.
Definition: tdLib.c:2752
volatile unsigned int eventNumber_hi
Definition: tdLib.h:70
int tdDisableFiber(int id, unsigned int fiber)
Disable Fiber transceiver.
Definition: tdLib.c:1407
unsigned int tdSlotMask()
Return the VME Slot mask of initialized TDs.
Definition: tdLib.c:390
unsigned int blank7[(0x128-0x10C)/4]
Definition: tdLib.h:78
int tdSetPortNamesFromCrateID(int id)
Set the port names for the specified TD from the received Crate IDs from the TI Slaves.
Definition: tdLib.c:2260
int tdSetTriggerLock(int id, int enable)
Set the the trigger lock mode for the specified TD.
Definition: tdLib.c:1539
unsigned int tdGetBusyTime(int id)
Return the current "busy" time of the module.
Definition: tdLib.c:2017
int tdEnableSyncResetRequest(int id, unsigned int portMask)
Configure which ports (and self) to enable response of a SyncReset request.
Definition: tdLib.c:2045
volatile unsigned int boardID
Definition: tdLib.h:24
volatile unsigned int triggerWindow
Definition: tdLib.h:39
volatile unsigned int inputCounter
Definition: tdLib.h:66
int tdAutoAlignSync(int id)
Auto Align Sync Delay.
Definition: tdLib.c:1881
volatile unsigned int fpDelay[2]
Definition: tdLib.h:77
volatile unsigned int syncDelay
Definition: tdLib.h:51
volatile unsigned int reset
Definition: tdLib.h:76
int tdSetPortName(int id, int iport, char *name)
Rename a specified port to a specified 20 character string.
Definition: tdLib.c:790
volatile unsigned int syncEventCtrl
Definition: tdLib.h:69
Definition: tdLib.h:22
volatile unsigned int JTAGFPGABase[(0x30000-0x20000)/4]
Definition: tdLib.h:94
int tdGetFirmwareVersion(int id)
Get the Firmware Version.
Definition: tdLib.c:1316
volatile unsigned int blocklimit
Definition: tdLib.h:75
volatile unsigned int adr24
Definition: tdLib.h:68
int tdGSetBlockBufferLevel(unsigned int level)
Set the block buffer level for the number of blocks in the system that need to be read out for all in...
Definition: tdLib.c:1297
int tdResetMGTRx(int id)
Reset the MGT Rx CDR.
Definition: tdLib.c:2402
int tdSetBlockLevel(int id, unsigned int blockLevel)
Set the number of events per block.
Definition: tdLib.c:1197
int tdGetPortTrigSrcEnabled(int id, int port)
Get the trigger sources enabled bits of the selected port.
Definition: tdLib.c:2314
volatile unsigned int master_tiID
Definition: tdLib.h:88
unsigned int blank4[(0xA8-0xA0)/4]
Definition: tdLib.h:60
volatile unsigned int trigDelay
Definition: tdLib.h:27
volatile unsigned int randomPulser
Definition: tdLib.h:54
unsigned int blank11[(0xDC00-0x1F4)/4]
Definition: tdLib.h:89
volatile unsigned int trigsrc
Definition: tdLib.h:32
volatile unsigned int busy
Definition: tdLib.h:34
volatile unsigned int triggerCommand
Definition: tdLib.h:53
STATUS tdInit(UINT32 addr, UINT32 addr_inc, int nfind, int iFlag)
Initialize JLAB TD Library.
Definition: tdLib.c:96
volatile unsigned int vmeControl
Definition: tdLib.h:31
volatile unsigned int fp_prescale
Definition: tdLib.h:49
volatile unsigned int eventNumber_lo
Definition: tdLib.h:71
unsigned int blank12[(0xFFFC-0xDE00)/4]
Definition: tdLib.h:91
volatile unsigned int tsInput
Definition: tdLib.h:41
volatile unsigned int blockBuffer
Definition: tdLib.h:37
volatile unsigned int nblocks
Definition: tdLib.h:57
int tdSavePortNames(char *filename)
Save the current port names to a file (with file name: filename)
Definition: tdLib.c:873
unsigned int blank9
Definition: tdLib.h:82
int tdGetTriggerLock(int id)
Get the current setting of the trigger lock mode for the specified TD.
Definition: tdLib.c:1601
volatile unsigned int blockStatus[4]
Definition: tdLib.h:67
int tdGetCrateID(int id, int port)
Get the crate ID of the selected port.
Definition: tdLib.c:2229
unsigned int tdGetBlockStatus(int id, int port, int pflag)
Obtain the status of blocks sent readout acknowledges received from the TI Slaves.
Definition: tdLib.c:2546
unsigned int blank6[(0xFC-0xF0)/4]
Definition: tdLib.h:74
int tdSetBusySource(int id, unsigned int sourcemask, int rFlag)
Set the busy source with a specified sourcemask.
Definition: tdLib.c:1487
int tdSetFiberMask(int id, unsigned int fibermask)
Enable/Disable fiber ports according to specified mask.
Definition: tdLib.c:1448
volatile unsigned int GTPStatusB
Definition: tdLib.h:64
void tdStatus(int id, int pflag)
Print some status information of the TD to standard out.
Definition: tdLib.c:487
volatile unsigned int triggerRuleMin
Definition: tdLib.h:81
volatile unsigned int adr32
Definition: tdLib.h:28
void tdGStatus(int pflag)
Print a summary of all configured TD modules and ports to standard out.
Definition: tdLib.c:997
int tdGetPortName(int id, int iport, char **name)
Get the current specified port name.
Definition: tdLib.c:837
volatile unsigned int sysMon[(0xDE00-0xDC00)/4]
Definition: tdLib.h:90
unsigned int blank10[(0x1D0-0x1C0)/4]
Definition: tdLib.h:86
volatile unsigned int intsetup
Definition: tdLib.h:26
unsigned int tdGetTrigCount(int id)
Return the number of triggers received from the trigger supervisor.
Definition: tdLib.c:2686
void tdGSetPortNamesFromCrateID()
Set the port names for all initialized TD from the received Crate IDs from the TI Slaves...
Definition: tdLib.c:2288
volatile unsigned int runningMode
Definition: tdLib.h:59
volatile unsigned int syncCommand
Definition: tdLib.h:50
int tdGetBusyStatus(int id, int port, int pflag)
Definition: tdLib.c:2594
volatile unsigned int triggerRule
Definition: tdLib.h:38
int tdTriggerReadyReset(int id)
Reset the triggers enabled status bits of TI Slaves.
Definition: tdLib.c:2186
void tdPrintPortNames()
Print the current port names to standard out.
Definition: tdLib.c:965
volatile unsigned int GTPtriggerBufferLength
Definition: tdLib.h:65
volatile unsigned int output
Definition: tdLib.h:43
volatile unsigned int trigCount
Definition: tdLib.h:58
int tdLatchTimers(int id)
Latch the Busy and Live Timers.
Definition: tdLib.c:1964
volatile unsigned int JTAGPROMBase[(0x20000-0x10000)/4]
Definition: tdLib.h:93
volatile unsigned int rocAckRead[2]
Definition: tdLib.h:45
volatile unsigned int dataFormat
Definition: tdLib.h:30
volatile unsigned int fiber
Definition: tdLib.h:25
volatile unsigned int busy_scaler1[7]
Definition: tdLib.h:84
int tdSetBlockBufferLevel(int id, unsigned int level)
Set the block buffer level for the number of blocks in the system that need to be read out...
Definition: tdLib.c:1256
int tdSetOutputPort(int id, 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: tdLib.c:2650
volatile unsigned int livetime
Definition: tdLib.h:61
unsigned int tdGetLiveTime(int id)
Return the current "live" time of the module.
Definition: tdLib.c:1990
int tdGSetTriggerLock(int enable)
Set the the trigger lock mode for all initialized TDs.
Definition: tdLib.c:1572