m3 server: setting counter mask, set vth[i] for counter[i] and its M_VTH1, not VTH1

This commit is contained in:
maliakal_d 2021-05-20 14:51:37 +02:00
parent ac613171ec
commit 224c8d9f8d
2 changed files with 23 additions and 23 deletions

View File

@ -5,8 +5,8 @@
#include "RegisterDefs.h" #include "RegisterDefs.h"
#include "clogger.h" #include "clogger.h"
#include "common.h" #include "common.h"
#include "mythen3.h"
#include "loadPattern.h" #include "loadPattern.h"
#include "mythen3.h"
#include "sharedMemory.h" #include "sharedMemory.h"
#include "sls/versionAPI.h" #include "sls/versionAPI.h"
#ifdef VIRTUAL #ifdef VIRTUAL
@ -21,7 +21,6 @@
#include <time.h> #include <time.h>
#endif #endif
// Global variable from slsDetectorServer_funcs // Global variable from slsDetectorServer_funcs
extern int debugflag; extern int debugflag;
extern int updateFlag; extern int updateFlag;
@ -379,7 +378,6 @@ void allocateDetectorStructureMemory() {
memset(channelMask, 0, NCHIP * NCHAN * sizeof(char)); memset(channelMask, 0, NCHIP * NCHAN * sizeof(char));
detectorDacs = malloc(NDAC * sizeof(int)); detectorDacs = malloc(NDAC * sizeof(int));
LOG(logDEBUG1, LOG(logDEBUG1,
("modules from 0x%x to 0x%x\n", detectorModules, detectorModules)); ("modules from 0x%x to 0x%x\n", detectorModules, detectorModules));
LOG(logDEBUG1, ("chans from 0x%x to 0x%x\n", detectorChans, detectorChans)); LOG(logDEBUG1, ("chans from 0x%x to 0x%x\n", detectorChans, detectorChans));
@ -938,8 +936,9 @@ void setCounterMask(uint32_t arg) {
for (int i = 0; i < NCOUNTERS; ++i) { for (int i = 0; i < NCOUNTERS; ++i) {
// if change in enable // if change in enable
if ((arg & (1 << i)) ^ (oldmask & (1 << i))) { if ((arg & (1 << i)) ^ (oldmask & (1 << i))) {
// will disable if counter disabled // will disable if counter disabled, else set corresponding vth dac
setDAC(VTH1, vthEnabledVals[i], 0); enum DACINDEX vth = (i == 0 ? M_VTH1 : (i == 1 ? M_VTH2 : M_VTH3));
setDAC(vth, vthEnabledVals[i], 0);
} }
} }
} }
@ -1074,7 +1073,6 @@ int setDACS(int* dacs){
return OK; return OK;
} }
int setModule(sls_detector_module myMod, char *mess) { int setModule(sls_detector_module myMod, char *mess) {
LOG(logINFO, ("Setting module\n")); LOG(logINFO, ("Setting module\n"));
@ -1267,6 +1265,12 @@ void setDAC(enum DACINDEX ind, int val, int mV) {
return; return;
} }
// out of scope, NDAC + 1 for vthreshold
if ((int)ind > NDAC + 1) {
LOG(logERROR, ("Unknown dac index %d\n", ind));
return;
}
if (ind == M_VTHRESHOLD) { if (ind == M_VTHRESHOLD) {
LOG(logINFO, LOG(logINFO,
("Setting Threshold voltages to %d %s\n", val, (mV ? "mv" : ""))); ("Setting Threshold voltages to %d %s\n", val, (mV ? "mv" : "")));
@ -1373,9 +1377,7 @@ int setHighVoltage(int val) {
return highvoltage; return highvoltage;
} }
int isMaster(){ int isMaster() { return !(bus_r(0x18) >> 31); }
return !(bus_r(0x18) >> 31);
}
/* parameters - timing */ /* parameters - timing */
void setTiming(enum timingMode arg) { void setTiming(enum timingMode arg) {

View File

@ -289,8 +289,6 @@ int64_t getMeasurementTime();
int setModule(sls_detector_module myMod, char *mess); int setModule(sls_detector_module myMod, char *mess);
#endif #endif
#ifdef MYTHEN3D #ifdef MYTHEN3D
int setBit(int ibit, int patword);
int clearBit(int ibit, int patword);
int setTrimbits(int *trimbits); int setTrimbits(int *trimbits);
int setAllTrimbits(int val); int setAllTrimbits(int val);
int getAllTrimbits(); int getAllTrimbits();