Esempio n. 1
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);
}
Esempio n. 2
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;
}
Esempio n. 3
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);
}