// VMEInterface.cpp: implementation of the VMEInterface class. // ////////////////////////////////////////////////////////////////////// #include "VMEInterface.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// VMEInterface::VMEInterface() { } VMEInterface::~VMEInterface() { } // set up the Bit-3 card void VMEInterface::setup(unsigned int crate) { bt_error_t status; // begin by setting up the Bit-3 interface char name[80], *gen_stat; gen_stat = bt_gen_name(crate,BT_DEV_A32,name,sizeof(name)); status = bt_open(&_unit,name,BT_RDWR); if (status!=BT_SUCCESS) { printf("ERROR: status of bt_open is %d.\n",status); bt_perror(_unit,status,"bt_open returns: "); } // change address modifier status=bt_set_info(_unit,BT_INFO_DMA_AMOD,(int)0x0d); // 0x09 works, but we decided to use 0x0d in the L2 system status=bt_set_info(_unit,BT_INFO_PIO_AMOD,(int)0x0d); // } // write a single 32-bit word void VMEInterface::write32(unsigned int address,unsigned int value) { // write value value to aVME address addrerss bt_error_t status; unsigned int *valuept=&value,m_real_bytes; //printf("Writing %x to %x\n",value,address); status=bt_write(_unit,(void *) valuept,address,4,&m_real_bytes); if (status!=BT_SUCCESS) { printf("ERROR: status of write32 is %d.\n",status); bt_perror(_unit,status,"bt_read returns: "); } } // write nwords 32-bit word void VMEInterface::blockWrite32(unsigned int address,unsigned int *buffer,unsigned int nwords) { // nwords is the number of 32-bit words to write. // buffer is an array containing the data to write. bt_error_t status; unsigned int m_real_bytes; //printf("Writing %d words, first word %x to address %x\n",nwords,buffer[0],address); //status=bt_write(_unit,(void *) buffer,address,nwords*4,&m_real_bytes); for(unsigned int i=0;i