mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-05-02 10:50:05 +02:00
posisibility to read adnd write registers in the front end board for eiger
This commit is contained in:
parent
389f356a3a
commit
af079f3168
@ -1921,4 +1921,35 @@ int Feb_Control_GetRightFPGATemp(){
|
||||
}
|
||||
|
||||
|
||||
uint32_t Feb_Control_WriteRegister(uint32_t offset, uint32_t data) {
|
||||
uint32_t value=0;
|
||||
if(Module_TopAddressIsValid(&modules[1])){
|
||||
if(!Feb_Interface_WriteRegister(Module_GetTopRightAddress (&modules[1]),offset, data,0, 0)) {
|
||||
cprintf(RED,"Could not read value. Value read:%d\n", value);
|
||||
value = 0;
|
||||
}
|
||||
} else {
|
||||
if(!Feb_Interface_WriteRegister(Module_GetBottomRightAddress (&modules[1]),offset, data,0, 0)) {
|
||||
cprintf(RED,"Could not read value. Value read:%d\n", value);
|
||||
value = 0;
|
||||
}
|
||||
}
|
||||
return Feb_Control_ReadRegister(offset);
|
||||
}
|
||||
|
||||
|
||||
uint32_t Feb_Control_ReadRegister(uint32_t offset) {
|
||||
uint32_t value=0;
|
||||
if(Module_TopAddressIsValid(&modules[1])){
|
||||
if(!Feb_Interface_ReadRegister(Module_GetTopRightAddress (&modules[1]),offset, &value)) {
|
||||
cprintf(RED,"Could not read value. Value read:%d\n", value);
|
||||
value = 0;
|
||||
}
|
||||
} else {
|
||||
if(!Feb_Interface_ReadRegister(Module_GetBottomRightAddress (&modules[1]),offset, &value)) {
|
||||
cprintf(RED,"Could not read value. Value read:%d\n", value);
|
||||
value = 0;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
@ -198,4 +198,6 @@ int Feb_Control_GetModuleNumber();
|
||||
int Feb_Control_GetLeftFPGATemp();
|
||||
int Feb_Control_GetRightFPGATemp();
|
||||
|
||||
uint32_t Feb_Control_WriteRegister(uint32_t offset, uint32_t data);
|
||||
uint32_t Feb_Control_ReadRegister(uint32_t offset);
|
||||
#endif
|
||||
|
Binary file not shown.
@ -342,7 +342,14 @@ void setupDetector() {
|
||||
|
||||
|
||||
|
||||
/* advanced read/write reg */
|
||||
uint32_t writeRegister(uint32_t offset, uint32_t data) {
|
||||
return Feb_Control_WriteRegister(offset, data);
|
||||
}
|
||||
|
||||
uint32_t readRegister(uint32_t offset) {
|
||||
return Feb_Control_ReadRegister(offset);
|
||||
}
|
||||
|
||||
|
||||
/* set parameters - nmod, dr, roi */
|
||||
|
@ -3359,9 +3359,9 @@ string slsDetectorCommand::cmdDetectorSize(int narg, char *args[], int action) {
|
||||
return string("unknown detector size ")+cmd;
|
||||
|
||||
if (cmd=="roimask")
|
||||
sprintf(ans,"%x",ret);
|
||||
sprintf(ans,"0x%x",ret);
|
||||
else
|
||||
sprintf(ans,"%d",ret);
|
||||
sprintf(ans,"0x%d",ret);
|
||||
|
||||
return string(ans);
|
||||
|
||||
@ -3689,7 +3689,7 @@ string slsDetectorCommand::cmdDigiTest(int narg, char *args[], int action) {
|
||||
if (cmd=="bustest"){
|
||||
if (action==PUT_ACTION)
|
||||
return string("cannot set ")+cmd;
|
||||
sprintf(answer,"%x",myDet->digitalTest(DETECTOR_BUS_TEST));
|
||||
sprintf(answer,"0x%x",myDet->digitalTest(DETECTOR_BUS_TEST));
|
||||
return string(answer);
|
||||
}
|
||||
|
||||
@ -3698,7 +3698,7 @@ string slsDetectorCommand::cmdDigiTest(int narg, char *args[], int action) {
|
||||
return string("cannot set ")+cmd;
|
||||
int ival=-1;
|
||||
if (sscanf(args[0],"digitest:%d",&ival)) {
|
||||
sprintf(answer,"%x",myDet->digitalTest(CHIP_TEST, ival));
|
||||
sprintf(answer,"0x%x",myDet->digitalTest(CHIP_TEST, ival));
|
||||
return string(answer);
|
||||
} else
|
||||
return string("undefined module number");
|
||||
@ -3710,7 +3710,7 @@ string slsDetectorCommand::cmdDigiTest(int narg, char *args[], int action) {
|
||||
int ival=-1;
|
||||
if (sscanf(args[1],"%d",&ival)) {
|
||||
if((ival==0)||(ival==1)){
|
||||
sprintf(answer,"%x",myDet->digitalTest(DIGITAL_BIT_TEST,ival));
|
||||
sprintf(answer,"0x%x",myDet->digitalTest(DIGITAL_BIT_TEST,ival));
|
||||
return string(answer);
|
||||
}
|
||||
else
|
||||
@ -3783,13 +3783,13 @@ string slsDetectorCommand::cmdRegister(int narg, char *args[], int action) {
|
||||
;
|
||||
else
|
||||
return string("Could not scan value (hexadecimal fomat) ")+string(args[2]);
|
||||
sprintf(answer,"%x",myDet->writeRegister(addr,val));
|
||||
sprintf(answer,"0x%x",myDet->writeRegister(addr,val));
|
||||
} else if (cmd=="adcreg") {
|
||||
if (sscanf(args[2],"%x",&val))
|
||||
;
|
||||
else
|
||||
return string("Could not scan value (hexadecimal fomat) ")+string(args[2]);
|
||||
sprintf(answer,"%x",myDet->writeAdcRegister(addr,val));
|
||||
sprintf(answer,"0x%x",myDet->writeAdcRegister(addr,val));
|
||||
} else {
|
||||
|
||||
if (sscanf(args[2],"%d",&n))
|
||||
@ -3801,9 +3801,9 @@ string slsDetectorCommand::cmdRegister(int narg, char *args[], int action) {
|
||||
return string("Bit number out of range")+string(args[2]);
|
||||
|
||||
if (cmd=="setbit")
|
||||
sprintf(answer,"%x",myDet->writeRegister(addr,myDet->readRegister(addr)| 1<<n));
|
||||
sprintf(answer,"0x%x",myDet->writeRegister(addr,myDet->readRegister(addr)| 1<<n));
|
||||
if (cmd=="clearbit")
|
||||
sprintf(answer,"%x",myDet->writeRegister(addr,myDet->readRegister(addr) & ~(1<<n)));
|
||||
sprintf(answer,"0x%x",myDet->writeRegister(addr,myDet->readRegister(addr) & ~(1<<n)));
|
||||
}
|
||||
|
||||
|
||||
@ -3824,7 +3824,7 @@ string slsDetectorCommand::cmdRegister(int narg, char *args[], int action) {
|
||||
return string("Could not scan address (hexadecimal fomat) ")+string(args[1]);
|
||||
|
||||
|
||||
sprintf(answer,"%x",myDet->readRegister(addr));
|
||||
sprintf(answer,"0x%x",myDet->readRegister(addr));
|
||||
|
||||
}
|
||||
|
||||
@ -3861,7 +3861,7 @@ string slsDetectorCommand::helpRegister(int narg, char *args[], int action) {
|
||||
|
||||
ostringstream os;
|
||||
if (action==PUT_ACTION || action==HELP_ACTION) {
|
||||
os << "reg addr val \n writes the register addr with the value val"<< std::endl;
|
||||
os << "reg addr val \n writes the register addr with the value val (hexadecimal format)"<< std::endl;
|
||||
}
|
||||
if (action==GET_ACTION || action==HELP_ACTION) {
|
||||
os << "reg addr \n reads the register addr"<< std::endl;
|
||||
|
@ -59,6 +59,9 @@ void setupDetector();
|
||||
#ifndef EIGERD
|
||||
extern u_int32_t writeRegister(u_int32_t offset, u_int32_t data); // blackfin.h
|
||||
extern u_int32_t readRegister(u_int32_t offset); // blackfin.h
|
||||
#else
|
||||
uint32_t writeRegister(uint32_t offset, uint32_t data);
|
||||
uint32_t readRegister(uint32_t offset);
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -1242,15 +1242,6 @@ int write_register(int file_des) {
|
||||
int retval=-1;
|
||||
sprintf(mess,"write to register failed\n");
|
||||
|
||||
#ifdef EIGERD
|
||||
//to receive any arguments
|
||||
while (n > 0)
|
||||
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
|
||||
ret = FAIL;
|
||||
sprintf(mess,"Function (Write Register) is not implemented for this detector\n");
|
||||
cprintf(RED, "Warning: %s", mess);
|
||||
#else
|
||||
|
||||
// receive arguments
|
||||
int arg[2]={-1,-1};
|
||||
n = receiveData(file_des,arg,sizeof(arg),INT32);
|
||||
@ -1282,7 +1273,6 @@ int write_register(int file_des) {
|
||||
#endif
|
||||
if (ret==OK && differentClients)
|
||||
ret=FORCE_UPDATE;
|
||||
#endif
|
||||
|
||||
// ret could be swapped during sendData
|
||||
ret1 = ret;
|
||||
@ -1310,15 +1300,6 @@ int read_register(int file_des) {
|
||||
int retval=-1;
|
||||
sprintf(mess,"read register failed\n");
|
||||
|
||||
#ifdef EIGERD
|
||||
//to receive any arguments
|
||||
while (n > 0)
|
||||
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
|
||||
ret = FAIL;
|
||||
sprintf(mess,"Function (Read Register) is not implemented for this detector\n");
|
||||
cprintf(RED, "Warning: %s", mess);
|
||||
#else
|
||||
|
||||
// receive arguments
|
||||
int arg=0;
|
||||
n = receiveData(file_des,&arg,sizeof(arg),INT32);
|
||||
@ -1337,7 +1318,6 @@ int read_register(int file_des) {
|
||||
#endif
|
||||
if (ret==OK && differentClients)
|
||||
ret=FORCE_UPDATE;
|
||||
#endif
|
||||
|
||||
// ret could be swapped during sendData
|
||||
ret1 = ret;
|
||||
|
Loading…
x
Reference in New Issue
Block a user