From 9a777b13bb4c36307f761ef124e7407c23ba408f Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Wed, 11 Aug 2021 18:01:28 +0200 Subject: [PATCH] g2: dbitpipeline --- python/slsdet/detector.py | 7 +- .../slsDetectorFunctionList.c | 52 +++--- .../gotthard2DetectorServer/RegisterDefs.h | 10 + .../slsDetectorFunctionList.c | 16 ++ .../slsDetectorFunctionList.c | 28 +-- .../include/slsDetectorFunctionList.h | 8 +- .../include/slsDetectorServer_funcs.h | 8 +- .../src/slsDetectorServer_funcs.c | 172 +++++++++--------- slsDetectorSoftware/include/sls/Detector.h | 14 +- slsDetectorSoftware/src/CmdProxy.h | 12 +- slsDetectorSoftware/src/Detector.cpp | 21 ++- slsDetectorSoftware/src/Module.cpp | 17 +- slsDetectorSoftware/src/Module.h | 7 +- .../tests/test-CmdProxy-chiptestboard.cpp | 35 ---- slsDetectorSoftware/tests/test-CmdProxy.cpp | 50 +++++ .../include/sls/sls_detector_funcs.h | 12 +- 16 files changed, 258 insertions(+), 211 deletions(-) diff --git a/python/slsdet/detector.py b/python/slsdet/detector.py index a5ae81f57..dc513389c 100755 --- a/python/slsdet/detector.py +++ b/python/slsdet/detector.py @@ -2661,7 +2661,12 @@ class Detector(CppDetectorApi): @property @element def dbitpipeline(self): - """[Ctb] Pipeline of the clock for latching digital bits. """ + """[Ctb][Gotthard2] Pipeline of the clock for latching digital bits. + Note + ---- + [CTB] Options: 0 - 255 + [Gotthard2] Options: 0 - 7 + """ return self.getDBITPipeline() @dbitpipeline.setter diff --git a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c index f58030fbd..da84f3d86 100644 --- a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c @@ -1840,46 +1840,38 @@ void configureSyncFrequency(enum CLKINDEX ind) { setFrequency(SYNC_CLK, min); } -void setPipeline(enum CLKINDEX ind, int val) { - if (ind != ADC_CLK && ind != DBIT_CLK) { - LOG(logERROR, ("Unknown clock index %d to set pipeline\n", ind)); - return; - } +void setADCPipeline(int val) { if (val < 0) { return; } - char *clock_names[] = {CLK_NAMES}; - LOG(logINFO, - ("Setting %s clock (%d) Pipeline to %d\n", clock_names[ind], ind, val)); - uint32_t offset = ADC_OFFSET_ADC_PPLN_OFST; - uint32_t mask = ADC_OFFSET_ADC_PPLN_MSK; - if (ind == DBIT_CLK) { - offset = ADC_OFFSET_DBT_PPLN_OFST; - mask = ADC_OFFSET_DBT_PPLN_MSK; - } - + LOG(logINFO, ("Setting adc pipeline to %d\n", val)); uint32_t addr = ADC_OFFSET_REG; - // reset value - bus_w(addr, bus_r(addr) & ~mask); - // set value - bus_w(addr, bus_r(addr) | ((val << offset) & mask)); - LOG(logDEBUG1, - (" %s clock (%d) Offset: 0x%8x\n", clock_names[ind], ind, bus_r(addr))); + bus_w(addr, bus_r(addr) & ~ADC_OFFSET_ADC_PPLN_MSK); + bus_w(addr, bus_r(addr) | ((val << ADC_OFFSET_ADC_PPLN_OFST) & + ADC_OFFSET_ADC_PPLN_MSK)); } -int getPipeline(enum CLKINDEX ind) { - if (ind != ADC_CLK && ind != DBIT_CLK) { - LOG(logERROR, ("Unknown clock index %d to get pipeline\n", ind)); - return -1; - } - if (ind == DBIT_CLK) { - return ((bus_r(ADC_OFFSET_REG) & ADC_OFFSET_DBT_PPLN_MSK) >> - ADC_OFFSET_DBT_PPLN_OFST); - } +int getADCPipeline() { return ((bus_r(ADC_OFFSET_REG) & ADC_OFFSET_ADC_PPLN_MSK) >> ADC_OFFSET_ADC_PPLN_OFST); } +void setDBITPipeline(int val) { + if (val < 0) { + return; + } + LOG(logINFO, ("Setting dbit pipeline to %d\n", val)); + uint32_t addr = ADC_OFFSET_REG; + bus_w(addr, bus_r(addr) & ~ADC_OFFSET_DBT_PPLN_MSK); + bus_w(addr, bus_r(addr) | ((val << ADC_OFFSET_DBT_PPLN_OFST) & + ADC_OFFSET_DBT_PPLN_MSK)); +} + +int getDBITPipeline() { + return ((bus_r(ADC_OFFSET_REG) & ADC_OFFSET_DBT_PPLN_MSK) >> + ADC_OFFSET_DBT_PPLN_OFST); +} + int setLEDEnable(int enable) { uint32_t addr = CONFIG_REG; diff --git a/slsDetectorServers/gotthard2DetectorServer/RegisterDefs.h b/slsDetectorServers/gotthard2DetectorServer/RegisterDefs.h index b134051bb..f94dc511a 100644 --- a/slsDetectorServers/gotthard2DetectorServer/RegisterDefs.h +++ b/slsDetectorServers/gotthard2DetectorServer/RegisterDefs.h @@ -170,6 +170,16 @@ #define ASIC_CONT_FRAMES_LSB_REG (0x06 * REG_OFFSET + BASE_ASIC) #define ASIC_CONT_FRAMES_MSB_REG (0x07 * REG_OFFSET + BASE_ASIC) + +/* ADIF registers --------------------------------------------------*/ + +/* ADIF Config register */ +#define ADIF_CONFIG_REG (0x00 * REG_OFFSET + BASE_ADIF) + +#define ADIF_CONFIG_DBIT_PIPELINE_OFST (4) +#define ADIF_CONFIG_DBIT_PIPELINE_MSK (0x00000007 << ADIF_CONFIG_DBIT_PIPELINE_OFST) + + /* Packetizer -------------------------------------------------------------*/ /* Packetizer Config Register */ diff --git a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c index 1204403c1..ff45cce6e 100644 --- a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c @@ -1907,6 +1907,22 @@ int powerChip(int on) { CONTROL_PWR_CHIP_OFST); } +void setDBITPipeline(int val) { + if (val < 0) { + return; + } + LOG(logINFO, ("Setting dbit pipeline to %d\n", val)); + uint32_t addr = ADIF_CONFIG_REG; + bus_w(addr, bus_r(addr) & ~ADIF_CONFIG_DBIT_PIPELINE_MSK); + bus_w(addr, bus_r(addr) | ((val << ADIF_CONFIG_DBIT_PIPELINE_OFST) & + ADIF_CONFIG_DBIT_PIPELINE_MSK)); +} + +int getDBITPipeline() { + return ((bus_r(ADIF_CONFIG_REG) & ADIF_CONFIG_DBIT_PIPELINE_MSK) >> + ADIF_CONFIG_DBIT_PIPELINE_OFST); +} + int setPhase(enum CLKINDEX ind, int val, int degrees) { if (ind < 0 || ind >= NUM_CLOCKS) { LOG(logERROR, ("Unknown clock index %d to set phase\n", ind)); diff --git a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c index 6a24aaa2a..1b97e243c 100644 --- a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c @@ -550,7 +550,7 @@ void setupDetector() { LOG(logERROR, ("%s\n\n", initErrorMessage)); initError = FAIL; } - setPipeline(ADC_CLK, DEFAULT_PIPELINE); + setADCPipeline(DEFAULT_PIPELINE); if (initError != FAIL) { initError = loadPatternFile(DEFAULT_PATTERN_FILE, initErrorMessage); } @@ -1562,35 +1562,23 @@ void configureSyncFrequency(enum CLKINDEX ind) { setFrequency(SYNC_CLK, min); } -// adc pipeline only -void setPipeline(enum CLKINDEX ind, int val) { - if (ind != ADC_CLK) { - LOG(logERROR, ("Unknown clock index %d to set pipeline\n", ind)); - return; - } +void setADCPipeline(int val) { if (val < 0) { return; } - LOG(logINFO, ("Setting adc clock (%d) Pipeline to %d\n", ADC_CLK, val)); - uint32_t offset = ADC_OFFSET_ADC_PPLN_OFST; - uint32_t mask = ADC_OFFSET_ADC_PPLN_MSK; + LOG(logINFO, ("Setting adc pipeline to %d\n", val)); uint32_t addr = ADC_OFFSET_REG; - // reset value - bus_w(addr, bus_r(addr) & ~mask); - // set value - bus_w(addr, bus_r(addr) | ((val << offset) & mask)); - LOG(logDEBUG1, (" adc clock (%d) Offset: 0x%8x\n", ADC_CLK, bus_r(addr))); + bus_w(addr, bus_r(addr) & ~ADC_OFFSET_ADC_PPLN_MSK); + bus_w(addr, bus_r(addr) | ((val << ADC_OFFSET_ADC_PPLN_OFST) & + ADC_OFFSET_ADC_PPLN_MSK)); } -int getPipeline(enum CLKINDEX ind) { - if (ind != ADC_CLK) { - LOG(logERROR, ("Unknown clock index %d to get pipeline\n", ind)); - return -1; - } +int getADCPipeline() { return ((bus_r(ADC_OFFSET_REG) & ADC_OFFSET_ADC_PPLN_MSK) >> ADC_OFFSET_ADC_PPLN_OFST); } + /* aquisition */ int startStateMachine() { diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h index d2ff9f013..5a01aa509 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h @@ -430,11 +430,13 @@ int validatePhaseinDegrees(enum CLKINDEX ind, int val, int retval); int setFrequency(enum CLKINDEX ind, int val); int getFrequency(enum CLKINDEX ind); void configureSyncFrequency(enum CLKINDEX ind); -void setPipeline(enum CLKINDEX ind, int val); -int getPipeline(enum CLKINDEX ind); +void setADCPipeline(int val); +int getADCPipeline(); #endif #ifdef CHIPTESTBOARDD +void setDBITPipeline(int val); +int getDBITPipeline(); int setLEDEnable(int enable); void setDigitalIODelay(uint64_t pinMask, int delay); #endif @@ -519,6 +521,8 @@ int getClockDivider(enum CLKINDEX ind); #elif GOTTHARD2D int checkDetectorType(); int powerChip(int on); +void setDBITPipeline(int val); +int getDBITPipeline(); int setPhase(enum CLKINDEX ind, int val, int degrees); int getPhase(enum CLKINDEX ind, int degrees); int getMaxPhase(enum CLKINDEX ind); diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h index 040b64f18..b57b5a2bc 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h @@ -188,8 +188,6 @@ int get_clock_phase(int); int get_max_clock_phase_shift(int); int set_clock_divider(int); int get_clock_divider(int); -int set_pipeline(int); -int get_pipeline(int); int set_on_chip_dac(int); int get_on_chip_dac(int); int set_inject_channel(int); @@ -264,4 +262,8 @@ int set_comp_disable_time(int); int get_flip_rows(int); int set_flip_rows(int); int get_filter_cell(int); -int set_filter_cell(int); \ No newline at end of file +int set_filter_cell(int); +int set_adc_pipeline(int); +int get_adc_pipeline(int); +int set_dbit_pipeline(int); +int get_dbit_pipeline(int); \ No newline at end of file diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 8e506f21b..9271b7285 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -313,8 +313,6 @@ void function_table() { flist[F_GET_MAX_CLOCK_PHASE_SHIFT] = &get_max_clock_phase_shift; flist[F_SET_CLOCK_DIVIDER] = &set_clock_divider; flist[F_GET_CLOCK_DIVIDER] = &get_clock_divider; - flist[F_SET_PIPELINE] = &set_pipeline; - flist[F_GET_PIPELINE] = &get_pipeline; flist[F_SET_ON_CHIP_DAC] = &set_on_chip_dac; flist[F_GET_ON_CHIP_DAC] = &get_on_chip_dac; flist[F_SET_INJECT_CHANNEL] = &set_inject_channel; @@ -390,6 +388,10 @@ void function_table() { flist[F_SET_FLIP_ROWS] = &set_flip_rows; flist[F_GET_FILTER_CELL] = &get_filter_cell; flist[F_SET_FILTER_CELL] = &set_filter_cell; + flist[F_SET_ADC_PIPELINE] = &set_adc_pipeline; + flist[F_GET_ADC_PIPELINE] = &get_adc_pipeline; + flist[F_SET_DBIT_PIPELINE] = &set_dbit_pipeline; + flist[F_GET_DBIT_PIPELINE] = &get_dbit_pipeline; // check if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) { @@ -6075,91 +6077,6 @@ int get_clock_divider(int file_des) { return Server_SendResult(file_des, INT32, &retval, sizeof(retval)); } -int set_pipeline(int file_des) { - ret = OK; - memset(mess, 0, sizeof(mess)); - int args[2] = {-1, -1}; - - if (receiveData(file_des, args, sizeof(args), INT32) < 0) - return printSocketReadError(); - LOG(logDEBUG1, ("Setting clock (%d) pipeline : %u\n", args[0], args[1])); - -#if !defined(CHIPTESTBOARDD) && !defined(MOENCHD) - functionNotImplemented(); -#else - - // only set - if (Server_VerifyLock() == OK) { - int ind = args[0]; - int val = args[1]; - enum CLKINDEX c = 0; - switch (ind) { - case ADC_CLOCK: - c = ADC_CLK; - break; -#ifdef CHIPTESTBOARDD - case DBIT_CLOCK: - c = DBIT_CLK; - break; -#endif - default: - modeNotImplemented("clock index (pipeline set)", ind); - break; - } - - if (ret != FAIL) { - char *clock_names[] = {CLK_NAMES}; - char modeName[50] = ""; - sprintf(modeName, "%s clock (%d) piepline", clock_names[c], (int)c); - - setPipeline(c, val); - int retval = getPipeline(c); - LOG(logDEBUG1, ("retval %s: %d\n", modeName, retval)); - validate(&ret, mess, val, retval, modeName, DEC); - } - } -#endif - return Server_SendResult(file_des, INT32, NULL, 0); -} - -int get_pipeline(int file_des) { - ret = OK; - memset(mess, 0, sizeof(mess)); - int arg = -1; - int retval = -1; - - if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) - return printSocketReadError(); - LOG(logDEBUG1, ("Getting clock (%d) frequency\n", arg)); - -#if !defined(CHIPTESTBOARDD) && !defined(MOENCHD) - functionNotImplemented(); -#else - // get only - enum CLKINDEX c = 0; - switch (arg) { - case ADC_CLOCK: - c = ADC_CLK; - break; -#ifdef CHIPTESTBOARDD - case DBIT_CLOCK: - c = DBIT_CLK; - break; -#endif - default: - modeNotImplemented("clock index (pipeline get)", arg); - break; - } - if (ret == OK) { - retval = getPipeline(c); - char *clock_names[] = {CLK_NAMES}; - LOG(logDEBUG1, ("retval %s clock (%d) pipeline: %d\n", clock_names[c], - (int)c, retval)); - } -#endif - return Server_SendResult(file_des, INT32, &retval, sizeof(retval)); -} - int set_on_chip_dac(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); @@ -8926,3 +8843,84 @@ int set_filter_cell(int file_des) { #endif return Server_SendResult(file_des, INT32, NULL, 0); } + +int set_adc_pipeline(int file_des) { + ret = OK; + memset(mess, 0, sizeof(mess)); + int arg = -1; + + if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) + return printSocketReadError(); + LOG(logDEBUG1, ("Setting adc pipeline : %u\n", arg)); + +#if !defined(CHIPTESTBOARDD) && !defined(MOENCHD) + functionNotImplemented(); +#else + + // only set + if (Server_VerifyLock() == OK) { + setADCPipeline(arg); + int retval = getADCPipeline(); + LOG(logDEBUG1, ("retval adc pipeline: %d\n", retval)); + validate(&ret, mess, arg, retval, "set adc pipeline", DEC); + } +#endif + return Server_SendResult(file_des, INT32, NULL, 0); +} + +int get_adc_pipeline(int file_des) { + ret = OK; + memset(mess, 0, sizeof(mess)); + int retval = -1; + + LOG(logDEBUG1, ("Getting adc pipeline\n")); + +#if !defined(CHIPTESTBOARDD) && !defined(MOENCHD) + functionNotImplemented(); +#else + // get only + retval = getADCPipeline(); + LOG(logDEBUG1, ("retval adc pipeline: %d\n", retval)); +#endif + return Server_SendResult(file_des, INT32, &retval, sizeof(retval)); +} + +int set_dbit_pipeline(int file_des) { + ret = OK; + memset(mess, 0, sizeof(mess)); + int arg = -1; + + if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) + return printSocketReadError(); + LOG(logDEBUG1, ("Setting dbit pipeline : %u\n", arg)); + +#if !defined(CHIPTESTBOARDD) && !defined(GOTTHARD2D) + functionNotImplemented(); +#else + + // only set + if (Server_VerifyLock() == OK) { + setDBITPipeline(arg); + int retval = getDBITPipeline(); + LOG(logDEBUG1, ("retval dbit pipeline: %d\n", retval)); + validate(&ret, mess, arg, retval, "set dbit pipeline", DEC); + } +#endif + return Server_SendResult(file_des, INT32, NULL, 0); +} + +int get_dbit_pipeline(int file_des) { + ret = OK; + memset(mess, 0, sizeof(mess)); + int retval = -1; + LOG(logDEBUG1, ("Getting dbit pipeline\n")); + +#if !defined(CHIPTESTBOARDD) && !defined(GOTTHARD2D) + functionNotImplemented(); +#else + // get only + retval = getDBITPipeline(); + LOG(logDEBUG1, ("retval dbit pipeline: %d\n", retval)); +#endif + return Server_SendResult(file_des, INT32, &retval, sizeof(retval)); +} \ No newline at end of file diff --git a/slsDetectorSoftware/include/sls/Detector.h b/slsDetectorSoftware/include/sls/Detector.h index 62222039a..e5ee174d0 100644 --- a/slsDetectorSoftware/include/sls/Detector.h +++ b/slsDetectorSoftware/include/sls/Detector.h @@ -496,6 +496,12 @@ class Detector { * (sls_detector_defs.h) on the structure and its members */ void setCurrentSource(defs::currentSrcParameters par, Positions pos = {}); + /** [CTB][Gotthard2] */ + Result getDBITPipeline(Positions pos = {}) const; + + /** [CTB] Options: 0-255 \n [Gotthard2] Options: 0-7 */ + void setDBITPipeline(int value, Positions pos = {}); + ///@{ /** @name Acquisition */ @@ -1502,13 +1508,7 @@ class Detector { /** [CTB] */ void setDBITClock(int value_in_MHz, Positions pos = {}); - /** [CTB] */ - Result getDBITPipeline(Positions pos = {}) const; - - /** [CTB] */ - void setDBITPipeline(int value, Positions pos = {}); - - /** + /** * [CTB] mV * Options: V_POWER_A, V_POWER_B, V_POWER_C, V_POWER_D, V_POWER_IO */ Result getMeasuredVoltage(defs::dacIndex index, diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index 4719821f3..d772ff1bf 100644 --- a/slsDetectorSoftware/src/CmdProxy.h +++ b/slsDetectorSoftware/src/CmdProxy.h @@ -804,6 +804,7 @@ class CmdProxy { {"parallel", &CmdProxy::parallel}, {"filterresistor", &CmdProxy::filterresistor}, {"currentsource", &CmdProxy::CurrentSource}, + {"dbitpipeline", &CmdProxy::dbitpipeline}, /** temperature */ {"templist", &CmdProxy::templist}, @@ -986,7 +987,6 @@ class CmdProxy { {"dsamples", &CmdProxy::dsamples}, {"romode", &CmdProxy::romode}, {"dbitclk", &CmdProxy::dbitclk}, - {"dbitpipeline", &CmdProxy::dbitpipeline}, {"v_a", &CmdProxy::v_a}, {"v_b", &CmdProxy::v_b}, {"v_c", &CmdProxy::v_c}, @@ -1356,6 +1356,12 @@ class CmdProxy { "for increasing resistance.\n\t[Gotthard2] Options: [0|1|2|3]. Default " "is 0.\n\t[Jungfrau] Options: [0|1]. Default is 1."); + INTEGER_COMMAND_VEC_ID(dbitpipeline, getDBITPipeline, setDBITPipeline, + StringTo, + "[n_value]\n\t[Ctb][Gotthard2] Pipeline of the " + "clock for latching digital bits.\n\t[Gotthard2] " + "Options: 0-7\n\t[CTB] Options: 0-255"); + /** temperature */ GET_COMMAND_NOID( templist, getTemperatureList, @@ -1994,10 +2000,6 @@ class CmdProxy { dbitclk, getDBITClock, setDBITClock, StringTo, "[n_clk in MHz]\n\t[Ctb] Clock for latching the digital bits in MHz."); - INTEGER_COMMAND_VEC_ID( - dbitpipeline, getDBITPipeline, setDBITPipeline, StringTo, - "[n_value]\n\t[Ctb] Pipeline of the clock for latching digital bits."); - INTEGER_IND_COMMAND(v_a, getVoltage, setVoltage, StringTo, defs::V_POWER_A, "[n_value]\n\t[Ctb] Voltage supply a in mV."); diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index fa2697097..5652f85af 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -715,6 +715,15 @@ Detector::getCurrentSource(Positions pos) const { void Detector::setCurrentSource(defs::currentSrcParameters par, Positions pos) { pimpl->Parallel(&Module::setCurrentSource, pos, par); } + +Result Detector::getDBITPipeline(Positions pos) const { + return pimpl->Parallel(&Module::getDBITPipeline, pos); +} + +void Detector::setDBITPipeline(int value, Positions pos) { + pimpl->Parallel(&Module::setDBITPipeline, pos, value); +} + // Acquisition void Detector::acquire() { pimpl->acquire(); } @@ -1806,15 +1815,11 @@ Result Detector::getSYNCClock(Positions pos) const { } Result Detector::getADCPipeline(Positions pos) const { - return pimpl->Parallel(&Module::getPipeline, pos, defs::ADC_CLOCK); + return pimpl->Parallel(&Module::getADCPipeline, pos); } void Detector::setADCPipeline(int value, Positions pos) { - pimpl->Parallel(&Module::setPipeline, pos, defs::ADC_CLOCK, value); -} - -Result Detector::getDBITPipeline(Positions pos) const { - return pimpl->Parallel(&Module::getPipeline, pos, defs::DBIT_CLOCK); + pimpl->Parallel(&Module::setADCPipeline, pos, value); } Result Detector::getVoltage(defs::dacIndex index, Positions pos) const { @@ -1894,10 +1899,6 @@ void Detector::setDBITClock(int value_in_MHz, Positions pos) { value_in_MHz); } -void Detector::setDBITPipeline(int value, Positions pos) { - pimpl->Parallel(&Module::setPipeline, pos, defs::DBIT_CLOCK, value); -} - Result Detector::getMeasuredVoltage(defs::dacIndex index, Positions pos) const { switch (index) { diff --git a/slsDetectorSoftware/src/Module.cpp b/slsDetectorSoftware/src/Module.cpp index 60c1d8727..98bb9f400 100644 --- a/slsDetectorSoftware/src/Module.cpp +++ b/slsDetectorSoftware/src/Module.cpp @@ -720,6 +720,14 @@ void Module::setCurrentSource(defs::currentSrcParameters par) { sendToDetector(F_SET_CURRENT_SOURCE, par, nullptr); } +int Module::getDBITPipeline() const { + return sendToDetector(F_GET_DBIT_PIPELINE); +} + +void Module::setDBITPipeline(int value) { + sendToDetector(F_SET_DBIT_PIPELINE, value, nullptr); +} + // Acquisition void Module::startReceiver() { @@ -2107,13 +2115,12 @@ void Module::setNumberOfAnalogSamples(int value) { } } -int Module::getPipeline(int clkIndex) const { - return sendToDetector(F_GET_PIPELINE, clkIndex); +int Module::getADCPipeline() const { + return sendToDetector(F_GET_ADC_PIPELINE); } -void Module::setPipeline(int clkIndex, int value) { - int args[]{clkIndex, value}; - sendToDetector(F_SET_PIPELINE, args, nullptr); +void Module::setADCPipeline(int value) { + sendToDetector(F_SET_ADC_PIPELINE, value, nullptr); } uint32_t Module::getADCEnableMask() const { diff --git a/slsDetectorSoftware/src/Module.h b/slsDetectorSoftware/src/Module.h index 782b8f442..a4dc82410 100644 --- a/slsDetectorSoftware/src/Module.h +++ b/slsDetectorSoftware/src/Module.h @@ -174,6 +174,9 @@ class Module : public virtual slsDetectorDefs { void setFilterResistor(int value); defs::currentSrcParameters getCurrentSource() const; void setCurrentSource(defs::currentSrcParameters par); + int getDBITPipeline() const; + void setDBITPipeline(int value); + /************************************************** * * * Acquisition * @@ -454,8 +457,8 @@ class Module : public virtual slsDetectorDefs { * ************************************************/ int getNumberOfAnalogSamples() const; void setNumberOfAnalogSamples(int value); - int getPipeline(int clkIndex) const; - void setPipeline(int clkIndex, int value); + int getADCPipeline() const; + void setADCPipeline(int value); uint32_t getADCEnableMask() const; void setADCEnableMask(uint32_t mask); uint32_t getTenGigaADCEnableMask() const; diff --git a/slsDetectorSoftware/tests/test-CmdProxy-chiptestboard.cpp b/slsDetectorSoftware/tests/test-CmdProxy-chiptestboard.cpp index be2df1248..d77471a0c 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy-chiptestboard.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy-chiptestboard.cpp @@ -519,41 +519,6 @@ TEST_CASE("dbitclk", "[.cmd]") { } } -TEST_CASE("dbitpipeline", "[.cmd]") { - Detector det; - CmdProxy proxy(&det); - auto det_type = det.getDetectorType().squash(); - - if (det_type == defs::CHIPTESTBOARD) { - auto prev_val = det.getDBITPipeline(); - { - std::ostringstream oss; - proxy.Call("dbitpipeline", {"1"}, -1, PUT, oss); - REQUIRE(oss.str() == "dbitpipeline 1\n"); - } - { - std::ostringstream oss; - proxy.Call("dbitpipeline", {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == "dbitpipeline 0\n"); - } - { - std::ostringstream oss; - proxy.Call("dbitpipeline", {"15"}, -1, PUT, oss); - REQUIRE(oss.str() == "dbitpipeline 15\n"); - } - { - std::ostringstream oss; - proxy.Call("dbitpipeline", {}, -1, GET, oss); - REQUIRE(oss.str() == "dbitpipeline 15\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setDBITPipeline(prev_val[i], {i}); - } - } else { - REQUIRE_THROWS(proxy.Call("dbitpipeline", {}, -1, GET)); - } -} - TEST_CASE("v_a", "[.cmd]") { Detector det; CmdProxy proxy(&det); diff --git a/slsDetectorSoftware/tests/test-CmdProxy.cpp b/slsDetectorSoftware/tests/test-CmdProxy.cpp index c1e101a95..a018e20cc 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy.cpp @@ -1423,6 +1423,56 @@ TEST_CASE("filterresistor", "[.cmd]") { } } +TEST_CASE("dbitpipeline", "[.cmd]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::CHIPTESTBOARD || det_type == defs::GOTTHARD2) { + auto prev_val = det.getDBITPipeline(); + { + std::ostringstream oss; + proxy.Call("dbitpipeline", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "dbitpipeline 1\n"); + } + { + std::ostringstream oss; + proxy.Call("dbitpipeline", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "dbitpipeline 0\n"); + } + if (det_type == defs::CHIPTESTBOARD) { + { + std::ostringstream oss; + proxy.Call("dbitpipeline", {"15"}, -1, PUT, oss); + REQUIRE(oss.str() == "dbitpipeline 15\n"); + } + { + std::ostringstream oss; + proxy.Call("dbitpipeline", {}, -1, GET, oss); + REQUIRE(oss.str() == "dbitpipeline 15\n"); + } + REQUIRE_THROWS(proxy.Call("dbitpipeline", {"256"}, -1, PUT)); + } else { + { + std::ostringstream oss; + proxy.Call("dbitpipeline", {"7"}, -1, PUT, oss); + REQUIRE(oss.str() == "dbitpipeline 7\n"); + } + { + std::ostringstream oss; + proxy.Call("dbitpipeline", {}, -1, GET, oss); + REQUIRE(oss.str() == "dbitpipeline 7\n"); + } + REQUIRE_THROWS(proxy.Call("dbitpipeline", {"8"}, -1, PUT)); + } + for (int i = 0; i != det.size(); ++i) { + det.setDBITPipeline(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("dbitpipeline", {}, -1, GET)); + } +} + TEST_CASE("currentsource", "[.cmd]") { Detector det; CmdProxy proxy(&det); diff --git a/slsSupportLib/include/sls/sls_detector_funcs.h b/slsSupportLib/include/sls/sls_detector_funcs.h index 19748de11..6e0e43fde 100755 --- a/slsSupportLib/include/sls/sls_detector_funcs.h +++ b/slsSupportLib/include/sls/sls_detector_funcs.h @@ -164,8 +164,6 @@ enum detFuncs { F_GET_MAX_CLOCK_PHASE_SHIFT, F_SET_CLOCK_DIVIDER, F_GET_CLOCK_DIVIDER, - F_SET_PIPELINE, - F_GET_PIPELINE, F_SET_ON_CHIP_DAC, F_GET_ON_CHIP_DAC, F_SET_INJECT_CHANNEL, @@ -241,6 +239,10 @@ enum detFuncs { F_SET_FLIP_ROWS, F_GET_FILTER_CELL, F_SET_FILTER_CELL, + F_SET_ADC_PIPELINE, + F_GET_ADC_PIPELINE, + F_SET_DBIT_PIPELINE, + F_GET_DBIT_PIPELINE, NUM_DET_FUNCTIONS, RECEIVER_ENUM_START = 256, /**< detector function should not exceed this @@ -513,8 +515,6 @@ const char* getFunctionNameFromEnum(enum detFuncs func) { case F_GET_MAX_CLOCK_PHASE_SHIFT: return "F_GET_MAX_CLOCK_PHASE_SHIFT"; case F_SET_CLOCK_DIVIDER: return "F_SET_CLOCK_DIVIDER"; case F_GET_CLOCK_DIVIDER: return "F_GET_CLOCK_DIVIDER"; - case F_SET_PIPELINE: return "F_SET_PIPELINE"; - case F_GET_PIPELINE: return "F_GET_PIPELINE"; case F_SET_ON_CHIP_DAC: return "F_SET_ON_CHIP_DAC"; case F_GET_ON_CHIP_DAC: return "F_GET_ON_CHIP_DAC"; case F_SET_INJECT_CHANNEL: return "F_SET_INJECT_CHANNEL"; @@ -589,6 +589,10 @@ const char* getFunctionNameFromEnum(enum detFuncs func) { case F_SET_FLIP_ROWS: return "F_SET_FLIP_ROWS"; case F_GET_FILTER_CELL: return "F_GET_FILTER_CELL"; case F_SET_FILTER_CELL: return "F_SET_FILTER_CELL"; + case F_SET_ADC_PIPELINE: return "F_SET_ADC_PIPELINE"; + case F_GET_ADC_PIPELINE: return "F_GET_ADC_PIPELINE"; + case F_SET_DBIT_PIPELINE: return "F_SET_DBIT_PIPELINE"; + case F_GET_DBIT_PIPELINE: return "F_GET_DBIT_PIPELINE"; case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS"; case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";