* making quad work in developer branch

* binary added

* minor changes

* bug fix to set quad to 0 when more than 1 detector
This commit is contained in:
Dhanya Thattil
2019-07-22 16:41:03 +02:00
committed by GitHub
parent 0fa63f8be2
commit e7a76ccea1
23 changed files with 432 additions and 70 deletions

View File

@ -37,6 +37,8 @@ uint32_t Beb_detid = 0;
int Beb_top =0;
uint64_t Beb_deactivatedStartFrameNumber = 0;
int Beb_quadEnable = 0;
int Beb_positions[2] = {0, 0};
void BebInfo_BebInfo(struct BebInfo* bebInfo, unsigned int beb_num) {
@ -1188,6 +1190,16 @@ void Beb_SetDetectorNumber(uint32_t detid) {
FILE_LOG(logINFO, ("Detector id %d set in UDP Header\n\n", detid));
}
void Beb_SetQuad(int value) {
if (value >= 0) {
Beb_quadEnable = (value == 0 ? 0 : 1);
Beb_SetDetectorPosition(Beb_positions);
}
}
int Beb_GetQuad() {
return Beb_quadEnable;
}
int Beb_SetDetectorPosition(int pos[]) {
@ -1195,8 +1207,18 @@ int Beb_SetDetectorPosition(int pos[]) {
return OK;
FILE_LOG(logINFO, ("Got Position values %d %d...\n", pos[0],pos[1]));
pos[0] = Beb_swap_uint16(pos[0]);
//pos[1] = Beb_swap_uint16(pos[1]);
// save positions
Beb_positions[0] = pos[0];
Beb_positions[1] = pos[1];
// get left and right
int posLeft[2] = {pos[0], Beb_top ? pos[1] : pos[1] + 1};
int posRight[2] = {pos[0], Beb_top ? pos[1] + 1 : pos[1]};
if (Beb_quadEnable) {
posRight[0] = 1; // right is next row
posRight[1] = 0; // right same first column
}
int ret = FAIL;
//mapping new memory to read master top module configuration
@ -1210,20 +1232,22 @@ int Beb_SetDetectorPosition(int pos[]) {
uint32_t value = 0;
ret = OK;
// x left
int posval = Beb_swap_uint16(posLeft[0]);
value = Beb_Read32(csp0base, UDP_HEADER_A_LEFT_OFST);
value &= UDP_HEADER_ID_MSK; // to keep previous id value
Beb_Write32(csp0base, UDP_HEADER_A_LEFT_OFST, value | ((pos[0] << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK));
Beb_Write32(csp0base, UDP_HEADER_A_LEFT_OFST, value | ((posval << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK));
value = Beb_Read32(csp0base, UDP_HEADER_A_LEFT_OFST);
if ((value & UDP_HEADER_X_MSK) != ((pos[0] << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK)) {
if ((value & UDP_HEADER_X_MSK) != ((posval << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK)) {
FILE_LOG(logERROR, ("Could not set row position for left port\n"));
ret = FAIL;
}
// x right
posval = Beb_swap_uint16(posRight[0]);
value = Beb_Read32(csp0base, UDP_HEADER_A_RIGHT_OFST);
value &= UDP_HEADER_ID_MSK; // to keep previous id value
Beb_Write32(csp0base, UDP_HEADER_A_RIGHT_OFST, value | ((pos[0] << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK));
Beb_Write32(csp0base, UDP_HEADER_A_RIGHT_OFST, value | ((posval << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK));
value = Beb_Read32(csp0base, UDP_HEADER_A_RIGHT_OFST);
if ((value & UDP_HEADER_X_MSK) != ((pos[0] << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK)) {
if ((value & UDP_HEADER_X_MSK) != ((posval << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK)) {
FILE_LOG(logERROR, ("Could not set row position for right port\n"));
ret = FAIL;
}
@ -1231,7 +1255,7 @@ int Beb_SetDetectorPosition(int pos[]) {
// y left (column)
int posval = Beb_swap_uint16(Beb_top ? pos[1] : (pos[1]+1));
posval = Beb_swap_uint16(posLeft[1]);
value = Beb_Read32(csp0base, UDP_HEADER_B_LEFT_OFST);
value &= UDP_HEADER_Z_MSK; // to keep previous z value
Beb_Write32(csp0base, UDP_HEADER_B_LEFT_OFST, value | ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK));
@ -1242,9 +1266,9 @@ int Beb_SetDetectorPosition(int pos[]) {
}
// y right
posval = Beb_swap_uint16(posRight[1]);
value = Beb_Read32(csp0base, UDP_HEADER_B_RIGHT_OFST);
value &= UDP_HEADER_Z_MSK; // to keep previous z value
posval = Beb_swap_uint16(Beb_top ? (pos[1]+1) : pos[1]);
Beb_Write32(csp0base, UDP_HEADER_B_RIGHT_OFST, value | ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK));
value = Beb_Read32(csp0base, UDP_HEADER_B_RIGHT_OFST);
if ((value & UDP_HEADER_Y_MSK) != ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK)) {
@ -1260,8 +1284,7 @@ int Beb_SetDetectorPosition(int pos[]) {
FILE_LOG(logINFO, ("Position set to...\n"
"\tLeft: [%d, %d]\n"
"\tRight:[%d, %d]\n",
Beb_swap_uint16(pos[0]), Beb_top ? pos[1] : (pos[1]+1)),
Beb_swap_uint16(pos[0]), Beb_top ? (pos[1]+1) : pos[1]);
posLeft[0], posLeft[1], posRight[0], posRight[1]));
}
return ret;

View File

@ -74,6 +74,8 @@ int Beb_Test(unsigned int beb_number);
int Beb_GetBebFPGATemp();
void Beb_SetDetectorNumber(uint32_t detid);
void Beb_SetQuad(int value);
int Beb_GetQuad();
int Beb_SetDetectorPosition(int pos[]);
int Beb_SetStartingFrameNumber(uint64_t value);
int Beb_GetStartingFrameNumber(uint64_t* retval);

View File

@ -1310,6 +1310,13 @@ int setDetectorPosition(int pos[]) {
#endif
}
void setQuad(int value) {
Beb_SetQuad(value);
}
int getQuad() {
return Beb_GetQuad();
}
int enableTenGigabitEthernet(int val) {
if (val!=-1) {

View File

@ -246,6 +246,10 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32
#if defined(JUNGFRAUD) || defined(EIGERD)
int setDetectorPosition(int pos[]);
#endif
#ifdef EIGERD
void setQuad(int value);
int getQuad();
#endif
#if defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(EIGERD)
int enableTenGigabitEthernet(int val);
#endif

View File

@ -244,6 +244,8 @@ const char* getFunctionName(enum detFuncs func) {
case F_EXTERNAL_SAMPLING: return "F_EXTERNAL_SAMPLING";
case F_SET_STARTING_FRAME_NUMBER: return "F_SET_STARTING_FRAME_NUMBER";
case F_GET_STARTING_FRAME_NUMBER: return "F_GET_STARTING_FRAME_NUMBER";
case F_SET_QUAD: return "F_SET_QUAD";
case F_GET_QUAD: return "F_GET_QUAD";
default: return "Unknown Function";
}
}
@ -328,6 +330,8 @@ void function_table() {
flist[F_EXTERNAL_SAMPLING] = &set_external_sampling;
flist[F_SET_STARTING_FRAME_NUMBER] = &set_starting_frame_number;
flist[F_GET_STARTING_FRAME_NUMBER] = &get_starting_frame_number;
flist[F_SET_QUAD] = &set_quad;
flist[F_GET_QUAD] = &get_quad;
// check
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
@ -4074,4 +4078,50 @@ int get_starting_frame_number(int file_des) {
}
#endif
return Server_SendResult(file_des, INT64, UPDATE, &retval, sizeof(retval));
}
int set_quad(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int arg = 0;
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
return printSocketReadError();
FILE_LOG(logINFO, ("Setting quad: %u\n", arg));
#ifndef EIGERD
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
setQuad(arg);
int retval = getQuad();
if (arg != retval) {
ret = FAIL;
sprintf(mess, "Could not set quad. Set %d, but read %d\n", retval, arg);
FILE_LOG(logERROR,(mess));
}
}
#endif
return Server_SendResult(file_des, INT32, UPDATE, NULL, 0);
}
int get_quad(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int retval = -1;
FILE_LOG(logDEBUG1, ("Getting Quad\n"));
#ifndef EIGERD
functionNotImplemented();
#else
// get only
retval = getQuad();
FILE_LOG(logDEBUG1, ("Quad retval: %u\n", retval));
#endif
return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval));
}

View File

@ -104,4 +104,6 @@ int get_adc_invert(int);
int set_external_sampling_source(int);
int set_external_sampling(int);
int set_starting_frame_number(int);
int get_starting_frame_number(int);
int get_starting_frame_number(int);
int set_quad(int);
int get_quad(int);