Пример #1
0
int
main(int argc, char *argv[])
{
  int ret;
  unsigned int addr = 0xd000;

  /* Open the default VME windows */
  vmeOpenDefaultWindows();

  /*
vmeBusLock();
  tiInit((21<<19),2,0);
  tiStatus(1);
vmeBusUnlock();
  */

 printf("argc=%d\n",argc);
 if(argc==2)
 {
   printf("argv=>%s<\n",argv[1]);
   addr = strtol(argv[1], (char **)NULL, 16);
 }

 printf("use addr=0x%04x\n",addr);


vmeBusLock();
  ret = v851Init(addr,0);
  v851_start(1000000);
vmeBusUnlock();


  exit(0);
}
Пример #2
0
int 
main(int argc, char *argv[]) 
{
  unsigned int laddr;
  unsigned int taddr = 0x0ed0;
  int stat;
  int inputchar=10;

  vmeOpenDefaultWindows();

  while(1 && (inputchar==10))
    {
	
      printf("Grab mutex lock\n");
      vmeBusLock();
      printf("Press return to unlock mutex..\n");
      getchar();
      vmeBusUnlock();
	
      printf("I think it's unlocked now... return to kill it\n");
      inputchar = getchar();
    }

 CLOSE:

  vmeCloseDefaultWindows();

  exit(0);
}
Пример #3
0
int
main(int argc, char *argv[])
{
  int res, i;
  char myname[256];
  unsigned int addr, laddr;
  int slot = 0, nssp = 0;

  printf("\n");
  if(argc==2||argc==3)
  {
    strncpy(myname, argv[1], 255);
    printf("Use argument >%s< as bin file name\n",myname);
    if(argc==3)
	{
	  slot = atoi(argv[2]);
      printf("Upgrade board at slot=%d only\n",slot);
	}
	else
	{
      slot = 0;
      printf("Upgrade all boards in crate\n");
	}
  }
  else
  {
    printf("Usage: sspfirmware <bin file> [slot]\n");
    exit(0);
  }
  printf("\n");

  /* Open the default VME windows */
  vmeOpenDefaultWindows();
  printf("\n");

  if(slot)
  {
    sspInit(slot<<19, 0, 1, SSP_INIT_NO_INIT | SSP_INIT_SKIP_FIRMWARE_CHECK);
    sspRich_Init(slot);
//    sspRich_FirmwareUpdateVerifyAll(slot, myname);
    sspRich_FirmwareVerifyAll(slot, myname);
  }
  else
  {
    sspInit(0, 0, 0, SSP_INIT_NO_INIT | SSP_INIT_SKIP_FIRMWARE_CHECK);
    nssp = sspGetNssp();
    for(i=0; i<nssp; i++)
    {
      slot = sspSlot(i);
      if(sspGetFirmwareType(slot) == SSP_CFG_SSPTYPE_HALLBRICH)
      {
        sspRich_Init(slot);
//        sspRich_FirmwareUpdateVerifyAll(slot, myname);
        sspRich_FirmwareVerifyAll(slot, myname);
      }
    }
  }

  exit(0);
}
Пример #4
0
int 
main(int argc, char *argv[]) 
{
  int chan=0, prescale=0, duty_mode;
  uint32_t read_prescale=0, read_dutymode=0;
  float read_dutycycle=0;

  if(argc!=4)
    return ERROR;

  chan = atoi(argv[1]);
  prescale = atoi(argv[2]);
  duty_mode = atoi(argv[3]);

  printf(" chan = %d   prescale = %d\n", chan, prescale);

  DO(vmeOpenDefaultWindows());
  
  DO(moInit(0xed0000,0));

  DO(moConfigPrint());

  DO(moGetPrescale(chan, &read_prescale));

  printf("before: read_prescale = %d\n",read_prescale);

  DO(moSetPrescale(chan, prescale));

  DO(moGetPrescale(chan, &read_prescale));
  
  printf(" after: read_prescale = %d\n",read_prescale);

  DO(moConfigPrint());

  DO(moGetDutyMode(chan, &read_dutymode));
  DO(moGetDutyCycle(chan, &read_dutycycle));
  printf(" before: read_dutymode = %d   read_dutycycle = %6.3f\n",
	 read_dutymode, read_dutycycle);

  DO(moSetDutyMode(chan, duty_mode));

  DO(moGetDutyMode(chan, &read_dutymode));
  DO(moGetDutyCycle(chan, &read_dutycycle));
  printf("  after: read_dutymode = %d   read_dutycycle = %6.3f\n",
	 read_dutymode, read_dutycycle);

  DO(moConfigPrint());
  

 CLOSE:
  vmeCloseDefaultWindows();
  
  return OK;
}
Пример #5
0
int main(int argc, char *argv[])
{
	int stat;
	
	if(signal(SIGINT, sig_handler) == SIG_ERR)
	{
		perror("signal");
		exit(0);
	}

	vmeSetQuietFlag(1);
	stat = vmeOpenDefaultWindows();
	if(stat != OK)
		goto CLOSE;

//	stat = crateShmCreate();
//	if(stat != OK)
//		goto CLOSE;

// Run socket server
	gCrateServerCBFcn.Read16 = Vme_Read16;
	gCrateServerCBFcn.Write16 = Vme_Write16;
	gCrateServerCBFcn.Read32 = Vme_Read32;
	gCrateServerCBFcn.Write32 = Vme_Write32;
	gCrateServerCBFcn.Delay = Vme_Delay;
	gCrateServerCBFcn.ReadScalers = Vme_ReadScalers;
	
	printf("Starting CrateMsgServer...");
	CrateMsgServerStart(&gCrateServerCBFcn, CRATEMSG_LISTEN_PORT);
	printf("Done.\n");

	while(1)
		sleep(1);
	
CLOSE:
	vmeOpenDefaultWindows();
	
	return 0;
}
Пример #6
0
int
main(int argc, char *argv[])
{
  int res;
  char myname[256];
  unsigned int addr, laddr;
  int slot = 0;

  printf("\n");
  if(argc==2||argc==3)
  {
    strncpy(myname, argv[1], 255);
    printf("Use argument >%s< as bin file name\n",myname);
    if(argc==3)
	{
	  slot = atoi(argv[2]);
      printf("Upgrade board at slot=%d only\n",slot);
	}
	else
	{
      slot = 0;
      printf("Upgrade all boards in crate\n");
	}
  }
  else
  {
    printf("Usage: sspfirmware <bin file> [slot]\n");
    exit(0);
  }
  printf("\n");

  /* Open the default VME windows */
  vmeOpenDefaultWindows();
  printf("\n");

  if(slot)
  {
    sspInit(slot<<19, 0, 1, SSP_INIT_NO_INIT | SSP_INIT_SKIP_FIRMWARE_CHECK);
    sspFirmwareRead(slot, myname);
//    sspFirmwareUpdateVerify(slot, myname);
  }
  else
  {
    printf("Error: Must specifiy slot number\n");
//    sspInit(0, 0, 0, SSP_INIT_NO_INIT | SSP_INIT_SKIP_FIRMWARE_CHECK);
//    sspGFirmwareUpdateVerify(myname);
  }

  exit(0);
}
Пример #7
0
int
main(int argc, char *argv[])
{
    int res;
    char myname[256];
    unsigned int addr, laddr;
    int iflag, ntd, slot = 0;

    /*
    printf("\n");
    if(argc==2||argc==3)
    {
      strncpy(myname, argv[1], 255);
      printf("Use argument >%s< as bin file name\n",myname);
      if(argc==3)
    {
      slot = atoi(argv[2]);
        printf("Upgrade board at slot=%d only\n",slot);
    }
    else
    {
        slot = 0;
        printf("Upgrade all boards in crate\n");
    }
    }
    else
    {
      printf("Usage: dsc2init <bin file> [slot]\n");
      exit(0);
    }
    printf("\n");
    */

    /* Open the default VME windows */
    vmeOpenDefaultWindows();
    printf("\n");

    ntd = 0;
    iflag = 1;
    tdInit((3<<19),0x80000,20,iflag);
    ntd = tdGetNtds(); /* actual number of TD boards found  */

    tdGStatus(0);

    exit(0);
}
Пример #8
0
int 
main(int argc, char *argv[]) 
{
  
  int stat;

  vmeOpenDefaultWindows();

  vmeBusLock();
  printf("Press return to assert SYSRESET\n");
  getchar();
  stat = vmeSysReset();
  printf("vmeSysReset returned 0x%x\n",stat);
  vmeBusUnlock();

  vmeCloseDefaultWindows();

  exit(0);
}
Пример #9
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 */     
Пример #10
0
int 
main(int argc, char *argv[]) {

    int stat;
    int slot;

    if(argc>1)
      {
	slot = atoi(argv[1]);
	if(slot<1 || slot>22)
	  {
	    printf("invalid slot... using 21");
	    slot=21;
	  }
      }
    else 
      slot=21;

    printf("\nJLAB TI Status... slot = %d\n",slot);
    printf("----------------------------\n");

    vmeOpenDefaultWindows();

    /* Set the TI structure pointer */
    tiInit((slot<<19),TI_READOUT_EXT_POLL,1);
    tiStatus();

    sdInit();
    sdStatus();

 CLOSE:

    vmeCloseDefaultWindows();

    exit(0);
}
Пример #11
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);
}
Пример #12
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);
}
Пример #13
0
int 
main(int argc, char *argv[]) 
{
  GEF_STATUS status;
  char *filename;
  int inputchar=10;
  int ch, ifa=0;
  unsigned int cfw=0;
  FILE *f;
  fa250Ped ped;

  printf("\nJLAB fadc pedestal measurement\n");
  printf("----------------------------\n");

  progName = argv[0];

  if(argc != 2)
  {
    printf(" ERROR: Must specify one arguments\n");
    Usage();
    exit(-1);
  }
  else
    filename = argv[1];

  status = vmeOpenDefaultWindows();

  fadcA32Base=0x09000000;

  int iFlag = (DIST_ADDR)<<10;
  /* Sync Source */
  iFlag |= (1<<0); /* P2 */
  /* Trigger Source */
  iFlag |= (1<<2); // VXS Input Trigger
  /* Clock Source */
  iFlag |= (0<<5); // Internal Clock Source

  iFlag |= (1<<18); // Skip firmware check
/*     iFlag |= (1<<16); // Skip initialization */

#ifdef SKIPSS
  faInit((unsigned int)(FADC_ADDR),(1<<19),NFADC+2,iFlag);
#else
  faInit((unsigned int)(FADC_ADDR),(1<<19),NFADC,iFlag);
#endif

  fadc250Config("");

  if(nfadc==0)
  {
    printf(" Unable to initialize any FADCs.\n");
    goto CLOSE;
  }
  
  f = fopen(filename, "wt");

#ifdef NEWFORMAT  
  for(ifa=0; ifa<nfadc; ifa++)
  {
    if(f) fprintf(f, "FADC250_SLOT %d\nFADC250_ALLCH_PED", faSlot(ifa));

    for(ch=0; ch<16; ch++)
	 {
      if(faMeasureChannelPedestal(faSlot(ifa), ch, &ped) != OK)
		{
        printf(" Unabled to measure pedestal on slot %d, ch %d...\n", faSlot(ifa), ch);
        fclose(f);
        goto CLOSE;
		}
		if(f) fprintf(f, " %8.3f", ped.avg);
    }
    if(f) fprintf(f, "\n");
  }
#else
  for(ifa=0; ifa<nfadc; ifa++)
  {
    for(ch=0; ch<16; ch++)
    {
      if(faMeasureChannelPedestal(faSlot(ifa), ch, &ped) != OK)
      {
        printf(" Unabled to measure pedestal on slot %d, ch %d...\n", faSlot(ifa), ch);
        fclose(f);
        goto CLOSE;
      }
      if(f) fprintf(f, "%3d %3d %8.3f %8.3f\n", faSlot(ifa),ch,ped.avg,ped.rms);
    }
  }
#endif

  if(f)
    fclose(f);
  else
    printf(" Unable to open pedestal file %s\n", filename);

CLOSE:

    status = vmeCloseDefaultWindows();
    if (status != GEF_SUCCESS)
    {
      printf("vmeCloseDefaultWindows failed: code 0x%08x\n",status);
      return -1;
    }

    exit(0);
}
Пример #14
0
void closeup()
{
	vmeOpenDefaultWindows();
	printf("DiagGUI server closed...\n");
}
Пример #15
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);
}
Пример #16
0
int
main(int argc, char *argv[])
#endif
{
  int res=0;
  char firmware_filename[50];
  int current_fw_version=0;
#ifdef WRITESERIALNUMBER
  unsigned int serial_number=0;
  unsigned int hall_board_version=0;
  unsigned int firmware_version=0;
#endif
  int inputchar=10;

  printf("\nJLAB Signal Distribution (SD) Firmware Update\n");
  printf("------------------------------------------------\n");

#ifdef VXWORKS
  strncpy(bin_name,__FUNCTION__,50);
#else
  strncpy(bin_name,argv[0],50);

#ifdef WRITESERIALNUMBER
  if(argc<5)
    {
      printf(" ERROR: Must specify four (4) arguments\n");
      Usage();
      exit(-1);
    }
  else
    {
      strncpy(firmware_filename,argv[1],50);
      serial_number = (unsigned int) strtoll(argv[2],NULL,10)&0xffffffff;
      hall_board_version = (unsigned int) strtoll(argv[3],NULL,16)&0xffffffff;
      firmware_version = (unsigned int) strtoll(argv[4],NULL,16)&0xffffffff;
    }
#else
  if(argc<2)
    {
      printf(" ERROR: Must specify two (2) arguments\n");
      Usage();
      exit(-1);
    }
  else
    {
      strncpy(firmware_filename,argv[1],50);
    }
#endif
#endif /* VXWORKS */

#ifdef WRITESERIALNUMBER
  /* Check on provided items */
  if(serial_number<1 || serial_number>255)
    {
      printf(" ERROR: Invalid Serial Number (%d).  Must be 1-255\n",serial_number);
      exit(-1);
    }

  if(hall_board_version<0x1 || hall_board_version>0xFF)
    {
      printf(" ERROR: Invalid Assigned Hall and Board Version (0x%x).\n  Must be 0x01-0xFF\n"
	     ,hall_board_version);
      exit(-1);
    }

  if(firmware_version<0x1 || firmware_version>0xFF)
    {
      printf(" ERROR: Firmware Version (0x%x).  Must be 0x01-0xFF\n",firmware_version);
      exit(-1);
    }

  printf("Firmware File                   = %s\n",firmware_filename);
  printf("Serial Number (dec)             = %4d\n",serial_number);
  printf("Assigned Hall and Board Version = 0x%02X\n",hall_board_version);
  printf("Firmware Version                = 0x%02X\n",firmware_version);
  printf("\n");

  printf(" Please verify these items before continuing... \n");
#else
  printf("Firmware File                   = %s\n",firmware_filename);
#endif
  printf("\n");

#ifndef VXWORKS
  vmeSetQuietFlag(1);
  res = vmeOpenDefaultWindows();
  if(res!=OK)
    goto CLOSE;
#endif

  res = sdFirmwareLoadFile(firmware_filename);
  if(res!=OK)
    goto CLOSE;

  res = tiInit(21<<19,0,1);
  if(res!=OK)
    {
      /* try tsInit, instead */
      res = tsInit(21<<19,0,1);
      if(res!=OK)
	goto CLOSE;
    }
  
  res = sdInit(SD_INIT_IGNORE_VERSION);
  if(res!=OK)
    goto CLOSE;

  current_fw_version = sdGetFirmwareVersion(0);
  printf("\n  Current SD Firmware Version = 0x%x\n\n",current_fw_version);

  printf(" <ENTER> to continue... or q and <ENTER> to quit without update\n");
  inputchar = getchar();

  if((inputchar == 113) ||
     (inputchar == 81))
    {
      printf(" Exiting without update\n");
      res=1;
      goto CLOSE;
    }


  res = sdFirmwareFlushFifo();
  if(res!=OK)
    goto CLOSE;

  res = sdFirmwareWriteToMemory();
  if(res!=OK)
    goto CLOSE;

  goto CLOSE;

/*   res = sdFirmwareVerifyMemory(); */
/*   if(res!=OK) */
/*     goto CLOSE; */

  sdFirmwareFlushFifo();
#ifdef WRITESERIALNUMBER
  sdFirmwareWriteSpecs(0x7F0000,serial_number,hall_board_version,firmware_version);
  sleep(3);
  sdFirmwarePrintSpecs();
#endif

 CLOSE:

  sdFirmwareFreeMemory();
#ifndef VXWORKS
  vmeCloseDefaultWindows();
#endif

  printf("\n");
  if(res==ERROR)
    printf(" ******** SD Update ended in ERROR! ******** \n");
  else if (res==OK)
    {
      printf(" ++++++++ SD Update Successful! ++++++++\n");
      printf("   Power Cycle to load new firmware\n");
    }
  

  printf("\n");
  return OK;
}
Пример #17
0
int 
main(int argc, char *argv[]) {

    int status;
    int stat=0;
    char *mcs_filename;
    int inputchar=10;
    unsigned int fadc_address=0;

    printf("\nJLAB fADC125 firmware update\n");
    printf("----------------------------\n");

    progName = argv[0];

    if(argc<3)
      {
	printf(" ERROR: Must specify two arguments\n");
	Usage();
	exit(-1);
      }
    else
      {
	mcs_filename = argv[1];
	fadc_address = (unsigned int) strtoll(argv[2],NULL,16)&0xffffffff;
      }

    fa125FirmwareSetDebug(0);

    if(fa125FirmwareReadMcsFile(mcs_filename) != OK)
      {
	exit(-1);
      }
    
    vmeSetQuietFlag(0);
    status = vmeOpenDefaultWindows();
    if(status<0)
      {
	printf(" Unable to initialize VME driver\n");
	exit(-1);
      }

    int iFlag = (1<<18); /* Do not perform firmware check */
    iFlag |= (2<<4);     /* Internal Clock */
    stat = fa125Init(fadc_address,0x0,1,iFlag);
    if(stat<0)
      {
	printf(" Unable to initialize FADC.\n");
	goto CLOSE;
      }

    /* Should get the firmware versions here and print them out */

    printf(" Will update firmware with file: \n   %s\n",mcs_filename);
    printf(" for fADC125 with VME address = 0x%08x\n",fadc_address);

    printf(" <ENTER> to continue... or q and <ENTER> to quit without update\n");

    inputchar = getchar();

    if((inputchar == 113) ||
       (inputchar == 81))
      {
	printf(" Exitting without update\n");
	goto CLOSE;
      }

    vmeBusLock();
    fa125FirmwareSetDebug(FA125_FIRMWARE_DEBUG_MEASURE_TIMES |
			  FA125_FIRMWARE_DEBUG_VERIFY_ERASE);

    if(fa125FirmwareEraseFull(0)!=OK)
      {
	vmeBusUnlock();
	goto CLOSE;
      }

    if(fa125FirmwareWriteFull(0)!=OK)
      {
	vmeBusUnlock();
	goto CLOSE;
      }

    vmeBusUnlock();

 CLOSE:

    fa125FirmwarePrintTimes();

    status = vmeCloseDefaultWindows();
    if (status != GEF_SUCCESS)
    {
      printf("vmeCloseDefaultWindows failed: code 0x%08x\n",status);
      return -1;
    }

    exit(0);
}
Пример #18
0
main(int argc, char *argv[])
#endif
{
  int stat;
  int BoardNumber;
  char *filename;
  int inputchar=10;
  unsigned int vme_addr=0;
  
  printf("\nTD firmware update via VME\n");
  printf("----------------------------\n");

#ifdef VXWORKS
  programName = __FUNCTION__;

  vme_addr = arg_vmeAddr;
  filename = arg_filename;
#else
  programName = argv[0];

  if(argc<3)
    {
      printf(" ERROR: Must specify two arguments\n");
      tdFirmwareUsage();
      return(-1);
    }
  else
    {
      vme_addr = (unsigned int) strtoll(argv[1],NULL,16)&0xffffffff;
      filename = argv[2];
    }

  vmeSetQuietFlag(1);
  stat = vmeOpenDefaultWindows();
  if(stat != OK)
    goto CLOSE;
#endif

  stat = tdInit(vme_addr,0,1,TD_INIT_SKIP_FIRMWARE_CHECK);
  if(stat != OK)
    {
      printf("\n");
      printf("*** Failed to initialize TD ***\nThis may indicate (either):\n");
      printf("   a) an incorrect VME Address provided\n");
      printf("   b) new firmware must be loaded at provided VME address\n");
      printf("\n");
      printf("Proceed with the update with the provided VME address?\n");
    REPEAT:
      printf(" (y/n): ");
      inputchar = getchar();

      if((inputchar == 'n') || (inputchar == 'N'))
	{
	  printf("--- Exiting without update ---\n");
	  goto CLOSE;
	}
      else if((inputchar == 'y') || (inputchar == 'Y'))
	{
	  printf("--- Continuing update, assuming VME address is correct ---\n");
	}
      else
	{
	  goto REPEAT;
	}
    }

  /* Read out the board serial number first */
  BoardSerialNumber = tdGetSerialNumber(0,NULL);
  printf(" Board Serial Number from PROM usercode is: 0x%08x (%d) \n", BoardSerialNumber,
	 BoardSerialNumber&0xffff);

  /* Check the serial number and ask for input if necessary */
  /* Force this program to only work for TD (not TI or TS) */
  if (!((BoardSerialNumber&0xffff0000) == 0x7D000000))
    { 
      printf(" This TD has an invalid serial number (0x%08x)\n",BoardSerialNumber);
      printf (" Enter a new board number (0-4095), or -1 to quit: ");

      scanf("%d",&BoardNumber);

      if(BoardNumber == -1)
	{
	  printf("--- Exiting without update ---\n");
	  goto CLOSE;
	}

      /* Add the TD board ID in the MSB */
      BoardSerialNumber = 0x7D000000 | (BoardNumber&0xfff);
      printf(" The board serial number will be set to: 0x%08x (%d)\n",BoardSerialNumber,
	     BoardSerialNumber&0xffff);
    }

  firmwareInfo = tdGetFirmwareVersion(0);
  if(firmwareInfo>0)
    {
      printf("  User ID: 0x%x \tFirmware (version - revision): 0x%X - 0x%03X\n",
	     (firmwareInfo&0xFFFF0000)>>16, (firmwareInfo&0xF000)>>12, firmwareInfo&0xFFF);
    }
Пример #19
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);
}
Пример #20
0
int 
main(int argc, char *argv[]) 
{

    GEF_STATUS status;
    int fpga_choice, firmware_choice=0;
    char *mcs_filename;
    int inputchar=10;
    int ifa=0;
    unsigned int cfw=0;

    printf("\nJLAB fadc firmware update\n");
    printf("----------------------------\n");

    progName = argv[0];

    if(argc<3)
      {
	printf(" ERROR: Must specify two arguments\n");
	Usage();
	exit(-1);
      }
    else
      {
	fpga_choice = atoi(argv[1]);
	mcs_filename = argv[2];
      }

    if( (fpga_choice != 1) &&
	(fpga_choice != 2) )
      {
	printf(" ERROR: Invalid FPGA choice (%d)\n",fpga_choice);
	Usage();
	exit(-1);
      }

    if(fadcFirmwareReadMcsFile(mcs_filename) != OK)
      {
	exit(-1);
      }

    status = vmeOpenDefaultWindows();

    fadcA32Base=0x09000000;

    int iFlag = (DIST_ADDR)<<10;
    /* Sync Source */
    iFlag |= (1<<0); /* P2 */
    /* Trigger Source */
    iFlag |= (1<<2); // VXS Input Trigger
    /* Clock Source */
    iFlag |= (0<<5); // Internal Clock Source

    iFlag |= (1<<18); // Skip firmware check
/*     iFlag |= (1<<16); // Skip initialization */

#ifdef SKIPSS
    faInit((unsigned int)(FADC_ADDR),(1<<19),NFADC+2,iFlag);
#else
    faInit((unsigned int)(FADC_ADDR),(1<<19),NFADC,iFlag);
#endif

    if(nfadc==0)
      {
	printf(" Unable to initialize any FADCs.\n");
	goto CLOSE;
      }

    for(ifa=0; ifa<nfadc; ifa++)
      {
	cfw = faGetFirmwareVersions(faSlot(ifa),0);
	printf("%2d: Control Firmware Version: 0x%04x   Proc Firmware Version: 0x%04x\n",
	       faSlot(ifa),cfw&0xFFFF,(cfw>>16)&0xFFFF);
      }

    printf(" Will update firmware for ");
    if(fpga_choice==1)
      {
	firmware_choice = FADC_FIRMWARE_FX70T;
	printf("FX70T (Control FPGA) ");
      }
    else if(fpga_choice==2)
      {
	firmware_choice = FADC_FIRMWARE_LX110;
	printf("LX110 (Processing FPGA) ");
      }

    printf(" with file: \n   %s\n",mcs_filename);
    printf(" <ENTER> to continue... or q and <ENTER> to quit without update\n");

    inputchar = getchar();

    if((inputchar == 113) ||
       (inputchar == 81))
      {
	printf(" Exiting without update\n");
	goto CLOSE;
      }

    fadcFirmwareGLoad(firmware_choice,0);

    goto CLOSE;

 CLOSE:


    status = vmeCloseDefaultWindows();
    if (status != GEF_SUCCESS)
    {
      printf("vmeCloseDefaultWindows failed: code 0x%08x\n",status);
      return -1;
    }

    exit(0);
}