mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-01-16 17:19:20 +01:00
filter resistor in
This commit is contained in:
@@ -63,7 +63,7 @@ int64_t numTriggersReg = 1;
|
||||
int64_t delayReg = 0;
|
||||
int64_t numBurstsReg = 1;
|
||||
int64_t burstPeriodReg = 0;
|
||||
int filter = 0;
|
||||
int filterResistor = 0;
|
||||
int cdsGain = 0;
|
||||
int detPos[2] = {};
|
||||
|
||||
@@ -388,7 +388,7 @@ void setupDetector() {
|
||||
delayReg = 0;
|
||||
numBurstsReg = 1;
|
||||
burstPeriodReg = 0;
|
||||
filter = 0;
|
||||
filterResistor = 0;
|
||||
cdsGain = 0;
|
||||
memset(clkPhase, 0, sizeof(clkPhase));
|
||||
memset(dacValues, 0, sizeof(dacValues));
|
||||
@@ -467,7 +467,7 @@ void setupDetector() {
|
||||
return;
|
||||
}
|
||||
setBurstMode(DEFAULT_BURST_MODE);
|
||||
setFilter(DEFAULT_FILTER);
|
||||
setFilterResistor(DEFAULT_FILTER_RESISTOR);
|
||||
setCDSGain(DEFAILT_CDS_GAIN);
|
||||
setSettings(DEFAULT_SETTINGS);
|
||||
|
||||
@@ -2458,7 +2458,7 @@ int setBurstMode(enum burstMode burst) {
|
||||
}
|
||||
|
||||
int configureASICGlobalSettings() {
|
||||
int value = ((filter << ASIC_FILTER_OFST) & ASIC_FILTER_MSK) |
|
||||
int value = ((filterResistor << ASIC_FILTER_OFST) & ASIC_FILTER_MSK) |
|
||||
((cdsGain << ASIC_CDS_GAIN_OFST) & ASIC_CDS_GAIN_MSK);
|
||||
switch (burstMode) {
|
||||
case BURST_INTERNAL:
|
||||
@@ -2473,9 +2473,9 @@ int configureASICGlobalSettings() {
|
||||
value |= (ASIC_CONT_MODE_MSK | ASIC_EXT_TIMING_MSK);
|
||||
break;
|
||||
}
|
||||
LOG(logINFO, ("\tSending Global Chip settings:0x%x (filter:%d, "
|
||||
LOG(logINFO, ("\tSending Global Chip settings:0x%x (filterResistor:%d, "
|
||||
"cdsgain:%d)\n",
|
||||
value, filter, cdsGain));
|
||||
value, filterResistor, cdsGain));
|
||||
|
||||
const int padding = 6; // due to address (4) to make it byte aligned
|
||||
const int lenTotalBits = padding + ASIC_GLOBAL_SETT_MAX_BITS +
|
||||
@@ -2551,17 +2551,17 @@ int setCDSGain(int enable) {
|
||||
|
||||
int getCDSGain() { return cdsGain; }
|
||||
|
||||
int setFilter(int value) {
|
||||
if (value < 0 || value > ASIC_FILTER_MAX_VALUE) {
|
||||
LOG(logERROR, ("Invalid filter value %d\n", value));
|
||||
int setFilterResistor(int value) {
|
||||
if (value < 0 || value > ASIC_FILTER_MAX_RES_VALUE) {
|
||||
LOG(logERROR, ("Invalid filter resistor value %d\n", value));
|
||||
return FAIL;
|
||||
}
|
||||
filter = value;
|
||||
LOG(logINFO, ("Setting Filter to %d\n", filter));
|
||||
filterResistor = value;
|
||||
LOG(logINFO, ("Setting Filter Resistor to %d\n", filterResistor));
|
||||
return configureASICGlobalSettings();
|
||||
}
|
||||
|
||||
int getFilter() { return filter; }
|
||||
int getFilterResistor() { return filterResistor; }
|
||||
|
||||
void setCurrentSource(int value) {
|
||||
uint32_t addr = ASIC_CONFIG_REG;
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
/** Default Parameters */
|
||||
#define DEFAULT_BURST_MODE (BURST_INTERNAL)
|
||||
#define DEFAULT_FILTER (0)
|
||||
#define DEFAULT_FILTER_RESISTOR (0)
|
||||
#define DEFAILT_CDS_GAIN (0)
|
||||
#define DEFAULT_NUM_FRAMES (1)
|
||||
#define DEFAULT_NUM_CYCLES (1)
|
||||
@@ -149,7 +149,7 @@ enum PLLINDEX { READOUT_PLL, SYSTEM_PLL };
|
||||
#define ASIC_CONT_MODE_MSK (0x1 << ASIC_CONT_MODE_OFST)
|
||||
#define ASIC_FILTER_OFST (3)
|
||||
#define ASIC_FILTER_MSK (0x3 << ASIC_FILTER_OFST)
|
||||
#define ASIC_FILTER_MAX_VALUE (3)
|
||||
#define ASIC_FILTER_MAX_RES_VALUE (3)
|
||||
#define ASIC_CDS_GAIN_OFST (5)
|
||||
#define ASIC_CDS_GAIN_MSK (0x1 << ASIC_CDS_GAIN_OFST)
|
||||
|
||||
|
||||
@@ -108,8 +108,9 @@
|
||||
// CSM mode = high current (100%), low current (16%)
|
||||
#define CONFIG_V11_STATUS_CRRNT_SRC_MODE_OFST (19)
|
||||
#define CONFIG_V11_STATUS_CRRNT_SRC_MODE_MSK (0x00000001 << CONFIG_V11_STATUS_CRRNT_SRC_MODE_OFST)
|
||||
#define CONFIG_V11_STATUS_FLTR_RSSTR_OFST (21)
|
||||
#define CONFIG_V11_STATUS_FLTR_RSSTR_MSK (0x00000001 << CONFIG_V11_STATUS_FLTR_RSSTR_OFST)
|
||||
#define CONFIG_V11_STATUS_FLTR_RSSTR_SMLR_OFST (21)
|
||||
#define CONFIG_V11_STATUS_FLTR_RSSTR_SMLR_MSK (0x00000001 << CONFIG_V11_STATUS_FLTR_RSSTR_SMLR_OFST)
|
||||
#define ASIC_FILTER_MAX_RES_VALUE (1)
|
||||
#define CONFIG_V11_STATUS_AUTO_MODE_OVRRD_OFST (23)
|
||||
#define CONFIG_V11_STATUS_AUTO_MODE_OVRRD_MSK (0x00000001 << CONFIG_V11_STATUS_AUTO_MODE_OVRRD_OFST)
|
||||
|
||||
@@ -249,8 +250,8 @@
|
||||
// CSM mode = high current (100%), low current (16%)
|
||||
#define CONFIG_V11_CRRNT_SRC_MODE_OFST (19)
|
||||
#define CONFIG_V11_CRRNT_SRC_MODE_MSK (0x00000001 << CONFIG_V11_CRRNT_SRC_MODE_OFST)
|
||||
#define CONFIG_V11_FLTR_RSSTR_OFST (21)
|
||||
#define CONFIG_V11_FLTR_RSSTR_MSK (0x00000001 << CONFIG_V11_FLTR_RSSTR_OFST)
|
||||
#define CONFIG_V11_FLTR_RSSTR_SMLR_OFST (21)
|
||||
#define CONFIG_V11_FLTR_RSSTR_SMLR_MSK (0x00000001 << CONFIG_V11_FLTR_RSSTR_SMLR_OFST)
|
||||
#define CONFIG_V11_AUTO_MODE_OVRRD_OFST (23)
|
||||
#define CONFIG_V11_AUTO_MODE_OVRRD_MSK (0x00000001 << CONFIG_V11_AUTO_MODE_OVRRD_OFST)
|
||||
|
||||
|
||||
@@ -474,7 +474,8 @@ void setupDetector() {
|
||||
// temp threshold and reset event
|
||||
setThresholdTemperature(DEFAULT_TMP_THRSHLD);
|
||||
setTemperatureEvent(0);
|
||||
setFlipRows(0);
|
||||
setFlipRows(DEFAULT_FLIP_ROWS);
|
||||
setFilterResistor(DEFAULT_FILTER_RESISTOR);
|
||||
}
|
||||
|
||||
int resetToDefaultDacs(int hardReset) {
|
||||
@@ -2022,6 +2023,38 @@ void setFlipRows(int arg) {
|
||||
}
|
||||
}
|
||||
|
||||
int getFilterResistor() {
|
||||
#ifdef VIRTUAL
|
||||
uint32_t addr = CONFIG_V11_REG;
|
||||
#else
|
||||
uint32_t addr = CONFIG_V11_STATUS_REG;
|
||||
#endif
|
||||
// 0 for lower value, 1 for higher value
|
||||
if (bus_r(addr) & CONFIG_V11_STATUS_FLTR_RSSTR_SMLR_MSK) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int setFilterResistor(int value) {
|
||||
// lower resistor
|
||||
if (value == 0) {
|
||||
LOG(logINFO, ("Setting Lower Filter Resistor\n"));
|
||||
bus_w(CONFIG_V11_REG,
|
||||
bus_r(CONFIG_V11_REG) | CONFIG_V11_FLTR_RSSTR_SMLR_MSK);
|
||||
return OK;
|
||||
}
|
||||
// higher resistor
|
||||
else if (value == 1) {
|
||||
LOG(logINFO, ("Setting Higher Filter Resistor\n"));
|
||||
bus_w(CONFIG_V11_REG,
|
||||
bus_r(CONFIG_V11_REG) & ~CONFIG_V11_FLTR_RSSTR_SMLR_MSK);
|
||||
return OK;
|
||||
}
|
||||
LOG(logERROR, ("Could not set Filter Resistor. Invalid value %d\n", value));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
int getTenGigaFlowControl() {
|
||||
return ((bus_r(CONFIG_REG) & CONFIG_ETHRNT_FLW_CNTRL_MSK) >>
|
||||
CONFIG_ETHRNT_FLW_CNTRL_OFST);
|
||||
|
||||
@@ -105,12 +105,14 @@ enum CLKINDEX { RUN_CLK, ADC_CLK, DBIT_CLK, NUM_CLOCKS };
|
||||
#define DEFAULT_STRG_CLL_STRT (0xf)
|
||||
#define DEFAULT_STRG_CLL_STRT_CHIP11 (0x3)
|
||||
#define DEFAULT_STRG_CLL_DLY (0)
|
||||
#define DEFAULT_FLIP_ROWS (0)
|
||||
#define DEFAULT_FILTER_RESISTOR (1) // higher resistor
|
||||
|
||||
#define HIGHVOLTAGE_MIN (60)
|
||||
#define HIGHVOLTAGE_MAX (200)
|
||||
#define DAC_MIN_MV (0)
|
||||
#define DAC_MAX_MV (2500)
|
||||
|
||||
|
||||
/* Defines in the Firmware */
|
||||
#define MAX_TIMESLOT_VAL (0x1F)
|
||||
#define MAX_THRESHOLD_TEMP_VAL (127999) // millidegrees
|
||||
|
||||
@@ -462,6 +462,8 @@ int setTemperatureEvent(int val);
|
||||
void alignDeserializer();
|
||||
int getFlipRows();
|
||||
void setFlipRows(int arg);
|
||||
int setFilterResistor(int value);
|
||||
int getFilterResistor();
|
||||
|
||||
// eiger specific - iodelay, pulse, rate, temp, activate, delay nw parameter
|
||||
#elif EIGERD
|
||||
@@ -533,8 +535,8 @@ int configureASICGlobalSettings();
|
||||
enum burstMode getBurstMode();
|
||||
int setCDSGain(int enable);
|
||||
int getCDSGain();
|
||||
int setFilter(int value);
|
||||
int getFilter();
|
||||
int setFilterResistor(int value);
|
||||
int getFilterResistor();
|
||||
void setCurrentSource(int value);
|
||||
int getCurrentSource();
|
||||
void setTimingSource(enum timingSourceType value);
|
||||
|
||||
@@ -229,8 +229,8 @@ int set_scan(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);
|
||||
int get_filter_resistor(int);
|
||||
int set_filter_resistor(int);
|
||||
int get_adc_config(int);
|
||||
int set_adc_config(int);
|
||||
int get_bad_channels(int);
|
||||
|
||||
@@ -354,8 +354,8 @@ void function_table() {
|
||||
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;
|
||||
flist[F_GET_FILTER_RESISTOR] = &get_filter_resistor;
|
||||
flist[F_SET_FILTER_RESISTOR] = &set_filter_resistor;
|
||||
flist[F_GET_ADC_CONFIGURATION] = &get_adc_config;
|
||||
flist[F_SET_ADC_CONFIGURATION] = &set_adc_config;
|
||||
flist[F_GET_BAD_CHANNELS] = &get_bad_channels;
|
||||
@@ -7771,49 +7771,57 @@ int set_cds_gain(int file_des) {
|
||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||
}
|
||||
|
||||
int get_filter(int file_des) {
|
||||
int get_filter_resistor(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int retval = -1;
|
||||
|
||||
LOG(logDEBUG1, ("Getting filter\n"));
|
||||
LOG(logDEBUG1, ("Getting filter resistor\n"));
|
||||
|
||||
#ifndef GOTTHARD2D
|
||||
#if !defined(GOTTHAR2D) && !defined(JUNGFRAUD)
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// get only
|
||||
retval = getFilter();
|
||||
LOG(logDEBUG1, ("filter retval: %u\n", retval));
|
||||
retval = getFilterResistor();
|
||||
LOG(logDEBUG1, ("filter resistor retval: %u\n", retval));
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
int set_filter(int file_des) {
|
||||
int set_filter_resistor(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));
|
||||
LOG(logINFO, ("Setting filter resistor: %u\n", arg));
|
||||
|
||||
#ifndef GOTTHARD2D
|
||||
#if !defined(GOTTHAR2D) && !defined(JUNGFRAUD)
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if (arg < 0 || arg > ASIC_FILTER_MAX_VALUE) {
|
||||
if (arg < 0 || arg > ASIC_FILTER_MAX_RES_VALUE) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
"Could not set filter. Invalid filter %d. "
|
||||
"Could not set filter resistor. Invalid filter argument %d. "
|
||||
"Options [0-%d]\n",
|
||||
arg, ASIC_FILTER_MAX_VALUE);
|
||||
arg, ASIC_FILTER_MAX_RES_VALUE);
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
setFilter(arg);
|
||||
int retval = getFilter();
|
||||
LOG(logDEBUG1, ("filter retval: %u\n", retval));
|
||||
validate(&ret, mess, arg, retval, "set filter", DEC);
|
||||
ret = setFilterResistor(arg);
|
||||
if (ret == FAIL) {
|
||||
ret = FAIL;
|
||||
strcpy(mess, "Could not set filter resistor.\n");
|
||||
LOG(logERROR, (mess));
|
||||
}
|
||||
#ifndef JUNGFRAUD
|
||||
// jungfrau might take time to update status register if acquiring
|
||||
int retval = getFilterResistor();
|
||||
LOG(logDEBUG1, ("filter resistor retval: %u\n", retval));
|
||||
validate(&ret, mess, arg, retval, "set filter resistor", DEC);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user