Niosmarie (#63)

* HV for Mythen3 server

* HV for mythen3 server

* corrected upstreams

* missing endif
This commit is contained in:
Marie Andrä
2019-09-03 09:36:02 +02:00
committed by Dhanya Thattil
parent 40b62ef5a4
commit 4b987abf41
10 changed files with 98 additions and 37 deletions

View File

@ -3,7 +3,7 @@ main_inc = ../slsDetectorServer/include/
main_src = ../slsDetectorServer/src/ main_src = ../slsDetectorServer/src/
support_lib = ../../slsSupportLib/include/ support_lib = ../../slsSupportLib/include/
CROSS = bfin-uclinux- CROSS = nios2-buildroot-linux-gnu-
CC = $(CROSS)gcc CC = $(CROSS)gcc
CFLAGS += -Wall -DMYTHEN3D -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir)#-DVERBOSEI #-DVERBOSE CFLAGS += -Wall -DMYTHEN3D -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir)#-DVERBOSEI #-DVERBOSE
LDLIBS += -lm LDLIBS += -lm
@ -12,10 +12,11 @@ DESTDIR ?= bin
INSTMODE = 0777 INSTMODE = 0777
SRCS = slsDetectorFunctionList.c SRCS = slsDetectorFunctionList.c
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)blackfin.c SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)nios.c $(main_src)DAC6571.c $(main_src)common.c
OBJS = $(SRCS:.c=.o) OBJS = $(SRCS:.c=.o)
#all: clean $(PROGS)
all: clean versioning $(PROGS) all: clean versioning $(PROGS)
boot: $(OBJS) boot: $(OBJS)
@ -31,7 +32,6 @@ $(PROGS): $(OBJS)
mkdir -p $(DESTDIR) mkdir -p $(DESTDIR)
$(CC) -o $@ $^ $(CFLAGS) $(LDLIBS) $(CC) -o $@ $^ $(CFLAGS) $(LDLIBS)
mv $(PROGS) $(DESTDIR) mv $(PROGS) $(DESTDIR)
rm *.gdb
rm $(main_src)*.o rm $(main_src)*.o
clean: clean:

View File

@ -5,6 +5,9 @@
#define MEM_MAP_SHIFT 1 #define MEM_MAP_SHIFT 1
#ifdef VIRTUAL // until firmware is ready ----------------------------------
/* Status register */ /* Status register */
#define STATUS_REG (0x01 << MEM_MAP_SHIFT) #define STATUS_REG (0x01 << MEM_MAP_SHIFT)
@ -34,3 +37,4 @@
/* Get Frames 64 bit register */ /* Get Frames 64 bit register */
#define GET_FRAMES_LSB_REG (0x0C << MEM_MAP_SHIFT) #define GET_FRAMES_LSB_REG (0x0C << MEM_MAP_SHIFT)
#define GET_FRAMES_MSB_REG (0x0D << MEM_MAP_SHIFT) #define GET_FRAMES_MSB_REG (0x0D << MEM_MAP_SHIFT)
#endif

View File

@ -1,7 +1,9 @@
#include "slsDetectorFunctionList.h" #include "slsDetectorFunctionList.h"
#include "versionAPI.h" #include "versionAPI.h"
#include "clogger.h" #include "clogger.h"
#include "blackfin.h" #include "nios.h"
#include "DAC6571.h"
#include "common.h"
#ifdef VIRTUAL #ifdef VIRTUAL
#include "communication_funcs_UDP.h" #include "communication_funcs_UDP.h"
#endif #endif
@ -27,7 +29,7 @@ int virtual_status = 0;
int virtual_stop = 0; int virtual_stop = 0;
#endif #endif
int highvoltage = 0;
int isFirmwareCheckDone() { int isFirmwareCheckDone() {
return firmware_check_done; return firmware_check_done;
@ -55,11 +57,13 @@ void basictests() {
firmware_check_done = 1; firmware_check_done = 1;
return; return;
#else #else
// faking it
firmware_check_done = 1;
#endif #endif
} }
/* Ids */ /* Ids */
int64_t getDetectorId(enum idMode arg){ int64_t getDetectorId(enum idMode arg){
@ -149,7 +153,6 @@ u_int32_t getDetectorIP(){
return res; return res;
} }
/* initialization */ /* initialization */
void initControlServer(){ void initControlServer(){
@ -171,7 +174,11 @@ void initStopServer() {
void setupDetector() { void setupDetector() {
FILE_LOG(logINFO, ("This Server is for 1 Mythen3 module \n")); FILE_LOG(logINFO, ("This Server is for 1 Mythen3 module \n"));
//Initialization of acquistion parameters // hv
DAC6571_SetDefines(HV_HARD_MAX_VOLTAGE, HV_DRIVER_FILE_NAME);
setHighVoltage(DEFAULT_HIGH_VOLTAGE);
// Initialization of acquistion parameters
setTimer(FRAME_NUMBER, DEFAULT_NUM_FRAMES); setTimer(FRAME_NUMBER, DEFAULT_NUM_FRAMES);
setTimer(CYCLES_NUMBER, DEFAULT_NUM_CYCLES); setTimer(CYCLES_NUMBER, DEFAULT_NUM_CYCLES);
setTimer(ACQUISITION_TIME, DEFAULT_EXPTIME); setTimer(ACQUISITION_TIME, DEFAULT_EXPTIME);
@ -199,6 +206,7 @@ int getSpeed(enum speedVariable ind) {
int64_t setTimer(enum timerIndex ind, int64_t val) { int64_t setTimer(enum timerIndex ind, int64_t val) {
int64_t retval = -1; int64_t retval = -1;
#ifdef VIRTUAL
switch(ind){ switch(ind){
case FRAME_NUMBER: // defined in sls_detector_defs.h (general) case FRAME_NUMBER: // defined in sls_detector_defs.h (general)
@ -238,7 +246,7 @@ int64_t setTimer(enum timerIndex ind, int64_t val) {
FILE_LOG(logERROR, ("Timer Index not implemented for this detector: %d\n", ind)); FILE_LOG(logERROR, ("Timer Index not implemented for this detector: %d\n", ind));
break; break;
} }
#endif
return retval; return retval;
} }
@ -267,6 +275,7 @@ int64_t getTimeLeft(enum timerIndex ind){
#ifdef VIRTUAL #ifdef VIRTUAL
return 0; return 0;
#endif #endif
#ifdef VIRTUAL // until Firmware is there
int64_t retval = -1; int64_t retval = -1;
switch(ind){ switch(ind){
@ -284,10 +293,30 @@ int64_t getTimeLeft(enum timerIndex ind){
FILE_LOG(logERROR, ("Remaining Timer index not implemented for this detector: %d\n", ind)); FILE_LOG(logERROR, ("Remaining Timer index not implemented for this detector: %d\n", ind));
break; break;
} }
#endif
return -1; return -1;
} }
int setHighVoltage(int val){
// limit values
if (val > HV_SOFT_MAX_VOLTAGE ) {
val = HV_SOFT_MAX_VOLTAGE ;
}
#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) { int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport) {
#ifdef VIRTUAL #ifdef VIRTUAL
@ -406,9 +435,12 @@ u_int32_t runBusy() {
#ifdef VIRTUAL #ifdef VIRTUAL
return virtual_status; return virtual_status;
#endif #endif
#ifdef VIRTUAL
u_int32_t s = (bus_r(STATUS_REG) & RUN_BUSY_MSK); u_int32_t s = (bus_r(STATUS_REG) & RUN_BUSY_MSK);
FILE_LOG(logDEBUG1, ("Status Register: %08x\n", s)); FILE_LOG(logDEBUG1, ("Status Register: %08x\n", s));
return s; return s;
#endif
return -1;
} }
/* common */ /* common */

View File

@ -10,11 +10,38 @@
#define NCHIP (10) #define NCHIP (10)
#define NDAC (16) #define NDAC (16)
#define TEMP_CLK (20) /* MHz */ #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 */ /** Default Parameters */
#define DEFAULT_NUM_FRAMES (1) #define DEFAULT_NUM_FRAMES (1)
#define DEFAULT_NUM_CYCLES (1) #define DEFAULT_NUM_CYCLES (1)
#define DEFAULT_EXPTIME (100*1000*1000) //ns #define DEFAULT_EXPTIME (100*1000*1000) //ns
#define DEFAULT_PERIOD (2*1000*1000) //ns #define DEFAULT_PERIOD (2*1000*1000) //ns
#define DEFAULT_HIGH_VOLTAGE (0)
/* Enums */
enum DACINDEX {VIBIASSH, VTRIM, VIPRE, VRFSHNPOL, VTH1, VIPREOUT, VRF, VTH2, CAS, CASSH, VPL, VDCSH, VICIN, VICINSH, VICBIAS, VPH, VTH3, VRFSH};
#define DEFAULT_DAC_VALS {1200, /* vIbiasSh */ \
2300, /* vTrim */ \
2150, /* vIpre */ \
2300, /* VrfShNpol */ \
900, /* Vth1 */ \
1000, /* vIpreOut */ \
900, /* Vrf */ \
900, /* Vth2 */ \
1474, /* cas */ \
983, /* casSh */ \
900, /* VPL */ \
655, /* VdcSh */ \
1400, /* vIcin */ \
1400, /* vIcinSh */ \
1200, /* vIcbias */ \
960, /* VPH */ \
900, /* Vth3 */ \
1100 /* VrfSh */ \
};

View File

@ -5,11 +5,10 @@
/** /**
* Set Defines * Set Defines
* @param dofst digital output offset * @param dofst digital output offset
* @param softMaxV maximum software limit (permissible for this detector)
* @param hardMaxV maximum hardware limit * @param hardMaxV maximum hardware limit
* @param driverfname driver file name * @param driverfname driver file name
*/ */
void DAC6571_SetDefines(int softMaxV, int hardMaxV, char* driverfname); void DAC6571_SetDefines(int hardMaxV, char* driverfname);
/** /**
* Set value * Set value

View File

@ -226,9 +226,9 @@ void powerOff();
int getADC(enum ADCINDEX ind); int getADC(enum ADCINDEX ind);
#endif #endif
#endif #endif
#if !defined(MYTHEN3D)
int setHighVoltage(int val); int setHighVoltage(int val);
#endif
// parameters - timing, extsig // parameters - timing, extsig

View File

@ -11,13 +11,11 @@
// defines from the hardware // defines from the hardware
int DAC6571_SoftMaxVoltage = 0;
int DAC6571_HardMaxVoltage = 0; int DAC6571_HardMaxVoltage = 0;
char DAC6571_DriverFileName[MAX_STR_LENGTH]; char DAC6571_DriverFileName[MAX_STR_LENGTH];
void DAC6571_SetDefines(int softMaxV, int hardMaxV, char* driverfname) { void DAC6571_SetDefines(int hardMaxV, char* driverfname) {
FILE_LOG(logINFOBLUE, ("Configuring High Voltage\n")); FILE_LOG(logINFOBLUE, ("Configuring High Voltage\n"));
DAC6571_SoftMaxVoltage = softMaxV;
DAC6571_HardMaxVoltage = hardMaxV; DAC6571_HardMaxVoltage = hardMaxV;
memset(DAC6571_DriverFileName, 0, MAX_STR_LENGTH); memset(DAC6571_DriverFileName, 0, MAX_STR_LENGTH);
strcpy(DAC6571_DriverFileName, driverfname); strcpy(DAC6571_DriverFileName, driverfname);
@ -30,10 +28,7 @@ int DAC6571_Set (int val) {
int dacvalue = 0; int dacvalue = 0;
// limit values
if (val > DAC6571_SoftMaxVoltage) {
val = DAC6571_SoftMaxVoltage;
}
// convert value // convert value
ConvertToDifferentRange(0, DAC6571_HardMaxVoltage, ConvertToDifferentRange(0, DAC6571_HardMaxVoltage,
DAC6571_MIN_DAC_VAL, DAC6571_MAX_DAC_VAL, DAC6571_MIN_DAC_VAL, DAC6571_MAX_DAC_VAL,
@ -48,7 +43,7 @@ int DAC6571_Set (int val) {
return FAIL; return FAIL;
} }
//convert to string, add 0 and write to file //convert to string, add 0 and write to file
fprintf(fd, "%d0\n", dacvalue); fprintf(fd, "%d\n", dacvalue);
fclose(fd); fclose(fd);
return OK; return OK;

View File

@ -668,9 +668,7 @@ int set_dac(int file_des) {
if (receiveData(file_des, args, sizeof(args), INT32) < 0) if (receiveData(file_des, args, sizeof(args), INT32) < 0)
return printSocketReadError(); return printSocketReadError();
#if defined(MYTHEN3D)
functionNotImplemented();
#else
enum dacIndex ind = args[0]; enum dacIndex ind = args[0];
int mV = args[1]; int mV = args[1];
@ -796,6 +794,10 @@ int set_dac(int file_des) {
#elif GOTTHARD2D #elif GOTTHARD2D
case HIGH_VOLTAGE: case HIGH_VOLTAGE:
break; break;
#elif MYTHEN3D
case HIGH_VOLTAGE:
break;
#endif #endif
default: default:
#ifdef JUNGFRAUD #ifdef JUNGFRAUD
@ -858,7 +860,7 @@ int set_dac(int file_des) {
case HIGH_VOLTAGE: case HIGH_VOLTAGE:
retval = setHighVoltage(val); retval = setHighVoltage(val);
FILE_LOG(logDEBUG1, ("High Voltage: %d\n", retval)); FILE_LOG(logDEBUG1, ("High Voltage: %d\n", retval));
#if defined(JUNGFRAUD) || defined (CHIPTESTBOARDD) || defined(MOENCHD) || defined(GOTTHARD2D) #if defined(JUNGFRAUD) || defined (CHIPTESTBOARDD) || defined(MOENCHD) || defined(GOTTHARD2D) || defined(MYTHEN3D)
validate(val, retval, "set high voltage", DEC); validate(val, retval, "set high voltage", DEC);
#endif #endif
#ifdef GOTTHARDD #ifdef GOTTHARDD
@ -965,6 +967,9 @@ int set_dac(int file_des) {
#ifdef GOTTHARD2D #ifdef GOTTHARD2D
default: default:
break; break;
#elif MYTHEN3D
default:
break;
#else #else
// dacs // dacs
default: default:
@ -1025,7 +1030,6 @@ int set_dac(int file_des) {
} }
} }
} }
#endif
return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval)); return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval));
} }

View File

@ -6,7 +6,7 @@
#define APIMOENCH 0x190820 #define APIMOENCH 0x190820
#define APICTB 0x190902 #define APICTB 0x190902
#define APIGOTTHARD 0x190902 #define APIGOTTHARD 0x190902
#define APIJUNGFRAU 0x190902
#define APIGOTTHARD2 0x190902 #define APIGOTTHARD2 0x190902
#define APIMYTHEN3 0x190902 #define APIJUNGFRAU 0x190902
#define APIEIGER 0x190902 #define APIEIGER 0x190902
#define APIMYTHEN3 0x190903