using setChipStatusRegister

This commit is contained in:
Erik Frojdh 2021-04-07 16:27:40 +02:00
parent 0299d315d5
commit 55b4a92453
2 changed files with 32 additions and 36 deletions

View File

@ -517,14 +517,11 @@ void setupDetector() {
}
powerChip(1);
if (initError != FAIL) {
patternParameters *pat=setChipStatusRegisterPattern(CSR_default);
if (pat) {
initError=loadPattern(pat);
startStateMachine();
free(pat);
}
if (!initError) {
setChipStatusRegister(CSR_default);
}
setAllTrimbits(DEFAULT_TRIMBIT_VALUE);
}
@ -1130,7 +1127,8 @@ int setTrimbits(int *trimbits) {
/////////////////////////////////////////////////////////////////
for (int ichip = 0; ichip < NCHIP; ichip++) {
pat=setChannelRegisterChip(ichip,channelMask,trimbits); //change here!!!
pat = setChannelRegisterChip(ichip, channelMask,
trimbits); // change here!!!
if (pat) {
error |= loadPattern(pat);
if (error == 0)
@ -2632,7 +2630,6 @@ int getNumberOfChips() { return NCHIP; }
int getNumberOfDACs() { return NDAC; }
int getNumberOfChannelsPerChip() { return NCHAN; }
int setChipStatusRegister(int csr) {
uint32_t prevRunClk = clkDivider[SYSTEM_C0];
patternParameters *pat = NULL;
@ -2647,26 +2644,25 @@ int setChipStatusRegister(int csr){
if (pat) {
error |= loadPattern(pat);
if (error == 0)
if (!error)
startPattern();
free(pat);
} else {
error = 1;
}
if (error == 0) {
if (!error) {
LOG(logINFO, ("CSR is now: 0x%x\n", csr));
}
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 OK;
}
int setGainCaps(int caps){
// Update only gain caps, leave the rest of the CSR unchanged
int csr = getChipStatusRegister();