/************************************************************************* * * 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 */ #define TD_SLOT_1ST 4 #define TD_SLOT_2ND 5 #define TD_SLOT_3RD 6 /* make useful TD library variables available*/ extern int tdID[21]; extern int nTD; extern unsigned int dscA32Base; #define BLOCKLEVEL 1 #define BUFFERLEVEL 1 /*int blockLevel = BLOCKLEVEL;*/ #include "dmaBankTools.h" #include "tsprimary_list.c" /* source required for CODA */ #include "vmeDSClib.h" extern unsigned int tsTriggerSource; int EventCounter = 0; /* function prototype */ /* void rocTrigger(int arg); */ /* do not define with 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); */ /* no need this is done in __download() defined in tsprimary_list.c*/ /***************** * TS SETUP *****************/ tsSetTriggerSource(TS_TRIGSRC_EXT); /*tsSetFPInput(0x500); /* TRIGGER INPUT A1,A2 -> bit9,10*/ tsSetFPInput(0x0c00); /* CDC trigger in A11, FDC trigger in A12 => 0x0c00*/ /*tsSetGenInput(0x1);*/ /* A9-A16 == 0xFF00 and B1-B9 == 0x00FF*/ /*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); /* 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, 0); /* * 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, 0x7f); /*tdAddSlaveMask(TD_SLOT_2ND, 0x7c); /*disable rocfdc2 and rocfdc3*/ tdAddSlaveMask(TD_SLOT_3RD, 0x7f); /*tdAddSlaveMask(TD_SLOT_3RD, 0x7d); /*disable rocfdc9*/ /*tdAddSlaveMask(TD_SLOT_3RD, 0x6f);/*disable rocfdc12*/ tdGSetBlockBufferLevel(BUFFERLEVEL); tdGSetBlockLevel(BLOCKLEVEL); /* Init SD Board. and activate slots for TDs*/ sdInit(); /*sdSetActiveVmeSlots( 0x38 );*/ sdSetActiveVmeSlots( (1<