00001 #include <iostream>
00002
00003 #include <ctype.h>
00004
00005 #include <unistd.h>
00006
00007 #include "RodModule.h"
00008
00009 #include "RCCVmeInterface.h"
00010
00011 using namespace std;
00012 using namespace SctPixelRod;
00013
00014 void usage();
00015
00016 int main(int argc, char **argv) {
00017
00018 const unsigned long mapSize=0xc00040;
00019 const long numSlaves=4;
00020
00021 int slot = -1;
00022 int fpga = 0;
00023 unsigned long baseAddress;
00024
00025 if (argc > 1) {
00026 for (int i=1; i<argc; i++) {
00027 string option;
00028 option = argv[i];
00029 if (option[0] != '-') break;
00030 switch (option[1]) {
00031 case 's': {
00032 slot = atoi(option.substr(2).c_str());
00033 break;
00034 }
00035 case 'f': {
00036 fpga = 1;
00037 break;
00038 }
00039 case 'h': {
00040 usage();
00041 exit(0);
00042 break;
00043 }
00044 default: {
00045 break;
00046 }
00047 }
00048 }
00049 }
00050
00051
00052 if (slot < 0) {
00053 cout << "Enter slot number (decimal):";
00054 cin >> slot;
00055 while ((slot < 1) || (slot > 21)) {
00056 cout << "Slot number out or range [1:21], re-enter: ";
00057 cin >> slot;
00058 }
00059 }
00060 baseAddress = slot << 24;
00061
00062
00063 RCCVmeInterface *vme = new RCCVmeInterface();
00064
00065
00066 RodModule* rod = new RodModule(baseAddress, mapSize, *vme, numSlaves);
00067
00068
00069
00070 unsigned long int fpgaReset = 0x20;
00071 unsigned long int mdspReset = 0x40;
00072
00073 unsigned long resetAddress;
00074 unsigned long resetValue;
00075
00076 if(fpga) {
00077 resetAddress = FPGA_CONTROL_REG_REL_ADDR[0];
00078 resetValue = fpgaReset;
00079 } else {
00080 resetAddress = FPGA_CONTROL_REG_REL_ADDR[2];
00081 resetValue = mdspReset;
00082 }
00083
00084 hex(cout);
00085
00086 cout << "Reset\n";
00087 cout << "Reset addresss: 0x" << resetAddress << endl;
00088 rod->getVmePort()->write32(resetAddress, resetValue);
00089
00090 cout << "Set value: 0x" << rod->getVmePort()->read32(resetAddress) << endl;
00091
00092
00093
00094 dec(cout);
00095
00096
00097 cout << "Suggest waiting about 10 seconds for the ROD to come up again\n";
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112 delete rod;
00113 delete vme;
00114
00115 return 0;
00116 }
00117
00118 void usage() {
00119 cout << "Usage: ResetRod [options]\n";
00120 cout << "\t-s# Reset ROD in slot # (decimal)\n";
00121 cout << "\t-f Reconfigure the FPGAs instead of resetting the DSPs\n";
00122 }