/* * File: * f1tdcLibTest.c * * Description: * Test JLab F1 TDC with GEFANUC Linux Driver * and f1tdc library * * */ #include #include #include #include "jvme.h" #include "tiLib.h" #include "f1tdcLib.h" #include "sdLib.h" /* #include "f1tm.h" */ #include "remexLib.h" DMA_MEM_ID vmeIN,vmeOUT; extern DMANODE *the_event; extern unsigned int *dma_dabufp; extern int tiA32Base; #define BLOCKLEVEL 1 #define DO_READOUT extern int f1tdcA32Base; extern int f1tdcA32Offset; extern int nf1tdc; /* access tirLib global variables */ int F1_SLOT; #define F1TDC_ADDR (3<<19) #define F1TM_ADDR 0xe100 /* Interrupt Service routine */ void mytiISR(int arg); int main(int argc, char *argv[]) { int stat; extern int f1ID[20]; int iflag; /* int status; */ int itdc; printf("\nJLAB f1tdc Lib Tests\n"); printf("----------------------------\n"); if(vmeOpenDefaultWindows() != OK) { goto CLOSE; } /* Set up remex */ remexSetCmsgServer("dafarm28"); remexInit("dafarm42",0); /* 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); /* INIT dmaPList */ dmaPFreeAll(); vmeIN = dmaPCreate("vmeIN",20244,100,0); vmeOUT = dmaPCreate("vmeOUT",0,0,0); dmaPStatsAll(); dmaPReInitAll(); ////////////////////////////// // TI SETUP ////////////////////////////// tiA32Base=0x08000000; tiInit(21<<19,TI_READOUT_EXT_POLL,TI_INIT_SKIP_FIRMWARE_CHECK); tiCheckAddresses(); char mySN[20]; printf("0x%08x\n",tiGetSerialNumber((char **)&mySN)); printf("mySN = %s\n",mySN); tiLoadTriggerTable(0); tiSetTriggerHoldoff(1,4,0); tiSetTriggerHoldoff(2,4,0); tiSetPrescale(0); tiSetBlockLevel(BLOCKLEVEL); stat = tiIntConnect(TI_INT_VEC, mytiISR, 0); if (stat != OK) { printf("ERROR: tiIntConnect failed \n"); goto CLOSE; } else { printf("INFO: Attached TI Interrupt\n"); } /* tiSetTriggerSource(TI_TRIGGER_TSINPUTS); */ tiSetTriggerSource(TI_TRIGGER_PULSER); /* tiEnableTSInput(TI_TSINPUT_1); */ /* tiSetBusySource(TI_BUSY_LOOPBACK,1); */ tiSetBlockBufferLevel(1); tiSetFiberDelay(1,2); tiSetSyncDelayWidth(1,0x3f,1); sdInit(1); sdGetSerialNumber(NULL); /* f1tmInit(F1TM_ADDR,0); */ /* f1tmSetPulserPeriod(0xffff); */ /* f1tmSetTriggerDelay(50); */ /* f1tmSetInputMode(F1TM_HITSRC_INT, F1TM_TRIGSRC_INT); */ /* f1tmEnablePulser(); */ /* f1tmStatus(); */ ////////////////////////////// // F1 SETUP ////////////////////////////// /* f1ConfigReadFile("../fromEd/cfg_v2_0hs_3125.dat"); */ /* f1ConfigReadFile("../fromEd/cfg_v3_0ns_3125.dat"); */ iflag = 0; #define VXS #ifdef VXS iflag |= F1_SRSRC_VXS; // SyncReset from VXS iflag |= F1_TRIGSRC_VXS; // Trigger from VXS iflag |= F1_CLKSRC_VXS; // Clock from VXS #else iflag |= F1_SRSRC_SOFT; // SyncReset from VXS iflag |= F1_TRIGSRC_SOFT; // Trigger from VXS iflag |= F1_CLKSRC_INT; // Clock from VXS #endif iflag |= F1_IFLAG_NOFWCHECK; printf("iflag = 0x%x\n",iflag); f1tdcA32Base = 0x09000000; /* f1tdcA32Offset = 0x08000000; */ f1Init(F1TDC_ADDR,(1<<19),18,iflag); F1_SLOT = f1ID[0]; if(nf1tdc>1) f1EnableMultiBlock(1); sdSetActiveVmeSlots(f1ScanMask()); /* Use the fadcSlotMask to configure the SD */ sdStatus(1); char sn[10]; f1GetSerialNumber(F1_SLOT,(char **)&sn); printf("sn = >%s<\n",sn); int ii; for(ii=0; iilength; unsigned int data=0; for(idata=0;idatadata[idata])); */ data = LSWAP(outEvent->data[idata]); f1DataDecode(0,data); } printf("\n\n"); } dmaPFreeItem(outEvent); if(tiIntCount%printout==0) printf("intCount = %d\n",tiIntCount ); /* sleep(1); */ }