Beispiel #1
0
void
rocTrigger(int arg)
{
  int ii, status, dma, count;
  int nwords;
  unsigned int datascan;

  tirIntOutput(2);

  *dma_dabufp++ = LSWAP(tirGetIntCount()); /* Insert Event Number */

  /* Check for valid data here */
  for(ii=0;ii<100;ii++) 
    {
      datascan = tdc1190Dready(0);
      if (datascan>0) 
	{
	  break;
	}
    }

  if(datascan>0) 
    {
      /* Get the TDC data from all modules... rflag=2 for Linked List DMA 
	 "64" is ignored in Linux */
      nwords = tdc1190ReadBlock(0,dma_dabufp,64,2);
    
      if(nwords < 0) 
	{
	  printf("ERROR: in transfer (event = %d), status = 0x%x\n", tirGetIntCount(),nwords);
	  *dma_dabufp++ = LSWAP(0xda000bad);
	} 
      else 
	{
	  dma_dabufp += nwords;
	}
    } 
  else 
    {
      printf("ERROR: Data not ready in event %d\n",tirGetIntCount());
      *dma_dabufp++ = LSWAP(0xda000bad);
    }

  *dma_dabufp++ = LSWAP(0xd00dd00d); /* Event EOB */

  tirIntOutput(0);
}
Beispiel #2
0
void
usrtrig(unsigned int EVTYPE, unsigned int EVSOURCE)
{
  int *jw, ind, ind2, i, ii, jj, jjj, blen, len, rlen, itdcbuf, nbytes;
  unsigned int *tdcbuf_save, *tdc;
  unsigned int *dabufp1, *dabufp2;
  int njjloops, slot;
  int nwords;
#ifndef VXWORKS
  TIMERL_VAR;
#endif

#ifdef USE_PRAD
  int islot;
  int stat, dCnt, idata;
  unsigned int sync_or_unbuff;
  unsigned int *dma_dabufp;
#endif

  char *chptr, *chptr0;

  /*printf("EVTYPE=%d syncFlag=%d\n",EVTYPE,syncFlag);*/


  if(syncFlag) printf("EVTYPE=%d syncFlag=%d\n",EVTYPE,syncFlag);

  rol->dabufp = (int *) 0;

  /*
usleep(100);
  */
  /*
  sleep(1);
  */

  CEOPEN(EVTYPE, BT_BANKS); /* reformatted on CODA_format.c !!! */

  if((syncFlag<0)||(syncFlag>1))         /* illegal */
  {
    printf("Illegal1: syncFlag=%d EVTYPE=%d\n",syncFlag,EVTYPE);
  }
  else if((syncFlag==0)&&(EVTYPE==0))    /* illegal */
  {
    printf("Illegal2: syncFlag=%d EVTYPE=%d\n",syncFlag,EVTYPE);
  }
  else if((syncFlag==1)&&(EVTYPE==0))    /* force_sync (scaler) events */
  {
    ;
/*
!!! we are geting here on End transition: syncFlag=1 EVTYPE=0 !!!
*/
  }
  else if((syncFlag==0)&&(EVTYPE==15)) /* helicity strob events */
  {
    ;
  }
  else           /* physics and physics_sync events */
  {

    /* for EVIO format, will dump raw data */
    tdcbuf_save = tdcbuf;

    /*************/
	/* TI stuff */

    /* Set high, the first output port 
    tiSetOutputPort(1,0,0,0);
    */

    /* Grab the data from the TI */
vmeBusLock();
    len = tiReadBlock(tdcbuf,900>>2,1);
vmeBusUnlock();
    BANKOPEN(0xe10A,1,rol->pid);
    if(len<=0)
    {
      printf("ERROR in tiReadBlock : No data or error, len = %d\n",len);
      sleep(1);
    }
    else
    {
	  ;
	  /*
      printf("ti: len=%d\n",len);
      for(jj=0; jj<len; jj++) printf("ti[%2d] 0x%08x\n",jj,LSWAP(tdcbuf[jj]));
	  */

	  
      for(jj=0; jj<len; jj++) *rol->dabufp++ = tdcbuf[jj];
	  
    }
    *rol->dabufp++ = LSWAP((lms_phase<<16) | trigger_type);
/*
    *rol->dabufp++ = LSWAP(tiGetScalar(1,0));
    *rol->dabufp++ = LSWAP(tiGetScalar(2,0));
    *rol->dabufp++ = LSWAP(tiGetScalar(3,0));
    *rol->dabufp++ = LSWAP(tiGetScalar(4,0));
    *rol->dabufp++ = LSWAP(tiGetScalar(5,0));
    *rol->dabufp++ = LSWAP(tiGetScalar(6,0));
*/
    BANKCLOSE;

    /* Turn off all output ports 
    tiSetOutputPort(0,0,0,0);
    */
	/* TI stuff */
    /*************/


#ifdef DEBUG
    printf("fadc1: start fadc processing\n");fflush(stdout);
#endif



#ifndef VXWORKS
TIMERL_START;
#endif







#ifdef USE_PRAD

#ifdef USE_V767

    BANKOPEN(0xe121,1,rol->pid);
    dma_dabufp = rol->dabufp;


vmeBusLock();
    stat = v767Dready(0);
vmeBusUnlock();

    jj = 0;
    while( (jj<100) && (stat==0) )
    {
vmeBusLock();
      stat = v767Dready(0);
vmeBusUnlock();
      jj++;
    }

    if(stat)
    {
vmeBusLock();
      dCnt = v767ReadEvent(0, dma_dabufp, 256);
vmeBusUnlock();
      if(dCnt <= 0) /*Error*/
	  {
        *dma_dabufp++ = LSWAP(0xed767bad);
        printf("v767(%d): No data or error.  dCnt = %d\n", ii, dCnt);
      }
      else
      {
        dma_dabufp += dCnt;
        /*printf("Read: %d\n", dCnt);*/
      }
    }
    else
    {
      printf("v767(%d): Timeout. Data not ready.\n", ii);
    }


    rol->dabufp = dma_dabufp;
    BANKCLOSE;

#endif

#ifdef USE_V1190
    int icheck = 0, maxcheck = 200, nev = 0;

    for(icheck = 0; icheck < maxcheck; icheck++)
    {
      nev = tdc1190Dready(0);
      if(nev > 0) break;
    }

    if(nev > 0) 
    {
      
      vmeBusLock();
      rlen = tdc1190ReadBoard(0, tdcbuf);
      vmeBusUnlock();
      
      if(rlen > 0) 
	  {
	  BANKOPEN(0xe121,1,rol->pid);

	    for(jj=0; jj<rlen; jj++)
	    {
	      *rol->dabufp++ = LSWAP(tdcbuf[jj]);
#ifdef V1190_TEST
	      if(!((*rol->nevents)%1000)) 
		  {
		    printf("Read %d words. \n", rlen);
		    if((tdcbuf[jj]&0xf8000000) == 0)
		      printf("channel %d, value %d\n", (tdcbuf[jj] >> 18)&0x7f, (tdcbuf[jj]&0x3ffff));
		  }
#endif
	    }
	    BANKCLOSE;
	  }
Beispiel #3
0
void
rocTrigger(int arg)
{
  int ii, status, dma, count;
  int nwords;
  unsigned int datascan, tirval, vme_addr;
  int length,size;
  unsigned long long time0, time1, time2, time3;

  tirIntOutput(1); /* Stop the gate to vmeDSC */

  tirval = tirIntType();

  *dma_dabufp++ = LSWAP(0xffdaf000); /* TI data header */
  *dma_dabufp++ = LSWAP(tirval);

  /* Check for valid data here */
  for(ii=0;ii<100;ii++) 
    {
      datascan = tdc1190Dready(0);
      if (datascan>0) 
	{
	  break;
	}
    }

  if(datascan>0) 
    {
      /* Get the TDC data from all modules... rflag=2 for Linked List DMA 
	 "64" is ignored in Linux */
      time0 = rdtsc();
      nwords = tdc1190ReadBlock(0,dma_dabufp,64,1);
      time1 = rdtsc();
    
      if(nwords < 0) 
	{
	  printf("ERROR: in transfer (event = %d), status = 0x%x\n", tirGetIntCount(),nwords);
	  *dma_dabufp++ = LSWAP(0xda000bad);
	} 
      else 
	{
	  dma_dabufp += nwords;
	}
    } 
  else 
    {
      printf("ERROR: Data not ready in event %d\n",tirGetIntCount());
      *dma_dabufp++ = LSWAP(0xda000bad);
    }

  for(ii=0; ii<1000; ii++)
    {
      tirval=tirIntType();
    }

  time2 = rdtsc();

  for(ii=0; ii<1000; ii++)
    {
      tirIntOutput(1); /* Stop the gate to vmeDSC */
    }

  time3 = rdtsc();

  /* Insert some data here */
  dscLatchScalers(0,2); /* latch both scalers */
  nwords = dscReadScalers(0,dma_dabufp,20,DSC_READOUT_TRGVME|DSC_READOUT_REF|DSC_READOUT_REFVME);
  dma_dabufp+=nwords;

  *dma_dabufp++ = LSWAP(0xcebaf009);
  *dma_dabufp++ = LSWAP((unsigned int)(time1-time0));
  *dma_dabufp++ = LSWAP((unsigned int)(time2-time1));
  *dma_dabufp++ = LSWAP((unsigned int)(time3-time2));
  *dma_dabufp++ = LSWAP((unsigned int)(dma_timer[0]-time0));
  *dma_dabufp++ = LSWAP((unsigned int)(dma_timer[1]-time0));
  *dma_dabufp++ = LSWAP((unsigned int)(dma_timer[2]-time0));
  *dma_dabufp++ = LSWAP((unsigned int)(dma_timer[3]-time0));
  *dma_dabufp++ = LSWAP((unsigned int)(dma_timer[4]-time0));
  *dma_dabufp++ = LSWAP((unsigned int)(dma_timer[5]-time0));

  *dma_dabufp++ = LSWAP(0xda0000ff);

/*   for(ii=0;ii<2000;ii++) */
/*     { */
/*       *dma_dabufp++ = LSWAP(0xda000000+ii); */
/*     } */

  tirIntOutput(0); 
}