diff --git a/slsDetectorServers/gotthard2DetectorServer/CMakeLists.txt b/slsDetectorServers/gotthard2DetectorServer/CMakeLists.txt index e4167e365..d0d55515d 100644 --- a/slsDetectorServers/gotthard2DetectorServer/CMakeLists.txt +++ b/slsDetectorServers/gotthard2DetectorServer/CMakeLists.txt @@ -4,7 +4,8 @@ add_executable(gotthard2DetectorServer_virtual ../slsDetectorServer/src/slsDetectorServer_funcs.c ../slsDetectorServer/src/communication_funcs.c ../slsDetectorServer/src/blackfin.c - ../slsDetectorServer/src/communication_funcs_UDP.c + ../slsDetectorServer/src/communication_funcs_UDP.c + ../slsDetectorServer/src/DAC6571.c ) include_directories( diff --git a/slsDetectorServers/gotthard2DetectorServer/Makefile b/slsDetectorServers/gotthard2DetectorServer/Makefile index 537b14987..1dcd25e1f 100755 --- a/slsDetectorServers/gotthard2DetectorServer/Makefile +++ b/slsDetectorServers/gotthard2DetectorServer/Makefile @@ -12,7 +12,7 @@ DESTDIR ?= bin INSTMODE = 0777 SRCS = slsDetectorFunctionList.c -SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)nios.c +SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)nios.c $(main_src)common.c $(main_src)DAC6571.c OBJS = $(SRCS:.c=.o) diff --git a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer index b9a5db12c..98e650c11 100755 Binary files a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer and b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer differ diff --git a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c index 3142b5dca..b5326be46 100644 --- a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c @@ -2,6 +2,8 @@ #include "versionAPI.h" #include "clogger.h" #include "blackfin.h" +#include "DAC6571.h" +#include "common.h" #ifdef VIRTUAL #include "communication_funcs_UDP.h" #endif @@ -29,6 +31,7 @@ int virtual_status = 0; int virtual_stop = 0; #endif +int highvoltage = 0; int isFirmwareCheckDone() { @@ -57,6 +60,8 @@ void basictests() { firmware_check_done = 1; return; #else + // faking it + firmware_check_done = 1; #endif @@ -173,6 +178,10 @@ void initStopServer() { void setupDetector() { FILE_LOG(logINFO, ("This Server is for 1 Gotthard2 module \n")); + // hv + DAC6571_SetDefines(HV_SOFT_MAX_VOLTAGE, HV_HARD_MAX_VOLTAGE, HV_DRIVER_FILE_NAME); + setHighVoltage(DEFAULT_HIGH_VOLTAGE); + //Initialization of acquistion parameters setTimer(FRAME_NUMBER, DEFAULT_NUM_FRAMES); setTimer(CYCLES_NUMBER, DEFAULT_NUM_CYCLES); @@ -286,6 +295,24 @@ int64_t getTimeLeft(enum timerIndex ind){ } + +int setHighVoltage(int val){ +#ifdef VIRTUAL + if (val >= 0) + highvoltage = val; + return highvoltage; +#endif + + // setting hv + if (val >= 0) { + FILE_LOG(logINFO, ("Setting High voltage: %d V", val)); + DAC6571_Set(val); + highvoltage = val; + } + return highvoltage; +} + + int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport) { #ifdef VIRTUAL char cDestIp[MAX_STR_LENGTH]; diff --git a/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h index 8d735a80b..c36022c38 100644 --- a/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h @@ -5,14 +5,22 @@ #define CTRL_SRVR_INIT_TIME_US (300 * 1000) + +/* Enums */ +enum DACINDEX {DAC0}; + /* Hardware Definitions */ #define NCHAN (128) #define NCHIP (10) #define NDAC (16) #define TEMP_CLK (20) /* MHz */ +#define HV_SOFT_MAX_VOLTAGE (200) +#define HV_HARD_MAX_VOLTAGE (530) +#define HV_DRIVER_FILE_NAME ("/root/devlinks/hvdac") /** Default Parameters */ #define DEFAULT_NUM_FRAMES (1) #define DEFAULT_NUM_CYCLES (1) #define DEFAULT_EXPTIME (1 * 1000 * 1000) // 1 ms -#define DEFAULT_PERIOD (1 * 1000 * 1000 * 1000) // 1 s \ No newline at end of file +#define DEFAULT_PERIOD (1 * 1000 * 1000 * 1000) // 1 s +#define DEFAULT_HIGH_VOLTAGE (0) \ No newline at end of file diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h index 5ebf24efc..ce91e0f3f 100755 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h @@ -215,7 +215,7 @@ void powerOff(); int getADC(enum ADCINDEX ind); #endif #endif -#if !defined(MYTHEN3D) && !defined(GOTTHARD2D) +#if !defined(MYTHEN3D) int setHighVoltage(int val); #endif diff --git a/slsDetectorServers/slsDetectorServer/src/DAC6571.c b/slsDetectorServers/slsDetectorServer/src/DAC6571.c index cce56168b..5ffd1454d 100755 --- a/slsDetectorServers/slsDetectorServer/src/DAC6571.c +++ b/slsDetectorServers/slsDetectorServer/src/DAC6571.c @@ -3,6 +3,8 @@ #include "common.h" #include "sls_detector_defs.h" +#include "string.h" + /* DAC6571 HV DEFINES */ #define DAC6571_MIN_DAC_VAL (0x0) #define DAC6571_MAX_DAC_VAL (0x3FF) @@ -42,7 +44,7 @@ int DAC6571_Set (int val) { //open file FILE* fd=fopen(DAC6571_DriverFileName,"w"); if (fd==NULL) { - FILE_LOG(logERROR, ("Could not open file for writing to set high voltage\n")); + FILE_LOG(logERROR, ("Could not open file %s for writing to set high voltage\n", DAC6571_DriverFileName)); return FAIL; } //convert to string, add 0 and write to file diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index fd9bd1b3a..5ce81b215 100755 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -654,7 +654,7 @@ int set_dac(int file_des) { if (receiveData(file_des, args, sizeof(args), INT32) < 0) return printSocketReadError(); -#if defined(MYTHEN3D) || defined(GOTTHARD2D) +#if defined(MYTHEN3D) functionNotImplemented(); #else @@ -779,6 +779,9 @@ int set_dac(int file_des) { case HIGH_VOLTAGE: case V_LIMIT: break; +#elif GOTTHARD2D + case HIGH_VOLTAGE: + break; #endif default: #ifdef JUNGFRAUD @@ -841,7 +844,7 @@ int set_dac(int file_des) { case HIGH_VOLTAGE: retval = setHighVoltage(val); FILE_LOG(logDEBUG1, ("High Voltage: %d\n", retval)); -#if defined(JUNGFRAUD) || defined (CHIPTESTBOARDD) || defined(MOENCHD) +#if defined(JUNGFRAUD) || defined (CHIPTESTBOARDD) || defined(MOENCHD) || defined(GOTTHARD2D) validate(val, retval, "set high voltage", DEC); #endif #ifdef GOTTHARDD @@ -945,7 +948,10 @@ int set_dac(int file_des) { validate(val, retval, "set vlimit", DEC); break; #endif - +#ifdef GOTTHARD2D + default: + break; +#elif // dacs default: if (mV && val > DAC_MAX_MV) { @@ -1001,6 +1007,7 @@ int set_dac(int file_des) { } FILE_LOG(logDEBUG1, ("Dac (%d): %d %s\n\n", serverDacIndex, retval, (mV ? "mV" : "dac units"))); break; +#endif } } } diff --git a/slsSupportLib/include/versionAPI.h b/slsSupportLib/include/versionAPI.h index 66a0c5e79..5e7d4ab73 100644 --- a/slsSupportLib/include/versionAPI.h +++ b/slsSupportLib/include/versionAPI.h @@ -9,4 +9,4 @@ #define APIJUNGFRAU 0x190830 #define APIMYTHEN3 0x190830 #define APIEIGER 0x190830 -#define APIGOTTHARD2 0x190830 +#define APIGOTTHARD2 0x190902