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