Exemplo n.º 1
0
/* Interrupt Service routine */
void
mytsISR(int arg)
{
  volatile unsigned short reg;
  int dCnt, len=0,idata;
  DMANODE *outEvent;
  int tsbready=0, timeout=0;
  int prescale=1;

  unsigned int tsIntCount = tsGetIntCount();

/*   tsPrintScalers(1); */
/*   printf(" tsIntCount = %d\n", tsIntCount); */
/*   tsPrintScalers(2); */
/*   tsPrintScalers(3); */

  GETEVENT(vmeIN,tsIntCount);

  dCnt = tsPartReadBlock(dma_dabufp,900>>2);
  if(dCnt<=0)
    {
      printf("No data or error.  dCnt = %d\n",dCnt);
    }
  else
    {
      dma_dabufp += dCnt;
/*       printf("dCnt = %d\n",dCnt); */
    
    }
  PUTEVENT(vmeOUT);
  
  outEvent = dmaPGetItem(vmeOUT);
#define READOUT
#ifdef READOUT
  if(tsIntCount%prescale==0)
    {
      printf("Received %d triggers...\n",
	     tsIntCount);

      len = outEvent->length;
      
      for(idata=0;idata<len;idata++)
	{
	  if((idata%5)==0) printf("\n\t");
	  printf("  0x%08x ",(unsigned int)LSWAP(outEvent->data[idata]));
	}
      printf("\n\n");
    }
#endif
  dmaPFreeItem(outEvent);
/*   tsStatus(); */
/*   sleep(1); */
}
Exemplo n.º 2
0
void asyncTrigger()
{
  int intCount=0;
  int length,size;
  unsigned int tirval;

  intCount = tidGetIntCount();

  /* grap a buffer from the queue */
  GETEVENT(vmeIN,intCount);
  if(the_event->length!=0) 
    {
      printf("Interrupt Count = %d\t",intCount);
      printf("the_event->length = %d\n",the_event->length);
    }

  the_event->type = 1;
  
  /* Execute user defined Trigger Routine */
  rocTrigger();

  /* Put this event's buffer into the OUT queue. */
  PUTEVENT(vmeOUT);
  /* Check if the event length is larger than expected */
  length = (((int)(dma_dabufp) - (int)(&the_event->length))) - 4;
  size = the_event->part->size - sizeof(DMANODE);

  if(length>size) 
    {
      printf("rocLib: ERROR: Event length > Buffer size (%d > %d).  Event %d\n",
	     length,size,the_event->nevent);
    }
  if(dmaPEmpty(vmeIN)) 
    {
      printf("WARN: vmeIN out of event buffers.\n");
      tidDoAck = 0;
      tidNeedAck = 1;
    }


}
Exemplo n.º 3
0
/* Interrupt Service routine */
void
mytiISR(int arg)
{
  volatile unsigned short reg;
  int dCnt, len=0,idata;
  DMANODE *outEvent;
  int blkReady=0, timeout=0;
  int printout = 1;

  unsigned int tiIntCount = tiGetIntCount();

#ifdef DO_READOUT
  GETEVENT(vmeIN,tiIntCount);

#ifdef DOINT
  blkReady = tiBReady();
  if(blkReady==ERROR)
    {
      printf("%s: ERROR: tiIntPoll returned ERROR.\n",__FUNCTION__);
      return;
    }

  if(blkReady==0 && timeout<100)
    {
      printf("NOT READY!\n");
      blkReady=tiBReady();
      timeout++;
    }

  if(timeout>=100)
    {
      printf("TIMEOUT!\n");
      return;
    }
#endif

/*   dCnt = tiReadBlock(dma_dabufp,3*BLOCKLEVEL+10,1); */
  dCnt = tiReadTriggerBlock(dma_dabufp);
  if(dCnt<=0)
    {
      printf("No data or error.  dCnt = %d\n",dCnt);
    }
  else
    {
      tiCheckTriggerBlock(dma_dabufp);
/*       dma_dabufp += dCnt; */
      /*       printf("dCnt = %d\n",dCnt); */
    
    }

  timeout=0;
  blkReady = vfTDCBReady(0);
  if(blkReady==0 && timeout<100)
    {
      printf("NOT READY!\n");
      blkReady = vfTDCBReady(0);
      timeout++;
    }

  if(timeout>=100)
    {
      printf("TIMEOUT!\n");
      return;
    }

  dCnt = vfTDCReadBlock(0,dma_dabufp,BLOCKLEVEL*(10*192+10),1);
  if(dCnt<=0)
    {
      printf("No data or error.  dCnt = %d\n",dCnt);
    }
  else
    {
      dma_dabufp += dCnt;
    }



  PUTEVENT(vmeOUT);

  outEvent = dmaPGetItem(vmeOUT);
#define READOUT
#ifdef READOUT
  if(tiIntCount%printout==0)
    {
      printf("Received %d triggers...\n",
	     tiIntCount);

      len = outEvent->length;
      
      for(idata=0;idata<len;idata++)
	{
/* 	  if((idata%5)==0) printf("\n\t"); */
/* 	  printf("  0x%08x ",(unsigned int)LSWAP(outEvent->data[idata])); */
	  vfTDCDataDecode(LSWAP(outEvent->data[idata]));
	}
      printf("\n\n");
    }
#endif
  dmaPFreeItem(outEvent);
#else /* DO_READOUT */
  /*   tiResetBlockReadout(); */

#endif /* DO_READOUT */
  if(tiIntCount%printout==0)
    printf("intCount = %d\n",tiIntCount );
/*     sleep(1); */

  static int bl = BLOCKLEVEL;
  if(tiGetSyncEventFlag())                                                      
    {                                                                           
/*       tiSetBlockLevel(bl++);                                               */
      printf("SE: Curr BL = %d\n",tiGetCurrentBlockLevel());                    
      printf("SE: Next BL = %d\n",tiGetNextBlockLevel());                       
    }                                                                           
 
}
Exemplo n.º 4
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);
}
Exemplo n.º 5
0
/* Interrupt Service routine */
void
mytsISR(int arg)
{
  volatile unsigned short reg;
  int dCnt, len=0,idata;
  DMANODE *outEvent;
  int tsbready=0, timeout=0;
  static int bl=BLOCKLEVEL;

  unsigned int tsIntCount = tsGetIntCount();

/*   tsPrintScalers(1); */
/*   printf(" tsIntCount = %d\n", tsIntCount); */
/*   tsPrintScalers(2); */
/*   tsPrintScalers(3); */

  GETEVENT(vmeIN,tsIntCount);

#ifdef DOINT
  tsbready = tsBReady();
  if(tsbready==ERROR)
    {
      printf("%s: ERROR: tsIntPoll returned ERROR.\n",__FUNCTION__);
      return;
    }

  if(tsbready==0 && timeout<100)
    {
      printf("NOT READY!\n");
      tsbready=tsBReady();
      timeout++;
    }

  if(timeout>=100)
    {
      printf("TIMEOUT!\n");
      return;
    }
#endif

  dCnt = tsReadTriggerBlock(dma_dabufp);
  if(dCnt<=0)
    {
      printf("No data or error.  dCnt = %d\n",dCnt);
    }
  else
    {
      dma_dabufp += dCnt;
/*       printf("dCnt = %d\n",dCnt); */
    
    }
  PUTEVENT(vmeOUT);
  
  outEvent = dmaPGetItem(vmeOUT);
#define READOUT
#ifdef READOUT
  if(tsIntCount%1==0)
    {
      printf("Received %d triggers...\n",
	     tsIntCount);

      len = outEvent->length;
      
      for(idata=0;idata<len;idata++)
	{
	  if((idata%5)==0) printf("\n\t");
	  printf("  0x%08x ",(unsigned int)(outEvent->data[idata]));
	}
      printf("\n\n");
    }
#endif
  dmaPFreeItem(outEvent);

  if(tsGetSyncEventFlag())
    {
/*       tsSetBlockLevel(bl++); */
      printf("SE: Curr BL = %d\n",tsGetCurrentBlockLevel());
      printf("SE: Next BL = %d\n",tsGetNextBlockLevel());
    }


/*   tsStatus(1); */
/*   sleep(1); */
}
Exemplo n.º 6
0
/* Interrupt Service routine */
void
myISR(int arg)
{
  volatile unsigned short reg;
  int dCnt, len=0,idata;
  DMANODE *outEvent;
  int tibready=0, timeout=0;
  int printout = 1;
  int iev=0;

  unsigned int tiIntCount = arg;

  GETEVENT(vmeIN,tiIntCount);

    /* Readout FADC */
  if(NFADC!=0)
    {
      FA_SLOT = fadcID[0];
      int itime=0, stat=0, roflag=1, islot=0;
      unsigned int gbready=0;
/*       for(itime=0;itime<10000;itime++)  */
/* 	{ */
/* 	  gbready = faGBready(); */
/* 	  stat = (gbready == fadcSlotMask); */
/* 	  if (stat>0)  */
/* 	    { */
/* 	      break; */
/* 	    } */
/* 	} */
/*       if(stat>0)  */
	{
	  if(NFADC>1) roflag=2; /* Use token passing scheme to readout all modules */
	  dCnt = faReadBlock(FA_SLOT,dma_dabufp,MAXFADCWORDS,roflag);
	  if(dCnt<=0)
	    {
	      printf("FADC%d: No data or error.  dCnt = %d\n",FA_SLOT,dCnt);
	    }
	  else
	    {
	      if(dCnt>MAXFADCWORDS)
		{
		  printf("%s: WARNING.. faReadBlock returned dCnt >= MAXFADCWORDS (%d >= %d)\n",
			 __FUNCTION__,dCnt, MAXFADCWORDS);
		}
	      else 
		dma_dabufp += dCnt;
	    }
	} 
/*       else  */
/* 	{ */
/* 	  printf ("FADC%d: no events   stat=%d  intcount = %d   gbready = 0x%08x  fadcSlotMask = 0x%08x\n", */
/* 		  FA_SLOT,stat,tiIntCount,gbready,fadcSlotMask); */
/* 	} */

      /* Reset the Token */
      if(roflag==2)
	{
	  for(islot=0; islot<NFADC; islot++)
	    {
	      FA_SLOT = fadcID[islot];
	      faResetToken(FA_SLOT);
	    }
	}
    }

  PUTEVENT(vmeOUT);

  outEvent = dmaPGetItem(vmeOUT);

#define READOUT
#ifdef READOUT
  if(tiIntCount%printout==0)
    {
      printf("Received %d triggers...\n",
	     tiIntCount);

      len = outEvent->length;
      
      for(idata=0;idata<len;idata++)
	{
	  faDataDecode(LSWAP(outEvent->data[idata]));
	}
      printf("\n\n");
    }
#endif
  dmaPFreeItem(outEvent);

  if(tiIntCount%printout==0)
    printf("intCount = %d\n",tiIntCount );

  /* Pulse flex io for next event */
  flexioWriteCsr(0, 0x101);


}