mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-26 16:20:03 +02:00
Modicfications for chiptestboard and moench03 module
This commit is contained in:
parent
d90db50a60
commit
8caab4e562
@ -328,9 +328,9 @@ int receiveData(int file_des, void* buf,int length, intType itype){
|
|||||||
int nreceiving;
|
int nreceiving;
|
||||||
int nreceived;
|
int nreceived;
|
||||||
if (file_des<0) return -1;
|
if (file_des<0) return -1;
|
||||||
//#ifdef VERY_VERBOSE
|
#ifdef VERY_VERBOSE
|
||||||
printf("want to receive %d Bytes\n", length);
|
printf("want to receive %d Bytes\n", length);
|
||||||
//#endif
|
#endif
|
||||||
|
|
||||||
while(length>0){
|
while(length>0){
|
||||||
nreceiving = (length>send_rec_max_size) ? send_rec_max_size:length;
|
nreceiving = (length>send_rec_max_size) ? send_rec_max_size:length;
|
||||||
|
@ -29,6 +29,9 @@
|
|||||||
#define MAX_FPGAPROGRAMSIZE (2 * 1024 *1024)
|
#define MAX_FPGAPROGRAMSIZE (2 * 1024 *1024)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define MAX_SCAN_LEVELS 2
|
||||||
|
|
||||||
typedef char mystring[MAX_STR_LENGTH];
|
typedef char mystring[MAX_STR_LENGTH];
|
||||||
typedef double mysteps[MAX_SCAN_STEPS];
|
typedef double mysteps[MAX_SCAN_STEPS];
|
||||||
|
|
||||||
@ -373,7 +376,12 @@ enum dacIndex {
|
|||||||
V_POWER_D = 103, /**new chiptest board */
|
V_POWER_D = 103, /**new chiptest board */
|
||||||
V_POWER_IO =104, /**new chiptest board */
|
V_POWER_IO =104, /**new chiptest board */
|
||||||
V_POWER_CHIP=105 ,/**new chiptest board */
|
V_POWER_CHIP=105 ,/**new chiptest board */
|
||||||
V_LIMIT=106 /**new chiptest board */
|
I_POWER_A=106 , /**new chiptest board */
|
||||||
|
I_POWER_B=107 , /**new chiptest board */
|
||||||
|
I_POWER_C=108 , /**new chiptest board */
|
||||||
|
I_POWER_D=109 , /**new chiptest board */
|
||||||
|
I_POWER_IO=110 , /**new chiptest board */
|
||||||
|
V_LIMIT=111 /**new chiptest board */
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,7 +16,8 @@ INSTMODE= 0777
|
|||||||
|
|
||||||
|
|
||||||
BINS = testlib_sharedlibc
|
BINS = testlib_sharedlibc
|
||||||
SRCS = server.c server_funcs.c communication_funcs.c firmware_funcs.c mcb_funcs.c sharedmemory.c
|
SRCS = server.c server_funcs.c communication_funcs.c firmware_funcs.c slow_adc.c blackfin.c
|
||||||
|
#mcb_funcs.c sharedmemory.c
|
||||||
OBJS = $(SRCS:%.c=%.o)
|
OBJS = $(SRCS:%.c=%.o)
|
||||||
|
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -77,7 +77,7 @@ int setDACRegister(int idac, int val, int imod);
|
|||||||
int getDacRegister(int dacnum);
|
int getDacRegister(int dacnum);
|
||||||
|
|
||||||
|
|
||||||
int getTemperature(int tempSensor,int imod);
|
int getTemperature(int tempSensor);
|
||||||
int initHighVoltage(int val,int imod);
|
int initHighVoltage(int val,int imod);
|
||||||
int initConfGain(int isettings,int val,int imod);
|
int initConfGain(int isettings,int val,int imod);
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ int allocateRAM();
|
|||||||
|
|
||||||
int writeADC(int addr, int val);
|
int writeADC(int addr, int val);
|
||||||
int prepareADC();
|
int prepareADC();
|
||||||
int prepareSlowADC();
|
|
||||||
|
|
||||||
|
|
||||||
int clearRAM();
|
int clearRAM();
|
||||||
@ -192,6 +192,21 @@ int setPower(int ind, int val);
|
|||||||
int setROI(int nroi,ROI* arg,int *retvalsize, int *ret);
|
int setROI(int nroi,ROI* arg,int *retvalsize, int *ret);
|
||||||
int getChannels();
|
int getChannels();
|
||||||
|
|
||||||
|
int getCurrent(int idac);
|
||||||
|
int getVoltage(int idac);
|
||||||
|
|
||||||
|
void defineGPIOpins();
|
||||||
|
void resetFPGA();
|
||||||
|
void FPGAdontTouchFlash();
|
||||||
|
void FPGATouchFlash();
|
||||||
|
|
||||||
|
int startWritingFPGAprogram(FILE** filefp);
|
||||||
|
int stopWritingFPGAprogram(FILE* filefp);
|
||||||
|
int writeFPGAProgram(char* fpgasrc, size_t fsize, FILE* filefp);
|
||||||
|
void eraseFlash();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
u_int32_t setNBits(u_int32_t);
|
u_int32_t setNBits(u_int32_t);
|
||||||
@ -218,8 +233,6 @@ int calibration_chip(int num, int *values, int *dacs);
|
|||||||
|
|
||||||
int64_t setSamples(int64_t value);
|
int64_t setSamples(int64_t value);
|
||||||
//int setOutputMode(int d);
|
//int setOutputMode(int d);
|
||||||
int prepareSlowADCSeq();
|
|
||||||
int readSlowADC(int ichan);
|
|
||||||
int setReadOutMode(int arg);
|
int setReadOutMode(int arg);
|
||||||
int vLimitCompliant(int val_mV)
|
int vLimitCompliant(int val_mV)
|
||||||
|
|
||||||
|
Binary file not shown.
@ -811,19 +811,20 @@ int initHighVoltageByModule(int val, int imod)
|
|||||||
|
|
||||||
int initConfGainByModule(int isettings,int val, int imod)
|
int initConfGainByModule(int isettings,int val, int imod)
|
||||||
{
|
{
|
||||||
int im;
|
/* int im; */
|
||||||
//for the particular module
|
/* //for the particular module */
|
||||||
if (imod>=0 && imod<nModX) {
|
/* if (imod>=0 && imod<nModX) { */
|
||||||
return initConfGain(isettings,val,imod);
|
/* return initConfGain(isettings,val,imod); */
|
||||||
}
|
/* } */
|
||||||
else{
|
/* else{ */
|
||||||
//checks if all modules have the same value(ALLMOD)
|
/* //checks if all modules have the same value(ALLMOD) */
|
||||||
for (im=1; im<nModX; im++) {
|
/* for (im=1; im<nModX; im++) { */
|
||||||
if (initConfGain(isettings,val,im)!=initConfGain(isettings,val,0))
|
/* if (initConfGain(isettings,val,im)!=initConfGain(isettings,val,0)) */
|
||||||
return -1;
|
/* return -1; */
|
||||||
}
|
/* } */
|
||||||
return initConfGain(isettings,val,0);
|
/* return initConfGain(isettings,val,0); */
|
||||||
}
|
/* } */
|
||||||
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -869,56 +870,56 @@ void showbits(int h)
|
|||||||
|
|
||||||
|
|
||||||
int setSettings(int i, int imod) {
|
int setSettings(int i, int imod) {
|
||||||
#ifdef VERBOSE
|
/* #ifdef VERBOSE */
|
||||||
if(i==-1)
|
/* if(i==-1) */
|
||||||
printf("\nReading settings of detector...\n");
|
/* printf("\nReading settings of detector...\n"); */
|
||||||
else
|
/* else */
|
||||||
printf("\ninside set settings wit settings=%d...\n",i);
|
/* printf("\ninside set settings wit settings=%d...\n",i); */
|
||||||
#endif
|
/* #endif */
|
||||||
int isett=-1,val=-1,retval=-1;
|
/* int isett=-1,val=-1,retval=-1; */
|
||||||
enum conf_gain {
|
/* enum conf_gain { */
|
||||||
dynamic = 0x0f00, //dynamic
|
/* dynamic = 0x0f00, //dynamic */
|
||||||
dynamichighgain0 = 0x0f01, //dynamichighgain0
|
/* dynamichighgain0 = 0x0f01, //dynamichighgain0 */
|
||||||
fixgain1 = 0x0f02, //fixgain1
|
/* fixgain1 = 0x0f02, //fixgain1 */
|
||||||
fixgain2 = 0x0f06, //fixgain2
|
/* fixgain2 = 0x0f06, //fixgain2 */
|
||||||
forceswitchgain1 = 0x1f00, //forceswitchgain1
|
/* forceswitchgain1 = 0x1f00, //forceswitchgain1 */
|
||||||
forceswitchgain2 = 0x3f00 //forceswitchgain2
|
/* forceswitchgain2 = 0x3f00 //forceswitchgain2 */
|
||||||
};
|
/* }; */
|
||||||
|
|
||||||
//determine conf value to write
|
/* //determine conf value to write */
|
||||||
if(i!=GET_SETTINGS){
|
/* if(i!=GET_SETTINGS){ */
|
||||||
switch(i){
|
/* switch(i){ */
|
||||||
case DYNAMICGAIN: val = dynamic;break;
|
/* case DYNAMICGAIN: val = dynamic;break; */
|
||||||
case DYNAMICHG0: val = dynamichighgain0;break;
|
/* case DYNAMICHG0: val = dynamichighgain0;break; */
|
||||||
case FIXGAIN1: val = fixgain1;break;
|
/* case FIXGAIN1: val = fixgain1;break; */
|
||||||
case FIXGAIN2: val = fixgain2;break;
|
/* case FIXGAIN2: val = fixgain2;break; */
|
||||||
case FORCESWITCHG1: val = forceswitchgain1;break;
|
/* case FORCESWITCHG1: val = forceswitchgain1;break; */
|
||||||
case FORCESWITCHG2: val = forceswitchgain2;break;
|
/* case FORCESWITCHG2: val = forceswitchgain2;break; */
|
||||||
default:
|
/* default: */
|
||||||
printf("Error: This settings is not defined for this detector %d\n",i);
|
/* printf("Error: This settings is not defined for this detector %d\n",i); */
|
||||||
return GET_SETTINGS;
|
/* return GET_SETTINGS; */
|
||||||
}
|
/* } */
|
||||||
}
|
/* } */
|
||||||
|
|
||||||
retval=initConfGainByModule(i,val,imod);
|
/* retval=initConfGainByModule(i,val,imod); */
|
||||||
|
|
||||||
switch(retval){
|
/* switch(retval){ */
|
||||||
case dynamic: isett=DYNAMICGAIN; break;
|
/* case dynamic: isett=DYNAMICGAIN; break; */
|
||||||
case dynamichighgain0: isett=DYNAMICHG0; break;
|
/* case dynamichighgain0: isett=DYNAMICHG0; break; */
|
||||||
case fixgain1: isett=FIXGAIN1; break;
|
/* case fixgain1: isett=FIXGAIN1; break; */
|
||||||
case fixgain2: isett=FIXGAIN2; break;
|
/* case fixgain2: isett=FIXGAIN2; break; */
|
||||||
case forceswitchgain1: isett=FORCESWITCHG1; break;
|
/* case forceswitchgain1: isett=FORCESWITCHG1; break; */
|
||||||
case forceswitchgain2: isett=FORCESWITCHG2; break;
|
/* case forceswitchgain2: isett=FORCESWITCHG2; break; */
|
||||||
default:
|
/* default: */
|
||||||
isett=UNDEFINED;
|
/* isett=UNDEFINED; */
|
||||||
printf("Error:Wrong settings read out from Gain Reg 0x%x\n",retval);
|
/* printf("Error:Wrong settings read out from Gain Reg 0x%x\n",retval); */
|
||||||
break;
|
/* break; */
|
||||||
}
|
/* } */
|
||||||
|
|
||||||
thisSettings=isett;
|
/* thisSettings=isett; */
|
||||||
//#ifdef VERBOSE
|
/* //#ifdef VERBOSE */
|
||||||
printf("detector settings are %d\n",thisSettings);
|
/* printf("detector settings are %d\n",thisSettings); */
|
||||||
//#endif
|
/* //#endif */
|
||||||
return thisSettings;
|
return thisSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,16 @@
|
|||||||
|
|
||||||
//#ifdef JUNGFRAU_DHANYA
|
//#ifdef JUNGFRAU_DHANYA
|
||||||
#define POWER_ON_REG 0x5e<<11
|
#define POWER_ON_REG 0x5e<<11
|
||||||
|
// Pwr_I2C_SDA <= PowerReg_s(1) when PowerReg_s(3)='1' else 'Z';
|
||||||
|
// Pwr_I2C_SCL <= PowerReg_s(0) when PowerReg_s(2)='1' else 'Z';
|
||||||
|
|
||||||
|
#define PWR_I2C_SCL_BIT 0
|
||||||
|
#define PWR_I2C_SDA_BIT 1
|
||||||
|
#define PWR_I2C_SCL_EN_BIT 2
|
||||||
|
#define PWR_I2C_SDA_EN_BIT 3
|
||||||
|
|
||||||
|
#define POWER_STATUS_REG 41<<11
|
||||||
|
|
||||||
#define ADCREG1 0x08
|
#define ADCREG1 0x08
|
||||||
#define ADCREG2 0x14//20
|
#define ADCREG2 0x14//20
|
||||||
#define ADCREG3 0x4
|
#define ADCREG3 0x4
|
||||||
@ -32,7 +42,7 @@
|
|||||||
#define ADC_PIPELINE_REG 66<<11 //0x42 same as ADC_OFFSET_REG
|
#define ADC_PIPELINE_REG 66<<11 //0x42 same as ADC_OFFSET_REG
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
#define ADC_OFFSET_REG 93<<11 //same as DAQ_REG
|
//#define ADC_OFFSET_REG 93<<11 //same as DAQ_REG
|
||||||
#define ADC_INVERSION_REG 67<<11
|
#define ADC_INVERSION_REG 67<<11
|
||||||
|
|
||||||
#define DAC_REG 64<<11//0x17<<11// control the dacs
|
#define DAC_REG 64<<11//0x17<<11// control the dacs
|
||||||
@ -63,7 +73,7 @@
|
|||||||
#define STATUS_REG 2<<11 //0x25<<11
|
#define STATUS_REG 2<<11 //0x25<<11
|
||||||
#define CONFIG_REG 77<<11//0x26<<11
|
#define CONFIG_REG 77<<11//0x26<<11
|
||||||
#define EXT_SIGNAL_REG 78<<11// 0x27<<11
|
#define EXT_SIGNAL_REG 78<<11// 0x27<<11
|
||||||
#define FPGA_SVN_REG 0x29<<11
|
//#define FPGA_SVN_REG 0x29<<11
|
||||||
|
|
||||||
|
|
||||||
#define CHIP_OF_INTRST_REG 0x2A<<11
|
#define CHIP_OF_INTRST_REG 0x2A<<11
|
||||||
@ -88,7 +98,6 @@
|
|||||||
//user entered
|
//user entered
|
||||||
|
|
||||||
|
|
||||||
#define NSAMPLES_REG 95<<11
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -185,10 +194,14 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define DAQ_REG 93<<11
|
//#define DAQ_REG 93<<11 //unused
|
||||||
|
#define NSAMPLES_REG 93<<11
|
||||||
|
|
||||||
|
|
||||||
#define HV_REG 95<<11
|
#define HV_REG 95<<11
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define PATTERN_IOCTRL_REG_LSB 108<<11
|
#define PATTERN_IOCTRL_REG_LSB 108<<11
|
||||||
#define PATTERN_IOCTRL_REG_MSB 109<<11
|
#define PATTERN_IOCTRL_REG_MSB 109<<11
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "server_defs.h"
|
#include "server_defs.h"
|
||||||
#include "firmware_funcs.h"
|
#include "firmware_funcs.h"
|
||||||
#include "mcb_funcs.h"
|
#include "mcb_funcs.h"
|
||||||
|
#include "slow_adc.h"
|
||||||
#include "registers_m.h"
|
#include "registers_m.h"
|
||||||
#include "gitInfoMoench.h"
|
#include "gitInfoMoench.h"
|
||||||
|
|
||||||
@ -72,10 +73,7 @@ int init_detector(int b, int checkType) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//print version
|
// defineGPIOpins();
|
||||||
printf("v: 0x%x\n",bus_r(FPGA_VERSION_REG));
|
|
||||||
printf("fp: 0x%x\n",bus_r(FIX_PATT_REG));
|
|
||||||
|
|
||||||
//checktype
|
//checktype
|
||||||
if (checkType) {
|
if (checkType) {
|
||||||
printf("Bus test... (checktype is %d; b is %d)",checkType,b );
|
printf("Bus test... (checktype is %d; b is %d)",checkType,b );
|
||||||
@ -123,44 +121,8 @@ int init_detector(int b, int checkType) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
printf("Detector type is %d\n", myDetectorType);
|
printf("Detector type is %d\n", myDetectorType);
|
||||||
|
if (b)
|
||||||
|
initDetector();
|
||||||
//control server only--
|
|
||||||
if (b) {
|
|
||||||
resetPLL();
|
|
||||||
bus_w16(CONTROL_REG, SYNC_RESET);
|
|
||||||
bus_w16(CONTROL_REG, 0);
|
|
||||||
bus_w16(CONTROL_REG, GB10_RESET_BIT);
|
|
||||||
bus_w16(CONTROL_REG, 0);
|
|
||||||
|
|
||||||
#ifdef MCB_FUNCS
|
|
||||||
printf("\nBoard Revision:0x%x\n",(bus_r(PCB_REV_REG)&BOARD_REVISION_MASK));
|
|
||||||
// if(myDetectorType == JUNGFRAU)
|
|
||||||
initDetector(); /*allocating detectorModules, detectorsDacs etc for "settings", also does allocate RAM*/
|
|
||||||
dataBytes=NMAXMOD*N_CHIP*N_CHAN*2; /**Nchip and Nchan real values get assigned in initDetector()*/
|
|
||||||
printf("Initializing Detector\n");
|
|
||||||
//bus_w16(CONTROL_REG, SYNC_RESET); // reset registers
|
|
||||||
#endif
|
|
||||||
if (myDetectorType==JUNGFRAUCTB) prepareSlowADCSeq();
|
|
||||||
|
|
||||||
prepareADC();
|
|
||||||
|
|
||||||
|
|
||||||
//Initialization of acquistion parameters
|
|
||||||
setFrames(-1);
|
|
||||||
setTrains(-1);
|
|
||||||
setExposureTime(-1);
|
|
||||||
setPeriod(-1);
|
|
||||||
setDelay(-1);
|
|
||||||
setGates(-1);
|
|
||||||
|
|
||||||
setTiming(GET_EXTERNAL_COMMUNICATION_MODE);
|
|
||||||
setMaster(GET_MASTER);
|
|
||||||
setSynchronization(GET_SYNCHRONIZATION_MODE);
|
|
||||||
startReceiver(0); //firmware
|
|
||||||
}//end of control server only--
|
|
||||||
else printf("\n\n");
|
|
||||||
|
|
||||||
|
|
||||||
//common for both control and stop server
|
//common for both control and stop server
|
||||||
strcpy(mess,"dummy message");
|
strcpy(mess,"dummy message");
|
||||||
@ -171,12 +133,6 @@ int init_detector(int b, int checkType) {
|
|||||||
|
|
||||||
/* both these functions setROI and allocateRAM should go into the control server part. */
|
/* both these functions setROI and allocateRAM should go into the control server part. */
|
||||||
|
|
||||||
int retvalsize,ret;
|
|
||||||
setROI(-1,NULL,&retvalsize,&ret);
|
|
||||||
allocateRAM();
|
|
||||||
|
|
||||||
setSamples(1);
|
|
||||||
bus_w(DAC_REG,0xffff);
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,7 +223,9 @@ int function_table() {
|
|||||||
flist[F_CALIBRATE_PEDESTAL]=&calibrate_pedestal;
|
flist[F_CALIBRATE_PEDESTAL]=&calibrate_pedestal;
|
||||||
flist[F_SET_CTB_PATTERN]=&set_ctb_pattern;
|
flist[F_SET_CTB_PATTERN]=&set_ctb_pattern;
|
||||||
flist[F_WRITE_ADC_REG]=&write_adc_register;
|
flist[F_WRITE_ADC_REG]=&write_adc_register;
|
||||||
|
flist[F_PROGRAM_FPGA]=&program_fpga;
|
||||||
flist[F_POWER_CHIP]=&power_chip;
|
flist[F_POWER_CHIP]=&power_chip;
|
||||||
|
flist[F_RESET_FPGA]=&reset_fpga;
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -735,49 +693,7 @@ int digital_test(int file_des) {
|
|||||||
printf("of module %d\n", imod);
|
printf("of module %d\n", imod);
|
||||||
#endif
|
#endif
|
||||||
retval=0;
|
retval=0;
|
||||||
#ifdef MCB_FUNCS
|
|
||||||
if (differentClients==1 && lockStatus==1) {
|
|
||||||
ret=FAIL;
|
|
||||||
sprintf(mess,"Detector locked by %s\n",lastClientIP);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (imod >= nModX) {
|
|
||||||
ret=FAIL;
|
|
||||||
sprintf(mess,"Module %d disabled\n",imod);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (testShiftIn(imod)) retval|=(1<<(ibit));
|
|
||||||
ibit++;
|
|
||||||
if (testShiftOut(imod)) retval|=(1<<(ibit));
|
|
||||||
ibit++;
|
|
||||||
if (testShiftStSel(imod)) retval|=(1<<(ibit));
|
|
||||||
ibit++;
|
|
||||||
//if ( testDataInOut(0x123456, imod)) retval|=(1<<(ibit++));
|
|
||||||
//if ( testExtPulse(imod)) retval|=(1<<(ibit++));
|
|
||||||
// for (ow=0; ow<6; ow++)
|
|
||||||
// ow=1;
|
|
||||||
//#ifndef PICASSOD
|
|
||||||
for (ow=0; ow<5; ow++) {
|
|
||||||
//#endif
|
|
||||||
if (testDataInOutMux(imod, ow, 0x789abc)) retval|=(1<<ibit);
|
|
||||||
ibit++;
|
|
||||||
}
|
|
||||||
//for (ow=0; ow<6; ow++)
|
|
||||||
// ow=1;
|
|
||||||
//#ifndef PICASSOD
|
|
||||||
for (ow=0; ow<5; ow++) {
|
|
||||||
//#endif
|
|
||||||
if (testExtPulseMux(imod, ow)) retval|=(1<<ibit);
|
|
||||||
ibit++;
|
|
||||||
}
|
|
||||||
//#ifndef PICASSOD
|
|
||||||
if ( testOutMux(imod)) retval|=(1<<(ibit));
|
|
||||||
ibit++;
|
|
||||||
if (testFpgaMux(imod)) retval|=(1<<(ibit));
|
|
||||||
ibit++;
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case MODULE_FIRMWARE_TEST:
|
case MODULE_FIRMWARE_TEST:
|
||||||
retval=0x2;
|
retval=0x2;
|
||||||
@ -1062,7 +978,7 @@ int set_dac(int file_des) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case HV_NEW:
|
case HV_NEW:
|
||||||
retval=initHighVoltageByModule(val,imod);
|
retval=initHighVoltage(val,imod);//ByModule
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case V_POWER_A:
|
case V_POWER_A:
|
||||||
@ -1153,6 +1069,7 @@ int get_adc(int file_des) {
|
|||||||
int imod;
|
int imod;
|
||||||
int n;
|
int n;
|
||||||
int idac=0;
|
int idac=0;
|
||||||
|
int ipwr=-1;
|
||||||
|
|
||||||
sprintf(mess,"Can't read ADC\n");
|
sprintf(mess,"Can't read ADC\n");
|
||||||
|
|
||||||
@ -1172,7 +1089,7 @@ int get_adc(int file_des) {
|
|||||||
if (imod>=getNModBoard() || imod<0)
|
if (imod>=getNModBoard() || imod<0)
|
||||||
ret=FAIL;
|
ret=FAIL;
|
||||||
|
|
||||||
#ifdef MCB_FUNCS
|
//#ifdef MCB_FUNCS
|
||||||
switch (ind) {
|
switch (ind) {
|
||||||
case TEMPERATURE_FPGA:
|
case TEMPERATURE_FPGA:
|
||||||
idac=TEMP_FPGA;
|
idac=TEMP_FPGA;
|
||||||
@ -1180,16 +1097,51 @@ int get_adc(int file_des) {
|
|||||||
case TEMPERATURE_ADC:
|
case TEMPERATURE_ADC:
|
||||||
idac=TEMP_ADC;
|
idac=TEMP_ADC;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case V_POWER_D:
|
||||||
|
idac++;
|
||||||
|
case V_POWER_C:
|
||||||
|
idac++;
|
||||||
|
case V_POWER_B:
|
||||||
|
idac++;
|
||||||
|
case V_POWER_A:
|
||||||
|
idac++;
|
||||||
|
case V_POWER_IO:
|
||||||
|
idac+=100;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case I_POWER_D:
|
||||||
|
idac++;
|
||||||
|
case I_POWER_C:
|
||||||
|
idac++;
|
||||||
|
case I_POWER_B:
|
||||||
|
idac++;
|
||||||
|
case I_POWER_A:
|
||||||
|
idac++;
|
||||||
|
case I_POWER_IO:
|
||||||
|
idac+=200;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
printf("Unknown DAC index %d\n",ind);
|
// printf("Unknown DAC index %d\n",ind);
|
||||||
sprintf(mess,"Unknown DAC index %d\n",ind);
|
sprintf(mess,"Unknown DAC index %d\n",ind);
|
||||||
ret=FAIL;
|
ret=FAIL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
printf("DAC index %d (%d)\n",idac,ind);
|
||||||
|
|
||||||
if (ret==OK)
|
if (ret==OK) {
|
||||||
retval=getTemperatureByModule(idac,imod);
|
|
||||||
else {
|
|
||||||
|
if (idac>=200)
|
||||||
|
retval=getCurrent(idac-200);
|
||||||
|
else if (idac>=100)
|
||||||
|
retval=getVoltage(idac-100);
|
||||||
|
else
|
||||||
|
retval=getTemperature(idac);
|
||||||
|
|
||||||
|
|
||||||
|
}else if (ind>=1000) {
|
||||||
retval=readSlowADC(ind-1000);
|
retval=readSlowADC(ind-1000);
|
||||||
if (retval>=0) {
|
if (retval>=0) {
|
||||||
ret=OK;
|
ret=OK;
|
||||||
@ -1198,7 +1150,7 @@ int get_adc(int file_des) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("ADC is %d V\n", retval);
|
printf("ADC is %d V\n", retval);
|
||||||
@ -1263,9 +1215,7 @@ int set_channel(int file_des) {
|
|||||||
ret=FAIL;
|
ret=FAIL;
|
||||||
sprintf(mess,"Detector locked by %s\n",lastClientIP);
|
sprintf(mess,"Detector locked by %s\n",lastClientIP);
|
||||||
} else {
|
} else {
|
||||||
#ifdef MCB_FUNCS
|
|
||||||
retval=initChannelbyNumber(myChan);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Maybe this is done inside the initialization funcs */
|
/* Maybe this is done inside the initialization funcs */
|
||||||
@ -1338,9 +1288,6 @@ int get_channel(int file_des) {
|
|||||||
|
|
||||||
|
|
||||||
if (ret==OK) {
|
if (ret==OK) {
|
||||||
#ifdef MCB_FUNCS
|
|
||||||
ret=getChannelbyNumber(&retval);
|
|
||||||
#endif
|
|
||||||
if (differentClients && ret==OK)
|
if (differentClients && ret==OK)
|
||||||
ret=FORCE_UPDATE;
|
ret=FORCE_UPDATE;
|
||||||
}
|
}
|
||||||
@ -1410,9 +1357,7 @@ int set_chip(int file_des) {
|
|||||||
ret=FAIL;
|
ret=FAIL;
|
||||||
sprintf(mess,"Detector locked by %s\n",lastClientIP);
|
sprintf(mess,"Detector locked by %s\n",lastClientIP);
|
||||||
} else {
|
} else {
|
||||||
#ifdef MCB_FUNCS
|
;
|
||||||
retval=initChipbyNumber(myChip);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
/* Maybe this is done inside the initialization funcs */
|
/* Maybe this is done inside the initialization funcs */
|
||||||
//copyChip(detectorChips[myChip.module]+(myChip.chip), &myChip);
|
//copyChip(detectorChips[myChip.module]+(myChip.chip), &myChip);
|
||||||
@ -1467,9 +1412,6 @@ int get_chip(int file_des) {
|
|||||||
|
|
||||||
|
|
||||||
if (ret==OK) {
|
if (ret==OK) {
|
||||||
#ifdef MCB_FUNCS
|
|
||||||
ret=getChipbyNumber(&retval);
|
|
||||||
#endif
|
|
||||||
if (differentClients && ret==OK)
|
if (differentClients && ret==OK)
|
||||||
ret=FORCE_UPDATE;
|
ret=FORCE_UPDATE;
|
||||||
}
|
}
|
||||||
@ -1584,11 +1526,6 @@ int set_module(int file_des) {
|
|||||||
ret=FAIL;
|
ret=FAIL;
|
||||||
sprintf(mess,"Detector locked by %s\n",lastClientIP);
|
sprintf(mess,"Detector locked by %s\n",lastClientIP);
|
||||||
} else {
|
} else {
|
||||||
#ifdef MCB_FUNCS
|
|
||||||
retval=initModulebyNumber(myModule);
|
|
||||||
if(retval != myModule.reg)
|
|
||||||
ret = FAIL;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1694,9 +1631,6 @@ int get_module(int file_des) {
|
|||||||
if (imod>=0 && imod<getNModBoard()) {
|
if (imod>=0 && imod<getNModBoard()) {
|
||||||
ret=OK;
|
ret=OK;
|
||||||
myModule.module=imod;
|
myModule.module=imod;
|
||||||
#ifdef MCB_FUNCS
|
|
||||||
getModulebyNumber(&myModule);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("Returning module %d of register %x\n", imod, myModule.reg);
|
printf("Returning module %d of register %x\n", imod, myModule.reg);
|
||||||
@ -1803,9 +1737,9 @@ int set_settings(int file_des) {
|
|||||||
ret=FAIL;
|
ret=FAIL;
|
||||||
sprintf(mess,"Detector locked by %s\n",lastClientIP);
|
sprintf(mess,"Detector locked by %s\n",lastClientIP);
|
||||||
} else {
|
} else {
|
||||||
#ifdef MCB_FUNCS
|
/* #ifdef MCB_FUNCS */
|
||||||
retval=setSettings(arg[0],imod);
|
/* retval=setSettings(arg[0],imod); */
|
||||||
#endif
|
/* #endif */
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("Settings changed to %d\n",retval);
|
printf("Settings changed to %d\n",retval);
|
||||||
#endif
|
#endif
|
||||||
@ -1948,36 +1882,7 @@ int get_run_status(int file_des) {
|
|||||||
|
|
||||||
retval= runState();
|
retval= runState();
|
||||||
printf("\n\nSTATUS=%08x\n",retval);
|
printf("\n\nSTATUS=%08x\n",retval);
|
||||||
if(myDetectorType == JUNGFRAU){
|
|
||||||
printf("Detector type jungfrau? %d\n",myDetectorType);
|
|
||||||
if(!(retval&RUN_BUSY_BIT)){
|
|
||||||
|
|
||||||
if((retval&READMACHINE_BUSY_BIT) ){
|
|
||||||
printf("-----------------------------------JF READ MACHINE BUSY--------------------------\n");
|
|
||||||
s=TRANSMITTING;
|
|
||||||
}
|
|
||||||
//and readbusy=0,idle
|
|
||||||
else if((!(retval&0xffff))||(retval==SOME_FIFO_FULL_BIT)){
|
|
||||||
printf("-----------------------------------JF IDLE--------------------------------------\n");
|
|
||||||
s=IDLE;
|
|
||||||
} else {
|
|
||||||
printf("-----------------------------------JF Unknown status %08x--------------------------------------\n", retval);
|
|
||||||
s=ERROR;
|
|
||||||
ret=FAIL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//if runbusy=1
|
|
||||||
else {
|
|
||||||
if (retval&WAITING_FOR_TRIGGER_BIT){
|
|
||||||
printf("-----------------------------------JF WAITING-----------------------------------\n");
|
|
||||||
s=WAITING;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
printf("-----------------------------------JF RUNNING-----------------------------------\n");
|
|
||||||
s=RUNNING;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//error
|
//error
|
||||||
if(retval&SOME_FIFO_FULL_BIT){
|
if(retval&SOME_FIFO_FULL_BIT){
|
||||||
printf("-----------------------------------ERROR--------------------------------------x%0x\n",retval);
|
printf("-----------------------------------ERROR--------------------------------------x%0x\n",retval);
|
||||||
@ -2011,7 +1916,6 @@ int get_run_status(int file_des) {
|
|||||||
s=RUNNING;
|
s=RUNNING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (ret!=OK) {
|
if (ret!=OK) {
|
||||||
printf("get status failed %04x\n",retval);
|
printf("get status failed %04x\n",retval);
|
||||||
sprintf(mess, "get status failed %08x\n", retval);
|
sprintf(mess, "get status failed %08x\n", retval);
|
||||||
@ -2053,13 +1957,13 @@ int read_frame(int file_des) {
|
|||||||
nframes++;
|
nframes++;
|
||||||
dataretval=(char*)ram_values;
|
dataretval=(char*)ram_values;
|
||||||
dataret=OK;
|
dataret=OK;
|
||||||
//#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("sending data of %d frames\n",nframes);
|
printf("sending data of %d frames\n",nframes);
|
||||||
//#endif
|
#endif
|
||||||
sendDataOnly(file_des,&dataret,sizeof(dataret));
|
sendDataOnly(file_des,&dataret,sizeof(dataret));
|
||||||
//#ifdef VERYVERBOSE
|
#ifdef VERYVERBOSE
|
||||||
printf("sending pointer %x of size %d\n",(unsigned int)(dataretval),dataBytes);
|
printf("sending pointer %x of size %d\n",(unsigned int)(dataretval),dataBytes);
|
||||||
//#endif
|
#endif
|
||||||
n=sendDataOnly(file_des,dataretval,dataBytes);
|
n=sendDataOnly(file_des,dataretval,dataBytes);
|
||||||
printf("Sent %d bytes\n",n);
|
printf("Sent %d bytes\n",n);
|
||||||
} else {
|
} else {
|
||||||
@ -2523,6 +2427,13 @@ int set_speed(int file_des) {
|
|||||||
|
|
||||||
case CLOCK_DIVIDER:
|
case CLOCK_DIVIDER:
|
||||||
retval=configureFrequency(val,run_clk_c);//setClockDivider(val,0);
|
retval=configureFrequency(val,run_clk_c);//setClockDivider(val,0);
|
||||||
|
if (configureFrequency(-1,sync_clk_c)>retval) {
|
||||||
|
configureFrequency(retval,sync_clk_c);
|
||||||
|
printf("--Configuring sync clk to %d MHz\n",val);
|
||||||
|
} else if (configureFrequency(-1,dbit_clk_c)>val && configureFrequency(-1,adc_clk_c)>retval) {
|
||||||
|
printf("++Configuring sync clk to %d MHz\n",val);
|
||||||
|
configureFrequency(retval,sync_clk_c);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* case PHASE_SHIFT: */
|
/* case PHASE_SHIFT: */
|
||||||
@ -2535,11 +2446,25 @@ int set_speed(int file_des) {
|
|||||||
|
|
||||||
case ADC_CLOCK:
|
case ADC_CLOCK:
|
||||||
retval=configureFrequency(val,adc_clk_c);//setClockDivider(val,1);
|
retval=configureFrequency(val,adc_clk_c);//setClockDivider(val,1);
|
||||||
configureFrequency(val,sync_clk_c);
|
if (configureFrequency(-1,sync_clk_c)>val) {
|
||||||
|
configureFrequency(retval,sync_clk_c);
|
||||||
|
printf("--Configuring sync clk to %d MHz\n",val);
|
||||||
|
} else if (configureFrequency(-1,dbit_clk_c)>val && configureFrequency(-1,run_clk_c)>retval) {
|
||||||
|
printf("++Configuring sync clk to %d MHz\n",val);
|
||||||
|
configureFrequency(retval,sync_clk_c);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DBIT_CLOCK:
|
case DBIT_CLOCK:
|
||||||
retval=configureFrequency(val,dbit_clk_c);//setClockDivider(val,2);
|
retval=configureFrequency(val,dbit_clk_c);//setClockDivider(val,2);
|
||||||
|
if (configureFrequency(-1,sync_clk_c)>retval){
|
||||||
|
configureFrequency(retval,sync_clk_c);
|
||||||
|
printf("--Configuring sync clk to %d MHz\n",val);
|
||||||
|
} else if (configureFrequency(-1,adc_clk_c)>retval && configureFrequency(-1,run_clk_c)>retval) {
|
||||||
|
printf("++Configuring sync clk to %d MHz\n",val);
|
||||||
|
configureFrequency(retval,sync_clk_c);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
@ -2760,7 +2685,7 @@ int send_update(int file_des) {
|
|||||||
n = sendDataOnly(file_des,&nModY,sizeof(nModY));
|
n = sendDataOnly(file_des,&nModY,sizeof(nModY));
|
||||||
n = sendDataOnly(file_des,&dynamicRange,sizeof(dynamicRange));
|
n = sendDataOnly(file_des,&dynamicRange,sizeof(dynamicRange));
|
||||||
n = sendDataOnly(file_des,&dataBytes,sizeof(dataBytes));
|
n = sendDataOnly(file_des,&dataBytes,sizeof(dataBytes));
|
||||||
t=setSettings(GET_SETTINGS,-1);
|
t=GET_SETTINGS;//setSettings(GET_SETTINGS,-1);
|
||||||
n = sendDataOnly(file_des,&t,sizeof(t));
|
n = sendDataOnly(file_des,&t,sizeof(t));
|
||||||
/* thr=getThresholdEnergy();
|
/* thr=getThresholdEnergy();
|
||||||
n = sendDataOnly(file_des,&thr,sizeof(thr));*/
|
n = sendDataOnly(file_des,&thr,sizeof(thr));*/
|
||||||
@ -2859,7 +2784,7 @@ int configure_mac(int file_des) {
|
|||||||
//#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
printf("Configuring MAC of module %d at port %x\n", imod, udpport);
|
printf("Configuring MAC of module %d at port %x\n", imod, udpport);
|
||||||
//#endif
|
//#endif
|
||||||
#ifdef MCB_FUNCS
|
//#ifdef MCB_FUNCS
|
||||||
if (ret==OK){
|
if (ret==OK){
|
||||||
if(runBusy()){
|
if(runBusy()){
|
||||||
ret=stopStateMachine();
|
ret=stopStateMachine();
|
||||||
@ -2871,7 +2796,7 @@ int configure_mac(int file_des) {
|
|||||||
configureMAC(ipad,imacadd,idetectormacadd,detipad,digitalTestBit,udpport);
|
configureMAC(ipad,imacadd,idetectormacadd,detipad,digitalTestBit,udpport);
|
||||||
retval=getAdcConfigured();
|
retval=getAdcConfigured();
|
||||||
}
|
}
|
||||||
#endif
|
//#endif
|
||||||
if (ret==FAIL)
|
if (ret==FAIL)
|
||||||
printf("configuring MAC of mod %d failed\n", imod);
|
printf("configuring MAC of mod %d failed\n", imod);
|
||||||
else
|
else
|
||||||
@ -3196,7 +3121,7 @@ int stop_receiver(int file_des) {
|
|||||||
strcpy(mess,"Could not stop receiver\n");
|
strcpy(mess,"Could not stop receiver\n");
|
||||||
|
|
||||||
/* execute action if the arguments correctly arrived*/
|
/* execute action if the arguments correctly arrived*/
|
||||||
#ifdef MCB_FUNCS
|
//#ifdef MCB_FUNCS
|
||||||
if (lockStatus==1 && differentClients==1){//necessary???
|
if (lockStatus==1 && differentClients==1){//necessary???
|
||||||
sprintf(mess,"Detector locked by %s\n", lastClientIP);
|
sprintf(mess,"Detector locked by %s\n", lastClientIP);
|
||||||
ret=FAIL;
|
ret=FAIL;
|
||||||
@ -3204,7 +3129,7 @@ int stop_receiver(int file_des) {
|
|||||||
else
|
else
|
||||||
ret=startReceiver(0);
|
ret=startReceiver(0);
|
||||||
|
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
|
|
||||||
if(ret==OK && differentClients){
|
if(ret==OK && differentClients){
|
||||||
@ -3536,3 +3461,160 @@ int power_chip(int file_des) {
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int reset_fpga(int file_des) {
|
||||||
|
int ret=OK;
|
||||||
|
int n;
|
||||||
|
sprintf(mess,"Reset FPGA unsuccessful\n");
|
||||||
|
|
||||||
|
resetFPGA();
|
||||||
|
initializeDetector();
|
||||||
|
|
||||||
|
ret = FORCE_UPDATE;
|
||||||
|
n = sendDataOnly(file_des,&ret,sizeof(ret));
|
||||||
|
if (ret==FAIL)
|
||||||
|
n += sendDataOnly(file_des,mess,sizeof(mess));
|
||||||
|
|
||||||
|
/*return ok/fail*/
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int program_fpga(int file_des) {
|
||||||
|
int ret=OK;
|
||||||
|
int n;
|
||||||
|
sprintf(mess,"Program FPGA unsuccessful\n");
|
||||||
|
char* fpgasrc = NULL;
|
||||||
|
FILE* fp = NULL;
|
||||||
|
size_t filesize = 0;
|
||||||
|
size_t unitprogramsize = 0;
|
||||||
|
size_t totalsize = 0;
|
||||||
|
|
||||||
|
|
||||||
|
//filesize
|
||||||
|
n = receiveDataOnly(file_des,&filesize,sizeof(filesize));
|
||||||
|
if (n < 0) {
|
||||||
|
sprintf(mess,"Error reading from socket\n");
|
||||||
|
ret=FAIL;
|
||||||
|
}
|
||||||
|
totalsize = filesize;
|
||||||
|
#ifdef VERY_VERBOSE
|
||||||
|
printf("\n\n Total size is:%d\n",totalsize);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//lock
|
||||||
|
if (ret==OK && differentClients==1 && lockStatus==1) {
|
||||||
|
ret=FAIL;
|
||||||
|
sprintf(mess,"Detector locked by %s\n",lastClientIP);
|
||||||
|
filesize = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//opening file pointer to flash and telling FPGA to not touch flash
|
||||||
|
if(ret == OK && startWritingFPGAprogram(&fp) != OK){
|
||||||
|
sprintf(mess,"Could not write to flash. Error at startup.\n");
|
||||||
|
cprintf(RED,"%s",mess);
|
||||||
|
ret=FAIL;
|
||||||
|
filesize = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------- first ret ----------------
|
||||||
|
n = sendDataOnly(file_des,&ret,sizeof(ret));
|
||||||
|
if (ret==FAIL)
|
||||||
|
n += sendDataOnly(file_des,mess,sizeof(mess));
|
||||||
|
//---------------- first ret ----------------
|
||||||
|
|
||||||
|
|
||||||
|
//erasing flash
|
||||||
|
if(ret != FAIL){
|
||||||
|
eraseFlash();
|
||||||
|
fpgasrc = (char*)malloc(MAX_FPGAPROGRAMSIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//writing to flash part by part
|
||||||
|
while(ret != FAIL && filesize){
|
||||||
|
|
||||||
|
unitprogramsize = MAX_FPGAPROGRAMSIZE; //2mb
|
||||||
|
if(unitprogramsize > filesize) //less than 2mb
|
||||||
|
unitprogramsize = filesize;
|
||||||
|
#ifdef VERY_VERBOSE
|
||||||
|
printf("unit size to receive is:%d\n",unitprogramsize);
|
||||||
|
printf("filesize:%d currentpointer:%d\n",filesize,currentPointer);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
//receive
|
||||||
|
n = receiveDataOnly(file_des,fpgasrc,unitprogramsize);
|
||||||
|
if (n < 0) {
|
||||||
|
sprintf(mess,"Error reading from socket\n");
|
||||||
|
ret=FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (ret==OK) {
|
||||||
|
if(!(unitprogramsize - filesize)){
|
||||||
|
fpgasrc[unitprogramsize]='\0';
|
||||||
|
filesize-=unitprogramsize;
|
||||||
|
unitprogramsize++;
|
||||||
|
}else
|
||||||
|
filesize-=unitprogramsize;
|
||||||
|
|
||||||
|
ret = writeFPGAProgram(fpgasrc,unitprogramsize,fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//---------------- middle rets ----------------
|
||||||
|
n = sendDataOnly(file_des,&ret,sizeof(ret));
|
||||||
|
if (ret==FAIL) {
|
||||||
|
n += sendDataOnly(file_des,mess,sizeof(mess));
|
||||||
|
cprintf(RED,"Failure: Breaking out of program receiving\n");
|
||||||
|
}
|
||||||
|
//---------------- middle rets ----------------
|
||||||
|
|
||||||
|
|
||||||
|
if(ret != FAIL){
|
||||||
|
//print progress
|
||||||
|
printf("Writing to Flash:%d%%\r",(int) (((double)(totalsize-filesize)/totalsize)*100) );
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
//closing file pointer to flash and informing FPGA
|
||||||
|
if(stopWritingFPGAprogram(fp) == FAIL){
|
||||||
|
sprintf(mess,"Could not write to flash. Error at end.\n");
|
||||||
|
cprintf(RED,"%s",mess);
|
||||||
|
ret=FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ret!=FAIL){
|
||||||
|
ret=FORCE_UPDATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//---------------- last ret ----------------
|
||||||
|
n = sendDataOnly(file_des,&ret,sizeof(ret));
|
||||||
|
if (ret==FAIL)
|
||||||
|
n += sendDataOnly(file_des,mess,sizeof(mess));
|
||||||
|
//---------------- last ret ----------------
|
||||||
|
|
||||||
|
|
||||||
|
//free resources
|
||||||
|
if(fpgasrc != NULL)
|
||||||
|
free(fpgasrc);
|
||||||
|
if(fp!=NULL)
|
||||||
|
fclose(fp);
|
||||||
|
#ifdef VERY_VERBOSE
|
||||||
|
printf("Done with program receiving command\n");
|
||||||
|
#endif
|
||||||
|
/*return ok/fail*/
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -96,4 +96,7 @@ int set_ctb_pattern(int);
|
|||||||
|
|
||||||
int write_adc_register(int);
|
int write_adc_register(int);
|
||||||
int power_chip(int);
|
int power_chip(int);
|
||||||
|
int reset_fpga(int);
|
||||||
|
int program_fpga(int);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -6625,7 +6625,7 @@ int slsDetector::programFPGA(string fname){
|
|||||||
size_t filesize=0;
|
size_t filesize=0;
|
||||||
char* fpgasrc = NULL;
|
char* fpgasrc = NULL;
|
||||||
|
|
||||||
if(thisDetector->myDetectorType != JUNGFRAU){
|
if(thisDetector->myDetectorType != JUNGFRAU && thisDetector->myDetectorType != JUNGFRAUCTB){
|
||||||
std::cout << "Not implemented for this detector" << std::endl;
|
std::cout << "Not implemented for this detector" << std::endl;
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,6 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define MAX_SCAN_LEVELS 2
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -467,6 +467,15 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
|||||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdAdvanced;
|
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdAdvanced;
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* chip */
|
||||||
|
descrToFuncMap[i].m_pFuncName="led";
|
||||||
|
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdAdvanced;
|
||||||
|
i++;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* versions/ serial numbers getId */
|
/* versions/ serial numbers getId */
|
||||||
|
|
||||||
descrToFuncMap[i].m_pFuncName="moduleversion"; //
|
descrToFuncMap[i].m_pFuncName="moduleversion"; //
|
||||||
@ -835,6 +844,46 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
|||||||
i++;
|
i++;
|
||||||
|
|
||||||
|
|
||||||
|
descrToFuncMap[i].m_pFuncName="i_a"; //
|
||||||
|
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdADC;
|
||||||
|
i++;
|
||||||
|
|
||||||
|
descrToFuncMap[i].m_pFuncName="i_b"; //
|
||||||
|
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdADC;
|
||||||
|
i++;
|
||||||
|
|
||||||
|
descrToFuncMap[i].m_pFuncName="i_c"; //
|
||||||
|
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdADC;
|
||||||
|
i++;
|
||||||
|
|
||||||
|
descrToFuncMap[i].m_pFuncName="i_d"; //
|
||||||
|
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdADC;
|
||||||
|
i++;
|
||||||
|
|
||||||
|
descrToFuncMap[i].m_pFuncName="i_io"; //
|
||||||
|
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdADC;
|
||||||
|
i++;
|
||||||
|
|
||||||
|
descrToFuncMap[i].m_pFuncName="vm_a"; //
|
||||||
|
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdADC;
|
||||||
|
i++;
|
||||||
|
|
||||||
|
descrToFuncMap[i].m_pFuncName="vm_b"; //
|
||||||
|
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdADC;
|
||||||
|
i++;
|
||||||
|
|
||||||
|
descrToFuncMap[i].m_pFuncName="vm_c"; //
|
||||||
|
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdADC;
|
||||||
|
i++;
|
||||||
|
|
||||||
|
descrToFuncMap[i].m_pFuncName="vm_d"; //
|
||||||
|
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdADC;
|
||||||
|
i++;
|
||||||
|
|
||||||
|
descrToFuncMap[i].m_pFuncName="vm_io"; //
|
||||||
|
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdADC;
|
||||||
|
i++;
|
||||||
|
|
||||||
/* r/w timers */
|
/* r/w timers */
|
||||||
|
|
||||||
descrToFuncMap[i].m_pFuncName="timing"; //
|
descrToFuncMap[i].m_pFuncName="timing"; //
|
||||||
@ -4038,6 +4087,26 @@ string slsDetectorCommand::cmdADC(int narg, char *args[], int action) {
|
|||||||
adc=TEMPERATURE_FPGA2;
|
adc=TEMPERATURE_FPGA2;
|
||||||
else if (cmd=="temp_fpgafr")
|
else if (cmd=="temp_fpgafr")
|
||||||
adc=TEMPERATURE_FPGA3;
|
adc=TEMPERATURE_FPGA3;
|
||||||
|
else if (cmd=="i_a")
|
||||||
|
adc=I_POWER_A;
|
||||||
|
else if (cmd=="i_b")
|
||||||
|
adc=I_POWER_B;
|
||||||
|
else if (cmd=="i_c")
|
||||||
|
adc=I_POWER_C;
|
||||||
|
else if (cmd=="i_d")
|
||||||
|
adc=I_POWER_D;
|
||||||
|
else if (cmd=="vm_a")
|
||||||
|
adc=V_POWER_A;
|
||||||
|
else if (cmd=="vm_b")
|
||||||
|
adc=V_POWER_B;
|
||||||
|
else if (cmd=="vm_c")
|
||||||
|
adc=V_POWER_C;
|
||||||
|
else if (cmd=="vm_d")
|
||||||
|
adc=V_POWER_D;
|
||||||
|
else if (cmd=="vm_io")
|
||||||
|
adc=V_POWER_IO;
|
||||||
|
else if (cmd=="i_io")
|
||||||
|
adc=I_POWER_IO;
|
||||||
else
|
else
|
||||||
return string("cannot decode adc ")+cmd;
|
return string("cannot decode adc ")+cmd;
|
||||||
|
|
||||||
@ -4546,6 +4615,19 @@ string slsDetectorCommand::cmdAdvanced(int narg, char *args[], int action) {
|
|||||||
}
|
}
|
||||||
sprintf(ans,"%d",myDet->powerChip());
|
sprintf(ans,"%d",myDet->powerChip());
|
||||||
return string(ans);
|
return string(ans);
|
||||||
|
} else if (cmd=="led") {
|
||||||
|
char ans[100];
|
||||||
|
int val=0;
|
||||||
|
myDet->setOnline(ONLINE_FLAG);
|
||||||
|
if (action==PUT_ACTION){
|
||||||
|
int ival = -1;
|
||||||
|
if (!sscanf(args[1],"%d",&ival))
|
||||||
|
return string("could not scan powerchip parameter " + string(args[1]));
|
||||||
|
val=myDet->readRegister(0x4d);
|
||||||
|
myDet->writeRegister(0x4d,(val&(~1))|((~ival)&1));//config register
|
||||||
|
}
|
||||||
|
sprintf(ans,"%d",~(myDet->readRegister(0x4d))&1);
|
||||||
|
return string(ans);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return string("unknown command ")+cmd;
|
return string("unknown command ")+cmd;
|
||||||
@ -4563,11 +4645,13 @@ string slsDetectorCommand::helpAdvanced(int narg, char *args[], int action) {
|
|||||||
|
|
||||||
os << "programfpga f \t programs the fpga with file f (with .pof extension)." << std::endl;
|
os << "programfpga f \t programs the fpga with file f (with .pof extension)." << std::endl;
|
||||||
os << "resetfpga f \t resets fpga, f can be any value" << std::endl;
|
os << "resetfpga f \t resets fpga, f can be any value" << std::endl;
|
||||||
|
os << "led s \t sets led status (0 off, 1 on)" << std::endl;
|
||||||
}
|
}
|
||||||
if (action==GET_ACTION || action==HELP_ACTION) {
|
if (action==GET_ACTION || action==HELP_ACTION) {
|
||||||
|
|
||||||
os << "extsig:i \t gets the mode of the external signal i. can be \n \t \t \t off, \n \t \t \t gate_in_active_high, \n \t \t \t gate_in_active_low, \n \t \t \t trigger_in_rising_edge, \n \t \t \t trigger_in_falling_edge, \n \t \t \t ro_trigger_in_rising_edge, \n \t \t \t ro_trigger_in_falling_edge, \n \t \t \t gate_out_active_high, \n \t \t \t gate_out_active_low, \n \t \t \t trigger_out_rising_edge, \n \t \t \t trigger_out_falling_edge, \n \t \t \t ro_trigger_out_rising_edge, \n \t \t \t ro_trigger_out_falling_edge" << std::endl;
|
os << "extsig:i \t gets the mode of the external signal i. can be \n \t \t \t off, \n \t \t \t gate_in_active_high, \n \t \t \t gate_in_active_low, \n \t \t \t trigger_in_rising_edge, \n \t \t \t trigger_in_falling_edge, \n \t \t \t ro_trigger_in_rising_edge, \n \t \t \t ro_trigger_in_falling_edge, \n \t \t \t gate_out_active_high, \n \t \t \t gate_out_active_low, \n \t \t \t trigger_out_rising_edge, \n \t \t \t trigger_out_falling_edge, \n \t \t \t ro_trigger_out_rising_edge, \n \t \t \t ro_trigger_out_falling_edge" << std::endl;
|
||||||
os << "flags \t gets the readout flags. can be none, storeinram, tot, continous, parallel, nonparallel, safe, digital, analog_digital, unknown" << std::endl;
|
os << "flags \t gets the readout flags. can be none, storeinram, tot, continous, parallel, nonparallel, safe, digital, analog_digital, unknown" << std::endl;
|
||||||
|
os << "led \t returns led status (0 off, 1 on)" << std::endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
return os.str();
|
return os.str();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user