Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages

TouchRod.cxx

00001 
00002 
00003 #include <iostream>
00004 using namespace std;
00005 
00006 #include <ctype.h>
00007 
00008 #include "RodModule.h"
00009 
00010 #include "primParams.h"
00011 #include "RCCVmeInterface.h"
00012 #include "parameters.h"
00013 
00014 int main(int argc, char *argv[]) {
00015 
00016 using namespace SctPixelRod;
00017 
00018   unsigned long serialNumber, masked1, masked2, rodRevision;
00019   VmePort *myVmePort;
00020   
00021   std::string fileName(""), option;
00022   bool verbose = false;
00023   int slot = -1;
00024   unsigned long baseAddress;
00025 
00026   if (argc > 1) {
00027     for (int i=1; i<argc; i++) {
00028       option = argv[i];
00029       if (option[0] != '-') break;
00030       switch (option[1]) {
00031         case 'v': {
00032           verbose = true;
00033           break;
00034         }
00035         case 's': {
00036           slot = atoi(option.substr(2).c_str());
00037           break;
00038         }
00039         default: {
00040           break;
00041         }
00042       }
00043     }
00044   }
00045   
00046 // Prompt for slot number
00047   if (slot < 0 ) {
00048     cout << "Enter slot number (decimal):"; 
00049     cin >> slot;
00050     while ((slot < 1) || (slot > 21)) {
00051       cout << "Slot number out or range [1:21], re-enter: ";
00052       cin >> slot;
00053     }
00054   }
00055   baseAddress = slot << 24;
00056 
00057 // Create VME interface
00058   RCCVmeInterface *vme1 = new RCCVmeInterface();
00059   
00060 // Create RodModule and initialize it
00061   RodModule* rod0 = new RodModule(baseAddress, mapSize, *vme1, numSlaves);
00062   myVmePort = rod0->getVmePort();
00063 
00064   try {
00065 // Read the FPGA Status Register 6 (counting from 0)
00066     serialNumber = myVmePort->read32(FPGA_STATUS_REG_REL_ADDR[6]);
00067     cout << "FPGA Status Reg[6] = " << hex << serialNumber << endl;
00068     masked1 = serialNumber&0xFF000000;
00069     masked2 = serialNumber&0x000000FF;
00070     if (0xad000000 == masked1) {
00071       cout << "Sanity check passed" << endl;
00072       rodRevision = (serialNumber&0x00FF0000)>>16;
00073       cout << "Board revision = " << rodRevision << endl;
00074       serialNumber = serialNumber&0x3FF;
00075       cout << "board serial number = " << serialNumber << endl;
00076     }
00077     else if (0x000000ad == masked2) {
00078       cout << "Byte order wrong." << endl;
00079     }
00080     else {
00081       cout << "Sanity check failed!!!" << endl;
00082     }
00083 
00084     if(verbose) {
00085       cout << "HPIC: 0x" << hex << rod0->hpiFetch(HPIC) << dec << endl;
00086 
00087       cerr << "Load HWOB to HPIC\n";
00088       unsigned long hpicValue = 0x00010001;
00089       rod0->hpiLoad(HPIC, hpicValue);
00090       cerr << "...done\n";
00091 
00092       rod0->sleep(1000);
00093 
00094       cerr << "Read from EMIF\n";
00095       // mdspSingleRead/Write use HPID not HPID++ (not allowed)
00096       for(unsigned long addr = 0x01800000; addr < 0x01800020; addr+=4) {
00097         unsigned long val = rod0->mdspSingleRead(addr);
00098         cerr << "0x" << hex << addr << ": 0x" << val << dec << endl;
00099       } 
00100       cerr << "...done\n";
00101     }
00102   } catch(BaseException &b) {
00103     cout << "Exception touching ROD:\n" << b << endl;
00104   }
00105 
00106 // Delete the ROD and VME objects before exiting
00107   delete rod0;
00108   delete vme1;
00109 
00110   return 0;  
00111 }
00112 
00113 

Generated on Fri Dec 16 19:38:25 2005 for SCT DAQ/DCS Software - C++ by doxygen 1.3.5