mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 01:58:00 +02:00
filter and cds gain, burst and continuous value to asic changed, bug fix to scanning function addresses in server_funcs.c
This commit is contained in:
@ -56,6 +56,8 @@ int64_t numTriggersReg = 1;
|
||||
int64_t delayReg = 0;
|
||||
int64_t numBurstsReg = 1;
|
||||
int64_t burstPeriodReg = 0;
|
||||
int filter = 0;
|
||||
int cdsGain = 0;
|
||||
int detPos[2] = {};
|
||||
|
||||
int isInitCheckDone() { return initCheckDone; }
|
||||
@ -369,6 +371,8 @@ void setupDetector() {
|
||||
delayReg = 0;
|
||||
numBurstsReg = 1;
|
||||
burstPeriodReg = 0;
|
||||
filter = 0;
|
||||
cdsGain = 0;
|
||||
for (int i = 0; i < NUM_CLOCKS; ++i) {
|
||||
clkPhase[i] = 0;
|
||||
}
|
||||
@ -450,6 +454,8 @@ void setupDetector() {
|
||||
return;
|
||||
}
|
||||
setBurstMode(DEFAULT_BURST_MODE);
|
||||
setFilter(DEFAULT_FILTER);
|
||||
setCDSGain(DEFAILT_CDS_GAIN);
|
||||
setSettings(DEFAULT_SETTINGS);
|
||||
|
||||
// Initialization of acquistion parameters
|
||||
@ -2088,9 +2094,19 @@ int setBurstMode(enum burstMode burst) {
|
||||
}
|
||||
LOG(logINFO, ("\tDone Updating registers\n"))
|
||||
|
||||
return configureASICGlobalSettings();
|
||||
}
|
||||
|
||||
int configureASICGlobalSettings() {
|
||||
LOG(logINFO, ("\tSetting %s Mode in Chip\n",
|
||||
burstMode == BURST_OFF ? "Continuous" : "Burst"));
|
||||
int value = burstMode ? ASIC_GLOBAL_BURST_VALUE : ASIC_GLOBAL_CONT_VALUE;
|
||||
int modeValue =
|
||||
burstMode ? ASIC_GLOBAL_BURST_VALUE : ASIC_GLOBAL_CONT_VALUE;
|
||||
int value = ((modeValue << ASIC_GLOBAL_MODE_OFST) & ASIC_GLOBAL_MODE_MSK) |
|
||||
((filter << ASIC_FILTER_OFST) & ASIC_FILTER_MSK) |
|
||||
((cdsGain << ASIC_CDS_GAIN_OFST) & ASIC_CDS_GAIN_MSK);
|
||||
LOG(logINFO, ("\tsetting value:0x%x (mode:%d, filter:%d, cdsgain:%d)\n",
|
||||
value, modeValue, filter, cdsGain));
|
||||
|
||||
const int padding = 6; // due to address (4) to make it byte aligned
|
||||
const int lenTotalBits = padding + ASIC_GLOBAL_SETT_MAX_BITS +
|
||||
@ -2151,6 +2167,30 @@ enum burstMode getBurstMode() {
|
||||
return burstMode;
|
||||
}
|
||||
|
||||
int setCDSGain(int enable) {
|
||||
if (enable >= 0) {
|
||||
cdsGain = (enable == 0 ? 0 : 1);
|
||||
LOG(logINFO,
|
||||
("%s CDS Gain\n", (cdsGain == 0 ? "Disabling" : "Enabling")));
|
||||
return configureASICGlobalSettings();
|
||||
}
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
int getCDSGain() { return cdsGain; }
|
||||
|
||||
int setFilter(int value) {
|
||||
if (value < 0 || value > ASIC_FILTER_MAX_VALUE) {
|
||||
LOG(logERROR, ("Invalid filter value %d\n", value));
|
||||
return FAIL;
|
||||
}
|
||||
filter = value;
|
||||
LOG(logINFO, ("Setting Filter to %d\n", filter));
|
||||
return configureASICGlobalSettings();
|
||||
}
|
||||
|
||||
int getFilter() { return filter; }
|
||||
|
||||
void setCurrentSource(int value) {
|
||||
uint32_t addr = ASIC_CONFIG_REG;
|
||||
if (value > 0) {
|
||||
|
@ -31,6 +31,8 @@
|
||||
|
||||
/** Default Parameters */
|
||||
#define DEFAULT_BURST_MODE (BURST_INTERNAL)
|
||||
#define DEFAULT_FILTER (0)
|
||||
#define DEFAILT_CDS_GAIN (0)
|
||||
#define DEFAULT_NUM_FRAMES (1)
|
||||
#define DEFAULT_NUM_CYCLES (1)
|
||||
#define DEFAULT_NUM_BURSTS (1)
|
||||
@ -135,7 +137,14 @@ enum PLLINDEX { READOUT_PLL, SYSTEM_PLL };
|
||||
#define ASIC_ADC_MAX_VAL (0x7F)
|
||||
#define ASIC_GLOBAL_SETT_MAX_BITS (6)
|
||||
#define ASIC_GLOBAL_BURST_VALUE (0x0)
|
||||
#define ASIC_GLOBAL_CONT_VALUE (0x1E)
|
||||
#define ASIC_GLOBAL_CONT_VALUE (0x6)
|
||||
#define ASIC_GLOBAL_MODE_OFST (0)
|
||||
#define ASIC_GLOBAL_MODE_MSK (0x7 << ASIC_GLOBAL_MODE_OFST)
|
||||
#define ASIC_FILTER_OFST (3)
|
||||
#define ASIC_FILTER_MSK (0x3 << ASIC_FILTER_OFST)
|
||||
#define ASIC_FILTER_MAX_VALUE (3)
|
||||
#define ASIC_CDS_GAIN_OFST (5)
|
||||
#define ASIC_CDS_GAIN_MSK (0x1 << ASIC_CDS_GAIN_OFST)
|
||||
|
||||
/* Struct Definitions */
|
||||
typedef struct udp_header_struct {
|
||||
|
@ -509,7 +509,12 @@ int configureSingleADCDriver(int chipIndex);
|
||||
int configureADC();
|
||||
int setBurstModeinFPGA(enum burstMode value);
|
||||
int setBurstMode(enum burstMode burst);
|
||||
int configureASICGlobalSettings();
|
||||
enum burstMode getBurstMode();
|
||||
int setCDSGain(int enable);
|
||||
int getCDSGain();
|
||||
int setFilter(int value);
|
||||
int getFilter();
|
||||
void setCurrentSource(int value);
|
||||
int getCurrentSource();
|
||||
void setTimingSource(enum timingSourceType value);
|
||||
|
@ -228,4 +228,8 @@ int set_veto(int);
|
||||
int set_pattern(int);
|
||||
int get_scan(int);
|
||||
int set_scan(int);
|
||||
int get_scan_error_message(int);
|
||||
int get_scan_error_message(int);
|
||||
int get_cds_gain(int);
|
||||
int set_cds_gain(int);
|
||||
int get_filter(int);
|
||||
int set_filter(int);
|
||||
|
@ -343,9 +343,13 @@ void function_table() {
|
||||
flist[F_GET_VETO] = &get_veto;
|
||||
flist[F_SET_VETO] = &set_veto;
|
||||
flist[F_SET_PATTERN] = &set_pattern;
|
||||
flist[F_GET_SCAN] = get_scan;
|
||||
flist[F_SET_SCAN] = set_scan;
|
||||
flist[F_GET_SCAN_ERROR_MESSAGE] = get_scan_error_message;
|
||||
flist[F_GET_SCAN] = &get_scan;
|
||||
flist[F_SET_SCAN] = &set_scan;
|
||||
flist[F_GET_SCAN_ERROR_MESSAGE] = &get_scan_error_message;
|
||||
flist[F_GET_CDS_GAIN] = &get_cds_gain;
|
||||
flist[F_SET_CDS_GAIN] = &set_cds_gain;
|
||||
flist[F_GET_FILTER] = &get_filter;
|
||||
flist[F_SET_FILTER] = &set_filter;
|
||||
|
||||
// check
|
||||
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
|
||||
@ -637,8 +641,7 @@ int get_server_version(int file_des) {
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int64_t retval = -1;
|
||||
retval = getServerVersion();
|
||||
LOG(logDEBUG1,
|
||||
("server version retval: 0x%llx\n", (long long int)retval));
|
||||
LOG(logDEBUG1, ("server version retval: 0x%llx\n", (long long int)retval));
|
||||
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
@ -647,8 +650,7 @@ int get_serial_number(int file_des) {
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int64_t retval = -1;
|
||||
retval = getDetectorNumber();
|
||||
LOG(logDEBUG1,
|
||||
("detector number retval: 0x%llx\n", (long long int)retval));
|
||||
LOG(logDEBUG1, ("detector number retval: 0x%llx\n", (long long int)retval));
|
||||
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
@ -7645,4 +7647,102 @@ int get_scan_error_message(int file_des) {
|
||||
LOG(logDEBUG1, ("scan retval err message: [%s]\n", retvals));
|
||||
|
||||
return Server_SendResult(file_des, OTHER, retvals, sizeof(retvals));
|
||||
}
|
||||
}
|
||||
|
||||
int get_cds_gain(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int retval = -1;
|
||||
|
||||
LOG(logDEBUG1, ("Getting cds gain enable\n"));
|
||||
|
||||
#ifndef GOTTHARD2D
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// get only
|
||||
retval = getCDSGain();
|
||||
LOG(logDEBUG1, ("cds gain enable retval: %u\n", retval));
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
int set_cds_gain(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int arg = 0;
|
||||
|
||||
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
LOG(logINFO, ("Setting cds gain enable: %u\n", arg));
|
||||
|
||||
#ifndef GOTTHARD2D
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if (arg != 0 && arg != 1) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
"Could not set CDS gain. Invalid value %d. "
|
||||
"Options [0-1]\n",
|
||||
arg);
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
setCDSGain(arg);
|
||||
int retval = getCDSGain();
|
||||
LOG(logDEBUG1, ("cds gain enable retval: %u\n", retval));
|
||||
validate(arg, retval, "set cds gain enable", DEC);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||
}
|
||||
|
||||
int get_filter(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int retval = -1;
|
||||
|
||||
LOG(logDEBUG1, ("Getting filter\n"));
|
||||
|
||||
#ifndef GOTTHARD2D
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// get only
|
||||
retval = getFilter();
|
||||
LOG(logDEBUG1, ("filter retval: %u\n", retval));
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
int set_filter(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int arg = 0;
|
||||
|
||||
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
LOG(logINFO, ("Setting filter: %u\n", arg));
|
||||
|
||||
#ifndef GOTTHARD2D
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if (arg < 0 || arg > ASIC_FILTER_MAX_VALUE) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
"Could not set filter. Invalid filter %d. "
|
||||
"Options [0-%d]\n",
|
||||
arg, ASIC_FILTER_MAX_VALUE);
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
setFilter(arg);
|
||||
int retval = getFilter();
|
||||
LOG(logDEBUG1, ("filter retval: %u\n", retval));
|
||||
validate(arg, retval, "set filter", DEC);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||
}
|
||||
|
Reference in New Issue
Block a user