/************************************************************************* * * 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) /* GEO slot 3 */ /* 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 */ #include "conf_utils.h" #include "conf_utils.c" #define BLOCKLEVEL 1 #define BUFFERLEVEL 1 extern unsigned int tsTriggerSource; int usePulser = 0; /* function prototype */ void rocTrigger(int arg); /**************************************** * DOWNLOAD ****************************************/ void rocDownload() { int rc = -1; int stat; memset(&ts_bd, 0, sizeof(ts_bd)); gethostname(roc_name,ROCLEN); /* Global config file */ strcpy(filename,rol->usrConfig); printf(BOLDMAGENTA " Global Config File Name %s \n" RESET ,filename); rc = read_conf_global(filename,roc_name); if(rc != 0){ printf(BOLDRED " FATAL: Fail to read global configuration file %d \n" RESET, rc); daLogMsg(" FATAL: Fail to read global configuration file"); return; } /* 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 *****************/ print_ts_conf(); if(ts_bd.ts_master_trig == 1) tsSetTriggerSource(TS_TRIGSRC_PULSER); else if (ts_bd.ts_master_trig == 2) tsSetTriggerSource(TS_TRIGSRC_EXT); else { printf(BOLDRED " Unknown trigger type %d \n", ts_bd.ts_master_trig); return(-2); // Return will be replaced by a function provided by Dave A. } /* Enable/Disable specific inputs */ if(ts_bd.ts_master_trig == 2 && ts_bd.ts_fp_inputs != 0) tsSetFPInput(ts_bd.ts_fp_inputs); else { printf(BOLDRED " WARNING: TS FP inputs are disabled %d \n" RESET, ts_bd.ts_fp_inputs); } tsSetGenInput(0x1); tsSetGTPInput(0x0); /* 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 /* Init SD Board. and add TD Slaves */ sdInit(); if(ts_bd.ts_td_slots != 0) // sdSetActiveVmeSlots( 1<