diff --git a/slsDetectorGui/include/qDrawPlot.h b/slsDetectorGui/include/qDrawPlot.h
index 906617416..950154bae 100755
--- a/slsDetectorGui/include/qDrawPlot.h
+++ b/slsDetectorGui/include/qDrawPlot.h
@@ -161,8 +161,6 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
unsigned int nPixelsX{0};
unsigned int nPixelsY{0};
- const static int npixelsx_jctb = 400;
- int npixelsy_jctb{0};
uint32_t pixelMask{0};
uint32_t gainMask{0};
int gainOffset{0};
diff --git a/slsDetectorGui/src/qDetectorMain.cpp b/slsDetectorGui/src/qDetectorMain.cpp
index 139b56729..40c6712e2 100755
--- a/slsDetectorGui/src/qDetectorMain.cpp
+++ b/slsDetectorGui/src/qDetectorMain.cpp
@@ -431,8 +431,7 @@ void qDetectorMain::ExecuteUtilities(QAction *action) {
void qDetectorMain::ExecuteHelp(QAction *action) {
if (action == actionAbout) {
- FILE_LOG(logINFO) << "About Common GUI for Eiger, Gotthard, Jungfrau "
- "and Moench detectors";
+ FILE_LOG(logINFO) << "About Common GUI for Jungfrau, Eiger, Mythen3, Gotthard, Gotthard2 and Moench detectors";
std::string guiVersion = std::to_string(APIGUI);
std::string clientVersion = "unknown";
@@ -449,7 +448,7 @@ void qDetectorMain::ExecuteHelp(QAction *action) {
clientVersion +
"
"
"Common GUI to control the SLS Detectors: "
- "Eiger, Jungfrau, Mythen3, Gotthard, Gotthard2 and Moench.
"
+ "Jungfrau, Eiger, Mythen3, Gotthard, Gotthard2 and Moench.
"
"It can be operated in parallel with the command "
"line interface:
"
"sls_detector_put,
sls_detector_get,
sls_"
diff --git a/slsDetectorGui/src/qDrawPlot.cpp b/slsDetectorGui/src/qDrawPlot.cpp
index 6f4b8934d..50c38f28b 100755
--- a/slsDetectorGui/src/qDrawPlot.cpp
+++ b/slsDetectorGui/src/qDrawPlot.cpp
@@ -60,7 +60,6 @@ void qDrawPlot::SetupWidgetWindow() {
detType = det->getDetectorType().squash();
switch (detType) {
case slsDetectorDefs::JUNGFRAU:
- case slsDetectorDefs::MOENCH:
pixelMask = ((1 << 14) - 1);
gainMask = (3 << 14);
gainOffset = 14;
@@ -111,13 +110,6 @@ void qDrawPlot::SetupPlots() {
nPixelsX = res.x;
nPixelsY = res.y;
switch(detType) {
- case slsDetectorDefs::MOENCH:
- try{
- npixelsy_jctb = (det->getNumberOfAnalogSamples().tsquash("Inconsistent values for number of analog samples") * 2)/25;// for moench 03
- nPixelsX = npixelsx_jctb;
- nPixelsY = npixelsy_jctb;
- } CATCH_DISPLAY ("Could not get number of analog samples.", "qDrawPlot::SetupPlots")
- break;
case slsDetectorDefs::EIGER:
try{
if (det->getQuad().tsquash("Inconsistent values for quad type")) {
@@ -984,7 +976,6 @@ void qDrawPlot::toDoublePixelData(double *dest, char *source, int size, int data
case 16:
if (detType == slsDetectorDefs::JUNGFRAU ||
- detType == slsDetectorDefs::MOENCH ||
detType == slsDetectorDefs::GOTTHARD2) {
// show gain plot
diff --git a/slsDetectorGui/src/qTabDeveloper.cpp b/slsDetectorGui/src/qTabDeveloper.cpp
index 1fe5c5332..d82312a4f 100755
--- a/slsDetectorGui/src/qTabDeveloper.cpp
+++ b/slsDetectorGui/src/qTabDeveloper.cpp
@@ -82,14 +82,14 @@ void qTabDeveloper::SetupWidgetWindow() {
case slsDetectorDefs::MOENCH:
lblSpinHV->show();
spinHV->show();
- dacWidgets.push_back(new qDacWidget(this, det, true, "v Dac 0: ", getSLSIndex(detType, tempid++)));
- dacWidgets.push_back(new qDacWidget(this, det, true, "v Dac 1: ", getSLSIndex(detType, tempid++)));
- dacWidgets.push_back(new qDacWidget(this, det, true, "v Dac 2: ", getSLSIndex(detType, tempid++)));
- dacWidgets.push_back(new qDacWidget(this, det, true, "v Dac 3: ", getSLSIndex(detType, tempid++)));
- dacWidgets.push_back(new qDacWidget(this, det, true, "v Dac 4: ", getSLSIndex(detType, tempid++)));
- dacWidgets.push_back(new qDacWidget(this, det, true, "v Dac 5: ", getSLSIndex(detType, tempid++)));
- dacWidgets.push_back(new qDacWidget(this, det, true, "v Dac 6: ", getSLSIndex(detType, tempid++)));
- dacWidgets.push_back(new qDacWidget(this, det, true, "i Dac 7: ", getSLSIndex(detType, tempid++)));
+ dacWidgets.push_back(new qDacWidget(this, det, true, "vbp_colbuf: ", getSLSIndex(detType, tempid++)));
+ dacWidgets.push_back(new qDacWidget(this, det, true, "vipre: ", getSLSIndex(detType, tempid++)));
+ dacWidgets.push_back(new qDacWidget(this, det, true, "vin_cm: ", getSLSIndex(detType, tempid++)));
+ dacWidgets.push_back(new qDacWidget(this, det, true, "vb_sda: ", getSLSIndex(detType, tempid++)));
+ dacWidgets.push_back(new qDacWidget(this, det, true, "vcasc_sfp: ", getSLSIndex(detType, tempid++)));
+ dacWidgets.push_back(new qDacWidget(this, det, true, "vout_cm: ", getSLSIndex(detType, tempid++)));
+ dacWidgets.push_back(new qDacWidget(this, det, true, "vipre_cds: ", getSLSIndex(detType, tempid++)));
+ dacWidgets.push_back(new qDacWidget(this, det, true, "ibias_sfp: ", getSLSIndex(detType, tempid++)));
break;
case slsDetectorDefs::MYTHEN3:
@@ -343,10 +343,27 @@ slsDetectorDefs::dacIndex qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorTy
break;
case slsDetectorDefs::MOENCH:
- if (index >= 0 && index < (int)dacWidgets.size()) {
- return (slsDetectorDefs::dacIndex)index;
- }
- throw sls::RuntimeError(std::string("Unknown dac/adc index") + std::to_string(index));
+ switch (index) {
+ case 0:
+ return slsDetectorDefs::VBP_COLBUF;
+ case 1:
+ return slsDetectorDefs::VIPRE;
+ case 2:
+ return slsDetectorDefs::VIN_CM;
+ case 3:
+ return slsDetectorDefs::VB_SDA;
+ case 4:
+ return slsDetectorDefs::VCASC_SFP;
+ case 5:
+ return slsDetectorDefs::VOUT_CM;
+ case 6:
+ return slsDetectorDefs::VIPRE_CDS;
+ case 7:
+ return slsDetectorDefs::IBIAS_SFP;
+ default:
+ throw sls::RuntimeError(std::string("Unknown dac/adc index") + std::to_string(index));
+ }
+ break;
case slsDetectorDefs::MYTHEN3:
switch (index) {
diff --git a/slsDetectorGui/src/qTabPlot.cpp b/slsDetectorGui/src/qTabPlot.cpp
index 4fbea4210..83703e364 100755
--- a/slsDetectorGui/src/qTabPlot.cpp
+++ b/slsDetectorGui/src/qTabPlot.cpp
@@ -72,7 +72,6 @@ void qTabPlot::SetupWidgetWindow() {
chkGapPixels->setEnabled(true);
break;
case slsDetectorDefs::JUNGFRAU:
- case slsDetectorDefs::MOENCH:
chkGainPlot->setEnabled(true);
chkGainPlot->setChecked(true);
plot->EnableGainPlot(true);
@@ -585,7 +584,6 @@ void qTabPlot::Refresh() {
GetGapPixels();
break;
case slsDetectorDefs::JUNGFRAU:
- case slsDetectorDefs::MOENCH:
chkGainPlot->setEnabled(true);
break;
case slsDetectorDefs::GOTTHARD2:
diff --git a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c
index 368e3f8ab..1957d7df3 100755
--- a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c
+++ b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c
@@ -515,7 +515,7 @@ void setupDetector() {
// altera pll
ALTERA_PLL_SetDefines(PLL_CNTRL_REG, PLL_PARAM_REG, PLL_CNTRL_RCNFG_PRMTR_RST_MSK, PLL_CNTRL_WR_PRMTR_MSK, PLL_CNTRL_PLL_RST_MSK, PLL_CNTRL_ADDR_MSK, PLL_CNTRL_ADDR_OFST);
- bus_w(ADC_PORT_INVERT_REG, 0);// depends on chip
+ setADCInvertRegister(0);// depends on chip
FILE_LOG(logINFOBLUE, ("Setting Default parameters\n"));
cleanFifos(); // FIXME: why twice?
diff --git a/slsDetectorServers/ctbDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/ctbDetectorServer/slsDetectorServer_defs.h
index dd26567da..0db56c528 100755
--- a/slsDetectorServers/ctbDetectorServer/slsDetectorServer_defs.h
+++ b/slsDetectorServers/ctbDetectorServer/slsDetectorServer_defs.h
@@ -107,7 +107,6 @@ enum CLKINDEX {RUN_CLK, ADC_CLK, SYNC_CLK, DBIT_CLK, NUM_CLOCKS};
#define BIT32_MSK (0xFFFFFFFF)
#define BIT16_MASK (0xFFFF)
-#define ADC_PORT_INVERT_VAL (0x453b2593)
#define MAXIMUM_ADC_CLK (65)
#define PLL_VCO_FREQ_MHZ (800)
diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c
index 6c628adfb..79d3841ba 100755
--- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c
+++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c
@@ -1,7 +1,7 @@
#include "slsDetectorFunctionList.h"
#include "versionAPI.h"
#include "clogger.h"
-#include
+
#include "AD9257.h" // commonServerFunctions.h, blackfin.h, ansi.h
#include "LTC2620.h" // dacs
#include "MAX1932.h" // hv
@@ -14,6 +14,7 @@
#include
#include // usleep
+#include
#ifdef VIRTUAL
#include
#include
diff --git a/slsDetectorServers/moenchDetectorServer/Makefile b/slsDetectorServers/moenchDetectorServer/Makefile
index 00d7f828e..5285f2ea2 100755
--- a/slsDetectorServers/moenchDetectorServer/Makefile
+++ b/slsDetectorServers/moenchDetectorServer/Makefile
@@ -34,6 +34,7 @@ $(PROGS): $(OBJS)
mv $(PROGS) $(DESTDIR)
rm *.gdb
rm $(main_src)*.o
+ rm *.o
clean:
rm -rf $(DESTDIR)/$(PROGS) *.o *.gdb $(main_src)*.o
diff --git a/slsDetectorServers/moenchDetectorServer/RegisterDefs.h b/slsDetectorServers/moenchDetectorServer/RegisterDefs.h
index 83b9f3c0e..ca8263056 100755
--- a/slsDetectorServers/moenchDetectorServer/RegisterDefs.h
+++ b/slsDetectorServers/moenchDetectorServer/RegisterDefs.h
@@ -16,7 +16,7 @@
/* Fix pattern RO register */
#define FIX_PATT_REG (0x01 << MEM_MAP_SHIFT)
-#define FIX_PATT_VAL (0xACDC2014)
+#define FIX_PATT_VAL (0xACDC2016)
/* Status RO register */
#define STATUS_REG (0x02 << MEM_MAP_SHIFT)
@@ -289,7 +289,7 @@
/* Configuration RW register */
#define CONFIG_REG (0x4D << MEM_MAP_SHIFT)
-#define CONFIG_LED_DSBL_OFST (0)
+#define CONFIG_LED_DSBL_OFST (0) // Not used in firmware or software
#define CONFIG_LED_DSBL_MSK (0x00000001 << CONFIG_LED_DSBL_OFST)
#define CONFIG_DSBL_ANLG_OTPT_OFST (8)
#define CONFIG_DSBL_ANLG_OTPT_MSK (0x00000001 << CONFIG_DSBL_ANLG_OTPT_OFST)
@@ -365,23 +365,23 @@
#define PATTERN_CNTRL_RD_OFST (1)
#define PATTERN_CNTRL_RD_MSK (0x00000001 << PATTERN_CNTRL_RD_OFST)
#define PATTERN_CNTRL_ADDR_OFST (16)
-#define PATTERN_CNTRL_ADDR_MSK (0x0000FFFF << PATTERN_CNTRL_ADDR_OFST)
+#define PATTERN_CNTRL_ADDR_MSK (0x00001FFF << PATTERN_CNTRL_ADDR_OFST)
/* Pattern Limit RW regiser */
#define PATTERN_LIMIT_REG (0x53 << MEM_MAP_SHIFT)
#define PATTERN_LIMIT_STRT_OFST (0)
-#define PATTERN_LIMIT_STRT_MSK (0x0000FFFF << PATTERN_LIMIT_STRT_OFST)
+#define PATTERN_LIMIT_STRT_MSK (0x00001FFF << PATTERN_LIMIT_STRT_OFST)
#define PATTERN_LIMIT_STP_OFST (16)
-#define PATTERN_LIMIT_STP_MSK (0x0000FFFF << PATTERN_LIMIT_STP_OFST)
+#define PATTERN_LIMIT_STP_MSK (0x00001FFF << PATTERN_LIMIT_STP_OFST)
/* Pattern Loop 0 Address RW regiser */
#define PATTERN_LOOP_0_ADDR_REG (0x54 << MEM_MAP_SHIFT)
#define PATTERN_LOOP_0_ADDR_STRT_OFST (0)
-#define PATTERN_LOOP_0_ADDR_STRT_MSK (0x0000FFFF << PATTERN_LOOP_0_ADDR_STRT_OFST)
+#define PATTERN_LOOP_0_ADDR_STRT_MSK (0x00001FFF << PATTERN_LOOP_0_ADDR_STRT_OFST)
#define PATTERN_LOOP_0_ADDR_STP_OFST (16)
-#define PATTERN_LOOP_0_ADDR_STP_MSK (0x0000FFFF << PATTERN_LOOP_0_ADDR_STP_OFST)
+#define PATTERN_LOOP_0_ADDR_STP_MSK (0x00001FFF << PATTERN_LOOP_0_ADDR_STP_OFST)
/* Pattern Loop 0 Iteration RW regiser */
#define PATTERN_LOOP_0_ITERATION_REG (0x55 << MEM_MAP_SHIFT)
@@ -390,9 +390,9 @@
#define PATTERN_LOOP_1_ADDR_REG (0x56 << MEM_MAP_SHIFT)
#define PATTERN_LOOP_1_ADDR_STRT_OFST (0)
-#define PATTERN_LOOP_1_ADDR_STRT_MSK (0x0000FFFF << PATTERN_LOOP_1_ADDR_STRT_OFST)
+#define PATTERN_LOOP_1_ADDR_STRT_MSK (0x00001FFF << PATTERN_LOOP_1_ADDR_STRT_OFST)
#define PATTERN_LOOP_1_ADDR_STP_OFST (16)
-#define PATTERN_LOOP_1_ADDR_STP_MSK (0x0000FFFF << PATTERN_LOOP_1_ADDR_STP_OFST)
+#define PATTERN_LOOP_1_ADDR_STP_MSK (0x00001FFF << PATTERN_LOOP_1_ADDR_STP_OFST)
/* Pattern Loop 1 Iteration RW regiser */
#define PATTERN_LOOP_1_ITERATION_REG (0x57 << MEM_MAP_SHIFT)
@@ -401,9 +401,9 @@
#define PATTERN_LOOP_2_ADDR_REG (0x58 << MEM_MAP_SHIFT)
#define PATTERN_LOOP_2_ADDR_STRT_OFST (0)
-#define PATTERN_LOOP_2_ADDR_STRT_MSK (0x0000FFFF << PATTERN_LOOP_2_ADDR_STRT_OFST)
+#define PATTERN_LOOP_2_ADDR_STRT_MSK (0x00001FFF << PATTERN_LOOP_2_ADDR_STRT_OFST)
#define PATTERN_LOOP_2_ADDR_STP_OFST (16)
-#define PATTERN_LOOP_2_ADDR_STP_MSK (0x0000FFFF << PATTERN_LOOP_2_ADDR_STP_OFST)
+#define PATTERN_LOOP_2_ADDR_STP_MSK (0x00001FFF << PATTERN_LOOP_2_ADDR_STP_OFST)
/* Pattern Loop 2 Iteration RW regiser */
#define PATTERN_LOOP_2_ITERATION_REG (0x59 << MEM_MAP_SHIFT)
@@ -412,31 +412,36 @@
#define PATTERN_WAIT_0_ADDR_REG (0x5A << MEM_MAP_SHIFT)
#define PATTERN_WAIT_0_ADDR_OFST (0)
-#define PATTERN_WAIT_0_ADDR_MSK (0x0000FFFF << PATTERN_WAIT_0_ADDR_OFST)
+#define PATTERN_WAIT_0_ADDR_MSK (0x00001FFF << PATTERN_WAIT_0_ADDR_OFST)
//FIXME: is mask 3FF
/* Pattern Wait 1 RW regiser */
#define PATTERN_WAIT_1_ADDR_REG (0x5B << MEM_MAP_SHIFT)
#define PATTERN_WAIT_1_ADDR_OFST (0)
-#define PATTERN_WAIT_1_ADDR_MSK (0x0000FFFF << PATTERN_WAIT_1_ADDR_OFST)
+#define PATTERN_WAIT_1_ADDR_MSK (0x00001FFF << PATTERN_WAIT_1_ADDR_OFST)
/* Pattern Wait 2 RW regiser */
#define PATTERN_WAIT_2_ADDR_REG (0x5C << MEM_MAP_SHIFT)
#define PATTERN_WAIT_2_ADDR_OFST (0)
-#define PATTERN_WAIT_2_ADDR_MSK (0x0000FFFF << PATTERN_WAIT_2_ADDR_OFST)
+#define PATTERN_WAIT_2_ADDR_MSK (0x00001FFF << PATTERN_WAIT_2_ADDR_OFST)
/* Samples RW register */
#define SAMPLES_REG (0x5D << MEM_MAP_SHIFT)
+#define SAMPLES_DIGITAL_OFST (0)
+#define SAMPLES_DIGITAL_MSK (0x0000FFFF << SAMPLES_DIGITAL_OFST)
+#define SAMPLES_ANALOG_OFST (16)
+#define SAMPLES_ANALOG_MSK (0x0000FFFF << SAMPLES_ANALOG_OFST)
+
/** Power RW register */
#define POWER_REG (0x5E << MEM_MAP_SHIFT)
-#define POWER_ENBL_VLTG_RGLTR_OFST (16)
-#define POWER_ENBL_VLTG_RGLTR_MSK (0x0000001F << POWER_ENBL_VLTG_RGLTR_OFST)
-#define POWER_HV_SLCT_OFST (31)
-#define POWER_HV_SLCT_MSK (0x00000001 << POWER_HV_SLCT_OFST)
+#define POWER_CHIP_OFST (16)
+#define POWER_CHIP_MSK (0x00000001 << POWER_CHIP_OFST)
+#define POWER_HV_INTERNAL_SLCT_OFST (31)
+#define POWER_HV_INTERNAL_SLCT_MSK (0x00000001 << POWER_HV_INTERNAL_SLCT_OFST)
/* Number of Words RW register TODO */
#define NUMBER_OF_WORDS_REG (0x5F << MEM_MAP_SHIFT)
@@ -493,17 +498,16 @@
#define PATTERN_WAIT_TIMER_2_LSB_REG (0x76 << MEM_MAP_SHIFT)
#define PATTERN_WAIT_TIMER_2_MSB_REG (0x77 << MEM_MAP_SHIFT)
-/* ADC Disable RW register TODO */
-#define ADC_DISABLE_REG (0x78 << MEM_MAP_SHIFT)
+/* Readout enable RW register */
+#define READOUT_10G_ENABLE_REG (0x79 << MEM_MAP_SHIFT)
-/* DAC Value RW register TODO */
-//#define DAC_VALUE_REG (0x79 << MEM_MAP_SHIFT)
-
-/* DAC Number RW register TODO */
-//#define DAC_NUMBER_REG (0x7A << MEM_MAP_SHIFT)
+#define READOUT_10G_ENABLE_ANLG_OFST (0)
+#define READOUT_10G_ENABLE_ANLG_MSK (0x000000FF << READOUT_10G_ENABLE_ANLG_OFST)
+#define READOUT_10G_ENABLE_DGTL_OFST (8)
+#define READOUT_10G_ENABLE_DGTL_MSK (0x00000001 << READOUT_10G_ENABLE_DGTL_OFST)
/* Digital Bit External Trigger RW register */
-#define DBIT_EXT_TRG_REG (0x7B << MEM_MAP_SHIFT)
+#define DBIT_EXT_TRG_REG (0x7B << MEM_MAP_SHIFT) // Not used in firmware or software
#define DBIT_EXT_TRG_SRC_OFST (0)
#define DBIT_EXT_TRG_SRC_MSK (0x0000003F << DBIT_EXT_TRG_SRC_OFST)
@@ -511,7 +515,8 @@
#define DBIT_EXT_TRG_OPRTN_MD_MSK (0x00000001 << DBIT_EXT_TRG_OPRTN_MD_OFST)
/* Pin Delay 0 RW register */
-#define OUTPUT_DELAY_0_REG (0x7C << MEM_MAP_SHIFT)
+#define OUTPUT_DELAY_0_REG (0x7C << MEM_MAP_SHIFT) // Not used in firmware or software
+
#define OUTPUT_DELAY_0_OTPT_STTNG_STEPS (25)
#define OUTPUT_DELAY_0_OTPT_STTNG_OFST (0) //t = OTPT_STTNG * 25 ps, max for Cyclone V = 775 ps
#define OUTPUT_DELAY_0_OTPT_STTNG_MSK (0x0000001F << OUTPUT_DELAY_0_OTPT_STTNG_OFST)
@@ -523,7 +528,7 @@
/* Pin Delay 1 RW register
* Each bit configured as enable for dynamic output delay configuration */
-#define PIN_DELAY_1_REG (0x7D << MEM_MAP_SHIFT)
+#define PIN_DELAY_1_REG (0x7D << MEM_MAP_SHIFT) // Not used in firmware or software
/** Pattern Mask 64 bit RW regiser */
#define PATTERN_MASK_LSB_REG (0x80 << MEM_MAP_SHIFT)
@@ -533,7 +538,7 @@
#define PATTERN_SET_LSB_REG (0x82 << MEM_MAP_SHIFT)
#define PATTERN_SET_MSB_REG (0x83 << MEM_MAP_SHIFT)
-
-
+/* Round Robin */
+#define RXR_ENDPOINT_START_REG (0x1000 << MEM_MAP_SHIFT)
diff --git a/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer
new file mode 100755
index 000000000..5f32a8451
Binary files /dev/null and b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer differ
diff --git a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c
index 46613a557..77513d918 100755
--- a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c
+++ b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c
@@ -9,9 +9,7 @@
#include "MAX1932.h" // hv
#include "ALTERA_PLL.h" // pll
#include "blackfin.h"
-#ifndef VIRTUAL
-#include "programFpgaBlackfin.h"
-#endif
+#include "common.h"
#include
#include // usleep
@@ -22,14 +20,15 @@
// Global variable from slsDetectorServer_funcs
extern int debugflag;
+extern udpStruct udpDetails;
// Global variable from UDPPacketHeaderGenerator
extern uint64_t udpFrameNumber;
extern uint32_t udpPacketNumber;
-int firmware_compatibility = OK;
-int firmware_check_done = 0;
-char firmware_message[MAX_STR_LENGTH];
+int initError = OK;
+int initCheckDone = 0;
+char initErrorMessage[MAX_STR_LENGTH];
#ifdef VIRTUAL
pthread_t pthread_virtual_tid;
@@ -37,70 +36,69 @@ int virtual_status = 0;
int virtual_stop = 0;
#endif
+// 1g readout
int dataBytes = 0;
-char* ramValues = 0;
+int analogDataBytes = 0;
+int digitalDataBytes = 0;
+char* analogData = 0;
+char* digitalData = 0;
+char volatile *analogDataPtr = 0;
+char volatile *digitalDataPtr = 0;
char udpPacketData[UDP_PACKET_DATA_BYTES + sizeof(sls_detector_header)];
+uint32_t adcEnableMask_1g = 0;
-int32_t clkPhase[NUM_CLOCKS] = {0, 0, 0, 0};
-uint32_t clkDivider[NUM_CLOCKS] = {40, 20, 20, 200};
+// 10g readout
+uint8_t adcEnableMask_10g = 0;
-int dacValues[NDAC] = {0};
+int32_t clkPhase[NUM_CLOCKS] = {};
+uint32_t clkFrequency[NUM_CLOCKS] = {40, 20, 20, 200};
+int dacValues[NDAC] = {};
// software limit that depends on the current chip on the ctb
int vLimit = 0;
-
int highvoltage = 0;
-ROI rois[MAX_ROIS];
-int nROI = 0;
-uint32_t adcDisableMask = 0;
int nSamples = 1;
-char volatile *now_ptr = 0;
+int detPos[2] = {0, 0};
-// basic tests
-int isFirmwareCheckDone() {
- return firmware_check_done;
+int isInitCheckDone() {
+ return initCheckDone;
}
-int getFirmwareCheckResult(char** mess) {
- *mess = firmware_message;
- return firmware_compatibility;
+int getInitResult(char** mess) {
+ *mess = initErrorMessage;
+ return initError;
}
void basictests() {
- firmware_compatibility = OK;
- firmware_check_done = 0;
- memset(firmware_message, 0, MAX_STR_LENGTH);
+ initError = OK;
+ initCheckDone = 0;
+ memset(initErrorMessage, 0, MAX_STR_LENGTH);
#ifdef VIRTUAL
FILE_LOG(logINFOBLUE, ("******** Moench Detector Virtual Server *****************\n"));
if (mapCSP0() == FAIL) {
- strcpy(firmware_message,
+ strcpy(initErrorMessage,
"Could not map to memory. Dangerous to continue.\n");
- FILE_LOG(logERROR, (firmware_message));
- firmware_compatibility = FAIL;
- firmware_check_done = 1;
- return;
+ FILE_LOG(logERROR, (initErrorMessage));
+ initError = FAIL;
}
- firmware_check_done = 1;
return;
#else
defineGPIOpins();
resetFPGA();
if (mapCSP0() == FAIL) {
- strcpy(firmware_message,
+ strcpy(initErrorMessage,
"Could not map to memory. Dangerous to continue.\n");
- FILE_LOG(logERROR, ("%s\n\n", firmware_message));
- firmware_compatibility = FAIL;
- firmware_check_done = 1;
+ FILE_LOG(logERROR, ("%s\n\n", initErrorMessage));
+ initError = FAIL;
return;
}
// does check only if flag is 0 (by default), set by command line
if ((!debugflag) && ((checkType() == FAIL) || (testFpga() == FAIL) || (testBus() == FAIL))) {
- strcpy(firmware_message,
+ strcpy(initErrorMessage,
"Could not pass basic tests of FPGA and bus. Dangerous to continue.\n");
- FILE_LOG(logERROR, ("%s\n\n", firmware_message));
- firmware_compatibility = FAIL;
- firmware_check_done = 1;
+ FILE_LOG(logERROR, ("%s\n\n", initErrorMessage));
+ initError = FAIL;
return;
}
@@ -108,14 +106,14 @@ void basictests() {
uint16_t hsnumber = getHardwareSerialNumber();
uint32_t ipadd = getDetectorIP();
uint64_t macadd = getDetectorMAC();
- int64_t fwversion = getDetectorId(DETECTOR_FIRMWARE_VERSION);
- int64_t swversion = getDetectorId(DETECTOR_SOFTWARE_VERSION);
+ int64_t fwversion = getFirmwareVersion();
+ int64_t swversion = getServerVersion();
int64_t sw_fw_apiversion = 0;
- int64_t client_sw_apiversion = getDetectorId(CLIENT_SOFTWARE_API_VERSION);
+ int64_t client_sw_apiversion = getClientServerAPIVersion();
if (fwversion >= MIN_REQRD_VRSN_T_RD_API)
- sw_fw_apiversion = getDetectorId(SOFTWARE_FIRMWARE_API_VERSION);
+ sw_fw_apiversion = getFirmwareAPIVersion();
FILE_LOG(logINFOBLUE, ("************ Moench Detector Server *********************\n"
"Hardware Version:\t\t 0x%x\n"
"Hardware Serial Nr:\t\t 0x%x\n"
@@ -141,7 +139,6 @@ void basictests() {
// return if flag is not zero, debug mode
if (debugflag) {
- firmware_check_done = 1;
return;
}
@@ -149,41 +146,37 @@ void basictests() {
//cant read versions
FILE_LOG(logINFO, ("Testing Firmware-software compatibility:\n"));
if(!fwversion || !sw_fw_apiversion){
- strcpy(firmware_message,
+ strcpy(initErrorMessage,
"Cant read versions from FPGA. Please update firmware.\n");
- FILE_LOG(logERROR, (firmware_message));
- firmware_compatibility = FAIL;
- firmware_check_done = 1;
+ FILE_LOG(logERROR, (initErrorMessage));
+ initError = FAIL;
return;
}
//check for API compatibility - old server
if(sw_fw_apiversion > REQRD_FRMWR_VRSN){
- sprintf(firmware_message,
+ sprintf(initErrorMessage,
"This detector software software version (0x%llx) is incompatible.\n"
"Please update detector software (min. 0x%llx) to be compatible with this firmware.\n",
(long long int)sw_fw_apiversion,
(long long int)REQRD_FRMWR_VRSN);
- FILE_LOG(logERROR, (firmware_message));
- firmware_compatibility = FAIL;
- firmware_check_done = 1;
+ FILE_LOG(logERROR, (initErrorMessage));
+ initError = FAIL;
return;
}
//check for firmware compatibility - old firmware
if( REQRD_FRMWR_VRSN > fwversion) {
- sprintf(firmware_message,
+ sprintf(initErrorMessage,
"This firmware version (0x%llx) is incompatible.\n"
"Please update firmware (min. 0x%llx) to be compatible with this server.\n",
(long long int)fwversion,
(long long int)REQRD_FRMWR_VRSN);
- FILE_LOG(logERROR, (firmware_message));
- firmware_compatibility = FAIL;
- firmware_check_done = 1;
+ FILE_LOG(logERROR, (initErrorMessage));
+ initError = FAIL;
return;
}
FILE_LOG(logINFO, ("\tCompatibility - success\n"));
- firmware_check_done = 1;
#endif
}
@@ -195,7 +188,7 @@ int checkType() {
uint32_t expectedType = (((FPGA_VERSION_DTCTR_TYP_MOENCH_VAL) & FPGA_VERSION_DTCTR_TYP_MSK) >> FPGA_VERSION_DTCTR_TYP_OFST);
if (type != expectedType) {
- FILE_LOG(logERROR, ("This is not a Moench Detector Server (read %d, expected %d)\n",
+ FILE_LOG(logERROR, ("(Type Fail) - This is not a Moench Detector Server (read %d, expected %d)\n",
type, expectedType));
return FAIL;
}
@@ -313,39 +306,15 @@ int testBus() {
return ret;
}
-int detectorTest( enum digitalTestMode arg){
-#ifdef VIRTUAL
- return OK;
-#endif
- switch(arg){
- case DETECTOR_FIRMWARE_TEST: return testFpga();
- case DETECTOR_BUS_TEST: return testBus();
- default:
- FILE_LOG(logERROR, ("Test %s not implemented for this detector\n", (int)arg));
- break;
- }
- return OK;
-}
-
/* Ids */
-int64_t getDetectorId(enum idMode arg){
- int64_t retval = -1;
+uint64_t getServerVersion() {
+ return APIMOENCH;
+}
- switch(arg){
- case DETECTOR_SERIAL_NUMBER:
- return getDetectorNumber();
- case DETECTOR_FIRMWARE_VERSION:
- return getFirmwareVersion();
- case SOFTWARE_FIRMWARE_API_VERSION:
- return getFirmwareAPIVersion();
- case DETECTOR_SOFTWARE_VERSION:
- case CLIENT_SOFTWARE_API_VERSION:
- return APIMOENCH;
- default:
- return retval;
- }
+uint64_t getClientServerAPIVersion() {
+ return APIMOENCH;
}
uint64_t getFirmwareVersion() {
@@ -434,7 +403,10 @@ uint32_t getDetectorIP(){
/* initialization */
void initControlServer(){
- setupDetector();
+ if (initError == OK) {
+ setupDetector();
+ }
+ initCheckDone = 1;
}
void initStopServer() {
@@ -450,139 +422,175 @@ void initStopServer() {
/* set up detector */
void setupDetector() {
- FILE_LOG(logINFO, ("This Server is for 1 moench board\n"));
+ FILE_LOG(logINFO, ("This Server is for 1 Chip Test Board module\n"));
// default variables
dataBytes = 0;
- if (ramValues) {
- free(ramValues);
- ramValues = 0;
+ analogDataBytes = 0;
+ digitalDataBytes = 0;
+ if (analogData) {
+ free(analogData);
+ analogData = 0;
}
+ if (digitalData) {
+ free(digitalData);
+ digitalData = 0;
+ }
+ analogDataPtr = 0;
+ digitalDataPtr = 0;
{
int i = 0;
for (i = 0; i < NUM_CLOCKS; ++i) {
clkPhase[i] = 0;
}
- clkDivider[RUN_CLK] = DEFAULT_RUN_CLK;
- clkDivider[ADC_CLK] = DEFAULT_ADC_CLK;
- clkDivider[SYNC_CLK] = DEFAULT_SYNC_CLK;
- clkDivider[DBIT_CLK] = DEFAULT_DBIT_CLK;
+ clkFrequency[RUN_CLK] = DEFAULT_RUN_CLK;
+ clkFrequency[ADC_CLK] = DEFAULT_ADC_CLK;
+ clkFrequency[SYNC_CLK] = DEFAULT_SYNC_CLK;
+ clkFrequency[DBIT_CLK] = DEFAULT_DBIT_CLK;
+ // default adc phase in deg
+ {
+ int phase_shifts = 0;
+ ConvertToDifferentRange(0, 359, 0, getMaxPhase(ADC_CLK) - 1, DEFAULT_ADC_PHASE_DEG, &phase_shifts);
+ clkPhase[ADC_CLK] = phase_shifts;
+ }
+ FILE_LOG(logINFO, ("Default Run clk: %d MHz\n", clkFrequency[RUN_CLK]));
+ FILE_LOG(logINFO, ("Default Adc clk: %d MHz\n", clkFrequency[ADC_CLK]));
+ FILE_LOG(logINFO, ("Default Sync clk: %d MHz\n", clkFrequency[SYNC_CLK]));
+ FILE_LOG(logINFO, ("Default Dbit clk: %d MHz\n", clkFrequency[DBIT_CLK]));
+ FILE_LOG(logINFO, ("Default Adc Phase: %d (%d deg)\n", clkPhase[ADC_CLK], getPhase(ADC_CLK, 1)));
+
for (i = 0; i < NDAC; ++i)
dacValues[i] = -1;
}
vLimit = DEFAULT_VLIMIT;
highvoltage = 0;
- nROI = 0;
- adcDisableMask = 0;
+ adcEnableMask_1g = 0;
+ adcEnableMask_10g = 0;
nSamples = 1;
- now_ptr = 0;
-
ALTERA_PLL_ResetPLLAndReconfiguration();
- resetCore();
- resetPeripheral();
- cleanFifos();
+ resetCore();
+ resetPeripheral();
+ cleanFifos();
// hv
MAX1932_SetDefines(SPI_REG, SPI_HV_SRL_CS_OTPT_MSK, SPI_HV_SRL_CLK_OTPT_MSK, SPI_HV_SRL_DGTL_OTPT_MSK, SPI_HV_SRL_DGTL_OTPT_OFST, HIGHVOLTAGE_MIN, HIGHVOLTAGE_MAX);
MAX1932_Disable();
setHighVoltage(DEFAULT_HIGH_VOLTAGE);
- // adc
+ // power off chip
+ powerChip(0);
+
+ // adcs
AD9257_SetDefines(ADC_SPI_REG, ADC_SPI_SRL_CS_OTPT_MSK, ADC_SPI_SRL_CLK_OTPT_MSK, ADC_SPI_SRL_DT_OTPT_MSK, ADC_SPI_SRL_DT_OTPT_OFST);
AD9257_Disable();
AD9257_Configure();
- //dac
- LTC2620_SetDefines(SPI_REG, SPI_DAC_SRL_CS_OTPT_MSK, SPI_DAC_SRL_CLK_OTPT_MSK, SPI_DAC_SRL_DGTL_OTPT_MSK, SPI_DAC_SRL_DGTL_OTPT_OFST, NDAC, DAC_MIN_MV, DAC_MAX_MV);
+ // dacs
+ LTC2620_SetDefines(SPI_REG, SPI_DAC_SRL_CS_OTPT_MSK, SPI_DAC_SRL_CLK_OTPT_MSK, SPI_DAC_SRL_DGTL_OTPT_MSK, SPI_DAC_SRL_DGTL_OTPT_OFST, NDAC, DAC_MIN_MV, DAC_MAX_MV); //has to be before setvchip
LTC2620_Disable();
LTC2620_Configure();
- //FIXME:
- // switch off dacs (power regulators most likely only sets to minimum (if power enable on))
- FILE_LOG(logINFOBLUE, ("Powering down all dacs\n"));
- {
- int idac = 0;
- for (idac = 0; idac < NDAC; ++idac) {
- setDAC(idac, LTC2620_PWR_DOWN_VAL, 0);
- }
- }
+ setDefaultDacs();
- // altera pll
- ALTERA_PLL_SetDefines(PLL_CNTRL_REG, PLL_PARAM_REG, PLL_CNTRL_RCNFG_PRMTR_RST_MSK, PLL_CNTRL_WR_PRMTR_MSK, PLL_CNTRL_PLL_RST_MSK, PLL_CNTRL_ADDR_MSK, PLL_CNTRL_ADDR_OFST);
-
- bus_w(ADC_PORT_INVERT_REG, ADC_PORT_INVERT_VAL);//FIXME: got from moench config file
+ // altera pll
+ ALTERA_PLL_SetDefines(PLL_CNTRL_REG, PLL_PARAM_REG, PLL_CNTRL_RCNFG_PRMTR_RST_MSK, PLL_CNTRL_WR_PRMTR_MSK, PLL_CNTRL_PLL_RST_MSK, PLL_CNTRL_ADDR_MSK, PLL_CNTRL_ADDR_OFST);
+ // not using setADCInvertRegister command (as it xors the default)
+ bus_w(ADC_PORT_INVERT_REG, ADC_PORT_INVERT_VAL);
FILE_LOG(logINFOBLUE, ("Setting Default parameters\n"));
cleanFifos(); // FIXME: why twice?
resetCore();
- // 10 G UDP
- enableTenGigabitEthernet(1);
+ // 1G UDP
+ enableTenGigabitEthernet(0);
//Initialization of acquistion parameters
- setTimer(SAMPLES, DEFAULT_NUM_SAMPLES); // update databytes and allocate ram
- setTimer(FRAME_NUMBER, DEFAULT_NUM_FRAMES);
- setTimer(ACQUISITION_TIME, DEFAULT_EXPTIME);
- setTimer(TRIGGER_NUMBER, DEFAULT_NUM_CYCLES);
- setTimer(FRAME_PERIOD, DEFAULT_PERIOD);
- setTimer(DELAY_AFTER_TRIGGER, DEFAULT_DELAY);
+ setNumAnalogSamples(DEFAULT_NUM_SAMPLES);
+ setNumFrames(DEFAULT_NUM_FRAMES);
+ setExpTime(DEFAULT_EXPTIME);
+ setNumTriggers(DEFAULT_NUM_CYCLES);
+ setPeriod(DEFAULT_PERIOD);
+ setDelayAfterTrigger(DEFAULT_DELAY);
setTiming(DEFAULT_TIMING_MODE);
-
- // ensuring normal readout (only option for moench)
- bus_w(CONFIG_REG, bus_r(CONFIG_REG) & (~CONFIG_DSBL_ANLG_OTPT_MSK) & (~CONFIG_ENBLE_DGTL_OTPT_MSK));
-
- // clear roi
- {
- int ret = OK, retvalsize = 0;
- setROI(0, rois, &retvalsize, &ret);
+ setADCEnableMask(BIT32_MSK);
+ setADCEnableMask_10G(BIT32_MSK);
+ if (setAnalogOnlyReadout() == FAIL) {
+ strcpy(initErrorMessage,
+ "Could not set readout mode to analog only.\n");
+ FILE_LOG(logERROR, ("%s\n\n", initErrorMessage));
+ initError = FAIL;
}
+ setPipeline(ADC_CLK, DEFAULT_PIPELINE);
}
-int allocateRAM() {
- int oldDataBytes = dataBytes;
- updateDataBytes();
+int updateDatabytesandAllocateRAM() {
- // only allcoate RAM for 1 giga udp (if 10G, return)
- if (enableTenGigabitEthernet(-1))
+ int oldDataBytes = analogDataBytes;
+ updateDataBytes();
+
+ // update only if change in databytes
+ if (analogDataBytes == oldDataBytes) {
+ FILE_LOG(logDEBUG1, ("RAM size (Databytes:%d) already allocated. Nothing to be done.\n", dataBytes));
return OK;
-
- // update only if change in databytes
- if (dataBytes == oldDataBytes) {
- FILE_LOG(logDEBUG1, ("RAM of size %d already allocated. Nothing to be done.\n", dataBytes));
- return OK;
+ }
+ // Zero databytes
+ if (analogDataBytes == 0) {
+ FILE_LOG(logERROR, ("Can not allocate RAM for 0 bytes.\n"));
+ return FAIL;
+ }
+ // clear RAM
+ if (analogData) {
+ free(analogData);
+ analogData = 0;
}
- // Zero databytes
- if (dataBytes <= 0) {
- FILE_LOG(logERROR, ("Can not allocate RAM for 0 bytes (databytes: 0).\n"));
- return FAIL;
- }
- // clear RAM
- if (ramValues) {
- free(ramValues);
- ramValues = 0;
- }
- // allocate RAM
- ramValues = malloc(dataBytes);
+ // allocate RAM
+ analogData = malloc(analogDataBytes);
// cannot malloc
- if (ramValues == NULL) {
- FILE_LOG(logERROR, ("Can not allocate RAM for even 1 frame. "
- "Probably cause: Memory Leak.\n"));
+ if (analogData == NULL) {
+ FILE_LOG(logERROR, ("Can not allocate data RAM for even 1 frame. "
+ "Probable cause: Memory Leak.\n"));
return FAIL;
}
-
- FILE_LOG(logINFO, ("\tRAM allocated to %d bytes\n", dataBytes));
- return OK;
+ FILE_LOG(logINFO, ("\tRAM allocated to %d bytes\n", analogDataBytes));
+ return OK;
}
void updateDataBytes() {
- int oldDataBytes = dataBytes;
- dataBytes = NCHIP * NUM_BYTES_PER_PIXEL * nSamples;
- if (dataBytes != oldDataBytes) {
- FILE_LOG(logINFO, ("\tUpdating Databytes: %d\n", dataBytes));
+ int nchans = 0;
+ analogDataBytes = 0;
+
+ if (adcEnableMask_1g == BIT32_MSK)
+ nchans = 32;
+ else {
+ int ichan = 0;
+ for (ichan = 0; ichan < NCHAN; ++ichan) {
+ if (adcEnableMask_1g & (1 << ichan))
+ ++nchans;
+ }
}
+ analogDataBytes = nchans * (DYNAMIC_RANGE / 8) * nSamples;
+ FILE_LOG(logINFO, ("\t#Channels:%d, Databytes:%d\n", nchans, analogDataBytes));
+
+ dataBytes = analogDataBytes;
}
+int setDefaultDacs() {
+ int ret = OK;
+ FILE_LOG(logINFOBLUE, ("Setting Default Dac values\n"));
+ {
+ int i = 0;
+ const int defaultvals[NDAC] = DEFAULT_DAC_VALS;
+ for(i = 0; i < NDAC; ++i) {
+ // if not already default, set it to default
+ if (dacValues[i] != defaultvals[i]) {
+ setDAC((enum DACINDEX)i,defaultvals[i],0);
+ }
+ }
+ }
+ return ret;
+}
+
/* firmware functions (resets) */
void cleanFifos() {
@@ -613,354 +621,246 @@ void resetPeripheral() {
}
-/* set parameters - dr, roi */
+/* set parameters - dr, adcenablemask */
int setDynamicRange(int dr){
return DYNAMIC_RANGE;
}
-ROI* setROI(int n, ROI arg[], int *retvalsize, int *ret) {
- uint32_t addr = ADC_DISABLE_REG;
-
- // set ROI
- if(n >= 0) {
- // clear roi
- if (!n) {
- FILE_LOG(logINFO, ("Clearing ROI\n"));
- adcDisableMask = 0;
- }
- // set roi
- else {
- FILE_LOG(logINFO, ("Setting ROI:\n"));
- adcDisableMask = 0xffffffff;
- int iroi = 0;
- // for every roi
- for (iroi = 0; iroi < n; ++iroi) {
- FILE_LOG(logINFO, ("\t%d: (%d, %d)\n", iroi, arg[iroi].xmin, arg[iroi].xmax));
- // swap if xmin > xmax
- if (arg[iroi].xmin > arg[iroi].xmax) {
- int temp = arg[iroi].xmin;
- arg[iroi].xmin = arg[iroi].xmax;
- arg[iroi].xmax = temp;
- FILE_LOG(logINFORED, ("\tCorrected %d: (%d, %d)\n", iroi, arg[iroi].xmin, arg[iroi].xmax));
- }
- int ich = 0;
- // for the roi specified
- for (ich = arg[iroi].xmin; ich <= arg[iroi].xmax; ++ich) {
- // valid channel (disable)
- if (ich >= 0 && ich < NCHAN)
- adcDisableMask &= ~(1 << ich);
-
- FILE_LOG(logDEBUG1, ("%d: ich:%d adcDisableMask:0x%08x\n",
- iroi, ich, adcDisableMask));
- }
- }
- }
- FILE_LOG(logINFO, ("\tSetting adcDisableMask to 0x%08x\n", adcDisableMask));
- bus_w(addr, adcDisableMask);
+int setADCEnableMask(uint32_t mask) {
+ if (mask == 0u) {
+ FILE_LOG(logERROR, ("Cannot set 1gb adc mask to 0\n"));
+ return FAIL;
}
-
- // get roi
- adcDisableMask = bus_r(addr);
- FILE_LOG(logDEBUG1, ("Getting adcDisableMask: 0x%08x\n", adcDisableMask));
-
- nROI = 0;
- if (adcDisableMask) {
- int ich = 0;
- // loop through channels
- for (ich = 0; ich < NCHAN; ++ich) {
- // channel disabled
- if ((~adcDisableMask) & (1 << ich)) {
- // first channel
- if (ich == 0) {
- ++nROI;
- rois[nROI - 1].xmin = ich;
- rois[nROI - 1].xmax = ich;
- rois[nROI - 1].ymin = -1;
- rois[nROI - 1].ymax = -1;
- }
- // not first channel
- else {
- // previous channel enabled (so increase roi)
- if ((adcDisableMask) & (1 << (ich - 1))) {
- ++nROI;
- // max roi level
- if (nROI > MAX_ROIS) {
- nROI = -1;
- *ret = FAIL;
- FILE_LOG(logERROR, ("Max ROI reached!\n"));
- break;
- }
- rois[nROI - 1].xmin = ich;
- rois[nROI - 1].ymin = -1;
- rois[nROI - 1].ymax = -1;
- }
- // set max as current one each time
- rois[nROI - 1].xmax = ich;
- }
- }
- }
+ int topAdcs = __builtin_popcount(mask & 0xF0F0F0F0);
+ int bottomAdcs = __builtin_popcount(mask & 0x0F0F0F0F);
+ if (topAdcs > 0 && bottomAdcs > 0 && topAdcs != bottomAdcs) {
+ FILE_LOG(logERROR, ("Invalid mask. Top and bottom number of adcs do not match\n"));
+ return FAIL;
}
-
- // print
- if (!nROI) {
- FILE_LOG(logINFO, ("\tROI: None\n"));
- } else {
- FILE_LOG(logINFO, ("ROI:\n"));
- int i = 0;
- for (i = 0; i < nROI; ++i) {
- FILE_LOG(logINFO, ("\t%d: (%d, %d)\n", i, rois[i].xmin, rois[i].xmax));
-
+ FILE_LOG(logINFO, ("Setting adcEnableMask 1G to 0x%08x\n", mask));
+ adcEnableMask_1g = mask;
+ // 1Gb enabled
+ if (!enableTenGigabitEthernet(-1)) {
+ if (updateDatabytesandAllocateRAM() == FAIL) {
+ return FAIL;
}
}
-
- // validate and update databytes
- if (n >= 0) {
- // validate
- if((n != 0) && ((arg[0].xmin != rois[0].xmin)||
- (arg[0].xmax != rois[0].xmax)||
- (arg[0].ymin != rois[0].ymin)||
- (arg[0].ymax != rois[0].ymax))) {
- *ret = FAIL;
- FILE_LOG(logERROR, ("\tCould not set given ROI\n"));
- }
- if(n != nROI) {
- *ret = FAIL;
- FILE_LOG(logERROR, ("\tCould not set or clear ROIs\n"));
- }
- // update databytes (now that mask is up to date from fpga) and allocate ram
- if (allocateRAM() == FAIL) {
- *ret = FAIL;
- nROI = -2;
- }
- }
-
- *retvalsize = nROI;
- return rois;
-}
-
-
-/* parameters - speed, readout */
-
-void setSpeed(enum speedVariable ind, int val, int mode) {
- switch(ind) {
- case ADC_PHASE:
- FILE_LOG(logINFOBLUE, ("Configuring ADC Phase\n"));
- configurePhase(ADC_CLK, val, mode);
- break;
- case DBIT_PHASE:
- FILE_LOG(logINFOBLUE, ("Configuring Dbit Phase\n"));
- configurePhase(DBIT_CLK, val, mode);
- break;
- case ADC_CLOCK:
- FILE_LOG(logINFOBLUE, ("Configuring ADC Clock\n"));
- configureFrequency(ADC_CLK, val);
- configureSyncFrequency(ADC_CLK);
- break;
- case DBIT_CLOCK:
- FILE_LOG(logINFOBLUE, ("Configuring Dbit Clock\n"));
- configureFrequency(DBIT_CLK, val);
- configureSyncFrequency(DBIT_CLK);
- break;
- case ADC_PIPELINE:
- setAdcOffsetRegister(1, val);
- break;
- case DBIT_PIPELINE:
- setAdcOffsetRegister(0, val);
- break;
- case CLOCK_DIVIDER:
- FILE_LOG(logINFOBLUE, ("Configuring Run Clock\n"));
- configureFrequency(RUN_CLK, val);
- configureSyncFrequency(RUN_CLK);
- break;
- default:
- return;
- }
-}
-
-int getSpeed(enum speedVariable ind, int mode) {
- switch(ind) {
- case ADC_PHASE:
- return getPhase(ADC_CLK, mode);
- case DBIT_PHASE:
- return getPhase(DBIT_CLK, mode);
- case MAX_ADC_PHASE_SHIFT:
- return getMaxPhase(ADC_CLK);
- case MAX_DBIT_PHASE_SHIFT:
- return getMaxPhase(DBIT_CLK);
- case ADC_CLOCK:
- return getFrequency(ADC_CLK);
- case DBIT_CLOCK:
- return getFrequency(DBIT_CLK);
- case CLOCK_DIVIDER:
- return getFrequency(RUN_CLK);
- case ADC_PIPELINE:
- return getAdcOffsetRegister(1);
- case DBIT_PIPELINE:
- return getAdcOffsetRegister(0);
- default:
- return -1;
- }
-}
-
-
-
-/* parameters - timer */
-int64_t setTimer(enum timerIndex ind, int64_t val) {
-
- int64_t retval = -1;
- switch(ind){
-
- case FRAME_NUMBER:
- if(val >= 0) {
- FILE_LOG(logINFO, ("Setting #frames: %lld\n",(long long int)val));
- }
- retval = set64BitReg(val, FRAMES_LSB_REG, FRAMES_MSB_REG);
- FILE_LOG(logINFO, ("\tGetting #frames: %lld\n", (long long int)retval));
- break;
-
- case ACQUISITION_TIME:
- if(val >= 0){
- FILE_LOG(logINFO, ("Setting exptime (pattern wait time level 0): %lldns\n",(long long int)val));
- val *= (1E-3 * clkDivider[RUN_CLK]);
- setPatternWaitTime(0, val);
- }
- retval = setPatternWaitTime(0, -1) / (1E-3 * clkDivider[RUN_CLK]);
- FILE_LOG(logINFO, ("\tGetting exptime (pattern wait time level 0): %lldns\n", (long long int)retval));
- break;
-
- case FRAME_PERIOD:
- if(val >= 0){
- FILE_LOG(logINFO, ("Setting period: %lldns\n",(long long int)val));
- val *= (1E-3 * clkDivider[SYNC_CLK]);
- }
- retval = set64BitReg(val, PERIOD_LSB_REG, PERIOD_MSB_REG )/ (1E-3 * clkDivider[SYNC_CLK]);
- FILE_LOG(logINFO, ("\tGetting period: %lldns\n", (long long int)retval));
- break;
-
- case DELAY_AFTER_TRIGGER:
- if(val >= 0){
- FILE_LOG(logINFO, ("Setting delay: %lldns\n", (long long int)val));
- val *= (1E-3 * clkDivider[SYNC_CLK]);
- }
- retval = set64BitReg(val, DELAY_LSB_REG, DELAY_MSB_REG) / (1E-3 * clkDivider[SYNC_CLK]);
- FILE_LOG(logINFO, ("\tGetting delay: %lldns\n", (long long int)retval));
- break;
-
- case TRIGGER_NUMBER:
- if(val >= 0) {
- FILE_LOG(logINFO, ("Setting #triggers: %lld\n", (long long int)val));
- }
- retval = set64BitReg(val, CYCLES_LSB_REG, CYCLES_MSB_REG);
- FILE_LOG(logINFO, ("\tGetting #triggers: %lld\n", (long long int)retval));
- break;
-
- case SAMPLES:
- if(val >= 0) {
- FILE_LOG(logINFO, ("Setting #samples: %lld\n", (long long int)val));
- nSamples = val;
- bus_w(SAMPLES_REG, val);
- if (allocateRAM() == FAIL) {
- return -1;
- }
- }
- retval = nSamples;
- FILE_LOG(logINFO, ("\tGetting #samples: %lld\n", (long long int)retval));
- break;
-
- default:
- FILE_LOG(logERROR, ("Timer Index not implemented for this detector: %d\n", ind));
- break;
- }
-
- return retval;
-
-}
-
-
-
-int64_t getTimeLeft(enum timerIndex ind){
-#ifdef VIRTUAL
- return 0;
-#endif
- int64_t retval = -1;
- switch(ind){
-
- case FRAME_NUMBER:
- retval = get64BitReg(FRAMES_LEFT_LSB_REG, FRAMES_LEFT_MSB_REG);
- FILE_LOG(logINFO, ("Getting number of frames left: %lld\n",(long long int)retval));
- break;
-
- case FRAME_PERIOD:
- retval = get64BitReg(PERIOD_LEFT_LSB_REG, PERIOD_LEFT_MSB_REG) / (1E-3 * clkDivider[SYNC_CLK]);
- FILE_LOG(logINFO, ("Getting period left: %lldns\n", (long long int)retval));
- break;
-
- case DELAY_AFTER_TRIGGER:
- retval = get64BitReg(DELAY_LEFT_LSB_REG, DELAY_LEFT_MSB_REG) / (1E-3 * clkDivider[SYNC_CLK]);
- FILE_LOG(logINFO, ("Getting delay left: %lldns\n", (long long int)retval));
- break;
-
- case TRIGGER_NUMBER:
- retval = get64BitReg(CYCLES_LEFT_LSB_REG, CYCLES_LEFT_MSB_REG);
- FILE_LOG(logINFO, ("Getting number of triggers left: %lld\n", (long long int)retval));
- break;
-
- case ACTUAL_TIME:
- retval = get64BitReg(TIME_FROM_START_LSB_REG, TIME_FROM_START_MSB_REG) / (1E-3 * CLK_FREQ);
- FILE_LOG(logINFO, ("Getting actual time (time from start): %lld\n", (long long int)retval));
- break;
-
- case MEASUREMENT_TIME:
- retval = get64BitReg(START_FRAME_TIME_LSB_REG, START_FRAME_TIME_MSB_REG) / (1E-3 * CLK_FREQ);
- FILE_LOG(logINFO, ("Getting measurement time (timestamp/ start frame time): %lld\n", (long long int)retval));
- break;
-
- case FRAMES_FROM_START:
- case FRAMES_FROM_START_PG:
- retval = get64BitReg(FRAMES_FROM_START_PG_LSB_REG, FRAMES_FROM_START_PG_MSB_REG);
- FILE_LOG(logINFO, ("Getting frames from start run control %lld\n", (long long int)retval));
- break;
-
- default:
- FILE_LOG(logERROR, ("Remaining Timer index not implemented for this detector: %d\n", ind));
- break;
- }
-
- return retval;
-}
-
-
-int validateTimer(enum timerIndex ind, int64_t val, int64_t retval) {
- if (val < 0)
- return OK;
- switch(ind) {
- case FRAME_PERIOD:
- case DELAY_AFTER_TRIGGER:
- // convert to freq
- val *= (1E-3 * clkDivider[SYNC_CLK]);
- // convert back to timer
- val = (val) / (1E-3 * clkDivider[SYNC_CLK]);
- if (val != retval) {
- return FAIL;
- }
- break;
-
- case ACQUISITION_TIME:
- // convert to freq
- val *= (1E-3 * clkDivider[RUN_CLK]);
- // convert back to timer
- val = (val) / (1E-3 * clkDivider[RUN_CLK]);
- if (val != retval) {
- return FAIL;
- }
- break;
- default:
- break;
- }
return OK;
}
+uint32_t getADCEnableMask() {
+ return adcEnableMask_1g;
+}
+
+void setADCEnableMask_10G(uint32_t mask) {
+ if (mask == 0u) {
+ FILE_LOG(logERROR, ("Cannot set 10gb adc mask to 0\n"));
+ return;
+ }
+ int topAdcs = __builtin_popcount(mask & 0xF0F0F0F0);
+ int bottomAdcs = __builtin_popcount(mask & 0x0F0F0F0F);
+ if (topAdcs > 0 && bottomAdcs > 0 && topAdcs != bottomAdcs) {
+ FILE_LOG(logERROR, ("Invalid mask. Top and bottom number of adcs do not match\n"));
+ return;
+ }
+ // convert 32 bit mask to 8 bit mask
+ uint8_t actualMask = 0;
+ if (mask != 0) {
+ int ival = 0;
+ int ich = 0;
+ for (ich = 0; ich < NCHAN; ich = ich + 4) {
+ if ((1 << ich) & mask) {
+ actualMask |= (1 << ival);
+ }
+ ++ival;
+ }
+ }
+
+ FILE_LOG(logINFO, ("Setting adcEnableMask 10G to 0x%x (from 0x%08x)\n", actualMask, mask));
+ adcEnableMask_10g = actualMask;
+ uint32_t addr = READOUT_10G_ENABLE_REG;
+ bus_w(addr, bus_r(addr) & (~READOUT_10G_ENABLE_ANLG_MSK));
+ bus_w(addr, bus_r(addr) | ((adcEnableMask_10g << READOUT_10G_ENABLE_ANLG_OFST) & READOUT_10G_ENABLE_ANLG_MSK));
+}
+
+uint32_t getADCEnableMask_10G() {
+ adcEnableMask_10g = ((bus_r(READOUT_10G_ENABLE_REG) & READOUT_10G_ENABLE_ANLG_MSK) >> READOUT_10G_ENABLE_ANLG_OFST);
+
+ // convert 8 bit mask to 32 bit mask
+ uint32_t retval = 0;
+ if (adcEnableMask_10g) {
+ int ival = 0;
+ int iloop = 0;
+ for (ival = 0; ival < 8; ++ival) {
+ // if bit in 8 bit mask set
+ if ((1 << ival) & adcEnableMask_10g) {
+ // set it for 4 bits in 32 bit mask
+ for (iloop = 0; iloop < 4; ++iloop) {
+ retval |= (1 << (ival * 4 + iloop));
+ }
+ }
+ }
+ }
+ return retval;
+}
+
+void setADCInvertRegister(uint32_t val) {
+ FILE_LOG(logINFO, ("Setting ADC Port Invert Reg to 0x%x\n", val));
+ uint32_t defaultValue = ADC_PORT_INVERT_VAL;
+ uint32_t changeValue = defaultValue ^ val;
+ FILE_LOG(logINFO, ("\t default: 0x%x, final:0x%x\n", defaultValue, changeValue));
+ bus_w(ADC_PORT_INVERT_REG, changeValue);
+}
+
+uint32_t getADCInvertRegister() {
+ uint32_t readValue = bus_r(ADC_PORT_INVERT_REG);
+ int32_t defaultValue = ADC_PORT_INVERT_VAL;
+ uint32_t val = defaultValue ^ readValue;
+ FILE_LOG(logDEBUG1, ("\tread:0x%x, default:0x%x returned:0x%x\n", readValue, defaultValue, val));
+ return val;
+}
+
+/* parameters - timer */
+void setNumFrames(int64_t val) {
+ if (val > 0) {
+ FILE_LOG(logINFO, ("Setting number of frames %lld\n", (long long int)val));
+ set64BitReg(val, FRAMES_LSB_REG, FRAMES_MSB_REG);
+ }
+}
+
+int64_t getNumFrames() {
+ return get64BitReg(FRAMES_LSB_REG, FRAMES_MSB_REG);
+}
+
+void setNumTriggers(int64_t val) {
+ if (val > 0) {
+ FILE_LOG(logINFO, ("Setting number of triggers %lld\n", (long long int)val));
+ set64BitReg(val, CYCLES_LSB_REG, CYCLES_MSB_REG);
+ }
+}
+
+int64_t getNumTriggers() {
+ return get64BitReg(CYCLES_LSB_REG, CYCLES_MSB_REG);
+}
+
+int setNumAnalogSamples(int val) {
+ if (val < 0) {
+ FILE_LOG(logERROR, ("Invalid analog samples: %d\n", val));
+ return FAIL;
+ }
+ FILE_LOG(logINFO, ("Setting number of analog samples %d\n", val));
+ nSamples = val;
+ bus_w(SAMPLES_REG, bus_r(SAMPLES_REG) &~ SAMPLES_ANALOG_MSK);
+ bus_w(SAMPLES_REG, bus_r(SAMPLES_REG) | ((val << SAMPLES_ANALOG_OFST) & SAMPLES_ANALOG_MSK));
+
+ // 1Gb
+ if (!enableTenGigabitEthernet(-1)) {
+ if (updateDatabytesandAllocateRAM() == FAIL) {
+ return FAIL;
+ }
+ }
+ return OK;
+}
+
+int getNumAnalogSamples() {
+ return nSamples;
+}
+
+int setExpTime(int64_t val) {
+ if (val < 0) {
+ FILE_LOG(logERROR, ("Invalid exptime: %lld ns\n", (long long int)val));
+ return FAIL;
+ }
+ FILE_LOG(logINFO, ("Setting exptime %lld ns\n", (long long int)val));
+ val *= (1E-3 * clkFrequency[RUN_CLK]);
+ setPatternWaitTime(0, val);
+
+ // validate for tolerance
+ int64_t retval = getExpTime();
+ val /= (1E-3 * clkFrequency[RUN_CLK]);
+ if (val != retval) {
+ return FAIL;
+ }
+ return OK;
+}
+
+int64_t getExpTime() {
+ return setPatternWaitTime(0, -1) / (1E-3 * clkFrequency[RUN_CLK]);
+}
+
+int setPeriod(int64_t val) {
+ if (val < 0) {
+ FILE_LOG(logERROR, ("Invalid period: %lld ns\n", (long long int)val));
+ return FAIL;
+ }
+ FILE_LOG(logINFO, ("Setting period %lld ns\n", (long long int)val));
+ val *= (1E-3 * clkFrequency[SYNC_CLK]);
+ set64BitReg(val, PERIOD_LSB_REG, PERIOD_MSB_REG);
+
+ // validate for tolerance
+ int64_t retval = getPeriod();
+ val /= (1E-3 * clkFrequency[SYNC_CLK]);
+ if (val != retval) {
+ return FAIL;
+ }
+ return OK;
+}
+
+int64_t getPeriod() {
+ return get64BitReg(PERIOD_LSB_REG, PERIOD_MSB_REG)/ (1E-3 * clkFrequency[SYNC_CLK]);
+}
+
+int setDelayAfterTrigger(int64_t val) {
+ if (val < 0) {
+ FILE_LOG(logERROR, ("Invalid delay after trigger: %lld ns\n", (long long int)val));
+ return FAIL;
+ }
+ FILE_LOG(logINFO, ("Setting delay after trigger %lld ns\n", (long long int)val));
+ val *= (1E-3 * clkFrequency[SYNC_CLK]);
+ set64BitReg(val, DELAY_LSB_REG, DELAY_MSB_REG);
+
+ // validate for tolerance
+ int64_t retval = getDelayAfterTrigger();
+ val /= (1E-3 * clkFrequency[SYNC_CLK]);
+ if (val != retval) {
+ return FAIL;
+ }
+ return OK;
+}
+
+int64_t getDelayAfterTrigger() {
+ return get64BitReg(DELAY_LSB_REG, DELAY_MSB_REG) / (1E-3 * clkFrequency[SYNC_CLK]);
+}
+
+int64_t getNumFramesLeft() {
+ return get64BitReg(FRAMES_LEFT_LSB_REG, FRAMES_LEFT_MSB_REG);
+}
+
+int64_t getNumTriggersLeft() {
+ return get64BitReg(CYCLES_LEFT_LSB_REG, CYCLES_LEFT_MSB_REG);
+}
+
+int64_t getDelayAfterTriggerLeft() {
+ return get64BitReg(DELAY_LEFT_LSB_REG, DELAY_LEFT_MSB_REG) / (1E-3 * clkFrequency[SYNC_CLK]);
+}
+
+int64_t getPeriodLeft() {
+ return get64BitReg(PERIOD_LEFT_LSB_REG, PERIOD_LEFT_MSB_REG) / (1E-3 * clkFrequency[SYNC_CLK]);
+}
+
+int64_t getFramesFromStart() {
+ return get64BitReg(FRAMES_FROM_START_PG_LSB_REG, FRAMES_FROM_START_PG_MSB_REG);
+}
+
+int64_t getActualTime() {
+ return get64BitReg(TIME_FROM_START_LSB_REG, TIME_FROM_START_MSB_REG) / (1E-3 * CLK_FREQ);
+}
+
+int64_t getMeasurementTime() {
+ return get64BitReg(START_FRAME_TIME_LSB_REG, START_FRAME_TIME_MSB_REG) / (1E-3 * CLK_FREQ);
+}
+
/* parameters - settings */
@@ -970,8 +870,9 @@ enum detectorSettings getSettings() {
/* parameters - dac, adc, hv */
+
void setDAC(enum DACINDEX ind, int val, int mV) {
- if (val < 0 && val != LTC2620_PWR_DOWN_VAL)
+ if (val < 0 && val != LTC2620_GetPowerDownValue())
return;
FILE_LOG(logDEBUG1, ("Setting dac[%d]: %d %s \n", (int)ind, val, (mV ? "mV" : "dac units")));
@@ -1002,7 +903,7 @@ int getDAC(enum DACINDEX ind, int mV) {
}
int getMaxDacSteps() {
- return LTC2620_MAX_STEPS;
+ return LTC2620_GetMaxNumSteps();
}
int dacToVoltage(int dac) {
@@ -1045,13 +946,23 @@ int setHighVoltage(int val){
highvoltage = val;
return highvoltage;
#endif
- // setting hv
- if (val >= 0) {
- FILE_LOG(logINFO, ("Setting High voltage: %d V\n", val));
- MAX1932_Set(val);
- highvoltage = val;
- }
+ // setting hv
+ if (val >= 0) {
+ FILE_LOG(logINFO, ("Setting High voltage: %d V\n", val));
+ uint32_t addr = POWER_REG;
+
+ // switch to external high voltage
+ bus_w(addr, bus_r(addr) & (~POWER_HV_INTERNAL_SLCT_MSK));
+
+ MAX1932_Set(val);
+
+ // switch on internal high voltage, if set
+ if (val > 0)
+ bus_w(addr, bus_r(addr) | POWER_HV_INTERNAL_SLCT_MSK);
+
+ highvoltage = val;
+ }
return highvoltage;
}
@@ -1064,22 +975,18 @@ int setHighVoltage(int val){
void setTiming( enum timingMode arg){
-
- if(arg != GET_TIMING_MODE){
- switch((int)arg){
- case AUTO_TIMING:
- FILE_LOG(logINFO, ("Set Timing: Auto\n"));
- bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) & ~EXT_SIGNAL_MSK);
- break;
- case TRIGGER_EXPOSURE:
- FILE_LOG(logINFO, ("Set Timing: Trigger\n"));
- bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) | EXT_SIGNAL_MSK);
- break;
- default:
- FILE_LOG(logERROR, ("Unknown timing mode %d\n", arg));
- return;
- }
- }
+ switch(arg){
+ case AUTO_TIMING:
+ FILE_LOG(logINFO, ("Set Timing: Auto\n"));
+ bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) & ~EXT_SIGNAL_MSK);
+ break;
+ case TRIGGER_EXPOSURE:
+ FILE_LOG(logINFO, ("Set Timing: Trigger\n"));
+ bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) | EXT_SIGNAL_MSK);
+ break;
+ default:
+ FILE_LOG(logERROR, ("Unknown timing mode %d\n", arg));
+ }
}
@@ -1094,57 +1001,60 @@ enum timingMode getTiming() {
/* configure mac */
-long int calcChecksum(int sourceip, int destip) {
- ip_header ip;
- ip.ip_ver = 0x4;
- ip.ip_ihl = 0x5;
- ip.ip_tos = 0x0;
- ip.ip_len = IP_PACKETSIZE;
- ip.ip_ident = 0x0000;
- ip.ip_flag = 0x2; //not nibble aligned (flag& offset
- ip.ip_offset = 0x000;
- ip.ip_ttl = 0x40;
- ip.ip_protocol = 0x11;
- ip.ip_chksum = 0x0000 ; // pseudo
- ip.ip_sourceip = sourceip;
- ip.ip_destip = destip;
-
- int count = sizeof(ip);
-
- unsigned short *addr;
- addr = (unsigned short*) &(ip); /* warning: assignment from incompatible pointer type */
-
+void calcChecksum(udp_header* udp) {
+ int count = IP_HEADER_SIZE;
long int sum = 0;
- while( count > 1 ) {
+
+ // start at ip_tos as the memory is not continous for ip header
+ uint16_t *addr = (uint16_t*) (&(udp->ip_tos));
+
+ sum += *addr++;
+ count -= 2;
+
+ // ignore ethertype (from udp header)
+ addr++;
+
+ // from identification to srcip_lsb
+ while( count > 2 ) {
sum += *addr++;
count -= 2;
}
+
+ // ignore src udp port (from udp header)
+ addr++;
+
if (count > 0)
sum += *addr; // Add left-over byte, if any
- while (sum>>16)
+ while (sum >> 16)
sum = (sum & 0xffff) + (sum >> 16);// Fold 32-bit sum to 16 bits
- long int checksum = (~sum) & 0xffff;
- FILE_LOG(logINFO, ("IP checksum is 0x%lx\n",checksum));
- return checksum;
+ long int checksum = sum & 0xffff;
+ checksum += UDP_IP_HEADER_LENGTH_BYTES;
+ FILE_LOG(logINFO, ("\tIP checksum is 0x%lx\n",checksum));
+ udp->ip_checksum = checksum;
}
-
-int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport){
+int configureMAC(){
+ uint32_t sourceip = udpDetails.srcip;
+ uint32_t destip = udpDetails.dstip;
+ uint64_t sourcemac = udpDetails.srcmac;
+ uint64_t destmac = udpDetails.dstmac;
+ int sourceport = udpDetails.srcport;
+ int destport = udpDetails.dstport;
#ifdef VIRTUAL
- return OK;
+ return OK;
#endif
FILE_LOG(logINFOBLUE, ("Configuring MAC\n"));
// 1 giga udp
if (!enableTenGigabitEthernet(-1)) {
- // if it was in 10G mode, it was not allocating RAM
- if (allocateRAM() == FAIL)
+ FILE_LOG(logINFOBLUE, ("Configuring 1G MAC\n"));
+ if (updateDatabytesandAllocateRAM() == FAIL)
return -1;
char cDestIp[MAX_STR_LENGTH];
memset(cDestIp, 0, MAX_STR_LENGTH);
sprintf(cDestIp, "%d.%d.%d.%d", (destip>>24)&0xff,(destip>>16)&0xff,(destip>>8)&0xff,(destip)&0xff);
- FILE_LOG(logINFO, ("1G UDP: Destination (IP: %s, port:%d)\n", cDestIp, udpport));
- if (setUDPDestinationDetails(cDestIp, udpport) == FAIL) {
+ FILE_LOG(logINFO, ("1G UDP: Destination (IP: %s, port:%d)\n", cDestIp, destport));
+ if (setUDPDestinationDetails(0, cDestIp, destport) == FAIL) {
FILE_LOG(logERROR, ("could not set udp 1G destination IP and port\n"));
return FAIL;
}
@@ -1152,71 +1062,84 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t
}
// 10 G
- else {
- uint32_t sourceport = DEFAULT_TX_UDP_PORT;
+ FILE_LOG(logINFOBLUE, ("Configuring 10G MAC\n"));
- FILE_LOG(logINFO, ("\tSource IP : %d.%d.%d.%d \t\t(0x%08x)\n",
- (sourceip>>24)&0xff,(sourceip>>16)&0xff,(sourceip>>8)&0xff,(sourceip)&0xff, sourceip));
- FILE_LOG(logINFO, ("\tSource MAC : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
- (unsigned int)((sourcemac>>40)&0xFF),
- (unsigned int)((sourcemac>>32)&0xFF),
- (unsigned int)((sourcemac>>24)&0xFF),
- (unsigned int)((sourcemac>>16)&0xFF),
- (unsigned int)((sourcemac>>8)&0xFF),
- (unsigned int)((sourcemac>>0)&0xFF),
- (long long unsigned int)sourcemac));
- FILE_LOG(logINFO, ("\tSource Port : %d \t\t\t(0x%08x)\n",sourceport, sourceport));
+ FILE_LOG(logINFO, ("\tSource IP : %d.%d.%d.%d \t\t(0x%08x)\n",
+ (sourceip>>24)&0xff,(sourceip>>16)&0xff,(sourceip>>8)&0xff,(sourceip)&0xff, sourceip));
+ FILE_LOG(logINFO, ("\tSource MAC : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
+ (unsigned int)((sourcemac>>40)&0xFF),
+ (unsigned int)((sourcemac>>32)&0xFF),
+ (unsigned int)((sourcemac>>24)&0xFF),
+ (unsigned int)((sourcemac>>16)&0xFF),
+ (unsigned int)((sourcemac>>8)&0xFF),
+ (unsigned int)((sourcemac>>0)&0xFF),
+ (long long unsigned int)sourcemac));
+ FILE_LOG(logINFO, ("\tSource Port : %d \t\t\t(0x%08x)\n",sourceport, sourceport));
- FILE_LOG(logINFO, ("\tDest. IP : %d.%d.%d.%d \t\t(0x%08x)\n",
- (destip>>24)&0xff,(destip>>16)&0xff,(destip>>8)&0xff,(destip)&0xff, destip));
- FILE_LOG(logINFO, ("\tDest. MAC : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
- (unsigned int)((destmac>>40)&0xFF),
- (unsigned int)((destmac>>32)&0xFF),
- (unsigned int)((destmac>>24)&0xFF),
- (unsigned int)((destmac>>16)&0xFF),
- (unsigned int)((destmac>>8)&0xFF),
- (unsigned int)((destmac>>0)&0xFF),
- (long long unsigned int)destmac));
- FILE_LOG(logINFO, ("\tDest. Port : %d \t\t\t(0x%08x)\n",udpport, udpport));
+ FILE_LOG(logINFO, ("\tDest. IP : %d.%d.%d.%d \t\t(0x%08x)\n",
+ (destip>>24)&0xff,(destip>>16)&0xff,(destip>>8)&0xff,(destip)&0xff, destip));
+ FILE_LOG(logINFO, ("\tDest. MAC : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
+ (unsigned int)((destmac>>40)&0xFF),
+ (unsigned int)((destmac>>32)&0xFF),
+ (unsigned int)((destmac>>24)&0xFF),
+ (unsigned int)((destmac>>16)&0xFF),
+ (unsigned int)((destmac>>8)&0xFF),
+ (unsigned int)((destmac>>0)&0xFF),
+ (long long unsigned int)destmac));
+ FILE_LOG(logINFO, ("\tDest. Port : %d \t\t\t(0x%08x)\n",destport, destport));
- long int checksum=calcChecksum(sourceip, destip);
- bus_w(TX_IP_REG, sourceip);
- bus_w(RX_IP_REG, destip);
+ // start addr
+ uint32_t addr = RXR_ENDPOINT_START_REG;
+ // get struct memory
+ udp_header *udp = (udp_header*) (Blackfin_getBaseAddress() + addr / 2);
+ memset(udp, 0, sizeof(udp_header));
- uint32_t val = 0;
+ // mac addresses
+ // msb (32) + lsb (16)
+ udp->udp_destmac_msb = ((destmac >> 16) & BIT32_MASK);
+ udp->udp_destmac_lsb = ((destmac >> 0) & BIT16_MASK);
+ // msb (16) + lsb (32)
+ udp->udp_srcmac_msb = ((sourcemac >> 32) & BIT16_MASK);
+ udp->udp_srcmac_lsb = ((sourcemac >> 0) & BIT32_MASK);
- val = ((sourcemac >> LSB_OF_64_BIT_REG_OFST) & BIT_32_MSK);
- bus_w(TX_MAC_LSB_REG, val);
- FILE_LOG(logDEBUG1, ("Read from TX_MAC_LSB_REG: 0x%08x\n", bus_r(TX_MAC_LSB_REG)));
+ // ip addresses
+ udp->ip_srcip_msb = ((sourceip >> 16) & BIT16_MASK);
+ udp->ip_srcip_lsb = ((sourceip >> 0) & BIT16_MASK);
+ udp->ip_destip_msb = ((destip >> 16) & BIT16_MASK);
+ udp->ip_destip_lsb = ((destip >> 0) & BIT16_MASK);
- val = ((sourcemac >> MSB_OF_64_BIT_REG_OFST) & BIT_32_MSK);
- bus_w(TX_MAC_MSB_REG,val);
- FILE_LOG(logDEBUG1, ("Read from TX_MAC_MSB_REG: 0x%08x\n", bus_r(TX_MAC_MSB_REG)));
+ // source port
+ udp->udp_srcport = sourceport;
+ udp->udp_destport = destport;
- val = ((destmac >> LSB_OF_64_BIT_REG_OFST) & BIT_32_MSK);
- bus_w(RX_MAC_LSB_REG, val);
- FILE_LOG(logDEBUG1, ("Read from RX_MAC_LSB_REG: 0x%08x\n", bus_r(RX_MAC_LSB_REG)));
+ // other defines
+ udp->udp_ethertype = 0x800;
+ udp->ip_ver = 0x4;
+ udp->ip_ihl = 0x5;
+ udp->ip_flags = 0x2; //FIXME
+ udp->ip_ttl = 0x40;
+ udp->ip_protocol = 0x11;
+ // total length is redefined in firmware
- val = ((destmac >> MSB_OF_64_BIT_REG_OFST) & BIT_32_MSK);
- bus_w(RX_MAC_MSB_REG, val);
- FILE_LOG(logDEBUG1, ("Read from RX_MAC_MSB_REG: 0x%08x\n", bus_r(RX_MAC_MSB_REG)));
+ calcChecksum(udp);
- val = (((sourceport << UDP_PORT_TX_OFST) & UDP_PORT_TX_MSK) |
- ((udpport << UDP_PORT_RX_OFST) & UDP_PORT_RX_MSK));
- bus_w(UDP_PORT_REG, val);
- FILE_LOG(logDEBUG1, ("Read from UDP_PORT_REG: 0x%08x\n", bus_r(UDP_PORT_REG)));
-
- bus_w(TX_IP_CHECKSUM_REG,(checksum << TX_IP_CHECKSUM_OFST) & TX_IP_CHECKSUM_MSK);
- FILE_LOG(logDEBUG1, ("Read from TX_IP_CHECKSUM_REG: 0x%08x\n", bus_r(TX_IP_CHECKSUM_REG)));
-
- cleanFifos();//FIXME: resetPerpheral() for ctb?
- resetPeripheral();
- usleep(WAIT_TIME_CONFIGURE_MAC); /* todo maybe without */
- }
+ cleanFifos();//FIXME: resetPerpheral() for ctb?
+ resetPeripheral();
+ FILE_LOG(logINFO, ("Waiting for %d s for mac to be up\n", WAIT_TIME_CONFIGURE_MAC / (1000 * 1000)));
+ usleep(WAIT_TIME_CONFIGURE_MAC); // todo maybe without
return OK;
}
+int setDetectorPosition(int pos[]) {
+ memcpy(detPos, pos, sizeof(detPos));
+ return OK;
+}
+
+int* getDetectorPosition() {
+ return detPos;
+}
+
int enableTenGigabitEthernet(int val) {
uint32_t addr = CONFIG_REG;
@@ -1234,43 +1157,69 @@ int enableTenGigabitEthernet(int val) {
}
-
-/* moench specific - configure frequency, phase, pll, */
-
-int powerChip(int on) {
+/* moench specific - powerchip, configure frequency, phase, pll*/
+int powerChip (int on) {
uint32_t addr = POWER_REG;
- if (on >= 0) {
- FILE_LOG(logINFO, ("Powering %s\n", (on > 0 ? "on" : "off")));
- if (on)
- bus_w(addr, bus_r(addr) | POWER_ENBL_VLTG_RGLTR_MSK);
- else
- bus_w(addr, bus_r(addr) & (~POWER_ENBL_VLTG_RGLTR_MSK));
+ if (on > 0) {
+ FILE_LOG(logINFOBLUE, ("Powering on chip\n"));
+ bus_w(addr, bus_r(addr) | POWER_CHIP_MSK);
+ } else if (on == 0) {
+ FILE_LOG(logINFOBLUE, ("Powering off chip\n"));
+ bus_w(addr, bus_r(addr) &~ POWER_CHIP_MSK);
}
-
- uint32_t regval = bus_r(addr);
- FILE_LOG(logDEBUG1, ("\tPower Register: 0x%08x\n", regval));
-
- if (regval & POWER_ENBL_VLTG_RGLTR_MSK)
- return 1;
- return 0;
+ return ((bus_r(addr) & POWER_CHIP_MSK) >> POWER_CHIP_OFST);
}
-// ind can only be ADC_CLK or DBIT_CLK
-void configurePhase(enum CLKINDEX ind, int val, int degrees) {
- char clock_names[4][10]={"run_clk","adc_clk", "sync_clk", "dbit_clk"};
- int maxShift = getMaxPhase(ind);
+/* parameters - readout */
+int setAnalogOnlyReadout() {
+ FILE_LOG(logINFOBLUE, ("Setting Analog Only Readout\n"));
+
+ uint32_t addr = CONFIG_REG;
+ uint32_t addr_readout_10g = READOUT_10G_ENABLE_REG;
+ // default: analog only
+ bus_w(addr, bus_r(addr) & (~CONFIG_DSBL_ANLG_OTPT_MSK) & (~CONFIG_ENBLE_DGTL_OTPT_MSK));
+ bus_w(addr_readout_10g, bus_r(addr_readout_10g) & (~READOUT_10G_ENABLE_ANLG_MSK) & ~(READOUT_10G_ENABLE_DGTL_MSK));
+ bus_w(addr_readout_10g, bus_r(addr_readout_10g) | ((adcEnableMask_10g << READOUT_10G_ENABLE_ANLG_OFST) & READOUT_10G_ENABLE_ANLG_MSK));
+
+ // 1Gb
+ if (!enableTenGigabitEthernet(-1)) {
+ if (updateDatabytesandAllocateRAM() == FAIL) {
+ return FAIL;
+ }
+ }
+
+ // 10Gb
+ else {
+ // validate adcenablemask for 10g
+ if (adcEnableMask_10g != ((bus_r(READOUT_10G_ENABLE_REG) & READOUT_10G_ENABLE_ANLG_MSK) >> READOUT_10G_ENABLE_ANLG_OFST)) {
+ FILE_LOG(logERROR, ("Setting readout mode failed. Could not set 10g adc enable mask to 0x%x\n.", adcEnableMask_10g));
+ return FAIL;
+ }
+ }
+ return OK;
+}
+
+
+
+int setPhase(enum CLKINDEX ind, int val, int degrees) {
+ if (ind != ADC_CLK && ind != DBIT_CLK) {
+ FILE_LOG(logERROR, ("Unknown clock index %d to set phase\n", ind));
+ return FAIL;
+ }
+ char* clock_names[] = {CLK_NAMES};
+ FILE_LOG(logINFO, ("Setting %s clock (%d) phase to %d %s\n", clock_names[ind], ind, val, degrees == 0 ? "" : "degrees"));
+ int maxShift = getMaxPhase(ind);
// validation
if (degrees && (val < 0 || val > 359)) {
- FILE_LOG(logERROR, ("\tPhase provided for C%d(%s) outside limits (0 - 359°C)\n", ind, clock_names[ind]));
- return;
+ FILE_LOG(logERROR, ("\tPhase outside limits (0 - 359°C)\n"));
+ return FAIL;
}
if (!degrees && (val < 0 || val > maxShift - 1)) {
- FILE_LOG(logERROR, ("\tPhase provided for C%d(%s) outside limits (0 - %d phase shifts)\n", ind, clock_names[ind], maxShift - 1));
- return;
+ FILE_LOG(logERROR, ("\tPhase outside limits (0 - %d phase shifts)\n", maxShift - 1));
+ return FAIL;
}
- FILE_LOG(logINFO, ("\tConfiguring Phase of C%d(%s) to %d (degree mode: %d)\n", ind, clock_names[ind], val, degrees));
int valShift = val;
// convert to phase shift
if (degrees) {
@@ -1284,8 +1233,9 @@ void configurePhase(enum CLKINDEX ind, int val, int degrees) {
// same phase
if (!relativePhase) {
FILE_LOG(logINFO, ("\tNothing to do in Phase Shift\n"));
- return;
+ return OK;
}
+ FILE_LOG(logINFOBLUE, ("Configuring Phase\n"));
int phase = 0;
if (relativePhase > 0) {
@@ -1298,9 +1248,14 @@ void configurePhase(enum CLKINDEX ind, int val, int degrees) {
ALTERA_PLL_SetPhaseShift(phase, (int)ind, 0);
clkPhase[ind] = valShift;
+ return OK;
}
int getPhase(enum CLKINDEX ind, int degrees) {
+ if (ind != ADC_CLK && ind != DBIT_CLK) {
+ FILE_LOG(logERROR, ("Unknown clock index %d to get phase\n", ind));
+ return -1;
+ }
if (!degrees)
return clkPhase[ind];
// convert back to degrees
@@ -1310,31 +1265,29 @@ int getPhase(enum CLKINDEX ind, int degrees) {
}
int getMaxPhase(enum CLKINDEX ind) {
- int ret = ((double)PLL_VCO_FREQ_MHZ / (double)clkDivider[ind]) * MAX_PHASE_SHIFTS_STEPS;
+ if (ind != ADC_CLK && ind != DBIT_CLK) {
+ FILE_LOG(logERROR, ("Unknown clock index %d to get max phase\n", ind));
+ return -1;
+ }
+ int ret = ((double)PLL_VCO_FREQ_MHZ / (double)clkFrequency[ind]) * MAX_PHASE_SHIFTS_STEPS;
- char clock_names[4][10]={"run_clk","adc_clk", "sync_clk", "dbit_clk"};
+ char* clock_names[] = {CLK_NAMES};
FILE_LOG(logDEBUG1, ("Max Phase Shift (%s): %d (Clock: %d MHz, VCO:%d MHz)\n",
- clock_names[ind], ret, clkDivider[ind], PLL_VCO_FREQ_MHZ));
+ clock_names[ind], ret, clkFrequency[ind], PLL_VCO_FREQ_MHZ));
return ret;
}
-int validatePhaseinDegrees(enum speedVariable ind, int val, int retval) {
- if (val == -1)
- return OK;
- enum CLKINDEX clkIndex;
- switch(ind) {
- case ADC_PHASE:
- clkIndex = ADC_CLK;
- break;
- case DBIT_PHASE:
- clkIndex = DBIT_CLK;
- break;
- default:
- FILE_LOG(logERROR, ("Unknown speed enum %d for validating phase in degrees\n", (int)ind));
+int validatePhaseinDegrees(enum CLKINDEX ind, int val, int retval) {
+ if (ind != ADC_CLK && ind != DBIT_CLK) {
+ FILE_LOG(logERROR, ("Unknown clock index %d to validate phase in degrees\n", ind));
+ return FAIL;
}
- FILE_LOG(logDEBUG1, ("validating phase in degrees for clk %d\n", clkIndex));
- int maxShift = getMaxPhase(clkIndex);
+ if (val == -1) {
+ return OK;
+ }
+ FILE_LOG(logDEBUG1, ("validating phase in degrees for clk %d\n", ind));
+ int maxShift = getMaxPhase(ind);
// convert degrees to shift
int valShift = 0;
ConvertToDifferentRange(0, 359, 0, maxShift - 1, val, &valShift);
@@ -1346,36 +1299,62 @@ int validatePhaseinDegrees(enum speedVariable ind, int val, int retval) {
return FAIL;
}
-void configureFrequency(enum CLKINDEX ind, int val) {
- char clock_names[4][10]={"run_clk","adc_clk", "sync_clk", "dbit_clk"};
- if (val <= 0)
- return;
-
- FILE_LOG(logINFO, ("\tConfiguring Frequency of C%d(%s) to %d MHz\n", ind, clock_names[ind], val));
+int setFrequency(enum CLKINDEX ind, int val) {
+ if (ind < 0 || ind >= NUM_CLOCKS) {
+ FILE_LOG(logERROR, ("Unknown clock index %d to set frequency\n", ind));
+ return FAIL;
+ }
+ if (val <= 0) {
+ return FAIL;
+ }
+ char* clock_names[] = {CLK_NAMES};
+ FILE_LOG(logINFO, ("\tSetting %s clock (%d) frequency to %d MHz\n", clock_names[ind], ind, val));
// check adc clk too high
if (ind == ADC_CLK && val > MAXIMUM_ADC_CLK) {
FILE_LOG(logERROR, ("Frequency %d MHz too high for ADC\n", val));
- return;
+ return FAIL;
}
- // reset phase
- if (ind == ADC_CLK || ind == DBIT_CLK) {
- FILE_LOG(logINFO, ("\tReseting phase of %s\n", clock_names[ind]));
- configurePhase(ind, 0, 0);
- }
+ // Remembering adcphase/ dbit phase in degrees
+ int adcPhase = getPhase(ADC_CLK, 1);
+ FILE_LOG(logDEBUG1, ("\tRemembering ADC phase: %d degrees\n", adcPhase));
+ int dbitPhase = getPhase(DBIT_CLK, 1);
+ FILE_LOG(logDEBUG1, ("\tRemembering DBIT phase: %d degrees\n", dbitPhase));
// Calculate and set output frequency
- clkDivider[ind] = ALTERA_PLL_SetOuputFrequency (ind, PLL_VCO_FREQ_MHZ, val);
- FILE_LOG(logINFO, ("\tC%d(%s): Frequency set to %d MHz\n", ind, clock_names[ind], clkDivider[ind]));
+ clkFrequency[ind] = ALTERA_PLL_SetOuputFrequency (ind, PLL_VCO_FREQ_MHZ, val);
+ FILE_LOG(logINFO, ("\t%s clock (%d) frequency set to %d MHz\n", clock_names[ind], ind, clkFrequency[ind]));
+
+ // phase reset by pll (when setting output frequency)
+ clkPhase[ADC_CLK] = 0;
+ clkPhase[DBIT_CLK] = 0;
+
+ // set the phase (reset by pll)
+ FILE_LOG(logINFO, ("\tCorrecting ADC phase to %d degrees\n", adcPhase));
+ setPhase(ADC_CLK, adcPhase, 1);
+ FILE_LOG(logINFO, ("\tCorrecting DBIT phase to %d degrees\n", dbitPhase));
+ setPhase(DBIT_CLK, dbitPhase, 1);
+
+ // required to reconfigure as adc clock is stopped temporarily when resetting pll (in changing output frequency)
+ AD9257_Configure();
+
+ if (ind != SYNC_CLK) {
+ configureSyncFrequency(ind);
+ }
+ return OK;
}
int getFrequency(enum CLKINDEX ind) {
- return clkDivider[ind];
+ if (ind < 0 || ind >= NUM_CLOCKS) {
+ FILE_LOG(logERROR, ("Unknown clock index %d to get frequency\n", ind));
+ return -1;
+ }
+ return clkFrequency[ind];
}
void configureSyncFrequency(enum CLKINDEX ind) {
- char clock_names[4][10]={"run_clk","adc_clk", "sync_clk", "dbit_clk"};
+ char* clock_names[] = {CLK_NAMES};
int clka = 0, clkb = 0;
switch(ind) {
case ADC_CLK:
@@ -1391,6 +1370,7 @@ void configureSyncFrequency(enum CLKINDEX ind) {
clkb = ADC_CLK;
break;
default:
+ FILE_LOG(logERROR, ("Unknown clock index %d to configure sync frequcny\n", ind));
return;
}
@@ -1421,67 +1401,69 @@ void configureSyncFrequency(enum CLKINDEX ind) {
// configure sync to current
if (configure)
- configureFrequency(SYNC_CLK, min);
+ setFrequency(SYNC_CLK, min);
}
-
-void setAdcOffsetRegister(int adc, int val) {
- if (val < 0)
+// adc pipeline only
+void setPipeline(enum CLKINDEX ind, int val) {
+ if (ind != ADC_CLK) {
+ FILE_LOG(logERROR, ("Unknown clock index %d to set pipeline\n", ind));
+ return;
+ }
+ if (val < 0) {
return;
-
- FILE_LOG(logINFO, ("Setting %s Pipeline to %d\n", (adc ? "ADC" : "Dbit"), val));
+ }
+ FILE_LOG(logINFO, ("Setting adc clock (%d) Pipeline to %d\n", ADC_CLK, val));
uint32_t offset = ADC_OFFSET_ADC_PPLN_OFST;
uint32_t mask = ADC_OFFSET_ADC_PPLN_MSK;
- if (!adc) {
- offset = ADC_OFFSET_DBT_PPLN_OFST;
- mask = ADC_OFFSET_DBT_PPLN_MSK;
- }
-
uint32_t addr = ADC_OFFSET_REG;
// reset value
bus_w(addr, bus_r(addr) & ~ mask);
// set value
bus_w(addr, bus_r(addr) | ((val << offset) & mask));
- FILE_LOG(logDEBUG1, (" %s Offset: 0x%8x\n", (adc ? "ADC" : "Dbit"), bus_r(addr)));
+ FILE_LOG(logDEBUG1, (" adc clock (%d) Offset: 0x%8x\n", ADC_CLK, bus_r(addr)));
}
-int getAdcOffsetRegister(int adc) {
- if (adc)
- return ((bus_r(ADC_OFFSET_REG) & ADC_OFFSET_ADC_PPLN_MSK) >> ADC_OFFSET_ADC_PPLN_OFST);
- return ((bus_r(ADC_OFFSET_REG) & ADC_OFFSET_DBT_PPLN_MSK) >> ADC_OFFSET_DBT_PPLN_OFST);
+int getPipeline(enum CLKINDEX ind) {
+ if (ind != ADC_CLK) {
+ FILE_LOG(logERROR, ("Unknown clock index %d to get pipeline\n", ind));
+ return -1;
+ }
+ return ((bus_r(ADC_OFFSET_REG) & ADC_OFFSET_ADC_PPLN_MSK) >> ADC_OFFSET_ADC_PPLN_OFST);
}
// patterns
+
uint64_t writePatternIOControl(uint64_t word) {
if (word != -1) {
- FILE_LOG(logINFO, ("Setting Pattern - I/O Control: 0x%llx\n", (long long int) word));
+ FILE_LOG(logINFO, ("Setting Pattern I/O Control: 0x%llx\n", (long long int) word));
set64BitReg(word, PATTERN_IO_CNTRL_LSB_REG, PATTERN_IO_CNTRL_MSB_REG);
}
uint64_t retval = get64BitReg(PATTERN_IO_CNTRL_LSB_REG, PATTERN_IO_CNTRL_MSB_REG);
- FILE_LOG(logDEBUG1, ("I/O Control: 0x%llx\n", (long long int) retval));
+ FILE_LOG(logDEBUG1, (" I/O Control retval: 0x%llx\n", (long long int) retval));
return retval;
}
uint64_t writePatternClkControl(uint64_t word) {
if (word != -1) {
- FILE_LOG(logINFO, ("Setting Pattern - Clock Control: 0x%llx\n", (long long int) word));
+ FILE_LOG(logINFO, ("Setting Pattern Clock Control: 0x%llx\n", (long long int) word));
set64BitReg(word, PATTERN_IO_CLK_CNTRL_LSB_REG, PATTERN_IO_CLK_CNTRL_MSB_REG);
}
uint64_t retval = get64BitReg(PATTERN_IO_CLK_CNTRL_LSB_REG, PATTERN_IO_CLK_CNTRL_MSB_REG);
- FILE_LOG(logDEBUG1, ("Clock Control: 0x%llx\n", (long long int) retval));
+ FILE_LOG(logDEBUG1, (" Clock Control retval: 0x%llx\n", (long long int) retval));
return retval;
}
uint64_t readPatternWord(int addr) {
// error (handled in tcp)
- if (addr < 0 || addr > MAX_PATTERN_LENGTH) {
+ if (addr < 0 || addr >= MAX_PATTERN_LENGTH) {
FILE_LOG(logERROR, ("Cannot get Pattern - Word. Invalid addr 0x%x. "
- "Should be <= 0x%x\n", addr, MAX_PATTERN_LENGTH));
+ "Should be between 0 and 0x%x\n", addr, MAX_PATTERN_LENGTH));
return -1;
}
- FILE_LOG(logDEBUG1, (" Reading Pattern - Word (addr:0x%x)\n", addr));
+ FILE_LOG(logINFORED, (" Reading (Executing) Pattern Word (addr:0x%x)\n", addr));
uint32_t reg = PATTERN_CNTRL_REG;
// overwrite with only addr
@@ -1496,7 +1478,7 @@ uint64_t readPatternWord(int addr) {
// read value
uint64_t retval = get64BitReg(PATTERN_OUT_LSB_REG, PATTERN_OUT_MSB_REG);
- FILE_LOG(logDEBUG1, (" Word(addr:0x%x): 0x%llx\n", addr, (long long int) retval));
+ FILE_LOG(logDEBUG1, (" Word(addr:0x%x) retval: 0x%llx\n", addr, (long long int) retval));
return retval;
}
@@ -1507,13 +1489,13 @@ uint64_t writePatternWord(int addr, uint64_t word) {
return readPatternWord(addr);
// error (handled in tcp)
- if (addr < 0 || addr > MAX_PATTERN_LENGTH) {
+ if (addr < 0 || addr >= MAX_PATTERN_LENGTH) {
FILE_LOG(logERROR, ("Cannot set Pattern - Word. Invalid addr 0x%x. "
- "Should be <= 0x%x\n", addr, MAX_PATTERN_LENGTH));
+ "Should be between 0 and 0x%x\n", addr, MAX_PATTERN_LENGTH));
return -1;
}
- FILE_LOG(logINFO, ("Setting Pattern - Word (addr:0x%x, word:0x%llx)\n", addr, (long long int) word));
+ FILE_LOG(logINFO, ("Setting Pattern Word (addr:0x%x, word:0x%llx)\n", addr, (long long int) word));
uint32_t reg = PATTERN_CNTRL_REG;
// write word
@@ -1536,9 +1518,9 @@ uint64_t writePatternWord(int addr, uint64_t word) {
int setPatternWaitAddress(int level, int addr) {
// error (handled in tcp)
- if (addr > MAX_PATTERN_LENGTH) {
- FILE_LOG(logERROR, ("Cannot set Pattern - Wait Address. Invalid addr 0x%x. "
- "Should be <= 0x%x\n", addr, MAX_PATTERN_LENGTH));
+ if (addr >= MAX_PATTERN_LENGTH) {
+ FILE_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;
}
@@ -1563,20 +1545,20 @@ int setPatternWaitAddress(int level, int addr) {
mask = PATTERN_WAIT_2_ADDR_MSK;
break;
default:
- FILE_LOG(logERROR, ("Cannot set Pattern - Wait Address. Invalid level 0x%x. "
+ FILE_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) {
- FILE_LOG(logINFO, ("Setting Pattern - Wait Address (level:%d, addr:0x%x)\n", level, addr));
+ FILE_LOG(logINFO, ("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);
- FILE_LOG(logDEBUG1, (" Wait Address (level:%d, addr:0x%x)\n", level, regval));
+ uint32_t regval = ((bus_r(reg) & mask) >> offset);
+ FILE_LOG(logDEBUG1, (" Wait Address retval (level:%d, addr:0x%x)\n", level, regval));
return regval;
}
@@ -1598,38 +1580,29 @@ uint64_t setPatternWaitTime(int level, uint64_t t) {
regm = PATTERN_WAIT_TIMER_2_MSB_REG;
break;
default:
- FILE_LOG(logERROR, ("Cannot set Pattern - Wait Time. Invalid level %d. "
+ FILE_LOG(logERROR, ("Cannot set Pattern Wait Time. Invalid level %d. "
"Should be between 0 and 2.\n", level));
return -1;
}
// set
if (t >= 0) {
- FILE_LOG(logINFO, ("Setting Pattern - Wait Time (level:%d, t:%lld)\n", level, (long long int)t));
+ FILE_LOG(logINFO, ("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);
- FILE_LOG(logDEBUG1, (" Wait Time (level:%d, t:%lld)\n", level, (long long int)regval));
+ FILE_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) {
- // level 0-2, addr upto patternlength + 1 (checked at tcp)
- if ((level != -1) &&
- (*startAddr > MAX_PATTERN_LENGTH || *stopAddr > MAX_PATTERN_LENGTH)) {
- FILE_LOG(logERROR, ("Cannot set Pattern (Pattern Loop, level:%d, startaddr:0x%x, stopaddr:0x%x). "
- "Addr must be <= 0x%x\n",
- level, *startAddr, *stopAddr, MAX_PATTERN_LENGTH));
- }
-
- //level -1, addr upto patternlength (checked at tcp)
- else if ((level == -1) &&
- (*startAddr > MAX_PATTERN_LENGTH || *stopAddr > MAX_PATTERN_LENGTH)) {
- FILE_LOG(logERROR, ("Cannot set Pattern (Pattern Loop, complete pattern, startaddr:0x%x, stopaddr:0x%x). "
- "Addr must be <= 0x%x\n",
+ // (checked at tcp)
+ if (*startAddr >= MAX_PATTERN_LENGTH || *stopAddr >= MAX_PATTERN_LENGTH) {
+ FILE_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));
}
@@ -1676,7 +1649,7 @@ void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop) {
break;
default:
// already checked at tcp interface
- FILE_LOG(logERROR, ("Cannot set Pattern - Pattern loop. Invalid level %d. "
+ FILE_LOG(logERROR, ("Cannot set Pattern loop. Invalid level %d. "
"Should be between -1 and 2.\n", level));
*startAddr = 0;
*stopAddr = 0;
@@ -1687,7 +1660,7 @@ void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop) {
if (level >= 0) {
// set iteration
if (*nLoop >= 0) {
- FILE_LOG(logINFO, ("Setting Pattern - Pattern Loop (level:%d, nLoop:%d)\n",
+ FILE_LOG(logINFO, ("Setting Pattern Loop (level:%d, nLoop:%d)\n",
level, *nLoop));
bus_w(nLoopReg, *nLoop);
}
@@ -1695,9 +1668,9 @@ void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop) {
}
// set
- if (*startAddr != -1 && *stopAddr != -1) {
+ if (*startAddr >= 0 && *stopAddr >= 0) {
// writing start and stop addr
- FILE_LOG(logINFO, ("Setting Pattern - Pattern Loop (level:%d, startaddr:0x%x, stopaddr:0x%x)\n",
+ FILE_LOG(logINFO, ("Setting Pattern Loop (level:%d, startaddr:0x%x, stopaddr:0x%x)\n",
level, *startAddr, *stopAddr));
bus_w(addr, ((*startAddr << startOffset) & startMask) | ((*stopAddr << stopOffset) & stopMask));
FILE_LOG(logDEBUG1, ("Addr:0x%x, val:0x%x\n", addr, bus_r(addr)));
@@ -1706,55 +1679,15 @@ void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop) {
// get
else {
*startAddr = ((bus_r(addr) & startMask) >> startOffset);
- FILE_LOG(logDEBUG1, ("Getting Pattern - Pattern Loop Start Address (level:%d, Read startAddr:0x%x)\n",
+ FILE_LOG(logDEBUG1, ("Getting Pattern Loop Start Address (level:%d, Read startAddr:0x%x)\n",
level, *startAddr));
*stopAddr = ((bus_r(addr) & stopMask) >> stopOffset);
- FILE_LOG(logDEBUG1, ("Getting Pattern - Pattern Loop Stop Address (level:%d, Read stopAddr:0x%x)\n",
+ FILE_LOG(logDEBUG1, ("Getting Pattern Loop Stop Address (level:%d, Read stopAddr:0x%x)\n",
level, *stopAddr));
}
}
-int setLEDEnable(int enable) {
- uint32_t addr = CONFIG_REG;
-
- // set
- if (enable >= 0) {
- FILE_LOG(logINFO, ("Switching LED %s\n", (enable > 0) ? "ON" : "OFF"));
- // disable
- if (enable == 0) {
- bus_w(addr, bus_r(addr) | CONFIG_LED_DSBL_MSK);
- }
- // enable
- else {
- bus_w(addr, bus_r(addr) & (~CONFIG_LED_DSBL_MSK));
- }
- }
- // ~ to get the opposite
- return (((~bus_r(addr)) & CONFIG_LED_DSBL_MSK) >> CONFIG_LED_DSBL_OFST);
-}
-
-void setDigitalIODelay(uint64_t pinMask, int delay) {
- FILE_LOG(logINFO, ("Setings Digital IO Delay (pinMask:0x%llx, delay: %d ps)\n",
- (long long unsigned int)pinMask, delay));
-
- int delayunit = delay / OUTPUT_DELAY_0_OTPT_STTNG_STEPS;
- FILE_LOG(logDEBUG1, ("delay unit: 0x%x (steps of 25ps)\n", delayunit));
-
- // set pin mask
- bus_w(PIN_DELAY_1_REG, pinMask);
-
- uint32_t addr = OUTPUT_DELAY_0_REG;
- // set delay
- bus_w(addr, bus_r(addr) & (~OUTPUT_DELAY_0_OTPT_STTNG_MSK));
- bus_w(addr, (bus_r(addr) | ((delayunit << OUTPUT_DELAY_0_OTPT_STTNG_OFST) & OUTPUT_DELAY_0_OTPT_STTNG_MSK)));
-
- // load value
- bus_w(addr, bus_r(addr) | OUTPUT_DELAY_0_OTPT_TRGGR_MSK);
-
- // trigger configuration
- bus_w(addr, bus_r(addr) & (~OUTPUT_DELAY_0_OTPT_TRGGR_MSK));
-}
void setPatternMask(uint64_t mask) {
set64BitReg(mask, PATTERN_MASK_LSB_REG, PATTERN_MASK_MSB_REG);
@@ -1772,6 +1705,7 @@ uint64_t getPatternBitMask() {
return get64BitReg(PATTERN_SET_LSB_REG, PATTERN_SET_MSB_REG);
}
+
/* aquisition */
int startStateMachine(){
@@ -1786,10 +1720,11 @@ int startStateMachine(){
FILE_LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
return OK;
#endif
+ int send_to_10g = enableTenGigabitEthernet(-1);
// 1 giga udp
- if (!enableTenGigabitEthernet(-1)) {
+ if (send_to_10g == 0) {
// create udp socket
- if(createUDPSocket() != OK) {
+ if(createUDPSocket(0) != OK) {
return FAIL;
}
// update header with modId, detType and version. Reset offset and fnum
@@ -1797,9 +1732,10 @@ int startStateMachine(){
}
FILE_LOG(logINFOBLUE, ("Starting State Machine\n"));
-
cleanFifos();
- unsetFifoReadStrobes(); // FIXME: unnecessary to write bus_w(dumm, 0) as it is 0 in the beginnig and the strobes are always unset if set
+ if (send_to_10g == 0) {
+ unsetFifoReadStrobes(); // FIXME: unnecessary to write bus_w(dumm, 0) as it is 0 in the beginnig and the strobes are always unset if set
+ }
//start state machine
bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_STRT_ACQSTN_MSK | CONTROL_STRT_EXPSR_MSK);
@@ -1812,17 +1748,43 @@ int startStateMachine(){
#ifdef VIRTUAL
void* start_timer(void* arg) {
- int wait_in_s = (setTimer(FRAME_NUMBER, -1) *
- setTimer(TRIGGER_NUMBER, -1) *
- (setTimer(FRAME_PERIOD, -1)/(1E9)));
- FILE_LOG(logDEBUG1, ("going to wait for %d s\n", wait_in_s));
- while(!virtual_stop && (wait_in_s >= 0)) {
- usleep(1000 * 1000);
- wait_in_s--;
- }
- FILE_LOG(logINFOGREEN, ("Virtual Timer Done\n"));
+ int64_t periodns = getPeriod();
+ int numFrames = (getNumFrames() *
+ getNumTriggers() );
+ int64_t exp_ns = getExpTime();
+ int frameNr = 0;
+ // loop over number of frames
+ for(frameNr=0; frameNr!= numFrames; ++frameNr ) {
+
+ //check if virtual_stop is high
+ if(virtual_stop == 1){
+ break;
+ }
+
+ // sleep for exposure time
+ struct timespec begin, end;
+ clock_gettime(CLOCK_REALTIME, &begin);
+ usleep(exp_ns / 1000);
+ clock_gettime(CLOCK_REALTIME, &end);
+
+ // calculate time left in period
+ int64_t time_ns = ((end.tv_sec - begin.tv_sec) * 1E9 +
+ (end.tv_nsec - begin.tv_nsec));
+
+ // sleep for (period - exptime)
+ if (frameNr < numFrames) { // if there is a next frame
+ if (periodns > time_ns) {
+ usleep((periodns - time_ns)/ 1000);
+ }
+ }
+
+ // set register frames left
+ }
+
+ // set status to idle
virtual_status = 0;
+ FILE_LOG(logINFOBLUE, ("Finished Acquiring\n"));
return NULL;
}
#endif
@@ -1839,6 +1801,7 @@ int stopStateMachine(){
bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_STP_ACQSTN_MSK);
FILE_LOG(logINFO, ("Status Register: %08x\n",bus_r(STATUS_REG)));
+
return OK;
}
@@ -1863,7 +1826,7 @@ enum runStatus getRunStatus(){
// error
//if (retval & STATUS_SM_FF_FLL_MSK) { This bit is high when a analog fifo is full Or when external stop
- if (retval & STATUS_ANY_FF_FLL_MSK) { // if adc fifo is full
+ if (retval & STATUS_ANY_FF_FLL_MSK) { // if adc or digital fifo is full
FILE_LOG(logINFORED, ("Status: Error (Any fifo full)\n"));
return ERROR;
}
@@ -1908,9 +1871,9 @@ void readandSendUDPFrames(int *ret, char *mess) {
FILE_LOG(logDEBUG1, ("Reading from 1G UDP\n"));
// validate udp socket
- if (getUdPSocketDescriptor() <= 0) {
+ if (getUdPSocketDescriptor(0) <= 0) {
*ret = FAIL;
- sprintf(mess,"UDP Socket not created. sockfd:%d\n", getUdPSocketDescriptor());
+ sprintf(mess,"UDP Socket not created. sockfd:%d\n", getUdPSocketDescriptor(0));
FILE_LOG(logERROR, (mess));
return;
}
@@ -1919,24 +1882,24 @@ void readandSendUDPFrames(int *ret, char *mess) {
while(readFrameFromFifo() == OK) {
int bytesToSend = 0, n = 0;
while((bytesToSend = fillUDPPacket(udpPacketData))) {
- n += sendUDPPacket(udpPacketData, bytesToSend);
+ n += sendUDPPacket(0, udpPacketData, bytesToSend);
}
if (n >= dataBytes) {
FILE_LOG(logINFO, (" Frame %lld sent (%d packets, %d databytes, n:%d bytes sent)\n",
udpFrameNumber, udpPacketNumber + 1, dataBytes, n));
}
}
- closeUDPSocket();
+ closeUDPSocket(0);
}
-
void readFrame(int *ret, char *mess) {
#ifdef VIRTUAL
- while(virtual_status) {
- //FILE_LOG(logERROR, ("Waiting for finished flag\n");
- usleep(5000);
- }
+ // wait for acquisition to be done
+ while(runBusy()){
+ usleep(500); // random
+ }
+ FILE_LOG(logINFOGREEN, ("acquisition successfully finished\n"));
return;
#endif
// 1G
@@ -1954,76 +1917,84 @@ void readFrame(int *ret, char *mess) {
// ret could be fail in 1gudp for not creating udp sockets
if (*ret != FAIL) {
// frames left to give status
- int64_t retval = getTimeLeft(FRAME_NUMBER) + 2;
+ int64_t retval = getNumFramesLeft() + 2;
if ( retval > 1) {
- *ret = (int)FAIL;
sprintf(mess,"No data and run stopped: %lld frames left\n",(long long int)retval);
FILE_LOG(logERROR, (mess));
} else {
- *ret = (int)OK;
FILE_LOG(logINFOGREEN, ("Acquisition successfully finished\n"));
}
}
+ *ret = (int)OK;
}
void unsetFifoReadStrobes() {
- bus_w(DUMMY_REG, bus_r(DUMMY_REG) & (~DUMMY_ANLG_FIFO_RD_STRBE_MSK));
+ bus_w(DUMMY_REG, bus_r(DUMMY_REG) & (~DUMMY_ANLG_FIFO_RD_STRBE_MSK) & (~DUMMY_DGTL_FIFO_RD_STRBE_MSK));
}
void readSample(int ns) {
- uint32_t addr = DUMMY_REG;
- // read analog data
- uint32_t fifoAddr = FIFO_DATA_REG;
+ uint32_t addr = DUMMY_REG;
- // read strobe to all analog fifos
- bus_w(addr, bus_r(addr) | DUMMY_ANLG_FIFO_RD_STRBE_MSK);
- bus_w(addr, bus_r(addr) & (~DUMMY_ANLG_FIFO_RD_STRBE_MSK));
- // wait as it is connected directly to fifo running on a different clock
- //usleep(WAIT_TIME_FIFO_RD_STROBE);
- if (!(ns%1000)) {
- FILE_LOG(logDEBUG1, ("Reading sample ns:%d of %d AEmtpy:0x%x AFull:0x%x Status:0x%x\n",
- ns, nSamples, bus_r(FIFO_EMPTY_REG), bus_r(FIFO_FULL_REG), bus_r(STATUS_REG)));
- }
+ // read adcs
+ if (ns < nSamples) {
- // loop through all channels
- int ich = 0;
- for (ich = 0; ich < NCHAN; ++ich) {
+ uint32_t fifoAddr = FIFO_DATA_REG;
- // if channel is in ROI
- if ((1 << ich) & ~(adcDisableMask)) {
+ // read strobe to all analog fifos
+ bus_w(addr, bus_r(addr) | DUMMY_ANLG_FIFO_RD_STRBE_MSK);
+ bus_w(addr, bus_r(addr) & (~DUMMY_ANLG_FIFO_RD_STRBE_MSK));
- // unselect channel
- bus_w(addr, bus_r(addr) & ~(DUMMY_FIFO_CHNNL_SLCT_MSK));
+ // wait for 1 us to latch different clocks of read and read strobe
+ {
+ int i = 0;
+ for (i = 0; i < WAIT_TIME_1US_FOR_LOOP_CNT; ++i)
+ ;
+ }
- // select channel
- bus_w(addr, bus_r(addr) | ((ich << DUMMY_FIFO_CHNNL_SLCT_OFST) & DUMMY_FIFO_CHNNL_SLCT_MSK));
+ if (!(ns%1000)) {
+ FILE_LOG(logDEBUG1, ("Reading sample ns:%d of %d AEmtpy:0x%x AFull:0x%x Status:0x%x\n",
+ ns, nSamples, bus_r(FIFO_EMPTY_REG), bus_r(FIFO_FULL_REG), bus_r(STATUS_REG)));
+ }
- // read fifo and write it to current position of data pointer
- *((uint16_t*)now_ptr) = bus_r16(fifoAddr);
+ // loop through all channels
+ int ich = 0;
+ for (ich = 0; ich < NCHAN; ++ich) {
- // 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);
- }*/
+ // if channel is in enable mask
+ if ((1 << ich) & (adcEnableMask_1g)) {
- // increment pointer to data out destination
- now_ptr += 2;
+ // unselect channel
+ bus_w(addr, bus_r(addr) & ~(DUMMY_FIFO_CHNNL_SLCT_MSK));
+
+ // select channel
+ bus_w(addr, bus_r(addr) | ((ich << DUMMY_FIFO_CHNNL_SLCT_OFST) & DUMMY_FIFO_CHNNL_SLCT_MSK));
+
+ // read fifo and write it to current position of data pointer
+ *((uint16_t*)analogDataPtr) = bus_r16(fifoAddr);
+
+ // keep reading till the value is the same
+ /* while (*((uint16_t*)analogDataPtr) != bus_r16(fifoAddr)) {
+ FILE_LOG(logDEBUG1, ("%d ", ich));
+ *((uint16_t*)analogDataPtr) = bus_r16(fifoAddr);
+ }*/
+
+ // increment pointer to data out destination
+ analogDataPtr += 2;
+ }
}
}
-
}
uint32_t checkDataInFifo() {
uint32_t dataPresent = 0;
- uint32_t analogFifoEmpty = bus_r(FIFO_EMPTY_REG);
- FILE_LOG(logDEBUG2, ("Analog Fifo Empty (32 channels): 0x%x\n",analogFifoEmpty));
- dataPresent = (~analogFifoEmpty);
- FILE_LOG(logDEBUG2, ("Data in Fifo :0x%x\n", dataPresent));
+ uint32_t fifoEmpty = bus_r(FIFO_EMPTY_REG);
+ FILE_LOG(logINFO, ("Analog Fifo Empty (32 channels): 0x%08x\n", fifoEmpty));
+ dataPresent = (~fifoEmpty);
+ FILE_LOG(logDEBUG2, ("Data in Fifo :0x%x\n", dataPresent));
return dataPresent;
}
-// only called for first sample
+// only called for starting of a new frame
int checkFifoForEndOfAcquisition() {
uint32_t dataPresent = checkDataInFifo();
FILE_LOG(logDEBUG2, ("status:0x%x\n", bus_r(STATUS_REG)));
@@ -2053,11 +2024,10 @@ int checkFifoForEndOfAcquisition() {
return OK;
}
-
int readFrameFromFifo() {
int ns = 0;
// point the data pointer to the starting position of data
- now_ptr = ramValues;
+ analogDataPtr = analogData;
// no data for this frame
if (checkFifoForEndOfAcquisition() == FAIL) {
@@ -2066,7 +2036,6 @@ int readFrameFromFifo() {
// read Sample
while(ns < nSamples) {
- // chceck if no data in fifo, return ns?//FIXME: ask Anna
readSample(ns);
ns++;
}
@@ -2075,7 +2044,6 @@ int readFrameFromFifo() {
return OK;
}
-
uint32_t runBusy() {
#ifdef VIRTUAL
return virtual_status;
@@ -2098,7 +2066,7 @@ int calculateDataBytes(){
return dataBytes;
}
-int getTotalNumberOfChannels(){return ((int)getNumberOfChannelsPerChip() * (int)getNumberOfChips());}
+int getTotalNumberOfChannels() {return (getNumberOfChannelsPerChip() * getNumberOfChips());}
int getNumberOfChips(){return NCHIP;}
int getNumberOfDACs(){return NDAC;}
int getNumberOfChannelsPerChip(){return NCHAN;}
diff --git a/slsDetectorServers/moenchDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/moenchDetectorServer/slsDetectorServer_defs.h
index c9b0247b9..2641a83d2 100755
--- a/slsDetectorServers/moenchDetectorServer/slsDetectorServer_defs.h
+++ b/slsDetectorServers/moenchDetectorServer/slsDetectorServer_defs.h
@@ -4,27 +4,51 @@
#define MIN_REQRD_VRSN_T_RD_API 0x180314
-#define REQRD_FRMWR_VRSN 0x180314
+#define REQRD_FRMWR_VRSN 0x200302
-#define CTRL_SRVR_INIT_TIME_US (300 * 1000)
+#define CTRL_SRVR_INIT_TIME_US (2 * 1000 * 1000)
/* Struct Definitions */
-typedef struct ip_header_struct {
- uint16_t ip_len;
- uint8_t ip_tos;
- uint8_t ip_ihl:4 ,ip_ver:4;
- uint16_t ip_offset:13,ip_flag:3;
- uint16_t ip_ident;
- uint16_t ip_chksum;
- uint8_t ip_protocol;
- uint8_t ip_ttl;
- uint32_t ip_sourceip;
- uint32_t ip_destip;
-} ip_header;
+typedef struct udp_header_struct {
+ uint32_t udp_destmac_msb;
+ uint16_t udp_srcmac_msb;
+ uint16_t udp_destmac_lsb;
+ uint32_t udp_srcmac_lsb;
+ uint8_t ip_tos;
+ uint8_t ip_ihl: 4, ip_ver: 4;
+ uint16_t udp_ethertype;
+ uint16_t ip_identification;
+ uint16_t ip_totallength;
+ uint8_t ip_protocol;
+ uint8_t ip_ttl;
+ uint16_t ip_fragmentoffset: 13, ip_flags: 3;
+ uint16_t ip_srcip_msb;
+ uint16_t ip_checksum;
+ uint16_t ip_destip_msb;
+ uint16_t ip_srcip_lsb;
+ uint16_t udp_srcport;
+ uint16_t ip_destip_lsb;
+ uint16_t udp_checksum;
+ uint16_t udp_destport;
+} udp_header;
+
+#define IP_HEADER_SIZE (20)
+#define UDP_IP_HEADER_LENGTH_BYTES (28)
/* Enums */
+enum DACINDEX {MO_VBP_COLBUF, MO_VIPRE, MO_VIN_CM, MO_VB_SDA, MO_VCASC_SFP, MO_VOUT_CM, MO_VIPRE_CDS, MO_IBIAS_SFP};
+#define DEFAULT_DAC_VALS { 1300, /* MO_VBP_COLBUF */ \
+ 1000, /* MO_VIPRE */ \
+ 1400, /* MO_VIN_CM */ \
+ 680, /* MO_VB_SDA */ \
+ 1428, /* MO_VCASC_SFP */ \
+ 1200, /* MO_VOUT_CM */ \
+ 800, /* MO_VIPRE_CDS */ \
+ 900 /* MO_IBIAS_SFP */ \
+ };
+
enum CLKINDEX {RUN_CLK, ADC_CLK, SYNC_CLK, DBIT_CLK, NUM_CLOCKS};
-enum DACINDEX {D0, D1, D2, D3, D4, D5, D6, D7};
+#define CLK_NAMES "run", "adc", "sync", "dbit"
/* Hardware Definitions */
#define NCHAN (32)
@@ -33,12 +57,13 @@ enum DACINDEX {D0, D1, D2, D3, D4, D5, D6, D7};
#define DYNAMIC_RANGE (16)
#define NUM_BYTES_PER_PIXEL (DYNAMIC_RANGE / 8)
#define CLK_FREQ (156.25) /* MHz */
+#define NSAMPLES_PER_ROW (25)
/** Default Parameters */
#define DEFAULT_DATA_BYTES (NCHIP * NCHAN * NUM_BITS_PER_PIXEL)
-#define DEFAULT_NUM_SAMPLES (1)
+#define DEFAULT_NUM_SAMPLES (5000)
#define DEFAULT_EXPTIME (0)
-#define DEFAULT_NUM_FRAMES (100 * 1000 * 1000)
+#define DEFAULT_NUM_FRAMES (1)
#define DEFAULT_NUM_CYCLES (1)
#define DEFAULT_PERIOD (1 * 1000 * 1000) //ns
#define DEFAULT_DELAY (0)
@@ -46,35 +71,37 @@ enum DACINDEX {D0, D1, D2, D3, D4, D5, D6, D7};
#define DEFAULT_VLIMIT (-100)
#define DEFAULT_TIMING_MODE (AUTO_TIMING)
#define DEFAULT_TX_UDP_PORT (0x7e9a)
-#define DEFAULT_RUN_CLK (40)
-#define DEFAULT_ADC_CLK (20)
-#define DEFAULT_SYNC_CLK (20)
-#define DEFAULT_DBIT_CLK (200)
+#define DEFAULT_RUN_CLK (40)
+#define DEFAULT_ADC_CLK (20)
+#define DEFAULT_SYNC_CLK (20)
+#define DEFAULT_DBIT_CLK (20)
+#define DEFAULT_ADC_PHASE_DEG (30)
+#define DEFAULT_PIPELINE (14)
#define HIGHVOLTAGE_MIN (60)
-#define HIGHVOLTAGE_MAX (200)
+#define HIGHVOLTAGE_MAX (200) // min dac val
#define DAC_MIN_MV (0)
#define DAC_MAX_MV (2500)
/* Defines in the Firmware */
-#define MAX_PATTERN_LENGTH (0x7FFF)
+#define MAX_PATTERN_LENGTH (0x2000)
#define DIGITAL_IO_DELAY_MAXIMUM_PS ((OUTPUT_DELAY_0_OTPT_STTNG_MSK >> OUTPUT_DELAY_0_OTPT_STTNG_OFST) * OUTPUT_DELAY_0_OTPT_STTNG_STEPS)
#define MAX_PHASE_SHIFTS_STEPS (8)
#define WAIT_TME_US_FR_ACQDONE_REG (100) // wait time in us after acquisition done to ensure there is no data in fifo
#define WAIT_TIME_US_PLL (10 * 1000)
#define WAIT_TIME_US_STP_ACQ (100)
-#define WAIT_TIME_CONFIGURE_MAC (500 * 1000)
+#define WAIT_TIME_CONFIGURE_MAC (2 * 1000 * 1000)
#define WAIT_TIME_PATTERN_READ (10)
-#define WAIT_TIME_FIFO_RD_STROBE (10)
+#define WAIT_TIME_1US_FOR_LOOP_CNT (50) // around 30 is 1 us in blackfin
/* MSB & LSB DEFINES */
#define MSB_OF_64_BIT_REG_OFST (32)
#define LSB_OF_64_BIT_REG_OFST (0)
-#define BIT_32_MSK (0xFFFFFFFF)
+#define BIT32_MSK (0xFFFFFFFF)
+#define BIT16_MASK (0xFFFF)
-#define IP_PACKETSIZE (0x2032)
-#define ADC_PORT_INVERT_VAL (0x453b2593) //FIXME: a default value?
-#define MAXIMUM_ADC_CLK (40)
+#define ADC_PORT_INVERT_VAL (0x4a342593)
+#define MAXIMUM_ADC_CLK (20)
#define PLL_VCO_FREQ_MHZ (800)
diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h
index e0295aa1c..71696a9c7 100755
--- a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h
+++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h
@@ -3,6 +3,14 @@
#ifdef GOTTHARDD
#include "clogger.h" // runState(enum TLogLevel)
#endif
+#ifndef VIRTUAL
+#if defined(MYTHEN3D) || defined(GOTTHARD2D)
+#include "programFpgaNios.h"
+#elif defined(CHIPTESTBOARDD) || defined(JUNGFRAUD) || defined(MOENCHD)
+#include "programFpgaBlackfin.h"
+#endif
+#endif
+
#include
#include // FILE
#include
@@ -84,7 +92,7 @@ int updateDatabytesandAllocateRAM();
void updateDataBytes();
#endif
-#if defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(MYTHEN3D)
+#if defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(MYTHEN3D) || defined(MOENCHD)
int setDefaultDacs();
#endif
#ifdef GOTTHARD2D
@@ -141,6 +149,8 @@ void setADCEnableMask_10G(uint32_t mask);
uint32_t getADCEnableMask_10G();
void setADCInvertRegister(uint32_t val);
uint32_t getADCInvertRegister();
+#endif
+#if defined(CHIPTESTBOARDD)
int setExternalSamplingSource(int val);
int setExternalSampling(int val);
#endif
@@ -213,6 +223,8 @@ int64_t getStorageCellDelay();
#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
int setNumAnalogSamples(int val);
int getNumAnalogSamples();
+#endif
+#ifdef CHIPTESTBOARDD
int setNumDigitalSamples(int val);
int getNumDigitalSamples();
#endif
@@ -298,11 +310,9 @@ void setPower(enum DACINDEX ind, int val);
void powerOff();
#endif
-#ifndef MOENCHD
-#if !defined(MYTHEN3D) && !defined(GOTTHARD2D)
+#if !defined(MOENCHD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D)
int getADC(enum ADCINDEX ind);
#endif
-#endif
int setHighVoltage(int val);
@@ -358,6 +368,7 @@ int enableTenGigabitEthernet(int val);
// moench specific - powerchip
#ifdef MOENCHD
int powerChip (int on);
+int setAnalogOnlyReadout();
#endif
// chip test board or moench specific - configure frequency, phase, pll, flashing firmware
@@ -383,8 +394,10 @@ uint64_t writePatternWord(int addr, uint64_t word);
int setPatternWaitAddress(int level, int addr);
uint64_t setPatternWaitTime(int level, uint64_t t);
void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop);
+#ifdef CHIPTESTBOARDD
int setLEDEnable(int enable);
void setDigitalIODelay(uint64_t pinMask, int delay);
+#endif
void setPatternMask(uint64_t mask);
uint64_t getPatternMask();
void setPatternBitMask(uint64_t mask);
diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c
index 51170c764..42137d235 100755
--- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c
+++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c
@@ -2,13 +2,6 @@
#include "slsDetectorFunctionList.h"
#include "communication_funcs.h"
#include "clogger.h"
-#ifndef VIRTUAL
-#if defined(MYTHEN3D) || defined(GOTTHARD2D)
-#include "programFpgaNios.h"
-#elif defined(CHIPTESTBOARDD) || defined(JUNGFRAUD) || defined(MOENCHD)
-#include "programFpgaBlackfin.h"
-#endif
-#endif
#include
#include
@@ -928,10 +921,35 @@ int set_dac(int file_des) {
case V_LIMIT:
break;
#elif MOENCHD
+ case VBP_COLBUF:
+ serverDacIndex = MO_VBP_COLBUF;
+ break;
+ case VIPRE:
+ serverDacIndex = MO_VIPRE;
+ break;
+ case VIN_CM:
+ serverDacIndex = MO_VIN_CM;
+ break;
+ case VB_SDA:
+ serverDacIndex = MO_VB_SDA;
+ break;
+ case VCASC_SFP:
+ serverDacIndex = MO_VCASC_SFP;
+ break;
+ case VOUT_CM:
+ serverDacIndex = MO_VOUT_CM;
+ break;
+ case VIPRE_CDS:
+ serverDacIndex = MO_VIPRE_CDS;
+ break;
+ case IBIAS_SFP:
+ serverDacIndex = MO_IBIAS_SFP;
+ break;
case ADC_VPP:
case HIGH_VOLTAGE:
case V_LIMIT:
break;
+
#elif MYTHEN3D
case HIGH_VOLTAGE:
break;
@@ -1056,17 +1074,13 @@ int set_dac(int file_des) {
serverDacIndex = J_VREF_COMP;
break;
#endif
+
default:
#ifdef CHIPTESTBOARDD
if (ind < NDAC_ONLY) {
serverDacIndex = ind;
break;
}
-#elif MOENCHD
- if (ind < NDAC) {
- serverDacIndex = ind;
- break;
- }
#endif
modeNotImplemented("Dac Index", (int)ind);
break;
@@ -1750,18 +1764,23 @@ int start_acquisition(int file_des) {
FILE_LOG(logDEBUG1, ("Starting Acquisition\n"));
// only set
if (Server_VerifyLock() == OK) {
-#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
- int mode = getReadoutMode();
- int asamples = getNumAnalogSamples();
- int dsamples = getNumDigitalSamples();
- if ((mode == ANALOG_AND_DIGITAL || mode == ANALOG_ONLY) && (asamples <= 0)) {
+#if defined(MOENCHD)
+ if (getNumAnalogSamples() <= 0) {
ret = FAIL;
- sprintf(mess, "Could not start acquisition. Invalid number of analog samples: %d.\n", asamples);
+ sprintf(mess, "Could not start acquisition. Invalid number of analog samples: %d.\n", getNumAnalogSamples());
FILE_LOG(logERROR,(mess));
}
- else if ((mode == ANALOG_AND_DIGITAL || mode == DIGITAL_ONLY) && (dsamples <= 0)) {
+ else
+#endif
+#if defined(CHIPTESTBOARDD)
+ if ((getReadoutMode() == ANALOG_AND_DIGITAL || mode == ANALOG_ONLY) && (getNumAnalogSamples() <= 0)) {
ret = FAIL;
- sprintf(mess, "Could not start acquisition. Invalid number of digital samples: %d.\n", dsamples);
+ sprintf(mess, "Could not start acquisition. Invalid number of analog samples: %d.\n", getNumAnalogSamples());
+ FILE_LOG(logERROR,(mess));
+ }
+ else if ((getReadoutMode() == ANALOG_AND_DIGITAL || mode == DIGITAL_ONLY) && (getNumDigitalSamples() <= 0)) {
+ ret = FAIL;
+ sprintf(mess, "Could not start acquisition. Invalid number of digital samples: %d.\n", getNumDigitalSamples());
FILE_LOG(logERROR,(mess));
}
else
@@ -1880,18 +1899,23 @@ int start_and_read_all(int file_des) {
FILE_LOG(logDEBUG1, ("Starting Acquisition\n"));
// only set
if (Server_VerifyLock() == OK) {
-#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
- int mode = getReadoutMode();
- int asamples = getNumAnalogSamples();
- int dsamples = getNumDigitalSamples();
- if ((mode == ANALOG_AND_DIGITAL || mode == ANALOG_ONLY) && (asamples <= 0)) {
+#if defined(MOENCHD)
+ if (getNumAnalogSamples() <= 0) {
ret = FAIL;
- sprintf(mess, "Could not start acquisition. Invalid number of analog samples: %d.\n", asamples);
+ sprintf(mess, "Could not start acquisition. Invalid number of analog samples: %d.\n", getNumAnalogSamples());
FILE_LOG(logERROR,(mess));
}
- else if ((mode == ANALOG_AND_DIGITAL || mode == DIGITAL_ONLY) && (dsamples <= 0)) {
+ else
+#endif
+#if defined(CHIPTESTBOARDD)
+ if ((getReadoutMode() == ANALOG_AND_DIGITAL || mode == ANALOG_ONLY) && (getNumAnalogSamples() <= 0)) {
ret = FAIL;
- sprintf(mess, "Could not start acquisition. Invalid number of digital samples: %d.\n", dsamples);
+ sprintf(mess, "Could not start acquisition. Invalid number of analog samples: %d.\n", getNumAnalogSamples());
+ FILE_LOG(logERROR,(mess));
+ }
+ else if ((getReadoutMode() == ANALOG_AND_DIGITAL || mode == DIGITAL_ONLY) && (getNumDigitalSamples() <= 0)) {
+ ret = FAIL;
+ sprintf(mess, "Could not start acquisition. Invalid number of digital samples: %d.\n", getNumDigitalSamples());
FILE_LOG(logERROR,(mess));
}
else
@@ -2102,14 +2126,23 @@ int set_num_analog_samples(int file_des) {
#else
// only set
if (Server_VerifyLock() == OK) {
- ret = setNumAnalogSamples(arg);
- if (ret == FAIL) {
- sprintf(mess, "Could not set number of analog samples to %d. Could not allocate RAM\n", arg);
- FILE_LOG(logERROR,(mess));
- } else {
- int retval = getNumAnalogSamples();
- FILE_LOG(logDEBUG1, ("retval num analog samples %d\n", retval));
- validate(arg, retval, "set number of analog samples", DEC);
+#ifdef MOENCHD
+ if (arg % NSAMPLES_PER_ROW != 0) {
+ ret = FAIL;
+ sprintf(mess, "Could not set number of analog samples to %d. Must be divisible by %d\n", arg, NSAMPLES_PER_ROW);
+ FILE_LOG(logERROR,(mess));
+ }
+#endif
+ if (ret == OK) {
+ ret = setNumAnalogSamples(arg);
+ if (ret == FAIL) {
+ sprintf(mess, "Could not set number of analog samples to %d. Could not allocate RAM\n", arg);
+ FILE_LOG(logERROR,(mess));
+ } else {
+ int retval = getNumAnalogSamples();
+ FILE_LOG(logDEBUG1, ("retval num analog samples %d\n", retval));
+ validate(arg, retval, "set number of analog samples", DEC);
+ }
}
}
#endif
@@ -2121,7 +2154,7 @@ int get_num_digital_samples(int file_des) {
memset(mess, 0, sizeof(mess));
int retval = -1;
-#if !defined(CHIPTESTBOARDD) && !defined(MOENCHD)
+#if !defined(CHIPTESTBOARDD)
functionNotImplemented();
#else
// get only
@@ -2140,7 +2173,7 @@ int set_num_digital_samples(int file_des) {
return printSocketReadError();
FILE_LOG(logDEBUG1, ("Setting number of digital samples %d\n", arg));
-#if !defined(CHIPTESTBOARDD) && !defined(MOENCHD)
+#if !defined(CHIPTESTBOARDD)
functionNotImplemented();
#else
// only set
@@ -2856,10 +2889,16 @@ int send_update(int file_des) {
#endif
#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
+ // analog samples
+ i32 = getNumAnalogSamples();
+ n = sendData(file_des,&i32,sizeof(i32),INT32);
+ if (n < 0) return printSocketReadError();
+
// 1g adcmask
i32 = getADCEnableMask();
n = sendData(file_des,&i32,sizeof(i32),INT32);
if (n < 0) return printSocketReadError();
+
// 10g adc mask
i32 = getADCEnableMask_10G();
n = sendData(file_des,&i32,sizeof(i32),INT32);
@@ -4237,7 +4276,7 @@ int led(int file_des) {
return printSocketReadError();
FILE_LOG(logDEBUG1, ("Setting led enable to %d\n", arg));
-#if (!defined(MOENCHD)) && (!defined(CHIPTESTBOARDD))
+#if (!defined(CHIPTESTBOARDD))
functionNotImplemented();
#else
// set & get
@@ -4262,7 +4301,7 @@ int digital_io_delay(int file_des) {
return printSocketReadError();
FILE_LOG(logDEBUG1, ("Digital IO Delay, pinMask: 0x%llx, delay:%d ps\n", args[0], (int)args[1]));
-#if (!defined(MOENCHD)) && (!defined(CHIPTESTBOARDD))
+#if (!defined(CHIPTESTBOARDD))
functionNotImplemented();
#else
// only set
@@ -6169,9 +6208,11 @@ int set_pipeline(int file_des) {
case ADC_CLOCK:
c = ADC_CLK;
break;
+#ifdef CHIPTESTBOARDD
case DBIT_CLOCK:
c = DBIT_CLK;
break;
+#endif
default:
modeNotImplemented("clock index (pipeline set)", ind);
break;
diff --git a/slsDetectorSoftware/include/Detector.h b/slsDetectorSoftware/include/Detector.h
index eab4b6f9c..ce8128602 100644
--- a/slsDetectorSoftware/include/Detector.h
+++ b/slsDetectorSoftware/include/Detector.h
@@ -155,32 +155,32 @@ class Detector {
void setPeriod(ns t, Positions pos = {});
- /** [Gotthard][Jungfrau][CTB][Mythen3][Gotthard2] */
+ /** [Gotthard][Jungfrau][CTB][Moench][Mythen3][Gotthard2] */
Result getDelayAfterTrigger(Positions pos = {}) const;
- /** [Gotthard][Jungfrau][CTB][Mythen3][Gotthard2] */
+ /** [Gotthard][Jungfrau][CTB][Moench][Mythen3][Gotthard2] */
void setDelayAfterTrigger(ns value, Positions pos = {});
- /** [Gotthard][Jungfrau][CTB][Mythen3]
+ /** [Gotthard][Jungfrau][CTB][Moench][Mythen3]
* [Gotthard2] only in continuous mode */
Result getNumberOfFramesLeft(Positions pos = {}) const;
- /** [Gotthard][Jungfrau][CTB][Mythen3]
+ /** [Gotthard][Jungfrau][CTB][Moench][Mythen3]
* [Gotthard2] only in continuous mode */
Result getNumberOfTriggersLeft(Positions pos = {}) const;
- /** [Gotthard][Jungfrau][CTB][Mythen3]
+ /** [Gotthard][Jungfrau][CTB][Moench][Mythen3]
* [Gotthard2] only in continuous mode */
Result getPeriodLeft(Positions pos = {}) const;
- /** [Gotthard][Jungfrau][CTB][Mythen3]
+ /** [Gotthard][Jungfrau][CTB][Moench][Mythen3]
* [Gotthard2] only in continuous mode */
Result getDelayAfterTriggerLeft(Positions pos = {}) const;
Result getTimingMode(Positions pos = {}) const;
/**
- * [Gotthard][Jungfrau][CTB] Options: AUTO_TIMING, TRIGGER_EXPOSURE
+ * [Gotthard][Jungfrau][CTB][Moench] Options: AUTO_TIMING, TRIGGER_EXPOSURE
* [Eiger] Options: AUTO_TIMING, TRIGGER_EXPOSURE, GATED, BURST_TRIGGER
*/
void setTimingMode(defs::timingMode value, Positions pos = {});
@@ -192,19 +192,19 @@ class Detector {
* Options: FULL_SPEED, HALF_SPEED, QUARTER_SPEED */
void setSpeed(defs::speedLevel value, Positions pos = {});
- /** [Gotthard][Jungfrau][CTB] */
+ /** [Gotthard][Jungfrau][CTB][Moench] */
Result getADCPhase(Positions pos = {}) const;
- /** [Gotthard][Jungfrau][CTB] */
+ /** [Gotthard][Jungfrau][CTB][Moench] */
void setADCPhase(int value, Positions pos = {});
- /** [Jungfrau][CTB] */
+ /** [Jungfrau][CTB][Moench] */
Result getMaxADCPhaseShift(Positions pos = {}) const;
- /** [Gotthard][Jungfrau][CTB] */
+ /** [Gotthard][Jungfrau][CTB][Moench] */
Result getADCPhaseInDegrees(Positions pos = {}) const;
- /** [Gotthard][Jungfrau][CTB] */
+ /** [Gotthard][Jungfrau][CTB][Moench] */
void setADCPhaseInDegrees(int value, Positions pos = {});
/** [Mythen3][Gotthard2] Hz */
@@ -244,7 +244,7 @@ class Detector {
/**
* [Gotthard] Options: 0, 90, 110, 120, 150, 180, 200
- * [Jungfrau], CTB Options: 0, 60 - 200
+ * [Jungfrau][CTB][Moench] Options: 0, 60 - 200
* [Eiger][Mythen3][Gotthard2] Options: 0 - 200
*/
void setHighVoltage(int value, Positions pos = {});
@@ -415,10 +415,10 @@ class Detector {
Result printRxConfiguration(Positions pos = {}) const;
- /** [Eiger][CTB] */
+ /** [Eiger][CTB][Moench] */
Result getTenGiga(Positions pos = {}) const;
- /** [Eiger][CTB] */
+ /** [Eiger][CTB][Moench] */
void setTenGiga(bool value, Positions pos = {});
/** [Eiger, Jungfrau] */
@@ -954,18 +954,67 @@ class Detector {
/** [Mythen3] countermask bit set for each counter enabled */
void setCounterMask(uint32_t countermask, Positions pos = {});
+ /**************************************************
+ * *
+ * CTB / Moench Specific *
+ * *
+ * ************************************************/
+ /** [CTB][Moench] */
+ Result getNumberOfAnalogSamples(Positions pos = {}) const;
+
+ /** [CTB][Moench] */
+ void setNumberOfAnalogSamples(int value, Positions pos = {});
+
+ /** [CTB][Moench] */
+ Result getADCClock(Positions pos = {}) const;
+
+ /** [CTB][Moench] */
+ void setADCClock(int value_in_MHz, Positions pos = {});
+
+ /** [CTB][Moench] */
+ Result getRUNClock(Positions pos = {}) const;
+
+ /** [CTB][Moench] */
+ void setRUNClock(int value_in_MHz, Positions pos = {});
+
+ /** [CTB][Moench] */
+ Result getSYNCClock(Positions pos = {}) const;
+
+ /** [CTB][Moench] */
+ Result getADCPipeline(Positions pos = {}) const;
+
+ /** [CTB][Moench] */
+ void setADCPipeline(int value, Positions pos = {});
+
+ /** [CTB][Moench] */
+ Result getVoltage(defs::dacIndex index, Positions pos = {}) const;
+
+ /**
+ * [CTB][Moench] mV
+ * [Ctb] Options: V_LIMIT, V_POWER_A, V_POWER_B, V_POWER_C,
+ * V_POWER_D, V_POWER_IO, V_POWER_CHIP
+ * [Moench] Options: V_LIMIT
+ */
+ void setVoltage(defs::dacIndex index, int value, Positions pos = {});
+
+ /** [CTB][Moench] */
+ Result getADCEnableMask(Positions pos = {}) const;
+
+ /** [CTB][Moench] */
+ void setADCEnableMask(uint32_t mask, Positions pos = {});
+
+ /** [CTB][Moench] */
+ Result getTenGigaADCEnableMask(Positions pos = {}) const;
+
+ /** [CTB][Moench] */
+ void setTenGigaADCEnableMask(uint32_t mask, Positions pos = {});
+
/**************************************************
* *
* CTB Specific *
* *
* ************************************************/
- /** [CTB] */
- Result getNumberOfAnalogSamples(Positions pos = {}) const;
-
- /** [CTB] */
- void setNumberOfAnalogSamples(int value, Positions pos = {});
-
/** [CTB] */
Result getNumberOfDigitalSamples(Positions pos = {}) const;
@@ -978,6 +1027,12 @@ class Detector {
/** [CTB] Options: ANALOG_ONLY = 0, DIGITAL_ONLY = 1, ANALOG_AND_DIGITAL */
void setReadoutMode(defs::readoutMode value, Positions pos = {});
+ /** [CTB] */
+ Result getDBITClock(Positions pos = {}) const;
+
+ /** [CTB] */
+ void setDBITClock(int value_in_MHz, Positions pos = {});
+
/** [CTB] */
Result getDBITPhase(Positions pos = {}) const;
@@ -993,49 +1048,12 @@ class Detector {
/** [CTB] */
void setDBITPhaseInDegrees(int value, Positions pos = {});
- /** [CTB] */
- Result getADCClock(Positions pos = {}) const;
-
- /** [CTB] */
- void setADCClock(int value_in_MHz, Positions pos = {});
-
- /** [CTB] */
- Result getDBITClock(Positions pos = {}) const;
-
- /** [CTB] */
- void setDBITClock(int value_in_MHz, Positions pos = {});
-
- /** [CTB] */
- Result getRUNClock(Positions pos = {}) const;
-
- /** [CTB] */
- void setRUNClock(int value_in_MHz, Positions pos = {});
-
- /** [CTB] */
- Result getSYNCClock(Positions pos = {}) const;
-
- /** [CTB] */
- Result getADCPipeline(Positions pos = {}) const;
-
- /** [CTB] */
- void setADCPipeline(int value, Positions pos = {});
-
/** [CTB] */
Result getDBITPipeline(Positions pos = {}) const;
/** [CTB] */
void setDBITPipeline(int value, Positions pos = {});
- /** [CTB] */
- Result getVoltage(defs::dacIndex index, Positions pos = {}) const;
-
- /**
- * [CTB] mV
- * Options: V_LIMIT, V_POWER_A, V_POWER_B, V_POWER_C,
- * V_POWER_D, V_POWER_IO, V_POWER_CHIP
- */
- void setVoltage(defs::dacIndex index, int value, Positions pos = {});
-
/**
* [CTB] mV
* Options: V_POWER_A, V_POWER_B, V_POWER_C, V_POWER_D, V_POWER_IO */
@@ -1051,24 +1069,6 @@ class Detector {
/** [CTB] Options: SLOW_ADC0 - SLOW_ADC7 in uV */
Result getSlowADC(defs::dacIndex index, Positions pos = {}) const;
- /** [CTB]*/
- Result getADCEnableMask(Positions pos = {}) const;
-
- /** [CTB]*/
- void setADCEnableMask(uint32_t mask, Positions pos = {});
-
- /** [CTB]*/
- Result getTenGigaADCEnableMask(Positions pos = {}) const;
-
- /** [CTB]*/
- void setTenGigaADCEnableMask(uint32_t mask, Positions pos = {});
-
- /** [CTB] */
- Result getADCInvert(Positions pos = {}) const;
-
- /** [CTB]*/
- void setADCInvert(uint32_t value, Positions pos = {});
-
/** [CTB] */
Result getExternalSamplingSource(Positions pos = {}) const;
@@ -1113,72 +1113,71 @@ class Detector {
* *
* ************************************************/
- /** [CTB] */
+ /** [CTB][Moench][Mythen3] */
void setPattern(const std::string &fname, Positions pos = {});
- /** [CTB] */
+ /** [CTB][Moench][Mythen3] */
void savePattern(const std::string &fname);
- /** [CTB] */
+ /** [CTB][Moench][Mythen3] */
Result getPatternIOControl(Positions pos = {}) const;
- /** [CTB] */
+ /** [CTB][Moench][Mythen3] */
void setPatternIOControl(uint64_t word, Positions pos = {});
- /** [CTB] */
+ /** [CTB][Moench][Mythen3] */
Result getPatternClockControl(Positions pos = {}) const;
- /** [CTB] */
+ /** [CTB][Moench][Mythen3] */
void setPatternClockControl(uint64_t word, Positions pos = {});
- /** [CTB] same as executing
- * [Mythen3] */
+ /** [CTB][Moench][Mythen3] same as executing for ctb and moench */
Result getPatternWord(int addr, Positions pos = {});
/** [CTB] Caution: If word is -1 reads the addr (same as
* executing the pattern)
- * [Mythen3] */
+ * [Mythen3][Moench] */
void setPatternWord(int addr, uint64_t word, Positions pos = {});
- /**[CTB][Mythen3] Options: level: -1 (complete pattern) and 0-2 levels
+ /**[CTB][Moench][Mythen3] Options: level: -1 (complete pattern) and 0-2 levels
* @returns array of start address and stop address
*/
Result> getPatternLoopAddresses(int level,
Positions pos = {}) const;
- /** [CTB][Mythen3] Options: level: -1 (complete pattern) and 0-2 levels */
+ /** [CTB][Moench][Mythen3] Options: level: -1 (complete pattern) and 0-2 levels */
void setPatternLoopAddresses(int level, int start, int stop, Positions pos = {});
- /**[CTB][Mythen3] Options: level: -1 (complete pattern) and 0-2 levels
+ /**[CTB][Moench][Mythen3] Options: level: -1 (complete pattern) and 0-2 levels
* @returns number of loops
*/
Result getPatternLoopCycles(int level, Positions pos = {}) const;
- /** [CTB][Mythen3] n: 0-2, level: -1 (complete pattern) and 0-2 levels */
+ /** [CTB][Moench][Mythen3] n: 0-2, level: -1 (complete pattern) and 0-2 levels */
void setPatternLoopCycles(int level, int n, Positions pos = {});
- /* [CTB][Mythen3] */
+ /* [CTB][Moench][Mythen3] */
Result getPatternWaitAddr(int level, Positions pos = {}) const;
- /** [CTB][Mythen3] Options: level 0-2 */
+ /** [CTB][Moench][Mythen3] Options: level 0-2 */
void setPatternWaitAddr(int level, int addr, Positions pos = {});
- /** [CTB][Mythen3] */
+ /** [CTB][Moench][Mythen3] */
Result getPatternWaitTime(int level, Positions pos = {}) const;
- /** [CTB][Mythen3] Options: level 0-2 */
+ /** [CTB][Moench][Mythen3] Options: level 0-2 */
void setPatternWaitTime(int level, uint64_t t, Positions pos = {});
- /** [CTB][Mythen3] */
+ /** [CTB][Moench][Mythen3] */
Result getPatternMask(Positions pos = {});
- /** [CTB][Mythen3] Sets the mask applied to every pattern to the selected bit mask */
+ /** [CTB][Moench][Mythen3] Sets the mask applied to every pattern to the selected bit mask */
void setPatternMask(uint64_t mask, Positions pos = {});
- /** [CTB][Mythen3] */
+ /** [CTB][Moench][Mythen3] */
Result getPatternBitMask(Positions pos = {}) const;
- /** [CTB][Mythen3] Sets the bitmask that the mask will be applied to for every
+ /** [CTB][Moench][Mythen3] Sets the bitmask that the mask will be applied to for every
* pattern
*/
void setPatternBitMask(uint64_t mask, Positions pos = {});
@@ -1238,26 +1237,26 @@ class Detector {
* *
* ************************************************/
- /** [Jungfrau][CTB] fname is a pof file
+ /** [Jungfrau][CTB][Moench] fname is a pof file
* [Mythen3][Gotthard2] fname is an rbf file
*/
void programFPGA(const std::string &fname, Positions pos = {});
- /** [Jungfrau][CTB] */
+ /** [Jungfrau][CTB][Moench] */
void resetFPGA(Positions pos = {});
- /** [Jungfrau][Gotthard][CTB]
+ /** [Jungfrau][Gotthard][CTB][Moench]
* Copy detector server fname from tftp folder of hostname to detector
* Also changes respawn server, which is effective after a reboot.
*/
void copyDetectorServer(const std::string &fname,
const std::string &hostname, Positions pos = {});
- /** [Jungfrau][Gotthard][CTB][Mythen3][Gotthard2] */
+ /** [Jungfrau][Gotthard][CTB][Moench][Mythen3][Gotthard2] */
void rebootController(Positions pos = {});
/**
- * [Jungfrau][Gotthard][CTB]
+ * [Jungfrau][Gotthard][CTB][Moench]
* Updates the firmware, detector server and then reboots detector
* controller blackfin.
* @param sname name of detector server binary found on tftp folder of host
@@ -1278,13 +1277,13 @@ class Detector {
void clearBit(uint32_t addr, int bitnr, Positions pos = {});
- /** [Gotthard][Jungfrau][Mythen3][Gotthard2][CTB] */
+ /** [Gotthard][Jungfrau][Mythen3][Gotthard2][CTB][Moench] */
void executeFirmwareTest(Positions pos = {});
- /** [Gotthard][Jungfrau][Mythen3][Gotthard2][CTB] */
+ /** [Gotthard][Jungfrau][Mythen3][Gotthard2][CTB][Moench] */
void executeBusTest(Positions pos = {});
- /** [Gotthard][Jungfrau][CTB] not possible to read back*/
+ /** [Gotthard][Jungfrau][CTB][Moench] not possible to read back*/
void writeAdcRegister(uint32_t addr, uint32_t value, Positions pos = {});
bool getInitialChecks() const;
@@ -1293,6 +1292,12 @@ class Detector {
* default enabled */
void setInitialChecks(const bool value);
+ /** [CTB][Moench][Jungfrau] */
+ Result getADCInvert(Positions pos = {}) const;
+
+ /** [CTB][Moench][Jungfrau] */
+ void setADCInvert(uint32_t value, Positions pos = {});
+
/**************************************************
* *
* Insignificant *
@@ -1321,15 +1326,15 @@ class Detector {
/** Execute a command on the detector server console */
void executeCommand(const std::string &value, Positions pos = {});
- /** [Jungfrau][Mythen3][CTB]
+ /** [Jungfrau][Mythen3][CTB][Moench]
* [Gotthard2] only in continuous mode */
Result getNumberOfFramesFromStart(Positions pos = {}) const;
- /** [Jungfrau][Mythen3][CTB] Get time from detector start
+ /** [Jungfrau][Mythen3][CTB][Moench] Get time from detector start
* [Gotthard2] only in continuous mode */
Result getActualTime(Positions pos = {}) const;
- /** [Jungfrau][Mythen3][CTB] Get timestamp at a frame start
+ /** [Jungfrau][Mythen3][CTB][Moench] Get timestamp at a frame start
* [Gotthard2] only in continuous mode */
Result getMeasurementTime(Positions pos = {}) const;
diff --git a/slsDetectorSoftware/src/CmdProxy.cpp b/slsDetectorSoftware/src/CmdProxy.cpp
index 0d72860f4..add741892 100644
--- a/slsDetectorSoftware/src/CmdProxy.cpp
+++ b/slsDetectorSoftware/src/CmdProxy.cpp
@@ -395,10 +395,10 @@ std::string CmdProxy::Adcphase(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
- os << "[n_value] [(optional)deg]\n\t[Jungfrau][Ctb][Gotthard] Phase "
+ os << "[n_value] [(optional)deg]\n\t[Jungfrau][Ctb][Moench][Moench][Gotthard] Phase "
"shift of ADC clock. \n\t[Jungfrau] Absolute phase shift. If deg "
"used, then shift in degrees. Changing Speed also resets "
- "adcphase to recommended defaults.\n\t[Ctb] Absolute phase "
+ "adcphase to recommended defaults.\n\t[Ctb][Moench] Absolute phase "
"shift. If deg used, then shift in degrees. Changing adcclk also "
"resets adcphase and sets it to previous values.\n\t[Gotthard] "
"Relative phase shift"
@@ -588,8 +588,10 @@ std::string CmdProxy::Dac(int action) {
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[dac index] [dac or mv value] [(optional unit) mv] "
- "\n\t[Ctb][Jungfrau] Dac."
+ "\n\t[Ctb] Dac."
<< '\n';
+ } else if (det->getDetectorType().squash(defs::GENERIC) != defs::CHIPTESTBOARD) {
+ throw sls::RuntimeError("Dac command can only be used for chip test board. Use daclist to get list of dac commands for current detector.");
} else if (action == defs::GET_ACTION) {
bool mv = false;
if (args.size() == 2) {
@@ -707,6 +709,11 @@ std::vector CmdProxy::DacCommands() {
"vth1", "vicin", "vcas", "vpreamp", "vpl", "vipre",
"viinsh", "vph", "vtrim", "vdcsh"};
break;
+ case defs::MOENCH:
+ return std::vector{"vbp_colbuf", "vipre", "vin_cm",
+ "vb_sda", "vcasc_sfp", "vout_cm",
+ "vipre_cds", "ibias_sfp"};
+ break;
case defs::CHIPTESTBOARD:
return std::vector{
"dac 0", "dac 1", "dac 2", "dac 3", "dac 4", "dac 5",
@@ -1316,26 +1323,29 @@ std::string CmdProxy::Counters(int action) {
return os.str();
}
-/* CTB Specific */
+/* CTB / Moench Specific */
std::string CmdProxy::Samples(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[n_samples]\n\t[CTB] Number of samples (both analog and "
- "digitial) expected."
+ "digitial) expected.\n\t[Moench] Number of samples (analog only)"
<< '\n';
} else if (action == defs::GET_ACTION) {
if (!args.empty()) {
WrongNumberOfParameters(0);
}
auto a = det->getNumberOfAnalogSamples({det_id});
- auto d = det->getNumberOfDigitalSamples({det_id});
- int as = a.squash(-1);
- int ds = d.squash(-1);
- if (as == -1 || ds == -1 || as != ds) { // check if a == d?
- throw sls::RuntimeError(
+ // get also digital samples for ctb and compare with analog
+ if (det->getDetectorType().squash() == defs::CHIPTESTBOARD) {
+ auto d = det->getNumberOfDigitalSamples({det_id});
+ int as = a.squash(-1);
+ int ds = d.squash(-1);
+ if (as == -1 || ds == -1 || as != ds) { // check if a == d?
+ throw sls::RuntimeError(
"Different samples. Use asamples or dsamples.");
+ }
}
os << OutString(a) << '\n';
} else if (action == defs::PUT_ACTION) {
@@ -1343,7 +1353,10 @@ std::string CmdProxy::Samples(int action) {
WrongNumberOfParameters(1);
}
det->setNumberOfAnalogSamples(std::stoi(args[0]), {det_id});
- det->setNumberOfDigitalSamples(std::stoi(args[0]), {det_id});
+ // set also digital samples for ctb
+ if (det->getDetectorType().squash() == defs::CHIPTESTBOARD) {
+ det->setNumberOfDigitalSamples(std::stoi(args[0]), {det_id});
+ }
os << args.front() << '\n';
} else {
throw sls::RuntimeError("Unknown action");
@@ -1351,6 +1364,8 @@ std::string CmdProxy::Samples(int action) {
return os.str();
}
+/* CTB Specific */
+
std::string CmdProxy::Dbitphase(int action) {
std::ostringstream os;
os << cmd << ' ';
@@ -1499,7 +1514,7 @@ std::string CmdProxy::Pattern(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
- os << "[fname]\n\t[Mythen3][Ctb] Loads binary pattern file with only pattern "
+ os << "[fname]\n\t[Mythen3][Moench][Ctb][Moench] Loads binary pattern file with only pattern "
"words"
<< '\n';
} else if (action == defs::GET_ACTION) {
@@ -1520,7 +1535,7 @@ std::string CmdProxy::PatternWord(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
- os << "[step or address] [64 bit mask]\n\t[Ctb][Mythen3] 64 bit pattern at "
+ os << "[step or address] [64 bit mask]\n\t[Ctb][Moench][Mythen3] 64 bit pattern at "
"address of pattern memory."
<< '\n';
} else if (action == defs::GET_ACTION) {
@@ -1546,17 +1561,17 @@ std::string CmdProxy::PatternLoopAddresses(int action) {
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
if (cmd == "patlimits") {
- os << "[start addr] [stop addr] \n\t[Ctb][Mythen3] Limits of complete "
+ os << "[start addr] [stop addr] \n\t[Ctb][Moench][Mythen3] Limits of complete "
"pattern."
<< '\n';
} else if (cmd == "patloop0") {
- os << "[start addr] [stop addr] \n\t[Ctb][Mythen3] Limits of loop 0."
+ os << "[start addr] [stop addr] \n\t[Ctb][Moench][Mythen3] Limits of loop 0."
<< '\n';
} else if (cmd == "patloop1") {
- os << "[start addr] [stop addr] \n\t[Ctb][Mythen3] Limits of loop 1."
+ os << "[start addr] [stop addr] \n\t[Ctb][Moench][Mythen3] Limits of loop 1."
<< '\n';
} else if (cmd == "patloop2") {
- os << "[start addr] [stop addr] \n\t[Ctb][Mythen3] Limits of loop 2."
+ os << "[start addr] [stop addr] \n\t[Ctb][Moench][Mythen3] Limits of loop 2."
<< '\n';
} else {
throw sls::RuntimeError(
@@ -1601,11 +1616,11 @@ std::string CmdProxy::PatternLoopCycles(int action) {
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
if (cmd == "patnloop0") {
- os << "[n_cycles] \n\t[Ctb][Mythen3] Number of cycles of loop 0." << '\n';
+ os << "[n_cycles] \n\t[Ctb][Moench][Mythen3] Number of cycles of loop 0." << '\n';
} else if (cmd == "patnloop1") {
- os << "[n_cycles] \n\t[Ctb][Mythen3] Number of cycles of loop 1." << '\n';
+ os << "[n_cycles] \n\t[Ctb][Moench][Mythen3] Number of cycles of loop 1." << '\n';
} else if (cmd == "patnloop2") {
- os << "[n_cycles] \n\t[Ctb][Mythen3] Number of cycles of loop 2." << '\n';
+ os << "[n_cycles] \n\t[Ctb][Moench][Mythen3] Number of cycles of loop 2." << '\n';
} else {
throw sls::RuntimeError(
"Unknown command, use list to list all commands");
@@ -1646,11 +1661,11 @@ std::string CmdProxy::PatternWaitAddress(int action) {
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
if (cmd == "patwait0") {
- os << "[addr] \n\t[Ctb][Mythen3] Wait 0 address." << '\n';
+ os << "[addr] \n\t[Ctb][Moench][Mythen3] Wait 0 address." << '\n';
} else if (cmd == "patwait1") {
- os << "[addr] \n\t[Ctb][Mythen3] Wait 1 address." << '\n';
+ os << "[addr] \n\t[Ctb][Moench][Mythen3] Wait 1 address." << '\n';
} else if (cmd == "patwait2") {
- os << "[addr] \n\t[Ctb][Mythen3] Wait 2 address." << '\n';
+ os << "[addr] \n\t[Ctb][Moench][Mythen3] Wait 2 address." << '\n';
} else {
throw sls::RuntimeError(
"Unknown command, use list to list all commands");
@@ -1691,11 +1706,11 @@ std::string CmdProxy::PatternWaitTime(int action) {
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
if (cmd == "patwaittime0") {
- os << "[n_clk] \n\t[Ctb][Mythen3] Wait 0 time in clock cycles." << '\n';
+ os << "[n_clk] \n\t[Ctb][Moench][Mythen3] Wait 0 time in clock cycles." << '\n';
} else if (cmd == "patwaittime1") {
- os << "[n_clk] \n\t[Ctb][Mythen3] Wait 1 time in clock cycles." << '\n';
+ os << "[n_clk] \n\t[Ctb][Moench][Mythen3] Wait 1 time in clock cycles." << '\n';
} else if (cmd == "patwaittime2") {
- os << "[n_clk] \n\t[Ctb][Mythen3] Wait 2 time in clock cycles." << '\n';
+ os << "[n_clk] \n\t[Ctb][Moench][Mythen3] Wait 2 time in clock cycles." << '\n';
} else {
throw sls::RuntimeError(
"Unknown command, use list to list all commands");
@@ -1811,7 +1826,7 @@ std::string CmdProxy::ProgramFpga(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
- os << "[fname.pof | fname.rbf]\n\t[Jungfrau][Ctb] Programs FPGA from pof file."
+ os << "[fname.pof | fname.rbf]\n\t[Jungfrau][Ctb][Moench] Programs FPGA from pof file."
<< "\n\t[Mythen3][Gotthard2] Programs FPGA from rbf file."
<< '\n';
} else if (action == defs::GET_ACTION) {
@@ -1832,7 +1847,7 @@ std::string CmdProxy::CopyDetectorServer(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
- os << "[server_name] [pc_host_name]\n\t[Jungfrau][Ctb] Copies detector "
+ os << "[server_name] [pc_host_name]\n\t[Jungfrau][Ctb][Moench] Copies detector "
"server via tftp from pc and changes respawn server name in "
"/etc/inittab of detector."
<< '\n';
@@ -1854,7 +1869,7 @@ std::string CmdProxy::UpdateFirmwareAndDetectorServer(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
- os << "[server_name] [pc_host_name] [fname.pof]\n\t[Jungfrau][Ctb] "
+ os << "[server_name] [pc_host_name] [fname.pof]\n\t[Jungfrau][Ctb][Moench] "
"Updates detector server via tftp from pc, updates firmware to "
"pof file and then reboots controller (blackfin)."
<< '\n';
@@ -1904,7 +1919,7 @@ std::string CmdProxy::AdcRegister(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
- os << "[address] [value]\n\t[Jungfrau][Ctb][Gotthard] Writes to an adc "
+ os << "[address] [value]\n\t[Jungfrau][Ctb][Moench][Gotthard] Writes to an adc "
"register in hex."
<< '\n';
} else if (action == defs::GET_ACTION) {
diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h
index 1a5adeca4..d5d072df0 100644
--- a/slsDetectorSoftware/src/CmdProxy.h
+++ b/slsDetectorSoftware/src/CmdProxy.h
@@ -666,6 +666,12 @@ class CmdProxy {
{"vb_pixbuf", &CmdProxy::vb_pixbuf},
{"vin_com", &CmdProxy::vin_com},
{"vdd_prot", &CmdProxy::vdd_prot},
+ {"vbp_colbuf", &CmdProxy::vbp_colbuf},
+ {"vb_sda", &CmdProxy::vb_sda},
+ {"vcasc_sfp", &CmdProxy::vcasc_sfp},
+ {"vipre_cds", &CmdProxy::vipre_cds},
+ {"ibias_sfp", &CmdProxy::ibias_sfp},
+
{"dac", &CmdProxy::Dac},
{"daclist", &CmdProxy::DacList},
@@ -796,20 +802,24 @@ class CmdProxy {
/* Mythen3 Specific */
{"counters", &CmdProxy::Counters},
- /* CTB Specific */
+ /* CTB/ Moench Specific */
{"samples", &CmdProxy::Samples},
{"asamples", &CmdProxy::asamples},
- {"dsamples", &CmdProxy::dsamples},
- {"romode", &CmdProxy::romode},
- {"dbitphase", &CmdProxy::Dbitphase},
- {"maxdbitphaseshift", &CmdProxy::maxdbitphaseshift},
{"adcclk", &CmdProxy::adcclk},
- {"dbitclk", &CmdProxy::dbitclk},
{"runclk", &CmdProxy::runclk},
{"syncclk", &CmdProxy::syncclk},
{"adcpipeline", &CmdProxy::adcpipeline},
- {"dbitpipeline", &CmdProxy::dbitpipeline},
{"v_limit", &CmdProxy::v_limit},
+ {"adcenable", &CmdProxy::adcenable},
+ {"adcenable10g", &CmdProxy::adcenable10g},
+
+ /* CTB Specific */
+ {"dsamples", &CmdProxy::dsamples},
+ {"romode", &CmdProxy::romode},
+ {"dbitclk", &CmdProxy::dbitclk},
+ {"dbitphase", &CmdProxy::Dbitphase},
+ {"maxdbitphaseshift", &CmdProxy::maxdbitphaseshift},
+ {"dbitpipeline", &CmdProxy::dbitpipeline},
{"v_a", &CmdProxy::v_a},
{"v_b", &CmdProxy::v_b},
{"v_c", &CmdProxy::v_c},
@@ -827,9 +837,6 @@ class CmdProxy {
{"im_d", &CmdProxy::im_d},
{"im_io", &CmdProxy::im_io},
{"adc", &CmdProxy::SlowAdc},
- {"adcenable", &CmdProxy::adcenable},
- {"adcenable10g", &CmdProxy::adcenable10g},
- {"adcinvert", &CmdProxy::adcinvert},
{"extsampling", &CmdProxy::extsampling},
{"extsamplingsrc", &CmdProxy::extsamplingsrc},
{"rx_dbitlist", &CmdProxy::ReceiverDbitList},
@@ -881,6 +888,7 @@ class CmdProxy {
{"firmwaretest", &CmdProxy::firmwaretest},
{"bustest", &CmdProxy::bustest},
{"initialchecks", &CmdProxy::InitialChecks},
+ {"adcinvert", &CmdProxy::adcinvert},
/* Insignificant */
{"port", &CmdProxy::port},
@@ -955,8 +963,9 @@ class CmdProxy {
std::string BurstMode(int action);
/* Mythen3 Specific */
std::string Counters(int action);
- /* CTB Specific */
+ /* CTB/ Moench Specific */
std::string Samples(int action);
+ /* CTB Specific */
std::string Dbitphase(int action);
std::string SlowAdc(int action);
std::string ReceiverDbitList(int action);
@@ -1034,38 +1043,38 @@ class CmdProxy {
"\n\t[Gotthard2] Uploaded to detector just before acquisition starts");
TIME_COMMAND(delay, getDelayAfterTrigger, setDelayAfterTrigger,
- "[duration] [(optional unit) ns|us|ms|s]\n\t[Jungfrau][Gotthard][Mythen3][Gotthard2][Ctb] Delay after trigger");
+ "[duration] [(optional unit) ns|us|ms|s]\n\t[Jungfrau][Gotthard][Mythen3][Gotthard2][Ctb][Moench] Delay after trigger");
TIME_COMMAND(burstperiod, getBurstPeriod, setBurstPeriod,
"[duration] [(optional unit) ns|us|ms|s]\n\t[Gotthard2] Burst period. Only in burst mode and auto timing mode.");
GET_COMMAND(framesl, getNumberOfFramesLeft,
- "\n\t[Gotthard][Jungfrau][Mythen3][Gotthard2][CTB] Number of frames left in acquisition."
+ "\n\t[Gotthard][Jungfrau][Mythen3][Gotthard2][CTB][Moench] Number of frames left in acquisition."
"\n\t[Gotthard2] only in continuous mode.");
GET_COMMAND(triggersl, getNumberOfTriggersLeft,
- "\n\t[Gotthard][Jungfrau][Mythen3][Gotthard2][CTB] Number of triggers left in acquisition."
+ "\n\t[Gotthard][Jungfrau][Mythen3][Gotthard2][CTB][Moench] Number of triggers left in acquisition."
"\n\t[Gotthard2] only in continuous mode.");
TIME_GET_COMMAND(delayl, getDelayAfterTriggerLeft,
- "\n\t[Gotthard][Jungfrau][Mythen3][Gotthard2][CTB] DelayLeft Delay Left in Acquisition."
+ "\n\t[Gotthard][Jungfrau][Mythen3][Gotthard2][CTB][Moench] DelayLeft Delay Left in Acquisition."
"\n\t[Gotthard2] only in continuous mode.");
TIME_GET_COMMAND(periodl, getPeriodLeft,
- "\n\t[Gotthard][Jungfrau][Mythen3][Gotthard2][CTB] Period left for current frame."
+ "\n\t[Gotthard][Jungfrau][Mythen3][Gotthard2][CTB][Moench] Period left for current frame."
"\n\t[Gotthard2] only in continuous mode.");
INTEGER_COMMAND(timing, getTimingMode, setTimingMode, sls::StringTo,
- "[auto|trigger|gating|burst_trigger]\n\tTiming Mode of detector.\n\t[Jungfrau][Gotthard][Mythen3][Gotthard2][Ctb] [auto|trigger]\n\t[Eiger] [auto|trigger|gating|burst_trigger]");
+ "[auto|trigger|gating|burst_trigger]\n\tTiming Mode of detector.\n\t[Jungfrau][Gotthard][Mythen3][Gotthard2][Ctb][Moench] [auto|trigger]\n\t[Eiger] [auto|trigger|gating|burst_trigger]");
GET_COMMAND(maxadcphaseshift, getMaxADCPhaseShift,
- "\n\t[Jungfrau][CTB] Absolute maximum Phase shift of ADC clock.");
+ "\n\t[Jungfrau][CTB][Moench] Absolute maximum Phase shift of ADC clock.");
INTEGER_COMMAND(vhighvoltage, getHighVoltage, setHighVoltage, std::stoi,
"[n_value]\n\tHigh voltage to the sensor in Voltage."
"\n\t[Gotthard] [0|90|110|120|150|180|200]"
"\n\t[Eiger][Mythen3][Gotthard2] 0-200"
- "\n\t[Jungfrau][Ctb] [0|60-200]");
+ "\n\t[Jungfrau][Ctb][Moench] [0|60-200]");
INTEGER_COMMAND(powerchip, getPowerChip, setPowerChip, std::stoi,
"[0, 1]\n\t[Jungfrau][Mythen3][Gotthard2] Power the chip. Default 0."
@@ -1169,13 +1178,13 @@ class CmdProxy {
"[dac or mv value][(optional unit) mv] \n\t[Gotthard] Dac for ?? "); //TODO
DAC_COMMAND(vout_cm, getDAC, setDAC, defs::VOUT_CM,
- "[dac or mv value][(optional unit) mv] \n\t[Gotthard] Dac for ?? "); //TODO
+ "[dac or mv value][(optional unit) mv] \n\t[Gotthard] Dac for ?? \n\t[Moench] Dac for 5"); //TODO
DAC_COMMAND(vcasc_out, getDAC, setDAC, defs::VCASC_OUT,
"[dac or mv value][(optional unit) mv] \n\t[Gotthard] Dac for ?? "); //TODO
DAC_COMMAND(vin_cm, getDAC, setDAC, defs::VIN_CM,
- "[dac or mv value][(optional unit) mv] \n\t[Gotthard] Dac for ?? "); //TODO
+ "[dac or mv value][(optional unit) mv] \n\t[Gotthard] Dac for ?? \n\t[Moench] Dac for 2"); //TODO
DAC_COMMAND(vref_comp, getDAC, setDAC, defs::VREF_COMP,
"[dac or mv value][(optional unit) mv] \n\t[Gotthard][Jungfrau] Dac for ?? "); //TODO
@@ -1193,7 +1202,7 @@ class CmdProxy {
"[dac or mv value][(optional unit) mv] \n\t[Mythen3] voltage to define feedback resistance of the second shaper.");
DAC_COMMAND(vipre, getDAC, setDAC, defs::VIPRE,
- "[dac or mv value][(optional unit) mv] \n\t[Mythen3] Dac for the preamplifier's input transistor current.");
+ "[dac or mv value][(optional unit) mv] \n\t[Mythen3] Dac for the preamplifier's input transistor current.\n\t[Moench] Dac for 1");
DAC_COMMAND(viinsh, getDAC, setDAC, defs::VIINSH,
"[dac or mv value][(optional unit) mv] \n\t[Mythen3] Dac for the bias current for the shaper.");
@@ -1274,7 +1283,7 @@ class CmdProxy {
"[dac or mv value][(optional unit) mv] \n\t[Gotthard2] Dac for common mode voltage of ADC DAC bank 2.");
DAC_COMMAND(adcvpp, getDAC, setDAC, defs::ADC_VPP,
- "[dac or mv value][(optional unit) mv] \n\t[Ctb] Vpp of ADC.\n\t 0 -> 1V ; 1 -> 1.14V ; 2 -> 1.33V ; 3 -> 1.6V ; 4 -> 2V.");
+ "[dac or mv value][(optional unit) mv] \n\t[Ctb][Moench] Vpp of ADC.\n\t 0 -> 1V ; 1 -> 1.14V ; 2 -> 1.33V ; 3 -> 1.6V ; 4 -> 2V.");
DAC_COMMAND(vb_ds, getDAC, setDAC, defs::VB_DS,
"[dac or mv value][(optional unit) mv] \n\t[Jungfrau] Dac for ??"); //TODO
@@ -1291,6 +1300,21 @@ class CmdProxy {
DAC_COMMAND(vdd_prot, getDAC, setDAC, defs::VDD_PROT,
"[dac or mv value][(optional unit) mv] \n\t[Jungfrau] Dac for ??"); //TODO
+ DAC_COMMAND(vbp_colbuf, getDAC, setDAC, defs::VBP_COLBUF,
+ "[dac or mv value][(optional unit) mv] \n\t[Moench] Dac for 0");
+
+ DAC_COMMAND(vb_sda, getDAC, setDAC, defs::VB_SDA,
+ "[dac or mv value][(optional unit) mv] \n\t[Moench] Dac for 3");
+
+ DAC_COMMAND(vcasc_sfp, getDAC, setDAC, defs::VCASC_SFP,
+ "[dac or mv value][(optional unit) mv] \n\t[Moench] Dac for 4");
+
+ DAC_COMMAND(vipre_cds, getDAC, setDAC, defs::VIPRE_CDS,
+ "[dac or mv value][(optional unit) mv] \n\t[Moench] Dac for 6");
+
+ DAC_COMMAND(ibias_sfp, getDAC, setDAC, defs::IBIAS_SFP,
+ "[dac or mv value][(optional unit) mv] \n\t[Moench] Dac for 7");
+
/* on chip dacs */
INTEGER_USER_IND_COMMAND(vchip_comp_fe, getOnChipDAC, setOnChipDAC, stoiHex, defs::VB_COMP_FE,
@@ -1391,7 +1415,7 @@ class CmdProxy {
"\n\tPrints the receiver configuration.");
INTEGER_COMMAND(tengiga, getTenGiga, setTenGiga, std::stoi,
- "[0, 1]\n\t[Eiger][Ctb] 10GbE Enable.");
+ "[0, 1]\n\t[Eiger][Ctb][Moench] 10GbE Enable.");
INTEGER_COMMAND(flowcontrol10g, getTenGigaFlowControl, setTenGigaFlowControl, std::stoi,
"[0, 1]\n\t[Eiger][Jungfrau] 10GbE Flow Control.");
@@ -1574,10 +1598,34 @@ class CmdProxy {
/* Mythen3 Specific */
- /* CTB Specific */
+ /* CTB/ Moench Specific */
INTEGER_COMMAND(asamples, getNumberOfAnalogSamples, setNumberOfAnalogSamples, std::stoi,
- "[0, 1]\n\t[CTB] Number of analog samples expected.");
+ "[0, 1]\n\t[CTB][Moench] Number of analog samples expected.");
+
+ INTEGER_COMMAND(adcclk, getADCClock, setADCClock, std::stoi,
+ "[n_clk in MHz]\n\t[Ctb][Moench] ADC clock frequency in MHz.");
+
+ INTEGER_COMMAND(runclk, getRUNClock, setRUNClock, std::stoi,
+ "[n_clk in MHz]\n\t[Ctb][Moench] Run clock in MHz.");
+
+ GET_COMMAND(syncclk, getSYNCClock,
+ "[n_clk in MHz]\n\t[Ctb][Moench] Sync clock in MHz.");
+
+ INTEGER_COMMAND(adcpipeline, getADCPipeline, setADCPipeline, std::stoi,
+ "[n_value]\n\t[Ctb][Moench] Pipeline for ADC clock.");
+
+ INTEGER_IND_COMMAND(v_limit, getVoltage, setVoltage, std::stoi, defs::V_LIMIT,
+ "[n_value]\n\t[Ctb][Moench] Soft limit for power supplies(ctb only) and DACS in mV.");
+
+ INTEGER_COMMAND_HEX(adcenable, getADCEnableMask, setADCEnableMask, stoiHex,
+ "[bitmask]\n\t[Ctb][Moench] ADC Enable Mask for 1Gb Mode for each 32 ADC channel.");
+
+ INTEGER_COMMAND_HEX(adcenable10g, getTenGigaADCEnableMask, setTenGigaADCEnableMask, stoiHex,
+ "[bitmask]\n\t[Ctb][Moench] ADC Enable Mask for 10Gb mode for each 32 ADC channel. However, if any of consecutive 4 bits are enabled, the complete 4 bits are enabled.");
+
+ /* CTB Specific */
+
INTEGER_COMMAND(dsamples, getNumberOfDigitalSamples, setNumberOfDigitalSamples, std::stoi,
"[0, 1]\n\t[CTB] Number of digital samples expected.");
@@ -1585,30 +1633,15 @@ class CmdProxy {
INTEGER_COMMAND(romode, getReadoutMode, setReadoutMode, sls::StringTo,
"[analog|digital|analog_digital]\n\t[CTB] Readout mode. Default is analog.");
- GET_COMMAND(maxdbitphaseshift, getMaxDBITPhaseShift,
- "\n\t[CTB] Absolute maximum Phase shift of of the clock to latch digital bits.");
-
- INTEGER_COMMAND(adcclk, getADCClock, setADCClock, std::stoi,
- "[n_clk in MHz]\n\t[Ctb] ADC clock frequency in MHz.");
-
INTEGER_COMMAND(dbitclk, getDBITClock, setDBITClock, std::stoi,
"[n_clk in MHz]\n\t[Ctb] Clock for latching the digital bits in MHz.");
- INTEGER_COMMAND(runclk, getRUNClock, setRUNClock, std::stoi,
- "[n_clk in MHz]\n\t[Ctb] Run clock in MHz.");
-
- GET_COMMAND(syncclk, getSYNCClock,
- "[n_clk in MHz]\n\t[Ctb] Synch clock in MHz.");
-
- INTEGER_COMMAND(adcpipeline, getADCPipeline, setADCPipeline, std::stoi,
- "[n_value]\n\t[Ctb] Pipeline for ADC clock.");
+ GET_COMMAND(maxdbitphaseshift, getMaxDBITPhaseShift,
+ "\n\t[CTB] Absolute maximum Phase shift of of the clock to latch digital bits.");
INTEGER_COMMAND(dbitpipeline, getDBITPipeline, setDBITPipeline, std::stoi,
"[n_value]\n\t[Ctb] Pipeline of the clock for latching digital bits.");
- INTEGER_IND_COMMAND(v_limit, getVoltage, setVoltage, std::stoi, defs::V_LIMIT,
- "[n_value]\n\t[Ctb] Soft limit for power supplies and DACS in mV.");
-
INTEGER_IND_COMMAND(v_a, getVoltage, setVoltage, std::stoi, defs::V_POWER_A,
"[n_value]\n\t[Ctb] Voltage supply a in mV.");
@@ -1655,16 +1688,7 @@ class CmdProxy {
"\n\t[Ctb] Measured current of power supply d in mA.");
GET_IND_COMMAND(im_io, getMeasuredCurrent, defs::I_POWER_IO, "",
- "\n\t[Ctb] Measured current of power supply io in mA.");
-
- INTEGER_COMMAND_HEX(adcenable, getADCEnableMask, setADCEnableMask, stoiHex,
- "[bitmask]\n\t[Ctb] ADC Enable Mask for 1Gb Mode for each 32 ADC channel.");
-
- INTEGER_COMMAND_HEX(adcenable10g, getTenGigaADCEnableMask, setTenGigaADCEnableMask, stoiHex,
- "[bitmask]\n\t[Ctb] ADC Enable Mask for 10Gb mode for each 32 ADC channel. However, if any of consecutive 4 bits are enabled, the complete 4 bits are enabled.");
-
- INTEGER_COMMAND_HEX(adcinvert, getADCInvert, setADCInvert, stoiHex,
- "[bitmask]\n\t[Ctb][Jungfrau] ADC Inversion Mask.\n\t[Jungfrau] Inversions on top of the default mask.");
+ "\n\t[Ctb] Measured current of power supply io in mA.");
INTEGER_COMMAND(extsampling, getExternalSampling, setExternalSampling, std::stoi,
"[0, 1]\n\t[Ctb] Enable for external sampling signal to extsamplingsrc signal for digital data. For advanced users only.");
@@ -1682,19 +1706,19 @@ class CmdProxy {
/* Pattern */
EXECUTE_SET_COMMAND_NOID_1ARG(savepattern, savePattern,
- "[fname]\n\t[Ctb] Saves pattern to file (ascii). Also executes pattern.");
+ "[fname]\n\t[Ctb][Moench][Mythen3] Saves pattern to file (ascii). Also executes pattern.");
INTEGER_COMMAND_HEX(patioctrl, getPatternIOControl, setPatternIOControl, stoulHex,
- "[64 bit mask]\n\t[Ctb] 64 bit mask defining input (0) and output (1) signals.");
+ "[64 bit mask]\n\t[Ctb][Moench][Mythen3] 64 bit mask defining input (0) and output (1) signals.");
INTEGER_COMMAND_HEX(patclkctrl, getPatternClockControl, setPatternClockControl, stoulHex,
- "[64 bit mask]\n\t[Ctb] 64 bit mask defining output clock enable.");
+ "[64 bit mask]\n\t[Ctb][Moench][Mythen3] 64 bit mask defining output clock enable.");
INTEGER_COMMAND_HEX(patmask, getPatternMask, setPatternMask, stoulHex,
- "[64 bit mask]\n\t[Ctb][Mythen3] 64 bit mask applied to every pattern. Only these bits for each pattern will be masked against.");
+ "[64 bit mask]\n\t[Ctb][Moench][Mythen3] 64 bit mask applied to every pattern. Only these bits for each pattern will be masked against.");
INTEGER_COMMAND_HEX(patsetbit, getPatternBitMask, setPatternBitMask, stoulHex,
- "[64 bit mask]\n\t[Ctb][Mythen3] 64 bit values applied to the selected patmask for every pattern.");
+ "[64 bit mask]\n\t[Ctb][Moench][Mythen3] 64 bit values applied to the selected patmask for every pattern.");
/* Moench */
@@ -1711,17 +1735,19 @@ class CmdProxy {
/* Advanced */
EXECUTE_SET_COMMAND(resetfpga, resetFPGA,
- "\n\t[Jungfrau][Ctb] Reset FPGA.");
+ "\n\t[Jungfrau][Ctb][Moench] Reset FPGA.");
EXECUTE_SET_COMMAND(rebootcontroller, rebootController,
- "\n\t[Jungfrau][Ctb][Gotthard][Mythen3][Gotthard2] Reboot controler (blackfin) of detector.");
+ "\n\t[Jungfrau][Ctb][Moench][Gotthard][Mythen3][Gotthard2] Reboot controler (blackfin) of detector.");
EXECUTE_SET_COMMAND(firmwaretest, executeFirmwareTest,
- "\n\t[Jungfrau][Gotthard][Mythen3][Gotthard2][Ctb] Firmware test, ie. reads a read fixed pattern from a register.");
+ "\n\t[Jungfrau][Gotthard][Mythen3][Gotthard2][Ctb][Moench] Firmware test, ie. reads a read fixed pattern from a register.");
EXECUTE_SET_COMMAND(bustest, executeBusTest,
- "\n\t[Jungfrau][Gotthard][Mythen3][Gotthard2][Ctb] Bus test, ie. keeps writing and reading back different values in R/W register.");
+ "\n\t[Jungfrau][Gotthard][Mythen3][Gotthard2][Ctb][Moench] Bus test, ie. keeps writing and reading back different values in R/W register.");
+ INTEGER_COMMAND_HEX(adcinvert, getADCInvert, setADCInvert, stoiHex,
+ "[bitmask]\n\t[Ctb][Moench][Jungfrau][Moench] ADC Inversion Mask.\n\t[Jungfrau][Moench] Inversions on top of the default mask.");
/* Insignificant */
@@ -1738,7 +1764,7 @@ class CmdProxy {
"\n\tClient IP Address that last communicated with the detector.");
GET_COMMAND(nframes, getNumberOfFramesFromStart,
- "\n\t[Jungfrau][Mythen3][Gotthard2][Moench][CTB] Number of frames from start run control."
+ "\n\t[Jungfrau][Mythen3][Gotthard2][Moench][CTB][Moench] Number of frames from start run control."
"\n\t[Gotthard2] only in continuous mode.");
TIME_GET_COMMAND(now, getActualTime,
diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp
index 51520f027..aa2e8be8b 100644
--- a/slsDetectorSoftware/src/Detector.cpp
+++ b/slsDetectorSoftware/src/Detector.cpp
@@ -1230,7 +1230,7 @@ void Detector::setCounterMask(uint32_t countermask, Positions pos) {
pimpl->Parallel(&slsDetector::setCounterMask, pos, countermask);
}
-// CTB Specific
+// CTB/ Moench Specific
Result Detector::getNumberOfAnalogSamples(Positions pos) const {
return pimpl->Parallel(&slsDetector::getNumberOfAnalogSamples, pos);
@@ -1240,46 +1240,6 @@ void Detector::setNumberOfAnalogSamples(int value, Positions pos) {
pimpl->Parallel(&slsDetector::setNumberOfAnalogSamples, pos, value);
}
-Result Detector::getNumberOfDigitalSamples(Positions pos) const {
- return pimpl->Parallel(&slsDetector::getNumberOfDigitalSamples, pos);
-}
-
-void Detector::setNumberOfDigitalSamples(int value, Positions pos) {
- pimpl->Parallel(&slsDetector::setNumberOfDigitalSamples, pos, value);
-}
-
-Result Detector::getReadoutMode(Positions pos) const {
- return pimpl->Parallel(&slsDetector::getReadoutMode, pos);
-}
-
-void Detector::setReadoutMode(defs::readoutMode value, Positions pos) {
- pimpl->Parallel(&slsDetector::setReadoutMode, pos, value);
-}
-
-Result Detector::getDBITPhase(Positions pos) const {
- return pimpl->Parallel(&slsDetector::getClockPhase, pos, defs::DBIT_CLOCK,
- false);
-}
-
-void Detector::setDBITPhase(int value, Positions pos) {
- pimpl->Parallel(&slsDetector::setClockPhase, pos, defs::DBIT_CLOCK, value,
- false);
-}
-
-Result Detector::getMaxDBITPhaseShift(Positions pos) const {
- return pimpl->Parallel(&slsDetector::getMaxClockPhaseShift, pos,
- defs::DBIT_CLOCK);
-}
-
-Result Detector::getDBITPhaseInDegrees(Positions pos) const {
- return pimpl->Parallel(&slsDetector::getClockPhase, pos, defs::DBIT_CLOCK,
- true);
-}
-
-void Detector::setDBITPhaseInDegrees(int value, Positions pos) {
- pimpl->Parallel(&slsDetector::setClockPhase, pos, defs::DBIT_CLOCK, value,
- true);
-}
Result Detector::getADCClock(Positions pos) const {
return pimpl->Parallel(&slsDetector::getClockFrequency, pos,
@@ -1291,16 +1251,6 @@ void Detector::setADCClock(int value_in_MHz, Positions pos) {
value_in_MHz);
}
-Result Detector::getDBITClock(Positions pos) const {
- return pimpl->Parallel(&slsDetector::getClockFrequency, pos,
- defs::DBIT_CLOCK);
-}
-
-void Detector::setDBITClock(int value_in_MHz, Positions pos) {
- pimpl->Parallel(&slsDetector::setClockFrequency, pos, defs::DBIT_CLOCK,
- value_in_MHz);
-}
-
Result Detector::getRUNClock(Positions pos) const {
return pimpl->Parallel(&slsDetector::getClockFrequency, pos,
defs::RUN_CLOCK);
@@ -1328,10 +1278,6 @@ Result Detector::getDBITPipeline(Positions pos) const {
return pimpl->Parallel(&slsDetector::getPipeline, pos, defs::DBIT_CLOCK);
}
-void Detector::setDBITPipeline(int value, Positions pos) {
- pimpl->Parallel(&slsDetector::setPipeline, pos, defs::DBIT_CLOCK, value);
-}
-
Result Detector::getVoltage(defs::dacIndex index, Positions pos) const {
switch (index) {
case defs::V_LIMIT:
@@ -1364,6 +1310,81 @@ void Detector::setVoltage(defs::dacIndex index, int value, Positions pos) {
pimpl->Parallel(&slsDetector::setDAC, pos, value, index, 1);
}
+Result Detector::getADCEnableMask(Positions pos) const {
+ return pimpl->Parallel(&slsDetector::getADCEnableMask, pos);
+}
+
+void Detector::setADCEnableMask(uint32_t mask, Positions pos) {
+ pimpl->Parallel(&slsDetector::setADCEnableMask, pos, mask);
+}
+
+Result Detector::getTenGigaADCEnableMask(Positions pos) const {
+ return pimpl->Parallel(&slsDetector::getTenGigaADCEnableMask, pos);
+}
+
+void Detector::setTenGigaADCEnableMask(uint32_t mask, Positions pos) {
+ pimpl->Parallel(&slsDetector::setTenGigaADCEnableMask, pos, mask);
+}
+
+// CTB Specific
+
+
+Result Detector::getNumberOfDigitalSamples(Positions pos) const {
+ return pimpl->Parallel(&slsDetector::getNumberOfDigitalSamples, pos);
+}
+
+void Detector::setNumberOfDigitalSamples(int value, Positions pos) {
+ pimpl->Parallel(&slsDetector::setNumberOfDigitalSamples, pos, value);
+}
+
+Result Detector::getReadoutMode(Positions pos) const {
+ return pimpl->Parallel(&slsDetector::getReadoutMode, pos);
+}
+
+void Detector::setReadoutMode(defs::readoutMode value, Positions pos) {
+ pimpl->Parallel(&slsDetector::setReadoutMode, pos, value);
+}
+
+Result Detector::getDBITClock(Positions pos) const {
+ return pimpl->Parallel(&slsDetector::getClockFrequency, pos,
+ defs::DBIT_CLOCK);
+}
+
+void Detector::setDBITClock(int value_in_MHz, Positions pos) {
+ pimpl->Parallel(&slsDetector::setClockFrequency, pos, defs::DBIT_CLOCK,
+ value_in_MHz);
+}
+
+Result Detector::getDBITPhase(Positions pos) const {
+ return pimpl->Parallel(&slsDetector::getClockPhase, pos, defs::DBIT_CLOCK,
+ false);
+}
+
+void Detector::setDBITPhase(int value, Positions pos) {
+ pimpl->Parallel(&slsDetector::setClockPhase, pos, defs::DBIT_CLOCK, value,
+ false);
+}
+
+Result Detector::getMaxDBITPhaseShift(Positions pos) const {
+ return pimpl->Parallel(&slsDetector::getMaxClockPhaseShift, pos,
+ defs::DBIT_CLOCK);
+}
+
+Result Detector::getDBITPhaseInDegrees(Positions pos) const {
+ return pimpl->Parallel(&slsDetector::getClockPhase, pos, defs::DBIT_CLOCK,
+ true);
+}
+
+void Detector::setDBITPhaseInDegrees(int value, Positions pos) {
+ pimpl->Parallel(&slsDetector::setClockPhase, pos, defs::DBIT_CLOCK, value,
+ true);
+}
+
+
+void Detector::setDBITPipeline(int value, Positions pos) {
+ pimpl->Parallel(&slsDetector::setPipeline, pos, defs::DBIT_CLOCK, value);
+}
+
Result Detector::getMeasuredVoltage(defs::dacIndex index,
Positions pos) const {
switch (index) {
@@ -1402,30 +1423,6 @@ Result Detector::getSlowADC(defs::dacIndex index, Positions pos) const {
return pimpl->Parallel(&slsDetector::getADC, pos, index);
}
-Result Detector::getADCEnableMask(Positions pos) const {
- return pimpl->Parallel(&slsDetector::getADCEnableMask, pos);
-}
-
-void Detector::setADCEnableMask(uint32_t mask, Positions pos) {
- pimpl->Parallel(&slsDetector::setADCEnableMask, pos, mask);
-}
-
-Result Detector::getTenGigaADCEnableMask(Positions pos) const {
- return pimpl->Parallel(&slsDetector::getTenGigaADCEnableMask, pos);
-}
-
-void Detector::setTenGigaADCEnableMask(uint32_t mask, Positions pos) {
- pimpl->Parallel(&slsDetector::setTenGigaADCEnableMask, pos, mask);
-}
-
-Result Detector::getADCInvert(Positions pos) const {
- return pimpl->Parallel(&slsDetector::getADCInvert, pos);
-}
-
-void Detector::setADCInvert(uint32_t value, Positions pos) {
- pimpl->Parallel(&slsDetector::setADCInvert, pos, value);
-}
-
Result Detector::getExternalSamplingSource(Positions pos) const {
return pimpl->Parallel(&slsDetector::getExternalSamplingSource, pos);
}
@@ -1747,6 +1744,14 @@ void Detector::setInitialChecks(const bool value) {
pimpl->setInitialChecks(value);
}
+Result Detector::getADCInvert(Positions pos) const {
+ return pimpl->Parallel(&slsDetector::getADCInvert, pos);
+}
+
+void Detector::setADCInvert(uint32_t value, Positions pos) {
+ pimpl->Parallel(&slsDetector::setADCInvert, pos, value);
+}
+
// Insignificant
Result Detector::getControlPort(Positions pos) const {
diff --git a/slsDetectorSoftware/src/DetectorImpl.cpp b/slsDetectorSoftware/src/DetectorImpl.cpp
index 22a211fe6..95eb7387d 100755
--- a/slsDetectorSoftware/src/DetectorImpl.cpp
+++ b/slsDetectorSoftware/src/DetectorImpl.cpp
@@ -557,7 +557,7 @@ void DetectorImpl::readFrameFromReceiver() {
uint32_t yoffset = coordY * nPixelsY;
uint32_t singledetrowoffset = nPixelsX * bytesPerPixel;
uint32_t rowoffset = nX * singledetrowoffset;
- if (multi_shm()->multiDetectorType == CHIPTESTBOARD) {
+ if (multi_shm()->multiDetectorType == MOENCH) {
singledetrowoffset = size;
nPixelsY = 1; // TODO: nDetPixelsY is not updated.
}
@@ -1070,6 +1070,7 @@ std::vector DetectorImpl::readProgrammingFile(const std::string &fname) {
switch (multi_shm()->multiDetectorType) {
case JUNGFRAU:
case CHIPTESTBOARD:
+ case MOENCH:
if (fname.find(".pof") == std::string::npos) {
throw RuntimeError("Programming file must be a pof file.");
}
diff --git a/slsDetectorSoftware/src/slsDetector.cpp b/slsDetectorSoftware/src/slsDetector.cpp
index 3519f582a..1a9c36e21 100755
--- a/slsDetectorSoftware/src/slsDetector.cpp
+++ b/slsDetectorSoftware/src/slsDetector.cpp
@@ -336,6 +336,7 @@ void slsDetector::initializeDetectorStructure(detectorType type) {
shm()->roMode = ANALOG_ONLY;
shm()->currentSettings = UNINITIALIZED;
shm()->currentThresholdEV = -1;
+ shm()->nASamples = 1;
shm()->nFrames = 1;
shm()->nTriggers = 1;
shm()->nBursts = 1;
@@ -557,8 +558,8 @@ slsDetectorDefs::detectorType slsDetector::getDetectorType() const {
}
void slsDetector::updateNumberOfChannels() {
- if (shm()->myDetectorType == CHIPTESTBOARD ||
- shm()->myDetectorType == MOENCH) {
+
+ if (shm()->myDetectorType == CHIPTESTBOARD) {
int nachans = 0, ndchans = 0;
// analog channels (normal, analog/digital readout)
@@ -577,15 +578,29 @@ void slsDetector::updateNumberOfChannels() {
}
// digital channels (ctb only, digital, analog/digital readout)
- if (shm()->myDetectorType == CHIPTESTBOARD &&
- (shm()->roMode == DIGITAL_ONLY ||
- shm()->roMode == ANALOG_AND_DIGITAL)) {
+ if (shm()->roMode == DIGITAL_ONLY ||
+ shm()->roMode == ANALOG_AND_DIGITAL) {
ndchans = 64;
FILE_LOG(logDEBUG1) << "#Digital Channels:" << ndchans;
}
shm()->nChan.x = nachans + ndchans;
FILE_LOG(logDEBUG1) << "# Total #Channels:" << shm()->nChan.x;
}
+
+
+ else if (shm()->myDetectorType == MOENCH) {
+ uint32_t mask = shm()->tenGigaEnable ? shm()->adcEnableMaskTenGiga : shm()->adcEnableMaskOneGiga;
+ // count number of channels in x, each adc has 25 channels each
+ int nchanTop = __builtin_popcount(mask & 0xF0F0F0F0) * 25;
+ int nchanBot = __builtin_popcount(mask & 0x0F0F0F0F) * 25;
+ shm()->nChan.x = nchanTop > 0 ? nchanTop : nchanBot;
+ // if both top and bottom adcs enabled, rows = 2
+ int nrows = 1;
+ if (nchanTop > 0 && nchanBot > 0) {
+ nrows = 2;
+ }
+ shm()->nChan.y = shm()->nASamples / 25 * nrows;
+ }
}
slsDetectorDefs::xy slsDetector::getNumberOfChannels() const {
@@ -807,11 +822,18 @@ void slsDetector::updateCachedDetectorVariables() {
shm()->tenGigaEnable = static_cast(i32);
}
+ // analog samples and adc enable masks
if (shm()->myDetectorType == CHIPTESTBOARD ||
shm()->myDetectorType == MOENCH) {
- // 1gb adcmask
+
+ // analog samples
uint32_t u32 = 0;
n += client.Receive(&u32, sizeof(u32));
+ shm()->nASamples = u32;
+
+ // 1gb adcmask
+ u32 = 0;
+ n += client.Receive(&u32, sizeof(u32));
shm()->adcEnableMaskOneGiga = u32;
// 10gb adcmask
@@ -1321,6 +1343,7 @@ int slsDetector::getNumberOfAnalogSamples() {
void slsDetector::setNumberOfAnalogSamples(int value) {
FILE_LOG(logDEBUG1) << "Setting number of analog samples to " << value;
sendToDetector(F_SET_NUM_ANALOG_SAMPLES, value, nullptr);
+ shm()->nASamples = value;
// update #nchan, as it depends on #samples, adcmask
updateNumberOfChannels();
if (shm()->useReceiverFlag) {
@@ -1836,7 +1859,6 @@ std::string slsDetector::setReceiverHostname(const std::string &receiverIP) {
case MOENCH:
setNumberOfAnalogSamples(getNumberOfAnalogSamples());
- setNumberOfDigitalSamples(getNumberOfDigitalSamples());
enableTenGigabitEthernet(static_cast(shm()->tenGigaEnable));
setADCEnableMask(shm()->adcEnableMaskOneGiga);
setTenGigaADCEnableMask(shm()->adcEnableMaskTenGiga);
@@ -2974,6 +2996,7 @@ void slsDetector::programFPGA(std::vector buffer) {
switch (shm()->myDetectorType) {
case JUNGFRAU:
case CHIPTESTBOARD:
+ case MOENCH:
programFPGAviaBlackfin(buffer);
break;
case MYTHEN3:
diff --git a/slsDetectorSoftware/src/slsDetector.h b/slsDetectorSoftware/src/slsDetector.h
index d5f318053..ff7cb8953 100755
--- a/slsDetectorSoftware/src/slsDetector.h
+++ b/slsDetectorSoftware/src/slsDetector.h
@@ -13,7 +13,7 @@
class ServerInterface;
#define SLS_SHMAPIVERSION 0x190726
-#define SLS_SHMVERSION 0x200225
+#define SLS_SHMVERSION 0x200302
/**
* @short structure allocated in shared memory to store detector settings for
@@ -80,6 +80,9 @@ struct sharedSlsDetector {
/** detector threshold (eV) */
int currentThresholdEV;
+ /** number of analog samples */
+ int nASamples;
+
/** number of frames */
int64_t nFrames;
@@ -295,7 +298,7 @@ class slsDetector : public virtual slsDetectorDefs {
/**
* Update total number of channels (chiptestboard or moench)
- * depending on the number of samples, adenablemask, readout flags(ctb)
+ * depending on the number of samples, adcenablemask, readout flags(ctb)
*/
void updateNumberOfChannels();
@@ -554,10 +557,10 @@ class slsDetector : public virtual slsDetectorDefs {
/** [Jungfrau] Advanced */
void setNumberOfAdditionalStorageCells(int value);
- /** [CTB] */
+ /** [CTB][Moench] */
int getNumberOfAnalogSamples();
- /** [CTB] */
+ /** [CTB][Moench] */
void setNumberOfAnalogSamples(int value);
/** [CTB] */
@@ -574,10 +577,10 @@ class slsDetector : public virtual slsDetectorDefs {
void setPeriod(int64_t value);
- /** [Gotthard][Jungfrau][CTB][Mythen3][Gotthard2] */
+ /** [Gotthard][Jungfrau][CTB][Moench][Mythen3][Gotthard2] */
int64_t getDelayAfterTrigger();
- /** [Gotthard][Jungfrau][CTB][Mythen3][Gotthard2] */
+ /** [Gotthard][Jungfrau][CTB][Moench][Mythen3][Gotthard2] */
void setDelayAfterTrigger(int64_t value);
/** [Gotthard2] only in burst mode and in auto timing mode */
@@ -605,22 +608,22 @@ class slsDetector : public virtual slsDetectorDefs {
* Options: (0-1638375 ns (resolution of 25ns) */
void setStorageCellDelay(int64_t value);
- /** [Gotthard][Jungfrau][CTB][Mythen3]
+ /** [Gotthard][Jungfrau][CTB][Moench][Mythen3]
* [Gotthard2] only in continuous mode */
int64_t getNumberOfFramesLeft() const;
- /** [Gotthard][Jungfrau][CTB][Mythen3]
+ /** [Gotthard][Jungfrau][CTB][Moench][Mythen3]
* [Gotthard2] only in continuous mode */
int64_t getNumberOfTriggersLeft() const;
- /** [Gotthard][Jungfrau][CTB]
+ /** [Gotthard][Jungfrau][CTB][Moench]
* [Gotthard2] only in continuous mode */
int64_t getDelayAfterTriggerLeft() const;
/** [Gotthard] */
int64_t getExptimeLeft() const;
- /** [Gotthard][Jungfrau][CTB][Mythen3][Gotthard2] */
+ /** [Gotthard][Jungfrau][CTB][Moench][Mythen3][Gotthard2] */
int64_t getPeriodLeft() const;
/** [Eiger] minimum two frames */
@@ -629,15 +632,15 @@ class slsDetector : public virtual slsDetectorDefs {
/** [Eiger] */
int64_t getMeasuredSubFramePeriod() const;
- /** [Jungfrau][CTB][Mythen3]
+ /** [Jungfrau][CTB][Moench][Mythen3]
* [Gotthard2] only in continuous mode */
int64_t getNumberOfFramesFromStart() const;
- /** [Jungfrau][CTB][Mythen3] Get time from detector start
+ /** [Jungfrau][CTB][Moench][Mythen3] Get time from detector start
* [Gotthard2] only in continuous mode */
int64_t getActualTime() const;
- /** [Jungfrau][CTB][Mythen3] Get timestamp at a frame start
+ /** [Jungfrau][CTB][Moench][Mythen3] Get timestamp at a frame start
* [Gotthard2] only in continuous mode */
int64_t getMeasurementTime() const;
@@ -727,13 +730,13 @@ class slsDetector : public virtual slsDetectorDefs {
bool getStoreInRamMode();
/**
- * Set readout mode (Only for CTB and Moench)
+ * [Ctb]
* @param mode readout mode Options: ANALOG_ONLY, DIGITAL_ONLY, ANALOG_AND_DIGITAL
*/
void setReadoutMode(const readoutMode mode);
/**
- * Get readout mode(Only for CTB and Moench)
+ * [Ctb]
* @returns readout mode
*/
readoutMode getReadoutMode();
@@ -1117,10 +1120,10 @@ class slsDetector : public virtual slsDetectorDefs {
*/
int64_t getReceiverRealUDPSocketBufferSize() const;
- /** [Gotthard][Jungfrau][CTB] */
+ /** [Gotthard][Jungfrau][CTB][Moench] */
void executeFirmwareTest();
- /** [Gotthard][Jungfrau][CTB] */
+ /** [Gotthard][Jungfrau][CTB][Moench] */
void executeBusTest();
/** [Gotthard] */
@@ -1222,14 +1225,14 @@ class slsDetector : public virtual slsDetectorDefs {
uint32_t getTenGigaADCEnableMask();
/**
- * Set ADC invert register (CTB, Moench)
+ * Set ADC invert register (CTB, Moench, Jungfrau)
* @param value ADC invert value
* @param detPos -1 for all detectors in list or specific detector position
*/
void setADCInvert(uint32_t value);
/**
- * Get ADC invert register (CTB, Moench)
+ * Get ADC invert register (CTB, Moench, Jungfrau)
* @param detPos -1 for all detectors in list or specific detector position
* @returns ADC invert value
*/
diff --git a/slsReceiverSoftware/src/ClientInterface.cpp b/slsReceiverSoftware/src/ClientInterface.cpp
index 2bd2be3c6..aadeb5ffe 100755
--- a/slsReceiverSoftware/src/ClientInterface.cpp
+++ b/slsReceiverSoftware/src/ClientInterface.cpp
@@ -529,7 +529,7 @@ int ClientInterface::set_num_analog_samples(Interface &socket) {
int ClientInterface::set_num_digital_samples(Interface &socket) {
auto value = socket.Receive();
FILE_LOG(logDEBUG1) << "Setting num digital samples to " << value;
- if (myDetectorType != CHIPTESTBOARD && myDetectorType != MOENCH) {
+ if (myDetectorType != CHIPTESTBOARD) {
functionNotImplemented();
}
try {
diff --git a/slsReceiverSoftware/src/DataProcessor.cpp b/slsReceiverSoftware/src/DataProcessor.cpp
index f81673b55..0a1905514 100755
--- a/slsReceiverSoftware/src/DataProcessor.cpp
+++ b/slsReceiverSoftware/src/DataProcessor.cpp
@@ -447,6 +447,7 @@ void DataProcessor::PadMissingPackets(char* buf) {
memset(buf + fifohsize + (pnum * dsize), 0xFF, dsize+2);
break;
case CHIPTESTBOARD:
+ case MOENCH:
if (pnum == (pperFrame-1))
memset(buf + fifohsize + (pnum * dsize), 0xFF, corrected_dsize);
else
diff --git a/slsReceiverSoftware/src/GeneralData.h b/slsReceiverSoftware/src/GeneralData.h
index 067505731..7e62c8353 100755
--- a/slsReceiverSoftware/src/GeneralData.h
+++ b/slsReceiverSoftware/src/GeneralData.h
@@ -629,13 +629,6 @@ private:
/** Number of bytes per analog channel */
const int NUM_BYTES_PER_ANALOG_CHANNEL = 2;
- struct ctb_10g_packet_header {
- unsigned char emptyHeader[6];
- unsigned char reserved[4];
- uint32_t packetFrameNumber;
- uint64_t bunchid;
- } __attribute__((packed));
-
public:
@@ -660,7 +653,7 @@ public:
};
/**
- * Set databytes (ctb, moench)
+ * Set databytes
* @param a adc enable mask
* @param as analog number of samples
* @param ds digital number of samples
@@ -700,50 +693,21 @@ public:
nPixelsX = nachans + ndchans;
nPixelsY = 1;
+
// 10G
if (t) {
- headerSizeinPacket = sizeof(slsDetectorDefs::sls_detector_header);
dataSize = 8144;
- packetSize = headerSizeinPacket + dataSize;
- imageSize = adatabytes + ddatabytes;
- packetsPerFrame = ceil((double)imageSize / (double)dataSize);
- standardheader = true;
-
- /*
- headerSizeinPacket = 22;
- dataSize = 8192;
- packetSize = headerSizeinPacket + dataSize;
- imageSize = adatabytes + ddatabytes;
- packetsPerFrame = ceil((double)imageSize / (double)dataSize);
- standardheader = false;
- */
}
// 1g udp (via fifo readout)
else {
- headerSizeinPacket = sizeof(slsDetectorDefs::sls_detector_header);
dataSize = UDP_PACKET_DATA_BYTES;
- packetSize = headerSizeinPacket + dataSize;
- imageSize = adatabytes + ddatabytes;
- packetsPerFrame = ceil((double)imageSize / (double)dataSize);
- standardheader = true;
}
- return adatabytes;
- }
- /**
- * Get Header Infomation (frame number, packet number)
- * @param index thread index for debugging purposes
- * @param packetData pointer to data
- * @param oddStartingPacket odd starting packet (gotthard)
- * @param frameNumber frame number
- * @param packetNumber packet number
- */
- void GetHeaderInfo(int index, char* packetData, bool oddStartingPacket,
- uint64_t& frameNumber, uint32_t& packetNumber) const
- {
- auto header = reinterpret_cast(packetData);
- frameNumber = (header->packetFrameNumber >> frameIndexOffset) & frameIndexMask;
- packetNumber = header->packetFrameNumber & packetIndexMask;
+ packetSize = headerSizeinPacket + dataSize;
+ imageSize = adatabytes + ddatabytes;
+ packetsPerFrame = ceil((double)imageSize / (double)dataSize);
+
+ return adatabytes;
}
};
@@ -769,14 +733,14 @@ public:
imageSize = nPixelsX * nPixelsY * 2;
packetsPerFrame = ceil((double)imageSize / (double)UDP_PACKET_DATA_BYTES);
frameIndexMask = 0xFFFFFF;
- maxFramesPerFile = CTB_MAX_FRAMES_PER_FILE;
+ maxFramesPerFile = MOENCH_MAX_FRAMES_PER_FILE;
fifoBufferHeaderSize = FIFO_HEADER_NUMBYTES + sizeof(slsDetectorDefs::sls_receiver_header);
defaultFifoDepth = 2500;
standardheader = true;
};
/**
- * Set databytes (ctb, moench)
+ * Set databytes
* @param a adc enable mask
* @param as analog number of samples
* @param ds digital number of samples
@@ -785,41 +749,37 @@ public:
* @returns analog data bytes
*/
int setImageSize(uint32_t a, uint32_t as, uint32_t ds, bool t, slsDetectorDefs::readoutMode) {
- int nachans = 0;
- int adatabytes = 0;
+
+ // count number of channels in x, each adc has 25 channels each
+ int nchanTop = __builtin_popcount(a & 0xF0F0F0F0) * 25;
+ int nchanBot = __builtin_popcount(a & 0x0F0F0F0F) * 25;
+ nPixelsX = nchanTop > 0 ? nchanTop : nchanBot;
+
+ // if both top and bottom adcs enabled, rows = 2
+ int nrows = 1;
+ if (nchanTop > 0 && nchanBot > 0) {
+ nrows = 2;
+ }
+ nPixelsY = as / 25 * nrows;
+ FILE_LOG(logINFO) << "Number of Pixels: [" << nPixelsX << ", " << nPixelsY << "]";
- // analog channels (normal, analog/digital readout)
- if (a == BIT32_MASK) {
- nachans = 32;
- } else {
- for (int ich = 0; ich < 32; ++ich) {
- if (a & (1 << ich))
- ++nachans;
- }
- }
- adatabytes = nachans * NUM_BYTES_PER_ANALOG_CHANNEL * as;
- FILE_LOG(logDEBUG1) << "Total Number of Channels:" << nachans
- << " Databytes: " << adatabytes;
- nPixelsX = nachans;
- nPixelsY = 1;
// 10G
if (t) {
- headerSizeinPacket = sizeof(slsDetectorDefs::sls_detector_header);
- dataSize = UDP_PACKET_DATA_BYTES;
- packetSize = headerSizeinPacket + dataSize;
- imageSize = adatabytes;
- packetsPerFrame = ceil((double)imageSize / (double)dataSize);
+ dataSize = 8144;
}
// 1g udp (via fifo readout)
else {
- headerSizeinPacket = sizeof(slsDetectorDefs::sls_detector_header);
- dataSize = UDP_PACKET_DATA_BYTES;
- packetSize = headerSizeinPacket + dataSize;
- imageSize = adatabytes;
- packetsPerFrame = ceil((double)imageSize / (double)dataSize);
+ dataSize = UDP_PACKET_DATA_BYTES;
}
- return adatabytes;
+
+ imageSize = nPixelsX * nPixelsY * NUM_BYTES_PER_ANALOG_CHANNEL;
+ packetSize = headerSizeinPacket + dataSize;
+ packetsPerFrame = ceil((double)imageSize / (double)dataSize);
+
+ FILE_LOG(logDEBUG) << "Databytes: " << imageSize;
+
+ return imageSize;
}
};
diff --git a/slsSupportLib/include/sls_detector_defs.h b/slsSupportLib/include/sls_detector_defs.h
index 6c1056f84..07e30f8f9 100755
--- a/slsSupportLib/include/sls_detector_defs.h
+++ b/slsSupportLib/include/sls_detector_defs.h
@@ -332,6 +332,11 @@ class slsDetectorDefs {
VB_PIXBUF,
VIN_COM,
VDD_PROT,
+ VBP_COLBUF,
+ VB_SDA,
+ VCASC_SFP,
+ VIPRE_CDS,
+ IBIAS_SFP,
V_POWER_A = 100,
V_POWER_B = 101,
V_POWER_C = 102,
diff --git a/slsSupportLib/include/versionAPI.h b/slsSupportLib/include/versionAPI.h
index b5d4b63ac..0c81f31b6 100644
--- a/slsSupportLib/include/versionAPI.h
+++ b/slsSupportLib/include/versionAPI.h
@@ -1,6 +1,5 @@
/** API versions */
#define GITBRANCH "developer"
-#define APIMOENCH 0x200131
#define APIMYTHEN3 0x200226
#define APIJUNGFRAU 0x200226
#define APIEIGER 0x200226
@@ -10,3 +9,4 @@
#define APIGUI 0x200227
#define APICTB 0x200227
#define APIGOTTHARD2 0x200228
+#define APIMOENCH 0x200302