tiLib.h

Go to the documentation of this file.
00001 /*----------------------------------------------------------------------------*
00002  *  Copyright (c) 2012        Southeastern Universities Research Association, *
00003  *                            Thomas Jefferson National Accelerator Facility  *
00004  *                                                                            *
00005  *    This software was developed under a United States Government license    *
00006  *    described in the NOTICE file included as part of this distribution.     *
00007  *                                                                            *
00008  *    Authors: Bryan Moffit                                                   *
00009  *             moffit@jlab.org                   Jefferson Lab, MS-12B3       *
00010  *             Phone: (757) 269-5660             12000 Jefferson Ave.         *
00011  *             Fax:   (757) 269-5800             Newport News, VA 23606       *
00012  *                                                                            *
00013  *----------------------------------------------------------------------------*
00014  *
00015  * Description:
00016  *     Primitive trigger control for VME CPUs using the TJNAF Trigger
00017  *     Supervisor (TI) card
00018  *
00019  *----------------------------------------------------------------------------*/
00020 #ifndef TILIB_H
00021 #define TILIB_H
00022 
00023 #ifndef VXWORKS
00024 #include <pthread.h>
00025 
00026 pthread_mutex_t tiISR_mutex=PTHREAD_MUTEX_INITIALIZER;
00027 #else
00028 /* #include <intLib.h> */
00029 extern int intLock();
00030 extern int intUnlock();
00031 #endif
00032 
00033 #ifdef VXWORKS
00034 int intLockKeya;
00035 #define INTLOCK {               \
00036     intLockKeya = intLock();            \
00037 }
00038 
00039 #define INTUNLOCK {             \
00040     intUnlock(intLockKeya);         \
00041 }
00042 #else
00043 #define INTLOCK {               \
00044     vmeBusLock();               \
00045 }
00046 #define INTUNLOCK {             \
00047     vmeBusUnlock();             \
00048 }
00049 #endif
00050 
00051 struct TI_A24RegStruct
00052 { volatile unsigned int boardID; volatile unsigned int fiber; volatile unsigned int intsetup;
00056   /* 0x0000C */ volatile unsigned int trigDelay;
00057   /* 0x00010 */ volatile unsigned int adr32;
00058   /* 0x00014 */ volatile unsigned int blocklevel;
00059   /* 0x00018 */ volatile unsigned int dataFormat;
00060   /* 0x0001C */ volatile unsigned int vmeControl;
00061   /* 0x00020 */ volatile unsigned int trigsrc;
00062   /* 0x00024 */ volatile unsigned int sync;
00063   /* 0x00028 */ volatile unsigned int busy;
00064   /* 0x0002C */ volatile unsigned int clock;
00065   /* 0x00030 */ volatile unsigned int trig1Prescale;
00066   /* 0x00034 */ volatile unsigned int blockBuffer;
00067   /* 0x00038 */ volatile unsigned int triggerRule;
00068   /* 0x0003C */ volatile unsigned int triggerWindow;
00069   /* 0x00040 */          unsigned int blank0[(0x48-0x40)/4];
00070   /* 0x00048 */ volatile unsigned int tsInput;
00071   /* 0x0004C */ volatile unsigned int output;
00072   /* 0x00050 */ volatile unsigned int fiberSyncDelay;
00073   /* 0x00054 */          unsigned int blank_prescale[(0x78-0x54)/4];
00074   /* 0x00078 */ volatile unsigned int syncCommand;
00075   /* 0x0007C */ volatile unsigned int syncDelay;
00076   /* 0x00080 */ volatile unsigned int syncWidth;
00077   /* 0x00084 */ volatile unsigned int triggerCommand;
00078   /* 0x00088 */ volatile unsigned int randomPulser;
00079   /* 0x0008C */ volatile unsigned int fixedPulser1;
00080   /* 0x00090 */ volatile unsigned int fixedPulser2;
00081   /* 0x00094 */ volatile unsigned int nblocks;
00082   /* 0x00098 */ volatile unsigned int syncHistory;
00083   /* 0x0009C */ volatile unsigned int runningMode;
00084   /* 0x000A0 */ volatile unsigned int fiberLatencyMeasurement;
00085   /* 0x000A4 */ volatile unsigned int fiberAlignment;
00086   /* 0x000A8 */ volatile unsigned int livetime;
00087   /* 0x000AC */ volatile unsigned int busytime;
00088   /* 0x000B0 */ volatile unsigned int GTPStatusA;
00089   /* 0x000B4 */ volatile unsigned int GTPStatusB;
00090   /* 0x000B8 */ volatile unsigned int GTPtriggerBufferLength;
00091   /* 0x000BC */ volatile unsigned int inputCounter;
00092   /* 0x000C0 */ volatile unsigned int blockStatus[4];
00093   /* 0x000D0 */ volatile unsigned int adr24;
00094   /* 0x000D4 */ volatile unsigned int syncEventCtrl;
00095   /* 0x000D8 */ volatile unsigned int eventNumber_hi;
00096   /* 0x000DC */ volatile unsigned int eventNumber_lo;
00097   /* 0x000E0 */          unsigned int blank2[(0xFC-0xE0)/4];
00098   /* 0x000FC */ volatile unsigned int blocklimit;
00099   /* 0x00100 */ volatile unsigned int reset;
00100   /* 0x00104 */          unsigned int blank3[(0x180-0x104)/4];
00101   /* 0x00180 */ volatile unsigned int ts_scaler[6];
00102   /* 0x00198 */          unsigned int blank4[(0x1D0-0x198)/4];
00103   /* 0x001D0 */ volatile unsigned int hfbr_tiID[8];
00104   /* 0x001F0 */ volatile unsigned int master_tiID;
00105   /* 0x001F4 */          unsigned int blank5[(0x8C0-0x1F4)/4];
00106   /* 0x008C0 */ volatile unsigned int trigTable[(0x900-0x8C0)/4];
00107   /* 0x00900 */          unsigned int blank6[(0x2000-0x900)/4];
00108   /* 0x02000 */ volatile unsigned int SWB_status[(0x2200-0x2000)/4];
00109   /* 0x02200 */          unsigned int blank7[(0x2800-0x2200)/4];
00110   /* 0x02800 */ volatile unsigned int SWA_status[(0x3000-0x2800)/4];
00111   /* 0x03000 */          unsigned int blank8[(0xFFFC-0x3000)/4];
00112   /* 0x0FFFC */ volatile unsigned int eJTAGLoad;
00113   /* 0x10000 */ volatile unsigned int JTAGPROMBase[(0x20000-0x10000)/4];
00114   /* 0x20000 */ volatile unsigned int JTAGFPGABase[(0x30000-0x20000)/4];
00115   /* 0x30000 */ volatile unsigned int SWA[(0x40000-0x30000)/4];
00116   /* 0x40000 */ volatile unsigned int SWB[(0x50000-0x40000)/4];
00117 
00118 
00119 };
00120 
00121 /* Define TI Modes of operation:     Ext trigger - Interrupt mode   0
00122                                      TS  trigger - Interrupt mode   1
00123                                      Ext trigger - polling  mode    2 
00124                                      TS  trigger - polling  mode    3  */
00125 #define TI_READOUT_EXT_INT    0
00126 #define TI_READOUT_TS_INT     1
00127 #define TI_READOUT_EXT_POLL   2
00128 #define TI_READOUT_TS_POLL    3
00129 
00130 /* Supported firmware version */
00131 #define TI_SUPPORTED_FIRMWARE 0x203
00132 
00133 /* 0x0 boardID bits and masks */
00134 #define TI_BOARDID_TYPE_TIDS         0x71D5
00135 #define TI_BOARDID_TYPE_TI           0x7100
00136 #define TI_BOARDID_TYPE_TS           0x7500
00137 #define TI_BOARDID_TYPE_TD           0x7D00
00138 #define TI_BOARDID_TYPE_MASK     0xFF000000
00139 #define TI_BOARDID_PROD_MASK     0x00FF0000
00140 #define TI_BOARDID_GEOADR_MASK   0x00001F00
00141 #define TI_BOARDID_CRATEID_MASK  0x000000FF
00142 
00143 /* 0x4 fiber bits and masks */
00144 #define TI_FIBER_1                        (1<<0)
00145 #define TI_FIBER_2                        (1<<1)
00146 #define TI_FIBER_3                        (1<<2)
00147 #define TI_FIBER_4                        (1<<3)
00148 #define TI_FIBER_5                        (1<<4)
00149 #define TI_FIBER_6                        (1<<5)
00150 #define TI_FIBER_7                        (1<<6)
00151 #define TI_FIBER_8                        (1<<7)
00152 #define TI_FIBER_ENABLE_P0                (1<<8)
00153 #define TI_FIBER_ENABLED(x)           (1<<(x+1))
00154 #define TI_FIBER_MASK                 0x000000FF
00155 #define TI_FIBER_CONNECTED_1             (1<<16)
00156 #define TI_FIBER_CONNECTED_2             (1<<17)
00157 #define TI_FIBER_CONNECTED_3             (1<<18)
00158 #define TI_FIBER_CONNECTED_4             (1<<19)
00159 #define TI_FIBER_CONNECTED_5             (1<<20)
00160 #define TI_FIBER_CONNECTED_6             (1<<21)
00161 #define TI_FIBER_CONNECTED_7             (1<<22)
00162 #define TI_FIBER_CONNECTED_8             (1<<23)
00163 #define TI_FIBER_CONNECTED_TI(x)     (1<<(x+15))
00164 #define TI_FIBER_CONNECTED_MASK       0x00FF0000
00165 #define TI_FIBER_TRIGSRC_ENABLED_1       (1<<24)
00166 #define TI_FIBER_TRIGSRC_ENABLED_2       (1<<25)
00167 #define TI_FIBER_TRIGSRC_ENABLED_3       (1<<26)
00168 #define TI_FIBER_TRIGSRC_ENABLED_4       (1<<27)
00169 #define TI_FIBER_TRIGSRC_ENABLED_5       (1<<28)
00170 #define TI_FIBER_TRIGSRC_ENABLED_6       (1<<29)
00171 #define TI_FIBER_TRIGSRC_ENABLED_7       (1<<30)
00172 #define TI_FIBER_TRIGSRC_ENABLED_8       (1<<31)
00173 #define TI_FIBER_TRIGSRC_ENABLED_TI(x) (1<<(x+23))
00174 #define TI_FIBER_TRIGSRC_ENABLED_MASK 0xFF000000
00175 
00176 /* 0x8 intsetup bits and masks */
00177 #define TI_INTSETUP_VECTOR_MASK   0x000000FF
00178 #define TI_INTSETUP_LEVEL_MASK    0x00000F00
00179 #define TI_INTSETUP_ENABLE        (1<<16)
00180 
00181 /* 0xC trigDelay bits and masks */
00182 #define TI_TRIGDELAY_TRIG1_DELAY_MASK 0x000000FF
00183 #define TI_TRIGDELAY_TRIG1_WIDTH_MASK 0x0000FF00
00184 #define TI_TRIGDELAY_TRIG2_DELAY_MASK 0x00FF0000
00185 #define TI_TRIGDELAY_TRIG2_WIDTH_MASK 0xFF000000
00186 
00187 /* 0x10 adr32 bits and masks */
00188 #define TI_ADR32_MBLK_ADDR_MAX_MASK  0x000003FE
00189 #define TI_ADR32_MBLK_ADDR_MIN_MASK  0x003FC000
00190 #define TI_ADR32_BASE_MASK       0xFF800000
00191 
00192 /* 0x14 blocklevel bits and masks */
00193 #define TI_BLOCKLEVEL_MASK           0x000000FF
00194 #define TI_BLOCKLEVEL_CURRENT_MASK   0x00FF0000
00195 #define TI_BLOCKLEVEL_RECEIVED_MASK  0xFF000000
00196 
00197 
00198 /* 0x18 dataFormat bits and masks */
00199 #define TI_DATAFORMAT_TWOBLOCK_PLACEHOLDER (1<<0)
00200 #define TI_DATAFORMAT_TIMING_WORD          (1<<1)
00201 #define TI_DATAFORMAT_HIGHERBITS_WORD      (1<<2)
00202 
00203 /* 0x1C vmeControl bits and masks */
00204 #define TI_VMECONTROL_BERR           (1<<0)
00205 #define TI_VMECONTROL_TOKEN_TESTMODE (1<<1)
00206 #define TI_VMECONTROL_MBLK           (1<<2)
00207 #define TI_VMECONTROL_A32M           (1<<3)
00208 #define TI_VMECONTROL_A32            (1<<4)
00209 #define TI_VMECONTROL_ERROR_INT      (1<<7)
00210 #define TI_VMECONTROL_I2CDEV_HACK    (1<<8)
00211 #define TI_VMECONTROL_TOKENOUT_HI    (1<<9)
00212 #define TI_VMECONTROL_FIRST_BOARD    (1<<10)
00213 #define TI_VMECONTROL_LAST_BOARD     (1<<11)
00214 #define TI_VMECONTROL_BUFFER_DISABLE (1<<15)
00215 
00216 /* 0x20 trigsrc bits and masks */
00217 #define TI_TRIGSRC_SOURCEMASK       0x0000F3FF
00218 #define TI_TRIGSRC_P0               (1<<0)
00219 #define TI_TRIGSRC_HFBR1            (1<<1)
00220 #define TI_TRIGSRC_LOOPBACK         (1<<2)
00221 #define TI_TRIGSRC_FPTRG            (1<<3)
00222 #define TI_TRIGSRC_VME              (1<<4)
00223 #define TI_TRIGSRC_TSINPUTS         (1<<5)
00224 #define TI_TRIGSRC_TSREV2           (1<<6)
00225 #define TI_TRIGSRC_PULSER           (1<<7)
00226 #define TI_TRIGSRC_HFBR5            (1<<10)
00227 #define TI_TRIGSRC_PART_1           (1<<12)
00228 #define TI_TRIGSRC_PART_2           (1<<13)
00229 #define TI_TRIGSRC_PART_3           (1<<14)
00230 #define TI_TRIGSRC_PART_4           (1<<15)
00231 #define TI_TRIGSRC_MONITOR_MASK     0xFFFF0000
00232 
00233 /* 0x24 sync bits and masks */
00234 #define TI_SYNC_SOURCEMASK              0x000000FF
00235 #define TI_SYNC_P0                      (1<<0)
00236 #define TI_SYNC_HFBR1                   (1<<1)
00237 #define TI_SYNC_HFBR5                   (1<<2)
00238 #define TI_SYNC_FP                      (1<<3)
00239 #define TI_SYNC_LOOPBACK                (1<<4)
00240 #define TI_SYNC_USER_SYNCRESET_ENABLED  (1<<7)
00241 #define TI_SYNC_HFBR1_CODE_MASK         0x00000F00
00242 #define TI_SYNC_HFBR5_CODE_MASK         0x0000F000
00243 #define TI_SYNC_LOOPBACK_CODE_MASK      0x000F0000
00244 #define TI_SYNC_HISTORY_FIFO_MASK       0x00700000
00245 #define TI_SYNC_HISTORY_FIFO_EMPTY      (1<<20)
00246 #define TI_SYNC_HISTORY_FIFO_HALF_FULL  (1<<21)
00247 #define TI_SYNC_HISTORY_FIFO_FULL       (1<<22)
00248 #define TI_SYNC_MONITOR_MASK            0xFF000000
00249 
00250 /* 0x28 busy bits and masks */
00251 #define TI_BUSY_SOURCEMASK      0x0000FFFF
00252 #define TI_BUSY_SWA              (1<<0)
00253 #define TI_BUSY_SWB              (1<<1)
00254 #define TI_BUSY_P2               (1<<2)
00255 #define TI_BUSY_FP_FTDC          (1<<3)
00256 #define TI_BUSY_FP_FADC          (1<<4)
00257 #define TI_BUSY_FP               (1<<5)
00258 #define TI_BUSY_P2_TRIGGER_INPUT (1<<6)
00259 #define TI_BUSY_LOOPBACK         (1<<7)
00260 #define TI_BUSY_HFBR1            (1<<8)
00261 #define TI_BUSY_HFBR2            (1<<9)
00262 #define TI_BUSY_HFBR3            (1<<10)
00263 #define TI_BUSY_HFBR4            (1<<11)
00264 #define TI_BUSY_HFBR5            (1<<12)
00265 #define TI_BUSY_HFBR6            (1<<13)
00266 #define TI_BUSY_HFBR7            (1<<14)
00267 #define TI_BUSY_HFBR8            (1<<15)
00268 #define TI_BUSY_MONITOR_MASK     0xFFFF0000
00269 #define TI_BUSY_MONITOR_SWA      (1<<16)
00270 #define TI_BUSY_MONITOR_SWB      (1<<17)
00271 #define TI_BUSY_MONITOR_P2       (1<<18)
00272 #define TI_BUSY_MONITOR_FP_FTDC  (1<<19)
00273 #define TI_BUSY_MONITOR_FP_FADC  (1<<20)
00274 #define TI_BUSY_MONITOR_FP       (1<<21)
00275 #define TI_BUSY_MONITOR_LOOPBACK (1<<23)
00276 #define TI_BUSY_MONITOR_FIBER_BUSY(x) (1<<(x+23))
00277 #define TI_BUSY_MONITOR_HFBR1    (1<<24)
00278 #define TI_BUSY_MONITOR_HFBR2    (1<<25)
00279 #define TI_BUSY_MONITOR_HFBR3    (1<<26)
00280 #define TI_BUSY_MONITOR_HFBR4    (1<<27)
00281 #define TI_BUSY_MONITOR_HFBR5    (1<<28)
00282 #define TI_BUSY_MONITOR_HFBR6    (1<<29)
00283 #define TI_BUSY_MONITOR_HFBR7    (1<<30)
00284 #define TI_BUSY_MONITOR_HFBR8    (1<<31)
00285 
00286 /* 0x2C clock bits and mask  */
00287 #define TI_CLOCK_INTERNAL    (0)
00288 #define TI_CLOCK_HFBR5       (1)
00289 #define TI_CLOCK_HFBR1       (2)
00290 #define TI_CLOCK_FP          (3)
00291 #define TI_CLOCK_MASK        0x0000000F
00292 
00293 /* 0x30 trig1Prescale bits and masks */
00294 #define TI_TRIG1PRESCALE_MASK          0x0000FFFF
00295 
00296 /* 0x34 blockBuffer bits and masks */
00297 #define TI_BLOCKBUFFER_BUFFERLEVEL_MASK      0x000000FF
00298 #define TI_BLOCKBUFFER_BLOCKS_READY_MASK     0x0000FF00
00299 #define TI_BLOCKBUFFER_TRIGGERS_IN_BLOCK     0x00FF0000
00300 #define TI_BLOCKBUFFER_BLOCKS_NEEDACK_MASK   0x7F000000
00301 #define TI_BLOCKBUFFER_BUSY_ON_BLOCKLIMIT    (1<<28)
00302 #define TI_BLOCKBUFFER_SYNCRESET_REQUESTED   (1<<30)
00303 #define TI_BLOCKBUFFER_SYNCEVENT             (1<<31)
00304 
00305 /* 0x38 triggerRule bits and masks */
00306 #define TI_TRIGGERRULE_RULE1_MASK 0x000000FF
00307 #define TI_TRIGGERRULE_RULE2_MASK 0x0000FF00
00308 #define TI_TRIGGERRULE_RULE3_MASK 0x00FF0000
00309 #define TI_TRIGGERRULE_RULE4_MASK 0xFF000000
00310 
00311 /* 0x3C triggerWindow bits and masks */
00312 #define TI_TRIGGERWINDOW_COINC_MASK 0x0000FFFF
00313 
00314 /* 0x48 tsInput bits and masks */
00315 #define TI_TSINPUT_MASK      0x0000003F
00316 #define TI_TSINPUT_1         (1<<0)
00317 #define TI_TSINPUT_2         (1<<1)
00318 #define TI_TSINPUT_3         (1<<2)
00319 #define TI_TSINPUT_4         (1<<3)
00320 #define TI_TSINPUT_5         (1<<4)
00321 #define TI_TSINPUT_6         (1<<5)
00322 #define TI_TSINPUT_ALL       (0x3F)
00323 
00324 
00325 /* 0x4C output bits and masks */
00326 #define TI_OUTPUT_MASK                 0x0000FFFF
00327 #define TI_OUTPUT_BLOCKS_READY_MASK    0x00FF0000
00328 #define TI_OUTPUT_EVENTS_IN_BLOCK_MASK 0xFF000000
00329 
00330 /* 0x50 fiberSyncDelay bits and masks */
00331 #define TI_FIBERSYNCDELAY_HFBR1_SYNCPHASE_MASK    0x000000FF
00332 #define TI_FIBERSYNCDELAY_HFBR1_SYNCDELAY_MASK    0x0000FF00
00333 #define TI_FIBERSYNCDELAY_LOOPBACK_SYNCDELAY_MASK 0x00FF0000
00334 #define TI_FIBERSYNCDELAY_HFBR5_SYNCDELAY_MASK    0xFF000000
00335 
00336 /* 0x78 syncCommand bits and masks */
00337 #define TI_SYNCCOMMAND_VME_CLOCKRESET      0x11
00338 #define TI_SYNCCOMMAND_CLK250_RESYNC       0x22
00339 #define TI_SYNCCOMMAND_AD9510_RESYNC       0x33
00340 #define TI_SYNCCOMMAND_GTP_STATUSB_RESET   0x44
00341 #define TI_SYNCCOMMAND_TRIGGERLINK_ENABLE  0x55
00342 #define TI_SYNCCOMMAND_TRIGGERLINK_DISABLE 0x77
00343 #define TI_SYNCCOMMAND_SYNCRESET_HIGH      0x99
00344 #define TI_SYNCCOMMAND_TRIGGER_READY_RESET 0xAA
00345 #define TI_SYNCCOMMAND_RESET_EVNUM         0xBB
00346 #define TI_SYNCCOMMAND_SYNCRESET_LOW       0xCC
00347 #define TI_SYNCCOMMAND_SYNCRESET           0xDD
00348 #define TI_SYNCCOMMAND_SYNCCODE_MASK       0x000000FF
00349 
00350 /* 0x7C syncDelay bits and masks */
00351 #define TI_SYNCDELAY_MASK              0x0000007F
00352 
00353 /* 0x80 syncWidth bits and masks */
00354 #define TI_SYNCWIDTH_MASK              0x7F
00355 #define TI_SYNCWIDTH_LONGWIDTH_ENABLE  (1<<7)
00356 
00357 /* 0x84 triggerCommand bits and masks */
00358 #define TI_TRIGGERCOMMAND_VALUE_MASK     0x000000FF
00359 #define TI_TRIGGERCOMMAND_CODE_MASK      0x00000F00
00360 #define TI_TRIGGERCOMMAND_TRIG1          0x00000100
00361 #define TI_TRIGGERCOMMAND_TRIG2          0x00000200
00362 #define TI_TRIGGERCOMMAND_SYNC_EVENT     0x00000300
00363 #define TI_TRIGGERCOMMAND_SET_BLOCKLEVEL 0x00000800
00364 
00365 /* 0x88 randomPulser bits and masks */
00366 #define TI_RANDOMPULSER_TRIG1_RATE_MASK 0x0000000F
00367 #define TI_RANDOMPULSER_TRIG1_ENABLE    (1<<7)
00368 #define TI_RANDOMPULSER_TRIG2_RATE_MASK 0x00000F00
00369 #define TI_RANDOMPULSER_TRIG2_ENABLE    (1<<15)
00370 
00371 /* 0x8C fixedPulser1 bits and masks */
00372 #define TI_FIXEDPULSER1_NTRIGGERS_MASK 0x0000FFFF
00373 #define TI_FIXEDPULSER1_PERIOD_MASK    0x7FFF0000
00374 #define TI_FIXEDPULSER1_PERIOD_RANGE   (1<<31)
00375 
00376 /* 0x90 fixedPulser2 bits and masks */
00377 #define TI_FIXEDPULSER2_NTRIGGERS_MASK 0x0000FFFF
00378 #define TI_FIXEDPULSER2_PERIOD_MASK    0x7FFF0000
00379 #define TI_FIXEDPULSER2_PERIOD_RANGE   (1<<31)
00380 
00381 /* 0x94 nblocks bits and masks */
00382 #define TI_NBLOCKS_COUNT_MASK           0x00FFFFFF
00383 #define TI_NBLOCKS_EVENTS_IN_BLOCK_MASK 0xFF000000
00384 
00385 /* 0x98 syncHistory bits and masks */
00386 #define TI_SYNCHISTORY_HFBR1_CODE_MASK     0x0000000F
00387 #define TI_SYNCHISTORY_HFBR1_CODE_VALID    (1<<4)
00388 #define TI_SYNCHISTORY_HFBR5_CODE_MASK     0x000001E0
00389 #define TI_SYNCHISTORY_HFBR5_CODE_VALID    (1<<9)
00390 #define TI_SYNCHISTORY_LOOPBACK_CODE_MASK  0x00003C00
00391 #define TI_SYNCHISTORY_LOOPBACK_CODE_VALID (1<<14)
00392 #define TI_SYNCHISTORY_TIMESTAMP_OVERFLOW  (1<<15)
00393 #define TI_SYNCHISTORY_TIMESTAMP_MASK      0xFFFF0000
00394 
00395 /* 0x9C runningMode settings */
00396 #define TI_RUNNINGMODE_ENABLE          0x71
00397 #define TI_RUNNINGMODE_DISABLE         0x0
00398 
00399 /* 0xA0 fiberLatencyMeasurement bits and masks */
00400 #define TI_FIBERLATENCYMEASUREMENT_CARRYCHAIN_MASK 0x0000FFFF
00401 #define TI_FIBERLATENCYMEASUREMENT_IODELAY_MASK    0x007F0000
00402 #define TI_FIBERLATENCYMEASUREMENT_DATA_MASK       0xFF800000
00403 
00404 /* 0xA4 fiberAlignment bits and masks */
00405 #define TI_FIBERALIGNMENT_HFBR1_IODELAY_MASK   0x000000FF
00406 #define TI_FIBERALIGNMENT_HFBR1_SYNCDELAY_MASK 0x0000FF00
00407 #define TI_FIBERALIGNMENT_HFBR5_IODELAY_MASK   0x00FF0000
00408 #define TI_FIBERALIGNMENT_HFBR5_SYNCDELAY_MASK 0xFF000000
00409 
00410 /* 0xC0 blockStatus bits and masks */
00411 #define TI_BLOCKSTATUS_NBLOCKS_READY0    0x000000FF
00412 #define TI_BLOCKSTATUS_NBLOCKS_NEEDACK0  0x0000FF00
00413 #define TI_BLOCKSTATUS_NBLOCKS_READY1    0x00FF0000
00414 #define TI_BLOCKSTATUS_NBLOCKS_NEEDACK1  0xFF000000
00415 
00416 /* 0xD0 adr24 bits and masks */
00417 #define TI_ADR24_ADDRESS_MASK         0x0000001F
00418 #define TI_ADR24_HARDWARE_SET_MASK    0x000003E0
00419 #define TI_ADR24_TM_NBLOCKS_READY1    0x00FF0000
00420 #define TI_ADR24_TM_NBLOCKS_NEEDACK1  0xFF000000
00421 
00422 /* 0xD4 syncEventCtrl bits and masks */
00423 #define TI_SYNCEVENTCTRL_NBLOCKS_MASK 0x0000FFFF
00424 #define TI_SYNCEVENTCTRL_ENABLE       0x005A0000
00425 
00426 /* 0xD8 eventNumber_hi bits and masks */
00427 #define TI_EVENTNUMBER_HI_MASK        0xFFFF0000
00428 
00429 /* 0x100 reset bits and masks */
00430 #define TI_RESET_I2C                  (1<<1)
00431 #define TI_RESET_JTAG                 (1<<2)
00432 #define TI_RESET_SFM                  (1<<3)
00433 #define TI_RESET_SOFT                 (1<<4)
00434 #define TI_RESET_SYNC_HISTORY         (1<<6)
00435 #define TI_RESET_BUSYACK              (1<<7)
00436 #define TI_RESET_CLK250               (1<<8)
00437 #define TI_RESET_CLK200               (1<<8)
00438 #define TI_RESET_CLK125               (1<<9)
00439 #define TI_RESET_MGT                  (1<<10)
00440 #define TI_RESET_AUTOALIGN_HFBR1_SYNC (1<<11)
00441 #define TI_RESET_AUTOALIGN_HFBR5_SYNC (1<<12)
00442 #define TI_RESET_RAM_WRITE            (1<<12)
00443 #define TI_RESET_FIBER_AUTO_ALIGN     (1<<13)
00444 #define TI_RESET_IODELAY              (1<<14)
00445 #define TI_RESET_MEASURE_LATENCY      (1<<15)
00446 #define TI_RESET_TAKE_TOKEN           (1<<16)
00447 #define TI_RESET_BLOCK_READOUT        (1<<17)
00448 #define TI_RESET_FORCE_SYNCEVENT      (1<<20)
00449 #define TI_RESET_SYNCRESET_REQUEST    (1<<23)
00450 #define TI_RESET_SCALERS_LATCH        (1<<24)
00451 #define TI_RESET_SCALERS_RESET        (1<<25)
00452 #define TI_RESET_FILL_TO_END_BLOCK    (1<<31)
00453 
00454 /* 0x1D0-0x1F0 TI ID bits and masks */
00455 #define TI_ID_TRIGSRC_ENABLE_MASK     0x000000FF
00456 #define TI_ID_CRATEID_MASK            0x0000FF00
00457 #define TI_ID_BLOCKLEVEL_MASK         0x00FF0000
00458 
00459 /* Trigger Sources, used by tiSetTriggerSource  */
00460 #define TI_TRIGGER_P0        0
00461 #define TI_TRIGGER_HFBR1     1
00462 #define TI_TRIGGER_FPTRG     2
00463 #define TI_TRIGGER_TSINPUTS  3
00464 #define TI_TRIGGER_TSREV2    4
00465 #define TI_TRIGGER_RANDOM    5
00466 #define TI_TRIGGER_PULSER    5
00467 #define TI_TRIGGER_PART_1    6
00468 #define TI_TRIGGER_PART_2    7
00469 #define TI_TRIGGER_PART_3    8
00470 #define TI_TRIGGER_PART_4    9
00471 #define TI_TRIGGER_HFBR5    10
00472 
00473 /* Define default Interrupt vector and level */
00474 #define TI_INT_VEC      0xec
00475 /* #define TI_INT_VEC      0xc8 */
00476 #define TI_INT_LEVEL    5
00477 
00478 /* i2c data masks - 16bit data default */
00479 #define TI_I2C_DATA_MASK             0x0000ffff
00480 #define TI_I2C_8BIT_DATA_MASK        0x000000ff
00481 
00482 /* Data buffer bits and masks */
00483 #define TI_DATA_TYPE_DEFINE_MASK           0x80000000
00484 #define TI_WORD_TYPE_MASK                  0x78000000
00485 #define TI_FILLER_WORD_TYPE                0x78000000
00486 #define TI_BLOCK_HEADER_WORD_TYPE          0x00000000
00487 #define TI_BLOCK_TRAILER_WORD_TYPE         0x08000000
00488 #define TI_EMPTY_FIFO                      0xF0BAD0F0
00489 #define TI_BLOCK_HEADER_CRATEID_MASK       0xFF000000
00490 #define TI_BLOCK_HEADER_SLOTS_MASK         0x001F0000
00491 #define TI_BLOCK_TRAILER_CRATEID_MASK      0x00FF0000
00492 #define TI_BLOCK_TRAILER_SLOTS_MASK        0x1F000000
00493 #define TI_DATA_BLKNUM_MASK                0x0000FF00
00494 #define TI_DATA_BLKLEVEL_MASK              0x000000FF
00495 
00496 /* tiInit initialization flag bits */
00497 #define TI_INIT_NO_INIT                 (1<<0)
00498 #define TI_INIT_SLAVE_FIBER_5           (1<<1)
00499 #define TI_INIT_SKIP_FIRMWARE_CHECK     (1<<2)
00500 
00501 /* Some pre-initialization routine prototypes */
00502 int  tiSetFiberLatencyOffset_preInit(int flo);
00503 int  tiSetCrateID_prIinit(int cid);
00504 
00505 /* Function prototypes */
00506 int  tiInit(unsigned int tAddr, unsigned int mode, int force);
00507 unsigned int tiFind();
00508 int  tiCheckAddresses();
00509 void tiStatus(int pflag);
00510 int  tiSetSlavePort(int port);
00511 int  tiGetSlavePort();
00512 void tiSlaveStatus(int pflag);
00513 int  tiGetFirmwareVersion();
00514 int  tiReload();
00515 unsigned int tiGetSerialNumber(char **rSN);
00516 int  tiClockResync();
00517 int  tiReset();
00518 int  tiSetCrateID(unsigned int crateID);
00519 int  tiGetCrateID(int port);
00520 int  tiGetPortTrigSrcEnabled(int port);
00521 int  tiGetSlaveBlocklevel(int port);
00522 int  tiSetBlockLevel(int blockLevel);
00523 int  tiBroadcastNextBlockLevel(int blockLevel);
00524 int  tiGetNextBlockLevel();
00525 int  tiGetCurrentBlockLevel();
00526 int  tiSetTriggerSource(int trig);
00527 int  tiSetTriggerSourceMask(int trigmask);
00528 int  tiEnableTriggerSource();
00529 int  tiDisableTriggerSource(int fflag);
00530 int  tiSetSyncSource(unsigned int sync);
00531 int  tiSetEventFormat(int format);
00532 int  tiSoftTrig(int trigger, unsigned int nevents, unsigned int period_inc, int range);
00533 int  tiSetRandomTrigger(int trigger, int setting);
00534 int  tiDisableRandomTrigger();
00535 int  tiReadBlock(volatile unsigned int *data, int nwrds, int rflag);
00536 int  tiReadTriggerBlock(volatile unsigned int *data);
00537 int  tiEnableFiber(unsigned int fiber);
00538 int  tiDisableFiber(unsigned int fiber);
00539 int  tiSetBusySource(unsigned int sourcemask, int rFlag);
00540 void tiEnableBusError();
00541 void tiDisableBusError();
00542 int  tiPayloadPort2VMESlot(int payloadport);
00543 unsigned int  tiPayloadPortMask2VMESlotMask(unsigned int ppmask);
00544 int  tiVMESlot2PayloadPort(int vmeslot);
00545 unsigned int  tiVMESlotMask2PayloadPortMask(unsigned int vmemask);
00546 int  tiSetPrescale(int prescale);
00547 int  tiGetPrescale();
00548 int  tiSetTriggerPulse(int trigger, int delay, int width);
00549 void tiSetSyncDelayWidth(unsigned int delay, unsigned int width, int widthstep);
00550 void tiTrigLinkReset();
00551 void tiSyncReset(int bflag);
00552 void tiSyncResetResync();
00553 void tiClockReset();
00554 int  tiSetAdr32(unsigned int a32base);
00555 int  tiDisableA32();
00556 int  tiResetEventCounter();
00557 unsigned long long int tiGetEventCounter();
00558 int  tiSetBlockLimit(unsigned int limit);
00559 unsigned int  tiGetBlockLimit();
00560 unsigned int  tiBReady();
00561 int  tiGetSyncEventFlag();
00562 int  tiGetSyncEventReceived();
00563 int  tiEnableVXSSignals();
00564 int  tiDisableVXSSignals();
00565 int  tiSetBlockBufferLevel(unsigned int level);
00566 int  tiEnableTSInput(unsigned int inpMask);
00567 int  tiDisableTSInput(unsigned int inpMask);
00568 int  tiSetOutputPort(unsigned int set1, unsigned int set2, unsigned int set3, unsigned int set4);
00569 int  tiSetClockSource(unsigned int source);
00570 int  tiGetClockSource();
00571 void  tiSetFiberDelay(unsigned int delay, unsigned int offset);
00572 int  tiAddSlave(unsigned int fiber);
00573 int  tiSetTriggerHoldoff(int rule, unsigned int value, int timestep);
00574 int  tiGetTriggerHoldoff(int rule);
00575 
00576 int  tiDisableDataReadout();
00577 int  tiEnableDataReadout();
00578 void tiResetBlockReadout();
00579 
00580 int  tiLoadTriggerTable(int mode);
00581 int  tiLatchTimers();
00582 unsigned int tiGetLiveTime();
00583 unsigned int tiGetBusyTime();
00584 int  tiLive(int sflag);
00585 unsigned int tiGetTSscaler(int input, int latch);
00586 unsigned int tiBlockStatus(int fiber, int pflag);
00587 
00588 int  tiGetSWBBusy(int pflag);
00589 int  tiSetTokenTestMode(int mode);
00590 int  tiSetTokenOutTest(int level);
00591 
00592 int  tiGetFiberLatencyMeasurement();
00593 int  tiSetUserSyncResetReceive(int enable);
00594 int  tiGetLastSyncCodes(int pflag);
00595 int  tiGetSyncHistoryBufferStatus(int pflag);
00596 void tiResetSyncHistory();
00597 void tiUserSyncReset(int enable);
00598 void tiPrintSyncHistory();
00599 int  tiSetSyncEventInterval(int blk_interval);
00600 int  tiGetSyncEventInterval();
00601 int  tiForceSyncEvent();
00602 int  tiSyncResetRequest();
00603 int  tiGetSyncResetRequest();
00604 void tiTriggerReadyReset();
00605 int  tiFillToEndBlock();
00606 int  tiResetMGT();
00607 unsigned int tiGetGTPBufferLength(int pflag);
00608 unsigned int tiGetSWAStatus(int reg);
00609 unsigned int tiGetSWBStatus(int reg);
00610 
00611 
00612 /* Library Interrupt/Polling routine prototypes */
00613 int  tiIntConnect(unsigned int vector, VOIDFUNCPTR routine, unsigned int arg);
00614 int  tiIntDisconnect();
00615 int  tiAckConnect(VOIDFUNCPTR routine, unsigned int arg);
00616 void tiIntAck();
00617 int  tiIntEnable(int iflag);
00618 void tiIntDisable();
00619 unsigned int  tiGetIntCount();
00620 
00621 /* Some token testing routines */
00622 int  tiSetTokenTestMode(int mode);
00623 int  tiSetTokenOutTest(int level);
00624 
00625 #endif /* TILIB_H */

Generated on 17 Jun 2014 for JLab Pipeline TI Library by  doxygen 1.4.7