mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-22 03:40:04 +02:00
m3 server: setting counter mask, set vth[i] for counter[i] and its M_VTH1, not VTH1
This commit is contained in:
parent
ac613171ec
commit
224c8d9f8d
@ -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;
|
||||||
@ -47,7 +46,7 @@ enum detectorSettings thisSettings;
|
|||||||
sls_detector_module *detectorModules = NULL;
|
sls_detector_module *detectorModules = NULL;
|
||||||
int *detectorChans = NULL;
|
int *detectorChans = NULL;
|
||||||
int *detectorDacs = NULL;
|
int *detectorDacs = NULL;
|
||||||
int *channelMask=NULL;
|
int *channelMask = NULL;
|
||||||
|
|
||||||
int32_t clkPhase[NUM_CLOCKS] = {};
|
int32_t clkPhase[NUM_CLOCKS] = {};
|
||||||
uint32_t clkDivider[NUM_CLOCKS] = {};
|
uint32_t clkDivider[NUM_CLOCKS] = {};
|
||||||
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1057,7 +1056,7 @@ int64_t getMeasurementTime() {
|
|||||||
|
|
||||||
/* parameters - module, speed, readout */
|
/* parameters - module, speed, readout */
|
||||||
|
|
||||||
int setDACS(int* dacs){
|
int setDACS(int *dacs) {
|
||||||
for (int i = 0; i < NDAC; ++i) {
|
for (int i = 0; i < NDAC; ++i) {
|
||||||
if (dacs[i] != -1) {
|
if (dacs[i] != -1) {
|
||||||
setDAC((enum DACINDEX)i, dacs[i], 0);
|
setDAC((enum DACINDEX)i, dacs[i], 0);
|
||||||
@ -1074,17 +1073,16 @@ 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"));
|
||||||
|
|
||||||
if (setChipStatusRegister(myMod.reg)){
|
if (setChipStatusRegister(myMod.reg)) {
|
||||||
sprintf(mess, "Could not CSR from module\n");
|
sprintf(mess, "Could not CSR from module\n");
|
||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setDACS(myMod.dacs)){
|
if (setDACS(myMod.dacs)) {
|
||||||
sprintf(mess, "Could not set dacs\n");
|
sprintf(mess, "Could not set dacs\n");
|
||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@ -1093,7 +1091,7 @@ int setModule(sls_detector_module myMod, char *mess) {
|
|||||||
for (int i = 0; i < NCOUNTERS; ++i) {
|
for (int i = 0; i < NCOUNTERS; ++i) {
|
||||||
if (myMod.eV[i] >= 0) {
|
if (myMod.eV[i] >= 0) {
|
||||||
setThresholdEnergy(i, myMod.eV[i]);
|
setThresholdEnergy(i, myMod.eV[i]);
|
||||||
}else{
|
} else {
|
||||||
setThresholdEnergy(i, -1);
|
setThresholdEnergy(i, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -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) {
|
||||||
@ -2663,7 +2665,7 @@ int setChipStatusRegister(int csr) {
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int setGainCaps(int caps){
|
int setGainCaps(int caps) {
|
||||||
// Update only gain caps, leave the rest of the CSR unchanged
|
// Update only gain caps, leave the rest of the CSR unchanged
|
||||||
int csr = getChipStatusRegister();
|
int csr = getChipStatusRegister();
|
||||||
csr &= ~GAIN_MASK;
|
csr &= ~GAIN_MASK;
|
||||||
@ -2674,7 +2676,7 @@ int setGainCaps(int caps){
|
|||||||
return setChipStatusRegister(csr);
|
return setChipStatusRegister(csr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int getGainCaps(){
|
int getGainCaps() {
|
||||||
int csr = getChipStatusRegister();
|
int csr = getChipStatusRegister();
|
||||||
int caps = csrToGainCaps(csr);
|
int caps = csrToGainCaps(csr);
|
||||||
return caps;
|
return caps;
|
||||||
|
@ -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();
|
||||||
@ -360,7 +358,7 @@ int isMaster();
|
|||||||
int setGainCaps(int caps);
|
int setGainCaps(int caps);
|
||||||
int getGainCaps();
|
int getGainCaps();
|
||||||
int setChipStatusRegister(int csr);
|
int setChipStatusRegister(int csr);
|
||||||
int setDACS(int* dacs);
|
int setDACS(int *dacs);
|
||||||
#endif
|
#endif
|
||||||
#if defined(GOTTHARDD) || defined(MYTHEN3D)
|
#if defined(GOTTHARDD) || defined(MYTHEN3D)
|
||||||
void setExtSignal(int signalIndex, enum externalSignalFlag mode);
|
void setExtSignal(int signalIndex, enum externalSignalFlag mode);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user