// GSTM.cpp: implementation of the GSTM class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "GSTM.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// // default constructor GSTM::GSTM() : _crate(0), _gstmbase(0x90000000) { setup(0); } // destructor GSTM::~GSTM() { } // constructor with a crate and VME base address GSTM::GSTM(unsigned int crate,unsigned int vmebase) { _crate=crate; _gstmbase=vmebase; printf("in constructor, calling setup\n"); setup(crate); } // set up this GSTM void GSTM::setup(unsigned int crate, unsigned int vmebase) { _crate=crate; _gstmbase=vmebase; // first set up the VME part printf("setting up VME\n"); a32super.setup(_crate); printf("Done setting up VME crate\n"); } // reset the GSTM void GSTM::reset() { unsigned int offset,cmd; // start by writing 0 to the control and mode registers. offset=GSTM_CTRL; cmd=0x0; a32super.write32(_gstmbase+offset,cmd); offset=GSTM_MODE; cmd=0x0; a32super.write32(_gstmbase+offset,cmd); // reset the module, which requires //several writes, all of them are sticky. offset=GSTM_CTRL; unsigned int mask0=a32super.read32(_gstmbase+offset); // global reset: cmd=setBit(mask0,CTRL_RESET,1); a32super.write32(_gstmbase+offset,cmd); mask0=a32super.read32(_gstmbase+offset); // wait a little while Sleep(50); cmd=setBit(mask0,CTRL_RESET,0); a32super.write32(_gstmbase+offset,cmd); mask0=a32super.read32(_gstmbase+offset); // reset the error status bit cmd=setBit(mask0,CTRL_CLR_ERROR,1); a32super.write32(_gstmbase+offset,cmd); mask0=a32super.read32(_gstmbase+offset); cmd=setBit(mask0,CTRL_CLR_ERROR,0); a32super.write32(_gstmbase+offset,cmd); mask0=a32super.read32(_gstmbase+offset); // Clear the FIFOs cmd=setBit(mask0,CTRL_CLR_FIFO,1); a32super.write32(_gstmbase+offset,cmd); mask0=a32super.read32(_gstmbase+offset); cmd=setBit(mask0,CTRL_CLR_FIFO,0); a32super.write32(_gstmbase+offset,cmd); mask0=a32super.read32(_gstmbase+offset); } //Method to send standard events void GSTM::sendStandardEvent() { int data_nevts, i,j,k; int evtsize = 128; unsigned int data1; printf("How many events? Will be multiplied by 2\n"); scanf("%d",&data_nevts); //Set data to fifo for (k=0;k