/************************************************************************* * * ts_list.c - Library of routines for readout and buffering of * events using a JLAB Pipeline Trigger Supervisor (TS) with * a Linux VME controller in CODA 3.0 * */ /* Event Buffer definitions */ #define MAX_EVENT_POOL 10 #define MAX_EVENT_LENGTH 1024*60 /* Size in Bytes */ /* Define Interrupt source and address */ #define TS_READOUT TS_READOUT_EXT_POLL /* Poll for available data, external triggers */ #define TS_ADDR (21<<19) /* TDs in slot 3 and slot 19 */ #define TD_SLOT_MASK 0x18 #define TD_SLOT_1ST 3 #define TD_SLOT_2ND 4 #define TD_SLOT_3RD 5 /* make useful TD library variables available*/ extern int tdID[21]; extern int nTD; extern unsigned int dscA32Base; #include "dmaBankTools.h" #include "tsprimary_list.c" /* source required for CODA */ #include "vmeDSClib.h" #define BLOCKLEVEL 1 #define BUFFERLEVEL 1 extern unsigned int tsTriggerSource; int EventCounter = 0; /* function prototype */ void rocTrigger(int arg); /**************************************** * DOWNLOAD ****************************************/ void rocDownload() { int stat,k; dscA32Base = 0x09000000; /* Setup Address and data modes for DMA transfers * * vmeDmaConfig(addrType, dataType, sstMode); * * addrType = 0 (A16) 1 (A24) 2 (A32) * dataType = 0 (D16) 1 (D32) 2 (BLK32) 3 (MBLK) 4 (2eVME) 5 (2eSST) * sstMode = 0 (SST160) 1 (SST267) 2 (SST320) */ vmeDmaConfig(2,5,1); /* Define BLock Level */ blockLevel = BLOCKLEVEL; /* tsInit(21,2,0);*/ /***************** * TS SETUP *****************/ tsSetTriggerSource(TS_TRIGSRC_EXT); /*tsSetFPInput(0x500); /* TRIGGER INPUT A1,A2 -> bit9,10*/ tsSetFPInput(0xFFFF); /* CDC trigger in B1, FDC trigger in A9 => 0x0101*/ /*tsSetGenInput(0x1);*/ /*tsSetGTPInput(0x0);*/ /* Load the default trigger table */ tsSetBlockLevel(BLOCKLEVEL); tsLoadTriggerTable(); /* * Trigger Holdoff rules (20 ticks = 100 ns) */ tsSetTriggerHoldoff(1,20,0); tsSetTriggerHoldoff(2,20,0); tsSetTriggerHoldoff(3,20,0); tsSetTriggerHoldoff(4,20,0); /* Set the sync delay width to 0x40*32 = 2.048us */ /* ARGS: * delay: the delay (latency) set in units of 4ns. * width: the width set in units of 4ns. * twidth: if this is non-zero, set width in units of 32ns. * */ tsSetSyncDelayWidth(0x30, 0x40, 1); /* * Set the Block Buffer Level * 0: Pipeline mode * 1: One Block per readout - "ROC LOCK" mode * 2-255: "Buffered" mode. */ tsSetBlockBufferLevel(BUFFERLEVEL); /* Setup TDs - two boards in slot 3,19*/ printf("--- INITIALIZE TDs ---\n"); tdInit(0,0,0,0); tdAddSlaveMask(TD_SLOT_1ST, 0x0f); tdAddSlaveMask(TD_SLOT_2ND, 0x20); tdGSetBlockBufferLevel(BUFFERLEVEL); tdGSetBlockLevel(BLOCKLEVEL); /* Init SD Board. and activate slots for TDs*/ sdInit(); sdSetActiveVmeSlots( (1<