static void __download() { int i1, i2, i3; char *ch, tmp[64]; #ifdef POLLING_MODE rol->poll = 1; #else rol->poll = 0; #endif printf("\n>>>>>>>>>>>>>>> ROCID=%d, CLASSID=%d <<<<<<<<<<<<<<<<\n",rol->pid,rol->classid); printf("CONFFILE >%s<\n\n",rol->confFile); printf("LAST COMPILED: %s %s\n", __DATE__, __TIME__); printf("USRSTRING >%s<\n\n",rol->usrString); /* if slave, get fiber port number from user string */ #ifdef TI_SLAVE ti_slave_fiber_port = 1; /* default */ ch = strstr(rol->usrString,"fp="); if(ch != NULL) { strcpy(tmp,ch+strlen("fp=")); printf("tmp >>>>>>>>>>>>>>>>>>>>>%s<<<<<<<<<<<<<<<<<<<<<\n",tmp); ti_slave_fiber_port = atoi(tmp); printf("ti_slave_fiber_port =%d\n",ti_slave_fiber_port); tiSetFiberIn_preInit(ti_slave_fiber_port); } #endif /* printf("rol1: downloading DDL table ...\n"); clonbanks_(); printf("rol1: ... done.\n"); */ /**/ CTRIGINIT; /* initialize OS windows and TI board */ #ifdef VXWORKS CDOINIT(TIPRIMARY); #else CDOINIT(TIPRIMARY,TIR_SOURCE); #endif /************/ /* init daq */ daqInit(); DAQ_READ_CONF_FILE; /*************************************/ /* redefine TI settings if neseccary */ #ifndef TI_SLAVE /* TS 1-6 create physics trigger, no sync event pin, no trigger 2 */ vmeBusLock(); tiLoadTriggerTable(3); tiSetTriggerWindow(14); // (7+1)*4ns trigger it coincidence time to form trigger type /* tiSetTriggerHoldoff(1,20,1); tiSetTriggerHoldoff(2,0,1); tiSetTriggerHoldoff(3,0,1); tiSetTriggerHoldoff(4,0,1); */ // tiAddSlave(7); // tiAddSlave(8); vmeBusUnlock(); #endif /*********************************************************/ /*********************************************************/ #ifdef USE_PRAD /* (width + 3)*4 ns, 300 ns width */ vmeBusLock(); tiSetPromptTriggerWidth(60); int ii; for(ii = 1; ii <= 6; ++ii) tiSetTSInputDelay(ii, 0); vmeBusUnlock(); #endif /* set wide pulse */ vmeBusLock(); /*sergey: WAS tiSetSyncDelayWidth(1,127,1);*/ /*worked for bit pattern latch tiSetSyncDelayWidth(0x54,127,1);*/ vmeBusUnlock(); usrVmeDmaSetConfig(2,5,1); /*A32,2eSST,267MB/s*/ /*usrVmeDmaSetConfig(2,5,0);*/ /*A32,2eSST,160MB/s*/ /*usrVmeDmaSetConfig(2,3,0);*/ /*A32,MBLT*/ /* if(rol->pid==18) { usrVmeDmaSetConfig(2,3,0); } */ /* usrVmeDmaSetChannel(1); printf("===== Use DMA Channel %d\n\n\n",usrVmeDmaGetChannel()); */ tdcbuf = (unsigned int *)i2_from_rol1; /******************/ /* USER code here */ #ifdef USE_PRAD vmeBusLock(); dsc2Init(0x400000,0x80000,5,0/*1<<19*/); ndsc2 = dsc2GetNdsc(); printf("!!!!!!!!!!! ndsc2=%d\n",ndsc2); if(ndsc2>0) { DSC2_READ_CONF_FILE; ndsc2_daq = dsc2GetNdsc_daq(); printf("!!!!!!!!!!! ndsc2_daq=%d\n",ndsc2_daq); } printf("Set Gate Source... \n"); dsc2SetGateSource(9, 1, 1); //dsc2SetGateSource(9, 2, 3); /* dsc2Init(0x480000,0x80000,5,1<<19); int dsc_ch, dsc_sl; for(dsc_ch = 0; dsc_ch < 6; ++dsc_ch) dsc2SetThreshold(0, dsc_ch, 100, TDCTRG); for(dsc_sl = 1; dsc_sl < 5; ++dsc_sl) { dsc2SetDelay(dsc_sl, 0, 3); for(dsc_ch = 0; dsc_ch < 16; ++dsc_ch) dsc2SetThreshold(dsc_sl, dsc_ch, 10, TDCTRG); } dsc2SetChannelMask(0,0xffff,TDCTRG); dsc2SetChannelORMask(0,0xffff,TDCTRG); dsc2Status(0,0); */ vmeBusUnlock(); #ifdef USE_V767 /***************** * V767 SETUP *****************/ /*vmeBusLock();*/ v767Init(V767_ADDR1,V767_OFF,1,0); // turn off test mode v767WriteMicro(0, 0x0200); /* select stop trigger matching, substraction of trigger time, all channels on, autoload on, and save configuration */ // v767SetAcqMode(0,0); // v767SetDReadyMode(0,0); /* v767BusErrEnable(0); */ /* v767SetBLKEndMode(0, 1); */ /* v767AutoloadDisable(itdc); */ /* v767AddrRotary(itdc); */ // v767SetEdgeDetectionMode(0,1); /* v767OverlapTrigDisable(itdc); */ v767TriggerConfig(0,2000,1000,0); /* v767ChannelMask(itdc,channelmask); */ v767Status(0, 0, 0); // v767TriggerConfig(0,0,0,0); /* Print current trigger config */ printf("v767 8\n");fflush(stdout); /*vmeBusUnlock();*/ /* v767SaveConfig(itdc); */ #endif #ifdef USE_V1190 vmeBusLock(); tdc1190Init(V1190_ADDR1, V1190_OFF, 1, 0); TDC_READ_CONF_FILE; vmeBusUnlock(); #endif #endif /* USE_PRAD */ sprintf(rcname,"RC%02d",rol->pid); printf("rcname >%4.4s<\n",rcname); #ifdef SSIPC sprintf(ssname,"%s_%s",getenv("HOST"),rcname); printf("Smartsockets unique name >%s<\n",ssname); epics_msg_sender_init(getenv("EXPID"), ssname); /* SECOND ARG MUST BE UNIQUE !!! */ #endif logMsg("INFO: User Download Executed\n",1,2,3,4,5,6); }
int main(int argc, char *argv[]) { int stat; printf("\nJLAB vfTDC Tests\n"); printf("----------------------------\n"); /* remexSetCmsgServer("dafarm28"); */ /* remexInit(NULL,1); */ vmeOpenDefaultWindows(); /* 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",10244,500,0); vmeOUT = dmaPCreate("vmeOUT",0,0,0); dmaPStatsAll(); dmaPReInitAll(); /* gefVmeSetDebugFlags(vmeHdl,0x0); */ /* Set the TI structure pointer */ /* tiInit((2<<19),TI_READOUT_EXT_POLL,0); */ tiA32Base=0x08000000; if(tiInit(0,TI_READOUT_EXT_POLL,0)!=OK) goto CLOSE; tiCheckAddresses(); tiSetSyncEventInterval(10); tiSetEventFormat(3); char mySN[20]; printf("0x%08x\n",tiGetSerialNumber((char **)&mySN)); printf("mySN = %s\n",mySN); #ifndef DO_READOUT tiDisableDataReadout(); tiDisableA32(); #endif 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(0x1); /* tiSetFPInput(0x0); */ /* tiSetGenInput(0xffff); */ /* tiSetGTPInput(0x0); */ /* tiSetBusySource(TI_BUSY_LOOPBACK,1); */ tiSetBlockBufferLevel(1); tiSetFiberDelay(1,2); tiSetSyncDelayWidth(1,0x3f,1); tiSetBlockLimit(10); /*************************************************************/ /* VFTDC initialization */ /*************************************************************/ extern unsigned int vfTDCA32Base; vfTDCA32Base=0x09000000; vfTDCInit(14<<19, 1<<19, 1, VFTDC_INIT_VXS_SYNCRESET | VFTDC_INIT_VXS_TRIG | VFTDC_INIT_VXS_CLKSRC); vfTDCSetBlockLevel(0, BLOCKLEVEL); vfTDCSetWindowParamters(0, 1, 250); vfTDCStatus(0,0); printf("Hit enter to reset stuff\n"); getchar(); tiClockReset(); taskDelay(1); tiTrigLinkReset(); taskDelay(1); tiEnableVXSSignals(); int again=0; AGAIN: taskDelay(1); tiSyncReset(1); taskDelay(1); tiStatus(1); vfTDCStatus(0,0); printf("Hit enter to start triggers\n"); getchar(); tiIntEnable(0); tiStatus(1); #define SOFTTRIG #ifdef SOFTTRIG tiSetRandomTrigger(1,0x7); /* taskDelay(10); */ /* tiSoftTrig(1,0x1,0x700,0); */ #endif printf("Hit any key to Disable TID and exit.\n"); getchar(); tiStatus(1); #ifdef SOFTTRIG /* No more soft triggers */ /* tidSoftTrig(0x0,0x8888,0); */ tiSoftTrig(1,0,0x700,0); tiDisableRandomTrigger(); #endif tiIntDisable(); tiIntDisconnect(); vfTDCStatus(0,0); if(again==1) { again=0; goto AGAIN; } CLOSE: dmaPFreeAll(); vmeCloseDefaultWindows(); exit(0); }