mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-24 23:30:03 +02:00
Niosmarie (#63)
* HV for Mythen3 server * HV for mythen3 server * corrected upstreams * missing endif
This commit is contained in:
parent
40b62ef5a4
commit
4b987abf41
@ -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:
|
||||
|
@ -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
|
Binary file not shown.
@ -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 */
|
||||
|
@ -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 */ \
|
||||
};
|
||||
|
||||
|
||||
|
@ -5,11 +5,10 @@
|
||||
/**
|
||||
* Set Defines
|
||||
* @param dofst digital output offset
|
||||
* @param softMaxV maximum software limit (permissible for this detector)
|
||||
* @param hardMaxV maximum hardware limit
|
||||
* @param driverfname driver file name
|
||||
*/
|
||||
void DAC6571_SetDefines(int softMaxV, int hardMaxV, char* driverfname);
|
||||
void DAC6571_SetDefines(int hardMaxV, char* driverfname);
|
||||
|
||||
/**
|
||||
* Set value
|
||||
|
@ -226,9 +226,9 @@ void powerOff();
|
||||
int getADC(enum ADCINDEX ind);
|
||||
#endif
|
||||
#endif
|
||||
#if !defined(MYTHEN3D)
|
||||
|
||||
int setHighVoltage(int val);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// parameters - timing, extsig
|
||||
@ -245,12 +245,12 @@ int getExtSignal();
|
||||
#ifdef GOTTHARDD
|
||||
void calcChecksum(mac_conf* mac, int sourceip, int destip);
|
||||
#elif JUNGFRAUD
|
||||
void setNumberofUDPInterfaces(int val);
|
||||
int getNumberofUDPInterfaces();
|
||||
void selectPrimaryInterface(int val);
|
||||
int getPrimaryInterface();
|
||||
void setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip, uint64_t destmac, uint32_t destport, uint64_t sourcemac, uint32_t sourceip, uint32_t sourceport);
|
||||
void calcChecksum(udp_header* udp);
|
||||
void setNumberofUDPInterfaces(int val);
|
||||
int getNumberofUDPInterfaces();
|
||||
void selectPrimaryInterface(int val);
|
||||
int getPrimaryInterface();
|
||||
void setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip, uint64_t destmac, uint32_t destport, uint64_t sourcemac, uint32_t sourceip, uint32_t sourceport);
|
||||
void calcChecksum(udp_header* udp);
|
||||
#endif
|
||||
#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
|
||||
long int calcChecksum(int sourceip, int destip);
|
||||
|
@ -11,13 +11,11 @@
|
||||
|
||||
|
||||
// defines from the hardware
|
||||
int DAC6571_SoftMaxVoltage = 0;
|
||||
int DAC6571_HardMaxVoltage = 0;
|
||||
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"));
|
||||
DAC6571_SoftMaxVoltage = softMaxV;
|
||||
DAC6571_HardMaxVoltage = hardMaxV;
|
||||
memset(DAC6571_DriverFileName, 0, MAX_STR_LENGTH);
|
||||
strcpy(DAC6571_DriverFileName, driverfname);
|
||||
@ -30,10 +28,7 @@ int DAC6571_Set (int val) {
|
||||
|
||||
int dacvalue = 0;
|
||||
|
||||
// limit values
|
||||
if (val > DAC6571_SoftMaxVoltage) {
|
||||
val = DAC6571_SoftMaxVoltage;
|
||||
}
|
||||
|
||||
// convert value
|
||||
ConvertToDifferentRange(0, DAC6571_HardMaxVoltage,
|
||||
DAC6571_MIN_DAC_VAL, DAC6571_MAX_DAC_VAL,
|
||||
@ -48,7 +43,7 @@ int DAC6571_Set (int val) {
|
||||
return FAIL;
|
||||
}
|
||||
//convert to string, add 0 and write to file
|
||||
fprintf(fd, "%d0\n", dacvalue);
|
||||
fprintf(fd, "%d\n", dacvalue);
|
||||
fclose(fd);
|
||||
|
||||
return OK;
|
||||
|
@ -668,9 +668,7 @@ int set_dac(int file_des) {
|
||||
if (receiveData(file_des, args, sizeof(args), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
|
||||
#if defined(MYTHEN3D)
|
||||
functionNotImplemented();
|
||||
#else
|
||||
|
||||
|
||||
enum dacIndex ind = args[0];
|
||||
int mV = args[1];
|
||||
@ -796,6 +794,10 @@ int set_dac(int file_des) {
|
||||
#elif GOTTHARD2D
|
||||
case HIGH_VOLTAGE:
|
||||
break;
|
||||
#elif MYTHEN3D
|
||||
case HIGH_VOLTAGE:
|
||||
break;
|
||||
|
||||
#endif
|
||||
default:
|
||||
#ifdef JUNGFRAUD
|
||||
@ -858,7 +860,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) || defined(GOTTHARD2D)
|
||||
#if defined(JUNGFRAUD) || defined (CHIPTESTBOARDD) || defined(MOENCHD) || defined(GOTTHARD2D) || defined(MYTHEN3D)
|
||||
validate(val, retval, "set high voltage", DEC);
|
||||
#endif
|
||||
#ifdef GOTTHARDD
|
||||
@ -965,6 +967,9 @@ int set_dac(int file_des) {
|
||||
#ifdef GOTTHARD2D
|
||||
default:
|
||||
break;
|
||||
#elif MYTHEN3D
|
||||
default:
|
||||
break;
|
||||
#else
|
||||
// dacs
|
||||
default:
|
||||
@ -1025,7 +1030,6 @@ int set_dac(int file_des) {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
#define APIMOENCH 0x190820
|
||||
#define APICTB 0x190902
|
||||
#define APIGOTTHARD 0x190902
|
||||
#define APIJUNGFRAU 0x190902
|
||||
#define APIGOTTHARD2 0x190902
|
||||
#define APIMYTHEN3 0x190902
|
||||
#define APIJUNGFRAU 0x190902
|
||||
#define APIEIGER 0x190902
|
||||
#define APIMYTHEN3 0x190903
|
||||
|
Loading…
x
Reference in New Issue
Block a user