mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-13 13:27:14 +02:00
wip
This commit is contained in:
@ -998,76 +998,88 @@ 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 *toggle, int *exposure) {
|
||||||
|
unsigned int value = 0;
|
||||||
|
if (!Feb_Interface_ReadRegister(Feb_Control_AddressToAll(), FEB_REG_STATUS,
|
||||||
|
&value)) {
|
||||||
|
LOG(logERROR, ("Could not read FEB_REG_STATUS reg\n"));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
*toggle =
|
||||||
|
((value & FEB_REG_STATUS_EXP_TGL_MSK) >> FEB_REG_STATUS_EXP_TGL_OFST);
|
||||||
|
*exposure = ((value & FEB_REG_STATUS_EXP_MSK) >> FEB_REG_STATUS_EXP_OFST);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Feb_Control_SendSoftwareTrigger() {
|
||||||
|
// read old value in register
|
||||||
|
unsigned int orig_value = 0;
|
||||||
|
if (!Feb_Interface_ReadRegister(Feb_Control_AddressToAll(),
|
||||||
|
DAQ_REG_CHIP_CMDS, &orig_value)) {
|
||||||
|
LOG(logERROR, ("Could not read DAQ_REG_CHIP_CMDS to send software "
|
||||||
|
"trigger\n"));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
unsigned int cmd = orig_value | DAQ_REG_CHIP_CMDS_INT_TRIGGER;
|
||||||
|
|
||||||
|
// set trigger bit
|
||||||
|
LOG(logDEBUG1, ("Setting Trigger, Register:0x%x\n", cmd));
|
||||||
|
if (!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),
|
||||||
|
DAQ_REG_CHIP_CMDS, cmd, 0, 0)) {
|
||||||
|
LOG(logERROR, ("Could not give software trigger\n"));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// unset trigger bit
|
||||||
|
LOG(logDEBUG1, ("Unsetting Trigger, Register:0x%x\n", orig_value));
|
||||||
|
if (!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),
|
||||||
|
DAQ_REG_CHIP_CMDS, orig_value, 0, 0)) {
|
||||||
|
LOG(logERROR, ("Could not give software trigger\n"));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
LOG(logINFO, ("Software Internal Trigger Sent!\n"));
|
||||||
|
}
|
||||||
|
|
||||||
int Feb_Control_SoftwareTrigger(int block) {
|
int Feb_Control_SoftwareTrigger(int block) {
|
||||||
if (Feb_Control_activated) {
|
if (Feb_Control_activated) {
|
||||||
// read exp toggle value
|
|
||||||
unsigned int value = 0;
|
|
||||||
if (!Feb_Interface_ReadRegister(Feb_Control_AddressToAll(),
|
|
||||||
FEB_REG_STATUS, &value)) {
|
|
||||||
LOG(logERROR, ("Could not read FEB_REG_STATUS reg\n"));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
int prev_toggle = ((value & FEB_REG_STATUS_EXP_TGL_MSK) >>
|
|
||||||
FEB_REG_STATUS_EXP_TGL_OFST);
|
|
||||||
|
|
||||||
// send software trigger
|
int prev_toggle = 0, toggle = 0, prev_exposure = 0, exposure = 0;
|
||||||
unsigned int orig_value = 0;
|
|
||||||
if (!Feb_Interface_ReadRegister(Feb_Control_AddressToAll(),
|
|
||||||
DAQ_REG_CHIP_CMDS, &orig_value)) {
|
|
||||||
LOG(logERROR, ("Could not read DAQ_REG_CHIP_CMDS to send software "
|
|
||||||
"trigger\n"));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
unsigned int cmd = orig_value | DAQ_REG_CHIP_CMDS_INT_TRIGGER;
|
|
||||||
|
|
||||||
// set trigger bit
|
// remember previous toggle
|
||||||
LOG(logDEBUG1, ("Setting Trigger, Register:0x%x\n", cmd));
|
if (!Feb_Control_GetExposureStatus(&prev_toggle, &exposure)) {
|
||||||
if (!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),
|
|
||||||
DAQ_REG_CHIP_CMDS, cmd, 0, 0)) {
|
|
||||||
LOG(logERROR, ("Could not give software trigger\n"));
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
// unset trigger bit
|
|
||||||
LOG(logDEBUG1, ("Unsetting Trigger, Register:0x%x\n", orig_value));
|
Feb_Control_SendSoftwareTrigger();
|
||||||
if (!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),
|
|
||||||
DAQ_REG_CHIP_CMDS, orig_value, 0, 0)) {
|
|
||||||
LOG(logERROR, ("Could not give software trigger\n"));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
LOG(logINFO, ("Software Internal Trigger Sent!\n"));
|
|
||||||
|
|
||||||
// wait for trigger for 20ms
|
// wait for trigger for 20ms
|
||||||
usleep(20 * 1000);
|
usleep();
|
||||||
if (!Feb_Interface_ReadRegister(Feb_Control_AddressToAll(),
|
|
||||||
FEB_REG_STATUS, &value)) {
|
// get current toggle value
|
||||||
LOG(logERROR, ("Could not read FEB_REG_STATUS reg\n"));
|
if (!Feb_Control_GetExposureToggle(&toggle, &exposure)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int toggle = ((value & FEB_REG_STATUS_EXP_TGL_MSK) >>
|
|
||||||
FEB_REG_STATUS_EXP_TGL_OFST);
|
|
||||||
|
|
||||||
// no toggle, so no trigger
|
// no toggle error
|
||||||
if (toggle == prev_toggle) {
|
if (toggle == prev_toggle) {
|
||||||
LOG(logERROR, ("Software trigger failed. No exposure toggle "
|
LOG(logERROR, ("Software trigger failed. No exposure toggle "
|
||||||
"detected in 20ms.\n"));
|
"detected.\n"));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// read that it exposed
|
// no exposure
|
||||||
int exposure =
|
|
||||||
((value & FEB_REG_STATUS_EXP_MSK) >> FEB_REG_STATUS_EXP_OFST);
|
|
||||||
if (!exposure) {
|
if (!exposure) {
|
||||||
LOG(logERROR,
|
LOG(logERROR, ("Software trigger failed. No exposure detected.\n"));
|
||||||
("Software trigger failed. No exposure detected in 20ms.\n"));
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
prev_exposure = exposure;
|
||||||
|
|
||||||
// wait for toggle for exposure to be done
|
// wait for exposure to be done
|
||||||
if (block) {
|
if (block) {
|
||||||
while (toggle == prev_toggle) {
|
while (prev_exposure == exposure) {
|
||||||
usleep(5000);
|
usleep(5000);
|
||||||
toggle = ((value & FEB_REG_STATUS_EXP_TGL_MSK) >>
|
if (!Feb_Control_GetExposureStatus(&prev_toggle, &exposure)) {
|
||||||
FEB_REG_STATUS_EXP_TGL_OFST);
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,9 @@ 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_GetExposureToggle(int *toggle, int *exposure);
|
||||||
|
int Feb_Control_GetExposureStatus(int *status);
|
||||||
|
int Feb_Control_SendSoftwareTrigger();
|
||||||
int Feb_Control_SoftwareTrigger(int block);
|
int Feb_Control_SoftwareTrigger(int block);
|
||||||
|
|
||||||
// parameters
|
// parameters
|
||||||
|
Reference in New Issue
Block a user