mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 15:00:02 +02:00
mythen3: trim: removing printout while tirmming
This commit is contained in:
parent
6872f24037
commit
999c548aa1
@ -43,6 +43,7 @@ sls_detector_module *detectorModules = NULL;
|
||||
int *detectorChans = NULL;
|
||||
int *detectorDacs = NULL;
|
||||
|
||||
int trimming = 0;
|
||||
int32_t clkPhase[NUM_CLOCKS] = {};
|
||||
uint32_t clkDivider[NUM_CLOCKS] = {};
|
||||
|
||||
@ -388,6 +389,7 @@ void setupDetector() {
|
||||
clkDivider[SYSTEM_C2] = DEFAULT_SYSTEM_C2;
|
||||
|
||||
highvoltage = 0;
|
||||
trimming = 0;
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < NUM_CLOCKS; ++i) {
|
||||
@ -609,16 +611,12 @@ int setTrimbits(int *trimbits) {
|
||||
}
|
||||
}
|
||||
LOG(logINFO, ("Trimbits validated\n"));
|
||||
trimming = 1;
|
||||
|
||||
uint64_t patword = 0;
|
||||
int iaddr = 0;
|
||||
int ichip = 0;
|
||||
for (ichip = 0; ichip < NCHIP; ichip++) {
|
||||
if (iaddr >= MAX_PATTERN_LENGTH) {
|
||||
LOG(logERROR, ("Addr 0x%x is past max_address_length 0x%x!\n",
|
||||
iaddr, MAX_PATTERN_LENGTH));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFOBLUE, (" Chip %d\n", ichip));
|
||||
iaddr = 0;
|
||||
patword = 0;
|
||||
@ -646,12 +644,7 @@ int setTrimbits(int *trimbits) {
|
||||
}
|
||||
// for each channel (all chips)
|
||||
for (int ich = 0; ich < NCHAN_1_COUNTER; ich++) {
|
||||
if (iaddr >= MAX_PATTERN_LENGTH) {
|
||||
LOG(logERROR, ("Addr 0x%x is past max_address_length 0x%x!\n",
|
||||
iaddr, MAX_PATTERN_LENGTH));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFOBLUE, (" Chip %d, Channel %d\n", ichip, ich));
|
||||
// LOG(logINFOBLUE, (" Chip %d, Channel %d\n", ichip, ich));
|
||||
int val = trimbits[ichip * NCHAN_1_COUNTER * NCOUNTERS +
|
||||
NCOUNTERS * ich] +
|
||||
trimbits[ichip * NCHAN_1_COUNTER * NCOUNTERS +
|
||||
@ -697,6 +690,14 @@ int setTrimbits(int *trimbits) {
|
||||
patword = ClearBit(SIGNAL_TBLoad_1 + ichip, patword);
|
||||
writePatternWord(iaddr++, patword);
|
||||
|
||||
// last iaddr check
|
||||
if (iaddr >= MAX_PATTERN_LENGTH) {
|
||||
LOG(logERROR, ("Addr 0x%x is past max_address_length 0x%x!\n",
|
||||
iaddr, MAX_PATTERN_LENGTH));
|
||||
trimming = 0;
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// set pattern wait address
|
||||
for (int i = 0; i <= 2; i++)
|
||||
setPatternWaitAddress(i, MAX_PATTERN_LENGTH - 1);
|
||||
@ -723,6 +724,7 @@ int setTrimbits(int *trimbits) {
|
||||
for (ichan = 0; ichan < NCHAN; ++ichan) {
|
||||
detectorChans[ichan] = trimbits[ichan];
|
||||
}
|
||||
trimming = 0;
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -1204,6 +1206,8 @@ uint64_t readPatternWord(int addr) {
|
||||
}
|
||||
|
||||
uint64_t writePatternWord(int addr, uint64_t word) {
|
||||
|
||||
if (!trimming) {
|
||||
// get
|
||||
if ((int64_t)word == -1)
|
||||
return readPatternWord(addr);
|
||||
@ -1215,32 +1219,38 @@ uint64_t writePatternWord(int addr, uint64_t word) {
|
||||
addr, MAX_PATTERN_LENGTH));
|
||||
return -1;
|
||||
}
|
||||
|
||||
LOG(logINFO, ("Setting Pattern Word (addr:0x%x, word:0x%llx)\n", addr,
|
||||
(long long int)word));
|
||||
}
|
||||
|
||||
// write word
|
||||
uint32_t reg_lsb =
|
||||
PATTERN_STEP0_LSB_REG +
|
||||
addr * REG_OFFSET * 2; // the first word in RAM as base plus the offset
|
||||
// of the word to write (addr)
|
||||
uint32_t reg_msb = PATTERN_STEP0_MSB_REG + addr * REG_OFFSET * 2;
|
||||
|
||||
// write word
|
||||
set64BitReg(word, reg_lsb, reg_msb);
|
||||
|
||||
if (!trimming) {
|
||||
LOG(logDEBUG1, (" Wrote word. PatternIn Reg: 0x%llx\n",
|
||||
get64BitReg(reg_lsb, reg_msb)));
|
||||
|
||||
return readPatternWord(addr);
|
||||
} else {
|
||||
return word;
|
||||
}
|
||||
}
|
||||
|
||||
int setPatternWaitAddress(int level, int addr) {
|
||||
|
||||
if (!trimming) {
|
||||
// error (handled in tcp)
|
||||
if (addr >= MAX_PATTERN_LENGTH) {
|
||||
LOG(logERROR, ("Cannot set Pattern Wait Address. Invalid addr 0x%x. "
|
||||
LOG(logERROR,
|
||||
("Cannot set Pattern Wait Address. Invalid addr 0x%x. "
|
||||
"Should be between 0 and 0x%x\n",
|
||||
addr, MAX_PATTERN_LENGTH));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t reg = 0;
|
||||
uint32_t offset = 0;
|
||||
@ -1271,16 +1281,23 @@ int setPatternWaitAddress(int level, int addr) {
|
||||
|
||||
// set
|
||||
if (addr >= 0) {
|
||||
LOG(logINFO, ("Setting Pattern Wait Address (level:%d, addr:0x%x)\n",
|
||||
level, addr));
|
||||
if (!trimming) {
|
||||
LOG(logINFO,
|
||||
("Setting Pattern Wait Address (level:%d, addr:0x%x)\n", level,
|
||||
addr));
|
||||
}
|
||||
bus_w(reg, ((addr << offset) & mask));
|
||||
}
|
||||
|
||||
// get
|
||||
if (!trimming) {
|
||||
uint32_t regval = ((bus_r(reg) & mask) >> offset);
|
||||
LOG(logDEBUG1,
|
||||
(" Wait Address retval (level:%d, addr:0x%x)\n", level, regval));
|
||||
return regval;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t setPatternWaitTime(int level, uint64_t t) {
|
||||
@ -1323,8 +1340,10 @@ uint64_t setPatternWaitTime(int level, uint64_t t) {
|
||||
|
||||
void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop) {
|
||||
|
||||
if (!trimming) {
|
||||
// (checked at tcp)
|
||||
if (*startAddr >= MAX_PATTERN_LENGTH || *stopAddr >= MAX_PATTERN_LENGTH) {
|
||||
if (*startAddr >= MAX_PATTERN_LENGTH ||
|
||||
*stopAddr >= MAX_PATTERN_LENGTH) {
|
||||
LOG(logERROR, ("Cannot set Pattern Loop, Address (startaddr:0x%x, "
|
||||
"stopaddr:0x%x) must be "
|
||||
"less than 0x%x\n",
|
||||
@ -1334,6 +1353,7 @@ void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop) {
|
||||
*nLoop = -1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t addr = 0;
|
||||
uint32_t nLoopReg = 0;
|
||||
@ -1390,8 +1410,10 @@ void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop) {
|
||||
if (level >= 0) {
|
||||
// set iteration
|
||||
if (*nLoop >= 0) {
|
||||
LOG(logINFO,
|
||||
("Setting Pattern Loop (level:%d, nLoop:%d)\n", level, *nLoop));
|
||||
if (!trimming) {
|
||||
LOG(logINFO, ("Setting Pattern Loop (level:%d, nLoop:%d)\n",
|
||||
level, *nLoop));
|
||||
}
|
||||
bus_w(nLoopReg, *nLoop);
|
||||
}
|
||||
*nLoop = bus_r(nLoopReg);
|
||||
@ -1400,12 +1422,13 @@ void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop) {
|
||||
// set
|
||||
if (*startAddr >= 0 && *stopAddr >= 0) {
|
||||
// writing start and stop addr
|
||||
LOG(logINFO,
|
||||
("Setting Pattern Loop (level:%d, startaddr:0x%x, stopaddr:0x%x)\n",
|
||||
if (!trimming) {
|
||||
LOG(logINFO, ("Setting Pattern Loop (level:%d, startaddr:0x%x, "
|
||||
"stopaddr:0x%x)\n",
|
||||
level, *startAddr, *stopAddr));
|
||||
}
|
||||
bus_w(addr, ((*startAddr << startOffset) & startMask) |
|
||||
((*stopAddr << stopOffset) & stopMask));
|
||||
LOG(logDEBUG1, ("Addr:0x%x, val:0x%x\n", addr, bus_r(addr)));
|
||||
}
|
||||
|
||||
// get
|
||||
|
Loading…
x
Reference in New Issue
Block a user