merge conflict removed, jungfrau server and eiger server re compiled

This commit is contained in:
maliakal_d 2018-02-05 12:33:05 +01:00
commit 3da6a6df65
24 changed files with 1213 additions and 158 deletions

View File

@ -50,9 +50,9 @@ using namespace std;
#define PREPARE_ACQUISITION 0x0000100000000000ULL #define PREPARE_ACQUISITION 0x0000100000000000ULL
#define CLEANUP_ACQUISITION 0x0000080000000000ULL #define CLEANUP_ACQUISITION 0x0000080000000000ULL
#define REGISER_WRITE_READ 0x0000040000000000ULL #define REGISER_WRITE_READ 0x0000040000000000ULL
// 0xFFFFFFF000000000ULL // 0xFFFFFF0000000000ULL
// 0x0000000FFFFFFFFFULL // 0x000000FFFFFFFFFFULL
#define COULDNOT_SET_NETWORK_PARAMETER 0x0000000000000001ULL #define COULDNOT_SET_NETWORK_PARAMETER 0x0000000000000001ULL
#define COULDNOT_SET_ROI 0x0000000000000002ULL #define COULDNOT_SET_ROI 0x0000000000000002ULL
#define RECEIVER_READ_FREQUENCY 0x0000000000000004ULL #define RECEIVER_READ_FREQUENCY 0x0000000000000004ULL
@ -89,7 +89,10 @@ using namespace std;
#define RECEIVER_TIMER_NOT_SET 0x0000000200000000ULL #define RECEIVER_TIMER_NOT_SET 0x0000000200000000ULL
#define RECEIVER_ENABLE_GAPPIXELS_NOT_SET 0x0000000400000000ULL #define RECEIVER_ENABLE_GAPPIXELS_NOT_SET 0x0000000400000000ULL
#define RESTREAM_STOP_FROM_RECEIVER 0x0000000800000000ULL #define RESTREAM_STOP_FROM_RECEIVER 0x0000000800000000ULL
// 0x0000000FFFFFFFFFULL #define TEMPERATURE_CONTROL 0x0000001000000000ULL
#define AUTO_COMP_DISABLE 0x0000002000000000ULL
// 0x000000FFFFFFFFFFULL
/** @short class returning all error messages for error mask */ /** @short class returning all error messages for error mask */
class errorDefs { class errorDefs {
@ -280,7 +283,11 @@ public:
if(slsErrorMask&RESTREAM_STOP_FROM_RECEIVER) if(slsErrorMask&RESTREAM_STOP_FROM_RECEIVER)
retval.append("Could not restream stop from receiver.\n"); retval.append("Could not restream stop from receiver.\n");
if(slsErrorMask&TEMPERATURE_CONTROL)
retval.append("Could not set/get threshold temperature, temp control or temp event.\n");
if(slsErrorMask&AUTO_COMP_DISABLE)
retval.append("Could not set/get auto comparator disable\n");
//------------------------------------------------------ length of message //------------------------------------------------------ length of message

View File

@ -112,6 +112,12 @@ enum detFuncs{
F_ACTIVATE, /** < activate */ F_ACTIVATE, /** < activate */
F_PREPARE_ACQUISITION, /** < prepare acquisition */ F_PREPARE_ACQUISITION, /** < prepare acquisition */
F_CLEANUP_ACQUISITION, /** < clean up after acquisition */ F_CLEANUP_ACQUISITION, /** < clean up after acquisition */
F_THRESHOLD_TEMP, /** < set threshold temperature */
F_TEMP_CONTROL, /** < set temperature control */
F_TEMP_EVENT, /** < set temperature event */
F_AUTO_COMP_DISABLE, /** < auto comp disable mode */
/* Always append functions hereafter!!! */ /* Always append functions hereafter!!! */
/* Always append functions before!!! */ /* Always append functions before!!! */

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware/eigerDetectorServer Path: slsDetectorsPackage/slsDetectorSoftware/eigerDetectorServer
URL: origin git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repsitory UUID: 2f3dc8d109de8607f3217cf429619073dc9cc60e Repsitory UUID: 08fda2b6620353e69f4b654f8bf4c3ea4be60b1e
Revision: 315 Revision: 317
Branch: developer Branch: developer
Last Changed Author: Dhanya_Maliakal Last Changed Author: Dhanya_Maliakal
Last Changed Rev: 3397 Last Changed Rev: 3582
Last Changed Date: 2017-12-06 19:05:42.000000002 +0100 ./FebRegisterDefs.h Last Changed Date: 2018-02-05 11:53:29.000000002 +0100 ./FebRegisterDefs.h

View File

@ -1,6 +1,6 @@
#define GITURL "git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git" #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "2f3dc8d109de8607f3217cf429619073dc9cc60e" #define GITREPUUID "08fda2b6620353e69f4b654f8bf4c3ea4be60b1e"
#define GITAUTH "Dhanya_Maliakal" #define GITAUTH "Dhanya_Maliakal"
#define GITREV 0x3397 #define GITREV 0x3582
#define GITDATE 0x20171206 #define GITDATE 0x20180205
#define GITBRANCH "developer" #define GITBRANCH "developer"

View File

@ -62,6 +62,14 @@
#define HARDWARE_VERSION_NUM_MSK (0x0000003F << HARDWARE_VERSION_NUM_OFST) //Not used in software #define HARDWARE_VERSION_NUM_MSK (0x0000003F << HARDWARE_VERSION_NUM_OFST) //Not used in software
/* API Version Register */
#define API_VERSION_REG (0x0F << 11)
#define API_VERSION_OFST (0)
#define API_VERSION_MSK (0x00FFFFFF << API_VERSION_OFST)
#define API_VERSION_DETECTOR_TYPE_OFST (24) //Not used in software
#define API_VERSION_DETECTOR_TYPE_MSK (0x000000FF << API_VERSION_DETECTOR_TYPE_OFST) //Not used in software
/* Time from Start 64 bit register */ /* Time from Start 64 bit register */
#define TIME_FROM_START_LSB_REG (0x10 << 11) #define TIME_FROM_START_LSB_REG (0x10 << 11)
#define TIME_FROM_START_MSB_REG (0x11 << 11) #define TIME_FROM_START_MSB_REG (0x11 << 11)
@ -188,7 +196,7 @@
#define CONFIG_TDMA_ENABLE_VAL ((0x1 << CONFIG_TDMA_OFST) & CONFIG_TDMA_MSK) #define CONFIG_TDMA_ENABLE_VAL ((0x1 << CONFIG_TDMA_OFST) & CONFIG_TDMA_MSK)
#define CONFIG_TDMA_TIMESLOT_OFST (25) #define CONFIG_TDMA_TIMESLOT_OFST (25)
#define CONFIG_TDMA_TIMESLOT_MSK (0x0000001F << CONFIG_TDMA_TIMESLOT_OFST) #define CONFIG_TDMA_TIMESLOT_MSK (0x0000001F << CONFIG_TDMA_TIMESLOT_OFST)
#define CONFIG_TDMA_TIMESLOT_0_VAL ((0x0 << CONFIG_TDMA_TIMESLOT_OFST) & CONFIG_TDMA_TIMESLOT_MSK)
/* External Signal Register */ /* External Signal Register */
#define EXT_SIGNAL_REG (0x4E << 11) #define EXT_SIGNAL_REG (0x4E << 11)
@ -211,6 +219,8 @@
#define CONTROL_DDR3_MEM_RST_MSK (0x00000001 << CONTROL_DDR3_MEM_RST_OFST) //only PHY, not DDR3 PLL ,Not used in software #define CONTROL_DDR3_MEM_RST_MSK (0x00000001 << CONTROL_DDR3_MEM_RST_OFST) //only PHY, not DDR3 PLL ,Not used in software
#define CONTROL_ACQ_FIFO_CLR_OFST (14) #define CONTROL_ACQ_FIFO_CLR_OFST (14)
#define CONTROL_ACQ_FIFO_CLR_MSK (0x00000001 << CONTROL_ACQ_FIFO_CLR_OFST) #define CONTROL_ACQ_FIFO_CLR_MSK (0x00000001 << CONTROL_ACQ_FIFO_CLR_OFST)
#define CONTROL_STORAGE_CELL_NUM_OFST (16)
#define CONTROL_STORAGE_CELL_NUM_MSK (0x0000000F << CONTROL_STORAGE_CELL_NUM_OFST)
/* Reconfiguratble PLL Paramater Register */ /* Reconfiguratble PLL Paramater Register */
#define PLL_PARAM_REG (0x50 << 11) #define PLL_PARAM_REG (0x50 << 11)
@ -278,7 +288,13 @@
#define SAMPLE_DECMT_FACTOR_4_VAL ((0x2 << SAMPLE_DGTL_DECMT_FACTOR_OFST) & SAMPLE_DGTL_DECMT_FACTOR_MSK) #define SAMPLE_DECMT_FACTOR_4_VAL ((0x2 << SAMPLE_DGTL_DECMT_FACTOR_OFST) & SAMPLE_DGTL_DECMT_FACTOR_MSK)
/** Vref Comp Mod Register */ /** Vref Comp Mod Register */
#define VREF_COMP_MOD_REG (0x5C << 11) //Not used in software, TBD in firmware #define VREF_COMP_MOD_REG (0x5C << 11)
#define VREF_COMP_MOD_OFST (0)
#define VREF_COMP_MOD_MSK (0x00000FFF << VREF_COMP_MOD_OFST)
#define VREF_COMP_MOD_ENABLE_OFST (31)
#define VREF_COMP_MOD_ENABLE_MSK (0x00000FFF << VREF_COMP_MOD_ENABLE_OFST)
/** DAQ Register */ /** DAQ Register */
#define DAQ_REG (0x5D << 11) //TBD in firmware #define DAQ_REG (0x5D << 11) //TBD in firmware
@ -288,6 +304,21 @@
#define CHIP_POWER_ENABLE_OFST (0) #define CHIP_POWER_ENABLE_OFST (0)
#define CHIP_POWER_ENABLE_MSK (0x00000001 << CHIP_POWER_ENABLE_OFST) #define CHIP_POWER_ENABLE_MSK (0x00000001 << CHIP_POWER_ENABLE_OFST)
#define CHIP_POWER_STATUS_OFST (1)
#define CHIP_POWER_STATUS_MSK (0x00000001 << CHIP_POWER_STATUS_OFST)
/** Temperature Control Register */
#define TEMP_CTRL_REG (0x5F << 11)
#define TEMP_CTRL_PROTCT_THRSHLD_OFST (0)
#define TEMP_CTRL_PROTCT_THRSHLD_MSK (0x000007FF << TEMP_CTRL_PROTCT_THRSHLD_OFST)
#define TEMP_CTRL_PROTCT_ENABLE_OFST (16)
#define TEMP_CTRL_PROTCT_ENABLE_MSK (0x00000001 << TEMP_CTRL_PROTCT_ENABLE_OFST)
#define TEMP_CTRL_OVR_TMP_EVNT_OFST (31)
#define TEMP_CTRL_OVR_TMP_EVNT_MSK (0x00000001 << TEMP_CTRL_OVR_TMP_EVNT_OFST)
#define TEMP_CTRL_CLR_OVR_TMP_EVNT_VAL ((0x1 << TEMP_CTRL_OVR_TMP_EVNT_OFST) & TEMP_CTRL_OVR_TMP_EVNT_MSK)
/* Set Delay 64 bit register */ /* Set Delay 64 bit register */
#define SET_DELAY_LSB_REG (0x60 << 11) #define SET_DELAY_LSB_REG (0x60 << 11)
@ -309,6 +340,10 @@
#define SET_EXPTIME_LSB_REG (0x68 << 11) #define SET_EXPTIME_LSB_REG (0x68 << 11)
#define SET_EXPTIME_MSB_REG (0x69 << 11) #define SET_EXPTIME_MSB_REG (0x69 << 11)
/* Trigger Delay 32 bit register */
#define SET_TRIGGER_DELAY_LSB_REG (0x70 << 11)
#define SET_TRIGGER_DELAY_MSB_REG (0x71 << 11)
/* Module Coordinates Register 0 */ /* Module Coordinates Register 0 */
#define COORD_0 (0x7C << 11) #define COORD_0 (0x7C << 11)
@ -323,6 +358,14 @@
#define COORD_0_Z_OFST (0) #define COORD_0_Z_OFST (0)
#define COORD_0_Z_MSK (0x0000FFFF << COORD_0_Z_OFST) #define COORD_0_Z_MSK (0x0000FFFF << COORD_0_Z_OFST)
/* ASIC Control Register */
#define ASIC_CTRL_REG (0x7F)
#define ASIC_CTRL_PRCHRG_TMR_OFST (0)
#define ASIC_CTRL_PRCHRG_TMR_MSK (0x000000FF << ASIC_CTRL_PRCHRG_TMR_OFST)
#define ASIC_CTRL_DS_TMR_OFST (8)
#define ASIC_CTRL_DS_TMR_MSK (0x000000FF << ASIC_CTRL_DS_TMR_OFST)
#endif //REGISTERS_G_H #endif //REGISTERS_G_H

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware/jungfrauDetectorServer Path: slsDetectorsPackage/slsDetectorSoftware/jungfrauDetectorServer
URL: origin git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repsitory UUID: 2f3dc8d109de8607f3217cf429619073dc9cc60e Repsitory UUID: 08fda2b6620353e69f4b654f8bf4c3ea4be60b1e
Revision: 103 Revision: 105
Branch: developer Branch: developer
Last Changed Author: Dhanya_Maliakal Last Changed Author: Dhanya_Maliakal
Last Changed Rev: 3397 Last Changed Rev: 3582
Last Changed Date: 2017-12-04 18:23:05.000000002 +0100 ./RegisterDefs.h Last Changed Date: 2018-02-05 11:53:33.000000002 +0100 ./RegisterDefs.h

View File

@ -1,6 +1,6 @@
#define GITURL "git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git" #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "2f3dc8d109de8607f3217cf429619073dc9cc60e" #define GITREPUUID "08fda2b6620353e69f4b654f8bf4c3ea4be60b1e"
#define GITAUTH "Dhanya_Maliakal" #define GITAUTH "Dhanya_Maliakal"
#define GITREV 0x3397 #define GITREV 0x3582
#define GITDATE 0x20171204 #define GITDATE 0x20180205
#define GITBRANCH "developer" #define GITBRANCH "developer"

View File

@ -29,12 +29,12 @@ void checkFirmwareCompatibility(int flag) {
defineGPIOpins(); defineGPIOpins();
resetFPGA(); resetFPGA();
if (mapCSP0() == FAIL) { if (mapCSP0() == FAIL) {
cprintf(BG_RED, "Dangerous to continue. Goodbye!\n"); cprintf(BG_RED, "Dangerous to continue. Goodbye!\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
// does check only if flag is 0 (by default), set by command line // does check only if flag is 0 (by default), set by command line
if ((!flag) && ((checkType() == FAIL) || (testFpga() == FAIL) || (testBus() == FAIL))) { if ((!flag) && ((checkType() == FAIL) || (testFpga() == FAIL) || (testBus() == FAIL))) {
cprintf(BG_RED, "Dangerous to continue. Goodbye!\n"); cprintf(BG_RED, "Dangerous to continue. Goodbye!\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@ -46,7 +46,9 @@ void checkFirmwareCompatibility(int flag) {
uint64_t macadd = getDetectorMAC(); uint64_t macadd = getDetectorMAC();
int64_t fwversion = getDetectorId(DETECTOR_FIRMWARE_VERSION); int64_t fwversion = getDetectorId(DETECTOR_FIRMWARE_VERSION);
int64_t swversion = getDetectorId(DETECTOR_SOFTWARE_VERSION); int64_t swversion = getDetectorId(DETECTOR_SOFTWARE_VERSION);
//int64_t sw_fw_apiversion = getDetectorId(SOFTWARE_FIRMWARE_API_VERSION); int64_t sw_fw_apiversion = 0;
if (fwversion >= MIN_REQRD_VRSN_T_RD_API)
sw_fw_apiversion = getDetectorId(SOFTWARE_FIRMWARE_API_VERSION);
cprintf(BLUE,"\n\n" cprintf(BLUE,"\n\n"
"********************************************************\n" "********************************************************\n"
"****************** Jungfrau Server *********************\n" "****************** Jungfrau Server *********************\n"
@ -55,46 +57,49 @@ void checkFirmwareCompatibility(int flag) {
"Hardware Serial Nr:\t\t 0x%x\n" "Hardware Serial Nr:\t\t 0x%x\n"
"Detector IP Addr:\t\t 0x%x\n" "Detector IP Addr:\t\t 0x%x\n"
"Detector MAC Addr:\t\t 0x%llx\n" "Detector MAC Addr:\t\t 0x%llx\n\n"
"Firmware Version:\t\t 0x%llx\n" "Firmware Version:\t\t 0x%llx\n"
"Software Version:\t\t 0x%llx\n" "Software Version:\t\t 0x%llx\n"
//"F/w-S/w API Version:\t\t 0x%llx\n" "F/w-S/w API Version:\t\t 0x%llx\n"
//"Required Firmware Version:\t 0x%x\n" "Required Firmware Version:\t 0x%x\n"
"\n" "\n"
"********************************************************\n", "********************************************************\n",
hversion, hsnumber, hversion, hsnumber,
ipadd, macadd, ipadd, macadd,
fwversion, swversion fwversion, swversion,
//, sw_fw_apiversion, REQUIRED_FIRMWARE_VERSION sw_fw_apiversion, REQRD_FRMWR_VRSN
); );
// return if flag is not zero, debug mode
if (flag)
return;
/*
* printf("Testing firmware capability... ");
//cant read versions //cant read versions
printf("Testing Firmware-software compatibility ...\n");
if(!fwversion || !sw_fw_apiversion){ if(!fwversion || !sw_fw_apiversion){
cprintf(RED,"FATAL ERROR: Cant read versions from FPGA. Please update firmware\n"); cprintf(RED,"FATAL ERROR: Cant read versions from FPGA. Please update firmware\n");
cprintf(RED,"Exiting Server. Goodbye!\n\n"); cprintf(RED,"Exiting Server. Goodbye!\n\n");
exit(-1); exit(EXIT_FAILURE);
} }
//check for API compatibility - old server //check for API compatibility - old server
if(sw_fw_apiversion > REQUIRED_FIRMWARE_VERSION){ if(sw_fw_apiversion > REQRD_FRMWR_VRSN){
cprintf(RED,"FATAL ERROR: This software version is incompatible.\n" cprintf(RED,"FATAL ERROR: This software version is incompatible.\n"
"Please update it to be compatible with this firmware\n\n"); "Please update it to be compatible with this firmware\n\n");
cprintf(RED,"Exiting Server. Goodbye!\n\n"); cprintf(RED,"Exiting Server. Goodbye!\n\n");
exit(-1); exit(EXIT_FAILURE);
} }
//check for firmware compatibility - old firmware //check for firmware compatibility - old firmware
if( REQUIRED_FIRMWARE_VERSION > fwversion){ if( REQRD_FRMWR_VRSN > fwversion){
cprintf(RED,"FATAL ERROR: This firmware version is incompatible.\n" cprintf(RED,"FATAL ERROR: This firmware version is incompatible.\n"
"Please update it to v%d to be compatible with this server\n\n", REQUIRED_FIRMWARE_VERSION); "Please update it to v%d to be compatible with this server\n\n", REQRD_FRMWR_VRSN);
cprintf(RED,"Exiting Server. Goodbye!\n\n"); cprintf(RED,"Exiting Server. Goodbye!\n\n");
exit(-1); exit(EXIT_FAILURE);
} }
*/ printf("Compatibility - success\n");
} }
@ -176,28 +181,26 @@ int64_t getDetectorId(enum idMode arg){
switch(arg){ switch(arg){
case DETECTOR_SERIAL_NUMBER: case DETECTOR_SERIAL_NUMBER:
retval = getDetectorNumber();// or getDetectorMAC() return getDetectorNumber();// or getDetectorMAC()
break;
case DETECTOR_FIRMWARE_VERSION: case DETECTOR_FIRMWARE_VERSION:
retval = getFirmwareVersion(); return getFirmwareVersion();
break; case SOFTWARE_FIRMWARE_API_VERSION:
//case SOFTWARE_FIRMWARE_API_VERSION: return getFirmwareAPIVersion();
//return GetFirmwareSoftwareAPIVersion();
case DETECTOR_SOFTWARE_VERSION: case DETECTOR_SOFTWARE_VERSION:
retval= GITREV; return (GITDATE & 0xFFFFFF);
retval= (retval <<32) | GITDATE;
break;
default: default:
break; return retval;
} }
return retval;
} }
u_int64_t getFirmwareVersion() { u_int64_t getFirmwareVersion() {
return ((bus_r(FPGA_VERSION_REG) & BOARD_REVISION_MSK) >> BOARD_REVISION_OFST); return ((bus_r(FPGA_VERSION_REG) & BOARD_REVISION_MSK) >> BOARD_REVISION_OFST);
} }
u_int64_t getFirmwareAPIVersion() {
return ((bus_r(API_VERSION_REG) & API_VERSION_MSK) >> API_VERSION_OFST);
}
u_int16_t getHardwareVersionNumber() { u_int16_t getHardwareVersionNumber() {
return ((bus_r(MOD_SERIAL_NUM_REG) & HARDWARE_VERSION_NUM_MSK) >> HARDWARE_VERSION_NUM_OFST); return ((bus_r(MOD_SERIAL_NUM_REG) & HARDWARE_VERSION_NUM_MSK) >> HARDWARE_VERSION_NUM_OFST);
} }
@ -260,7 +263,7 @@ u_int32_t getDetectorIP(){
/* initialization */ /* initialization */
void initControlServer(){ void initControlServer(){
clkPhase[0] = 0; clkPhase[1] = 0; clkPhase[0] = 0; clkPhase[1] = 0;
setupDetector(); setupDetector();
printf("\n"); printf("\n");
} }
@ -359,6 +362,12 @@ void setupDetector() {
/*setSpeed(CLOCK_DIVIDER, HALF_SPEED); depends if all the previous stuff works*/ /*setSpeed(CLOCK_DIVIDER, HALF_SPEED); depends if all the previous stuff works*/
setTiming(DEFAULT_TIMING_MODE); setTiming(DEFAULT_TIMING_MODE);
setHighVoltage(DEFAULT_HIGH_VOLTAGE); setHighVoltage(DEFAULT_HIGH_VOLTAGE);
/* temporary set up until new firmware fixes bug */
// set temperature threshold
setThresholdTemperature(DEFAULT_TMP_THRSHLD);
// reset temp event
setTemperatureEvent(0);
} }
@ -380,9 +389,30 @@ int powerChip (int on){
bus_w(CHIP_POWER_REG, bus_r(CHIP_POWER_REG) & ~CHIP_POWER_ENABLE_MSK); bus_w(CHIP_POWER_REG, bus_r(CHIP_POWER_REG) & ~CHIP_POWER_ENABLE_MSK);
} }
} }
return bus_r(CHIP_POWER_REG);
return ((bus_r(CHIP_POWER_REG) & CHIP_POWER_ENABLE_MSK) >> CHIP_POWER_ENABLE_OFST);
/* temporary setup until new firmware fixes bug */
//return ((bus_r(CHIP_POWER_REG) & CHIP_POWER_STATUS_MSK) >> CHIP_POWER_STATUS_OFST);
} }
int autoCompDisable(int on) {
if(on != -1){
if(on){
cprintf(BLUE, "\n*** Auto comp disable mode: enabling ***\n");
bus_w(VREF_COMP_MOD_REG, bus_r(VREF_COMP_MOD_REG) | VREF_COMP_MOD_ENABLE_MSK);
}
else{
cprintf(BLUE, "\n*** Auto comp disable mode: disabling *** \n");
bus_w(VREF_COMP_MOD_REG, bus_r(VREF_COMP_MOD_REG) & ~VREF_COMP_MOD_ENABLE_MSK);
}
}
return (bus_r(VREF_COMP_MOD_REG) & VREF_COMP_MOD_ENABLE_MSK);
}
void cleanFifos() { void cleanFifos() {
printf("\nClearing Acquisition Fifos\n"); printf("\nClearing Acquisition Fifos\n");
bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_ACQ_FIFO_CLR_MSK); bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_ACQ_FIFO_CLR_MSK);
@ -455,33 +485,65 @@ int setSpeed(enum speedVariable arg, int val) {
// setting // setting
if(val >= 0) { if(val >= 0) {
switch(val){ // stop state machine if running
if(runBusy())
stopStateMachine();
// stop state machine if running uint32_t txndelay_msk = 0;
if(runBusy())
stopStateMachine(); switch(val){
// todo in firmware, for now setting half speed // todo in firmware, for now setting half speed
case FULL_SPEED://40 case FULL_SPEED://40
printf("\nSetting Half Speed (20 MHz):\n"); printf("\nSetting Half Speed (20 MHz):\n");
printf("Setting Sample Reg to 0x%x\n", SAMPLE_ADC_HALF_SPEED); bus_w(SAMPLE_REG, SAMPLE_ADC_HALF_SPEED);
printf("Setting Config Reg to 0x%x\n", CONFIG_HALF_SPEED); bus_w(CONFIG_REG, CONFIG_HALF_SPEED); printf("Setting Sample Reg to 0x%x\n", SAMPLE_ADC_HALF_SPEED);
printf("Setting ADC Ofst Reg to 0x%x\n", ADC_OFST_HALF_SPEED_VAL); bus_w(ADC_OFST_REG, ADC_OFST_HALF_SPEED_VAL); bus_w(SAMPLE_REG, SAMPLE_ADC_HALF_SPEED);
printf("Setting ADC Phase Reg to 0x%x\n", ADC_PHASE_HALF_SPEED); adcPhase(ADC_PHASE_HALF_SPEED);
txndelay_msk = (bus_r(CONFIG_REG) & CONFIG_TDMA_TIMESLOT_MSK); // read config tdma timeslot value
printf("Setting Config Reg to 0x%x\n", CONFIG_HALF_SPEED | txndelay_msk);
bus_w(CONFIG_REG, CONFIG_HALF_SPEED | txndelay_msk);
printf("Setting ADC Ofst Reg to 0x%x\n", ADC_OFST_HALF_SPEED_VAL);
bus_w(ADC_OFST_REG, ADC_OFST_HALF_SPEED_VAL);
printf("Setting ADC Phase Reg to 0x%x\n", ADC_PHASE_HALF_SPEED);
adcPhase(ADC_PHASE_HALF_SPEED);
break; break;
case HALF_SPEED: case HALF_SPEED:
printf("\nSetting Half Speed (20 MHz):\n"); printf("\nSetting Half Speed (20 MHz):\n");
printf("Setting Sample Reg to 0x%x\n", SAMPLE_ADC_HALF_SPEED); bus_w(SAMPLE_REG, SAMPLE_ADC_HALF_SPEED);
printf("Setting Config Reg to 0x%x\n", CONFIG_HALF_SPEED); bus_w(CONFIG_REG, CONFIG_HALF_SPEED); printf("Setting Sample Reg to 0x%x\n", SAMPLE_ADC_HALF_SPEED);
printf("Setting ADC Ofst Reg to 0x%x\n", ADC_OFST_HALF_SPEED_VAL); bus_w(ADC_OFST_REG, ADC_OFST_HALF_SPEED_VAL); bus_w(SAMPLE_REG, SAMPLE_ADC_HALF_SPEED);
printf("Setting ADC Phase Reg to 0x%x\n", ADC_PHASE_HALF_SPEED); adcPhase(ADC_PHASE_HALF_SPEED);
txndelay_msk = (bus_r(CONFIG_REG) & CONFIG_TDMA_TIMESLOT_MSK); // read config tdma timeslot value
printf("Setting Config Reg to 0x%x\n", CONFIG_HALF_SPEED | txndelay_msk);
bus_w(CONFIG_REG, CONFIG_HALF_SPEED | txndelay_msk);
printf("Setting ADC Ofst Reg to 0x%x\n", ADC_OFST_HALF_SPEED_VAL);
bus_w(ADC_OFST_REG, ADC_OFST_HALF_SPEED_VAL);
printf("Setting ADC Phase Reg to 0x%x\n", ADC_PHASE_HALF_SPEED);
adcPhase(ADC_PHASE_HALF_SPEED);
break; break;
case QUARTER_SPEED: case QUARTER_SPEED:
printf("\nSetting Half Speed (10 MHz):\n"); printf("\nSetting Half Speed (10 MHz):\n");
printf("Setting Sample Reg to 0x%x\n", SAMPLE_ADC_QUARTER_SPEED); bus_w(SAMPLE_REG, SAMPLE_ADC_QUARTER_SPEED);
printf("Setting Config Reg to 0x%x\n", CONFIG_QUARTER_SPEED); bus_w(CONFIG_REG, CONFIG_QUARTER_SPEED); printf("Setting Sample Reg to 0x%x\n", SAMPLE_ADC_QUARTER_SPEED);
printf("Setting ADC Ofst Reg to 0x%x\n", ADC_OFST_QUARTER_SPEED_VAL); bus_w(ADC_OFST_REG, ADC_OFST_QUARTER_SPEED_VAL); bus_w(SAMPLE_REG, SAMPLE_ADC_QUARTER_SPEED);
printf("Setting ADC Phase Reg to 0x%x\n", ADC_PHASE_QUARTER_SPEED); adcPhase(ADC_PHASE_QUARTER_SPEED);
txndelay_msk = (bus_r(CONFIG_REG) & CONFIG_TDMA_TIMESLOT_MSK); // read config tdma timeslot value
printf("Setting Config Reg to 0x%x\n", CONFIG_QUARTER_SPEED | txndelay_msk);
bus_w(CONFIG_REG, CONFIG_QUARTER_SPEED | txndelay_msk);
printf("Setting ADC Ofst Reg to 0x%x\n", ADC_OFST_QUARTER_SPEED_VAL);
bus_w(ADC_OFST_REG, ADC_OFST_QUARTER_SPEED_VAL);
printf("Setting ADC Phase Reg to 0x%x\n", ADC_PHASE_QUARTER_SPEED);
adcPhase(ADC_PHASE_QUARTER_SPEED);
break; break;
} }
printf("\n"); printf("\n");
@ -543,7 +605,7 @@ int64_t setTimer(enum timerIndex ind, int64_t val) {
printf("\nSetting delay to %lldns\n", (long long int)val); printf("\nSetting delay to %lldns\n", (long long int)val);
val *= (1E-3 * CLK_SYNC); val *= (1E-3 * CLK_SYNC);
} }
retval = set64BitReg(val, SET_DELAY_LSB_REG, SET_DELAY_MSB_REG) / (1E-3 * CLK_SYNC); retval = set64BitReg(val, SET_TRIGGER_DELAY_LSB_REG, SET_TRIGGER_DELAY_MSB_REG) / (1E-3 * CLK_SYNC);
printf("Getting delay: %lldns\n", (long long int)retval); printf("Getting delay: %lldns\n", (long long int)retval);
break; break;
@ -835,6 +897,11 @@ void setDAC(enum DACINDEX ind, int val, int imod, int mV, int retval[]){
DAC_SERIAL_CLK_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_OFST); DAC_SERIAL_CLK_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_OFST);
dacValues[ind] = dacval; dacValues[ind] = dacval;
if (ind == VREF_COMP) {
bus_w (VREF_COMP_MOD_REG, (bus_r(VREF_COMP_MOD_REG) &~ (VREF_COMP_MOD_MSK)) // reset
| ((val << VREF_COMP_MOD_OFST) & VREF_COMP_MOD_MSK)); // or it with value
}
} }
printf("Getting DAC %d : ",ind); printf("Getting DAC %d : ",ind);
@ -1129,6 +1196,82 @@ void configurePll() {
int setThresholdTemperature(int val) {
if (val >= 0) {
printf("\nThreshold Temperature: %d\n", val);
val *= (10.0/625.0);
#ifdef VERBOSE
printf("Converted Threshold Temperature: %d\n", val);
#endif
bus_w(TEMP_CTRL_REG, (bus_r(TEMP_CTRL_REG) &~(TEMP_CTRL_PROTCT_THRSHLD_MSK) &~(TEMP_CTRL_OVR_TMP_EVNT_MSK))
| (((val << TEMP_CTRL_PROTCT_THRSHLD_OFST) & TEMP_CTRL_PROTCT_THRSHLD_MSK)));
#ifdef VERBOSE
printf("Converted Threshold Temperature set to %d\n", ((bus_r(TEMP_CTRL_REG) & TEMP_CTRL_PROTCT_THRSHLD_MSK) >> TEMP_CTRL_PROTCT_THRSHLD_OFST));
#endif
}
uint32_t temp = ((bus_r(TEMP_CTRL_REG) & TEMP_CTRL_PROTCT_THRSHLD_MSK) >> TEMP_CTRL_PROTCT_THRSHLD_OFST);
// conversion
temp *= (625.0/10.0);
printf("Threshold Temperature %f °C\n",(double)temp/1000.00);
return temp;
}
int setTemperatureControl(int val) {
if (val >= 0) {
// binary value
if (val > 0 ) val = 1;
printf("\nTemperature control: %d\n", val);
bus_w(TEMP_CTRL_REG, (bus_r(TEMP_CTRL_REG) &~(TEMP_CTRL_PROTCT_ENABLE_MSK) &~(TEMP_CTRL_OVR_TMP_EVNT_MSK))
| (((val << TEMP_CTRL_PROTCT_ENABLE_OFST) & TEMP_CTRL_PROTCT_ENABLE_MSK)));
#ifdef VERBOSE
printf("Temperature control set to %d\n", ((bus_r(TEMP_CTRL_REG) & TEMP_CTRL_PROTCT_ENABLE_MSK) >> TEMP_CTRL_PROTCT_ENABLE_OFST));
#endif
}
return ((bus_r(TEMP_CTRL_REG) & TEMP_CTRL_PROTCT_ENABLE_MSK) >> TEMP_CTRL_PROTCT_ENABLE_OFST);
}
int setTemperatureEvent(int val) {
if (val >= 0) {
// set bit to clear it
val = 1;
printf("\nTemperature Event: %d\n", val);
bus_w(TEMP_CTRL_REG, (bus_r(TEMP_CTRL_REG) &~TEMP_CTRL_OVR_TMP_EVNT_MSK)
| (((val << TEMP_CTRL_OVR_TMP_EVNT_OFST) & TEMP_CTRL_OVR_TMP_EVNT_MSK)));
#ifdef VERBOSE
printf("Temperature Event set to %d\n", ((bus_r(TEMP_CTRL_REG) & TEMP_CTRL_OVR_TMP_EVNT_MSK) >> TEMP_CTRL_OVR_TMP_EVNT_OFST));
#endif
}
return ((bus_r(TEMP_CTRL_REG) & TEMP_CTRL_OVR_TMP_EVNT_MSK) >> TEMP_CTRL_OVR_TMP_EVNT_OFST);
}
int setNetworkParameter(enum NETWORKINDEX mode, int value) {
if (mode != TXN_FRAME)
return -1;
if (value >= 0) {
printf("\nSetting transmission delay: %d\n", value);
bus_w(CONFIG_REG, (bus_r(CONFIG_REG) &~CONFIG_TDMA_TIMESLOT_MSK)
| (((value << CONFIG_TDMA_TIMESLOT_OFST) & CONFIG_TDMA_TIMESLOT_MSK)));
#ifdef VERBOSE
printf("Transmission delay set to %d\n", ((bus_r(CONFIG_REG) & CONFIG_TDMA_TIMESLOT_MSK) >> CONFIG_TDMA_TIMESLOT_OFST));
#endif
}
return ((bus_r(CONFIG_REG) & CONFIG_TDMA_TIMESLOT_MSK) >> CONFIG_TDMA_TIMESLOT_OFST);
}
/* aquisition */ /* aquisition */

View File

@ -8,7 +8,8 @@
#define GOODBYE (-200) #define GOODBYE (-200)
//#define REQUIRED_FIRMWARE_VERSION 16 #define MIN_REQRD_VRSN_T_RD_API 0x171113
#define REQRD_FRMWR_VRSN 0x171113
/* Struct Definitions */ /* Struct Definitions */
@ -48,13 +49,14 @@ enum DACINDEX {VB_COMP, VDD_PROT, VIN_COM, VREF_PRECH, VB_PIXBUF, VB_DS, VREF
0x1f00, /* FORCESWITCHG1 */ \ 0x1f00, /* FORCESWITCHG1 */ \
0x3f00 /* FORCESWITCHG2 */ \ 0x3f00 /* FORCESWITCHG2 */ \
}; };
#define DEFAULT_SETT_NAMES { "Dynamic Gain", /* DYNAMICGAIN */ \ #define DEFAULT_SETT_NAMES { "Dynamic Gain", /* DYNAMICGAIN */ \
"Dynamic High Gain 0", /* DYNAMICHG0 */ \ "Dynamic High Gain 0", /* DYNAMICHG0 */ \
"Fix Gain 1", /* FIXGAIN1 */ \ "Fix Gain 1", /* FIXGAIN1 */ \
"Fix Gain 2", /* FIXGAIN2 */ \ "Fix Gain 2", /* FIXGAIN2 */ \
"Force Switch Gain 1", /* FORCESWITCHG1*/ \ "Force Switch Gain 1", /* FORCESWITCHG1*/ \
"Force Switch Gain 2" /* FORCESWITCHG2*/ \ "Force Switch Gain 2" /* FORCESWITCHG2*/ \
}; };
enum NETWORKINDEX { TXN_FRAME };
@ -84,16 +86,19 @@ enum DACINDEX {VB_COMP, VDD_PROT, VIN_COM, VREF_PRECH, VB_PIXBUF, VB_DS, VREF
#define DEFAULT_TIMING_MODE (AUTO_TIMING) #define DEFAULT_TIMING_MODE (AUTO_TIMING)
#define DEFAULT_SETTINGS (DYNAMICGAIN) #define DEFAULT_SETTINGS (DYNAMICGAIN)
#define DEFAULT_TX_UDP_PORT (0x7e9a) #define DEFAULT_TX_UDP_PORT (0x7e9a)
#define DEFAULT_TMP_THRSHLD (65*1000) //milli degree Celsius
/* Defines in the Firmware */ /* Defines in the Firmware */
#define FIX_PATT_VAL (0xACDC2014) #define FIX_PATT_VAL (0xACDC2014)
#define ADC_PORT_INVERT_VAL (0x453b2a9c) #define ADC_PORT_INVERT_VAL (0x453b2a9c)
#define MAX_TIMESLOT_VAL (0x1F)
#define MAX_THRESHOLD_TEMP_VAL (127999) //millidegrees
#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_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 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_HALF_SPEED (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 CONFIG_QUARTER_SPEED (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_HALF_SPEED_VAL (0x20) //adc pipeline
#define ADC_OFST_QUARTER_SPEED_VAL (0x0f) #define ADC_OFST_QUARTER_SPEED_VAL (0x0f)
#define ADC_PHASE_HALF_SPEED (0x41) #define ADC_PHASE_HALF_SPEED (0x41)

View File

@ -3369,6 +3369,173 @@ dacs_t multiSlsDetector::getADC(dacIndex idac, int imod) {
return ret; return ret;
} }
int multiSlsDetector::setThresholdTemperature(int val, int imod) {
int ret = -100;
// single
{
int id=-1, im=-1;
if (decodeNMod(imod, id, im)>=0) {
if(detectors[id]){
ret = detectors[id]->setThresholdTemperature(val, im);
if(detectors[id]->getErrorMask())
setErrorMask(getErrorMask()|(1<<id));
return ret;
}
return -1;
}
}
// multi
if(!threadpool){
cout << "Error in creating threadpool. Exiting" << endl;
return -1;
}
int posmin=0, posmax=thisMultiDetector->numberOfDetectors;
int* iret[posmax-posmin];
for(int idet=posmin; idet<posmax; ++idet){
if(detectors[idet]){
iret[idet]= new dacs_t(-1);
Task* task = new Task(new func2_t<int,int,int>(&slsDetector::setThresholdTemperature,
detectors[idet], val, imod, iret[idet]));
threadpool->add_task(task);
}
}
threadpool->startExecuting();
threadpool->wait_for_tasks_to_complete();
for(int idet=posmin; idet<posmax; ++idet){
if(detectors[idet]){
if(iret[idet] != NULL){
if (ret==-100)
ret=*iret[idet];
else if (ret!=*iret[idet])
ret=-1;
delete iret[idet];
}else ret=-1;
if(detectors[idet]->getErrorMask())
setErrorMask(getErrorMask()|(1<<idet));
}
}
return ret;
}
int multiSlsDetector::setTemperatureControl(int val, int imod) {
int ret = -100;
// single
{
int id=-1, im=-1;
if (decodeNMod(imod, id, im)>=0) {
if(detectors[id]){
ret = detectors[id]->setTemperatureControl(val, im);
if(detectors[id]->getErrorMask())
setErrorMask(getErrorMask()|(1<<id));
return ret;
}
return -1;
}
}
// multi
if(!threadpool){
cout << "Error in creating threadpool. Exiting" << endl;
return -1;
}
int posmin=0, posmax=thisMultiDetector->numberOfDetectors;
int* iret[posmax-posmin];
for(int idet=posmin; idet<posmax; ++idet){
if(detectors[idet]){
iret[idet]= new dacs_t(-1);
Task* task = new Task(new func2_t<int,int,int>(&slsDetector::setTemperatureControl,
detectors[idet], val, imod, iret[idet]));
threadpool->add_task(task);
}
}
threadpool->startExecuting();
threadpool->wait_for_tasks_to_complete();
for(int idet=posmin; idet<posmax; ++idet){
if(detectors[idet]){
if(iret[idet] != NULL){
if (ret==-100)
ret=*iret[idet];
else if (ret!=*iret[idet])
ret=-1;
delete iret[idet];
}else ret=-1;
if(detectors[idet]->getErrorMask())
setErrorMask(getErrorMask()|(1<<idet));
}
}
return ret;
}
int multiSlsDetector::setTemperatureEvent(int val, int imod) {
int ret = -100;
// single
{
int id=-1, im=-1;
if (decodeNMod(imod, id, im)>=0) {
if(detectors[id]){
ret = detectors[id]->setTemperatureEvent(val, im);
if(detectors[id]->getErrorMask())
setErrorMask(getErrorMask()|(1<<id));
return ret;
}
return -1;
}
}
// multi
if(!threadpool){
cout << "Error in creating threadpool. Exiting" << endl;
return -1;
}
int posmin=0, posmax=thisMultiDetector->numberOfDetectors;
int* iret[posmax-posmin];
for(int idet=posmin; idet<posmax; ++idet){
if(detectors[idet]){
iret[idet]= new dacs_t(-1);
Task* task = new Task(new func2_t<int,int,int>(&slsDetector::setTemperatureEvent,
detectors[idet], val, imod, iret[idet]));
threadpool->add_task(task);
}
}
threadpool->startExecuting();
threadpool->wait_for_tasks_to_complete();
for(int idet=posmin; idet<posmax; ++idet){
if(detectors[idet]){
if(iret[idet] != NULL){
if (ret==-100)
ret=*iret[idet];
else if (ret!=*iret[idet])
ret=-1;
delete iret[idet];
}else ret=-1;
if(detectors[idet]->getErrorMask())
setErrorMask(getErrorMask()|(1<<idet));
}
}
return ret;
}
int multiSlsDetector::setChannel(int64_t reg, int ichan, int ichip, int imod) { int multiSlsDetector::setChannel(int64_t reg, int ichan, int ichip, int imod) {
int ret, ret1=-100; int ret, ret1=-100;
int id=-1, im=-1; int id=-1, im=-1;
@ -4507,6 +4674,22 @@ int multiSlsDetector::powerChip(int ival){
} }
int multiSlsDetector::setAutoComparatorDisableMode(int ival) {
int ret=OK, ret1=OK;
for (int i=0; i<thisMultiDetector->numberOfDetectors; ++i) {
if (detectors[i]) {
ret=detectors[i]->setAutoComparatorDisableMode(ival);
if(detectors[i]->getErrorMask())
setErrorMask(getErrorMask()|(1<<i));
if (ret==FAIL)
ret1=FAIL;
}
}
return ret1;
}
int multiSlsDetector::loadSettingsFile(string fname, int imod) { int multiSlsDetector::loadSettingsFile(string fname, int imod) {
int ret=OK; int ret=OK;

View File

@ -554,6 +554,12 @@ class multiSlsDetector : public slsDetectorUtils {
*/ */
int powerChip(int ival= -1); int powerChip(int ival= -1);
/** automatic comparator disable for Jungfrau only
\param ival on is 1, off is 0, -1 to get
\returns OK or FAIL
*/
int setAutoComparatorDisableMode(int ival= -1);
/** loads the modules settings/trimbits reading from a file - file name extension is automatically generated! */ /** loads the modules settings/trimbits reading from a file - file name extension is automatically generated! */
int loadSettingsFile(string fname, int nmod=-1); int loadSettingsFile(string fname, int nmod=-1);
@ -975,6 +981,31 @@ class multiSlsDetector : public slsDetectorUtils {
\returns current DAC value (temperature for eiger and jungfrau in millidegrees) \returns current DAC value (temperature for eiger and jungfrau in millidegrees)
*/ */
dacs_t getADC(dacIndex index, int imod=-1); dacs_t getADC(dacIndex index, int imod=-1);
/**
set/gets threshold temperature (Jungfrau only)
\param val value in millidegrees, -1 gets
\param imod module number, -1 is all
\returns threshold temperature in millidegrees
*/
int setThresholdTemperature(int val=-1, int imod=-1);
/**
enables/disables temperature control (Jungfrau only)
\param val value, -1 gets
\param imod module number, -1 is all
\returns temperature control enable
*/
int setTemperatureControl(int val=-1, int imod=-1);
/**
Resets/ gets over-temperature event (Jungfrau only)
\param val value, -1 gets
\param imod module number, -1 is all
\returns over-temperature event
*/
int setTemperatureEvent(int val=-1, int imod=-1);
/** /**
configure channel configure channel
\param reg channel register \param reg channel register

View File

@ -849,13 +849,13 @@ void setDAC(enum DACINDEX ind, int val, int imod, int mV, int retval[]){
int i; int i;
// start and chip select bar down ----------------- // start and chip select bar down -----------------
SPIChipSelect (valw, SPI_REG, (0x1 << csdx)); SPIChipSelect (&valw, SPI_REG, (0x1 << csdx));
// next dac -------------------------------------- // next dac --------------------------------------
for (i = 0; i < ichip; ++i) { for (i = 0; i < ichip; ++i) {
printf("%d next DAC\n", i); printf("%d next DAC\n", i);
sendDataToSPI (valw, SPI_REG, LTC2620_DAC_CMD_MSK, LTC2620_DAC_NUMBITS, sendDataToSPI (&valw, SPI_REG, LTC2620_DAC_CMD_MSK, LTC2620_DAC_NUMBITS,
DAC_SERIAL_CLK_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_OFST); DAC_SERIAL_CLK_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_OFST);
} }
@ -892,13 +892,13 @@ void setDAC(enum DACINDEX ind, int val, int imod, int mV, int retval[]){
// next dac ----------------------------------------------------------- // next dac -----------------------------------------------------------
for (i = ichip+1; i < (N_DAC / NDAC_PER_SET); ++i) { for (i = ichip+1; i < (N_DAC / NDAC_PER_SET); ++i) {
printf("%d next DAC\n", i); printf("%d next DAC\n", i);
sendDataToSPI (valw, SPI_REG, LTC2620_DAC_CMD_MSK, LTC2620_DAC_NUMBITS, sendDataToSPI (&valw, SPI_REG, LTC2620_DAC_CMD_MSK, LTC2620_DAC_NUMBITS,
DAC_SERIAL_CLK_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_OFST); DAC_SERIAL_CLK_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_OFST);
} }
//chip select bar up, clk down and stop -------------------------------- //chip select bar up, clk down and stop --------------------------------
SPIChipDeselect (valw, SPI_REG, (0x1 << csdx), DAC_SERIAL_CLK_OUT_MSK); SPIChipDeselect (&valw, SPI_REG, (0x1 << csdx), DAC_SERIAL_CLK_OUT_MSK);
// writes to register // writes to register
setDacRegister(ind, dacval); setDacRegister(ind, dacval);

View File

@ -2694,6 +2694,129 @@ dacs_t slsDetector::getADC(dacIndex index, int imod){
}; };
int slsDetector::setThresholdTemperature(int val, int imod) {
int retval = -1;
int fnum = F_THRESHOLD_TEMP;
int ret = FAIL;
char mess[MAX_STR_LENGTH] = "";
int arg[2];
arg[0]=val;
arg[1]=imod;
#ifdef VERBOSE
std::cout<< std::endl;
std::cout<< "Setting/Getting Threshold Temperature to "<< val << " of module " << imod << std::endl;
#endif
if (thisDetector->onlineFlag==ONLINE_FLAG) {
if (connectStop() == OK){
stopSocket->SendDataOnly(&fnum,sizeof(fnum));
stopSocket->SendDataOnly(arg,sizeof(arg));
stopSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret!=FAIL) {
stopSocket->ReceiveDataOnly(&retval,sizeof(retval));
#ifdef VERBOSE
std::cout<< "Threshold Temperature returned "<< retval << std::endl;
#endif
} else {
stopSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Detector returned error: " << mess << std::endl;
setErrorMask((getErrorMask())|(TEMPERATURE_CONTROL));
}
disconnectStop();
}
}
return retval;
}
int slsDetector::setTemperatureControl(int val, int imod) {
int retval = -1;
int fnum = F_TEMP_CONTROL;
int ret = FAIL;
char mess[MAX_STR_LENGTH] = "";
int arg[2];
arg[0]=val;
arg[1]=imod;
#ifdef VERBOSE
std::cout<< std::endl;
std::cout<< "Setting/Getting Threshold Temperature to "<< val << " of module " << imod << std::endl;
#endif
if (thisDetector->onlineFlag==ONLINE_FLAG) {
if (connectStop() == OK){
stopSocket->SendDataOnly(&fnum,sizeof(fnum));
stopSocket->SendDataOnly(arg,sizeof(arg));
stopSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret!=FAIL) {
stopSocket->ReceiveDataOnly(&retval,sizeof(retval));
#ifdef VERBOSE
std::cout<< "Threshold Temperature returned "<< retval << std::endl;
#endif
} else {
stopSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Detector returned error: " << mess << std::endl;
setErrorMask((getErrorMask())|(TEMPERATURE_CONTROL));
}
disconnectStop();
}
}
return retval;
}
int slsDetector::setTemperatureEvent(int val, int imod) {
int retval = -1;
int fnum = F_TEMP_EVENT;
int ret = FAIL;
char mess[MAX_STR_LENGTH] = "";
int arg[2];
arg[0]=val;
arg[1]=imod;
#ifdef VERBOSE
std::cout<< std::endl;
std::cout<< "Setting/Getting Threshold Temperature to "<< val << " of module " << imod << std::endl;
#endif
if (thisDetector->onlineFlag==ONLINE_FLAG) {
if (connectStop() == OK){
stopSocket->SendDataOnly(&fnum,sizeof(fnum));
stopSocket->SendDataOnly(arg,sizeof(arg));
stopSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret!=FAIL) {
stopSocket->ReceiveDataOnly(&retval,sizeof(retval));
#ifdef VERBOSE
std::cout<< "Threshold Temperature returned "<< retval << std::endl;
#endif
} else {
stopSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Detector returned error: " << mess << std::endl;
setErrorMask((getErrorMask())|(TEMPERATURE_CONTROL));
}
disconnectStop();
}
}
return retval;
}
/* /*
configure single channel configure single channel
enum channelRegisterBit { enum channelRegisterBit {
@ -7614,6 +7737,43 @@ int slsDetector::powerChip(int ival){
return retval; return retval;
} }
int slsDetector::setAutoComparatorDisableMode(int ival){
int ret=FAIL;
int fnum=F_AUTO_COMP_DISABLE;
char mess[MAX_STR_LENGTH]="";
int retval=-1;
if(thisDetector->myDetectorType != JUNGFRAU){
std::cout << "Not implemented for this detector" << std::endl;
return FAIL;
}
#ifdef VERBOSE
std::cout<< "Enabling/disabling Auto comp disable mode " << endl;
#endif
if (thisDetector->onlineFlag==ONLINE_FLAG) {
if (connectControl() == OK){
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
controlSocket->SendDataOnly(&ival,sizeof(ival));
//check opening error
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret==FAIL) {
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Detector returned error: " << mess << std::endl;
setErrorMask((getErrorMask())|(AUTO_COMP_DISABLE));
}else
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
disconnectControl();
if (ret==FORCE_UPDATE)
updateDetector();
}
}
return retval;
}
int slsDetector::loadSettingsFile(string fname, int imod) { int slsDetector::loadSettingsFile(string fname, int imod) {
sls_detector_module *myMod=NULL; sls_detector_module *myMod=NULL;

View File

@ -568,6 +568,12 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
*/ */
int powerChip(int ival= -1); int powerChip(int ival= -1);
/** automatic comparator disable for Jungfrau only
\param ival on is 1, off is 0, -1 to get
\returns OK or FAIL
*/
int setAutoComparatorDisableMode(int ival= -1);
/** loads the modules settings/trimbits reading from a file /** loads the modules settings/trimbits reading from a file
\param fname file name . If not specified, extension is automatically generated! \param fname file name . If not specified, extension is automatically generated!
@ -945,6 +951,30 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
*/ */
dacs_t getADC(dacIndex index, int imod=0); dacs_t getADC(dacIndex index, int imod=0);
/**
set/gets threshold temperature (Jungfrau only)
\param val value in millidegrees, -1 gets
\param imod module number, -1 is all
\returns threshold temperature in millidegrees
*/
int setThresholdTemperature(int val=-1, int imod=-1);
/**
enables/disables temperature control (Jungfrau only)
\param val value, -1 gets
\param imod module number, -1 is all
\returns temperature control enable
*/
int setTemperatureControl(int val=-1, int imod=-1);
/**
Resets/ gets over-temperature event (Jungfrau only)
\param val value, -1 gets
\param imod module number, -1 is all
\returns over-temperature event
*/
int setTemperatureEvent(int val=-1, int imod=-1);
/** /**
configure channel configure channel
\param reg channel register \param reg channel register

View File

@ -234,7 +234,6 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
/*! \page config Configuration commands /*! \page config Configuration commands
Commands to configure the detector. these commands are often left to the configuration file. Commands to configure the detector. these commands are often left to the configuration file.
- \ref configstructure "Data Structure": commands to configure detector data structure - \ref configstructure "Data Structure": commands to configure detector data structure
@ -469,6 +468,13 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdAdvanced; descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdAdvanced;
++i; ++i;
/*! \page config
- <b>auto_comp_disable i </b> Currently not implemented. this mode disables the on-chip gain switching comparator automatically after 93.75% of exposure time (only for longer than 100us). 1 enables mode, 0 disables mode. By default, mode is disabled (comparator is enabled throughout). (JUNGFRAU only). \c Returns \c (int)
*/
descrToFuncMap[i].m_pFuncName="auto_comp_disable"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdAdvanced;
++i;
/*! \page config /*! \page config
- <b>pulse [n] [x] [y]</b> pulses pixel at coordinates (x,y) n number of times. Used in EIGER only. Only put! \c Returns \c ("successful", "unsuccessful") - <b>pulse [n] [x] [y]</b> pulses pixel at coordinates (x,y) n number of times. Used in EIGER only. Only put! \c Returns \c ("successful", "unsuccessful")
*/ */
@ -966,6 +972,7 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
- \ref settingssett "Settings and Threshold": commands to configure settings and threshold of detector - \ref settingssett "Settings and Threshold": commands to configure settings and threshold of detector
- \ref settingsdacs "DACs": commands to configure DACs of detector - \ref settingsdacs "DACs": commands to configure DACs of detector
- \ref settingsadcs "ADCs": commands to readout ADCs of detector - \ref settingsadcs "ADCs": commands to readout ADCs of detector
- \ref settingstmp "Temp Control": commands to monitor and handle temperature overshoot (only JUNGFRAU)
*/ */
/* trim/cal directories */ /* trim/cal directories */
@ -1640,6 +1647,35 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdADC; descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdADC;
++i; ++i;
/* temperature control */
/*! \page settings
\section settingsadcs Temp Control
commands to monitor and handle temperature overshoot (only JUNGFRAU)
*/
/*! \page settings
- <b>temp_threshold</b> Sets/gets the threshold temperature. JUNGFRAU ONLY. \c Returns \c (double"°C")
*/
descrToFuncMap[i].m_pFuncName="temp_threshold"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTempControl;
++i;
/*! \page settings
- <b>temp_control</b> Enables/Disables the temperature control. 1 enables, 0 disables. JUNGFRAU ONLY. \c Returns \c int
*/
descrToFuncMap[i].m_pFuncName="temp_control"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTempControl;
++i;
/*! \page settings
- <b>temp_event</b> Resets/gets over-temperative event. Put only with option 0 to clear event. Gets 1 if temperature went over threshold and control is enabled, else 0. /Disables the temperature control. JUNGFRAU ONLY. \c Returns \c int
*/
descrToFuncMap[i].m_pFuncName="temp_event"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTempControl;
++i;
/* file name */ /* file name */
/*! \page output Output settings /*! \page output Output settings
@ -5438,6 +5474,80 @@ string slsDetectorCommand::helpADC(int narg, char *args[], int action) {
return os.str(); return os.str();
} }
string slsDetectorCommand::cmdTempControl(int narg, char *args[], int action) {
char answer[1000]="";
int val = -1;
if (action==HELP_ACTION)
return helpTempControl(narg, args, action);
myDet->setOnline(ONLINE_FLAG);
if (cmd == "temp_threshold") {
if (action==PUT_ACTION) {
double fval=0.0;
if (!sscanf(args[1],"%lf", &fval))
return string("cannot scan temp control value ")+string(args[1]);
val = fval * 1000;
myDet->setThresholdTemperature(val);
}
val = myDet->setThresholdTemperature();
if (val == -1)
sprintf(answer,"%d",val);
else
sprintf(answer,"%.2f°C", (double)val/1000.000);
}
else if (cmd == "temp_control") {
if (action==PUT_ACTION) {
if (!sscanf(args[1],"%d", &val))
return string("cannot scan temp control value ")+string(args[1]);
if ((val!=0) && (val!=1))
return string ("temp_control option must be 0 or 1");
myDet->setTemperatureControl(val);
}
sprintf(answer,"%d", myDet->setTemperatureControl());
}
else if (cmd == "temp_event") {
if (action==PUT_ACTION) {
if (!sscanf(args[1],"%d", &val))
return string("cannot scan temp control value ")+string(args[1]);
if (val!=0)
return string ("temp_event option must be 0 to clear event");
myDet->setTemperatureEvent(val);
}
sprintf(answer,"%d", myDet->setTemperatureEvent());
}
else
return string ("cannot scan command " + cmd);
return string(answer);
}
string slsDetectorCommand::helpTempControl(int narg, char *args[], int action) {
ostringstream os;
if (action==PUT_ACTION || action==HELP_ACTION) {
os << "temp_threshold t \t sets the threshold temperature. Jungfrau only" << std::endl;
os << "temp_control t \t Enables/Disables the temperature control. 1 enables, 0 disables. JUNGFRAU ONLY" << std::endl;
os << "temp_event t \t Resets over-temperative event. Put only with option 0 to clear event. JUNGFRAU ONLY." << std::endl;
}
if (action==GET_ACTION || action==HELP_ACTION) {
os << "temp_threshold \t gets the threshold temperature. Jungfrau only." << std::endl;
os << "temp_control \t gets temperature control enable. 1 enabled, 0 disabled. JUNGFRAU ONLY" << std::endl;
os << "temp_event \t gets over-temperative event. Gets 1 if temperature went over threshold and control is enabled, else 0. /Disables the temperature control. JUNGFRAU ONLY." << std::endl;
}
return os.str();
}
string slsDetectorCommand::cmdTiming(int narg, char *args[], int action){ string slsDetectorCommand::cmdTiming(int narg, char *args[], int action){
#ifdef VERBOSE #ifdef VERBOSE
cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n"); cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n");
@ -5894,7 +6004,9 @@ 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") { }
else if (cmd=="led") {
char ans[100]; char ans[100];
int val=0; int val=0;
myDet->setOnline(ONLINE_FLAG); myDet->setOnline(ONLINE_FLAG);
@ -5908,6 +6020,19 @@ string slsDetectorCommand::cmdAdvanced(int narg, char *args[], int action) {
sprintf(ans,"%d",~(myDet->readRegister(0x4d))&1); sprintf(ans,"%d",~(myDet->readRegister(0x4d))&1);
return string(ans); return string(ans);
} }
else if (cmd=="auto_comp_disable") {
char ans[100];
myDet->setOnline(ONLINE_FLAG);
if (action==PUT_ACTION){
int ival = -1;
if (!sscanf(args[1],"%d",&ival))
return string("could not scan auto_comp_control parameter " + string(args[1]));
myDet->setAutoComparatorDisableMode(ival);
}
sprintf(ans,"%d",myDet->setAutoComparatorDisableMode());
return string(ans);
}
else else
return string("unknown command ")+cmd; return string("unknown command ")+cmd;
@ -5927,6 +6052,7 @@ string slsDetectorCommand::helpAdvanced(int narg, char *args[], int action) {
os << "led s \t sets led status (0 off, 1 on)" << std::endl; os << "led s \t sets led status (0 off, 1 on)" << std::endl;
os << "powerchip i \t powers on or off the chip. i = 1 for on, i = 0 for off" << std::endl; os << "powerchip i \t powers on or off the chip. i = 1 for on, i = 0 for off" << std::endl;
os << "auto_comp_disable i \t Currently not implemented. this mode disables the on-chip gain switching comparator automatically after 93.75% of exposure time (only for longer than 100us). 1 enables mode, 0 disables mode. By default, mode is disabled (comparator is enabled throughout). (JUNGFRAU only). " << std::endl;
} }
if (action==GET_ACTION || action==HELP_ACTION) { if (action==GET_ACTION || action==HELP_ACTION) {
@ -5936,6 +6062,7 @@ string slsDetectorCommand::helpAdvanced(int narg, char *args[], int action) {
os << "led \t returns led status (0 off, 1 on)" << std::endl; os << "led \t returns led status (0 off, 1 on)" << std::endl;
os << "flags \t gets the readout flags. can be none, storeinram, tot, continous, parallel, nonparallel, safe, unknown" << std::endl; os << "flags \t gets the readout flags. can be none, storeinram, tot, continous, parallel, nonparallel, safe, unknown" << std::endl;
os << "powerchip \t gets if the chip has been powered on or off" << std::endl; os << "powerchip \t gets if the chip has been powered on or off" << std::endl;
os << "auto_comp_disable \t Currently not implemented. gets if the automatic comparator diable mode is enabled/disabled" << std::endl;
} }
return os.str(); return os.str();

View File

@ -82,6 +82,7 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
static string helpImage(int narg, char *args[], int action); static string helpImage(int narg, char *args[], int action);
static string helpCounter(int narg, char *args[], int action); static string helpCounter(int narg, char *args[], int action);
static string helpADC(int narg, char *args[], int action); static string helpADC(int narg, char *args[], int action);
static string helpTempControl(int narg, char *args[], int action);
static string helpEnablefwrite(int narg, char *args[], int action); static string helpEnablefwrite(int narg, char *args[], int action);
static string helpOverwrite(int narg, char *args[], int action); static string helpOverwrite(int narg, char *args[], int action);
static string helpReceiver(int narg, char *args[], int action); static string helpReceiver(int narg, char *args[], int action);
@ -155,6 +156,7 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
string cmdImage(int narg, char *args[], int action); string cmdImage(int narg, char *args[], int action);
string cmdCounter(int narg, char *args[], int action); string cmdCounter(int narg, char *args[], int action);
string cmdADC(int narg, char *args[], int action); string cmdADC(int narg, char *args[], int action);
string cmdTempControl(int narg, char *args[], int action);
string cmdEnablefwrite(int narg, char *args[], int action); string cmdEnablefwrite(int narg, char *args[], int action);
string cmdOverwrite(int narg, char *args[], int action); string cmdOverwrite(int narg, char *args[], int action);
string cmdReceiver(int narg, char *args[], int action); string cmdReceiver(int narg, char *args[], int action);

View File

@ -622,6 +622,12 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
*/ */
virtual int powerChip(int ival= -1)=0; virtual int powerChip(int ival= -1)=0;
/** automatic comparator disable for Jungfrau only
\param ival on is 1, off is 0, -1 to get
\returns OK or FAIL
*/
virtual int setAutoComparatorDisableMode(int ival= -1)=0;
/** saves the modules settings/trimbits writing to a file /** saves the modules settings/trimbits writing to a file
\param fname file name . Axtension is automatically generated! \param fname file name . Axtension is automatically generated!
\param imod module number, -1 means all modules \param imod module number, -1 means all modules
@ -658,6 +664,30 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
*/ */
virtual dacs_t getADC(dacIndex index, int imod=-1)=0; virtual dacs_t getADC(dacIndex index, int imod=-1)=0;
/**
set/gets threshold temperature (Jungfrau only)
\param val value in millidegrees, -1 gets
\param imod module number, -1 is all
\returns threshold temperature in millidegrees
*/
virtual int setThresholdTemperature(int val=-1, int imod=-1)=0;
/**
enables/disables temperature control (Jungfrau only)
\param val value, -1 gets
\param imod module number, -1 is all
\returns temperature control enable
*/
virtual int setTemperatureControl(int val=-1, int imod=-1)=0;
/**
Resets/ gets over-temperature event (Jungfrau only)
\param val value, -1 gets
\param imod module number, -1 is all
\returns over-temperature event
*/
virtual int setTemperatureEvent(int val=-1, int imod=-1)=0;
/** /**
get the maximum size of the detector get the maximum size of the detector
\param d dimension \param d dimension

View File

@ -6,67 +6,68 @@
#endif #endif
/* global variables */ /* global variables */
void serializeToSPI(u_int32_t addr, u_int32_t val, u_int32_t csmask, int numbitstosend, u_int32_t clkmask, u_int32_t digoutmask, int digofset) {
#ifdef VERBOSE
if (numbitstosend == 16)
printf("Writing to SPI Register: 0x%04x\n",val);
else
printf("Writing to SPI Register: 0x%08x\n", val);
#endif
u_int32_t valw; void SPIChipSelect (u_int32_t* valw, u_int32_t addr, u_int32_t csmask) {
SPIChipSelect (valw, addr, csmask);
sendDataToSPI(valw, addr, val, numbitstosend, clkmask, digoutmask, digofset);
SPIChipDeselect(valw, addr, csmask, clkmask);
}
void SPIChipSelect (u_int32_t& valw, u_int32_t addr, u_int32_t csmask) {
// start point // start point
valw = 0xffffffff; // old board compatibility (not using specific bits) (*valw) = 0xffffffff; // old board compatibility (not using specific bits)
bus_w (addr, valw); bus_w (addr, (*valw));
// chip sel bar down // chip sel bar down
valw &= ~csmask; /* todo with test: done a bit different, not with previous value */ (*valw) &= ~csmask; /* todo with test: done a bit different, not with previous value */
bus_w (addr, valw); bus_w (addr, (*valw));
} }
void SPIChipDeselect (u_int32_t& valw, u_int32_t addr, u_int32_t csmask, u_int32_t clkmask) { void SPIChipDeselect (u_int32_t* valw, u_int32_t addr, u_int32_t csmask, u_int32_t clkmask) {
// chip sel bar up // chip sel bar up
valw |= csmask; /* todo with test: not done for spi */ (*valw) |= csmask; /* todo with test: not done for spi */
bus_w (addr, valw); bus_w (addr, (*valw));
//clk down //clk down
valw &= ~clkmask; (*valw) &= ~clkmask;
bus_w (addr, valw); bus_w (addr, (*valw));
// stop point = start point of course // stop point = start point of course
valw = 0xffffffff; // old board compatibility (not using specific bits) (*valw) = 0xffffffff; // old board compatibility (not using specific bits)
bus_w (addr, valw); bus_w (addr, (*valw));
} }
void sendDataToSPI (u_int32_t& valw, u_int32_t addr, u_int32_t val, int numbitstosend, u_int32_t clkmask, u_int32_t digoutmask, int digofset) { void sendDataToSPI (u_int32_t* valw, u_int32_t addr, u_int32_t val, int numbitstosend, u_int32_t clkmask, u_int32_t digoutmask, int digofset) {
int i = 0; int i = 0;
for (i = 0; i < numbitstosend; ++i) { for (i = 0; i < numbitstosend; ++i) {
// clk down // clk down
valw &= ~clkmask; (*valw) &= ~clkmask;
bus_w (addr, valw); bus_w (addr, (*valw));
// write data (i) // write data (i)
valw = ((valw & ~digoutmask) + // unset bit (*valw) = (((*valw) & ~digoutmask) + // unset bit
(((val >> (numbitstosend - 1 - i)) & 0x1) << digofset)); // each bit from val starting from msb (((val >> (numbitstosend - 1 - i)) & 0x1) << digofset)); // each bit from val starting from msb
bus_w (addr, valw); bus_w (addr, (*valw));
// clk up // clk up
valw |= clkmask ; (*valw) |= clkmask ;
bus_w (addr, valw); bus_w (addr, (*valw));
} }
} }
void serializeToSPI(u_int32_t addr, u_int32_t val, u_int32_t csmask, int numbitstosend, u_int32_t clkmask, u_int32_t digoutmask, int digofset) {
#ifdef VERBOSE
if (numbitstosend == 16)
printf("Writing to SPI Register: 0x%04x\n",val);
else
printf("Writing to SPI Register: 0x%08x\n", val);
#endif
u_int32_t valw;
SPIChipSelect (&valw, addr, csmask);
sendDataToSPI(&valw, addr, val, numbitstosend, clkmask, digoutmask, digofset);
SPIChipDeselect(&valw, addr, csmask, clkmask);
}
#endif //COMMON_SERVER_FUNCTIONS_H #endif //COMMON_SERVER_FUNCTIONS_H

View File

@ -37,6 +37,7 @@ u_int64_t getFirmwareVersion();
#ifdef MYTHEND #ifdef MYTHEND
int64_t getModuleId(enum idMode arg, int imod); int64_t getModuleId(enum idMode arg, int imod);
#elif JUNGFRAUD #elif JUNGFRAUD
u_int64_t getFirmwareAPIVersion();
u_int16_t getHardwareVersionNumber(); u_int16_t getHardwareVersionNumber();
u_int16_t getHardwareSerialNumber(); u_int16_t getHardwareSerialNumber();
#endif #endif
@ -75,11 +76,13 @@ int powerChip (int on);
void cleanFifos(); void cleanFifos();
void resetCore(); void resetCore();
void resetPeripheral(); void resetPeripheral();
#endif
#ifdef MYTHEN3D
int getPhase(int i); int getPhase(int i);
int configurePhase(int val, enum CLKINDEX i); int configurePhase(int val, enum CLKINDEX i);
int configureFrequency(int val, int i); int configureFrequency(int val, int i);
#endif #elif JUNGFRAUD
#ifdef JUNGFRAUD int autoCompDisable(int on);
int adcPhase(int st); int adcPhase(int st);
int getPhase(); int getPhase();
#endif #endif
@ -197,6 +200,9 @@ int calibratePedestal(int frames);
void resetPLL(); void resetPLL();
u_int32_t setPllReconfigReg(u_int32_t reg, u_int32_t val); u_int32_t setPllReconfigReg(u_int32_t reg, u_int32_t val);
void configurePll(); void configurePll();
int setThresholdTemperature(int val);
int setTemperatureControl(int val);
int setTemperatureEvent(int val);
extern void eraseFlash(); // programfpga.h extern void eraseFlash(); // programfpga.h
extern int startWritingFPGAprogram(FILE** filefp); // programfpga.h extern int startWritingFPGAprogram(FILE** filefp); // programfpga.h
extern void stopWritingFPGAprogram(FILE* filefp); // programfpga.h extern void stopWritingFPGAprogram(FILE* filefp); // programfpga.h
@ -220,7 +226,9 @@ int setAllTrimbits(int val);
int getAllTrimbits(); int getAllTrimbits();
int getBebFPGATemp(); int getBebFPGATemp();
int activate(int enable); int activate(int enable);
int setNetworkParameter(enum NETWORKINDEX mode, int value); #endif
#if defined(JUNGFRAUD) || defined(EIGERD)
int setNetworkParameter(enum NETWORKINDEX mode, int value);
#endif #endif

View File

@ -12,7 +12,6 @@
#include <signal.h> #include <signal.h>
#include <string.h> #include <string.h>
extern int sockfd; extern int sockfd;
@ -30,14 +29,13 @@ int main(int argc, char *argv[]){
// subsequent read/write to socket gives error - must handle locally // subsequent read/write to socket gives error - must handle locally
signal(SIGPIPE, SIG_IGN); signal(SIGPIPE, SIG_IGN);
// circumvent the basic tests // circumvent the basic tests
if(argc > 1) { if(argc > 1) {
if(!strcasecmp(argv[1],"-debug")){ if(!strcasecmp(argv[1],"-debug")){
debugflag = 1; debugflag = 1;
argc=1; argc=1;
} }
} }
#ifdef STOP_SERVER #ifdef STOP_SERVER
char cmd[100]; char cmd[100];
@ -85,8 +83,10 @@ int main(int argc, char *argv[]){
printf("function table assigned \n"); printf("function table assigned \n");
#endif #endif
if (b)
printf("\nReady...\n\n"); printf("\nControl Server Ready...\n\n");
else
printf("\nStop Server Ready...\n\n");
/* waits for connection */ /* waits for connection */
while(retval!=GOODBYE) { while(retval!=GOODBYE) {

View File

@ -50,7 +50,7 @@ int printSocketReadError() {
} }
void basictests(int flag) { void basictests(int flag) {
debugflag = flag; debugflag = flag;
#ifdef SLS_DETECTOR_FUNCTION_LIST #ifdef SLS_DETECTOR_FUNCTION_LIST
checkFirmwareCompatibility(debugflag); checkFirmwareCompatibility(debugflag);
#endif #endif
@ -64,7 +64,7 @@ void init_detector(int controlserver) {
#ifdef SLS_DETECTOR_FUNCTION_LIST #ifdef SLS_DETECTOR_FUNCTION_LIST
if (controlserver) { if (controlserver) {
isControlServer = 1; isControlServer = 1;
initControlServer(); initControlServer();
} }
else initStopServer(); else initStopServer();
@ -183,6 +183,11 @@ const char* getFunctionName(enum detFuncs func) {
case F_ACTIVATE: return "F_ACTIVATE"; case F_ACTIVATE: return "F_ACTIVATE";
case F_PREPARE_ACQUISITION: return "F_PREPARE_ACQUISITION"; case F_PREPARE_ACQUISITION: return "F_PREPARE_ACQUISITION";
case F_CLEANUP_ACQUISITION: return "F_CLEANUP_ACQUISITION"; case F_CLEANUP_ACQUISITION: return "F_CLEANUP_ACQUISITION";
case F_THRESHOLD_TEMP: return "F_THRESHOLD_TEMP";
case F_TEMP_CONTROL: return "F_TEMP_CONTROL";
case F_TEMP_EVENT: return "F_TEMP_EVENT";
case F_AUTO_COMP_DISABLE: return "F_AUTO_COMP_DISABLE";
default: return "Unknown Function"; default: return "Unknown Function";
} }
} }
@ -261,6 +266,10 @@ void function_table() {
flist[F_ACTIVATE] = &set_activate; flist[F_ACTIVATE] = &set_activate;
flist[F_PREPARE_ACQUISITION] = &prepare_acquisition; flist[F_PREPARE_ACQUISITION] = &prepare_acquisition;
flist[F_CLEANUP_ACQUISITION] = &cleanup_acquisition; flist[F_CLEANUP_ACQUISITION] = &cleanup_acquisition;
flist[F_THRESHOLD_TEMP] = &threshold_temp;
flist[F_TEMP_CONTROL] = &temp_control;
flist[F_TEMP_EVENT] = &temp_event;
flist[F_AUTO_COMP_DISABLE] = &auto_comp_disable;
// check // check
if (NUM_DET_FUNCTIONS >= TOO_MANY_FUNCTIONS_DEFINED) { if (NUM_DET_FUNCTIONS >= TOO_MANY_FUNCTIONS_DEFINED) {
@ -4187,11 +4196,6 @@ int set_all_trimbits(int file_des){
int set_ctb_pattern(int file_des) { int set_ctb_pattern(int file_des) {
int ret=OK,ret1=OK; int ret=OK,ret1=OK;
int n=0; int n=0;
int retval=-1;
int mode = -1;
int addr = -1, level = -1, nl = -1, start = -1, stop = -1;
uint64_t word = -1,retval64 = -1, t = -1;
sprintf(mess,"Could not set pattern\n"); sprintf(mess,"Could not set pattern\n");
#ifndef MYTHEN3D #ifndef MYTHEN3D
@ -4212,7 +4216,13 @@ int set_ctb_pattern(int file_des) {
return ret; return ret;
#endif #else
int retval=-1;
int mode = -1;
int addr = -1, level = -1, nl = -1, start = -1, stop = -1;
uint64_t word = -1,retval64 = -1, t = -1;
n = receiveDataOnly(file_des, &mode, sizeof(mode)); n = receiveDataOnly(file_des, &mode, sizeof(mode));
printf("pattern mode is %d\n",mode); printf("pattern mode is %d\n",mode);
@ -4223,7 +4233,7 @@ int set_ctb_pattern(int file_des) {
n = receiveDataOnly(file_des,&word,sizeof(word)); n = receiveDataOnly(file_des,&word,sizeof(word));
ret=OK; ret=OK;
printf("pattern addr is %d %x\n",addr, word); printf("pattern addr is %d %llx\n",addr, word);
switch (addr) { switch (addr) {
case -1: case -1:
retval64=writePatternIOControl(word); retval64=writePatternIOControl(word);
@ -4359,6 +4369,7 @@ int set_ctb_pattern(int file_des) {
// return ok / fail // return ok / fail
return ret; return ret;
#endif
} }
@ -4763,7 +4774,7 @@ int set_network_parameter(int file_des) {
int retval=-1; int retval=-1;
sprintf(mess,"set network parameter failed\n"); sprintf(mess,"set network parameter failed\n");
#ifndef EIGERD #if !defined(EIGERD) && !defined(JUNGFRAUD)
//to receive any arguments //to receive any arguments
while (n > 0) while (n > 0)
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
@ -4784,7 +4795,7 @@ int set_network_parameter(int file_des) {
if (n < 0) return printSocketReadError(); if (n < 0) return printSocketReadError();
// execute action // execute action
if (differentClients && lockStatus && value<0) { if (differentClients && lockStatus && value >= 0) {
ret = FAIL; ret = FAIL;
sprintf(mess,"Detector locked by %s\n",lastClientIP); sprintf(mess,"Detector locked by %s\n",lastClientIP);
cprintf(RED, "Warning: %s", mess); cprintf(RED, "Warning: %s", mess);
@ -4795,17 +4806,27 @@ int set_network_parameter(int file_des) {
printf("setting network parameter mode %d to %d\n",(int)mode,value); printf("setting network parameter mode %d to %d\n",(int)mode,value);
#endif #endif
switch (mode) { switch (mode) {
#ifdef EIGERD
case FLOW_CONTROL_10G:
index = FLOWCTRL_10G;
break;
case DETECTOR_TXN_DELAY_LEFT: case DETECTOR_TXN_DELAY_LEFT:
index = TXN_LEFT; index = TXN_LEFT;
break; break;
case DETECTOR_TXN_DELAY_RIGHT: case DETECTOR_TXN_DELAY_RIGHT:
index = TXN_RIGHT; index = TXN_RIGHT;
break; break;
#endif
case DETECTOR_TXN_DELAY_FRAME: case DETECTOR_TXN_DELAY_FRAME:
index = TXN_FRAME; index = TXN_FRAME;
break; #ifdef JUNGFRAUD
case FLOW_CONTROL_10G: if (value > MAX_TIMESLOT_VAL) {
index = FLOWCTRL_10G; ret=FAIL;
sprintf(mess,"Transmission delay %d should be in range: 0 - %d\n", value, MAX_TIMESLOT_VAL);
cprintf(RED, "Warning: %s", mess);
}
#endif
break; break;
default: default:
ret=FAIL; ret=FAIL;
@ -4963,9 +4984,9 @@ int program_fpga(int file_des) {
#ifdef VERY_VERBOSE #ifdef VERY_VERBOSE
printf("Done with program receiving command\n"); printf("Done with program receiving command\n");
#endif #endif
if (isControlServer) if (isControlServer)
basictests(debugflag); basictests(debugflag);
init_detector(isControlServer); init_detector(isControlServer);
} }
#endif #endif
if (ret==OK) if (ret==OK)
@ -5011,9 +5032,9 @@ int reset_fpga(int file_des) {
} }
#ifdef SLS_DETECTOR_FUNCTION_LIST #ifdef SLS_DETECTOR_FUNCTION_LIST
else { else {
if (isControlServer) if (isControlServer)
basictests(debugflag); basictests(debugflag);
init_detector(isControlServer); initControlServer(isControlServer);
ret = FORCE_UPDATE; ret = FORCE_UPDATE;
} }
#endif #endif
@ -5074,7 +5095,10 @@ int power_chip(int file_des) {
ret=OK; ret=OK;
} else { } else {
ret=FAIL; ret=FAIL;
sprintf(mess,"Powering chip failed, wrote %d but read %d\n", arg, retval); if(setTemperatureEvent(-1) == 1)
sprintf(mess,"Powering chip failed due to over-temperature event. Clear event & power chip again. Wrote %d, read %d \n", arg, retval);
else
sprintf(mess,"Powering chip failed, wrote %d but read %d\n", arg, retval);
cprintf(RED, "Warning: %s", mess); cprintf(RED, "Warning: %s", mess);
} }
} }
@ -5250,3 +5274,255 @@ int cleanup_acquisition(int file_des) {
} }
int threshold_temp(int file_des) {
int ret=OK,ret1=OK;
int n=0;
int retval=-1;
sprintf(mess,"could not set/get threshold temperature\n");
#ifndef JUNGFRAUD
//to receive any arguments
while (n > 0)
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
ret = FAIL;
sprintf(mess,"Function (Threshold Temp) is not implemented for this detector\n");
cprintf(RED, "%s", mess);
#else
int arg[2]={-1,-1};
int val=-1;
// receive arguments
n = receiveData(file_des,arg,sizeof(arg),INT32);
if (n < 0) return printSocketReadError();
val=arg[0];
//ignoring imod
if (val > MAX_THRESHOLD_TEMP_VAL) {
ret=FAIL;
sprintf(mess,"Threshold Temp %d should be in range: 0 - %d\n", val, MAX_THRESHOLD_TEMP_VAL);
cprintf(RED, "Warning: %s", mess);
}
#ifdef SLS_DETECTOR_FUNCTION_LIST
if (ret==OK) {
#ifdef VERBOSE
printf("Setting Threshold Temperature to %d\n", val);
#endif
retval=setThresholdTemperature(val);
}
#endif
#ifdef VERBOSE
printf("Threshold temperature is %d\n", retval);
#endif
if (ret==OK && differentClients && val >= 0)
ret=FORCE_UPDATE;
#endif
// ret could be swapped during sendData
ret1 = ret;
// send ok / fail
n = sendData(file_des,&ret1,sizeof(ret),INT32);
// send return argument
if (ret!=FAIL) {
n += sendData(file_des,&retval,sizeof(retval),INT32);
} else {
n += sendData(file_des,mess,sizeof(mess),OTHER);
}
// return ok / fail
return ret;
}
int temp_control(int file_des) {
int ret=OK,ret1=OK;
int n=0;
int retval=-1;
sprintf(mess,"could not set/get temperature control\n");
#ifndef JUNGFRAUD
//to receive any arguments
while (n > 0)
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
ret = FAIL;
sprintf(mess,"Function (Temperature control) is not implemented for this detector\n");
cprintf(RED, "%s", mess);
#else
int arg[2]={-1,-1};
int val=-1;
// receive arguments
n = receiveData(file_des,arg,sizeof(arg),INT32);
if (n < 0) return printSocketReadError();
val=arg[0];
//ignoring imod
#ifdef SLS_DETECTOR_FUNCTION_LIST
if (ret==OK) {
#ifdef VERBOSE
printf("Setting Temperature control to %d\n", val);
#endif
retval=setTemperatureControl(val);
}
#endif
#ifdef VERBOSE
printf("Temperature control is %d\n", retval);
#endif
if (ret==OK && differentClients && val >= 0)
ret=FORCE_UPDATE;
#endif
// ret could be swapped during sendData
ret1 = ret;
// send ok / fail
n = sendData(file_des,&ret1,sizeof(ret),INT32);
// send return argument
if (ret!=FAIL) {
n += sendData(file_des,&retval,sizeof(retval),INT32);
} else {
n += sendData(file_des,mess,sizeof(mess),OTHER);
}
// return ok / fail
return ret;
}
int temp_event(int file_des) {
int ret=OK,ret1=OK;
int n=0;
int retval=-1;
sprintf(mess,"could not set/get temperature event\n");
#ifndef JUNGFRAUD
//to receive any arguments
while (n > 0)
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
ret = FAIL;
sprintf(mess,"Function (Temperature Event) is not implemented for this detector\n");
cprintf(RED, "%s", mess);
#else
int arg[2]={-1,-1};
int val=-1;
// receive arguments
n = receiveData(file_des,arg,sizeof(arg),INT32);
if (n < 0) return printSocketReadError();
val=arg[0];
//ignoring imod
#ifdef SLS_DETECTOR_FUNCTION_LIST
if (ret==OK) {
#ifdef VERBOSE
printf("Setting Temperature Event to %d\n", val);
#endif
retval=setTemperatureEvent(val);
}
#endif
#ifdef VERBOSE
printf("Temperature Event is %d\n", retval);
#endif
if (ret==OK && differentClients && val >= 0)
ret=FORCE_UPDATE;
#endif
// ret could be swapped during sendData
ret1 = ret;
// send ok / fail
n = sendData(file_des,&ret1,sizeof(ret),INT32);
// send return argument
if (ret!=FAIL) {
n += sendData(file_des,&retval,sizeof(retval),INT32);
} else {
n += sendData(file_des,mess,sizeof(mess),OTHER);
}
// return ok / fail
return ret;
}
int auto_comp_disable(int file_des) {
int ret=OK,ret1=OK;
int n=0;
int retval=-1;
sprintf(mess,"auto comp disable failed\n");
#ifndef JUNGFRAUD
//to receive any arguments
while (n > 0)
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
ret = FAIL;
sprintf(mess,"Function (Auto Comp Disable) is not implemented for this detector\n");
cprintf(RED, "%s", mess);
#else
//to receive any arguments
while (n > 0)
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
ret = FAIL;
sprintf(mess,"Function (Auto Comp Disable) is not yet implemented for this detector\n");
cprintf(RED, "%s", mess);
/* will be connected after teh fpga upgrade
// receive arguments
int arg=-1;
n = receiveData(file_des,&arg,sizeof(arg),INT32);
if (n < 0) return printSocketReadError();
// execute action
if (differentClients && lockStatus && arg!=-1) {
ret = FAIL;
sprintf(mess,"Detector locked by %s\n",lastClientIP);
cprintf(RED, "Warning: %s", mess);
}
#ifdef SLS_DETECTOR_FUNCTION_LIST
else {
#ifdef VERBOSE
printf("Auto Comp Disable to %d\n", arg);
#endif
retval=autoCompDisable(arg);
#ifdef VERBOSE
printf("Auto comp disable set to: %d\n",retval);
#endif
if (retval==arg || arg<0) {
ret=OK;
} else {
ret=FAIL;
sprintf(mess,"Atuo Comp Disable failed, wrote %d but read %d\n", arg, retval);
cprintf(RED, "Warning: %s", mess);
}
}
#endif
if (ret==OK && differentClients)
ret=FORCE_UPDATE;
*/
#endif
// ret could be swapped during sendData
ret1 = ret;
// send ok / fail
n = sendData(file_des,&ret1,sizeof(ret),INT32);
// send return argument
if (ret==FAIL) {
n += sendData(file_des,mess,sizeof(mess),OTHER);
} else
n += sendData(file_des,&retval,sizeof(retval),INT32);
// return ok / fail
return ret;
}

View File

@ -88,6 +88,9 @@ int power_chip(int);
int set_activate(int); int set_activate(int);
int prepare_acquisition(int); int prepare_acquisition(int);
int cleanup_acquisition(int); int cleanup_acquisition(int);
int threshold_temp(int);
int temp_control(int);
int temp_event(int);
int auto_comp_disable(int);
#endif #endif