mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 06:50:02 +02:00
Merge branch 'master' of gitorious.psi.ch:sls_det_software/sls_detector_software
This commit is contained in:
commit
b4f995084c
@ -341,7 +341,8 @@ enum dacIndex {
|
||||
E_Vcp, /**< eiger */
|
||||
E_Vcn, /**< eiger */
|
||||
E_Vis, /**< eiger */
|
||||
IO_DELAY /**< eiger io delay */
|
||||
IO_DELAY, /**< eiger io delay */
|
||||
ADC_VPP /**< adc vpp for jctb */
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -6,7 +6,7 @@
|
||||
CROSS = bfin-uclinux-
|
||||
CC = $(CROSS)gcc
|
||||
|
||||
CFLAGS += -Wall -DMOENCHD -DMCB_FUNCS -DDACS_INT -DDEBUG #-DVERBOSE #-DVERYVERBOSE #-DVIRTUAL #-DDACS_INT_CSERVER
|
||||
CFLAGS += -Wall -DMOENCHD -DMCB_FUNCS -DDACS_INT -DDEBUG -DV1#-DVERBOSE #-DVERYVERBOSE #-DVIRTUAL #-DDACS_INT_CSERVER
|
||||
|
||||
|
||||
PROGS= jungfrauDetectorServer
|
||||
|
@ -1,7 +1,7 @@
|
||||
//#define TESTADC
|
||||
#define TESTADC1
|
||||
|
||||
|
||||
//#define TIMEDBG
|
||||
#include "server_defs.h"
|
||||
#include "firmware_funcs.h"
|
||||
#include "mcb_funcs.h"
|
||||
@ -20,6 +20,10 @@
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
struct timeval tss,tse,tsss; //for timing
|
||||
|
||||
|
||||
//for memory mapping
|
||||
u_int64_t CSP0BASE;
|
||||
@ -375,7 +379,7 @@ u_int32_t setPllReconfigReg(u_int32_t reg, u_int32_t val, int trig) {
|
||||
|
||||
|
||||
|
||||
printf("*********** pll busy: %08x\n",bus_r(STATUS_REG)&PLL_RECONFIG_BUSY);
|
||||
// printf("*********** pll busy: %08x\n",bus_r(STATUS_REG)&PLL_RECONFIG_BUSY);
|
||||
|
||||
bus_w(PLL_PARAM_REG,val);
|
||||
// printf("param: %x\n",val);
|
||||
@ -396,7 +400,7 @@ u_int32_t setPllReconfigReg(u_int32_t reg, u_int32_t val, int trig) {
|
||||
// printf("wrote: %08x\n",vv);
|
||||
bus_w(PLL_CNTRL_REG,vv);
|
||||
usleep(10000);
|
||||
printf("+++++++++ pll busy: %08x\n",bus_r(STATUS_REG)&PLL_RECONFIG_BUSY);
|
||||
// printf("+++++++++ pll busy: %08x\n",bus_r(STATUS_REG)&PLL_RECONFIG_BUSY);
|
||||
|
||||
// bus_w(PLL_CNTRL_REG,(1<<PLL_CNTR_READ_BIT)|(reg<<PLL_CNTR_ADDR_OFF));
|
||||
// usleep(1000);
|
||||
@ -418,8 +422,8 @@ u_int32_t getPllReconfigReg(u_int32_t reg, int trig) {
|
||||
u_int32_t val=reg<<PLL_CNTR_ADDR_OFF;
|
||||
u_int32_t vv;
|
||||
|
||||
printf("cntrlreg: %08x\n",PLL_CNTRL_REG);
|
||||
printf("wrote: %08x\n",val);
|
||||
// printf("cntrlreg: %08x\n",PLL_CNTRL_REG);
|
||||
// printf("wrote: %08x\n",val);
|
||||
bus_w(PLL_CNTRL_REG,val);
|
||||
// printf("read: %08x\n",bus_r(PLL_CNTRL_REG));
|
||||
usleep(100);
|
||||
@ -441,7 +445,7 @@ u_int32_t getPllReconfigReg(u_int32_t reg, int trig) {
|
||||
usleep(100);
|
||||
|
||||
val=0;
|
||||
printf("wrote: %08x\n",val);
|
||||
// printf("wrote: %08x\n",val);
|
||||
bus_w(PLL_CNTRL_REG,val);
|
||||
|
||||
while(bus_r(STATUS_REG)&PLL_RECONFIG_BUSY) {
|
||||
@ -489,26 +493,58 @@ void configurePll(int i) {
|
||||
|
||||
val= (i<<18)| (odd<<17) | l | (h<<8);
|
||||
|
||||
printf("Counter %d, val: %08x\n", i, val); setPllReconfigReg(PLL_C_COUNTER_REG, val,0);
|
||||
printf("Counter %d, val: %08x\n", i, val);
|
||||
setPllReconfigReg(PLL_C_COUNTER_REG, val,0);
|
||||
// usleep(20);
|
||||
//change sync at the same time as
|
||||
if (i>0) {
|
||||
val= (2<<18)| (odd<<17) | l | (h<<8);
|
||||
|
||||
printf("Counter %d, val: %08x\n", i, val);
|
||||
setPllReconfigReg(PLL_C_COUNTER_REG, val,0);
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
// if (mode==1) {
|
||||
// } else {
|
||||
printf("phase in %d\n",clkPhase[0]);
|
||||
printf("phase in %d\n",clkPhase[1]);
|
||||
|
||||
if (clkPhase[0]>0) {
|
||||
if (clkPhase[1]>0) {
|
||||
inv=0;
|
||||
phase=clkPhase[0];
|
||||
phase=clkPhase[1];
|
||||
} else {
|
||||
inv=1;
|
||||
phase=-1*clkPhase[0];
|
||||
phase=-1*clkPhase[1];
|
||||
}
|
||||
|
||||
printf("phase out %d %08x\n",phase,phase);
|
||||
val=phase | (inv<<16);;// | (inv<<21);
|
||||
if (inv) {
|
||||
val=phase | (1<<16);// | (inv<<21);
|
||||
printf("**************** phase word %08x\n",val);
|
||||
|
||||
printf("Phase, val: %08x\n", val); setPllReconfigReg(PLL_PHASE_SHIFT_REG,val,0); //shifts counter 0
|
||||
// printf("Phase, val: %08x\n", val);
|
||||
setPllReconfigReg(PLL_PHASE_SHIFT_REG,val,0); //shifts counter 0
|
||||
} else {
|
||||
|
||||
|
||||
val=phase ;// | (inv<<21);
|
||||
printf("**************** phase word %08x\n",val);
|
||||
|
||||
// printf("Phase, val: %08x\n", val);
|
||||
setPllReconfigReg(PLL_PHASE_SHIFT_REG,val,0); //shifts counter 0
|
||||
val=phase | (2<<16);// | (inv<<21);
|
||||
printf("Start reconfig\n"); setPllReconfigReg(PLL_START_REG, 1,0);
|
||||
|
||||
// bus_w(PLL_CNTRL_REG, 0);
|
||||
printf("Status register\n"); getPllReconfigReg(PLL_STATUS_REG,0);
|
||||
// sleep(1);
|
||||
|
||||
printf("**************** phase word %08x\n",val);
|
||||
|
||||
// printf("Phase, val: %08x\n", val);
|
||||
setPllReconfigReg(PLL_PHASE_SHIFT_REG,val,0); //shifts counter 0
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -521,14 +557,14 @@ void configurePll(int i) {
|
||||
|
||||
// printf("PLL mode\n"); setPllReconfigReg(PLL_MODE_REG,0,0);
|
||||
usleep(10000);
|
||||
/* if (mode!=1) { */
|
||||
/* printf("reset pll\n"); */
|
||||
/* bus_w(PLL_CNTRL_REG,((1<<PLL_CNTR_PLL_RESET_BIT))); //reset PLL */
|
||||
/* usleep(100); */
|
||||
/* bus_w(PLL_CNTRL_REG, 0); */
|
||||
if (i<2) {
|
||||
printf("reset pll\n");
|
||||
bus_w(PLL_CNTRL_REG,((1<<PLL_CNTR_PLL_RESET_BIT))); //reset PLL
|
||||
usleep(100);
|
||||
bus_w(PLL_CNTRL_REG, 0);
|
||||
|
||||
|
||||
/* } */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -578,45 +614,29 @@ u_int32_t setClockDivider(int d, int ic) {
|
||||
}
|
||||
|
||||
|
||||
int phaseStep(int st, int ic){
|
||||
|
||||
u_int32_t addr, val=( (1<<PLL_CNTR_UPDN_BIT)| (1<<PLL_CNTR_CNTSEL_OFF) | (1<< PLL_CNTR_PHASE_EN_BIT));
|
||||
/* int ic=0 is run clk; ic=1 is adc clk */
|
||||
|
||||
/* if (st>0) */
|
||||
/* ic=1; */
|
||||
/* else { */
|
||||
/* ic=0; */
|
||||
/* st*=-1; */
|
||||
/* } */
|
||||
int phaseStep(int st){
|
||||
|
||||
int i;
|
||||
if (st>65535 || st<-65535)
|
||||
return -1;
|
||||
return clkPhase[0];
|
||||
|
||||
printf("ic=%d; phase %d\n", ic, st);
|
||||
printf("phase %d\n", st);
|
||||
|
||||
clkPhase[1]=st-clkPhase[0];
|
||||
|
||||
|
||||
if (ic==1)
|
||||
clkPhase[0]=-st;
|
||||
else if (ic==0)
|
||||
configurePll(2);
|
||||
clkPhase[0]=st;
|
||||
|
||||
|
||||
|
||||
/* printf("Changin phase %d\n",st); */
|
||||
/* for (i=0; i<st; i++) { */
|
||||
/* bus_w(PLL_CNTRL_REG,0); */
|
||||
/* bus_w(PLL_CNTRL_REG,val); */
|
||||
|
||||
/* } */
|
||||
/* sleep(1); */
|
||||
// bus_w(PLL_CNTRL_REG,0);
|
||||
configurePll(2);
|
||||
return clkPhase[0];
|
||||
}
|
||||
|
||||
|
||||
int getPhase() {
|
||||
return clkPhase[0];
|
||||
|
||||
};
|
||||
|
||||
|
||||
u_int32_t getClockDivider(int ic) {
|
||||
|
||||
@ -1959,11 +1979,15 @@ u_int32_t fifo_full(void)
|
||||
}
|
||||
|
||||
|
||||
u_int16_t* fifo_read_event()
|
||||
u_int16_t* fifo_read_event(int ns)
|
||||
{
|
||||
int i=0;
|
||||
|
||||
u_int16_t *dum;
|
||||
|
||||
/* #ifdef TIMEDBG */
|
||||
/* gettimeofday(&tse,NULL); */
|
||||
/* #endif */
|
||||
if (ns==0) {
|
||||
volatile u_int32_t t = bus_r16(LOOK_AT_ME_REG);
|
||||
|
||||
bus_w(DUMMY_REG,0);
|
||||
@ -1984,19 +2008,33 @@ u_int16_t* fifo_read_event()
|
||||
printf(".");
|
||||
#endif
|
||||
}
|
||||
/* #ifdef TIMEDBG */
|
||||
/* // tsss=tss; */
|
||||
/* gettimeofday(&tss,NULL); */
|
||||
/* printf("look for data = %ld usec\n", (tss.tv_usec) - (tse.tv_usec)); */
|
||||
|
||||
/* #endif */
|
||||
|
||||
}
|
||||
// printf("%08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG));
|
||||
/* dma_memcpy(now_ptr,values ,dataBytes); */
|
||||
/* #else */
|
||||
|
||||
bus_w16(DUMMY_REG,1<<8); // read strobe to all fifos
|
||||
bus_w16(DUMMY_REG,0);
|
||||
for (i=0; i<32; i++) {
|
||||
dum=((u_int16_t*)(now_ptr))+i;
|
||||
bus_w(DUMMY_REG,i<<1);
|
||||
// usleep(10);
|
||||
bus_w(DUMMY_REG,(i<<1) | 1);
|
||||
// usleep(10);
|
||||
bus_w(DUMMY_REG,i<<1);
|
||||
/* usleep(10); */
|
||||
*dum=bus_r16(FIFO_DATA_REG);
|
||||
bus_w16(DUMMY_REG,i);
|
||||
// dum=((u_int16_t*)(now_ptr))+i;
|
||||
// *dum=bus_r16(FIFO_DATA_REG);
|
||||
//dum=;
|
||||
*(((u_int16_t*)(now_ptr))+i)=bus_r16(FIFO_DATA_REG);
|
||||
}
|
||||
/* #ifdef TIMEDBG */
|
||||
|
||||
/* gettimeofday(&tss,NULL); */
|
||||
/* printf("read data loop = %ld usec\n",(tss.tv_usec) - (tse.tv_usec)); */
|
||||
|
||||
/* #endif */
|
||||
#ifdef VERBOSE
|
||||
printf("*");
|
||||
#endif
|
||||
@ -2007,23 +2045,31 @@ u_int16_t* fifo_read_event()
|
||||
|
||||
u_int16_t* fifo_read_frame()
|
||||
{
|
||||
u_int16_t *dum;
|
||||
#ifdef TIMEDBG
|
||||
gettimeofday(&tsss,NULL);
|
||||
#endif
|
||||
|
||||
// u_int16_t *dum;
|
||||
int ns=0;
|
||||
now_ptr=(char*)ram_values;
|
||||
while(ns<nSamples) {
|
||||
dum=fifo_read_event();
|
||||
if (dum==NULL) break;
|
||||
while(ns<nSamples && fifo_read_event(ns)) {
|
||||
now_ptr+=dataBytes;
|
||||
ns++;
|
||||
}
|
||||
#ifdef TIMEDBG
|
||||
// usleep(10);
|
||||
gettimeofday(&tss,NULL);
|
||||
printf("total read data loop = %ld usec\n",(tss.tv_usec) - (tsss.tv_usec));
|
||||
|
||||
#endif
|
||||
// printf("%x %d\n",dum, ns);
|
||||
if (ns==0) return NULL;
|
||||
if (ns) return ram_values;
|
||||
#ifdef VERBOSE
|
||||
printf("+\n");
|
||||
#else
|
||||
printf("+");
|
||||
#endif
|
||||
return ram_values;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -2240,37 +2286,37 @@ int writeADC(int addr, int val) {
|
||||
printf("***** ADC SPI WRITE TO REGISTER %04X value %04X\n",addr,val);
|
||||
// start point
|
||||
valw=0xff;
|
||||
bus_w(ADC_WRITE_REG,(valw));
|
||||
bus_w16(ADC_WRITE_REG,(valw));
|
||||
|
||||
//chip sel bar down
|
||||
valw=((0xffffffff&(~csmask)));
|
||||
bus_w(ADC_WRITE_REG,valw);
|
||||
bus_w16(ADC_WRITE_REG,valw);
|
||||
|
||||
for (i=0;i<24;i++) {
|
||||
//cldwn
|
||||
valw=valw&(~(0x1<<cdx));
|
||||
bus_w(ADC_WRITE_REG,valw);
|
||||
usleep(0);
|
||||
bus_w16(ADC_WRITE_REG,valw);
|
||||
// usleep(0);
|
||||
|
||||
//write data (i)
|
||||
valw=(valw&(~(0x1<<ddx)))+(((codata>>(23-i))&0x1)<<ddx);
|
||||
bus_w(ADC_WRITE_REG,valw);
|
||||
usleep(0);
|
||||
bus_w16(ADC_WRITE_REG,valw);
|
||||
// usleep(0);
|
||||
|
||||
//clkup
|
||||
valw=valw+(0x1<<cdx);
|
||||
bus_w(ADC_WRITE_REG,valw);
|
||||
usleep(0);
|
||||
bus_w16(ADC_WRITE_REG,valw);
|
||||
// usleep(0);
|
||||
}
|
||||
|
||||
// stop point =start point
|
||||
valw=valw&(~(0x1<<cdx));
|
||||
usleep(0);
|
||||
// usleep(0);
|
||||
valw=0xff;
|
||||
bus_w(ADC_WRITE_REG,(valw));
|
||||
bus_w16(ADC_WRITE_REG,(valw));
|
||||
|
||||
//usleep in between
|
||||
usleep(50000);
|
||||
// usleep(50000);
|
||||
|
||||
return OK;
|
||||
}
|
||||
@ -2759,7 +2805,7 @@ int calibratePedestal(int frames){
|
||||
|
||||
while(dataret==OK){
|
||||
//got data
|
||||
if (fifo_read_event()) {
|
||||
if (fifo_read_event(0)) {
|
||||
dataret=OK;
|
||||
//sendDataOnly(file_des,&dataret,sizeof(dataret));
|
||||
//sendDataOnly(file_des,dataretval,dataBytes);
|
||||
@ -3042,6 +3088,8 @@ void initDac(int dacnum) {
|
||||
|
||||
ddx=0; cdx=1;
|
||||
csdx=dacnum/8+2;
|
||||
|
||||
|
||||
printf("data bit=%d, clkbit=%d, csbit=%d",ddx,cdx,csdx);
|
||||
codata=((((0x6)<<4)+((0xf))<<16)+((0x0<<4)&0xfff0));
|
||||
|
||||
|
@ -29,7 +29,8 @@ u_int32_t bus_w(u_int32_t offset, u_int32_t data);
|
||||
u_int32_t bus_r(u_int32_t offset);
|
||||
|
||||
int setPhaseShiftOnce();
|
||||
int phaseStep(int st, int ic);
|
||||
int phaseStep(int st);
|
||||
int getPhase();
|
||||
int cleanFifo();
|
||||
int setDAQRegister();
|
||||
|
||||
@ -134,7 +135,7 @@ u_int32_t fifo_full(void);
|
||||
|
||||
|
||||
|
||||
u_int16_t* fifo_read_event();
|
||||
u_int16_t* fifo_read_event(int ns);
|
||||
u_int16_t* fifo_read_frame();
|
||||
u_int32_t* decode_data(int* datain);
|
||||
//u_int32_t move_data(u_int64_t* datain, u_int64_t* dataout);
|
||||
|
@ -1985,7 +1985,7 @@ int testExtPulse(int imod) {
|
||||
//startStateMachine();
|
||||
startReadOut();
|
||||
usleep(100);
|
||||
val1=(int*)(decode_data((int*)(fifo_read_event())));
|
||||
val1=(int*)(decode_data((int*)(fifo_read_event(0))));
|
||||
// val1=fifo_read_event();
|
||||
//imod=0;
|
||||
//for (imod=0; imod<nModX; imod++) {
|
||||
@ -2054,7 +2054,7 @@ int testExtPulseMux(int imod, int ow) {
|
||||
|
||||
startReadOut();
|
||||
usleep(100);
|
||||
v1=(int*)(fifo_read_event());
|
||||
v1=(int*)(fifo_read_event(0));
|
||||
if (v1)
|
||||
values=(int*)(decode_data(v1));
|
||||
else {
|
||||
@ -2129,7 +2129,7 @@ int testDataInOutMux(int imod, int ow, int num) {
|
||||
printf("mux %d\n",ow);
|
||||
startReadOut();
|
||||
usleep(100);
|
||||
v1=(int*)(fifo_read_event());
|
||||
v1=(int*)(fifo_read_event(0));
|
||||
if (v1)
|
||||
values=(int*)(decode_data(v1));
|
||||
else {
|
||||
|
@ -54,6 +54,8 @@ int digitalTestBit = 0;
|
||||
extern int withGotthard;
|
||||
|
||||
|
||||
int adcvpp=0x4;
|
||||
|
||||
int init_detector(int b, int checkType) {
|
||||
|
||||
int i;
|
||||
@ -995,22 +997,36 @@ int set_dac(int file_des) {
|
||||
sprintf(mess,"Detector locked by %s\n",lastClientIP);
|
||||
} else{
|
||||
|
||||
if (ind<16) {
|
||||
|
||||
if (mV) {
|
||||
if (val>2500)
|
||||
val=-1;
|
||||
printf("%d mV is ",val);
|
||||
if (val>0)
|
||||
val=16535*val/2500;
|
||||
val=4095*val/2500;
|
||||
printf("%d DACu\n", val);
|
||||
} else if (val>16535)
|
||||
} else if (val>4095)
|
||||
val=-1;
|
||||
|
||||
|
||||
retval=setDac(ind,val);
|
||||
/* if(idac==HIGH_VOLTAGE) */
|
||||
/* retval=initHighVoltageByModule(val,imod); */
|
||||
/* else */
|
||||
/* retval=initDACbyIndexDACU(idac,val,imod); */
|
||||
/* if(idac==HIGH_VOLTAGE) */
|
||||
/* retval=initHighVoltageByModule(val,imod); */
|
||||
/* else */
|
||||
/* retval=initDACbyIndexDACU(idac,val,imod); */
|
||||
}
|
||||
else if (ind==ADC_VPP) {
|
||||
printf("Setting ADC VPP to %d\n",val);
|
||||
if (val>4 || val<0)
|
||||
printf("Cannot set ADC VPP to %d\n",val);
|
||||
else {
|
||||
writeADC(0x18,val);
|
||||
adcvpp=val;
|
||||
}
|
||||
retval=adcvpp;;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
if(ret==OK){
|
||||
@ -1025,7 +1041,7 @@ int set_dac(int file_des) {
|
||||
/* }//since v r saving only msb */
|
||||
/* else if ((retval-val)<=3 || val==-1) */
|
||||
/* ret=OK; */
|
||||
|
||||
if (ind<16) {
|
||||
if (mV) {
|
||||
|
||||
printf("%d DACu is ",retval);
|
||||
@ -1039,7 +1055,7 @@ int set_dac(int file_des) {
|
||||
#ifdef VERBOSE
|
||||
printf("DAC set to %d V\n", retval);
|
||||
#endif
|
||||
|
||||
}
|
||||
if(ret==FAIL)
|
||||
printf("Setting dac %d of module %d: wrote %d but read %d\n", ind, imod, val, retval);
|
||||
else{
|
||||
@ -2361,7 +2377,17 @@ int set_speed(int file_des) {
|
||||
|
||||
if (ret==OK) {
|
||||
|
||||
if (arg==PHASE_SHIFT || arg==ADC_PHASE) {
|
||||
|
||||
|
||||
retval=phaseStep(val);
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
if (val!=-1) {
|
||||
|
||||
|
||||
if (differentClients==1 && lockStatus==1 && val>=0) {
|
||||
ret=FAIL;
|
||||
sprintf(mess,"Detector locked by %s\n",lastClientIP);
|
||||
@ -2371,9 +2397,9 @@ int set_speed(int file_des) {
|
||||
retval=setClockDivider(val,0);
|
||||
break;
|
||||
|
||||
case PHASE_SHIFT:
|
||||
retval=phaseStep(val,0);
|
||||
break;
|
||||
/* case PHASE_SHIFT: */
|
||||
/* retval=phaseStep(val,0); */
|
||||
/* break; */
|
||||
|
||||
case OVERSAMPLING:
|
||||
retval=setOversampling(val);
|
||||
@ -2383,9 +2409,9 @@ int set_speed(int file_des) {
|
||||
retval=setClockDivider(val,1);
|
||||
break;
|
||||
|
||||
case ADC_PHASE:
|
||||
retval=phaseStep(val,1);
|
||||
break;
|
||||
/* case ADC_PHASE: */
|
||||
/* retval=phaseStep(val,1); */
|
||||
/* break; */
|
||||
|
||||
|
||||
case ADC_PIPELINE:
|
||||
@ -2402,16 +2428,19 @@ int set_speed(int file_des) {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
switch (arg) {
|
||||
case CLOCK_DIVIDER:
|
||||
retval=getClockDivider(0);
|
||||
break;
|
||||
|
||||
case PHASE_SHIFT:
|
||||
retval=getPhase();
|
||||
// retval=phaseStep(-1);
|
||||
//ret=FAIL;
|
||||
//sprintf(mess,"Cannot read phase",arg);
|
||||
retval=-1;
|
||||
break;
|
||||
|
||||
case OVERSAMPLING:
|
||||
@ -2423,7 +2452,7 @@ int set_speed(int file_des) {
|
||||
break;
|
||||
|
||||
case ADC_PHASE:
|
||||
retval=-1;
|
||||
retval=getPhase();
|
||||
break;
|
||||
|
||||
|
||||
|
@ -236,7 +236,7 @@ int choose_vthresh_and_vtrim(int countlim, int nsigma, int im) {
|
||||
while (runBusy()) {
|
||||
}
|
||||
usleep(500);
|
||||
fifodata=fifo_read_event();
|
||||
fifodata=fifo_read_event(0);
|
||||
scan=decode_data(fifodata);
|
||||
for (imod=modmi; imod<modma; imod++) {
|
||||
for (ichan=0; ichan<nChans*nChips; ichan++){
|
||||
@ -377,7 +377,7 @@ int trim_with_level(int countlim, int im) {
|
||||
}
|
||||
usleep(500);
|
||||
|
||||
fifodata=fifo_read_event();
|
||||
fifodata=fifo_read_event(0);
|
||||
scan=decode_data(fifodata);
|
||||
for (imod=modmi; imod<modma; imod++) {
|
||||
for (ichan=0; ichan<nChans*nChips; ichan++) {
|
||||
@ -515,7 +515,7 @@ int choose_vthresh() {
|
||||
}
|
||||
usleep(500);
|
||||
|
||||
fifodata=fifo_read_event();
|
||||
fifodata=fifo_read_event(0);
|
||||
scan=decode_data(fifodata);
|
||||
//
|
||||
scan1=decode_data(fifodata);
|
||||
@ -553,7 +553,7 @@ int choose_vthresh() {
|
||||
}
|
||||
usleep(500);
|
||||
|
||||
fifodata=fifo_read_event();
|
||||
fifodata=fifo_read_event(0);
|
||||
scan=decode_data(fifodata);
|
||||
//
|
||||
scan1=decode_data(fifodata);
|
||||
@ -680,7 +680,7 @@ int trim_with_median(int stop, int im) {
|
||||
while (runBusy()) {
|
||||
}
|
||||
usleep(500);
|
||||
fifodata=fifo_read_event();
|
||||
fifodata=fifo_read_event(0);
|
||||
scan=decode_data(fifodata);
|
||||
scan1=decode_data(fifodata);
|
||||
|
||||
|
@ -699,6 +699,12 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
i++;
|
||||
|
||||
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="adcvpp"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDAC;
|
||||
i++;
|
||||
|
||||
|
||||
/* r/w timers */
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="temp_adc"; //
|
||||
@ -898,6 +904,14 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
/* pattern generator */
|
||||
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="adcinvert"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdPattern;
|
||||
i++;
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="adcdisable"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdPattern;
|
||||
i++;
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="pattern"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdPattern;
|
||||
i++;
|
||||
@ -3383,6 +3397,8 @@ string slsDetectorCommand::cmdDAC(int narg, char *args[], int action) {
|
||||
printf("chiptestboard!\n");
|
||||
dac=(dacIndex)idac;
|
||||
}
|
||||
else if (cmd=="adcvpp")
|
||||
dac=ADC_VPP;
|
||||
else if (cmd=="vthreshold")
|
||||
dac=THRESHOLD;
|
||||
else if (cmd=="vcalibration")
|
||||
@ -3942,15 +3958,17 @@ string slsDetectorCommand::cmdSpeed(int narg, char *args[], int action) {
|
||||
index=TOT_CLOCK_DIVIDER;
|
||||
else if (cmd=="totdutycycle")
|
||||
index=TOT_DUTY_CYCLE;
|
||||
else if (cmd=="phasestep")
|
||||
else if (cmd=="phasestep") {
|
||||
index=PHASE_SHIFT;
|
||||
else if (cmd=="oversampling")
|
||||
t=100000;
|
||||
} else if (cmd=="oversampling")
|
||||
index=OVERSAMPLING;
|
||||
else if (cmd=="adcclk")
|
||||
index=ADC_CLOCK;
|
||||
else if (cmd=="adcphase")
|
||||
else if (cmd=="adcphase") {
|
||||
index=ADC_PHASE;
|
||||
else if (cmd=="adcpipeline")
|
||||
t=100000;
|
||||
} else if (cmd=="adcpipeline")
|
||||
index=ADC_PIPELINE;
|
||||
else
|
||||
return string("could not decode speed variable ")+cmd;
|
||||
@ -3961,6 +3979,7 @@ string slsDetectorCommand::cmdSpeed(int narg, char *args[], int action) {
|
||||
;
|
||||
else
|
||||
return string("cannot scan speed value ")+string(args[1]);
|
||||
|
||||
}
|
||||
|
||||
myDet->setOnline(ONLINE_FLAG);
|
||||
@ -4335,6 +4354,9 @@ string slsDetectorCommand::helpPattern(int narg, char *args[], int action) {
|
||||
os << "patwaittime0 nclk \t sets wait 0 waiting time in clock number " << std::endl;
|
||||
os << "patwaittime1 nclk \t sets wait 1 waiting time in clock number " << std::endl;
|
||||
os << "patwaittime2 nclk \t sets wait 2 waiting time in clock number " << std::endl;
|
||||
os << "adcinvert mask\t sets the adcinversion mask (hex)" << std::endl;
|
||||
os << "adcdisable mask\t sets the adcdisable mask (hex)" << std::endl;
|
||||
|
||||
}
|
||||
if (action==GET_ACTION || action==HELP_ACTION){
|
||||
os << "pattern \t cannot get" << std::endl;
|
||||
@ -4354,6 +4376,9 @@ string slsDetectorCommand::helpPattern(int narg, char *args[], int action) {
|
||||
os << "patwaittime0 \t returns the wait 0 waiting time in clock number " << std::endl;
|
||||
os << "patwaittime1 \t returns the wait 1 waiting time in clock number " << std::endl;
|
||||
os << "patwaittime2 \t returns the wait 2 waiting time in clock number " << std::endl;
|
||||
os << "adcinvert \t returns the adcinversion mask " << std::endl;
|
||||
|
||||
os << "adcdisable \t returns the adcdisable mask " << std::endl;
|
||||
|
||||
}
|
||||
return os.str();
|
||||
@ -4757,7 +4782,42 @@ string slsDetectorCommand::cmdPattern(int narg, char *args[], int action) {
|
||||
|
||||
os << myDet->setCTBPatWaitTime(2,-1);
|
||||
|
||||
} else if (cmd=="adcinvert") {
|
||||
if (action==PUT_ACTION) {
|
||||
|
||||
if (sscanf(args[1],"%x",&addr))
|
||||
;
|
||||
else
|
||||
return string("Could not scan adcinvert reg ")+string(args[1]);
|
||||
|
||||
|
||||
myDet->writeRegister(67,addr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
os << hex << myDet->readRegister(67) << dec;
|
||||
|
||||
} else if (cmd=="adcdisable") {
|
||||
if (action==PUT_ACTION) {
|
||||
|
||||
if (sscanf(args[1],"%x",&addr))
|
||||
;
|
||||
else
|
||||
return string("Could not scan adcdisable reg ")+string(args[1]);
|
||||
|
||||
|
||||
myDet->writeRegister(94,addr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
os << hex << myDet->readRegister(94) << dec;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
else return helpPattern(narg, args, action);
|
||||
|
||||
|
||||
|
@ -786,118 +786,122 @@ int slsDetectorUtils::dumpDetectorSetup(string const fname, int level){
|
||||
slsDetectorCommand *cmd;
|
||||
string names[100];
|
||||
int nvar=0;
|
||||
int nvar1=0;
|
||||
|
||||
names[nvar++]="fname";
|
||||
names[nvar++]="index";
|
||||
names[nvar++]="dr";
|
||||
names[nvar++]="settings";
|
||||
names[nvar++]="exptime";
|
||||
names[nvar++]="period";
|
||||
names[nvar++]="frames";
|
||||
names[nvar++]="cycles";
|
||||
names[nvar++]="measurements";
|
||||
names[nvar++]="timing";
|
||||
|
||||
switch (getDetectorsType()) {
|
||||
case EIGER:
|
||||
names[nvar++]="fname";
|
||||
names[nvar++]="index";
|
||||
names[nvar++]="flags";
|
||||
names[nvar++]="dr";
|
||||
names[nvar++]="settings";
|
||||
names[nvar++]="threshold";
|
||||
names[nvar++]="exptime";
|
||||
names[nvar++]="period";
|
||||
names[nvar++]="frames";
|
||||
names[nvar++]="cycles";
|
||||
names[nvar++]="timing";
|
||||
names[nvar++]="fineoff";
|
||||
names[nvar++]="startscript";
|
||||
names[nvar++]="startscriptpar";
|
||||
names[nvar++]="stopscript";
|
||||
names[nvar++]="stopscriptpar";
|
||||
names[nvar++]="scriptbefore";
|
||||
names[nvar++]="scriptbeforepar";
|
||||
names[nvar++]="scriptafter";
|
||||
names[nvar++]="scriptafterpar";
|
||||
names[nvar++]="scan0script";
|
||||
names[nvar++]="scan0par";
|
||||
names[nvar++]="scan0prec";
|
||||
names[nvar++]="scan0steps";
|
||||
names[nvar++]="scan1script";
|
||||
names[nvar++]="scan1par";
|
||||
names[nvar++]="scan1prec";
|
||||
names[nvar++]="scan1steps";
|
||||
names[nvar++]="ratecorr";
|
||||
names[nvar++]="flatfield";
|
||||
names[nvar++]="badchannels";
|
||||
break;
|
||||
case GOTTHARD:
|
||||
names[nvar++]="fname";
|
||||
names[nvar++]="index";
|
||||
names[nvar++]="flags";
|
||||
names[nvar++]="dr";
|
||||
names[nvar++]="settings";
|
||||
names[nvar++]="exptime";
|
||||
names[nvar++]="period";
|
||||
names[nvar++]="delay";
|
||||
names[nvar++]="gates";
|
||||
names[nvar++]="frames";
|
||||
names[nvar++]="cycles";
|
||||
names[nvar++]="timing";
|
||||
names[nvar++]="fineoff";
|
||||
names[nvar++]="startscript";
|
||||
names[nvar++]="startscriptpar";
|
||||
names[nvar++]="stopscript";
|
||||
names[nvar++]="stopscriptpar";
|
||||
names[nvar++]="scriptbefore";
|
||||
names[nvar++]="scriptbeforepar";
|
||||
names[nvar++]="scriptafter";
|
||||
names[nvar++]="scriptafterpar";
|
||||
names[nvar++]="scan0script";
|
||||
names[nvar++]="scan0par";
|
||||
names[nvar++]="scan0prec";
|
||||
names[nvar++]="scan0steps";
|
||||
names[nvar++]="scan1script";
|
||||
names[nvar++]="scan1par";
|
||||
names[nvar++]="scan1prec";
|
||||
names[nvar++]="scan1steps";
|
||||
names[nvar++]="ratecorr";
|
||||
names[nvar++]="flatfield";
|
||||
names[nvar++]="badchannels";
|
||||
break;
|
||||
case MYTHEN:
|
||||
names[nvar++]="fname";
|
||||
names[nvar++]="index";
|
||||
names[nvar++]="flags";
|
||||
names[nvar++]="dr";
|
||||
names[nvar++]="settings";
|
||||
names[nvar++]="threshold";
|
||||
names[nvar++]="exptime";
|
||||
names[nvar++]="period";
|
||||
names[nvar++]="delay";
|
||||
names[nvar++]="gates";
|
||||
names[nvar++]="frames";
|
||||
names[nvar++]="cycles";
|
||||
names[nvar++]="probes";
|
||||
names[nvar++]="timing";
|
||||
names[nvar++]="fineoff";
|
||||
names[nvar++]="startscript";
|
||||
names[nvar++]="startscriptpar";
|
||||
names[nvar++]="stopscript";
|
||||
names[nvar++]="stopscriptpar";
|
||||
names[nvar++]="scriptbefore";
|
||||
names[nvar++]="scriptbeforepar";
|
||||
names[nvar++]="scriptafter";
|
||||
names[nvar++]="scriptafterpar";
|
||||
names[nvar++]="scan0script";
|
||||
names[nvar++]="scan0par";
|
||||
names[nvar++]="scan0prec";
|
||||
names[nvar++]="scan0steps";
|
||||
names[nvar++]="scan1script";
|
||||
names[nvar++]="scan1par";
|
||||
names[nvar++]="scan1prec";
|
||||
names[nvar++]="scan1steps";
|
||||
names[nvar++]="ratecorr";
|
||||
names[nvar++]="flatfield";
|
||||
names[nvar++]="badchannels";
|
||||
names[nvar++]="trimbits";
|
||||
break;
|
||||
case JUNGFRAUCTB:
|
||||
|
||||
names[nvar++]="dac:0";
|
||||
names[nvar++]="dac:1";
|
||||
names[nvar++]="dac:2";
|
||||
names[nvar++]="dac:3";
|
||||
names[nvar++]="dac:4";
|
||||
names[nvar++]="dac:5";
|
||||
names[nvar++]="dac:6";
|
||||
names[nvar++]="dac:7";
|
||||
names[nvar++]="dac:8";
|
||||
names[nvar++]="dac:9";
|
||||
names[nvar++]="dac:10";
|
||||
names[nvar++]="dac:11";
|
||||
names[nvar++]="dac:12";
|
||||
names[nvar++]="dac:13";
|
||||
names[nvar++]="dac:14";
|
||||
names[nvar++]="dac:15";
|
||||
names[nvar++]="adcvpp";
|
||||
|
||||
|
||||
|
||||
names[nvar++]="adcclk";
|
||||
names[nvar++]="clkdivider";
|
||||
names[nvar++]="adcphase";
|
||||
names[nvar++]="adcpipeline";
|
||||
names[nvar++]="adcinvert"; //
|
||||
names[nvar++]="adcdisable";
|
||||
names[nvar++]="patioctrl";
|
||||
names[nvar++]="patclkctrl";
|
||||
names[nvar++]="patlimits";
|
||||
names[nvar++]="patloop0";
|
||||
names[nvar++]="patnloop0";
|
||||
names[nvar++]="patwait0";
|
||||
names[nvar++]="patwaittime0";
|
||||
names[nvar++]="patloop1";
|
||||
names[nvar++]="patnloop1";
|
||||
names[nvar++]="patwait1";
|
||||
names[nvar++]="patwaittime1";
|
||||
names[nvar++]="patloop2";
|
||||
names[nvar++]="patnloop2";
|
||||
names[nvar++]="patwait2";
|
||||
names[nvar++]="patwaittime2";
|
||||
}
|
||||
|
||||
|
||||
|
||||
names[nvar++]="startscript";
|
||||
names[nvar++]="startscriptpar";
|
||||
names[nvar++]="stopscript";
|
||||
names[nvar++]="stopscriptpar";
|
||||
names[nvar++]="scriptbefore";
|
||||
names[nvar++]="scriptbeforepar";
|
||||
names[nvar++]="scriptafter";
|
||||
names[nvar++]="scriptafterpar";
|
||||
names[nvar++]="scan0script";
|
||||
names[nvar++]="scan0par";
|
||||
names[nvar++]="scan0prec";
|
||||
names[nvar++]="scan0steps";
|
||||
names[nvar++]="scan1script";
|
||||
names[nvar++]="scan1par";
|
||||
names[nvar++]="scan1prec";
|
||||
names[nvar++]="scan1steps";
|
||||
|
||||
switch (getDetectorsType()) {
|
||||
case EIGER:
|
||||
case MYTHEN:
|
||||
case GOTTHARD:
|
||||
names[nvar++]="flatfield";
|
||||
names[nvar++]="badchannels";
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
switch (getDetectorsType()) {
|
||||
case EIGER:
|
||||
case MYTHEN:
|
||||
names[nvar++]="trimbits";
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
// char ext[100];
|
||||
|
||||
@ -907,8 +911,8 @@ int slsDetectorUtils::dumpDetectorSetup(string const fname, int level){
|
||||
|
||||
|
||||
ofstream outfile;
|
||||
char *args[2];
|
||||
for (int ia=0; ia<2; ia++) {
|
||||
char *args[4];
|
||||
for (int ia=0; ia<4; ia++) {
|
||||
args[ia]=new char[1000];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user