partialread changed to readnrows

This commit is contained in:
2021-08-31 16:46:49 +02:00
parent 11b1d9f6db
commit 25d03f949e
35 changed files with 171 additions and 168 deletions

View File

@ -33,7 +33,7 @@ int Beb_top = 0;
uint64_t Beb_deactivatedNextFrameNumber = 0;
int Beb_quadEnable = 0;
int Beb_positions[2] = {0, 0};
int Beb_partialReadout = MAX_ROWS_PER_READOUT;
int Beb_readNRows = MAX_ROWS_PER_READOUT;
int Beb_deactivated_transmission_flowcontrol_10g = 0;
int Beb_deactivated_transmission_delay_frame = 0;
int Beb_deactivated_transmission_delay_left = 0;
@ -903,7 +903,7 @@ int Beb_RequestNImages(int ten_gig, unsigned int nimages, int test_just_send_out
unsigned int maxnl = MAX_ROWS_PER_READOUT;
unsigned int maxnp = (ten_gig ? 4 : 16) * Beb_bit_mode;
unsigned int nl = Beb_partialReadout;
unsigned int nl = Beb_readNRows;
unsigned int npackets = (nl * maxnp) / maxnl;
if ((nl * maxnp) % maxnl) {
LOG(logERROR, ("Read N Lines is incorrect. Switching to Full Image "
@ -1265,7 +1265,7 @@ int Beb_GetNextFrameNumber(uint64_t *retval, int tengigaEnable) {
return OK;
}
void Beb_SetPartialReadout(int value) { Beb_partialReadout = value; }
void Beb_SetReadNRows(int value) { Beb_readNRows = value; }
int Beb_GetNumberofDestinations(int *retval) {
if (!Beb_activated) {

View File

@ -1554,24 +1554,24 @@ int Feb_Control_SetChipSignalsToTrimQuad(int enable) {
return 1;
}
int Feb_Control_SetPartialReadout(int value) {
LOG(logINFO, ("Setting Partial Readout to %d\n", value));
int Feb_Control_SetReadNRows(int value) {
LOG(logINFO, ("Setting number of rows to %d\n", value));
if (!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),
DAQ_REG_PARTIAL_READOUT, value, 0, 0)) {
LOG(logERROR, ("Could not write %d to Partial Readout reg\n", value));
DAQ_REG_READ_N_ROWS, value, 0, 0)) {
LOG(logERROR, ("Could not write %d to number of rows reg\n", value));
return 0;
}
return 1;
}
int Feb_Control_GetPartialReadout() {
int Feb_Control_GetReadNRows() {
uint32_t regVal = 0;
if (!Feb_Interface_ReadRegister(Feb_Control_AddressToAll(),
DAQ_REG_PARTIAL_READOUT, &regVal)) {
LOG(logERROR, ("Could not read back Partial Readout reg\n"));
DAQ_REG_READ_N_ROWS, &regVal)) {
LOG(logERROR, ("Could not read back ReadNRows reg\n"));
return -1;
}
LOG(logDEBUG1, ("Retval Partial Readout: %d\n", regVal));
LOG(logDEBUG1, ("Retval ReadNRows: %d\n", regVal));
return regVal;
}

View File

@ -88,8 +88,8 @@ void Feb_Control_SetMasterVariable(int val);
int Feb_Control_SetMaster(enum MASTERINDEX ind);
int Feb_Control_SetQuad(int val);
int Feb_Control_SetChipSignalsToTrimQuad(int enable);
int Feb_Control_SetPartialReadout(int value);
int Feb_Control_GetPartialReadout();
int Feb_Control_SetReadNRows(int value);
int Feb_Control_GetReadNRows();
int Feb_Control_WriteRegister(uint32_t offset, uint32_t data);
int Feb_Control_ReadRegister(uint32_t offset, uint32_t *retval);

View File

@ -13,7 +13,7 @@
#define DAQ_REG_EXPOSURE_REPEAT_TIMER 5 // == (31 downto 3) * 10^(2 downto 0)
#define DAQ_REG_SUBFRAME_EXPOSURES 6
#define DAQ_REG_SUBFRAME_PERIOD 7 // also pg and fifo status register
#define DAQ_REG_PARTIAL_READOUT 8
#define DAQ_REG_READ_N_ROWS 8
#define DAQ_REG_HRDWRE 12
// clang-format off

View File

@ -85,7 +85,7 @@ uint64_t eiger_virtual_nextframenumber = 1;
int eiger_virtual_detPos[2] = {0, 0};
int eiger_virtual_test_mode = 0;
int eiger_virtual_quad_mode = 0;
int eiger_virtual_partial_readout = 256;
int eiger_virtual_read_n_rows = 256;
int eiger_virtual_interrupt_subframe = 0;
int eiger_virtual_left_datastream = 1;
int eiger_virtual_right_datastream = 1;
@ -708,7 +708,7 @@ void setupDetector() {
setIODelay(DEFAULT_IO_DELAY);
setTiming(DEFAULT_TIMING_MODE);
setNextFrameNumber(DEFAULT_STARTING_FRAME_NUMBER);
setPartialReadout(MAX_ROWS_PER_READOUT);
setReadNRows(MAX_ROWS_PER_READOUT);
// SetPhotonEnergyCalibrationParameters(-5.8381e-5,1.838515,5.09948e-7,-4.32390e-11,1.32527e-15);
eiger_tau_ns = DEFAULT_RATE_CORRECTION;
setRateCorrection(DEFAULT_RATE_CORRECTION);
@ -1683,29 +1683,29 @@ int getInterruptSubframe() {
#endif
}
int setPartialReadout(int value) {
int setReadNRows(int value) {
if (value < 0)
return FAIL;
#ifndef VIRTUAL
sharedMemory_lockLocalLink();
if (!Feb_Control_SetPartialReadout(value)) {
if (!Feb_Control_SetReadNRows(value)) {
sharedMemory_unlockLocalLink();
return FAIL;
}
sharedMemory_unlockLocalLink();
Beb_SetPartialReadout(value);
Beb_SetReadNRows(value);
#else
eiger_virtual_partial_readout = value;
eiger_virtual_read_n_rows = value;
#endif
return OK;
}
int getPartialReadout() {
int getReadNRows() {
#ifdef VIRTUAL
return eiger_virtual_partial_readout;
return eiger_virtual_read_n_rows;
#else
sharedMemory_lockLocalLink();
int retval = Feb_Control_GetPartialReadout();
int retval = Feb_Control_GetReadNRows();
sharedMemory_unlockLocalLink();
return retval;
#endif
@ -2328,15 +2328,15 @@ void *start_timer(void *arg) {
int colLeft = top ? eiger_virtual_detPos[1] : eiger_virtual_detPos[1] + 1;
int colRight = top ? eiger_virtual_detPos[1] + 1 : eiger_virtual_detPos[1];
int partialReadout = getPartialReadout();
if (partialReadout == -1) {
int readNRows = getReadNRows();
if (readNRows == -1) {
LOG(logERROR,
("partial readout is -1. Assuming no partial readout.\n"));
partialReadout = MAX_ROWS_PER_READOUT;
("readNRows is -1. Assuming no readNRows.\n"));
readNRows = MAX_ROWS_PER_READOUT;
}
const int maxRows = MAX_ROWS_PER_READOUT;
const int packetsPerFrame =
(maxPacketsPerFrame * partialReadout) / maxRows;
(maxPacketsPerFrame * readNRows) / maxRows;
LOG(logDEBUG1,
@ -2419,7 +2419,7 @@ void *start_timer(void *arg) {
// loop packet
for (int i = 0; i != maxPacketsPerFrame; ++i) {
// calculate for partial readout
// calculate for readNRows
const int startval = 0;
const int endval = startval + packetsPerFrame - 1;

View File

@ -167,13 +167,13 @@
#define ADC_PORT_INVERT_ADC_3_OFST (24)
#define ADC_PORT_INVERT_ADC_3_MSK (0x000000FF << ADC_PORT_INVERT_ADC_3_OFST)
/** Partial Readout Register */
#define PARTIAL_READOUT_REG (0x44 << MEM_MAP_SHIFT)
/** Read N Rows Register */
#define READ_N_ROWS_REG (0x44 << MEM_MAP_SHIFT)
#define PARTIAL_READOUT_NUM_ROWS_OFST (0)
#define PARTIAL_READOUT_NUM_ROWS_MSK (0x0000003F << PARTIAL_READOUT_NUM_ROWS_OFST)
#define PARTIAL_READOUT_ENBL_OFST (7)
#define PARTIAL_READOUT_ENBL_MSK (0x00000001 << PARTIAL_READOUT_ENBL_OFST)
#define READ_N_ROWS_NUM_ROWS_OFST (0)
#define READ_N_ROWS_NUM_ROWS_MSK (0x0000003F << READ_N_ROWS_NUM_ROWS_OFST)
#define READ_N_ROWS_ENBL_OFST (7)
#define READ_N_ROWS_ENBL_MSK (0x00000001 << READ_N_ROWS_ENBL_OFST)
/* Configuration Register */

View File

@ -53,7 +53,7 @@ int chipVersion = 10; // (1.0)
int chipConfigured = 0;
// until firmware is done
int temp_partialReadout = 512;
int temp_readNRows = 512;
int isInitCheckDone() { return initCheckDone; }
@ -485,7 +485,7 @@ void setupDetector() {
setFilterCell(DEFAULT_FILTER_CELL);
}
disableCurrentSource();
setPartialReadout(MAX_ROWS_PER_READOUT);
setReadNRows(MAX_ROWS_PER_READOUT);
}
int resetToDefaultDacs(int hardReset) {
@ -1636,45 +1636,48 @@ int *getDetectorPosition() { return detPos; }
/* jungfrau specific - powerchip, autocompdisable, asictimer, clockdiv, pll,
* flashing fpga */
int setPartialReadout(int value) {
if (value < 0 || (value % PARTIAL_READOUT_MULTIPLE != 0))
int setReadNRows(int value) {
if (value < 0 || (value % READ_N_ROWS_MULTIPLE != 0)) {
LOG(logERROR, ("Invalid number of rows %d\n", value));
return FAIL;
}
// will be replaced when firmware is fixed
temp_partialReadout = value;
LOG(logWARNING, ("Setting number of rows: %d (Not implemented in firmware yet)\n", value));
temp_readNRows = value;
return OK;
// regval is numpackets - 1
int regval = (value / PARTIAL_READOUT_MULTIPLE) - 1;
uint32_t addr = PARTIAL_READOUT_REG;
LOG(logINFO, ("Setting Partial Readout: %d (regval:%d)\n", value, regval));
bus_w(addr, bus_r(addr) &~PARTIAL_READOUT_NUM_ROWS_MSK);
bus_w(addr, bus_r(addr) | ((regval << PARTIAL_READOUT_NUM_ROWS_OFST) & PARTIAL_READOUT_NUM_ROWS_MSK));
int regval = (value / READ_N_ROWS_MULTIPLE) - 1;
uint32_t addr = READ_N_ROWS_REG;
LOG(logINFO, ("Setting number of rows: %d (regval:%d)\n", value, regval));
bus_w(addr, bus_r(addr) &~READ_N_ROWS_NUM_ROWS_MSK);
bus_w(addr, bus_r(addr) | ((regval << READ_N_ROWS_NUM_ROWS_OFST) & READ_N_ROWS_NUM_ROWS_MSK));
if (value == MAX_ROWS_PER_READOUT) {
LOG(logINFO, ("Disabling Partial Readout\n"));
bus_w(addr, bus_r(addr) &~PARTIAL_READOUT_ENBL_MSK);
LOG(logINFO, ("Disabling Partial Readout (#rows)\n"));
bus_w(addr, bus_r(addr) &~READ_N_ROWS_ENBL_MSK);
} else {
LOG(logINFO, ("Enabling Partial Readout\n"));
bus_w(addr, bus_r(addr) | PARTIAL_READOUT_ENBL_MSK);
LOG(logINFO, ("Enabling Partial Readout (#rows)\n"));
bus_w(addr, bus_r(addr) | READ_N_ROWS_ENBL_MSK);
}
return OK;
}
int getPartialReadout() {
int getReadNRows() {
// will be replaced when firmware is fixed
return temp_partialReadout;
return temp_readNRows;
int enable = (bus_r(PARTIAL_READOUT_REG) & PARTIAL_READOUT_ENBL_MSK);
int regval = ((bus_r(PARTIAL_READOUT_REG) & PARTIAL_READOUT_NUM_ROWS_MSK) >> PARTIAL_READOUT_NUM_ROWS_OFST);
int enable = (bus_r(READ_N_ROWS_REG) & READ_N_ROWS_ENBL_MSK);
int regval = ((bus_r(READ_N_ROWS_REG) & READ_N_ROWS_NUM_ROWS_MSK) >> READ_N_ROWS_NUM_ROWS_OFST);
int maxRegval = (MAX_ROWS_PER_READOUT/ PARTIAL_READOUT_MULTIPLE) - 1;
int maxRegval = (MAX_ROWS_PER_READOUT/ READ_N_ROWS_MULTIPLE) - 1;
if ((regval == maxRegval && enable) || (regval != maxRegval && !enable)) {
return -1;
}
return (regval + 1) * PARTIAL_READOUT_MULTIPLE;
return (regval + 1) * READ_N_ROWS_MULTIPLE;
}
void initReadoutConfiguration() {
@ -2354,14 +2357,14 @@ void *start_timer(void *arg) {
const int packetsize = dataSize + sizeof(sls_detector_header);
const int maxPacketsPerFrame = 128;
const int maxRows = MAX_ROWS_PER_READOUT;
int partialReadout = getPartialReadout();
if (partialReadout == -1) {
int readNRows = getReadNRows();
if (readNRows == -1) {
LOG(logERROR,
("partial readout is -1. Assuming no partial readout.\n"));
partialReadout = MAX_ROWS_PER_READOUT;
("number of rows is -1. Assuming no partial readout (#rows).\n"));
readNRows = MAX_ROWS_PER_READOUT;
}
const int packetsPerFrame =
((maxPacketsPerFrame / 2) * partialReadout) / (maxRows / 2);
((maxPacketsPerFrame / 2) * readNRows) / (maxRows / 2);
// Generate data
char imageData[DATA_BYTES];

View File

@ -116,7 +116,7 @@ enum CLKINDEX { RUN_CLK, ADC_CLK, DBIT_CLK, NUM_CLOCKS };
#define MAX_FILTER_CELL_VAL (12)
#define MIN_ROWS_PER_READOUT (8)
#define MAX_ROWS_PER_READOUT (512)
#define PARTIAL_READOUT_MULTIPLE (8) //512 rows/128packets * 2 interfaces
#define READ_N_ROWS_MULTIPLE (8) //512 rows/128packets * 2 interfaces
/* Defines in the Firmware */
#define MAX_TIMESLOT_VAL (0x1F)

View File

@ -416,8 +416,8 @@ int setQuad(int value);
int getQuad();
int setInterruptSubframe(int value);
int getInterruptSubframe();
int setPartialReadout(int value);
int getPartialReadout();
int setReadNRows(int value);
int getReadNRows();
#endif
#if defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(EIGERD) || \
defined(MYTHEN3D)
@ -456,8 +456,8 @@ void setDigitalIODelay(uint64_t pinMask, int delay);
// jungfrau specific - powerchip, autocompdisable, clockdiv, asictimer, clock,
// pll, flashing firmware
#ifdef JUNGFRAUD
int setPartialReadout(int value);
int getPartialReadout();
int setReadNRows(int value);
int getReadNRows();
void initReadoutConfiguration();
int powerChip(int on);
int isChipConfigured();

View File

@ -144,8 +144,8 @@ int set_quad(int);
int get_quad(int);
int set_interrupt_subframe(int);
int get_interrupt_subframe(int);
int set_partial_readout(int);
int get_partial_readout(int);
int set_read_n_rows(int);
int get_read_n_rows(int);
void calculate_and_set_position();
int set_detector_position(int);
int check_detector_idle(const char *s);

View File

@ -284,8 +284,8 @@ void function_table() {
flist[F_GET_QUAD] = &get_quad;
flist[F_SET_INTERRUPT_SUBFRAME] = &set_interrupt_subframe;
flist[F_GET_INTERRUPT_SUBFRAME] = &get_interrupt_subframe;
flist[F_SET_PARTIAL_READOUT] = &set_partial_readout;
flist[F_GET_PARTIAL_READOUT] = &get_partial_readout;
flist[F_SET_READ_N_ROWS] = &set_read_n_rows;
flist[F_GET_READ_N_ROWS] = &get_read_n_rows;
flist[F_SET_POSITION] = &set_detector_position;
flist[F_SET_SOURCE_UDP_MAC] = &set_source_udp_mac;
flist[F_GET_SOURCE_UDP_MAC] = &get_source_udp_mac;
@ -4741,14 +4741,14 @@ int get_interrupt_subframe(int file_des) {
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
}
int set_partial_readout(int file_des) {
int set_read_n_rows(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int arg = 0;
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
return printSocketReadError();
LOG(logDEBUG1, ("Setting partial readout: %u\n", arg));
LOG(logDEBUG1, ("Setting number of rows: %u\n", arg));
#if !defined(EIGERD) && !defined(JUNGFRAUD)
functionNotImplemented();
@ -4758,7 +4758,7 @@ int set_partial_readout(int file_des) {
if (arg <= 0 || arg > MAX_ROWS_PER_READOUT) {
ret = FAIL;
sprintf(mess,
"Could not set partial readout. Must be between %d "
"Could not set read n rows. Must be between %d "
"and %d\n",
MIN_ROWS_PER_READOUT, MAX_ROWS_PER_READOUT);
LOG(logERROR, (mess));
@ -4771,7 +4771,7 @@ int set_partial_readout(int file_des) {
if ((arg * maxnp) % maxnl) {
ret = FAIL;
sprintf(mess,
"Could not set %d partial readout. For %d bit "
"Could not set number of rows to %d. For %d bit "
"mode and 10 giga %s, (%d (num "
"rows) x %d (max num packets for this mode)) must be "
"divisible by %d\n",
@ -4780,26 +4780,26 @@ int set_partial_readout(int file_des) {
LOG(logERROR, (mess));
} else
#elif JUNGFRAUD
if ((check_detector_idle("set partial readout") == OK) && (arg % PARTIAL_READOUT_MULTIPLE != 0)) {
if ((check_detector_idle("set nmber of rows") == OK) && (arg % READ_N_ROWS_MULTIPLE != 0)) {
ret = FAIL;
sprintf(mess,
"Could not set partial readout. %d must be a multiple "
"Could not set number of rows. %d must be a multiple "
"of %d\n",
arg, PARTIAL_READOUT_MULTIPLE);
arg, READ_N_ROWS_MULTIPLE);
LOG(logERROR, (mess));
} else
#endif
{
if (setPartialReadout(arg) == FAIL) {
if (setReadNRows(arg) == FAIL) {
ret = FAIL;
sprintf(mess, "Could not set partial readout to %d.\n", arg);
sprintf(mess, "Could not set number of rows to %d.\n", arg);
LOG(logERROR, (mess));
} else {
int retval = getPartialReadout();
int retval = getReadNRows();
if (arg != retval) {
ret = FAIL;
sprintf(mess,
"Could not set partial readout. Set %d, but "
"Could not set number of rows. Set %d, but "
"read %d\n",
retval, arg);
LOG(logERROR, (mess));
@ -4812,24 +4812,24 @@ int set_partial_readout(int file_des) {
return Server_SendResult(file_des, INT32, NULL, 0);
}
int get_partial_readout(int file_des) {
int get_read_n_rows(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int retval = -1;
LOG(logDEBUG1, ("Getting partial readout\n"));
LOG(logDEBUG1, ("Getting number of rows\n"));
#if !defined(EIGERD) && !defined(JUNGFRAUD)
functionNotImplemented();
#else
// get only
retval = getPartialReadout();
retval = getReadNRows();
if (retval == -1) {
ret = FAIL;
sprintf(mess, "Could not get partial readout. \n");
sprintf(mess, "Could not get numbr of rows. \n");
LOG(logERROR, (mess));
} else {
LOG(logDEBUG1, ("Partial readout retval: %u\n", retval));
LOG(logDEBUG1, ("number of rows retval: %u\n", retval));
}
#endif
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
@ -7211,9 +7211,9 @@ int get_receiver_parameters(int file_des) {
if (n < 0)
return printSocketReadError();
// partialReadout
// ReadNRows
#if defined(EIGERD) || defined(JUNGFRAUD)
i32 = getPartialReadout();
i32 = getReadNRows();
#else
i32 = 0;
#endif