diff --git a/slsDetectorServers/mythen3DetectorServer/RegisterDefs.h b/slsDetectorServers/mythen3DetectorServer/RegisterDefs.h index da52bdc9b..2e6612990 100644 --- a/slsDetectorServers/mythen3DetectorServer/RegisterDefs.h +++ b/slsDetectorServers/mythen3DetectorServer/RegisterDefs.h @@ -140,6 +140,13 @@ #define DTA_OFFSET_REG (0x24 * REG_OFFSET + BASE_CONTROL) +/* Formatting for data core -----------------------------------------------*/ +#define FMT_CONFIG_REG (0x00 * REG_OFFSET + BASE_FMT) + +#define FMT_CONFIG_TXN_DELAY_OFST (0) +#define FMT_CONFIG_TXN_DELAY_MSK (0x00FFFFFF << FMT_CONFIG_TXN_DELAY_OFST) + + /* Packetizer -------------------------------------------------------------*/ /* Packetizer Config Register */ diff --git a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer index a0233a721..7ba030459 100755 Binary files a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer and b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer differ diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c index 123fc9e15..e3347a839 100644 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c @@ -2067,6 +2067,28 @@ int getClockDivider(enum CLKINDEX ind) { return clkDivider[ind]; } +int getTransmissionDelayFrame() { + return ((bus_r(FMT_CONFIG_REG) & FMT_CONFIG_TXN_DELAY_MSK) >> + FMT_CONFIG_TXN_DELAY_OFST); +} + +int setTransmissionDelayFrame(int value) { + if (value < 0 || value > MAX_TIMESLOT_VAL) { + LOG(logERROR, ("Transmission delay %d should be in range: 0 - %d\n", + value, MAX_TIMESLOT_VAL)); + return FAIL; + } + LOG(logINFO, ("Setting transmission delay: %d\n", value)); + uint32_t addr = FMT_CONFIG_REG; + bus_w(addr, bus_r(addr) & ~FMT_CONFIG_TXN_DELAY_MSK); + bus_w(addr, (bus_r(addr) | ((value << FMT_CONFIG_TXN_DELAY_OFST) & + FMT_CONFIG_TXN_DELAY_MSK))); + LOG(logDEBUG1, ("Transmission delay read %d\n", + ((bus_r(addr) & FMT_CONFIG_TXN_DELAY_MSK) >> + FMT_CONFIG_TXN_DELAY_OFST))); + return OK; +} + /* aquisition */ int startStateMachine() { diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h index 7ba583474..3fd3dd250 100644 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h @@ -45,6 +45,7 @@ #define DEFAULT_MSTR_OTPT_P1_NUM_PULSES (20) /* Firmware Definitions */ +#define MAX_TIMESLOT_VAL (0xFFFFFF) #define IP_HEADER_SIZE (20) #define FIXED_PLL_FREQUENCY (020000000) // 20MHz #define READOUT_PLL_VCO_FREQ_HZ (1250000000) // 1.25GHz diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h index 134e9f50c..613f40554 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h @@ -531,6 +531,8 @@ int *getBadChannels(int *nch); #if defined(JUNGFRAUD) || defined(EIGERD) int getTenGigaFlowControl(); int setTenGigaFlowControl(int value); +#endif +#if defined(JUNGFRAUD) || defined(EIGERD) || defined(MYTHEN3D) int getTransmissionDelayFrame(); int setTransmissionDelayFrame(int value); #endif diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 8a1323660..ab24f4b18 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -3489,12 +3489,12 @@ int set_transmission_delay_frame(int file_des) { return printSocketReadError(); LOG(logINFO, ("Setting transmission delay frame: %d\n", arg)); -#if !defined(EIGERD) && !defined(JUNGFRAUD) +#if !defined(EIGERD) && !defined(JUNGFRAUD) && !defined(MYTHEN3D) functionNotImplemented(); #else // only set if (Server_VerifyLock() == OK) { -#ifdef JUNGFRAUD +#if defined(JUNGFRAUD) || defined(MYTHEN3D) if (arg > MAX_TIMESLOT_VAL) { ret = FAIL; sprintf(mess, "Transmission delay %d should be in range: 0 - %d\n", @@ -3526,7 +3526,7 @@ int get_transmission_delay_frame(int file_des) { LOG(logDEBUG1, ("Getting transmission delay frame\n")); -#if !defined(EIGERD) && !defined(JUNGFRAUD) +#if !defined(EIGERD) && !defined(JUNGFRAUD) && !defined(MYTHEN3D) functionNotImplemented(); #else // get only diff --git a/slsDetectorSoftware/include/Detector.h b/slsDetectorSoftware/include/Detector.h index ccd1641a3..5b7bcc96f 100644 --- a/slsDetectorSoftware/include/Detector.h +++ b/slsDetectorSoftware/include/Detector.h @@ -529,13 +529,13 @@ class Detector { /** [Eiger][CTB][Moench][Mythen3] */ void setTenGiga(bool value, Positions pos = {}); - /** [Eiger, Jungfrau] */ + /** [Eiger][Jungfrau] */ Result getTenGigaFlowControl(Positions pos = {}) const; - /** [Eiger, Jungfrau] */ + /** [Eiger][Jungfrau] */ void setTenGigaFlowControl(bool enable, Positions pos = {}); - /** [Eiger, Jungfrau] */ + /** [Eiger][Jungfrau][Mythen3] */ Result getTransmissionDelayFrame(Positions pos = {}) const; /** @@ -543,6 +543,8 @@ class Detector { * streamed out of the module. Options: 0 - 31, each value represenets 1 ms * [Eiger]: Sets the transmission delay of entire frame streamed out for * both left and right UDP ports. Options: //TODO possible values + * [Mythen3] Options: [0-16777215] Each value represents 8 ns (125 MHz + * clock), max is 134 ms. */ void setTransmissionDelayFrame(int value, Positions pos = {}); diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index 22e976eb6..dba9bbb41 100644 --- a/slsDetectorSoftware/src/CmdProxy.h +++ b/slsDetectorSoftware/src/CmdProxy.h @@ -1706,10 +1706,13 @@ class CmdProxy { INTEGER_COMMAND( txndelay_frame, getTransmissionDelayFrame, setTransmissionDelayFrame, StringTo, - "[n_delay]\n\t[Eiger][Jungfrau] Transmission delay of each image being " + "[n_delay]\n\t[Eiger][Jungfrau][Mythen3] Transmission delay of each " + "image being " "streamed out of the module.\n\t[Jungfrau] [0-31] Each value " "represents 1 ms\n\t[Eiger] Additional delay to txndelay_left and " - "txndelay_right. Each value represents 10ns. Typical value is 50000."); + "txndelay_right. Each value represents 10ns. Typical value is " + "50000.\n\t[Mythen3] [0-16777215] Each value represents 8 ns (125 MHz " + "clock), max is 134 ms."); INTEGER_COMMAND( txndelay_left, getTransmissionDelayLeft, setTransmissionDelayLeft, diff --git a/slsDetectorSoftware/tests/test-CmdProxy.cpp b/slsDetectorSoftware/tests/test-CmdProxy.cpp index f2ad5bd28..d98337fca 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy.cpp @@ -1648,7 +1648,8 @@ TEST_CASE("txndelay_frame", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::EIGER || det_type == defs::JUNGFRAU) { + if (det_type == defs::EIGER || det_type == defs::JUNGFRAU || + det_type == defs::MYTHEN3) { auto prev_val = det.getTransmissionDelayFrame(); auto val = 5000; if (det_type == defs::JUNGFRAU) { diff --git a/slsSupportLib/include/versionAPI.h b/slsSupportLib/include/versionAPI.h index 0da84a2f5..9fb0f288a 100644 --- a/slsSupportLib/include/versionAPI.h +++ b/slsSupportLib/include/versionAPI.h @@ -7,6 +7,6 @@ #define APIGOTTHARD 0x200810 #define APIGOTTHARD2 0x200810 #define APIJUNGFRAU 0x200810 -#define APIMYTHEN3 0x200810 #define APIMOENCH 0x200810 -#define APIEIGER 0x200818 +#define APIMYTHEN3 0x200818 +#define APIEIGER 0x200818