00001 #include <iostream>
00002 using namespace std;
00003
00004 #include <ctype.h>
00005
00006 #include <unistd.h>
00007
00008 #include "RodModule.h"
00009 #include "BocCard.h"
00010
00011 #include "RCCVmeInterface.h"
00012 #include "registerIndices.h"
00013
00014 using namespace SctPixelRod;
00015
00016 void usage();
00017
00018 int main(int argc, char **argv) {
00019 const unsigned long mapSize=0xc00040;
00020 const long numSlaves=4;
00021
00022 int slot = -1;
00023 int link = -1;
00024
00025 unsigned long baseAddress;
00026
00027 if (argc > 1) {
00028 for (int i=1; i<argc; i++) {
00029 string option;
00030 option = argv[i];
00031 if (option[0] != '-') break;
00032 switch (option[1]) {
00033 case 's': slot = atoi(option.substr(2).c_str()); break;
00034 case 'l': link = atoi(option.substr(2).c_str()); break;
00035 default: {
00036 break;
00037 }
00038 }
00039 }
00040 }
00041
00042
00043 if (slot < 0 || link < 0) {
00044 cout << "Must specify all parameters\n";
00045 usage();
00046 exit(1);
00047 }
00048 baseAddress = slot << 24;
00049
00050
00051 RCCVmeInterface vme;
00052
00053
00054 RodModule rod(baseAddress, mapSize, vme, numSlaves);
00055 rod.initialize(false);
00056
00057 int formatter = link/12;
00058 int intLink = link%12;
00059
00060 int primLength = sizeof(RW_REG_FIELD_IN)/4;
00061 long regData[primLength];
00062 struct RW_REG_FIELD_IN ®Struct = *(RW_REG_FIELD_IN *)regData;
00063
00064 regStruct.registerID = FMT_LINK_DATA_TEST_MUX(formatter);
00065 regStruct.offset = 0;
00066 regStruct.width = 4;
00067 regStruct.readNotWrite = 0;
00068 regStruct.dataIn = intLink;
00069
00070 RodPrimitive registerPrim(primLength+4, 1, RW_REG_FIELD, R_RW_REG_FIELD, regData);
00071 rod.synchSendPrim(registerPrim);
00072
00073 regStruct.registerID = EFB_CMND_0;
00074 regStruct.offset = 4;
00075 regStruct.width = 3;
00076 regStruct.readNotWrite = 0;
00077 regStruct.dataIn = formatter & 0x7;
00078
00079 RodPrimitive registerPrim2(primLength+4, 1, RW_REG_FIELD, R_RW_REG_FIELD, regData);
00080 rod.synchSendPrim(registerPrim2);
00081
00082
00083 return 0;
00084 }
00085
00086 void usage() {
00087 cout << "Usage:\n";
00088 cout << " SetTestLinkOut -s[slot] -l[link]\n";
00089 }