CAEN FERS Library v1.3.0
SDK for FERS systems
Loading...
Searching...
No Matches
FERSlib.h File Reference

CAEN FERS Library. More...

#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "ExportTypes.h"
#include "FERS_Registers_520X.h"
#include "FERS_Registers_5215.h"
#include <stdbool.h>
Include dependency graph for FERSlib.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  FERS_TDL_ChainInfo_t
 TDL chain information structure. More...
 
struct  FERS_CncInfo_t
 Concentrator board information structure. More...
 
struct  FERS_BoardInfo_t
 FERS board information structure. More...
 
struct  FERS_A5256_Info_t
 A5256 adapter information structure. More...
 
struct  SpectEvent_t
 Spectroscopy Event data structure (with or without timing) More...
 
struct  CountingEvent_t
 Counting Event data structure. More...
 
struct  WaveEvent_t
 Waveform Event data structure. More...
 
struct  ListEvent_t
 List Event data structure for timing mode. More...
 
struct  ServEvent_t
 Service Event data structure, common to all FERS module. More...
 
struct  TestEvent_t
 Test Mode Event data structure. More...
 

Macros

#define _FERSLIB_H
 
#define FERSLIB_STR_HELPER_(S)
 
#define FERSLIB_STR(S)
 
#define f_sprintf   sprintf_s
 
#define f_fopen   fopen_s
 
#define FERSLIB_VERSION_MAJOR   1
 
#define FERSLIB_VERSION_MINOR   3
 
#define FERSLIB_VERSION_PATCH   0
 
#define FERSLIB_RELEASE_NUM   (FERSLIB_VERSION_MAJOR * 10000) + (FERSLIB_VERSION_MINOR * 100) + (FERSLIB_VERSION_PATCH)
 
#define FERSLIB_RELEASE_STRING   FERSLIB_STR(FERSLIB_VERSION_MAJOR) "." FERSLIB_STR(FERSLIB_VERSION_MINOR) "." FERSLIB_STR(FERSLIB_VERSION_PATCH)
 
#define FERSLIB_RELEASE_DATE   "14/01/2026"
 
#define THROUGHPUT_METER   0
 Must be 0 in normal operation (can be used to test the data throughput in different points of the readout process)
 
#define INVALID_TEMP   999
 Invalid temperature.
 
#define FERSLIB_MAX_NCNC   4
 
#define FERSLIB_MAX_NBRD   128
 
#define FERSLIB_MAX_NCH   128
 
#define FERSLIB_MAX_NCH_5202   64
 
#define FERSLIB_MAX_NCH_5203   128
 
#define FERSLIB_MAX_NCH_5204   64
 
#define PICOTDC_NCH   64
 
#define FERSLIB_MAX_NTDL   8
 
#define FERSLIB_MAX_NNODES   16
 
#define DBLOG_FERSLIB_MSG   0x0001
 
#define DBLOG_RAW_DATA_OUTFILE   0x0002
 
#define DBLOG_LL_DATADUMP   0x0004
 
#define DBLOG_LL_MSGDUMP   0x0008
 
#define DBLOG_QUEUES   0x0010
 
#define DBLOG_RAW_DECODE   0x0020
 
#define DBLOG_LL_READDUMP   0x0040
 
#define DBLOG_PARAMS   0x0080
 
#define DBLOG_CONFIG   0x0100
 
#define ENABLE_FERSLIB_LOGMSG   1
 
#define ACQMODE_SPECT   0x01
 
#define ACQMODE_TSPECT   0x03
 
#define ACQMODE_TIMING_CSTART   0x02
 
#define ACQMODE_TIMING_GATED   0x02
 
#define ACQMODE_TIMING_CSTOP   0x12
 
#define ACQMODE_TIMING_STREAMING   0x22
 
#define ACQMODE_COMMON_START   0x02
 
#define ACQMODE_COMMON_STOP   0x12
 
#define ACQMODE_STREAMING   0x22
 
#define ACQMODE_TRG_MATCHING   0x32
 
#define ACQMODE_TEST_MODE   0x01
 
#define ACQMODE_COUNT   0x04
 
#define ACQMODE_WAVE   0x08
 
#define DTQ_SPECT   0x01
 
#define DTQ_TIMING   0x02
 
#define DTQ_COUNT   0x04
 
#define DTQ_WAVE   0x08
 
#define DTQ_TSPECT   0x03
 
#define DTQ_SERVICE   0x2F
 
#define DTQ_TEST   0xFF
 
#define DTQ_START   0x0F
 
#define NODATA_TIMEOUT   100
 Timeout values.
 
#define STOP_TIMEOUT   500
 
#define FERS_CONNECT_TIMEOUT   3
 
#define TDL_COMMAND_DELAY   1000000
 
#define CLK_PERIOD_5202   8
 
#define CLK_PERIOD_5203   12.8
 
#define CLK_PERIOD_5204   12.8
 
#define TDC_CLK_PERIOD   (CLK_PERIOD_5203*2)
 
#define TDC_PULSER_CLK_PERIOD   (TDC_CLK_PERIOD / 32)
 
#define TDC_LSB_ps   (TDC_CLK_PERIOD / 8 / 1.024)
 
#define CLK2LSB   4096
 
#define MAX_WAVEFORM_LENGTH   2048
 Readout constants.
 
#define MAX_LIST_SIZE   2048
 
#define MAX_TEST_NWORDS   4
 
#define MAX_SERV_NWORDS   6
 
#define MEASMODE_LEAD_ONLY   0x01
 
#define MEASMODE_LEAD_TRAIL   0x03
 
#define MEASMODE_LEAD_TOT8   0x05
 
#define MEASMODE_LEAD_TOT11   0x09
 
#define MEASMODE_OWLT(m)
 
#define EDGE_LEAD   1
 
#define EDGE_TRAIL   0
 
#define STOPRUN_MANUAL   0
 
#define STOPRUN_PRESET_TIME   1
 
#define STOPRUN_PRESET_COUNTS   2
 
#define EVBLD_DISABLED   0
 
#define EVBLD_TRGTIME_SORTING   1
 
#define EVBLD_TRGID_SORTING   2
 
#define CITIROC_CFG_FROM_REGS   0
 
#define CITIROC_CFG_FROM_FILE   1
 
#define ENERGY_NBIT   14
 Data width for Energy, ToA and ToT (5202)
 
#define TOA_NBIT   16
 
#define TOA_LSB_ns   0.5
 
#define TOT_NBIT   9
 
#define EEPROM_BIC_SIZE   44
 
#define EEPROM_BIC_PAGE   0
 
#define EEPROM_CAL_PAGE   256
 
#define EEPROM_CAL_SIZE   256
 
#define FLASH_PAGE_SIZE   528
 
#define FLASH_BIC_PAGE   0
 
#define FLASH_PEDCALIB_PAGE   4
 
#define FLASH_PEDCALIB_BCK_PAGE   5
 
#define FLASH_THR_OFFS_PAGE   4
 
#define FLASH_THR_OFFS_BCK_PAGE   5
 
#define FERS_INDEX(handle)
 
#define FERS_CONNECTIONTYPE(handle)
 
#define FERS_CONNECTIONTYPE_ETH   0x00000
 
#define FERS_CONNECTIONTYPE_USB   0x10000
 
#define FERS_CONNECTIONTYPE_TDL   0x20000
 
#define FERS_CONNECTIONTYPE_CNC   0x80000
 
#define FERS_NODE(handle)
 
#define FERS_CHAIN(handle)
 
#define FERS_CNCINDEX(handle)
 
#define FERS_CNC_HANDLE(handle)
 
#define FUP_BA   0xFF000000
 Fimrware upgrade via tdl constants.
 
#define FUP_CONTROL_REG   1023
 
#define FUP_PARAM_REG   1022
 
#define FUP_RESULT_REG   1021
 
#define FUP_CMD_READ_VERSION   0xFF
 
#define POLY   0x82f63b78
 
#define FERSLIB_MAX_GW   20
 
#define OUTFILE_RAW_LL   0x0001
 
#define CFG_HARD   0
 
#define CFG_SOFT   1
 
#define max(a, b)
 
#define min(a, b)
 
#define A5256_CH0_POSITIVE   0
 CH0 positive polarity.
 
#define A5256_CH0_NEGATIVE   1
 CH0 negative polarity.
 
#define A5256_CH0_DUAL   2
 CH0 dual polarity.
 
#define ADAPTER_NONE   0x0000
 No adapter.
 
#define ADAPTER_A5255   0x0000
 A5255 is just a mechanical adapter (same as NONE)
 
#define ADAPTER_A5256   0x0002
 16+1 ch discriminator with programmable thresholds
 
#define ADAPTER_A5256_REV0_POS   0x0100
 Proto0 of A5256 used with positive signals (discontinued)
 
#define ADAPTER_A5256_REV0_NEG   0x0101
 Proto0 of A5256 used with negative signals (discontinued)
 
#define NC   -1
 
#define A5256_DAC_LSB   ((float)2500/4095)
 LSB of the threshold in mV.
 
#define A5256_mV_to_DAC(mV)
 Convert Threshold from mV into DAC LSB.
 
#define A5256_DAC_to_mV(lsb)
 Convert Threshold from DAC LSB to mV.
 
#define A5203_FLASH   0
 
#define A5256_EEPROM   1
 

Enumerations

enum  FERSLIB_RxThreadSatatus { RXSTATUS_OFF = 0 , RXSTATUS_IDLE = 1 , RXSTATUS_RUNNING = 2 , RXSTATUS_EMPTYING = 3 }
 Status of the data RX thread. More...
 
enum  FERSLIB_ReadoutStatus {
  ROSTATUS_IDLE = 0 , ROSTATUS_RUNNING = 1 , ROSTATUS_EMPTYING = 2 , ROSTATUS_FLUSHING = 3 ,
  RAWDATA_REPROCESS_FINISHED = 4
}
 Readout status. More...
 
enum  FERSLIB_ErrorCodes {
  FERSLIB_SUCCESS = 0 , FERSLIB_ERR_GENERIC = -1 , FERSLIB_ERR_COMMUNICATION = -2 , FERSLIB_ERR_MAX_NBOARD_REACHED = -3 ,
  FERSLIB_ERR_DEVICE_ALREADY_OPENED = -4 , FERSLIB_ERR_INVALID_PATH = -5 , FERSLIB_ERR_INVALID_HANDLE = -6 , FERSLIB_ERR_READOUT_ERROR = -7 ,
  FERSLIB_ERR_MALLOC_BUFFERS = -8 , FERSLIB_ERR_INVALID_BIC = -9 , FERSLIB_ERR_READOUT_NOT_INIT = -10 , FERSLIB_ERR_CALIB_NOT_FOUND = -11 ,
  FERSLIB_ERR_PEDCALIB_NOT_FOUND = -11 , FERSLIB_ERR_INVALID_FWFILE = -12 , FERSLIB_ERR_UPGRADE_ERROR = -13 , FERSLIB_ERR_INVALID_PARAM = -14 ,
  FERSLIB_ERR_NOT_APPLICABLE = -15 , FERSLIB_ERR_TDL_ERROR = -16 , FERSLIB_ERR_QUEUE_OVERRUN = -17 , FERSLIB_ERR_START_STOP_ERROR = -18 ,
  FERSLIB_ERR_OPER_NOT_ALLOWED = -19 , FERSLIB_ERR_INVALID_CLK_SETTING = -20 , FERSLIB_ERR_TDL_CHAIN_BROKEN = -21 , FERSLIB_ERR_TDL_CHAIN_DOWN = -22 ,
  FERSLIB_ERR_I2C_NACK = -23 , FERSLIB_ERR_CALIB_FAIL = -24 , FERSLIB_ERR_INVALID_FW = -25 , FERSLIB_ERR_INVALID_PARAM_VALUE = -26 ,
  FERSLIB_ERR_INVALID_PARAM_UNIT = -27
}
 Error codes. More...
 
enum  FERSLIB_EvtBuildingModes { ROMODE_DISABLE_SORTING = 0x0000 , ROMODE_TRGTIME_SORTING = 0x0001 , ROMODE_TRGID_SORTING = 0x0002 }
 Event Building modes. More...
 
enum  FERSLIB_ServEventsMode { SE_HV = 1 , SE_COUNT = 2 , SE_ALL = 3 }
 Service event Modes. More...
 
enum  FERSLIB_StartMode { STARTRUN_ASYNC = 0 , STARTRUN_CHAIN_T0 = 1 , STARTRUN_CHAIN_T1 = 2 , STARTRUN_TDL = 3 }
 Start/Stop modes. More...
 
enum  FERSLIB_GlitchFilterModes { GLITCHFILTERMODE_DISABLED = 0 , GLITCHFILTERMODE_TRAILING = 1 , GLITCHFILTERMODE_LEADING = 2 , GLITCHFILTERMODE_BOTH = 3 }
 Glitch filter modes. More...
 
enum  FERSLIB_HRClockModes { HRCLK_DISABLED = 0 , HRCLK_DAISY_CHAIN = 1 , HRCLK_FAN_OUT = 2 }
 High resolution clock modes. More...
 

Functions

int ConfigureProbe (int handle)
 
char * FERS_GetLibReleaseNum ()
 Get the release number of the library.
 
char * FERS_GetLibReleaseDate ()
 Get the release date of the library.
 
int FERS_LibMsg (char *fmt,...)
 Write on FERSlib log file.
 
int FERS_GetLastError (char description[1024])
 Get the last message error of library.
 
void _setLastLocalError (const char *description,...)
 
int FERS_OpenRawDataFile (int *handle, int RunNum, int NumBrd)
 Open raw data file, to be done before starting the run.
 
int FERS_CloseRawDataFile (int *handle, int NumBrd)
 Close raw data file after run stops.
 
float FERS_GetClockPeriod (int handle)
 Get the clock of the FERS board.
 
int FERS_OpenDevice (char *path, int *handle)
 Open a device (either FERS board, concentrator or offline)
 
int FERS_IsOpen (char *path)
 Check if a device is already opened.
 
int FERS_IsOpenByHandle (int handle, char *path)
 Check if a device is already opened, with handle.
 
int FERS_CloseDevice (int handle)
 Cloase a device (either FERS board or concentrator)
 
int FERS_TotalAllocatedMemory ()
 Return the total size of the allocated buffers for the readout of all boards.
 
int FERS_Reset_IPaddress (int handle)
 Restore the factory IP address (192.168.50.3) of the device. The board must be connected through the USB port.
 
int FERS_Get_CncPath (char *dev_path, char *cnc_path)
 Find the path of the concentrator to which a device is connected.
 
int FERS_InitTDLchains (int handle, float DelayAdjust[8][16])
 Send a sync broadcast command via TDL.
 
bool FERS_TDLchainsInitialized (int handle)
 Check if TDL chains are initialized.
 
uint16_t FERS_GetNumBrdConnected ()
 Get the number of boards connected.
 
int FERS_ReadRegister (int handle, uint32_t address, uint32_t *data)
 Read a register of a FERS board.
 
int FERS_WriteRegister (int handle, uint32_t address, uint32_t data)
 Write a register of a FERS board.
 
int FERS_WriteRegisterSlice (int handle, uint32_t address, uint32_t start_bit, uint32_t stop_bit, uint32_t data)
 Write a slice of a register of a FERS board.
 
int FERS_SendCommand (int handle, uint32_t cmd)
 
Send a command to the board
 
int FERS_SendCommandBroadcast (int *handle, uint32_t cmd, uint32_t delay)
 Send a broadcast command to multiple boards connected to a concentrator.
 
int FERS_I2C_ReadRegister (int handle, uint32_t i2c_dev_addr, uint32_t reg_addr, uint32_t *reg_data)
 Read a register of an I2C register (picoTDC, PLL, ...)
 
int FERS_I2C_WriteRegister (int handle, uint32_t i2c_dev_addr, uint32_t reg_addr, uint32_t reg_data)
 Write a register of an I2C register (picoTDC, PLL, ...)
 
int FERS_I2C_WriteRegisterSlice (int handle, uint32_t i2c_dev_addr, uint32_t address, uint32_t start_bit, uint32_t stop_bit, uint32_t data)
 Write a slice of a register of an I2C device.
 
int FERS_ReadFlashPage (int handle, int pagenum, int size, uint8_t *data)
 Read a page from the flash memory.
 
int FERS_WriteFlashPage (int handle, int pagenum, int size, uint8_t *data)
 Write a page of the flash memory.
 
int FERS_XROC_WriteRegister (int handle, int page_addr, int sub_addr, uint8_t data)
 Write a register of the XROC ASIC chip via I2C.
 
int FERS_XROC_ReadRegister (int handle, int page_addr, int sub_addr, uint8_t *data)
 Read a register of the XROC ASIC chip via I2C.
 
int FERS_XROC_WriteRegisterSilce (int handle, int page_addr, int sub_addr, uint32_t start_bit, uint32_t stop_bit, uint8_t data)
 Write a register slice of the XROC ASIC chip via I2C.
 
int FERS_ReadConcentratorInfo (int handle, FERS_CncInfo_t *cinfo)
 Read concentrator info from the device.
 
int FERS_WriteBoardInfo (int handle, FERS_BoardInfo_t binfo)
 Write Board info into the relevant flash memory page.
 
int FERS_WritePedestals (int handle, uint16_t *PedLG, uint16_t *PedHG, uint16_t *dco)
 Write Pedestal calibration.
 
int FERS_ReadPedestalsFromFlash (int handle, char *date, uint16_t *PedLG, uint16_t *PedHG, uint16_t *dco)
 Read pedestal calibration and DC offset.
 
int FERS_PedestalBackupPage (int handle, int EnBckPage)
 Switch to pedestal backup page.
 
int FERS_SetCommonPedestal (int handle, uint16_t Pedestal)
 Set a common pedestal (applied to all channels after pedestal calibration)
 
int FERS_EnablePedestalCalibration (int handle, int enable)
 Enable / Disabled pedestal calibration.
 
int FERS_GetChannelPedestalBeforeCalib (int handle, int ch, uint16_t *PedLG, uint16_t *PedHG)
 
int FERS_SetEnergyBitsRange (uint16_t EnergyRange)
 
int FERS_GetBoardInfo (int handle, FERS_BoardInfo_t *BrdInfo)
 Get board info saved into the library structure.
 
int FERS_GetCncInfo (int handle, FERS_CncInfo_t *BrdInfo)
 Get concentrator info saved into the library structure.
 
uint32_t FERS_pid (int handle)
 Get the board PID.
 
uint16_t FERS_Code (int handle)
 Get the code of the FERS board.
 
char * FERS_ModelName (int handle)
 Get the model name of the FERS board.
 
uint32_t FERS_FPGA_FWrev (int handle)
 Get the FPGA firmware revision of the FERS board.
 
uint32_t FERS_FPGA_FW_MajorRev (int handle)
 Get the major revision of the FPGA firmware.
 
uint32_t FERS_FPGA_FW_MinorRev (int handle)
 Get the minor revision of the FPGA firmware.
 
uint32_t FERS_uC_FWrev (int handle)
 Get them microcontroller firmware revision.
 
uint16_t FERS_NumChannels (int handle)
 Get the number of channels of the FERS board.
 
uint8_t FERS_PCB_Rev (int handle)
 Get the PCB revision of the FERS board.
 
bool FERS_IsXROC (int handle)
 Check if the board mounts an XROC ASIC chip.
 
int FERS_DumpBoardRegister (int handle)
 Dump the board register information to a file.
 
int FERS_DumpCfgSaved (int handle)
 Dump the saved configuration.
 
int FERS_Get_TDC0_Temp (int handle, float *temp)
 Get the temperature from picoTDC0 (on the board)
 
int FERS_Get_TDC1_Temp (int handle, float *temp)
 Get the temperature from picoTDC1 (on the mezzanine)
 
int FERS_Get_FPGA_Temp (int handle, float *temp)
 Get FPGA die temperature.
 
int FERS_Get_Board_Temp (int handle, float *temp)
 Get Board temperature, between PIC and FPGA.
 
int FERS_HV_Init (int handle)
 Initialize the HV communication bus (I2C)
 
int FERS_HV_WriteReg (int handle, uint32_t reg_addr, uint32_t dtype, uint32_t reg_data)
 Write a value of the HV.
 
int FERS_HV_ReadReg (int handle, uint32_t reg_addr, uint32_t dtype, uint32_t *reg_data)
 Read a register of HV.
 
int FERS_HV_Set_OnOff (int handle, int OnOff)
 Turn the high voltage module ON or OFF.
 
int FERS_HV_Get_Status (int handle, int *OnOff, int *Ramping, int *OvC, int *OvV)
 Get the status of the high voltage module.
 
int FERS_HV_Get_FWVer (int handle, uint32_t *FWver)
 Get the Firmware Version of the high voltage module.
 
int FERS_HV_Get_SerNum (int handle, int *sernum)
 Get the serial number of the high voltage module.
 
int FERS_HV_Set_Vbias (int handle, float vbias)
 Set HV output voltage (bias)
 
int FERS_HV_Get_Vbias (int handle, float *vbias)
 Get the output bias voltage set.
 
int FERS_HV_Get_Vmon (int handle, float *vmon)
 Get HV output voltage (HV read back with internal ADC)
 
int FERS_HV_Set_Imax (int handle, float imax)
 Set the maximum output current from the high voltage module.
 
int FERS_HV_Get_Imax (int handle, float *imax)
 Get the maximum allowed current of the high voltage module.
 
int FERS_HV_Get_Imon (int handle, float *imon)
 Get the output monitored current flowing into the detector.
 
int FERS_HV_Get_IntTemp (int handle, float *temp)
 Get the internal temperature of the HV module.
 
int FERS_HV_Get_DetectorTemp (int handle, float *temp)
 Get external temperature (of the detector). Temp sensor must be connected to dedicated lines.
 
int FERS_HV_Set_Tsens_Coeff (int handle, float Tsens_coeff[3])
 Set coefficients for external temperature sensor. T = V*V*c2 + V*c1 + c0.
 
int FERS_HV_Set_TempFeedback (int handle, int enable, float Tsens_coeff)
 Set coefficient for Vbias temperature feedback.
 
int FERS_TDC_WriteReg (int handle, int tdc_id, uint32_t addr, uint32_t data)
 
int FERS_TDC_ReadReg (int handle, int tdc_id, uint32_t addr, uint32_t *data)
 
int FERS_TDC_Config (int handle, int tdc_id, int StartSrc, int StopSrc)
 
int FERS_TDC_DoStartStopMeasurement (int handle, int tdc_id, double *tof_ns)
 
int FERS_configure (int handle, int mode)
 Configures a FERS board.
 
int FERS_LoadConfigFile (char *filepath)
 Loads a configuration file.
 
int FERS_SetParam (int handle, const char *param_name, const char *value_original)
 Set a parameter by name. The function assigns the value to the relevant parameter in the FERScfg struct, but it doesn't actually write it into the board (this is done by the "FERS_configure" function)
 
int FERS_GetParam (int handle, const char *param_name, char *value)
 Get the value of a parameter. The function reads the value from the relevant parameter in the FERScfg struct, but it doesn't actually read it from the board.
 
int FERS_InitReadout (int handle, int ROmode, int *AllocatedSize)
 Init readout for one board (allocate buffers and initialize variables)
 
int FERS_CloseReadout (int handle)
 De-init readoout (free buffers)
 
int FERS_FlushData (int handle)
 Flush the data buffer (Read and discard data until the RX buffer is empty)
 
int FERS_GetCrcErrorCnt (int cnc_handle, uint32_t *errcnt)
 Get the number of CRC errors detected by the concentrator since the last start of run.
 
int FERS_StartAcquisition (int *handle, int NumBrd, int StartMode, int RunNum)
 Start data acquisition. Set ReadoutState = RUNNING, wait until all threads are running, then send the run command to the boards, according to the given start mode.
 
int FERS_StopAcquisition (int *handle, int NumBrd, int StartMode, int RunNum)
 Send the stop command to the boards (according to the same mode used to start them)
 
int FERS_GetEvent (int *handle, int *bindex, int *DataQualifier, double *tstamp_us, void **Event, int *nb)
 Read and decode one event from the readout buffers. There are two readout modes: sorted or unsorted. If sorting is requested, the readout init function will allocate queues for sorting.
 
int FERS_GetEventFromBoard (int handle, int *DataQualifier, double *tstamp_us, void **Event, int *nb)
 Read and decode one event from a specific board.
 
int FERS_FirmwareUpgrade (int handle, char filen[200], void(*ptr)(char *msg, int progress))
 Upgrade the firmware of the board.
 
int FERS_FirmwareBootApplication_ethusb (int handle)
 Reboot the firmware application via Ethernet/USB.
 
int FERS_FirmwareBootApplication_tdl (int *handle)
 Reboot the firmware application via TDL.
 
int FERS_CheckBootloaderVersion (int handle, int *isInBootloader, uint32_t *version, uint32_t *release)
 Check if the FPGA is in "bootloader mode" and read the bootloader version.
 
int FERS_ReadA5256EEPROMInfo (int handle, FERS_A5256_Info_t *binfo)
 Read Adapter A5256 info into the relevant EEPROM memory page.
 
int FERS_WriteA5256EEPROMInfo (int handle, FERS_A5256_Info_t binfo)
 Write Adapter A5256 info into the relevant EEPROM memory page.
 
int FERS_ReadEEPROMBlock (int handle, int start_address, int size, uint8_t *data)
 Reads a block of data from the EEPROM.
 
int FERS_WriteEEPROMBlock (int handle, int start_address, int size, uint8_t *data)
 Writes a block of data to the EEPROM.
 
int FERS_checkA5256presence (int handle, FERS_A5256_Info_t *tinfo)
 Check A5256 presence.
 
int FERS_ChIndex_ada2tdc (int Adapter_ch, int *TDC_ch, int brd)
 Remap Adapter channel to TDC channel.
 
int FERS_ChIndex_tdc2ada (int TDC_ch, int *Adapter_ch, int brd)
 Remap TDC channel to Adapter channel.
 
int FERS_FindMemThrDest (int handle)
 Find the source where calibration is stored (if present EEPROM is default)
 
int FERS_ReadThrCalib (int handle, int npts, int MemThrDest, char *date, float *ThrOffset)
 Read threshold calibration offsets from flash memory.
 
int FERS_AdapterNch (int brd)
 Get the number of channels for the adapter.
 
int FERS_DisableThrCalib (int handle)
 Disable threshold calibration.
 
int FERS_Set_DiscrThreshold (int handle, int Adapter_ch, float thr_mv, int brd)
 Set the discriminator threshold.
 
int FERS_ChMask_ada2tdc (uint32_t AdapterMask, uint32_t *ChMask0, uint32_t *ChMask1, int brd)
 Remap bits of adapter channel mask to the picoTDC channel mask.
 
int FERS_CalibThresholdOffset (int handle, float min_thr, float max_thr, int *done, float *ThrOffset, float *RMSnoise, void(*ptr)(char *msg, int progress))
 Calibate the threshold offset of A5256 adapter.
 
int FERS_WriteThrCalib (int handle, int npts, int MemThrDest, float *ThrOffset)
 Write Threshold offset calibration of A5256 adapter to flash.
 

Detailed Description

CAEN FERS Library.

CAEN SpA - Front End Division Via Vetraia, 11 - 55049 - Viareggio ITALY +390594388398 - www.caen.it

Note
TERMS OF USE: This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. The user relies on the software, documentation and results solely at his own risk.
Author
Daniele Ninci, Carlo Tintori
Version
1.3.0
Date
14/01/2026

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. The user relies on the software, documentation and results solely at his own risk.

Definition in file FERSlib.h.

Macro Definition Documentation

◆ _FERSLIB_H

#define _FERSLIB_H

Definition at line 41 of file FERSlib.h.

◆ FERSLIB_STR_HELPER_

#define FERSLIB_STR_HELPER_ ( S)
Value:
#S

Definition at line 59 of file FERSlib.h.

◆ FERSLIB_STR

#define FERSLIB_STR ( S)
Value:
#define FERSLIB_STR_HELPER_(S)
Definition FERSlib.h:59

Definition at line 60 of file FERSlib.h.

◆ f_sprintf

#define f_sprintf   sprintf_s

Definition at line 63 of file FERSlib.h.

◆ f_fopen

#define f_fopen   fopen_s

Definition at line 64 of file FERSlib.h.

◆ THROUGHPUT_METER

#define THROUGHPUT_METER   0

Must be 0 in normal operation (can be used to test the data throughput in different points of the readout process)

Definition at line 124 of file FERSlib.h.

◆ INVALID_TEMP

#define INVALID_TEMP   999

Invalid temperature.

Definition at line 126 of file FERSlib.h.

◆ STOP_TIMEOUT

#define STOP_TIMEOUT   500

timeout for forcing the RX thread to go in idle state after the stop of the run in the boards

Definition at line 286 of file FERSlib.h.

◆ FERS_CONNECT_TIMEOUT

#define FERS_CONNECT_TIMEOUT   3

timeout connection in seconds

Definition at line 287 of file FERSlib.h.

◆ MAX_LIST_SIZE

#define MAX_LIST_SIZE   2048

Maximum hits list size

Definition at line 319 of file FERSlib.h.

◆ MAX_TEST_NWORDS

#define MAX_TEST_NWORDS   4

Maximum number of words in test event (5203)

Definition at line 320 of file FERSlib.h.

◆ MAX_SERV_NWORDS

#define MAX_SERV_NWORDS   6

Max number of words in service event

Definition at line 321 of file FERSlib.h.

◆ EDGE_LEAD

#define EDGE_LEAD   1

Definition at line 337 of file FERSlib.h.

◆ EDGE_TRAIL

#define EDGE_TRAIL   0

Definition at line 338 of file FERSlib.h.

◆ STOPRUN_MANUAL

#define STOPRUN_MANUAL   0

Janus parameter

Definition at line 352 of file FERSlib.h.

◆ STOPRUN_PRESET_TIME

#define STOPRUN_PRESET_TIME   1

Janus parameter

Definition at line 353 of file FERSlib.h.

◆ STOPRUN_PRESET_COUNTS

#define STOPRUN_PRESET_COUNTS   2

Janus parameter

Definition at line 354 of file FERSlib.h.

◆ EVBLD_DISABLED

#define EVBLD_DISABLED   0

Definition at line 356 of file FERSlib.h.

◆ EVBLD_TRGTIME_SORTING

#define EVBLD_TRGTIME_SORTING   1

Definition at line 357 of file FERSlib.h.

◆ EVBLD_TRGID_SORTING

#define EVBLD_TRGID_SORTING   2

Definition at line 358 of file FERSlib.h.

◆ CITIROC_CFG_FROM_REGS

#define CITIROC_CFG_FROM_REGS   0

Definition at line 361 of file FERSlib.h.

◆ CITIROC_CFG_FROM_FILE

#define CITIROC_CFG_FROM_FILE   1

Definition at line 362 of file FERSlib.h.

◆ TOA_NBIT

#define TOA_NBIT   16

Max nbits for ToA (5202)

Definition at line 370 of file FERSlib.h.

◆ TOA_LSB_ns

#define TOA_LSB_ns   0.5

LSB value of ToA in ns (5202)

Definition at line 371 of file FERSlib.h.

◆ TOT_NBIT

#define TOT_NBIT   9

Max num of bits for ToT (5202)

Definition at line 372 of file FERSlib.h.

◆ FUP_CONTROL_REG

#define FUP_CONTROL_REG   1023

Definition at line 462 of file FERSlib.h.

◆ FUP_PARAM_REG

#define FUP_PARAM_REG   1022

Definition at line 463 of file FERSlib.h.

◆ FUP_RESULT_REG

#define FUP_RESULT_REG   1021

Definition at line 464 of file FERSlib.h.

◆ FUP_CMD_READ_VERSION

#define FUP_CMD_READ_VERSION   0xFF

Definition at line 465 of file FERSlib.h.

◆ POLY

#define POLY   0x82f63b78

Definition at line 466 of file FERSlib.h.

◆ FERSLIB_MAX_GW

#define FERSLIB_MAX_GW   20

max. number of generic write commads

Definition at line 470 of file FERSlib.h.

◆ OUTFILE_RAW_LL

#define OUTFILE_RAW_LL   0x0001

Definition at line 472 of file FERSlib.h.

Function Documentation

◆ ConfigureProbe()

int ConfigureProbe ( int handle)

◆ _setLastLocalError()

void _setLastLocalError ( const char * description,
... )

◆ FERS_GetChannelPedestalBeforeCalib()

int FERS_GetChannelPedestalBeforeCalib ( int handle,
int ch,
uint16_t * PedLG,
uint16_t * PedHG )

◆ FERS_SetEnergyBitsRange()

int FERS_SetEnergyBitsRange ( uint16_t EnergyRange)

◆ FERS_TDC_WriteReg()

int FERS_TDC_WriteReg ( int handle,
int tdc_id,
uint32_t addr,
uint32_t data )

◆ FERS_TDC_ReadReg()

int FERS_TDC_ReadReg ( int handle,
int tdc_id,
uint32_t addr,
uint32_t * data )

◆ FERS_TDC_Config()

int FERS_TDC_Config ( int handle,
int tdc_id,
int StartSrc,
int StopSrc )

◆ FERS_TDC_DoStartStopMeasurement()

int FERS_TDC_DoStartStopMeasurement ( int handle,
int tdc_id,
double * tof_ns )