mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 10:07:59 +02:00
jungfrau: comp disable time
This commit is contained in:
@ -1662,6 +1662,32 @@ int autoCompDisable(int on) {
|
||||
EXT_DAQ_CTRL_CMP_LGC_ENBL_OFST);
|
||||
}
|
||||
|
||||
int setComparatorDisableTime(int64_t val) {
|
||||
if (getChipVersion() != 11) {
|
||||
return FAIL;
|
||||
}
|
||||
if (val < 0) {
|
||||
LOG(logERROR,
|
||||
("Invalid comp disable time: %lld ns\n", (long long int)val));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("Setting comp disable time %lld ns\n", (long long int)val));
|
||||
val *= (1E-3 * CLK_RUN);
|
||||
bus_w(COMP_DSBLE_TIME_REG, val);
|
||||
|
||||
// validate for tolerance
|
||||
int64_t retval = getComparatorDisableTime();
|
||||
val /= (1E-3 * CLK_RUN);
|
||||
if (val != retval) {
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
int64_t getComparatorDisableTime() {
|
||||
return bus_r(COMP_DSBLE_TIME_REG) / (1E-3 * CLK_RUN);
|
||||
}
|
||||
|
||||
void configureASICTimer() {
|
||||
LOG(logINFO, ("Configuring ASIC Timer\n"));
|
||||
bus_w(ASIC_CTRL_REG, (bus_r(ASIC_CTRL_REG) & ~ASIC_CTRL_PRCHRG_TMR_MSK) |
|
||||
|
@ -450,6 +450,8 @@ int powerChip(int on);
|
||||
int isChipConfigured();
|
||||
void configureChip();
|
||||
int autoCompDisable(int on);
|
||||
int setComparatorDisableTime(int64_t val);
|
||||
int64_t getComparatorDisableTime();
|
||||
void configureASICTimer();
|
||||
int setClockDivider(enum CLKINDEX ind, int val);
|
||||
int getClockDivider(enum CLKINDEX ind);
|
||||
|
@ -258,4 +258,6 @@ int get_chip_version(int);
|
||||
int get_default_dac(int);
|
||||
int set_default_dac(int);
|
||||
int get_gain_mode(int);
|
||||
int set_gain_mode(int);
|
||||
int set_gain_mode(int);
|
||||
int get_comp_disable_time(int);
|
||||
int set_comp_disable_time(int);
|
@ -384,6 +384,8 @@ void function_table() {
|
||||
flist[F_SET_DEFAULT_DAC] = &set_default_dac;
|
||||
flist[F_GET_GAIN_MODE] = &get_gain_mode;
|
||||
flist[F_SET_GAIN_MODE] = &set_gain_mode;
|
||||
flist[F_GET_COMP_DISABLE_TIME] = &get_comp_disable_time;
|
||||
flist[F_SET_COMP_DISABLE_TIME] = &set_comp_disable_time;
|
||||
|
||||
// check
|
||||
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
|
||||
@ -8613,3 +8615,61 @@ int set_gain_mode(int file_des) {
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||
}
|
||||
|
||||
int get_comp_disable_time(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int64_t retval = -1;
|
||||
#ifndef JUNGFRAUD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// get only
|
||||
if (getChipVersion() != 11) {
|
||||
ret = FAIL;
|
||||
strcpy(mess,
|
||||
"Cannot get comparator disable time. Only valid for chipv1.1\n");
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
retval = getComparatorDisableTime();
|
||||
LOG(logDEBUG1,
|
||||
("retval comp disable time %lld ns\n", (long long int)retval));
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
int set_comp_disable_time(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int64_t arg = -1;
|
||||
if (receiveData(file_des, &arg, sizeof(arg), INT64) < 0)
|
||||
return printSocketReadError();
|
||||
LOG(logDEBUG1, ("Setting comp disable time %lld ns\n", (long long int)arg));
|
||||
|
||||
#ifndef JUNGFRAUD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if (getChipVersion() != 11) {
|
||||
ret = FAIL;
|
||||
strcpy(mess, "Cannot get comparator disable time. Only valid for "
|
||||
"chipv1.1\n");
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
ret = setComparatorDisableTime(arg);
|
||||
int64_t retval = getComparatorDisableTime();
|
||||
LOG(logDEBUG1, ("retval get comp disable time %lld ns\n",
|
||||
(long long int)retval));
|
||||
if (ret == FAIL) {
|
||||
sprintf(mess,
|
||||
"Could not set comp disable time. Set %lld ns, read "
|
||||
"%lld ns.\n",
|
||||
(long long int)arg, (long long int)retval);
|
||||
LOG(logERROR, (mess));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT64, NULL, 0);
|
||||
}
|
Reference in New Issue
Block a user