mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 01:58:00 +02:00
merge from developer (without the additional json header implementations)
This commit is contained in:
@ -2118,8 +2118,8 @@ void readSample() {
|
||||
|
||||
// keep reading till the value is the same
|
||||
while (*((uint16_t*)now_ptr) != bus_r16(fifoAddr)) {
|
||||
FILE_LOG(logDEBUG1, ("%d ", ich));
|
||||
*((uint16_t*)now_ptr) = bus_r16(fifoAddr);
|
||||
FILE_LOG(logDEBUG1, (""))
|
||||
}
|
||||
|
||||
// increment pointer to data out destination
|
||||
|
@ -1978,7 +1978,7 @@ int64_t Feb_Control_GetMeasuredPeriod() {
|
||||
|
||||
unsigned int value = 0;
|
||||
Feb_Interface_ReadRegister(sub_num,MEAS_PERIOD_REG, &value);
|
||||
return value*10;
|
||||
return (int64_t)value*10;
|
||||
}
|
||||
|
||||
int64_t Feb_Control_GetSubMeasuredPeriod() {
|
||||
@ -1988,7 +1988,7 @@ int64_t Feb_Control_GetSubMeasuredPeriod() {
|
||||
|
||||
unsigned int value = 0;
|
||||
Feb_Interface_ReadRegister(sub_num,MEAS_SUBPERIOD_REG, &value);
|
||||
return value*10;
|
||||
return (int64_t)value*10;
|
||||
}
|
||||
|
||||
|
||||
@ -2022,14 +2022,22 @@ 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)) {
|
||||
FILE_LOG(logERROR, ("Could not read value. Value read:%d\n", value));
|
||||
FILE_LOG(logERROR, ("Could not read tr value. Value read:%d\n", value));
|
||||
value = 0;
|
||||
}
|
||||
if(!Feb_Interface_WriteRegister(Module_GetTopLeftAddress (&modules[1]),offset, data,0, 0)) {
|
||||
cprintf(RED,"Could not read tl value. Value read:%d\n", value);
|
||||
value = 0;
|
||||
}
|
||||
} else {
|
||||
if (!Feb_Interface_WriteRegister(Module_GetBottomRightAddress (&modules[1]),offset, data,0, 0)) {
|
||||
FILE_LOG(logERROR, ("Could not read value. Value read:%d\n", value));
|
||||
FILE_LOG(logERROR, ("Could not read br value. Value read:%d\n", value));
|
||||
value = 0;
|
||||
}
|
||||
if(!Feb_Interface_WriteRegister(Module_GetBottomLeftAddress (&modules[1]),offset, data,0, 0)) {
|
||||
cprintf(RED,"Could not read bl value. Value read:%d\n", value);
|
||||
value = 0;
|
||||
}
|
||||
}
|
||||
return Feb_Control_ReadRegister(offset);
|
||||
}
|
||||
@ -2037,16 +2045,33 @@ uint32_t Feb_Control_WriteRegister(uint32_t offset, uint32_t data) {
|
||||
|
||||
uint32_t Feb_Control_ReadRegister(uint32_t offset) {
|
||||
uint32_t value=0;
|
||||
uint32_t value1=0;
|
||||
if (Module_TopAddressIsValid(&modules[1])) {
|
||||
if (!Feb_Interface_ReadRegister(Module_GetTopRightAddress (&modules[1]),offset, &value)) {
|
||||
FILE_LOG(logERROR, ("Could not read value. Value read:%d\n", value));
|
||||
value = 0;
|
||||
}
|
||||
printf("Read top right addr: 0x%08x\n", value);
|
||||
if(!Feb_Interface_ReadRegister(Module_GetTopLeftAddress (&modules[1]),offset, &value1)) {
|
||||
cprintf(RED,"Could not read value. Value read:%d\n", value1);
|
||||
value1 = 0;
|
||||
}
|
||||
printf("Read top left addr: 0x%08x\n", value1);
|
||||
if (value != value1)
|
||||
value = -1;
|
||||
} else {
|
||||
if (!Feb_Interface_ReadRegister(Module_GetBottomRightAddress (&modules[1]),offset, &value)) {
|
||||
FILE_LOG(logERROR, ("Could not read value. Value read:%d\n", value));
|
||||
value = 0;
|
||||
}
|
||||
printf("Read bottom right addr: 0x%08x\n", value);
|
||||
if(!Feb_Interface_ReadRegister(Module_GetBottomLeftAddress (&modules[1]),offset, &value1)) {
|
||||
cprintf(RED,"Could not read value. Value read:%d\n", value1);
|
||||
value1 = 0;
|
||||
}
|
||||
printf("Read bottom left addr: 0x%08x\n", value1);
|
||||
if (value != value1)
|
||||
value = -1;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
@ -61,7 +61,7 @@
|
||||
#define DAQ_TKN_TMNG_OFST (0)
|
||||
#define DAQ_TKN_TMNG_MSK (0x0000FFFF << DAQ_TKN_TMNG_OFST)
|
||||
#define DAQ_TKN_TMNG_BRD_RVSN_1_VAL ((0x1f16 << DAQ_TKN_TMNG_OFST) & DAQ_TKN_TMNG_MSK)
|
||||
#define DAQ_TKN_TMNG_BRD_RVSN_2_VAL ((0x1f0f << DAQ_TKN_TMNG_OFST) & DAQ_TKN_TMNG_MSK)
|
||||
#define DAQ_TKN_TMNG_BRD_RVSN_2_VAL ((0x1f10 << DAQ_TKN_TMNG_OFST) & DAQ_TKN_TMNG_MSK)
|
||||
#define DAQ_PCKT_LNGTH_OFST (16)
|
||||
#define DAQ_PCKT_LNGTH_MSK (0x0000FFFF << DAQ_PCKT_LNGTH_OFST)
|
||||
#define DAQ_PCKT_LNGTH_NO_ROI_VAL ((0x0013f << DAQ_PCKT_LNGTH_OFST) & DAQ_PCKT_LNGTH_MSK)
|
||||
|
@ -1480,6 +1480,64 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t
|
||||
|
||||
usleep(1000 * 1000);
|
||||
FILE_LOG(logDEBUG1, ("\tConfigure Mac Done\n"));
|
||||
{
|
||||
/** send out first image as first packet does not give 0xcacacaca (needed to know if first image
|
||||
* when switching back and forth between roi and no roi
|
||||
*/
|
||||
FILE_LOG(logINFOBLUE, ("Sending an image to counter the packet numbers\n"));
|
||||
// remember old parameters
|
||||
enum externalCommunicationMode oldtiming = getTiming();
|
||||
uint64_t oldframes = setTimer(FRAME_NUMBER, -1);
|
||||
uint64_t oldcycles = setTimer(CYCLES_NUMBER, -1);
|
||||
uint64_t oldPeriod = setTimer(FRAME_PERIOD, -1);
|
||||
uint64_t oldExptime = setTimer(ACQUISITION_TIME, -1);
|
||||
|
||||
// set to basic parameters
|
||||
FILE_LOG(logINFO, ("\tSetting basic parameters\n"
|
||||
"\tTiming: auto\n"
|
||||
"\tframes: 1\n"
|
||||
"\tcycles: 1\n"
|
||||
"\tperiod: 1s\n"
|
||||
"\texptime: 900ms\n"));
|
||||
setTiming(AUTO_TIMING);
|
||||
setTimer(FRAME_NUMBER, 1);
|
||||
setTimer(CYCLES_NUMBER, 1);
|
||||
setTimer(FRAME_PERIOD, 1e9); // important to keep this until we have to wait for acquisition to start
|
||||
setTimer(ACQUISITION_TIME, 900 * 1000);
|
||||
|
||||
// take an image
|
||||
if (masterflags == IS_MASTER)
|
||||
usleep(1 * 1000 * 1000); // required to ensure master starts acquisition only after slave has changed to basic parameters and is waiting
|
||||
|
||||
int loop = 0;
|
||||
startStateMachine();
|
||||
// wait for acquisition to start (trigger from master)
|
||||
FILE_LOG(logINFO, ("\tWaiting for acquisition to start\n"));
|
||||
while(!runBusy()) {
|
||||
usleep(0);
|
||||
++loop;
|
||||
}
|
||||
|
||||
FILE_LOG(logINFO, ("\twaited %d loops to start\n", loop));
|
||||
FILE_LOG(logINFO, ("\tWaiting for acquisition to end (frames left: %lld)\n", (long long int)getTimeLeft(FRAME_NUMBER)));
|
||||
waitForAcquisitionFinish();
|
||||
|
||||
// set to previous parameters
|
||||
FILE_LOG(logINFO, ("\tSetting previous parameters:\n"
|
||||
"\tTiming: %d\n"
|
||||
"\tframes: %lld\n"
|
||||
"\tcycles: %lld\n"
|
||||
"\tperiod: %lld ns\n"
|
||||
"\texptime:%lld ns\n",
|
||||
(int)oldtiming, (long long int)oldframes, (long long int)oldcycles,
|
||||
(long long int)oldPeriod, (long long int)oldExptime));
|
||||
setTiming(oldtiming);
|
||||
setTimer(FRAME_NUMBER, oldframes);
|
||||
setTimer(CYCLES_NUMBER, oldcycles);
|
||||
setTimer(FRAME_PERIOD, oldPeriod);
|
||||
setTimer(ACQUISITION_TIME, oldExptime);
|
||||
FILE_LOG(logINFOBLUE, ("Done sending a frame at configuration\n"));
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -1604,6 +1662,7 @@ int startStateMachine(){
|
||||
return OK;
|
||||
#endif
|
||||
FILE_LOG(logINFOBLUE, ("Starting State Machine\n"));
|
||||
FILE_LOG(logINFO, ("#frames to acquire:%lld\n", (long long int)setTimer(FRAME_NUMBER, -1)));
|
||||
|
||||
cleanFifos();
|
||||
|
||||
|
@ -1359,6 +1359,7 @@ int start_acquisition(int file_des) {
|
||||
FILE_LOG(logDEBUG1, ("Starting Acquisition\n"));
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
nframes = 0;
|
||||
ret = startStateMachine();
|
||||
if (ret == FAIL) {
|
||||
sprintf(mess, "Could not start acquisition\n");
|
||||
@ -1443,6 +1444,7 @@ int start_and_read_all(int file_des) {
|
||||
FILE_LOG(logDEBUG1, ("Stopping Acquisition\n"));
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
nframes = 0;
|
||||
ret = startStateMachine();
|
||||
if (ret == FAIL) {
|
||||
sprintf(mess, "Could not start acquisition\n");
|
||||
@ -1473,7 +1475,6 @@ int read_all(int file_des) {
|
||||
#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
|
||||
// read from fifo enabled
|
||||
if (!sendUDP(-1)) {
|
||||
nframes = 0;
|
||||
|
||||
// keep reading frames
|
||||
while(readFrameFromFifo() == OK) {
|
||||
|
Reference in New Issue
Block a user