Ejemplo n.º 1
0
static void __download()
{
  int status;

  daLogMsg("INFO","Readout list compiled %s", DAYTIME);
#ifdef POLLING___
  rol->poll = 1;
#endif
  *(rol->async_roc) = 0; /* Normal ROC */

  bigendian_out=1;
 
  /* Open the default VME windows */
  vmeOpenDefaultWindows();

  /* Initialize memory partition library */
  dmaPartInit();

  /* Setup Buffer memory to store events */
  dmaPFreeAll();
  vmeIN  = dmaPCreate("vmeIN",MAX_EVENT_LENGTH,MAX_EVENT_POOL,0);
  vmeOUT = dmaPCreate("vmeOUT",0,0,0);

  /* Reinitialize the Buffer memory */
  dmaPReInitAll();
  dmaPStatsAll();

  /* Initialize VME Interrupt interface - use defaults */
  tidInit(TID_ADDR,TID_READOUT,0);

  /* Execute User defined download */
  rocDownload();
 
  daLogMsg("INFO","Download Executed");


} /*end download */     
Ejemplo n.º 2
0
int 
main(int argc, char *argv[]) {

    int stat;

    printf("\nJLAB TS Tests\n");
    printf("----------------------------\n");

    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",1024,500,0);
    vmeOUT = dmaPCreate("vmeOUT",0,0,0);
    
    dmaPStatsAll();

    dmaPReInitAll();

    tsReload();

/*     gefVmeSetDebugFlags(vmeHdl,0x0); */
    /* Set the TS structure pointer */
    tsPartInit(1,(21<<19),TS_READOUT_EXT_POLL,0);
    if(tsCheckAddresses()==ERROR)
      goto CLOSE;

    tsPartLoadTriggerTable();
    tsPartSetBlockBufferLevel(10);    

    tsSetBlockLevel(1);

    stat = tsPartIntConnect(mytsISR, 0);
    if (stat != OK) 
      {
	printf("ERROR: tsIntConnect failed \n");
	goto CLOSE;
      } 
    else 
      {
	printf("INFO: Attached TS Interrupt\n");
      }

    tsSetTriggerSource(6); // Pulser = 5, GTP/Ext/FP = 6

    tsSetFPInput(0);
    tsSetGenInput(0xffff);
    tsSetGTPInput(0x0);

    tsPartSetFPInput(1,2,3);
    tsPartSetExtInput(1,2,3,4,5);
    tsPartSetGTPInput(1,2,3,4,5);

/*     tsSetBusySource(TS_BUSY_LOOPBACK,1); */
    tsSetBusySource(0,1);

/*     tsSetBlockBufferLevel(1); */

    tsClockReset();
    taskDelay(1);
    tsTrigLinkReset();
    taskDelay(1);
    tsSyncReset();

    taskDelay(1);
    
    tsStatus();

    printf("Hit enter to start triggers\n");
    getchar();

    tsPartIntEnable(0);
    tsStatus();

/* #define SOFTTRIG */
#ifdef SOFTTRIG
    tsSetRandomTrigger(1,0x7);
    taskDelay(10);
    tsSoftTrig(1,0x1,0x700,0);
#endif

    printf("Hit any key to Disable TID and exit.\n");
    getchar();
    tsStatus();
    tsPrintScalers(1);
    tsPrintScalers(2);
    tsPrintScalers(3);

#ifdef SOFTTRIG
    /* No more soft triggers */
/*     tidSoftTrig(0x0,0x8888,0); */
    tsSoftTrig(1,0,0x700,0);
    tsDisableRandomTrigger();
#endif

    tsPartIntDisable();

    tsPartIntDisconnect();


 CLOSE:

    vmeCloseDefaultWindows();

    exit(0);
}
Ejemplo n.º 3
0
int 
main(int argc, char *argv[]) 
{

  int status;
  unsigned int addr=0x18000000;
  
  vmeOpenDefaultWindows();
  
  status = vmeOpenSlaveA32(addr,0x00400000);
  if(status != OK)
    {
      printf("%s: ERROR: failed to open slave window (%d)\n",
	     __FUNCTION__,status);
      return ERROR;
    }
  dmaPUseSlaveWindow(1);

  /* INIT dmaPList */
  dmaPFreeAll();
  vmeIN  = dmaPCreate("vmeIN",BUFFER_SIZE,NBUFFER,0);
  vmeOUT = dmaPCreate("vmeOUT",0,0,0);

  dmaPStatsAll();
  
  dmaPReInitAll();

  GETEVENT(vmeIN,0);
/*   data = (unsigned int *)a32slave_window; */
  data = (unsigned int*)dma_dabufp;

  printf("a32slavewindow = 0x%08x\n",(unsigned int*)a32slave_window);
  printf("dma_dabufp     = 0x%08x\n",(unsigned int*)dma_dabufp);
  printf("data           = 0x%08x\n",(unsigned int*)data);

  printf("vmeDmaLocalToVmeAdrs(dma_dabufp)  = 0x%08x\n",
	 vmeDmaLocalToVmeAdrs((unsigned int)dma_dabufp));
  printf("vmeDmaLocalToPhysAdrs(dma_dabufp) = 0x%08x\n",
	 vmeDmaLocalToPhysAdrs((unsigned int)dma_dabufp));

  printf("Press <Enter> to look at data\n");
  getchar();
  int idata=0, iter=0;
  int inputchar=10;
  while(1 && (inputchar==10))
    {
      for(idata=0+4*8*iter; idata<4*8*(iter+1); idata++)
	{
	if((idata%4)==0) printf("\n");
	printf("%5d: 0x%08x ",idata,(unsigned int)data[idata]);
	}
      iter++;
      printf("\n\n");

      printf("<Enter> for next trigger, 1 and <Enter> to End\n");
      inputchar = getchar();
      printf("inputchar = %d\n",inputchar);
      if(inputchar==49) break; /* 1 */
      if(inputchar==50) {
	iter=0;
/* 	if(iter<0) iter=0; */
	inputchar=10;
      }
    }
  


  status = vmeCloseA32Slave();
  
  vmeCloseDefaultWindows();
  
  exit(0);
}
Ejemplo n.º 4
0
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);
}
Ejemplo n.º 5
0
int 
main(int argc, char *argv[]) 
{

  int stat;

  printf("\nJLAB fADC250-V2 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",MAX_EVENT_LENGTH,MAX_EVENT_POOL,0);
  vmeOUT = dmaPCreate("vmeOUT",0,0,0);
    
  dmaPStatsAll();

  dmaPReInitAll();

  /*     gefVmeSetDebugFlags(vmeHdl,0x0); */

  vmeSetQuietFlag(1); /* skip the errors associated with BUS Errors */

  /* Setup FlexIO */
  flexioInit(0xee0, FLEXIO_MODE_POLL);

  flexioWriteCsr(0, 0x8000); // reset
  flexioWriteCsr(0, 0x1);    // output in vme pulse mode

  /* Setup output data pattern */
  flexioWriteData(0, 0xeded);
/*   flexioWriteData(0, 0xeded); */

  /* Setup fADC250 */
  NFADC = 16+2;   /* 16 slots + 2 (for the switch slots) */
  fadcA32Base=0x09000000;

  /* Setup the iFlag.. flags for FADC initialization */
  int iFlag=0;
  /* Sync Source */
  iFlag |= (0<<0);    /* VME */
  /* Trigger Source */
  iFlag |= (4<<1);    /* Internal */
  /* Clock Source */
  iFlag |= FA_INIT_INT_CLKSRC;    /* Self */

  iFlag |= FA_INIT_SKIP_FIRMWARE_CHECK;

/*   faInit((unsigned int)(3<<19),(1<<19),NFADC,iFlag); */
  faInit(0xed0000,0,1,iFlag);
  NFADC=nfadc;        /* Redefine our NFADC with what was found from the driver */
  vmeSetQuietFlag(0); /* Turn the error statements back on */
  faItrigDisable(0, 1);
  
  MAXFADCWORDS = NFADC * BLOCKLEVEL * (1+2+FADC_WINDOW_WIDTH*16) + 3;
  
  printf("**************************************************\n");
  printf("* Calculated MAX FADC words per block = %d\n",MAXFADCWORDS);
  printf("**************************************************\n");

  
  if(NFADC>1)
    faEnableMultiBlock(1);

  if(NFADC==0)
    goto CLOSE;

  /* Additional Configuration for each module */
  fadcSlotMask=0;
  int islot=0;
  for(islot=0;islot<NFADC;islot++) 
    {
      FA_SLOT = fadcID[islot];      /* Grab the current module's slot number */
      fadcSlotMask |= (1<<FA_SLOT); /* Add it to the mask */

      /*       faDataInsertAdcParameters(FA_SLOT,1); */
      /*       faDataSuppressTriggerTime(FA_SLOT,2); */
      /* Set the internal DAC level */
      faSetDAC(FA_SLOT,FADC_DAC_LEVEL,0);
      /* Set the threshold for data readout */
      faSetThreshold(FA_SLOT,FADC_THRESHOLD,0);
	
      /*  Setup option 1 processing - RAW Window Data     <-- */
      /*        option 2            - RAW Pulse Data */
      /*        option 3            - Integral Pulse Data */
      /*  Setup 200 nsec latency (PL  = 50)  */
      /*  Setup  80 nsec Window  (PTW = 20) */
      /*  Setup Pulse widths of 36ns (NSB(3)+NSA(6) = 9)  */
      /*  Setup up to 1 pulse processed */
      /*  Setup for both ADC banks(0 - all channels 0-15) */
      /* Integral Pulse Data */
      faSetProcMode(FA_SLOT,faMode,FADC_WINDOW_LAT,FADC_WINDOW_WIDTH,3,6,3,0);
	
      /* Bus errors to terminate block transfers (preferred) */
      faEnableBusError(FA_SLOT);
      /* Set the Block level */
      faSetBlockLevel(FA_SLOT,BLOCKLEVEL);

      /* Set the individual channel pedestals for the data that is sent
       * to the CTP
       */
      int ichan;
      for(ichan=0; ichan<16; ichan++)
	{
	  faSetChannelPedestal(FA_SLOT,ichan,0);
	}

      faSetTriggerPathThreshold(FA_SLOT, 500);
    }

  /************************************************************
   *
   *  Setup Internal Triggering
   *   
   *   Four Modes of Operation (tmode)
   *     0) Table Mode
   *     1) Coincidence Mode
   *     2) Window Mode
   *     3) INVALID
   *     4) Sum Mode
   *
   *   wMask     = Mask of 16 channels to be enabled for Window Mode
   *   wWidth    = Width of trigger window before latching (in clocks)
   *   cMask     = Mask of 16 channels to be enabled for Coincidence Mode
   *   sumThresh = 10-12 bit threshold for Sum trigger to be latched 
   *   tTable    = pointer to trigger table (65536 values) to be loaded
   */
  int tmode=0;
  unsigned int wWidth=5, wMask=0x0, cMask=0xeded, sumThresh=0, tTable[65536];

  memset((char *)tTable,0,65536*sizeof(unsigned int));

  tTable[0xeded] = 1;

  faItrigSetMode(FA_SLOT, tmode, wWidth, wMask,
		 cMask, sumThresh, (uint32_t *)tTable);
    
  faItrigSetHBwidth(0, 2, 0xffff);
  faGStatus(0);

  /* FADC Perform some resets, status */
  for(islot=0;islot<NFADC;islot++) 
    {
      FA_SLOT = fadcID[islot];
      /*       faSetClockSource(FA_SLOT,2); */
      faClear(FA_SLOT);
      faResetToken(FA_SLOT);
      faResetTriggerCount(FA_SLOT);
    }

  faGStatus(0);
  faItrigStatus(0,0);
  faItrigPrintHBinfo(0);

  /*  Enable FADC */
  for(islot=0;islot<NFADC;islot++) 
    {
      FA_SLOT = fadcID[islot];
      faEnableSyncSrc(FA_SLOT);
    }

  faSync(0);

  taskDelay(1);

/*   faGStatus(0); */

  int pti_status;
  void *res;

  pti_status = 
    pthread_create(&fapollthread,
		   NULL,
		   (void*(*)(void *)) faPoll,
		   (void *)NULL);
  if(pti_status!=0) 
    {						
      printf("%s: ERROR: FA Polling Thread could not be started.\n",
	     __FUNCTION__);	
      printf("\t pthread_create returned: %d\n",pti_status);
    }

  printf("Hit enter to start triggers\n");
  getchar();

  faGEnable(1,0);
  faItrigEnable(0, 1);
  faItrigStatus(0,0);
  faStopped=0;
  flexioWriteCsr(0, 0x101); // send first pulse


  printf("Hit any key to Disable TID and exit.\n");
  getchar();

  vmeBusLock();
  /* FADC Disable */
  faGDisable(1);

  faStopped=1;
  vmeBusUnlock();
  if(fapollthread) 
    {
      if(pthread_cancel(fapollthread)<0) 
	perror("pthread_cancel");
      if(pthread_join(fapollthread,&res)<0)
	perror("pthread_join");
      if (res == PTHREAD_CANCELED)
	printf("%s: Polling thread canceled\n",__FUNCTION__);
      else
	printf("%s: ERROR: Polling thread NOT canceled\n",__FUNCTION__);
    }




  faGStatus(0);
  faPrintAuxScal(0);

 CLOSE:

  dmaPFreeAll();
  vmeCloseDefaultWindows();

  exit(0);
}