added new jungfraustructure, wiht common detector tcp interface

This commit is contained in:
Dhanya Maliakal
2017-06-12 18:50:18 +02:00
parent b46da37932
commit d41abc2b1c
37 changed files with 39 additions and 5668 deletions

View File

@@ -1 +0,0 @@
*.gdb

View File

@@ -1 +0,0 @@
AXIS_BUILDTYPE ?= cris-axis-linux-gnu

View File

@@ -1,57 +1,26 @@
# $Id: Makefile,v 1.1.1.1 2006/02/04 03:35:01 freza Exp $
# first compile
# make cris-axis-linux-gnu
CROSS = bfin-uclinux-
CC = $(CROSS)gcc
CFLAGS += -Wall -DJUNGFRAUD -DSLS_DETECTOR_FUNCTION_LIST -DDACS_INT -DSTOP_SERVER #-DVERBOSEI #-DVERBOSE
LDLIBS += -lm -lstdc++
PROGS = jungfrauDetectorServer
DESTDIR ?= bin
INSTMODE = 0777
CROSS = bfin-uclinux-
CC = $(CROSS)gcc
SRC_CLNT = communication_funcs.c slsDetectorServer.c slsDetectorServer_funcs.c slsDetectorFunctionList.c
OBJS = $(SRC_CLNT:.c=.o)
all: clean $(PROGS)
CFLAGS += -Wall -DJUNGFRAUD -DMCB_FUNCS -DDACS_INT #-DVERBOSE #-DVERYVERBOSE #-DVIRTUAL
boot: $(OBJS)
PROGS= jungfrauDetectorServer
INSTDIR= /tftpboot
INSTMODE= 0777
BINS = testlib_sharedlibc
SRCS = server.c server_funcs.c communication_funcs.c firmware_funcs.c mcb_funcs.c
OBJS = $(SRCS:%.c=%.o)
all: clean $(PROGS)
test: clean jungfrauADCTEst
boot: $(OBJS)
jungfrauDetectorServer: $(OBJS)
echo $(OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS_$@) $(LDFLAGS_$@)
jungfrauADCTEst: $(OBJS)
echo $(OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS_$@) $(LDFLAGS_$@) -DTESTADC
install: $(PROGS)
$(INSTALL) -d $(INSTDIR)
$(INSTALL) -m $(INSTMODE) $(PROGS) $(INSTDIR)
romfs:
$(ROMFSINST) /bin/$(PROGS)
$(PROGS): $(OBJS)
echo $(OBJS)
mkdir -p $(DESTDIR)
$(CC) -o $@ $^ $(CFLAGS) $(LDLIBS)
mv $(PROGS) $(DESTDIR)
rm *.gdb
clean:
rm -rf $(PROGS) *.o *.gdb
rm -rf $(DESTDIR)/$(PROGS) *.o

View File

@@ -1,30 +1,25 @@
CC = gcc
CFLAGS += -Wall -DJUNGFRAUD -DSLS_DETECTOR_FUNCTION_LIST -DDACS_INT -DSTOP_SERVER #-DVERBOSEI #-DVERBOSE
LDLIBS += -lm -lstdc++
DESTDIR ?= ./
PROGS = jungfrauDetectorServer
DESTDIR ?= bin
INSTMODE = 0777
CC = gcc
CFLAGS += -Wall -DMOENCHD -DMCB_FUNCS -DDACS_INT -DDEBUG -DVIRTUAL
PROGS= $(DESTDIR)/moenchVirtualServer
SRCS = server.c server_funcs.c communication_funcs.c firmware_funcs.c mcb_funcs.c trimming_funcs.c sharedmemory.c
OBJS = $(SRCS:%.c=%.o)
moenchVirtualServer = $(PROGS)
all: clean $(PROGS)
SRC_CLNT = communication_funcs.c slsDetectorServer.c slsDetectorServer_funcs.c slsDetectorFunctionList.c
OBJS = $(SRC_CLNT:.c=.o)
all: clean $(PROGS)
boot: $(OBJS)
$(PROGS): $(OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS_$@) $(LDFLAGS_$@)
echo $(OBJS)
mkdir -p $(DESTDIR)
$(CC) -o $@ $^ $(CFLAGS) $(LDLIBS)
mv $(PROGS) $(DESTDIR)
rm *.gdb
clean:
rm -rf $(PROGS) *.o *.gdb
rm -rf $(DESTDIR)/$(PROGS) *.o

View File

@@ -1,11 +0,0 @@
add the following to /etc/rc before using programfpga command before cat motd
#registering 7th and 9th pin to linux kernel
echo 7 > /sys/class/gpio/export
echo 9 > /sys/class/gpio/export
#define direction for the linux kernel
echo in > /sys/class/gpio/gpio7/direction
echo out > /sys/class/gpio/gpio9/direction
#needed, else all write errors when server starts up, because linux tries to take control fof gpio
echo 1 > /sys/class/gpio/gpio9/value

View File

@@ -1,13 +1,9 @@
#ifndef REGISTERS_G_H
#define REGISTERS_G_H
#include "sls_detector_defs.h"
#ifndef REGISTER_DEFS_H
#define REGISTER_DEFS_H
/* Definitions for FPGA*/
#define CSP0 0x20200000
#define MEM_SIZE 0x100000
#define MEM_SIZE 0x100000
/* FPGA Version register */
#define FPGA_VERSION_REG (0x00 << 11)
@@ -88,13 +84,8 @@
#define GET_PERIOD_LSB_REG (0x18 << 11)
#define GET_PERIOD_MSB_REG (0x19 << 11)
/* Get Period 64 bit register */
#define GET_EXPTIME_LSB_REG (0x1A << 11)
#define GET_EXPTIME_MSB_REG (0x1B << 11)
/* Get Period 64 bit register */
#define GET_GATES_LSB_REG (0x1C << 11)
#define GET_GATES_MSB_REG (0x1D << 11)
/** Get Temperature Carlos, incorrectl as get gates */
#define GET_TEMPERATURE_TMP112_REG (0x1c << 11) // in 10ths of millidegrees of TMP112
/* Get Frames from Start 64 bit register (frames from start Run Control) */
#define FRAMES_FROM_START_PG_LSB_REG (0x24 << 11)
@@ -153,18 +144,18 @@
#define RX_MAC_MSB_REG (0x48 << 11)
#define RX_MAC_LSB_OFST (0)
#define RX_MAC_LSB_MSK (0x0000FFFF << RX_MAC_LSB_OFST)
#define RX_MAC_LSB_MSK (0xFFFFFFFF << RX_MAC_LSB_OFST)
#define RX_MAC_MSB_OFST (0)
#define RX_MAC_MSB_MSK (0x000000FF << RX_MAC_MSB_OFST)
#define RX_MAC_MSB_MSK (0x0000FFFF << RX_MAC_MSB_OFST)
/* Detector/ Transmitter Mac Address 64 bit Register */
#define TX_MAC_LSB_REG (0x49 << 11)
#define TX_MAC_MSB_REG (0x4A << 11)
#define TX_MAC_LSB_OFST (0)
#define TX_MAC_LSB_MSK (0x0000FFFF << TX_MAC_LSB_OFST)
#define TX_MAC_LSB_MSK (0xFFFFFFFF << TX_MAC_LSB_OFST)
#define TX_MAC_MSB_OFST (0)
#define TX_MAC_MSB_MSK (0x000000FF << TX_MAC_MSB_OFST)
#define TX_MAC_MSB_MSK (0x0000FFFF << TX_MAC_MSB_OFST)
/* Detector/ Transmitter IP Address Register */
#define TX_IP_REG (0x4B << 11)
@@ -173,7 +164,7 @@
#define TX_IP_CHECKSUM_REG (0x4C << 11)
#define TX_IP_CHECKSUM_OFST (0)
#define TX_IP_CHECKSUM_MSK (0x000000FF << TX_IP_CHECKSUM_OFST)
#define TX_IP_CHECKSUM_MSK (0x0000FFFF << TX_IP_CHECKSUM_OFST)
/* Configuration Register */
#define CONFIG_REG (0x4D << 11)
@@ -186,7 +177,7 @@
#define CONFIG_READOUT_SPEED_MSK (0x00000003 << CONFIG_READOUT_SPEED_OFST)
#define CONFIG_QUARTER_SPEED_10MHZ_VAL ((0x0 << CONFIG_READOUT_SPEED_OFST) & CONFIG_READOUT_SPEED_MSK)
#define CONFIG_HALF_SPEED_20MHZ_VAL ((0x1 << CONFIG_READOUT_SPEED_OFST) & CONFIG_READOUT_SPEED_MSK)
#define CONFIG_FULL_SPEED_VAL ((0x2 << CONFIG_READOUT_SPEED_OFST) & CONFIG_READOUT_SPEED_MSK)
#define CONFIG_FULL_SPEED_40MHZ_VAL ((0x2 << CONFIG_READOUT_SPEED_OFST) & CONFIG_READOUT_SPEED_MSK)
#define CONFIG_TDMA_OFST (24)
#define CONFIG_TDMA_MSK (0x00000001 << CONFIG_TDMA_OFST)
#define CONFIG_TDMA_DISABLE_VAL ((0x0 << CONFIG_TDMA_OFST) & CONFIG_TDMA_MSK)
@@ -233,9 +224,9 @@
#define PLL_CTRL_ADDR_MSK (0x0000003F << PLL_CTRL_ADDR_OFST)
/* Sample Register (Obsolete) */
#define SAMPLE_REG (0x59 << 11) /** carlos set speed differently*/
#define SAMPLE_REG (0x59 << 11)
#define SAMPLE_ADC_SAMPLE_SEL_OFST (0) /** carlos cant use the bits*/
#define SAMPLE_ADC_SAMPLE_SEL_OFST (0)
#define SAMPLE_ADC_SAMPLE_SEL_MSK (0x00000007 << SAMPLE_ADC_SAMPLE_SEL_OFST)
#define SAMPLE_ADC_SAMPLE_0_VAL ((0x0 << SAMPLE_ADC_SAMPLE_SEL_OFST) & SAMPLE_ADC_SAMPLE_SEL_MSK)
#define SAMPLE_ADC_SAMPLE_1_VAL ((0x1 << SAMPLE_ADC_SAMPLE_SEL_OFST) & SAMPLE_ADC_SAMPLE_SEL_MSK)
@@ -288,14 +279,6 @@
/** DAQ Register */
#define DAQ_REG (0x5D << 11) //TBD in firmware
/** carlos ?? */
/* settings/conf gain register */
#define GAIN_MASK 0x0000ffff
#define GAIN_OFFSET 0
#define SPEED_GAIN_MASK 0xf0000000
#define SPEED_GAIN_OFFSET 28
/***************/
/** Chip Power Register */
#define CHIP_POWER_REG (0x5E << 11)
@@ -337,6 +320,10 @@
#define COORD_0_Z_MSK (0x0000FFFF << COORD_0_Z_OFST)
#endif //REGISTERS_G_H
@@ -345,16 +332,7 @@
/**carlos */
#define SET_GATES_LSB_REG 106<<11//0x7c<<11
#define SET_GATES_MSB_REG 107<<11//0x7d<<11
/**ADC SYNC CLEAN FIFO*/
#define ADCSYNC_CLEAN_FIFO_BITS 0x300000
#define CLEAN_FIFO_MASK 0x0fffff
#endif

View File

@@ -1 +1 @@
/afs/psi.ch/project/sls_det_software/dhanya_softwareDevelopment/mySoft/slsDetectorsPackage/slsReceiverSoftware/include/ansi.h
../../slsReceiverSoftware/include/ansi.h

File diff suppressed because it is too large Load Diff

View File

@@ -1,127 +0,0 @@
#ifndef FIRMWARE_FUNCS_H
#define FIRMWARE_FUNCS_H
#include "sls_detector_defs.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <stdarg.h>
#include <unistd.h>
//#include <asm/page.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdarg.h>
#include <unistd.h>
int mapCSP0(void);
u_int16_t bus_w16(u_int32_t offset, u_int16_t data);
u_int16_t bus_r16(u_int32_t offset);
u_int16_t ram_w16(u_int32_t ramType, int adc, int adcCh, int Ch, u_int16_t data);
u_int16_t ram_r16(u_int32_t ramType, int adc, int adcCh, int Ch);
u_int32_t bus_w(u_int32_t offset, u_int32_t data);
u_int32_t bus_r(u_int32_t offset);
void initializeDetector();
int checkType();
void printVersions();
int testFifos(void);
u_int32_t testFpga(void);
u_int32_t testRAM(void);
int testBus(void);
u_int64_t getDetectorNumber();
u_int64_t getFirmwareVersion();
int64_t getId(enum idMode arg);
void defineGPIOpins();
void resetFPGA();
void FPGAdontTouchFlash();
void FPGATouchFlash();
void eraseFlash();
int startWritingFPGAprogram(FILE** filefp);
int stopWritingFPGAprogram(FILE* filefp);
int writeFPGAProgram(char* fpgasrc, size_t fsize, FILE* filefp);
long int calcChecksum(int sourceip, int destip);
void configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, int sourceip, uint32_t destport);
int64_t set64BitReg(int64_t value, int aLSB, int aMSB);
int64_t get64BitReg(int aLSB, int aMSB);
int64_t setFrames(int64_t value);
int64_t getFrames();
int64_t setExposureTime(int64_t value);
int64_t getExposureTime();
int64_t setGates(int64_t value);
int64_t getGates();
int64_t setDelay(int64_t value);
int64_t getDelay();
int64_t setPeriod(int64_t value);
int64_t getPeriod();
int64_t setTrains(int64_t value);
int64_t getTrains();
int64_t setProbes(int64_t value);
int64_t getProbes();
int64_t getActualTime();
int64_t getMeasurementTime();
int64_t getFramesFromStart();
u_int32_t runBusy(void);
int startStateMachine();
int stopStateMachine();
enum runStatus getStatus();
void waitForAcquisitionEnd();
void serializeToSPI(u_int32_t addr, u_int32_t val, u_int16_t csmask, int numbitstosend, u_int16_t clkmask, u_int16_t digoutmask, int digofset);
void initDac(int dacnum);
int setDac(int dacnum, int dacvalue);
int setHighVoltage(int val, int imod);
void setAdc(int addr, int val);
void prepareADC();
int setDynamicRange(int dr);
int getDynamicRange();
int getNModBoard();
int setNMod(int n);
int getNMod();
int powerChip (int on);
void cleanFifos();
void resetCore();
void resetPeripheral();
int adcPhase(int st);
int getPhase();
u_int32_t setClockDivider(int d);
u_int32_t getClockDivider();
int getTemperature(int tempSensor,int imod);
int initConfGain(int isettings,int val,int imod);
int initSpeedConfGain(int val);
void resetPLL();
u_int32_t setPllReconfigReg(u_int32_t reg, u_int32_t val);
void configurePll();
int loadImage(int index, short int ImageVals[]);
int readCounterBlock(int startACQ, short int CounterVals[]);
int resetCounterBlock(int startACQ);
int calibratePedestal(int frames);
int setTiming(int t);
int setMaster(int f);
int setSynchronization(int s);
#endif

View File

@@ -1,323 +0,0 @@
#ifdef MCB_FUNCS
#include "registers_m.h"
#include "server_defs.h"
#include "firmware_funcs.h"
#include "mcb_funcs.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>
/* global variables */
enum detectorSettings thisSettings;
int sChan, sChip, sMod, sDac, sAdc;
const int allSelected=-2;
const int noneSelected=-1;
sls_detector_module *detectorModules=NULL;
int *detectorChips=NULL;
int *detectorChans=NULL;
int *detectorDacs=NULL;
int *detectorAdcs=NULL;
int initDetector() {
int imod;
int n=getNModBoard();
#ifdef VERBOSE
printf("Board is for %d modules\n",n);
#endif
detectorModules=malloc(n*sizeof(sls_detector_module));
detectorDacs=malloc(n*NDAC*sizeof(int));
detectorAdcs=malloc(n*NADC*sizeof(int));
detectorChips=NULL;
detectorChans=NULL;
detectorAdcs=NULL;
#ifdef VERBOSE
printf("modules from 0x%x to 0x%x\n",(unsigned int)(detectorModules), (unsigned int)(detectorModules+n));
printf("dacs from 0x%x to 0x%x\n",(unsigned int)(detectorDacs), (unsigned int)(detectorDacs+n*NDAC));
printf("adcs from 0x%x to 0x%x\n",(unsigned int)(detectorAdcs), (unsigned int)(detectorAdcs+n*NADC));
#endif
for (imod=0; imod<n; imod++) {
(detectorModules+imod)->dacs=detectorDacs+imod*NDAC;
(detectorModules+imod)->adcs=detectorAdcs+imod*NADC;
(detectorModules+imod)->ndac=NDAC;
(detectorModules+imod)->nadc=NADC;
(detectorModules+imod)->nchip=NCHIP;
(detectorModules+imod)->nchan=NCHIP*NCHAN;
(detectorModules+imod)->module=imod;
(detectorModules+imod)->gain=0;
(detectorModules+imod)->offset=0;
(detectorModules+imod)->reg=0;
}
thisSettings=UNINITIALIZED;
sChan=noneSelected;
sChip=noneSelected;
sMod=noneSelected;
sDac=noneSelected;
sAdc=noneSelected;
return OK;
}
int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) {
int idac, iadc;
int ret=OK;
#ifdef VERBOSE
printf("Copying module %x to module %x\n",(unsigned int)(srcMod),(unsigned int)(destMod));
#endif
if (srcMod->module>=0) {
#ifdef VERBOSE
printf("Copying module number %d to module number %d\n",srcMod->module,destMod->module);
#endif
destMod->module=srcMod->module;
}
if (srcMod->serialnumber>=0){
/* #ifdef VERBOSE */
/* printf("Copying module serial number %x to module serial number %x\n",srcMod->serialnumber,destMod->serialnumber); */
/* #endif */
destMod->serialnumber=srcMod->serialnumber;
}
/*
if ((srcMod->nchip)>(destMod->nchip)) {
printf("Number of chip of source is larger than number of chips of destination\n");
return FAIL;
}
if ((srcMod->nchan)>(destMod->nchan)) {
printf("Number of channels of source is larger than number of channels of destination\n");
return FAIL;
}
*/
if ((srcMod->ndac)>(destMod->ndac)) {
printf("Number of dacs of source is larger than number of dacs of destination\n");
return FAIL;
}
if ((srcMod->nadc)>(destMod->nadc)) {
printf("Number of dacs of source is larger than number of dacs of destination\n");
return FAIL;
}
#ifdef VERBOSE
printf("DACs: src %d, dest %d\n",srcMod->ndac,destMod->ndac);
printf("ADCs: src %d, dest %d\n",srcMod->nadc,destMod->nadc);
//printf("Chips: src %d, dest %d\n",srcMod->nchip,destMod->nchip);
//printf("Chans: src %d, dest %d\n",srcMod->nchan,destMod->nchan);
#endif
destMod->ndac=srcMod->ndac;
destMod->nadc=srcMod->nadc;
// destMod->nchip=srcMod->nchip;
//destMod->nchan=srcMod->nchan;
if (srcMod->reg>=0)
destMod->reg=srcMod->reg;
#ifdef VERBOSE
printf("Copying register %x (%x)\n",destMod->reg,srcMod->reg );
#endif
if (srcMod->gain>=0)
destMod->gain=srcMod->gain;
if (srcMod->offset>=0)
destMod->offset=srcMod->offset;
// printf("copying gain and offset %f %f to %f %f\n",srcMod->gain,srcMod->offset,destMod->gain,destMod->offset);
for (idac=0; idac<(srcMod->ndac); idac++) {
if (*((srcMod->dacs)+idac)>=0)
*((destMod->dacs)+idac)=*((srcMod->dacs)+idac);
}
for (iadc=0; iadc<(srcMod->nadc); iadc++) {
if (*((srcMod->adcs)+iadc)>=0)
*((destMod->adcs)+iadc)=*((srcMod->adcs)+iadc);
}
return ret;
}
int setSettings(int i, int imod) {
//#ifdef VERBOSE
if(i!=-1)
printf("\nSetting settings wit value %d\n",i);
//#endif
int isett=-1,val=-1,retval=-1;
enum conf_gain {
dynamic = 0x0f00, //dynamic
dynamichighgain0 = v, //dynamichighgain0
fixgain1 = 0x0f02, //fixgain1
fixgain2 = 0x0f06, //fixgain2
forceswitchgain1 = 0x1f00, //forceswitchgain1
forceswitchgain2 = 0x3f00 //forceswitchgain2
};
//determine conf value to write
if(i!=GET_SETTINGS){
switch(i){
case DYNAMICGAIN: val = dynamic; break;
case DYNAMICHG0: val = dynamichighgain0; break;
case FIXGAIN1: val = fixgain1; break;
case FIXGAIN2: val = fixgain2; break;
case FORCESWITCHG1: val = forceswitchgain1; break;
case FORCESWITCHG2: val = forceswitchgain2; break;
default:
printf("Error: This settings is not defined for this detector %d\n",i);
return GET_SETTINGS;
}
}
retval = initConfGain(i,val,imod);
switch(retval){
case dynamic: isett=DYNAMICGAIN; break;
case dynamichighgain0: isett=DYNAMICHG0; break;
case fixgain1: isett=FIXGAIN1; break;
case fixgain2: isett=FIXGAIN2; break;
case forceswitchgain1: isett=FORCESWITCHG1; break;
case forceswitchgain2: isett=FORCESWITCHG2; break;
default:
isett=UNDEFINED;
printf("Error:Wrong settings read out from Gain Reg 0x%x\n",retval);
break;
}
thisSettings=isett;
//#ifdef VERBOSE
printf("detector settings are %d\n",thisSettings);
//#endif
return thisSettings;
}
/* Initialization*/
int initModulebyNumber(sls_detector_module myMod) {
printf("\nInitializing Module\n");
int nchip,nchan;//int ichip, nchip, ichan, nchan;
int im, modmi,modma;
// int ft, cae, ae, coe, ocoe, counts, chanreg;
int imod;
// int obe;
// int ow;
/* int v[NDAC];*/
int retval =-1, idac;
nchip=myMod.nchip;
nchan=(myMod.nchan)/nchip;
imod=myMod.module;
sMod=imod;
if (sMod==ALLMOD)
sMod=allSelected;
if (sMod==allSelected) {
modmi=0;
modma=NMODX;//getNModBoard();
} else if (sMod==noneSelected || sMod>NMODX || sMod<0) {// (sMod==noneSelected || sMod>getNModBoard() || sMod<0) {
modmi=0;
modma=-1;
} else {
modmi=sMod;
modma=sMod+1;
}
//printf("ndac:%d\n",NDAC);
for (idac=0; idac<NDAC; idac++){
retval = setDac(idac,(myMod.dacs)[idac]);
if(retval ==(myMod.dacs)[idac])
printf("Setting dac %d to %d\n",idac,retval);
else
printf("Error: Could not set dac %d, wrote %d but read %d\n",idac,(myMod.dacs)[idac],retval);
}
if (detectorModules) {
for (im=modmi; im<modma; im++) {
#ifdef VERBOSE
printf("im=%d\n",im);
#endif
copyModule(detectorModules+im,&myMod);
}
}
//setting the conf gain and the settings register
setSettings(myMod.reg,imod);
printf("Done Initializing Module\n");
return thisSettings;
}
int getModulebyNumber(sls_detector_module* myMod) {
int imod=myMod->module;
#ifdef VERBOSE
printf("Getting module %d\n",imod);
#endif
if (detectorModules) {
copyModule(myMod,detectorModules+imod);
;
} else
return FAIL;
return OK;
}
// Fifo continuous read
int getModuleNumber(int modnum) {
int val = 0xfff;
// val=readin(modnum);
return val;
}
#endif

View File

@@ -1,17 +0,0 @@
#ifdef MCB_FUNCS
#ifndef MCB_FUNCS_H
#define MCB_FUNCS_H
#include "sls_detector_defs.h"
int initDetector();
int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod);
int setSettings(int i,int imod);
int initModulebyNumber(sls_detector_module);
int getModulebyNumber(sls_detector_module*);
int getModuleNumber(int modnum);
#endif
#endif

View File

@@ -1,121 +0,0 @@
/* A simple server in the internet domain using TCP
The port number is passed as an argument */
#include "sls_detector_defs.h"
#include <stdlib.h>
#include "communication_funcs.h"
#include "server_funcs.h"
#include <string.h>
extern int sockfd;
extern int phase_shift;
void error(char *msg)
{
perror(msg);
}
int main(int argc, char *argv[])
{
int portno, b;
char cmd[500];
int retval=OK;
int sd, fd;
int iarg;
for(iarg=1; iarg<argc; iarg++){
if(!strcasecmp(argv[iarg],"-phaseshift")){
if(argc==iarg+1){
printf("No phaseshift given. Exiting.\n");
return 1;
}
if ( sscanf(argv[iarg+1],"%d",&phase_shift)==0) {
printf("could not decode phase shift\n");
return 1;
}
}
else if(!strcasecmp(argv[iarg],"-test")){
if(argc==iarg+1){
printf("No test condition given. Exiting.\n");
return 1;
}
}
}
//stop server
if ((argc > 2) && (!strcasecmp(argv[2],"stopserver"))){
portno = DEFAULT_PORTNO+1;
if ( sscanf(argv[1],"%d",&portno) ==0) {
printf("could not open stop server: unknown port\n");
return 1;
}
b=0;
printf("\n\nStop Server\nOpening stop server on port %d\n",portno);
}
//control server
else {
portno = DEFAULT_PORTNO;
sprintf(cmd,"%s %d stopserver &",argv[0],DEFAULT_PORTNO+1);
printf("\n\nControl Server\nOpening control server on port %d\n",portno );
//printf("\n\ncmd:%s\n",cmd);
system(cmd);
b=1;
}
init_detector(b);
sd=bindSocket(portno);
sockfd=sd;
if (getServerError(sd)) {
printf("server error!\n");
return -1;
}
/* assign function table */
function_table();
#ifdef VERBOSE
printf("function table assigned \n");
#endif
/* waits for connection */
while(retval!=GOODBYE) {
#ifdef VERBOSE
printf("\n");
#endif
#ifdef VERY_VERBOSE
printf("Waiting for client call\n");
#endif
fd=acceptConnection(sockfd);
#ifdef VERY_VERBOSE
printf("Conenction accepted\n");
#endif
retval=decode_function(fd);
#ifdef VERY_VERBOSE
printf("function executed\n");
#endif
closeConnection(fd);
#ifdef VERY_VERBOSE
printf("connection closed\n");
#endif
}
exitServer(sockfd);
printf("Goodbye!\n");
return 0;
}

View File

@@ -1,158 +0,0 @@
#ifndef SERVER_DEFS_H
#define SERVER_DEFS_H
#include "sls_detector_defs.h"
#include <stdint.h>
#define GOODBYE (-200)
/* Hardware Definitions */
#define NMAXMODY (1)
#define NMAXMODX (1)
#define NMAXMOD (NMAXMODX * NMAXMODY)
#define NMODY (1)
#define NMODX (1)
#define NMOD (NMODX * NMODY)
#define NCHAN (256 * 256)
#define NCHIP (8)
#define NADC (0)
#define NDAC (8)
#define NCHANS (NCHAN * NCHIP * NMAXMOD)
#define NDACS (NDAC * NMAXMOD)
#define DYNAMIC_RANGE (16)
#define DATA_BYTES (NMAXMOD * NCHIP * NCHAN * 2)
#define IP_PACKETSIZE (0x0522) /**carlos?? calcChecksum*/
#define UDP_PACKETSIZE (0x050E) /**carlos?? calcChecksum*/
#define CLK_EXPTIME (40) /** 0x28 better name? */
#define CLK_FC (20) /** 0x14 better name? */
#define CLK_FREQ 156.25E+6 /**carlos used in firmware_funcs.. but needed ?*/
/** Default Acqusition Parameters */
#define DEFAULT_NUM_FRAMES (1*1000*1000)
#define DEFAULT_NUM_CYCLES (0)
#define DEFAULT_EXPTIME (10*1000)
#define DEFAULT_PERIOD (2*1000*1000)
#define DEFAULT_DELAY (0)
#define DEFAULT_NUM_GATES (0)
#define DEFAULT_HIGH_VOLTAGE (0)
/* Other Default Values */
//enum DACNAMES { VB_COMP, VDD_PROT, VIN_COM, VREF_PRECH, VB_PIXBUF, VB_DS, VREF_DS, VREF_COMP };
#define DEFAULT_DAC_VALS { 1220, 3000, 1053, 1450, 750, 1000, 480, 420 };
enum adcVals {TEMP_FPGA, TEMP_ADC};
#define DEFAULT_SETTINGS (DYNAMICGAIN)
#define DEFAULT_TX_UDP_PORT (0x7e9a)
/* Defines in the Firmware */
#define FIX_PATT_VAL (0xACDC2014)
#define ADC_PORT_INVERT_VAL (0x453b2a9c)
#define ADC_OFST_HALF_SPEED_VAL (0x20)
#define ADC_OFST_QUARTER_SPEED_VAL (0x10)
#define SAMPLE_ADC_HALF_SPEED (0x7f7c)
#define SAMPLE_ADC_QUARTER_SPEED (0x8981)
#define DAQ_HALF_SPEED (0x0)
#define DAQ_QUARTER_SPEED (0xf)
#define ADC_PHASE_HALF_SPEED (0x41)
#define ADC_PHASE_QUARTER_SPEED (0x19)
/* Maybe not required for jungfrau */
#define NTRIMBITS (6)
#define NCOUNTBITS (24)
#define NCHIPS_PER_ADC (2)
#define TRIM_DR (((int)pow(2,NTRIMBITS))-1)
#define COUNT_DR (((int)pow(2,NCOUNTBITS))-1)
#define ALLMOD (0xffff)
#define ALLFIFO (0xffff)
/* LTC2620 DAC DEFINES */
#define LTC2620_DAC_CMD_OFST (20)
#define LTC2620_DAC_CMD_MSK (0x0000000F << LTC2620_DAC_CMD_OFST)
#define LTC2620_DAC_ADDR_OFST (16)
#define LTC2620_DAC_ADDR_MSK (0x0000000F << LTC2620_DAC_ADDR_OFST)
#define LTC2620_DAC_DATA_OFST (4)
#define LTC2620_DAC_DATA_MSK (0x00000FFF << LTC2620_DAC_DATA_OFST)
#define LTC2620_DAC_CMD_WRITE (0x00000000 << LTC2620_DAC_CMD_OFST)
#define LTC2620_DAC_CMD_SET (0x00000003 << LTC2620_DAC_CMD_OFST)
#define LTC2620_DAC_CMD_POWER_DOWN (0x00000004 << LTC2620_DAC_CMD_OFST)
#define LTC2620_DAC_NUMBITS (24)
/* MAX1932 HV DEFINES */
#define MAX1932_HV_NUMBITS (8)
#define MAX1932_HV_DATA_OFST (0)
#define MAX1932_HV_DATA_MSK (0x000000FF << MAX1932_HV_DATA_OFST)
/* AD9257 ADC DEFINES */
#define AD9257_ADC_NUMBITS (24)
#define AD9257_DEV_IND_2_REG (0x04)
#define AD9257_CHAN_H_OFST (0)
#define AD9257_CHAN_H_MSK (0x00000001 << AD9257_CHAN_H_OFST)
#define AD9257_CHAN_G_OFST (1)
#define AD9257_CHAN_G_MSK (0x00000001 << AD9257_CHAN_G_OFST)
#define AD9257_CHAN_F_OFST (2)
#define AD9257_CHAN_F_MSK (0x00000001 << AD9257_CHAN_F_OFST)
#define AD9257_CHAN_E_OFST (3)
#define AD9257_CHAN_E_MSK (0x00000001 << AD9257_CHAN_E_OFST)
#define AD9257_DEV_IND_1_REG (0x05)
#define AD9257_CHAN_D_OFST (0)
#define AD9257_CHAN_D_MSK (0x00000001 << AD9257_CHAN_D_OFST)
#define AD9257_CHAN_C_OFST (1)
#define AD9257_CHAN_C_MSK (0x00000001 << AD9257_CHAN_C_OFST)
#define AD9257_CHAN_B_OFST (2)
#define AD9257_CHAN_B_MSK (0x00000001 << AD9257_CHAN_B_OFST)
#define AD9257_CHAN_A_OFST (3)
#define AD9257_CHAN_A_MSK (0x00000001 << AD9257_CHAN_A_OFST)
#define AD9257_CLK_CH_DCO_OFST (4)
#define AD9257_CLK_CH_DCO_MSK (0x00000001 << AD9257_CLK_CH_DCO_OFST)
#define AD9257_CLK_CH_IFCO_OFST (5)
#define AD9257_CLK_CH_IFCO_MSK (0x00000001 << AD9257_CLK_CH_IFCO_OFST)
#define AD9257_POWER_MODE_REG (0x08)
#define AD9257_POWER_INTERNAL_OFST (0)
#define AD9257_POWER_INTERNAL_MSK (0x00000003 << AD9257_POWER_INTERNAL_OFST)
#define AD9257_INT_RESET_VAL (0x3)
#define AD9257_INT_CHIP_RUN_VAL (0x0)
#define AD9257_POWER_EXTERNAL_OFST (5)
#define AD9257_POWER_EXTERNAL_MSK (0x00000001 << AD9257_POWER_EXTERNAL_OFST)
#define AD9257_EXT_FULL_POWER_VAL (0x0)
#define AD9257_EXT_STANDBY_VAL (0x1)
#define AD9257_OUT_MODE_REG (0x14)
#define AD9257_OUT_FORMAT_OFST (0)
#define AD9257_OUT_FORMAT_MSK (0x00000001 << AD9257_OUT_FORMAT_OFST)
#define AD9257_OUT_BINARY_OFST_VAL (0)
#define AD9257_OUT_TWOS_COMPL_VAL (1)
#define AD9257_OUT_LVDS_OPT_OFST (6)
#define AD9257_OUT_LVDS_OPT_MSK (0x00000001 << AD9257_OUT_LVDS_OPT_OFST)
#define AD9257_OUT_LVDS_ANSI_VAL (0)
#define AD9257_OUT_LVDS_IEEE_VAL (1)
#define AD9257_OUT_PHASE_REG (0x16)
#define AD9257_OUT_CLK_OFST (0)
#define AD9257_OUT_CLK_MSK (0x0000000F << AD9257_OUT_CLK_OFST)
#define AD9257_OUT_CLK_60_VAL (0x1)
#define AD9257_IN_CLK_OFST (4)
#define AD9257_IN_CLK_MSK (0x00000007 << AD9257_IN_CLK_OFST)
#define AD9257_IN_CLK_0_VAL (0x0)
#define AD9257_VREF_REG (0x18)
#define AD9257_VREF_OFST (0)
#define AD9257_VREF_MSK (0x00000003 << AD9257_VREF_OFST)
#define AD9257_VREF_1_33_VAL (0x2)
#define AD9257_TEST_MODE_REG (0x0D)
#define AD9257_OUT_TEST_OFST (0)
#define AD9257_OUT_TEST_MSK (0x0000000F << AD9257_OUT_TEST_OFST)
#define AD9257_NONE_VAL (0x0)
#define AD9257_MIXED_BIT_FREQ_VAL (0xC)
#define AD9257_TEST_RESET_SHORT_GEN (4)
#define AD9257_TEST_RESET_LONG_GEN (5)
#define AD9257_USER_IN_MODE_OFST (6)
#define AD9257_USER_IN_MODE_MSK (0x00000003 << AD9257_USER_IN_MODE_OFST)
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,92 +0,0 @@
#ifndef SERVER_FUNCS_H
#define SERVER_FUNCS_H
#include "sls_detector_defs.h"
#include "communication_funcs.h"
#include <stdio.h>
#define GOODBYE (-200)
int sockfd;
int function_table();
int decode_function(int);
int init_detector(int);
int M_nofunc(int);
int exit_server(int);
int exec_command(int);
// General purpose functions
int get_detector_type(int);
int set_number_of_modules(int);
int get_max_number_of_modules(int);
int set_external_signal_flag(int);
int set_external_communication_mode(int);
int get_id(int);
int digital_test(int);
int write_register(int);
int read_register(int);
int set_dac(int);
int get_adc(int);
int set_channel(int);
int get_channel(int);
int set_chip(int);
int get_chip(int);
int set_module(int);
int get_module(int);
int get_threshold_energy(int);
int set_threshold_energy(int);
int set_settings(int);
int start_acquisition(int);
int stop_acquisition(int);
int start_readout(int);
int get_run_status(int);
int read_frame(int);
int read_all(int);
int start_and_read_all(int);
int set_timer(int);
int get_time_left(int);
int set_dynamic_range(int);
int set_roi(int);
int get_roi(int);
int set_speed(int);
int set_readout_flags(int);
int execute_trimming(int);
int lock_server(int);
int set_port(int);
int get_last_client_ip(int);
int send_update(int);
int update_client(int);
int configure_mac(int);
int load_image(int);
int set_master(int);
int set_synchronization(int);
int read_counter_block(int);
int reset_counter_block(int);
int start_receiver(int);
int stop_receiver(int);
int calibrate_pedestal(int);
int set_roi(int);
int write_adc_register(int);;
int program_fpga(int);
int reset_fpga(int);
int power_chip(int);
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1 @@
../slsDetectorServer/slsDetectorFunctionList.h

View File

@@ -0,0 +1 @@
../slsDetectorServer/slsDetectorServer.c

View File

@@ -0,0 +1,252 @@
#ifndef SLSDETECTORSERVER_DEFS_H
#define SLSDETECTORSERVER_DEFS_H
#include "sls_detector_defs.h" //default dynamicgain in settings
#include "RegisterDefs.h"
#include <stdint.h>
#define GOODBYE (-200)
#define CTRL_SRVR_INIT_TIME_US (300 * 1000)
//#define REQUIRED_FIRMWARE_VERSION 16
/* Struct Definitions */
typedef struct ip_header_struct {
uint16_t ip_len;
uint8_t ip_tos;
uint8_t ip_ihl:4 ,ip_ver:4;
uint16_t ip_offset:13,ip_flag:3;
uint16_t ip_ident;
uint16_t ip_chksum;
uint8_t ip_protocol;
uint8_t ip_ttl;
uint32_t ip_sourceip;
uint32_t ip_destip;
} ip_header;
/* Enums */
enum CLK_SPEED_INDEX {FULL_SPEED, HALF_SPEED, QUARTER_SPEED};
enum ADCINDEX {TEMP_FPGA, TEMP_ADC};
enum DACINDEX {VB_COMP, VDD_PROT, VIN_COM, VREF_PRECH, VB_PIXBUF, VB_DS, VREF_DS, VREF_COMP };
#define DEFAULT_DAC_VALS { 1220, /* VB_COMP */ \
3000, /* VDD_PROT */ \
1053, /* VIN_COM */ \
1450, /* VREF_PRECH */ \
750, /* VB_PIXBUF */ \
1000, /* VB_DS */ \
480, /* VREF_DS */ \
420 /* VREF_COMP */ \
};
#define NUM_SETTINGS 6
#define DEFAULT_SETT_INDX {DYNAMICGAIN, DYNAMICHG0, FIXGAIN1, FIXGAIN2, FORCESWITCHG1, FORCESWITCHG2};
#define DEFAULT_SETT_VALS { 0x0f00, /* DYNAMICGAIN */ \
0x0f01, /* DYNAMICHG0 */ \
0x0f02, /* FIXGAIN1 */ \
0x0f06, /* FIXGAIN2 */ \
0x1f00, /* FORCESWITCHG1 */ \
0x3f00 /* FORCESWITCHG2 */ \
};
#define DEFAULT_SETT_NAMES { "Dynamic Gain", /* DYNAMICGAIN */ \
"Dynamic High Gain 0", /* DYNAMICHG0 */ \
"Fix Gain 1", /* FIXGAIN1 */ \
"Fix Gain 2", /* FIXGAIN2 */ \
"Force Switch Gain 1", /* FORCESWITCHG1*/ \
"Force Switch Gain 2" /* FORCESWITCHG2*/ \
};
/* Hardware Definitions */
#define NMAXMOD (1)
#define NMOD (1)
#define NCHAN (256 * 256)
#define NCHIP (8)
#define NADC (0)
#define NDAC (8)
#define NDAC_OLDBOARD (16)
#define DYNAMIC_RANGE (16)
#define NUM_BITS_PER_PIXEL (DYNAMIC_RANGE / 8)
#define DATA_BYTES (NCHIP * NCHAN * NUM_BITS_PER_PIXEL)
#define IP_PACKETSIZE (0x2052)
#define CLK_RUN (40) /* MHz */
#define CLK_SYNC (20) /* MHz */
/** Default Parameters */
#define DEFAULT_NUM_FRAMES (100*1000*1000)
#define DEFAULT_NUM_CYCLES (1)
#define DEFAULT_EXPTIME (10*1000) //ns
#define DEFAULT_PERIOD (2*1000*1000) //ns
#define DEFAULT_DELAY (0)
#define DEFAULT_HIGH_VOLTAGE (0)
#define DEFAULT_TIMING_MODE (AUTO_TIMING)
#define DEFAULT_SETTINGS (DYNAMICGAIN)
#define DEFAULT_TX_UDP_PORT (0x7e9a)
/* Defines in the Firmware */
#define FIX_PATT_VAL (0xACDC2014)
#define ADC_PORT_INVERT_VAL (0x453b2a9c)
#define SAMPLE_ADC_HALF_SPEED (SAMPLE_DECMT_FACTOR_2_VAL + SAMPLE_DGTL_SAMPLE_0_VAL + SAMPLE_ADC_DECMT_FACTOR_0_VAL + SAMPLE_ADC_SAMPLE_0_VAL) /* 0x1000 */
#define SAMPLE_ADC_QUARTER_SPEED (SAMPLE_DECMT_FACTOR_4_VAL + SAMPLE_DGTL_SAMPLE_8_VAL + SAMPLE_ADC_DECMT_FACTOR_1_VAL + SAMPLE_ADC_SAMPLE_0_VAL) /* 0x2810 */
#define CONFIG_HALF_SPEED (CONFIG_TDMA_TIMESLOT_0_VAL + CONFIG_TDMA_DISABLE_VAL + CONFIG_HALF_SPEED_20MHZ_VAL + CONFIG_MODE_1_X_10GBE_VAL)
#define CONFIG_QUARTER_SPEED (CONFIG_TDMA_TIMESLOT_0_VAL + CONFIG_TDMA_DISABLE_VAL + CONFIG_QUARTER_SPEED_10MHZ_VAL + CONFIG_MODE_1_X_10GBE_VAL)
#define ADC_OFST_HALF_SPEED_VAL (0x20) //adc pipeline
#define ADC_OFST_QUARTER_SPEED_VAL (0x0f)
#define ADC_PHASE_HALF_SPEED (0x41)
#define ADC_PHASE_QUARTER_SPEED (0x19)
/* Maybe not required for jungfrau */
#define NTRIMBITS (6)
#define NCOUNTBITS (24)
#define NCHIPS_PER_ADC (2)
#define TRIM_DR (((int)pow(2,NTRIMBITS))-1)
#define COUNT_DR (((int)pow(2,NCOUNTBITS))-1)
#define ALLMOD (0xffff)
#define ALLFIFO (0xffff)
/* MSB & LSB DEFINES */
#define MSB_OF_64_BIT_REG_OFST (32)
#define LSB_OF_64_BIT_REG_OFST (0)
#define BIT_32_MSK (0xFFFFFFFF)
/* LTC2620 DAC DEFINES */
#define LTC2620_DAC_CMD_OFST (20)
#define LTC2620_DAC_CMD_MSK (0x0000000F << LTC2620_DAC_CMD_OFST)
#define LTC2620_DAC_ADDR_OFST (16)
#define LTC2620_DAC_ADDR_MSK (0x0000000F << LTC2620_DAC_ADDR_OFST)
#define LTC2620_DAC_DATA_OFST (4)
#define LTC2620_DAC_DATA_MSK (0x00000FFF << LTC2620_DAC_DATA_OFST)
#define LTC2620_DAC_CMD_WRITE (0x00000000 << LTC2620_DAC_CMD_OFST)
#define LTC2620_DAC_CMD_SET (0x00000003 << LTC2620_DAC_CMD_OFST)
#define LTC2620_DAC_CMD_POWER_DOWN (0x00000004 << LTC2620_DAC_CMD_OFST)
#define LTC2620_DAC_NUMBITS (24)
/* MAX1932 HV DEFINES */
#define MAX1932_HV_NUMBITS (8)
#define MAX1932_HV_DATA_OFST (0)
#define MAX1932_HV_DATA_MSK (0x000000FF << MAX1932_HV_DATA_OFST)
/* AD9257 ADC DEFINES */
#define AD9257_ADC_NUMBITS (24)
#define AD9257_DEV_IND_2_REG (0x04)
#define AD9257_CHAN_H_OFST (0)
#define AD9257_CHAN_H_MSK (0x00000001 << AD9257_CHAN_H_OFST)
#define AD9257_CHAN_G_OFST (1)
#define AD9257_CHAN_G_MSK (0x00000001 << AD9257_CHAN_G_OFST)
#define AD9257_CHAN_F_OFST (2)
#define AD9257_CHAN_F_MSK (0x00000001 << AD9257_CHAN_F_OFST)
#define AD9257_CHAN_E_OFST (3)
#define AD9257_CHAN_E_MSK (0x00000001 << AD9257_CHAN_E_OFST)
#define AD9257_DEV_IND_1_REG (0x05)
#define AD9257_CHAN_D_OFST (0)
#define AD9257_CHAN_D_MSK (0x00000001 << AD9257_CHAN_D_OFST)
#define AD9257_CHAN_C_OFST (1)
#define AD9257_CHAN_C_MSK (0x00000001 << AD9257_CHAN_C_OFST)
#define AD9257_CHAN_B_OFST (2)
#define AD9257_CHAN_B_MSK (0x00000001 << AD9257_CHAN_B_OFST)
#define AD9257_CHAN_A_OFST (3)
#define AD9257_CHAN_A_MSK (0x00000001 << AD9257_CHAN_A_OFST)
#define AD9257_CLK_CH_DCO_OFST (4)
#define AD9257_CLK_CH_DCO_MSK (0x00000001 << AD9257_CLK_CH_DCO_OFST)
#define AD9257_CLK_CH_IFCO_OFST (5)
#define AD9257_CLK_CH_IFCO_MSK (0x00000001 << AD9257_CLK_CH_IFCO_OFST)
#define AD9257_POWER_MODE_REG (0x08)
#define AD9257_POWER_INTERNAL_OFST (0)
#define AD9257_POWER_INTERNAL_MSK (0x00000003 << AD9257_POWER_INTERNAL_OFST)
#define AD9257_INT_RESET_VAL (0x3)
#define AD9257_INT_CHIP_RUN_VAL (0x0)
#define AD9257_POWER_EXTERNAL_OFST (5)
#define AD9257_POWER_EXTERNAL_MSK (0x00000001 << AD9257_POWER_EXTERNAL_OFST)
#define AD9257_EXT_FULL_POWER_VAL (0x0)
#define AD9257_EXT_STANDBY_VAL (0x1)
#define AD9257_OUT_MODE_REG (0x14)
#define AD9257_OUT_FORMAT_OFST (0)
#define AD9257_OUT_FORMAT_MSK (0x00000001 << AD9257_OUT_FORMAT_OFST)
#define AD9257_OUT_BINARY_OFST_VAL (0)
#define AD9257_OUT_TWOS_COMPL_VAL (1)
#define AD9257_OUT_LVDS_OPT_OFST (6)
#define AD9257_OUT_LVDS_OPT_MSK (0x00000001 << AD9257_OUT_LVDS_OPT_OFST)
#define AD9257_OUT_LVDS_ANSI_VAL (0)
#define AD9257_OUT_LVDS_IEEE_VAL (1)
#define AD9257_OUT_PHASE_REG (0x16)
#define AD9257_OUT_CLK_OFST (0)
#define AD9257_OUT_CLK_MSK (0x0000000F << AD9257_OUT_CLK_OFST)
#define AD9257_OUT_CLK_60_VAL (0x1)
#define AD9257_IN_CLK_OFST (4)
#define AD9257_IN_CLK_MSK (0x00000007 << AD9257_IN_CLK_OFST)
#define AD9257_IN_CLK_0_VAL (0x0)
#define AD9257_VREF_REG (0x18)
#define AD9257_VREF_OFST (0)
#define AD9257_VREF_MSK (0x00000003 << AD9257_VREF_OFST)
#define AD9257_VREF_1_33_VAL (0x2)
#define AD9257_TEST_MODE_REG (0x0D)
#define AD9257_OUT_TEST_OFST (0)
#define AD9257_OUT_TEST_MSK (0x0000000F << AD9257_OUT_TEST_OFST)
#define AD9257_NONE_VAL (0x0)
#define AD9257_MIXED_BIT_FREQ_VAL (0xC)
#define AD9257_TEST_RESET_SHORT_GEN (4)
#define AD9257_TEST_RESET_LONG_GEN (5)
#define AD9257_USER_IN_MODE_OFST (6)
#define AD9257_USER_IN_MODE_MSK (0x00000003 << AD9257_USER_IN_MODE_OFST)
/** PLL Reconfiguration Registers */
//https://www.altera.com/documentation/mcn1424769382940.html
#define PLL_MODE_REG (0x00)
#define PLL_STATUS_REG (0x01)
#define PLL_START_REG (0x02)
#define PLL_N_COUNTER_REG (0x03)
#define PLL_M_COUNTER_REG (0x04)
#define PLL_C_COUNTER_REG (0x05)
#define PLL_PHASE_SHIFT_REG (0x06)
#define PLL_SHIFT_NUM_SHIFTS_OFST (0)
#define PLL_SHIFT_NUM_SHIFTS_MSK (0x0000FFFF << PLL_SHIFT_NUM_SHIFTS_OFST)
#define PLL_SHIFT_CNT_SELECT_OFST (16)
#define PLL_SHIFT_CNT_SELECT_MSK (0x0000001F << PLL_SHIFT_CNT_SELECT_OFST)
#define PLL_SHIFT_CNT_SLCT_C0_VAL ((0x0 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
#define PLL_SHIFT_CNT_SLCT_C1_VAL ((0x1 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
#define PLL_SHIFT_CNT_SLCT_C2_VAL ((0x2 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
#define PLL_SHIFT_CNT_SLCT_C3_VAL ((0x3 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
#define PLL_SHIFT_CNT_SLCT_C4_VAL ((0x4 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
#define PLL_SHIFT_CNT_SLCT_C5_VAL ((0x5 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
#define PLL_SHIFT_CNT_SLCT_C6_VAL ((0x6 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
#define PLL_SHIFT_CNT_SLCT_C7_VAL ((0x7 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
#define PLL_SHIFT_CNT_SLCT_C8_VAL ((0x8 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
#define PLL_SHIFT_CNT_SLCT_C9_VAL ((0x9 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
#define PLL_SHIFT_CNT_SLCT_C10_VAL ((0x10 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
#define PLL_SHIFT_CNT_SLCT_C11_VAL ((0x11 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
#define PLL_SHIFT_CNT_SLCT_C12_VAL ((0x12 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
#define PLL_SHIFT_CNT_SLCT_C13_VAL ((0x13 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
#define PLL_SHIFT_CNT_SLCT_C14_VAL ((0x14 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
#define PLL_SHIFT_CNT_SLCT_C15_VAL ((0x15 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
#define PLL_SHIFT_CNT_SLCT_C16_VAL ((0x16 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
#define PLL_SHIFT_CNT_SLCT_C17_VAL ((0x17 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
#define PLL_SHIFT_UP_DOWN_OFST (21)
#define PLL_SHIFT_UP_DOWN_MSK (0x00000001 << PLL_SHIFT_UP_DOWN_OFST)
#define PLL_SHIFT_UP_DOWN_NEG_VAL ((0x0 << PLL_SHIFT_UP_DOWN_OFST) & PLL_SHIFT_UP_DOWN_MSK)
#define PLL_SHIFT_UP_DOWN_POS_VAL ((0x1 << PLL_SHIFT_UP_DOWN_OFST) & PLL_SHIFT_UP_DOWN_MSK)
#define PLL_K_COUNTER_REG (0x07)
#define PLL_BANDWIDTH_REG (0x08)
#define PLL_CHARGEPUMP_REG (0x09)
#define PLL_VCO_DIV_REG (0x1c)
#define PLL_MIF_REG (0x1f)
#endif /* SLSDETECTORSERVER_DEFS_H */

View File

@@ -0,0 +1 @@
../slsDetectorServer/slsDetectorServer_funcs.c

View File

@@ -0,0 +1 @@
../slsDetectorServer/slsDetectorServer_funcs.h

View File

@@ -1,46 +0,0 @@
/* A simple server in the internet domain using TCP
The port number is passed as an argument */
#include "sls_detector_defs.h"
#include "communication_funcs.h"
#include "firmware_funcs.h"
int sockfd;
int main(int argc, char *argv[])
{
int portno;
int retval=0;
portno = DEFAULT_PORTNO;
bindSocket(portno);
if (getServerError())
return -1;
/* waits for connection */
while(retval!=GOODBYE) {
#ifdef VERBOSE
printf("\n");
#endif
#ifdef VERY_VERBOSE
printf("Stop server: waiting for client call\n");
#endif
acceptConnection();
retval=stopStateMachine();
closeConnection();
}
exitServer();
printf("Goodbye!\n");
return 0;
}