mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-05-10 14:50:02 +02:00
using setChipStatusRegister
This commit is contained in:
parent
0299d315d5
commit
55b4a92453
Binary file not shown.
@ -517,14 +517,11 @@ void setupDetector() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
powerChip(1);
|
powerChip(1);
|
||||||
if (initError != FAIL) {
|
|
||||||
patternParameters *pat=setChipStatusRegisterPattern(CSR_default);
|
if (!initError) {
|
||||||
if (pat) {
|
setChipStatusRegister(CSR_default);
|
||||||
initError=loadPattern(pat);
|
|
||||||
startStateMachine();
|
|
||||||
free(pat);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setAllTrimbits(DEFAULT_TRIMBIT_VALUE);
|
setAllTrimbits(DEFAULT_TRIMBIT_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1119,8 +1116,8 @@ int setModule(sls_detector_module myMod, char *mess) {
|
|||||||
int setTrimbits(int *trimbits) {
|
int setTrimbits(int *trimbits) {
|
||||||
// remember previous run clock
|
// remember previous run clock
|
||||||
uint32_t prevRunClk = clkDivider[SYSTEM_C0];
|
uint32_t prevRunClk = clkDivider[SYSTEM_C0];
|
||||||
patternParameters *pat=NULL;
|
patternParameters *pat = NULL;
|
||||||
int error=0;
|
int error = 0;
|
||||||
// set to trimming clock
|
// set to trimming clock
|
||||||
if (setClockDivider(SYSTEM_C0, DEFAULT_TRIMMING_RUN_CLKDIV) == FAIL) {
|
if (setClockDivider(SYSTEM_C0, DEFAULT_TRIMMING_RUN_CLKDIV) == FAIL) {
|
||||||
LOG(logERROR,
|
LOG(logERROR,
|
||||||
@ -1128,24 +1125,25 @@ int setTrimbits(int *trimbits) {
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
for (int ichip=0; ichip<NCHIP; ichip++) {
|
for (int ichip = 0; ichip < NCHIP; ichip++) {
|
||||||
|
|
||||||
pat=setChannelRegisterChip(ichip,channelMask,trimbits); //change here!!!
|
pat = setChannelRegisterChip(ichip, channelMask,
|
||||||
if (pat) {
|
trimbits); // change here!!!
|
||||||
error|=loadPattern(pat);
|
if (pat) {
|
||||||
if (error==0)
|
error |= loadPattern(pat);
|
||||||
startPattern();
|
if (error == 0)
|
||||||
free(pat);
|
startPattern();
|
||||||
} else
|
free(pat);
|
||||||
error=1;
|
} else
|
||||||
|
error = 1;
|
||||||
}
|
}
|
||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
if (error == 0) {
|
if (error == 0) {
|
||||||
// copy trimbits locally
|
// copy trimbits locally
|
||||||
for (int ichan = 0; ichan < ((detectorModules)->nchan); ++ichan) {
|
for (int ichan = 0; ichan < ((detectorModules)->nchan); ++ichan) {
|
||||||
detectorChans[ichan] = trimbits[ichan];
|
detectorChans[ichan] = trimbits[ichan];
|
||||||
}
|
}
|
||||||
LOG(logINFO, ("All trimbits have been loaded\n"));
|
LOG(logINFO, ("All trimbits have been loaded\n"));
|
||||||
}
|
}
|
||||||
trimmingPrint = logINFO;
|
trimmingPrint = logINFO;
|
||||||
// set back to previous clock
|
// set back to previous clock
|
||||||
@ -2632,12 +2630,11 @@ int getNumberOfChips() { return NCHIP; }
|
|||||||
int getNumberOfDACs() { return NDAC; }
|
int getNumberOfDACs() { return NDAC; }
|
||||||
int getNumberOfChannelsPerChip() { return NCHAN; }
|
int getNumberOfChannelsPerChip() { return NCHAN; }
|
||||||
|
|
||||||
|
int setChipStatusRegister(int csr) {
|
||||||
int setChipStatusRegister(int csr){
|
|
||||||
uint32_t prevRunClk = clkDivider[SYSTEM_C0];
|
uint32_t prevRunClk = clkDivider[SYSTEM_C0];
|
||||||
patternParameters *pat=NULL;
|
patternParameters *pat = NULL;
|
||||||
|
|
||||||
int error=0;
|
int error = 0;
|
||||||
if (setClockDivider(SYSTEM_C0, DEFAULT_TRIMMING_RUN_CLKDIV) == FAIL) {
|
if (setClockDivider(SYSTEM_C0, DEFAULT_TRIMMING_RUN_CLKDIV) == FAIL) {
|
||||||
LOG(logERROR,
|
LOG(logERROR,
|
||||||
("Could not set to trimming clock in order to change CSR\n"));
|
("Could not set to trimming clock in order to change CSR\n"));
|
||||||
@ -2645,28 +2642,27 @@ int setChipStatusRegister(int csr){
|
|||||||
}
|
}
|
||||||
pat = setChipStatusRegisterPattern(csr);
|
pat = setChipStatusRegisterPattern(csr);
|
||||||
|
|
||||||
if (pat) {
|
if (pat) {
|
||||||
error |= loadPattern(pat);
|
error |= loadPattern(pat);
|
||||||
if (error == 0)
|
if (!error)
|
||||||
startPattern();
|
startPattern();
|
||||||
free(pat);
|
free(pat);
|
||||||
}else{
|
} else {
|
||||||
error = 1;
|
error = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error == 0) {
|
if (!error) {
|
||||||
LOG(logINFO, ("CSR is now: 0x%x\n", csr));
|
LOG(logINFO, ("CSR is now: 0x%x\n", csr));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setClockDivider(SYSTEM_C0, prevRunClk) == FAIL) {
|
if (setClockDivider(SYSTEM_C0, prevRunClk) == FAIL) {
|
||||||
LOG(logERROR, ("Could not set to previous run clock after changing CSR\n"));
|
LOG(logERROR,
|
||||||
|
("Could not set to previous run clock after changing CSR\n"));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user