mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-01-16 07:01:33 +01:00
gotthard2: bursttype to burstmode
This commit is contained in:
Binary file not shown.
@@ -46,8 +46,7 @@ int injectedChannelsOffset = 0;
|
||||
int injectedChannelsIncrement = 0;
|
||||
int vetoReference[NCHIP][NCHAN];
|
||||
uint8_t adcConfiguration[NCHIP][NADC];
|
||||
int burstMode = 0;
|
||||
enum burstModeType burstType = INTERNAL;
|
||||
int burstMode = BURST_INTERNAL;
|
||||
int64_t exptime_ns = 0;
|
||||
int64_t period_ns = 0;
|
||||
int64_t nframes = 0;
|
||||
@@ -349,8 +348,7 @@ void setupDetector() {
|
||||
highvoltage = 0;
|
||||
injectedChannelsOffset = 0;
|
||||
injectedChannelsIncrement = 0;
|
||||
burstMode = 0;
|
||||
burstType = INTERNAL;
|
||||
burstMode = BURST_INTERNAL;
|
||||
exptime_ns = 0;
|
||||
period_ns = 0;
|
||||
nframes = 0;
|
||||
@@ -431,8 +429,6 @@ void setupDetector() {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
// set burst mode will take in burstType and also set it
|
||||
burstType = DEFAULT_BURST_TYPE;
|
||||
setBurstMode(DEFAULT_BURST_MODE);
|
||||
setSettings(DEFAULT_SETTINGS);
|
||||
|
||||
@@ -1667,10 +1663,10 @@ int configureSingleADCDriver(int chipIndex) {
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 0; i < NADC; ++i) {
|
||||
if (!burstMode) {
|
||||
if (burstMode == BURST_OFF) {
|
||||
values[i] |= ASIC_CONTINUOUS_MODE_MSK;
|
||||
}
|
||||
FILE_LOG(logDEBUG1, ("Value %d: 0x%02hhx\n", i, values[i]));
|
||||
FILE_LOG(logDEBUG2, ("Value %d: 0x%02hhx\n", i, values[i]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1746,14 +1742,39 @@ int configureADC() {
|
||||
return OK;
|
||||
}
|
||||
|
||||
int setBurstModeinFPGA(enum burstMode value) {
|
||||
uint32_t addr = ASIC_CONFIG_REG;
|
||||
uint32_t runmode = 0;
|
||||
switch (value) {
|
||||
case BURST_OFF:
|
||||
runmode = ASIC_CONFIG_RUN_MODE_CONT_VAL;
|
||||
break;
|
||||
case BURST_INTERNAL:
|
||||
runmode = ASIC_CONFIG_RUN_MODE_INT_BURST_VAL;
|
||||
break;
|
||||
case BURST_EXTERNAL:
|
||||
runmode = ASIC_CONFIG_RUN_MODE_EXT_BURST_VAL;
|
||||
break;
|
||||
default:
|
||||
FILE_LOG(logERROR, ("Unknown burst mode %d\n", value));
|
||||
return FAIL;
|
||||
}
|
||||
FILE_LOG(logDEBUG1, ("Run mode (FPGA val): %d\n", runmode));
|
||||
bus_w(addr, bus_r(addr) &~ ASIC_CONFIG_RUN_MODE_MSK);
|
||||
bus_w(addr, bus_r(addr) | ((runmode << ASIC_CONFIG_RUN_MODE_OFST) & ASIC_CONFIG_RUN_MODE_MSK));
|
||||
burstMode = value;
|
||||
return OK;
|
||||
}
|
||||
|
||||
int setBurstMode(int burst) {
|
||||
FILE_LOG(logINFO, ("Setting %s Mode\n", burst == 1 ? "Burst" : "Continuous"));
|
||||
burstMode = burst;
|
||||
setBurstType(burstType);
|
||||
int setBurstMode(enum burstMode burst) {
|
||||
FILE_LOG(logINFO, ("Setting burst mode to %s\n", burst == BURST_OFF ? "off" : (burst == BURST_INTERNAL ? "internal" : "external")));
|
||||
|
||||
FILE_LOG(logINFO, ("\tSetting %s Mode in Chip\n", burst == 1 ? "Burst" : "Continuous"));
|
||||
int value = burst ? ASIC_GLOBAL_BURST_VALUE : ASIC_GLOBAL_CONT_VALUE;
|
||||
if (setBurstModeinFPGA(burst) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
FILE_LOG(logINFO, ("\tSetting %s Mode in Chip\n", burstMode == BURST_OFF ? "Continuous" : "Burst"));
|
||||
int value = burstMode ? ASIC_GLOBAL_BURST_VALUE : ASIC_GLOBAL_CONT_VALUE;
|
||||
|
||||
const int padding = 6; // due to address (4) to make it byte aligned
|
||||
const int lenTotalBits = padding + ASIC_GLOBAL_SETT_MAX_BITS + ASIC_ADDR_MAX_BITS; // 4 + 6 + 4 = 16
|
||||
@@ -1794,58 +1815,28 @@ int setBurstMode(int burst) {
|
||||
return configureADC();
|
||||
}
|
||||
|
||||
int getBurstMode() {
|
||||
enum burstMode getBurstMode() {
|
||||
uint32_t addr = ASIC_CONFIG_REG;
|
||||
int runmode = bus_r (addr) & ASIC_CONFIG_RUN_MODE_MSK;
|
||||
switch (runmode) {
|
||||
case ASIC_CONFIG_RUN_MODE_CONT_VAL:
|
||||
return BURST_OFF;
|
||||
case ASIC_CONFIG_RUN_MODE_INT_BURST_VAL:
|
||||
return BURST_INTERNAL;
|
||||
case ASIC_CONFIG_RUN_MODE_EXT_BURST_VAL:
|
||||
return 1;
|
||||
return BURST_EXTERNAL;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void setBurstType(enum burstModeType val) {
|
||||
uint32_t addr = ASIC_CONFIG_REG;
|
||||
uint32_t runmode = ASIC_CONFIG_RUN_MODE_CONT_VAL;
|
||||
if (burstMode) {
|
||||
switch (val) {
|
||||
case INTERNAL:
|
||||
runmode = ASIC_CONFIG_RUN_MODE_INT_BURST_VAL;
|
||||
break;
|
||||
case EXTERNAL:
|
||||
runmode = ASIC_CONFIG_RUN_MODE_EXT_BURST_VAL;
|
||||
break;
|
||||
default:
|
||||
FILE_LOG(logERROR, ("Unknown burst type %d\n", val));
|
||||
return;
|
||||
}
|
||||
FILE_LOG(logDEBUG1, ("Run mode: %d\n", runmode));
|
||||
bus_w(addr, bus_r(addr) &~ ASIC_CONFIG_RUN_MODE_MSK);
|
||||
bus_w(addr, bus_r(addr) | ((runmode << ASIC_CONFIG_RUN_MODE_OFST) & ASIC_CONFIG_RUN_MODE_MSK));
|
||||
}
|
||||
}
|
||||
|
||||
enum burstModeType getBurstType() {
|
||||
uint32_t addr = ASIC_CONFIG_REG;
|
||||
int runmode = bus_r (addr) & ASIC_CONFIG_RUN_MODE_MSK;
|
||||
switch (runmode) {
|
||||
case ASIC_CONFIG_RUN_MODE_INT_BURST_VAL:
|
||||
return INTERNAL;
|
||||
case ASIC_CONFIG_RUN_MODE_EXT_BURST_VAL:
|
||||
return EXTERNAL;
|
||||
default:
|
||||
FILE_LOG(logERROR, ("Unknown burst type read from FPGA: %d\n", runmode));
|
||||
FILE_LOG(logERROR, ("Unknown run mode read from FPGA %d\n", runmode));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* aquisition */
|
||||
|
||||
int updateAcquisitionRegisters(char* mess) {
|
||||
// burst mode
|
||||
if (burstMode) {
|
||||
if (burstMode != BURST_OFF) {
|
||||
// validate #frames in burst mode
|
||||
if (nframes > MAX_FRAMES_IN_BURST_MODE) {
|
||||
sprintf(mess, "Could not start acquisition because number of frames %lld must be <= %d in burst mode.\n", (long long unsigned int)nframes, MAX_FRAMES_IN_BURST_MODE);
|
||||
|
||||
@@ -29,8 +29,7 @@
|
||||
#define TYPE_NO_MODULE_STARTING_VAL (800)
|
||||
|
||||
/** Default Parameters */
|
||||
#define DEFAULT_BURST_MODE (1)
|
||||
#define DEFAULT_BURST_TYPE (INTERNAL)
|
||||
#define DEFAULT_BURST_MODE (BURST_INTERNAL)
|
||||
#define DEFAULT_NUM_FRAMES (1)
|
||||
#define DEFAULT_NUM_CYCLES (1)
|
||||
#define DEFAULT_EXPTIME (1 * 1000 * 1000) // 1 ms
|
||||
|
||||
@@ -474,10 +474,9 @@ int setVetoPhoton(int chipIndex, int gainIndex, int* values);
|
||||
int getVetoPhoton(int chipIndex, int* retvals);
|
||||
int configureSingleADCDriver(int chipIndex);
|
||||
int configureADC();
|
||||
int setBurstMode(int burst);
|
||||
int getBurstMode();
|
||||
void setBurstType(enum burstModeType val);
|
||||
enum burstModeType getBurstType();
|
||||
int setBurstModeinFPGA(enum burstMode value);
|
||||
int setBurstMode(enum burstMode burst);
|
||||
enum burstMode getBurstMode();
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -206,5 +206,3 @@ int set_adc_enable_mask_10g(int);
|
||||
int get_adc_enable_mask_10g(int);
|
||||
int set_counter_mask(int);
|
||||
int get_counter_mask(int);
|
||||
int set_burst_type(int);
|
||||
int get_burst_type(int);
|
||||
|
||||
@@ -308,8 +308,6 @@ const char* getFunctionName(enum detFuncs func) {
|
||||
case F_GET_ADC_ENABLE_MASK_10G: return "F_GET_ADC_ENABLE_MASK_10G";
|
||||
case F_SET_COUNTER_MASK: return "F_SET_COUNTER_MASK";
|
||||
case F_GET_COUNTER_MASK: return "F_GET_COUNTER_MASK";
|
||||
case F_SET_BURST_TYPE: return "F_SET_BURST_TYPE";
|
||||
case F_GET_BURST_TYPE: return "F_GET_BURST_TYPE";
|
||||
|
||||
default: return "Unknown Function";
|
||||
}
|
||||
@@ -494,8 +492,6 @@ void function_table() {
|
||||
flist[F_GET_ADC_ENABLE_MASK_10G] = &get_adc_enable_mask_10g;
|
||||
flist[F_SET_COUNTER_MASK] = &set_counter_mask;
|
||||
flist[F_GET_COUNTER_MASK] = &get_counter_mask;
|
||||
flist[F_SET_BURST_TYPE] = &set_burst_type;
|
||||
flist[F_GET_BURST_TYPE] = &get_burst_type;
|
||||
|
||||
// check
|
||||
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
|
||||
@@ -6499,22 +6495,35 @@ int set_veto_reference(int file_des) {
|
||||
int set_burst_mode(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int arg = -1;
|
||||
enum burstMode arg = BURST_OFF;
|
||||
|
||||
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
FILE_LOG(logINFO, ("Setting burst mode: %d\n", arg));
|
||||
FILE_LOG(logDEBUG1, ("Setting burst mode: %d\n", arg));
|
||||
|
||||
#ifndef GOTTHARD2D
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
arg = arg == 0 ? 0 : 1;
|
||||
ret = setBurstMode(arg);
|
||||
if (ret == FAIL) {
|
||||
sprintf(mess, "Could not set burst mode to %d\n", arg);
|
||||
FILE_LOG(logERROR, (mess));
|
||||
switch (arg) {
|
||||
case BURST_OFF:
|
||||
case BURST_INTERNAL:
|
||||
case BURST_EXTERNAL:
|
||||
break;
|
||||
default:
|
||||
modeNotImplemented("Burst mode", (int)arg);
|
||||
break;
|
||||
}
|
||||
if (ret == OK) {
|
||||
setBurstMode(arg);
|
||||
enum burstMode retval = getBurstMode();
|
||||
FILE_LOG(logDEBUG, ("burst mode retval: %d\n", retval));
|
||||
if (retval != arg) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Could not set burst type. Set %d, got %d\n", arg, retval);
|
||||
FILE_LOG(logERROR, (mess));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -6525,7 +6534,7 @@ int set_burst_mode(int file_des) {
|
||||
int get_burst_mode(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int retval = -1;
|
||||
enum burstMode retval = BURST_OFF;
|
||||
|
||||
FILE_LOG(logDEBUG1, ("Getting burst mode\n"));
|
||||
|
||||
@@ -6534,7 +6543,7 @@ int get_burst_mode(int file_des) {
|
||||
#else
|
||||
// get only
|
||||
retval = getBurstMode();
|
||||
FILE_LOG(logDEBUG1, ("Get burst mode:%d\n", retval));
|
||||
FILE_LOG(logDEBUG1, ("Get burst mode retval:%d\n", retval));
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval));
|
||||
}
|
||||
@@ -6594,60 +6603,3 @@ int get_counter_mask(int file_des) {
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
|
||||
|
||||
int set_burst_type(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
enum burstModeType arg = 0;
|
||||
|
||||
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
|
||||
FILE_LOG(logINFO, ("Setting burst type: %d\n", arg));
|
||||
|
||||
#ifndef GOTTHARD2D
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
switch (arg) {
|
||||
case INTERNAL:
|
||||
case EXTERNAL:
|
||||
break;
|
||||
default:
|
||||
modeNotImplemented("Burst type", (int)arg);
|
||||
break;
|
||||
}
|
||||
if (ret == OK) {
|
||||
setBurstType(arg);
|
||||
enum burstModeType retval = getBurstType();
|
||||
FILE_LOG(logDEBUG, ("burst type retval: %d\n", retval));
|
||||
if (retval != arg) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Could not set burst type. Set %s, got %s\n", (arg == 0 ? "internal" : "external"), (retval == 0 ? "internal" : "external"));
|
||||
FILE_LOG(logERROR, (mess));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, UPDATE, NULL, 0);
|
||||
}
|
||||
|
||||
|
||||
int get_burst_type(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
enum burstModeType retval = 0;
|
||||
FILE_LOG(logDEBUG1, ("Getting burst type\n"));
|
||||
|
||||
#ifndef GOTTHARD2D
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// get only
|
||||
retval = getBurstType();
|
||||
FILE_LOG(logDEBUG, ("burst type retval: %d\n", retval));
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval));
|
||||
}
|
||||
Reference in New Issue
Block a user