/************************************************************************* * * 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 20 #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 (20<<19) /* GEO slot 20 for ELMA backplane*/ /* TDs in slot 3 and slot 19 */ #define TD_SLOT_MASK 0x80008 #define TD_SLOT_1 3 #define TD_SLOT_2 19 /* make useful TD library variables available*/ extern int tdID[21]; extern int nTD; #include "dmaBankTools.h" #include "tsprimary_list.c" /* source required for CODA */ #define BLOCKLEVEL 2 #define BUFFERLEVEL 10 extern unsigned int tsTriggerSource; /* Set to Zero to define a Front Panel Trigger source */ int usePulser=0; /* function prototype */ void rocTrigger(int arg); /**************************************** * DOWNLOAD ****************************************/ void rocDownload() { /* 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; /***************** * TS SETUP *****************/ if(usePulser) tsSetTriggerSource(TS_TRIGSRC_PULSER); else tsSetTriggerSource(TS_TRIGSRC_EXT); /* Enable/Disable specific inputs */ tsSetFPInput(0x3); tsSetGTPInput(0x0); /* Set Time stamp format - 48 bits */ tsSetEventFormat(3); /* Load the default trigger table */ 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 */ 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); /* Set a Maximum Block count before trigger autmatically disables (0 disables block limit)*/ tsSetBlockLimit(0); /* Override the busy source set in tsInit (only if TS crate running alone) */ #define USETD #ifdef USETD /* Setup TDs - */ tdInit(0,0,0,0); tdGSetBlockBufferLevel(BUFFERLEVEL); /* No Need to add TD slaves here */ /*tdAddSlave(TD_SLOT_1,4); */ /* TI Slave - Slot 4 only */ /* Init SD Board. and add TD Slaves */ sdInit(); sdSetActiveVmeSlots(tdSlotMask()); sdStatus(0); /* Reset Active ROC Masks on all TD modules */ tsTriggerReadyReset(); #else tsSetBusySource(TS_BUSY_LOOPBACK,1); tsAddSlave(1); #endif /* tsSetPrescale(0); */ printf("rocDownload: User Download Executed\n"); } /**************************************** * PRESTART ****************************************/ void rocPrestart() { unsigned short iflag; int stat; int islot; /* Set number of events per block */ tsSetBlockLevel(blockLevel); printf("rocPrestart: Block Level to be broadcasted: %d\n",blockLevel); /* On TD's too */ tdGSetBlockLevel(blockLevel); /* Reset Active ROC Masks on all TD modules */ tsTriggerReadyReset(); /* Print Status info */ tdGStatus(0); tsStatus(0); printf("rocPrestart: User Prestart Executed\n"); } /**************************************** * GO ****************************************/ void rocGo() { int ii, islot, tmask; /* Enable TD module Ports that have indicated they are active */ for (ii=0;ii