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/
support_lib = ../../slsSupportLib/include/
CROSS = bfin-uclinux-
CROSS = nios2-buildroot-linux-gnu-
CC = $(CROSS)gcc
CFLAGS += -Wall -DMYTHEN3D -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir)#-DVERBOSEI #-DVERBOSE
LDLIBS += -lm
@ -12,10 +12,11 @@ DESTDIR ?= bin
INSTMODE = 0777
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)
#all: clean $(PROGS)
all: clean versioning $(PROGS)
boot: $(OBJS)
@ -31,7 +32,6 @@ $(PROGS): $(OBJS)
mkdir -p $(DESTDIR)
$(CC) -o $@ $^ $(CFLAGS) $(LDLIBS)
mv $(PROGS) $(DESTDIR)
rm *.gdb
rm $(main_src)*.o
clean:

View File

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

View File

@ -1,7 +1,9 @@
#include "slsDetectorFunctionList.h"
#include "versionAPI.h"
#include "clogger.h"
#include "blackfin.h"
#include "nios.h"
#include "DAC6571.h"
#include "common.h"
#ifdef VIRTUAL
#include "communication_funcs_UDP.h"
#endif
@ -27,7 +29,7 @@ int virtual_status = 0;
int virtual_stop = 0;
#endif
int highvoltage = 0;
int isFirmwareCheckDone() {
return firmware_check_done;
@ -55,11 +57,13 @@ void basictests() {
firmware_check_done = 1;
return;
#else
// faking it
firmware_check_done = 1;
#endif
}
/* Ids */
int64_t getDetectorId(enum idMode arg){
@ -149,7 +153,6 @@ u_int32_t getDetectorIP(){
return res;
}
/* initialization */
void initControlServer(){
@ -171,7 +174,11 @@ void initStopServer() {
void setupDetector() {
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(CYCLES_NUMBER, DEFAULT_NUM_CYCLES);
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 retval = -1;
#ifdef VIRTUAL
switch(ind){
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));
break;
}
#endif
return retval;
}
@ -267,6 +275,7 @@ int64_t getTimeLeft(enum timerIndex ind){
#ifdef VIRTUAL
return 0;
#endif
#ifdef VIRTUAL // until Firmware is there
int64_t retval = -1;
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));
break;
}
#endif
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) {
#ifdef VIRTUAL
@ -406,9 +435,12 @@ u_int32_t runBusy() {
#ifdef VIRTUAL
return virtual_status;
#endif
#ifdef VIRTUAL
u_int32_t s = (bus_r(STATUS_REG) & RUN_BUSY_MSK);
FILE_LOG(logDEBUG1, ("Status Register: %08x\n", s));
return s;
#endif
return -1;
}
/* common */

View File

@ -10,11 +10,38 @@
#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 (100*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 */ \
};