This commit is contained in:
maliakal_d 2021-06-25 16:24:26 +02:00
parent 927d642bf7
commit 0d01de451a
2 changed files with 42 additions and 83 deletions

View File

@ -998,23 +998,19 @@ int Feb_Control_StartAcquisition() {
int Feb_Control_StopAcquisition() { return Feb_Control_Reset(); } int Feb_Control_StopAcquisition() { return Feb_Control_Reset(); }
int Feb_Control_GetExposureStatus(int left, int *rising, int *falling, int int Feb_Control_IsReadyForTrigger(int *readyForTrigger) {
int *exposure) { unsigned int addr[2] = {Feb_Control_leftAddress, Feb_Control_rightAddress};
unsigned int value[2] = {0, 0};
unsigned int addr = for (int i = 0; i < 2; ++i) {
(left == 1 ? Feb_Control_leftAddress : Feb_Control_rightAddress); if (!Feb_Interface_ReadRegister(addr[i], FEB_REG_STATUS, &value[i])) {
unsigned int value = 0;
if (!Feb_Interface_ReadRegister(addr, FEB_REG_STATUS, &value)) {
LOG(logERROR, ("Could not read %s FEB_REG_STATUS reg\n", LOG(logERROR, ("Could not read %s FEB_REG_STATUS reg\n",
(left == 1 ? "left" : "right"))); (i == 0 ? "left" : "right")));
return 0; return 0;
} }
LOG(logINFORED, ("febregstatus:0x%x\n", value)); }
*rising = ((value & FEB_REG_STATUS_EXP_TGL_RISING_MSK) >> *readyForTrigger =
FEB_REG_STATUS_EXP_TGL_RISING_OFST); ((value[0] | value[1]) & FEB_REG_STATUS_WAIT_FOR_TRGGR_MSK);
*falling = ((value & FEB_REG_STATUS_EXP_TGL_FALLING_MSK) >>
FEB_REG_STATUS_EXP_TGL_FALLING_OFST);
*exposure = ((value & FEB_REG_STATUS_EXP_MSK) >> FEB_REG_STATUS_EXP_OFST);
return 1; return 1;
} }
@ -1049,56 +1045,20 @@ int Feb_Control_SendSoftwareTrigger() {
int Feb_Control_SoftwareTrigger(int block) { int Feb_Control_SoftwareTrigger(int block) {
if (Feb_Control_activated) { if (Feb_Control_activated) {
/*
int rising[2] = {0, 0}, falling[2] = {0, 0}, exposure[2] = {0, 0}, // if not ready for trigger, throw
prev_toggle[2] = {0, 0}; int readyForTrigger = 0;
for (int i = 0; i < 1; ++i) { if (!Feb_Control_IsReadyForTrigger(&readyForTrigger)) {
if (!Feb_Control_GetExposureStatus(i, &rising[i], &falling[i], LOG(logWARNING, ("Not yet ready for trigger!\n"));
&exposure[i])) {
return 0; return 0;
} }
*/
if (exposure[i]) {
LOG(logERROR,
("Software trigger failed. %s FPGA still exposing.\n",
i == 1 ? "left" : "right"));
return 0;
}
// remember previous rising toggle
prev_toggle[i] = rising[i];
}
// send trigger to both fpgas // send trigger to both fpgas
Feb_Control_SendSoftwareTrigger(); Feb_Control_SendSoftwareTrigger();
/*
// will need to wait if delay after trigger introduced // will need to wait if delay after trigger introduced
// usleep(0); // usleep(0);
for (int i = 0; i < 1; ++i) {
// get current toggle value
if (!Feb_Control_GetExposureStatus(i, &rising[i], &falling[i],
&exposure[i])) {
return 0;
}
// no toggle error
if (rising[i] == prev_toggle[i]) {
LOG(logERROR, ("Software trigger failed. No exposure toggle "
"detected on %s fpga.\n",
i == 1 ? "left" : "right"));
return 0;
}
// no exposure
if (!exposure[i]) {
LOG(logERROR, ("Software trigger failed. No exposure detected "
"on %s fpga.\n",
i == 1 ? "left" : "right"));
return 0;
}
}
// wait for exposure to be done // wait for exposure to be done
if (block) { if (block) {
for (int i = 0; i < 1; ++i) { for (int i = 0; i < 1; ++i) {
@ -1113,13 +1073,13 @@ int Feb_Control_SoftwareTrigger(int block) {
// exposure low // exposure low
if (exposure[i]) { if (exposure[i]) {
LOG(logERROR, LOG(logERROR,
("Software trigger failed. Still exposing after " ("Software trigger failed. Still exposing after
"exposure finished toggled in %s fpga.\n", " "exposure finished toggled in %s fpga.\n", i == 1 ? "left" :
i == 1 ? "left" : "right")); "right")); return 0;
return 0;
} }
} }
} }
*/
} }
return 1; return 1;
} }

View File

@ -55,8 +55,7 @@ int Feb_Control_PrepareForAcquisition();
void Feb_Control_PrintAcquisitionSetup(); void Feb_Control_PrintAcquisitionSetup();
int Feb_Control_StartAcquisition(); int Feb_Control_StartAcquisition();
int Feb_Control_StopAcquisition(); int Feb_Control_StopAcquisition();
int Feb_Control_GetExposureStatus(int left, int *rising, int *falling, int Feb_Control_IsReadyForTrigger(int *readyForTrigger);
int *exposure);
int Feb_Control_SendSoftwareTrigger(); int Feb_Control_SendSoftwareTrigger();
int Feb_Control_SoftwareTrigger(int block); int Feb_Control_SoftwareTrigger(int block);