mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 18:17:59 +02:00
merge from developer
This commit is contained in:
@ -11,8 +11,7 @@ add_executable(mythen3DetectorServer_virtual
|
||||
../slsDetectorServer/src/LTC2620_Driver.c
|
||||
../slsDetectorServer/src/ALTERA_PLL_CYCLONE10.c
|
||||
../slsDetectorServer/src/programFpgaNios.c
|
||||
../slsDetectorServer/src/readDefaultPattern.c
|
||||
../slsDetectorServer/src/loadPattern.c
|
||||
../slsDetectorServer/src/loadPattern.c
|
||||
../slsDetectorServer/src/sharedMemory.c
|
||||
)
|
||||
|
||||
|
@ -13,7 +13,7 @@ DESTDIR ?= bin
|
||||
INSTMODE = 0777
|
||||
|
||||
SRCS = slsDetectorFunctionList.c
|
||||
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)nios.c $(main_src)DAC6571.c $(main_src)common.c $(main_src)LTC2620_Driver.c $(main_src)ALTERA_PLL_CYCLONE10.c $(main_src)/programFpgaNios.c $(main_src)readDefaultPattern.c $(main_src)/sharedMemory.c $(main_src)/loadPattern.c mythen3.c
|
||||
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)nios.c $(main_src)DAC6571.c $(main_src)common.c $(main_src)LTC2620_Driver.c $(main_src)ALTERA_PLL_CYCLONE10.c $(main_src)/programFpgaNios.c $(main_src)/sharedMemory.c $(main_src)/loadPattern.c mythen3.c
|
||||
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
#include "mythen3.h"
|
||||
#include "clogger.h"
|
||||
#include "common.h"
|
||||
#include "mythen3.h"
|
||||
#include "sls/ansi.h"
|
||||
#include "sls/sls_detector_defs.h"
|
||||
#include "slsDetectorServer_defs.h"
|
||||
@ -22,353 +22,343 @@ typedef struct __attribute__((packed)) {
|
||||
} patternParameters;
|
||||
*/
|
||||
|
||||
int chipStatusRegister=0;
|
||||
int chipStatusRegister = 0;
|
||||
|
||||
int setBit(int ibit, int patword) { return patword |= (1 << ibit); }
|
||||
|
||||
int clearBit(int ibit, int patword) { return patword &= ~(1 << ibit); }
|
||||
|
||||
extern enum TLogLevel trimmingPrint ;
|
||||
int getChipStatusRegister() { return chipStatusRegister; }
|
||||
|
||||
int gainCapsToCsr(int caps) {
|
||||
// Translates bit representation
|
||||
int csr = 0;
|
||||
if (!(caps & M3_C10pre))
|
||||
csr |= 1 << _CSR_C10pre;
|
||||
if (caps & M3_C15sh)
|
||||
csr |= 1 << CSR_C15sh;
|
||||
if (caps & M3_C30sh)
|
||||
csr |= 1 << CSR_C30sh;
|
||||
if (caps & M3_C50sh)
|
||||
csr |= 1 << CSR_C50sh;
|
||||
if (caps & M3_C225ACsh)
|
||||
csr |= 1 << CSR_C225ACsh;
|
||||
if (!(caps & M3_C15pre))
|
||||
csr |= 1 << _CSR_C15pre;
|
||||
|
||||
int getChipStatusRegister(){
|
||||
return chipStatusRegister;
|
||||
return csr;
|
||||
}
|
||||
|
||||
int gainCapsToCsr(int caps){
|
||||
//Translates bit representation
|
||||
int csr = 0;
|
||||
if (!(caps & M3_C10pre))
|
||||
csr |= 1 << _CSR_C10pre;
|
||||
if (caps & M3_C15sh)
|
||||
csr |= 1 << CSR_C15sh;
|
||||
if (caps & M3_C30sh)
|
||||
csr |= 1 << CSR_C30sh;
|
||||
if (caps & M3_C50sh)
|
||||
csr |= 1 << CSR_C50sh;
|
||||
if (caps & M3_C225ACsh)
|
||||
csr |= 1 << CSR_C225ACsh;
|
||||
if (!(caps & M3_C15pre))
|
||||
csr |= 1 << _CSR_C15pre;
|
||||
int csrToGainCaps(int csr) {
|
||||
// Translates bit representation
|
||||
int caps = 0;
|
||||
if (!(csr & (1 << _CSR_C10pre)))
|
||||
caps |= M3_C10pre;
|
||||
if (csr & (1 << CSR_C15sh))
|
||||
caps |= M3_C15sh;
|
||||
if (csr & (1 << CSR_C30sh))
|
||||
caps |= M3_C30sh;
|
||||
if (csr & (1 << CSR_C50sh))
|
||||
caps |= M3_C50sh;
|
||||
if (csr & (1 << CSR_C225ACsh))
|
||||
caps |= M3_C225ACsh;
|
||||
if (!(csr & (1 << _CSR_C15pre)))
|
||||
caps |= M3_C15pre;
|
||||
|
||||
return csr;
|
||||
}
|
||||
|
||||
int csrToGainCaps(int csr){
|
||||
//Translates bit representation
|
||||
int caps = 0;
|
||||
if (!(csr & (1 << _CSR_C10pre)))
|
||||
caps |= M3_C10pre;
|
||||
if (csr & (1 << CSR_C15sh))
|
||||
caps |= M3_C15sh;
|
||||
if (csr & (1 << CSR_C30sh))
|
||||
caps |= M3_C30sh;
|
||||
if (csr & (1 << CSR_C50sh))
|
||||
caps |= M3_C50sh;
|
||||
if (csr & (1 << CSR_C225ACsh))
|
||||
caps |= M3_C225ACsh;
|
||||
if (!(csr & (1 << _CSR_C15pre)))
|
||||
caps |= M3_C15pre;
|
||||
|
||||
return caps;
|
||||
return caps;
|
||||
}
|
||||
|
||||
patternParameters *setChipStatusRegisterPattern(int csr) {
|
||||
int iaddr=0;
|
||||
int nbits=18;
|
||||
int error=0;
|
||||
//int start=0, stop=MAX_PATTERN_LENGTH, loop=0;
|
||||
int patword=0;
|
||||
|
||||
patternParameters *pat = malloc(sizeof(patternParameters));
|
||||
memset(pat, 0, sizeof(patternParameters));
|
||||
|
||||
patword=setBit(SIGNAL_STATLOAD,patword);
|
||||
for (int i=0; i<2; i++)
|
||||
pat->word[iaddr++]=patword;
|
||||
patword=setBit(SIGNAL_resStorage,patword);
|
||||
patword=setBit(SIGNAL_resCounter,patword);
|
||||
for (int i=0; i<8; i++)
|
||||
pat->word[iaddr++]=patword;
|
||||
patword=clearBit(SIGNAL_resStorage,patword);
|
||||
patword=clearBit(SIGNAL_resCounter,patword);
|
||||
for (int i=0; i<8; i++)
|
||||
pat->word[iaddr++]=patword;
|
||||
//#This version of the serializer pushes in the MSB first (compatible with the CSR bit numbering)
|
||||
for (int ib=nbits-1; ib>=0; ib--) {
|
||||
if (csr&(1<<ib))
|
||||
patword=setBit(SIGNAL_serialIN,patword);
|
||||
else
|
||||
patword=clearBit(SIGNAL_serialIN,patword);
|
||||
for (int i=0; i<4; i++)
|
||||
pat->word[iaddr++]=patword;
|
||||
patword=setBit(SIGNAL_CHSclk,patword);
|
||||
pat->word[iaddr++]=patword;
|
||||
patword=clearBit(SIGNAL_CHSclk,patword);
|
||||
pat->word[iaddr++]=patword;
|
||||
}
|
||||
int iaddr = 0;
|
||||
int nbits = 18;
|
||||
int error = 0;
|
||||
// int start=0, stop=MAX_PATTERN_LENGTH, loop=0;
|
||||
int patword = 0;
|
||||
|
||||
patword=clearBit(SIGNAL_serialIN,patword);
|
||||
for (int i=0; i<2; i++)
|
||||
pat->word[iaddr++]=patword;
|
||||
patword=setBit(SIGNAL_STO,patword);
|
||||
for (int i=0; i<5; i++)
|
||||
pat->word[iaddr++]=patword;
|
||||
patword=clearBit(SIGNAL_STO,patword);
|
||||
for (int i=0; i<5; i++)
|
||||
pat->word[iaddr++]=patword;
|
||||
patword=clearBit(SIGNAL_STATLOAD,patword);
|
||||
for (int i=0; i<5; i++)
|
||||
pat->word[iaddr++]=patword;
|
||||
patternParameters *pat = malloc(sizeof(patternParameters));
|
||||
memset(pat, 0, sizeof(patternParameters));
|
||||
|
||||
if (iaddr >= MAX_PATTERN_LENGTH) {
|
||||
LOG(logERROR, ("Addr 0x%x is past max_address_length 0x%x!\n",
|
||||
iaddr, MAX_PATTERN_LENGTH));
|
||||
error = 1;
|
||||
}
|
||||
// set pattern wait address
|
||||
for (int i = 0; i <= 2; i++)
|
||||
pat->wait[i]=MAX_PATTERN_LENGTH - 1;
|
||||
// pattern loop
|
||||
for (int i = 0; i <= 2; i++) {
|
||||
//int stop = MAX_PATTERN_LENGTH - 1, nloop = 0;
|
||||
pat->loop[i * 2 + 0]=MAX_PATTERN_LENGTH - 1;
|
||||
pat->loop[i * 2 + 1]=MAX_PATTERN_LENGTH - 1;
|
||||
pat->nloop[i]=0;
|
||||
}
|
||||
|
||||
// pattern limits
|
||||
{
|
||||
pat->limits[0]=0;
|
||||
pat->limits[1]=iaddr;
|
||||
}
|
||||
|
||||
if (error != 0) {
|
||||
free(pat);
|
||||
return NULL;
|
||||
}
|
||||
chipStatusRegister=csr;
|
||||
return pat;
|
||||
patword = setBit(SIGNAL_STATLOAD, patword);
|
||||
for (int i = 0; i < 2; i++)
|
||||
pat->word[iaddr++] = patword;
|
||||
patword = setBit(SIGNAL_resStorage, patword);
|
||||
patword = setBit(SIGNAL_resCounter, patword);
|
||||
for (int i = 0; i < 8; i++)
|
||||
pat->word[iaddr++] = patword;
|
||||
patword = clearBit(SIGNAL_resStorage, patword);
|
||||
patword = clearBit(SIGNAL_resCounter, patword);
|
||||
for (int i = 0; i < 8; i++)
|
||||
pat->word[iaddr++] = patword;
|
||||
//#This version of the serializer pushes in the MSB first (compatible with
|
||||
//the CSR bit numbering)
|
||||
for (int ib = nbits - 1; ib >= 0; ib--) {
|
||||
if (csr & (1 << ib))
|
||||
patword = setBit(SIGNAL_serialIN, patword);
|
||||
else
|
||||
patword = clearBit(SIGNAL_serialIN, patword);
|
||||
for (int i = 0; i < 4; i++)
|
||||
pat->word[iaddr++] = patword;
|
||||
patword = setBit(SIGNAL_CHSclk, patword);
|
||||
pat->word[iaddr++] = patword;
|
||||
patword = clearBit(SIGNAL_CHSclk, patword);
|
||||
pat->word[iaddr++] = patword;
|
||||
}
|
||||
|
||||
patword = clearBit(SIGNAL_serialIN, patword);
|
||||
for (int i = 0; i < 2; i++)
|
||||
pat->word[iaddr++] = patword;
|
||||
patword = setBit(SIGNAL_STO, patword);
|
||||
for (int i = 0; i < 5; i++)
|
||||
pat->word[iaddr++] = patword;
|
||||
patword = clearBit(SIGNAL_STO, patword);
|
||||
for (int i = 0; i < 5; i++)
|
||||
pat->word[iaddr++] = patword;
|
||||
patword = clearBit(SIGNAL_STATLOAD, patword);
|
||||
for (int i = 0; i < 5; i++)
|
||||
pat->word[iaddr++] = patword;
|
||||
|
||||
if (iaddr >= MAX_PATTERN_LENGTH) {
|
||||
LOG(logERROR, ("Addr 0x%x is past max_address_length 0x%x!\n", iaddr,
|
||||
MAX_PATTERN_LENGTH));
|
||||
error = 1;
|
||||
}
|
||||
// set pattern wait address
|
||||
for (int i = 0; i <= 2; i++)
|
||||
pat->wait[i] = MAX_PATTERN_LENGTH - 1;
|
||||
// pattern loop
|
||||
for (int i = 0; i <= 2; i++) {
|
||||
// int stop = MAX_PATTERN_LENGTH - 1, nloop = 0;
|
||||
pat->loop[i * 2 + 0] = MAX_PATTERN_LENGTH - 1;
|
||||
pat->loop[i * 2 + 1] = MAX_PATTERN_LENGTH - 1;
|
||||
pat->nloop[i] = 0;
|
||||
}
|
||||
|
||||
// pattern limits
|
||||
{
|
||||
pat->limits[0] = 0;
|
||||
pat->limits[1] = iaddr;
|
||||
}
|
||||
|
||||
if (error != 0) {
|
||||
free(pat);
|
||||
return NULL;
|
||||
}
|
||||
chipStatusRegister = csr;
|
||||
return pat;
|
||||
}
|
||||
|
||||
patternParameters *setInterpolation(int mask) {
|
||||
int csr;
|
||||
if (mask)
|
||||
csr=chipStatusRegister|(1<< CSR_interp);
|
||||
else
|
||||
csr=chipStatusRegister & ~(1<< CSR_interp);
|
||||
int csr;
|
||||
if (mask)
|
||||
csr = chipStatusRegister | (1 << CSR_interp);
|
||||
else
|
||||
csr = chipStatusRegister & ~(1 << CSR_interp);
|
||||
|
||||
return setChipStatusRegisterPattern(csr);
|
||||
return setChipStatusRegisterPattern(csr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
patternParameters *setPumpProbe(int mask) {
|
||||
int csr;
|
||||
if (mask)
|
||||
csr=chipStatusRegister|(1<< CSR_pumprobe);
|
||||
else
|
||||
csr=chipStatusRegister & ~(1<< CSR_pumprobe);
|
||||
|
||||
return setChipStatusRegisterPattern(csr);
|
||||
int csr;
|
||||
if (mask)
|
||||
csr = chipStatusRegister | (1 << CSR_pumprobe);
|
||||
else
|
||||
csr = chipStatusRegister & ~(1 << CSR_pumprobe);
|
||||
|
||||
return setChipStatusRegisterPattern(csr);
|
||||
}
|
||||
patternParameters *setDigitalPulsing(int mask) {
|
||||
|
||||
int csr;
|
||||
if (mask)
|
||||
csr=chipStatusRegister|(1<< CSR_dpulse);
|
||||
else
|
||||
csr=chipStatusRegister & ~(1<< CSR_dpulse);
|
||||
int csr;
|
||||
if (mask)
|
||||
csr = chipStatusRegister | (1 << CSR_dpulse);
|
||||
else
|
||||
csr = chipStatusRegister & ~(1 << CSR_dpulse);
|
||||
|
||||
return setChipStatusRegisterPattern(csr);
|
||||
|
||||
return setChipStatusRegisterPattern(csr);
|
||||
}
|
||||
patternParameters *setAnalogPulsing(int mask){
|
||||
patternParameters *setAnalogPulsing(int mask) {
|
||||
|
||||
int csr;
|
||||
if (mask)
|
||||
csr=chipStatusRegister|(1<< CSR_apulse);
|
||||
else
|
||||
csr=chipStatusRegister & ~(1<< CSR_apulse);
|
||||
int csr;
|
||||
if (mask)
|
||||
csr = chipStatusRegister | (1 << CSR_apulse);
|
||||
else
|
||||
csr = chipStatusRegister & ~(1 << CSR_apulse);
|
||||
|
||||
return setChipStatusRegisterPattern(csr);
|
||||
|
||||
return setChipStatusRegisterPattern(csr);
|
||||
}
|
||||
patternParameters *setNegativePolarity(int mask){
|
||||
patternParameters *setNegativePolarity(int mask) {
|
||||
|
||||
int csr;
|
||||
if (mask)
|
||||
csr=chipStatusRegister|(1<< CSR_invpol);
|
||||
else
|
||||
csr=chipStatusRegister & ~(1<< CSR_invpol);
|
||||
int csr;
|
||||
if (mask)
|
||||
csr = chipStatusRegister | (1 << CSR_invpol);
|
||||
else
|
||||
csr = chipStatusRegister & ~(1 << CSR_invpol);
|
||||
|
||||
return setChipStatusRegisterPattern(csr);
|
||||
|
||||
return setChipStatusRegisterPattern(csr);
|
||||
}
|
||||
|
||||
patternParameters *setChannelRegisterChip(int ichip, int *mask, int *trimbits) {
|
||||
|
||||
patternParameters *pat = malloc(sizeof(patternParameters));
|
||||
memset(pat, 0, sizeof(patternParameters));
|
||||
|
||||
patternParameters *pat = malloc(sizeof(patternParameters));
|
||||
memset(pat, 0, sizeof(patternParameters));
|
||||
|
||||
// validate
|
||||
for (int ichan = ichip * NCHAN_1_COUNTER * NCOUNTERS; ichan < ichip * NCHAN_1_COUNTER * NCOUNTERS+NCHAN_1_COUNTER*NCOUNTERS; ichan++) {
|
||||
if (trimbits[ichan]<0) {
|
||||
LOG(logERROR, ("Trimbit value (%d) for channel %d is invalid - setting it to 0\n",
|
||||
trimbits[ichan], ichan));
|
||||
trimbits[ichan]=0;
|
||||
for (int ichan = ichip * NCHAN_1_COUNTER * NCOUNTERS;
|
||||
ichan <
|
||||
ichip * NCHAN_1_COUNTER * NCOUNTERS + NCHAN_1_COUNTER * NCOUNTERS;
|
||||
ichan++) {
|
||||
if (trimbits[ichan] < 0) {
|
||||
LOG(logERROR, ("Trimbit value (%d) for channel %d is invalid - "
|
||||
"setting it to 0\n",
|
||||
trimbits[ichan], ichan));
|
||||
trimbits[ichan] = 0;
|
||||
}
|
||||
if (trimbits[ichan] > 63) {
|
||||
LOG(logERROR, ("Trimbit value (%d) for channel %d is invalid - "
|
||||
"settings it to 63\n",
|
||||
trimbits[ichan], ichan));
|
||||
trimbits[ichan] = 63;
|
||||
}
|
||||
}
|
||||
if (trimbits[ichan] > 63) {
|
||||
LOG(logERROR, ("Trimbit value (%d) for channel %d is invalid - settings it to 63\n",
|
||||
trimbits[ichan], ichan));
|
||||
trimbits[ichan]=63;
|
||||
}
|
||||
}
|
||||
LOG(logINFO, ("Trimbits validated\n"));
|
||||
trimmingPrint = logDEBUG5;
|
||||
LOG(logINFO, ("Trimbits validated\n"));
|
||||
|
||||
|
||||
// trimming
|
||||
int error = 0;
|
||||
uint64_t patword = 0;
|
||||
int iaddr = 0;
|
||||
|
||||
LOG(logDEBUG1, (" Chip %d\n", ichip));
|
||||
iaddr = 0;
|
||||
patword = 0;
|
||||
pat->word[iaddr++]=patword;
|
||||
|
||||
// chip select
|
||||
patword = setBit(SIGNAL_TBLoad_1 + ichip, patword);
|
||||
pat->word[iaddr++]=patword;
|
||||
|
||||
// reset trimbits
|
||||
patword = setBit(SIGNAL_resStorage, patword);
|
||||
patword = setBit(SIGNAL_resCounter, patword);
|
||||
pat->word[iaddr++]=patword;
|
||||
pat->word[iaddr++]=patword;
|
||||
patword = clearBit(SIGNAL_resStorage, patword);
|
||||
patword = clearBit(SIGNAL_resCounter, patword);
|
||||
pat->word[iaddr++]=patword;
|
||||
pat->word[iaddr++]=patword;
|
||||
|
||||
// select first channel
|
||||
patword = setBit(SIGNAL_CHSserialIN, patword);
|
||||
pat->word[iaddr++]=patword;
|
||||
// 1 clk pulse
|
||||
patword = setBit(SIGNAL_CHSclk, patword);
|
||||
pat->word[iaddr++]=patword;
|
||||
patword = clearBit(SIGNAL_CHSclk, patword);
|
||||
// clear 1st channel
|
||||
pat->word[iaddr++]=patword;
|
||||
patword = clearBit(SIGNAL_CHSserialIN, patword);
|
||||
// 2 clk pulses
|
||||
for (int i = 0; i < 2; i++) {
|
||||
// trimming
|
||||
int error = 0;
|
||||
uint64_t patword = 0;
|
||||
int iaddr = 0;
|
||||
|
||||
LOG(logDEBUG1, (" Chip %d\n", ichip));
|
||||
iaddr = 0;
|
||||
patword = 0;
|
||||
pat->word[iaddr++] = patword;
|
||||
|
||||
// chip select
|
||||
patword = setBit(SIGNAL_TBLoad_1 + ichip, patword);
|
||||
pat->word[iaddr++] = patword;
|
||||
|
||||
// reset trimbits
|
||||
patword = setBit(SIGNAL_resStorage, patword);
|
||||
patword = setBit(SIGNAL_resCounter, patword);
|
||||
pat->word[iaddr++] = patword;
|
||||
pat->word[iaddr++] = patword;
|
||||
patword = clearBit(SIGNAL_resStorage, patword);
|
||||
patword = clearBit(SIGNAL_resCounter, patword);
|
||||
pat->word[iaddr++] = patword;
|
||||
pat->word[iaddr++] = patword;
|
||||
|
||||
// select first channel
|
||||
patword = setBit(SIGNAL_CHSserialIN, patword);
|
||||
pat->word[iaddr++] = patword;
|
||||
// 1 clk pulse
|
||||
patword = setBit(SIGNAL_CHSclk, patword);
|
||||
pat->word[iaddr++]=patword;
|
||||
pat->word[iaddr++] = patword;
|
||||
patword = clearBit(SIGNAL_CHSclk, patword);
|
||||
pat->word[iaddr++]=patword;
|
||||
}
|
||||
|
||||
// for each channel (all chips)
|
||||
for (int ich = 0; ich < NCHAN_1_COUNTER; ich++) {
|
||||
LOG(logDEBUG1, (" Chip %d, Channel %d\n", ichip, ich));
|
||||
int val = trimbits[ichip * NCHAN_1_COUNTER * NCOUNTERS +
|
||||
NCOUNTERS * ich] +
|
||||
trimbits[ichip * NCHAN_1_COUNTER * NCOUNTERS +
|
||||
NCOUNTERS * ich + 1] *
|
||||
64 +
|
||||
trimbits[ichip * NCHAN_1_COUNTER * NCOUNTERS +
|
||||
NCOUNTERS * ich + 2] *
|
||||
64 * 64;
|
||||
|
||||
// push 6 0 bits
|
||||
for (int i = 0; i < 3; i++) {
|
||||
patword = clearBit(SIGNAL_serialIN, patword);
|
||||
patword = clearBit(SIGNAL_clk, patword);
|
||||
pat->word[iaddr++]=patword;
|
||||
patword = setBit(SIGNAL_clk, patword);
|
||||
pat->word[iaddr++]=patword;
|
||||
// clear 1st channel
|
||||
pat->word[iaddr++] = patword;
|
||||
patword = clearBit(SIGNAL_CHSserialIN, patword);
|
||||
// 2 clk pulses
|
||||
for (int i = 0; i < 2; i++) {
|
||||
patword = setBit(SIGNAL_CHSclk, patword);
|
||||
pat->word[iaddr++] = patword;
|
||||
patword = clearBit(SIGNAL_CHSclk, patword);
|
||||
pat->word[iaddr++] = patword;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (mask[i])
|
||||
patword = setBit(SIGNAL_serialIN, patword);
|
||||
else
|
||||
patword = clearBit(SIGNAL_serialIN, patword);
|
||||
patword = clearBit(SIGNAL_clk, patword);
|
||||
pat->word[iaddr++]=patword;
|
||||
patword = setBit(SIGNAL_clk, patword);
|
||||
pat->word[iaddr++]=patword;
|
||||
|
||||
// for each channel (all chips)
|
||||
for (int ich = 0; ich < NCHAN_1_COUNTER; ich++) {
|
||||
LOG(logDEBUG1, (" Chip %d, Channel %d\n", ichip, ich));
|
||||
int val =
|
||||
trimbits[ichip * NCHAN_1_COUNTER * NCOUNTERS + NCOUNTERS * ich] +
|
||||
trimbits[ichip * NCHAN_1_COUNTER * NCOUNTERS + NCOUNTERS * ich +
|
||||
1] *
|
||||
64 +
|
||||
trimbits[ichip * NCHAN_1_COUNTER * NCOUNTERS + NCOUNTERS * ich +
|
||||
2] *
|
||||
64 * 64;
|
||||
|
||||
// push 6 0 bits
|
||||
for (int i = 0; i < 3; i++) {
|
||||
patword = clearBit(SIGNAL_serialIN, patword);
|
||||
patword = clearBit(SIGNAL_clk, patword);
|
||||
pat->word[iaddr++] = patword;
|
||||
patword = setBit(SIGNAL_clk, patword);
|
||||
pat->word[iaddr++] = patword;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (mask[i])
|
||||
patword = setBit(SIGNAL_serialIN, patword);
|
||||
else
|
||||
patword = clearBit(SIGNAL_serialIN, patword);
|
||||
patword = clearBit(SIGNAL_clk, patword);
|
||||
pat->word[iaddr++] = patword;
|
||||
patword = setBit(SIGNAL_clk, patword);
|
||||
pat->word[iaddr++] = patword;
|
||||
}
|
||||
|
||||
// deserialize
|
||||
for (int i = 0; i < 18; i++) {
|
||||
if (val & (1 << i)) {
|
||||
patword = setBit(SIGNAL_serialIN, patword);
|
||||
} else {
|
||||
patword = clearBit(SIGNAL_serialIN, patword);
|
||||
}
|
||||
patword = clearBit(SIGNAL_clk, patword);
|
||||
pat->word[iaddr++] = patword;
|
||||
|
||||
patword = setBit(SIGNAL_clk, patword);
|
||||
pat->word[iaddr++] = patword;
|
||||
}
|
||||
pat->word[iaddr++] = patword;
|
||||
pat->word[iaddr++] = patword;
|
||||
|
||||
// move to next channel
|
||||
for (int i = 0; i < 3; i++) {
|
||||
patword = setBit(SIGNAL_CHSclk, patword);
|
||||
pat->word[iaddr++] = patword;
|
||||
patword = clearBit(SIGNAL_CHSclk, patword);
|
||||
pat->word[iaddr++] = patword;
|
||||
}
|
||||
}
|
||||
|
||||
// deserialize
|
||||
for (int i = 0; i < 18; i++) {
|
||||
if (val & (1 << i)) {
|
||||
patword = setBit(SIGNAL_serialIN, patword);
|
||||
} else {
|
||||
patword = clearBit(SIGNAL_serialIN, patword);
|
||||
}
|
||||
patword = clearBit(SIGNAL_clk, patword);
|
||||
pat->word[iaddr++]=patword;
|
||||
|
||||
patword = setBit(SIGNAL_clk, patword);
|
||||
pat->word[iaddr++]=patword;
|
||||
// chip unselect
|
||||
patword = clearBit(SIGNAL_TBLoad_1 + ichip, patword);
|
||||
pat->word[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));
|
||||
error = 1;
|
||||
}
|
||||
pat->word[iaddr++]=patword;
|
||||
pat->word[iaddr++]=patword;
|
||||
|
||||
// move to next channel
|
||||
for (int i = 0; i < 3; i++) {
|
||||
patword = setBit(SIGNAL_CHSclk, patword);
|
||||
pat->word[iaddr++]=patword;
|
||||
patword = clearBit(SIGNAL_CHSclk, patword);
|
||||
pat->word[iaddr++]=patword;
|
||||
|
||||
if (iaddr >= MAX_PATTERN_LENGTH) {
|
||||
LOG(logERROR, ("Addr 0x%x is past max_address_length 0x%x!\n", iaddr,
|
||||
MAX_PATTERN_LENGTH));
|
||||
error = 1;
|
||||
}
|
||||
}
|
||||
// chip unselect
|
||||
patword = clearBit(SIGNAL_TBLoad_1 + ichip, patword);
|
||||
pat->word[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));
|
||||
error = 1;
|
||||
}
|
||||
|
||||
if (iaddr >= MAX_PATTERN_LENGTH) {
|
||||
LOG(logERROR, ("Addr 0x%x is past max_address_length 0x%x!\n",
|
||||
iaddr, MAX_PATTERN_LENGTH));
|
||||
error = 1;
|
||||
}
|
||||
// set pattern wait address
|
||||
for (int i = 0; i <= 2; i++)
|
||||
pat->wait[i]=MAX_PATTERN_LENGTH - 1;
|
||||
// pattern loop
|
||||
for (int i = 0; i <= 2; i++) {
|
||||
//int stop = MAX_PATTERN_LENGTH - 1, nloop = 0;
|
||||
pat->loop[i * 2 + 0]=MAX_PATTERN_LENGTH - 1;
|
||||
pat->loop[i * 2 + 1]=MAX_PATTERN_LENGTH - 1;
|
||||
pat->nloop[i]=0;
|
||||
}
|
||||
|
||||
// pattern limits
|
||||
{
|
||||
pat->limits[0]=0;
|
||||
pat->limits[1]=iaddr;
|
||||
}
|
||||
|
||||
trimmingPrint = logINFO;
|
||||
if (error == 0) {
|
||||
|
||||
LOG(logINFO, ("All trimbits have been loaded\n"));
|
||||
} else {
|
||||
free(pat);
|
||||
return NULL;
|
||||
}
|
||||
return pat;
|
||||
// set pattern wait address
|
||||
for (int i = 0; i <= 2; i++)
|
||||
pat->wait[i] = MAX_PATTERN_LENGTH - 1;
|
||||
// pattern loop
|
||||
for (int i = 0; i <= 2; i++) {
|
||||
// int stop = MAX_PATTERN_LENGTH - 1, nloop = 0;
|
||||
pat->loop[i * 2 + 0] = MAX_PATTERN_LENGTH - 1;
|
||||
pat->loop[i * 2 + 1] = MAX_PATTERN_LENGTH - 1;
|
||||
pat->nloop[i] = 0;
|
||||
}
|
||||
|
||||
// pattern limits
|
||||
{
|
||||
pat->limits[0] = 0;
|
||||
pat->limits[1] = iaddr;
|
||||
}
|
||||
|
||||
if (error == 0) {
|
||||
|
||||
LOG(logINFO, ("All trimbits have been loaded\n"));
|
||||
} else {
|
||||
free(pat);
|
||||
return NULL;
|
||||
}
|
||||
return pat;
|
||||
}
|
||||
|
@ -1118,48 +1118,50 @@ int setModule(sls_detector_module myMod, char *mess) {
|
||||
|
||||
int setTrimbits(int *trimbits) {
|
||||
LOG(logINFOBLUE, ("Setting trimbits\n"));
|
||||
|
||||
// remember previous run clock
|
||||
uint32_t prevRunClk = clkDivider[SYSTEM_C0];
|
||||
patternParameters *pat = NULL;
|
||||
int error = 0;
|
||||
|
||||
// set to trimming clock
|
||||
if (setClockDivider(SYSTEM_C0, DEFAULT_TRIMMING_RUN_CLKDIV) == FAIL) {
|
||||
LOG(logERROR,
|
||||
("Could not start trimming. Could not set to trimming clock\n"));
|
||||
return FAIL;
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////
|
||||
for (int ichip = 0; ichip < NCHIP; ichip++) {
|
||||
|
||||
pat = setChannelRegisterChip(ichip, channelMask,
|
||||
trimbits); // change here!!!
|
||||
if (pat) {
|
||||
error |= loadPattern(logDEBUG5, pat);
|
||||
if (error == 0)
|
||||
// for every chip
|
||||
int error = 0;
|
||||
char cmess[MAX_STR_LENGTH];
|
||||
for (int ichip = 0; ichip < NCHIP; ichip++) {
|
||||
patternParameters *pat = setChannelRegisterChip(
|
||||
ichip, channelMask,
|
||||
trimbits); // change here!!! @who: Change what?
|
||||
if (pat == NULL) {
|
||||
error = 1;
|
||||
} else {
|
||||
memset(cmess, 0, MAX_STR_LENGTH);
|
||||
error |= loadPattern(cmess, logDEBUG5, pat);
|
||||
if (!error)
|
||||
startPattern();
|
||||
free(pat);
|
||||
} else
|
||||
error = 1;
|
||||
}
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
// copy trimbits locally
|
||||
if (error == 0) {
|
||||
// copy trimbits locally
|
||||
for (int ichan = 0; ichan < ((detectorModules)->nchan); ++ichan) {
|
||||
detectorChans[ichan] = trimbits[ichan];
|
||||
}
|
||||
LOG(logINFO, ("All trimbits have been loaded\n"));
|
||||
}
|
||||
trimmingPrint = logINFO;
|
||||
|
||||
// set back to previous clock
|
||||
if (setClockDivider(SYSTEM_C0, prevRunClk) == FAIL) {
|
||||
LOG(logERROR, ("Could not set to previous run clock after trimming\n"));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (error != 0) {
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
return (error ? FAIL : OK);
|
||||
}
|
||||
|
||||
int setAllTrimbits(int val) {
|
||||
@ -1747,273 +1749,6 @@ int enableTenGigabitEthernet(int val) {
|
||||
return oneG ? 0 : 1;
|
||||
}
|
||||
|
||||
/* pattern */
|
||||
|
||||
void startPattern() {
|
||||
LOG(logINFOBLUE, ("Starting Pattern\n"));
|
||||
bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_STRT_PATTERN_MSK);
|
||||
usleep(1);
|
||||
while (bus_r(PAT_STATUS_REG) & PAT_STATUS_RUN_BUSY_MSK) {
|
||||
usleep(1);
|
||||
}
|
||||
LOG(logINFOBLUE, ("Pattern done\n"));
|
||||
}
|
||||
|
||||
uint64_t readPatternWord(int addr) {
|
||||
// error (handled in tcp)
|
||||
if (addr < 0 || addr >= MAX_PATTERN_LENGTH) {
|
||||
LOG(logERROR, ("Cannot get Pattern - Word. Invalid addr 0x%x. "
|
||||
"Should be between 0 and 0x%x\n",
|
||||
addr, MAX_PATTERN_LENGTH));
|
||||
return -1;
|
||||
}
|
||||
|
||||
LOG(logDEBUG1, (" Reading Pattern Word (addr:0x%x)\n", addr));
|
||||
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;
|
||||
|
||||
// read value
|
||||
uint64_t retval = get64BitReg(reg_lsb, reg_msb);
|
||||
LOG(logDEBUG1,
|
||||
(" Word(addr:0x%x) retval: 0x%llx\n", addr, (long long int)retval));
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
uint64_t writePatternWord(int addr, uint64_t word) {
|
||||
|
||||
// get
|
||||
if ((int64_t)word == -1)
|
||||
return readPatternWord(addr);
|
||||
|
||||
// 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(logDEBUG1, ("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;
|
||||
set64BitReg(word, reg_lsb, reg_msb);
|
||||
|
||||
LOG(logDEBUG1, (" Wrote word. PatternIn Reg: 0x%llx\n",
|
||||
get64BitReg(reg_lsb, reg_msb)));
|
||||
return readPatternWord(addr);
|
||||
}
|
||||
|
||||
int setPatternWaitAddress(int level, int addr) {
|
||||
// error (handled in tcp)
|
||||
if (addr >= MAX_PATTERN_LENGTH) {
|
||||
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;
|
||||
uint32_t mask = 0;
|
||||
|
||||
switch (level) {
|
||||
case 0:
|
||||
reg = PATTERN_WAIT_0_ADDR_REG;
|
||||
offset = PATTERN_WAIT_0_ADDR_OFST;
|
||||
mask = PATTERN_WAIT_0_ADDR_MSK;
|
||||
break;
|
||||
case 1:
|
||||
reg = PATTERN_WAIT_1_ADDR_REG;
|
||||
offset = PATTERN_WAIT_1_ADDR_OFST;
|
||||
mask = PATTERN_WAIT_1_ADDR_MSK;
|
||||
break;
|
||||
case 2:
|
||||
reg = PATTERN_WAIT_2_ADDR_REG;
|
||||
offset = PATTERN_WAIT_2_ADDR_OFST;
|
||||
mask = PATTERN_WAIT_2_ADDR_MSK;
|
||||
break;
|
||||
default:
|
||||
LOG(logERROR, ("Cannot set Pattern Wait Address. Invalid level 0x%x. "
|
||||
"Should be between 0 and 2.\n",
|
||||
level));
|
||||
return -1;
|
||||
}
|
||||
|
||||
// set
|
||||
if (addr >= 0) {
|
||||
LOG(trimmingPrint,
|
||||
("Setting Pattern Wait Address (level:%d, addr:0x%x)\n", level,
|
||||
addr));
|
||||
bus_w(reg, ((addr << offset) & mask));
|
||||
}
|
||||
|
||||
// get
|
||||
uint32_t regval = ((bus_r(reg) & mask) >> offset);
|
||||
LOG(logDEBUG1,
|
||||
(" Wait Address retval (level:%d, addr:0x%x)\n", level, regval));
|
||||
return regval;
|
||||
}
|
||||
|
||||
uint64_t setPatternWaitTime(int level, uint64_t t) {
|
||||
uint32_t regl = 0;
|
||||
uint32_t regm = 0;
|
||||
|
||||
switch (level) {
|
||||
case 0:
|
||||
regl = PATTERN_WAIT_TIMER_0_LSB_REG;
|
||||
regm = PATTERN_WAIT_TIMER_0_MSB_REG;
|
||||
break;
|
||||
case 1:
|
||||
regl = PATTERN_WAIT_TIMER_1_LSB_REG;
|
||||
regm = PATTERN_WAIT_TIMER_1_MSB_REG;
|
||||
break;
|
||||
case 2:
|
||||
regl = PATTERN_WAIT_TIMER_2_LSB_REG;
|
||||
regm = PATTERN_WAIT_TIMER_2_MSB_REG;
|
||||
break;
|
||||
default:
|
||||
LOG(logERROR, ("Cannot set Pattern Wait Time. Invalid level %d. "
|
||||
"Should be between 0 and 2.\n",
|
||||
level));
|
||||
return -1;
|
||||
}
|
||||
|
||||
// set
|
||||
if ((int64_t)t >= 0) {
|
||||
LOG(trimmingPrint, ("Setting Pattern Wait Time (level:%d, t:%lld)\n",
|
||||
level, (long long int)t));
|
||||
set64BitReg(t, regl, regm);
|
||||
}
|
||||
|
||||
// get
|
||||
uint64_t regval = get64BitReg(regl, regm);
|
||||
LOG(logDEBUG1, (" Wait Time retval (level:%d, t:%lld)\n", level,
|
||||
(long long int)regval));
|
||||
return regval;
|
||||
}
|
||||
|
||||
void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop) {
|
||||
|
||||
// (checked at tcp)
|
||||
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",
|
||||
*startAddr, *stopAddr, MAX_PATTERN_LENGTH));
|
||||
*startAddr = -1;
|
||||
*stopAddr = -1;
|
||||
*nLoop = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t addr = 0;
|
||||
uint32_t nLoopReg = 0;
|
||||
uint32_t startOffset = 0;
|
||||
uint32_t startMask = 0;
|
||||
uint32_t stopOffset = 0;
|
||||
uint32_t stopMask = 0;
|
||||
|
||||
switch (level) {
|
||||
case 0:
|
||||
addr = PATTERN_LOOP_0_ADDR_REG;
|
||||
nLoopReg = PATTERN_LOOP_0_ITERATION_REG;
|
||||
startOffset = PATTERN_LOOP_0_ADDR_STRT_OFST;
|
||||
startMask = PATTERN_LOOP_0_ADDR_STRT_MSK;
|
||||
stopOffset = PATTERN_LOOP_0_ADDR_STP_OFST;
|
||||
stopMask = PATTERN_LOOP_0_ADDR_STP_MSK;
|
||||
break;
|
||||
case 1:
|
||||
addr = PATTERN_LOOP_1_ADDR_REG;
|
||||
nLoopReg = PATTERN_LOOP_1_ITERATION_REG;
|
||||
startOffset = PATTERN_LOOP_1_ADDR_STRT_OFST;
|
||||
startMask = PATTERN_LOOP_1_ADDR_STRT_MSK;
|
||||
stopOffset = PATTERN_LOOP_1_ADDR_STP_OFST;
|
||||
stopMask = PATTERN_LOOP_1_ADDR_STP_MSK;
|
||||
break;
|
||||
case 2:
|
||||
addr = PATTERN_LOOP_2_ADDR_REG;
|
||||
nLoopReg = PATTERN_LOOP_2_ITERATION_REG;
|
||||
startOffset = PATTERN_LOOP_2_ADDR_STRT_OFST;
|
||||
startMask = PATTERN_LOOP_2_ADDR_STRT_MSK;
|
||||
stopOffset = PATTERN_LOOP_2_ADDR_STP_OFST;
|
||||
stopMask = PATTERN_LOOP_2_ADDR_STP_MSK;
|
||||
break;
|
||||
case -1:
|
||||
// complete pattern
|
||||
addr = PATTERN_LIMIT_REG;
|
||||
nLoopReg = -1;
|
||||
startOffset = PATTERN_LIMIT_STRT_OFST;
|
||||
startMask = PATTERN_LIMIT_STRT_MSK;
|
||||
stopOffset = PATTERN_LIMIT_STP_OFST;
|
||||
stopMask = PATTERN_LIMIT_STP_MSK;
|
||||
break;
|
||||
default:
|
||||
// already checked at tcp interface
|
||||
LOG(logERROR, ("Cannot set Pattern loop. Invalid level %d. "
|
||||
"Should be between -1 and 2.\n",
|
||||
level));
|
||||
*startAddr = 0;
|
||||
*stopAddr = 0;
|
||||
*nLoop = 0;
|
||||
}
|
||||
|
||||
// set iterations
|
||||
if (level >= 0) {
|
||||
// set iteration
|
||||
if (*nLoop >= 0) {
|
||||
LOG(trimmingPrint,
|
||||
("Setting Pattern Loop (level:%d, nLoop:%d)\n", level, *nLoop));
|
||||
bus_w(nLoopReg, *nLoop);
|
||||
}
|
||||
*nLoop = bus_r(nLoopReg);
|
||||
}
|
||||
|
||||
// set
|
||||
if (*startAddr >= 0 && *stopAddr >= 0) {
|
||||
// writing start and stop addr
|
||||
LOG(trimmingPrint, ("Setting Pattern Loop (level:%d, startaddr:0x%x, "
|
||||
"stopaddr:0x%x)\n",
|
||||
level, *startAddr, *stopAddr));
|
||||
bus_w(addr, ((*startAddr << startOffset) & startMask) |
|
||||
((*stopAddr << stopOffset) & stopMask));
|
||||
}
|
||||
|
||||
*startAddr = ((bus_r(addr) & startMask) >> startOffset);
|
||||
LOG(logDEBUG1, ("Getting Pattern Loop Start Address (level:%d, Read "
|
||||
"startAddr:0x%x)\n",
|
||||
level, *startAddr));
|
||||
|
||||
*stopAddr = ((bus_r(addr) & stopMask) >> stopOffset);
|
||||
LOG(logDEBUG1, ("Getting Pattern Loop Stop Address (level:%d, Read "
|
||||
"stopAddr:0x%x)\n",
|
||||
level, *stopAddr));
|
||||
}
|
||||
|
||||
void setPatternMask(uint64_t mask) {
|
||||
set64BitReg(mask, PATTERN_MASK_LSB_REG, PATTERN_MASK_MSB_REG);
|
||||
}
|
||||
|
||||
uint64_t getPatternMask() {
|
||||
return get64BitReg(PATTERN_MASK_LSB_REG, PATTERN_MASK_MSB_REG);
|
||||
}
|
||||
|
||||
void setPatternBitMask(uint64_t mask) {
|
||||
set64BitReg(mask, PATTERN_SET_LSB_REG, PATTERN_SET_MSB_REG);
|
||||
}
|
||||
|
||||
uint64_t getPatternBitMask() {
|
||||
return get64BitReg(PATTERN_SET_LSB_REG, PATTERN_SET_MSB_REG);
|
||||
}
|
||||
|
||||
int checkDetectorType() {
|
||||
#ifdef VIRTUAL
|
||||
return OK;
|
||||
@ -2653,36 +2388,40 @@ int getNumberOfDACs() { return NDAC; }
|
||||
int getNumberOfChannelsPerChip() { return NCHAN; }
|
||||
|
||||
int setChipStatusRegister(int csr) {
|
||||
uint32_t prevRunClk = clkDivider[SYSTEM_C0];
|
||||
patternParameters *pat = NULL;
|
||||
|
||||
int error = 0;
|
||||
// remember previous run clock
|
||||
uint32_t prevRunClk = clkDivider[SYSTEM_C0];
|
||||
|
||||
// set to trimming clock
|
||||
if (setClockDivider(SYSTEM_C0, DEFAULT_TRIMMING_RUN_CLKDIV) == FAIL) {
|
||||
LOG(logERROR,
|
||||
("Could not set to trimming clock in order to change CSR\n"));
|
||||
return FAIL;
|
||||
}
|
||||
pat = setChipStatusRegisterPattern(csr);
|
||||
|
||||
if (pat) {
|
||||
error |= loadPattern(logDEBUG5, pat);
|
||||
if (!error)
|
||||
startPattern();
|
||||
free(pat);
|
||||
int iret = OK;
|
||||
char cmess[MAX_STR_LENGTH];
|
||||
patternParameters *pat = setChipStatusRegisterPattern(csr);
|
||||
if (pat == NULL) {
|
||||
iret = FAIL;
|
||||
} else {
|
||||
error = 1;
|
||||
}
|
||||
|
||||
if (!error) {
|
||||
LOG(logINFO, ("CSR is now: 0x%x\n", csr));
|
||||
memset(cmess, 0, MAX_STR_LENGTH);
|
||||
iret = loadPattern(cmess, logDEBUG5, pat);
|
||||
if (iret == OK) {
|
||||
startPattern();
|
||||
LOG(logINFO, ("CSR is now: 0x%x\n", csr));
|
||||
}
|
||||
free(pat);
|
||||
}
|
||||
|
||||
// set back to previous clock
|
||||
if (setClockDivider(SYSTEM_C0, prevRunClk) == FAIL) {
|
||||
LOG(logERROR,
|
||||
("Could not set to previous run clock after changing CSR\n"));
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
|
||||
return iret;
|
||||
}
|
||||
|
||||
int setGainCaps(int caps) {
|
||||
|
Reference in New Issue
Block a user