| CAEN FERS Library v1.1.4 SDK for FERS systems

FERSlib.h
Go to the documentation of this file.
1
41#ifndef _FERSLIB_H
42#define _FERSLIB_H // Protect against multiple inclusion
43
44#include <stdint.h>
45#include <stdlib.h> // for min/max definition
46#include <stdio.h>
47#include <math.h>
48#include "ExportTypes.h"
49
50#include "FERS_Registers_520X.h"
51#include "FERS_Registers_5215.h"
52
53//#include "FERS_MultiPlatform.h"
54
55#ifndef WIN32
56#include <stdbool.h>
57#endif
58
59
60#define FERSLIB_STR_HELPER_(S) #S
61#define FERSLIB_STR(S) FERSLIB_STR_HELPER_(S)
62
107#define FERSLIB_VERSION_MAJOR 1
108#define FERSLIB_VERSION_MINOR 1
109#define FERSLIB_VERSION_PATCH 4
110#define FERSLIB_RELEASE_NUM (FERSLIB_VERSION_MAJOR * 10000) + (FERSLIB_VERSION_MINOR * 100) + (FERSLIB_VERSION_PATCH)
111#define FERSLIB_RELEASE_STRING FERSLIB_STR(FERSLIB_VERSION_MAJOR) "." FERSLIB_STR(FERSLIB_VERSION_MINOR) "." FERSLIB_STR(FERSLIB_VERSION_PATCH)
112#define FERSLIB_RELEASE_DATE "23/05/2025"
115#define THROUGHPUT_METER 0
116
117#define INVALID_TEMP 999
118
125#define FERSLIB_MAX_NCNC 4
126#define FERSLIB_MAX_NBRD 128
127#define FERSLIB_MAX_NCH 128
128#define FERSLIB_MAX_NCH_5202 64
129#define FERSLIB_MAX_NCH_5203 128
130#define FERSLIB_MAX_NCH_5204 64
131#define PICOTDC_NCH 64
132#define FERSLIB_MAX_NTDL 8
133#define FERSLIB_MAX_NNODES 16
143#define DBLOG_FERSLIB_MSG 0x0001
144#define DBLOG_RAW_DATA_OUTFILE 0x0002
145#define DBLOG_LL_DATADUMP 0x0004
146#define DBLOG_LL_MSGDUMP 0x0008
147#define DBLOG_QUEUES 0x0010
148#define DBLOG_RAW_DECODE 0x0020
149#define DBLOG_LL_READDUMP 0x0040
150#define DBLOG_PARAMS 0x0080
151#define DBLOG_CONFIG 0x0100
152#define ENABLE_FERSLIB_LOGMSG 1
159 typedef enum {
160 RXSTATUS_OFF = 0,
161 RXSTATUS_IDLE = 1,
162 RXSTATUS_RUNNING = 2,
163 RXSTATUS_EMPTYING = 3
164} FERSLIB_RxThreadSatatus;
165
170 typedef enum {
171 ROSTATUS_IDLE = 0,
172 ROSTATUS_RUNNING = 1,
173 ROSTATUS_EMPTYING = 2,
174 ROSTATUS_FLUSHING = 3,
175 RAWDATA_REPROCESS_FINISHED = 4
176} FERSLIB_ReadoutStatus;
177
182 typedef enum {
183 FERSLIB_SUCCESS = 0,
184 FERSLIB_ERR_GENERIC = -1,
185 FERSLIB_ERR_COMMUNICATION = -2,
186 FERSLIB_ERR_MAX_NBOARD_REACHED = -3,
187 FERSLIB_ERR_DEVICE_ALREADY_OPENED = -4,
188 FERSLIB_ERR_INVALID_PATH = -5,
189 FERSLIB_ERR_INVALID_HANDLE = -6,
190 FERSLIB_ERR_READOUT_ERROR = -7,
191 FERSLIB_ERR_MALLOC_BUFFERS = -8,
192 FERSLIB_ERR_INVALID_BIC = -9,
193 FERSLIB_ERR_READOUT_NOT_INIT = -10,
194 FERSLIB_ERR_CALIB_NOT_FOUND = -11,
195 FERSLIB_ERR_PEDCALIB_NOT_FOUND = -11,
196 FERSLIB_ERR_INVALID_FWFILE = -12,
197 FERSLIB_ERR_UPGRADE_ERROR = -13,
198 FERSLIB_ERR_INVALID_PARAM = -14,
199 FERSLIB_ERR_NOT_APPLICABLE = -15,
200 FERSLIB_ERR_TDL_ERROR = -16,
201 FERSLIB_ERR_QUEUE_OVERRUN = -17,
202 FERSLIB_ERR_START_STOP_ERROR = -18,
203 FERSLIB_ERR_OPER_NOT_ALLOWED = -19,
204 FERSLIB_ERR_INVALID_CLK_SETTING = -20,
205 FERSLIB_ERR_TDL_CHAIN_BROKEN = -21,
206 FERSLIB_ERR_TDL_CHAIN_DOWN = -22,
207 FERSLIB_ERR_I2C_NACK = -23,
208 FERSLIB_ERR_CALIB_FAIL = -24,
209 FERSLIB_ERR_INVALID_FW = -25,
210 FERSLIB_ERR_INVALID_PARAM_VALUE = -26,
211 FERSLIB_ERR_INVALID_PARAM_UNIT = -27
212} FERSLIB_ErrorCodes;
213
220#define ACQMODE_SPECT 0x01
221#define ACQMODE_TSPECT 0x03
222#define ACQMODE_TIMING_CSTART 0x02
223#define ACQMODE_TIMING_GATED 0x02
224#define ACQMODE_TIMING_CSTOP 0x12
225#define ACQMODE_TIMING_STREAMING 0x22
226#define ACQMODE_COMMON_START 0x02
227#define ACQMODE_COMMON_STOP 0x12
228#define ACQMODE_STREAMING 0x22
229#define ACQMODE_TRG_MATCHING 0x32
230#define ACQMODE_TEST_MODE 0x01
231#define ACQMODE_COUNT 0x04
232#define ACQMODE_WAVE 0x08
241#define DTQ_SPECT 0x01
242#define DTQ_TIMING 0x02
243#define DTQ_COUNT 0x04
244#define DTQ_WAVE 0x08
245#define DTQ_TSPECT 0x03
246#define DTQ_SERVICE 0x2F
247#define DTQ_TEST 0xFF
248#define DTQ_START 0x0F
255 typedef enum {
256 ROMODE_DISABLE_SORTING = 0x0000,
257 ROMODE_TRGTIME_SORTING = 0x0001,
258 ROMODE_TRGID_SORTING = 0x0002
259} FERSLIB_EvtBuildingModes;
260
265 typedef enum {
266 SE_HV = 1,
267 SE_COUNT = 2,
268 SE_ALL = 3
269} FERSLIB_ServEventsMode;
270
271
276#define NODATA_TIMEOUT 100
277#define STOP_TIMEOUT 500
278#define FERS_CONNECT_TIMEOUT 3
286#define TDL_COMMAND_DELAY 1000000
287#define CLK_PERIOD_5202 8
288#define CLK_PERIOD_5203 12.8
289#define CLK_PERIOD_5204 12.8
298#define TDC_CLK_PERIOD (CLK_PERIOD_5203*2)
299#define TDC_PULSER_CLK_PERIOD (TDC_CLK_PERIOD / 32)
300#define TDC_LSB_ps (TDC_CLK_PERIOD / 8 / 1.024)
301#define CLK2LSB 4096
303// ---------------------
304
309#define MAX_WAVEFORM_LENGTH 2048
310#define MAX_LIST_SIZE 2048
311#define MAX_TEST_NWORDS 4
312#define MAX_SERV_NWORDS 6
321#define MEASMODE_LEAD_ONLY 0x01
322#define MEASMODE_LEAD_TRAIL 0x03
323#define MEASMODE_LEAD_TOT8 0x05
324#define MEASMODE_LEAD_TOT11 0x09
325#define MEASMODE_OWLT(m) (((m) == MEASMODE_LEAD_TOT8) || ((m) == MEASMODE_LEAD_TOT11))
328#define EDGE_LEAD 1
329#define EDGE_TRAIL 0
330
336 typedef enum {
337 STARTRUN_ASYNC = 0,
338 STARTRUN_CHAIN_T0 = 1,
339 STARTRUN_CHAIN_T1 = 2,
340 STARTRUN_TDL = 3,
341} FERSLIB_StartMode;
342
343#define STOPRUN_MANUAL 0
344#define STOPRUN_PRESET_TIME 1
345#define STOPRUN_PRESET_COUNTS 2
347#define EVBLD_DISABLED 0 // Event Building disabled */
348#define EVBLD_TRGTIME_SORTING 1 // Sorting events by timestamp of the trigger */
349#define EVBLD_TRGID_SORTING 2 // Sorting events by the trigger ID */
350
351// Citiroc Configuration
352#define CITIROC_CFG_FROM_REGS 0
353#define CITIROC_CFG_FROM_FILE 1
354
355
360#define ENERGY_NBIT 14
361#define TOA_NBIT 16
362#define TOA_LSB_ns 0.5
363#define TOT_NBIT 9
366// Parameter Options
372 typedef enum {
373 GLITCHFILTERMODE_DISABLED = 0,
374 GLITCHFILTERMODE_TRAILING = 1,
375 GLITCHFILTERMODE_LEADING = 2,
376 GLITCHFILTERMODE_BOTH = 3
377} FERSLIB_GlitchFilterModes;
378
384 typedef enum {
385 HRCLK_DISABLED = 0,
386 HRCLK_DAISY_CHAIN = 1,
387 HRCLK_FAN_OUT = 2
388} FERSLIB_HRClockModes;
389
396#define EEPROM_BIC_SIZE 44
397#define EEPROM_BIC_PAGE 0
398#define EEPROM_CAL_PAGE 256
399#define EEPROM_CAL_SIZE 256
408#define FLASH_PAGE_SIZE 528
409#define FLASH_BIC_PAGE 0
411#define FLASH_PEDCALIB_PAGE 4
412#define FLASH_PEDCALIB_BCK_PAGE 5
414#define FLASH_THR_OFFS_PAGE 4
415#define FLASH_THR_OFFS_BCK_PAGE 5
423#define A5203_FLASH 0
424#define A5256_EEPROM 1
427// Handles and indexing
434#define FERS_INDEX(handle) ((handle) & 0xFF)
435#define FERS_CONNECTIONTYPE(handle) ((handle) & 0xF0000)
436#define FERS_CONNECTIONTYPE_ETH 0x00000
437#define FERS_CONNECTIONTYPE_USB 0x10000
438#define FERS_CONNECTIONTYPE_TDL 0x20000
439#define FERS_CONNECTIONTYPE_CNC 0x80000
440#define FERS_NODE(handle) ((handle >> 20) & 0xF)
441#define FERS_CHAIN(handle) ((handle >> 24) & 0xF)
442#define FERS_CNCINDEX(handle) ((handle >> 30) & 0xF)
443#define FERS_CNC_HANDLE(handle) (0x80000 | ((handle >> 30) & 0xF))
446// Fimrware upgrade via TDL
452#define FUP_BA 0xFF000000
453#define FUP_CONTROL_REG 1023
454#define FUP_PARAM_REG 1022
455#define FUP_RESULT_REG 1021
456#define FUP_CMD_READ_VERSION 0xFF
457#define POLY 0x82f63b78
458
459
460// Definition of limits and sizes
461#define FERSLIB_MAX_GW 20
463#define OUTFILE_RAW_LL 0x0001 // Can be a Janus parameter
464
469#define CFG_HARD 0
470#define CFG_SOFT 1
472// Other macros
479#ifndef max
480#define max(a,b) ((a) > (b) ? (a) : (b))
481#endif
482#ifndef min
483#define min(a,b) ((a) < (b) ? (a) : (b))
484#endif
487//******************************************************************
488// TDL-chain Info Struct
489//******************************************************************
494 typedef struct {
495 uint16_t Status;
496 uint16_t BoardCount;
497 float rrt;
498 uint64_t EventCount;
499 uint64_t ByteCount;
500 float EventRate;
501 float Mbps;
502} FERS_TDL_ChainInfo_t;
503
504//******************************************************************
505// Concentrator Info Struct
506//******************************************************************
511 typedef struct {
512 uint32_t pid;
513 char PCBrevision[16];
514 char ModelCode[16];
515 char ModelName[16];
516 char FPGA_FWrev[20];
517 char SW_rev[20];
518 char MACaddr_10GbE[20];
519 uint16_t NumLink;
520 FERS_TDL_ChainInfo_t ChainInfo[8];
521} FERS_CncInfo_t;
522
523//******************************************************************
524// FERS Board Info Struct
525//******************************************************************
530 typedef struct {
531 uint32_t pid;
532 uint16_t FERSCode;
533 uint8_t PCBrevision;
534 char ModelCode[16];
535 char ModelName[16];
536 uint8_t FormFactor;
537 uint16_t NumCh;
538 uint32_t FPGA_FWrev;
539 uint32_t uC_FWrev;
540} FERS_BoardInfo_t;
541
542//******************************************************************
543// A5256 Adapter Info Struct
544//******************************************************************
549 typedef struct {
550 uint32_t pid;
551 uint16_t AdapterCode;
552 uint8_t PCBrevision;
553 char ModelCode[16];
554 char ModelName[16];
555 uint16_t NumCh;
556} FERS_A5256_Info_t;
557
558//******************************************************************
559// Event Data Structures
560//******************************************************************
561// Spectroscopy Event (with or without timing)
566 typedef struct {
567 double tstamp_us;
568 double rel_tstamp_us;
569 uint64_t trigger_id;
570 uint64_t chmask;
571 uint64_t qdmask;
572 uint16_t energyHG[64];
573 uint16_t energyLG[64];
574 uint32_t tstamp[64];
575 uint16_t ToT[64];
576} SpectEvent_t;
577
578// Counting Event
583 typedef struct {
584 double tstamp_us;
585 double rel_tstamp_us;
586 uint64_t trigger_id;
587 uint64_t chmask;
588 uint32_t counts[64];
589 uint32_t t_or_counts;
590 uint32_t q_or_counts;
591} CountingEvent_t;
592
593// Waveform Event
598 typedef struct {
599 double tstamp_us;
600 uint64_t trigger_id;
601 uint16_t ns;
602 uint16_t *wave_hg;
603 uint16_t *wave_lg;
604 uint8_t *dig_probes;
605} WaveEvent_t;
606
611 typedef struct {
612 double tstamp_us;
613 uint64_t Tref_tstamp;
614 uint64_t tstamp_clk;
615 uint64_t trigger_id;
616 uint16_t nhits;
617 uint32_t header1[8];
618 uint32_t header2[8];
619 uint32_t ow_trailer;
620 uint32_t trailer[8];
621 uint8_t channel[MAX_LIST_SIZE];
622 uint8_t edge[MAX_LIST_SIZE];
623 uint32_t tstamp[MAX_LIST_SIZE];
624 uint32_t ToA[MAX_LIST_SIZE];
625 uint16_t ToT[MAX_LIST_SIZE];
626} ListEvent_t; // 5202 + 5203
627
632 typedef struct {
633 double tstamp_us;
634 uint64_t update_time;
635 uint16_t pkt_size;
636 uint8_t version;
637 uint8_t format;
638 uint32_t ch_trg_cnt[FERSLIB_MAX_NCH_5202]; // Channel trigger counts
639 uint32_t q_or_cnt;
640 uint32_t t_or_cnt;
641 float tempFPGA;
642 float tempBoard;
643 float tempTDC[2];
644 float tempHV;
645 float tempDetector;
646 float hv_Vmon;
647 float hv_Imon;
648 uint8_t hv_status_on;
649 uint8_t hv_status_ramp;
650 uint8_t hv_status_ovv;
651 uint8_t hv_status_ovc;
652 uint16_t Status;
653 uint16_t TDCROStatus;
654 uint64_t ChAlmFullFlags[2];
655 uint32_t ReadoutFlags;
656 uint32_t TotTrg_cnt;
657 uint32_t RejTrg_cnt;
658 uint32_t SupprTrg_cnt;
659} ServEvent_t; // 5202 + 5203
660
661
662// Test Mode Event (fixed data patterns)
667 typedef struct {
668 double tstamp_us;
669 uint64_t trigger_id;
670 uint16_t nwords;
671 uint32_t test_data[MAX_TEST_NWORDS];
672} TestEvent_t;
673
674
681#define A5256_CH0_POSITIVE 0
682#define A5256_CH0_NEGATIVE 1
683#define A5256_CH0_DUAL 2
684
685
686#define ADAPTER_NONE 0x0000
687#define ADAPTER_A5255 0x0000
688#define ADAPTER_A5256 0x0002
689#define ADAPTER_A5256_REV0_POS 0x0100
690#define ADAPTER_A5256_REV0_NEG 0x0101
691
692
693#define NC -1 // DNIN=?
694
695#define A5256_DAC_LSB ((float)2500/4095)
696#define A5256_mV_to_DAC(mV) (uint32_t)round((1250 - (mV)) / A5256_DAC_LSB)
697#define A5256_DAC_to_mV(lsb) (1250 - (float)((lsb) * A5256_DAC_LSB))
700#ifdef __cplusplus
701 extern "C" {
702#endif
703 // *****************************************************************
704 // External Variables (defined in FERlib.c)
705 // *****************************************************************
709 extern uint16_t PedestalLG[FERSLIB_MAX_NBRD][FERSLIB_MAX_NCH_5202];
710 extern uint16_t PedestalHG[FERSLIB_MAX_NBRD][FERSLIB_MAX_NCH_5202];
711 extern uint16_t CommonPedestal;
712 extern int EnablePedCal;
713 extern uint32_t TDL_NumNodes[FERSLIB_MAX_NCNC][FERSLIB_MAX_NTDL];
714
715 //extern uint8_t EnableRawData; //!< Flag to enable Low Level data saving
716 extern uint8_t ProcessRawData;
717 //extern uint8_t EnableMaxSizeFile; //!< Flag to enable the maximum size eforcement for Raw Data file saving
718 extern uint8_t EnableSubRun;
719 //extern float MaxSizeRawDataFile; //!< Maximum size for saving low-level data
720 extern char RawDataFilename[FERSLIB_MAX_NBRD][500];
721 extern char RawDataFilenameTdl[FERSLIB_MAX_NBRD][500];
722 extern int FERS_Offline;
723
724 extern int FERS_RunningCnt;
725 extern int FERS_ReadoutStatus;
726 extern int FERS_TotalAllocatedMem;
727 extern int DebugLogs;
728
729 //extern mutex_t FERS_mutex; //!< Mutex for access to shared resources (FERScfg, InitBuffers ...)
734 // *****************************************************************
735 // Funtion Prototypes
736 // *****************************************************************
742 CAEN_FERS_DLLAPI int ConfigureProbe(int handle);
743
744 // -----------------------------------------------------------------
745 // Get FERSlib info
746 // -----------------------------------------------------------------
756 CAEN_FERS_DLLAPI char* FERS_GetLibReleaseNum();
757
763 CAEN_FERS_DLLAPI char* FERS_GetLibReleaseDate();
764
765 // -----------------------------------------------------------------
766 // Messaging and errors
767 // -----------------------------------------------------------------
768
781 CAEN_FERS_DLLAPI int FERS_LibMsg(char* fmt, ...);
782
789 CAEN_FERS_DLLAPI int FERS_GetLastError(char description[1024]);
790
791 // Not exported
792 void _setLastLocalError(const char* description, ...);
793
794 // -----------------------------------------------------------------
795 // Raw Data Save and Load
796 // -----------------------------------------------------------------
797 // DNIN: Is it better to have an API to enable both RawData and LimitFileSize
798 // and then do the open directly inside the StartAcquisition?
800 //* @ingroup Functions
801 //* @defgroup RawData RawData Saving/Loading
802 //*/
804 // * @brief Enable the rawdata file saving and set default file name
805 // * @param[in] RawDataEnable bool to activate rawdata file saving
806 // * @param[in] DataOutputPath path where rawdata will be saved
807 // * @param[in] RunNumber number of the current run
808 // * @return 0
809 // * @ingroup RawData
810 //*/
811 //CAEN_FERS_DLLAPI int FERS_EnableRawdataWriteFile(uint8_t RawDataEnable, char* DataOutputPath, int RunNumber);
812
814 // * @brief Enable and set the size limit for rawdata file
815 // * @param[in] LimitSizeEnable Flag to enable the size limit
816 // * @param[in] MaxSizeRawOutputFile Maximum size of output file
817 // * @return 0
818 // * @ingroup RawData
819 //*/
820 //CAEN_FERS_DLLAPI int FERS_EnableLimitRawdataFileSize(uint8_t LimitSizeEnable, float MaxSizeRawOutputFile);
821
822 //CAEN_FERS_DLLAPI int FERS_SetRawdataReadFile(char DataRawFilePath[500], int brd);
823
831 CAEN_FERS_DLLAPI int FERS_OpenRawDataFile(int* handle, int RunNum);
832
839 CAEN_FERS_DLLAPI int FERS_CloseRawDataFile(int* handle);
840
847 CAEN_FERS_DLLAPI float FERS_GetClockPeriod(int handle);
848 //CAEN_FERS_DLLAPI int FERS_SetPedestalOffline(uint16_t PedLG[FERSLIB_MAX_NCH_5202], uint16_t PedHG[FERSLIB_MAX_NCH_5202], int handle);
849
850 // -----------------------------------------------------------------
851 // Open/Close
852 // -----------------------------------------------------------------
865 CAEN_FERS_DLLAPI int FERS_OpenDevice(char* path, int* handle);
866
873 CAEN_FERS_DLLAPI int FERS_IsOpen(char* path);
874
881 CAEN_FERS_DLLAPI int FERS_CloseDevice(int handle);
882
888 CAEN_FERS_DLLAPI int FERS_TotalAllocatedMemory();
889
896 CAEN_FERS_DLLAPI int FERS_Reset_IPaddress(int handle);
897
905 CAEN_FERS_DLLAPI int FERS_Get_CncPath(char* dev_path, char* cnc_path);
906
913 CAEN_FERS_DLLAPI int FERS_InitTDLchains(int handle, float DelayAdjust[FERSLIB_MAX_NTDL][FERSLIB_MAX_NNODES]);
914
921 CAEN_FERS_DLLAPI bool FERS_TDLchainsInitialized(int handle);
922
923 //CAEN_FERS_DLLAPI int FERS_SetOffline(int offline);
924 //CAEN_FERS_DLLAPI int FERS_SetBoardInfo(FERS_BoardInfo_t* BrdInfo, int b);
925 //CAEN_FERS_DLLAPI int FERS_SetConcentratorInfo(int handle, FERS_CncInfo_t* cinfo);
926
933 CAEN_FERS_DLLAPI uint16_t FERS_GetNumBrdConnected();
934
935
936 // -----------------------------------------------------------------
937 // Register Read/Write
938 // -----------------------------------------------------------------
953 CAEN_FERS_DLLAPI int FERS_ReadRegister(int handle, uint32_t address, uint32_t* data);
954
964 CAEN_FERS_DLLAPI int FERS_WriteRegister(int handle, uint32_t address, uint32_t data);
965
977 CAEN_FERS_DLLAPI int FERS_WriteRegisterSlice(int handle, uint32_t address, uint32_t start_bit, uint32_t stop_bit, uint32_t data);
978
987 CAEN_FERS_DLLAPI int FERS_SendCommand(int handle, uint32_t cmd);
988
998 CAEN_FERS_DLLAPI int FERS_SendCommandBroadcast(int* handle, uint32_t cmd, uint32_t delay);
999
1010 CAEN_FERS_DLLAPI int FERS_I2C_ReadRegister(int handle, uint32_t i2c_dev_addr, uint32_t reg_addr, uint32_t* reg_data);
1011
1022 CAEN_FERS_DLLAPI int FERS_I2C_WriteRegister(int handle, uint32_t i2c_dev_addr, uint32_t reg_addr, uint32_t reg_data);
1023
1036 CAEN_FERS_DLLAPI 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);
1037 //CAEN_FERS_DLLAPI int FERS_ReadBoardInfo(int handle, FERS_BoardInfo_t* binfo);
1038
1039 // -----------------------------------------------------------------
1040 // Flash Read/Write
1041 // -----------------------------------------------------------------
1052 CAEN_FERS_DLLAPI int FERS_ReadFlashPage(int handle, int pagenum, int size, uint8_t* data);
1053
1065 CAEN_FERS_DLLAPI int FERS_WriteFlashPage(int handle, int pagenum, int size, uint8_t* data);
1066
1067
1068 // -----------------------------------------------------------------
1069 // XROC Register Read/Write
1070 // -----------------------------------------------------------------
1081 CAEN_FERS_DLLAPI int FERS_XROC_WriteRegister(int handle, int page_addr, int sub_addr, uint8_t data);
1082
1093 CAEN_FERS_DLLAPI int FERS_XROC_ReadRegister(int handle, int page_addr, int sub_addr, uint8_t* data);
1094
1107 CAEN_FERS_DLLAPI int FERS_XROC_WriteRegisterSilce(int handle, int page_addr, int sub_addr, uint32_t start_bit, uint32_t stop_bit, uint8_t data);
1108
1109
1118 CAEN_FERS_DLLAPI int FERS_ReadConcentratorInfo(int handle, FERS_CncInfo_t* cinfo);
1119
1129 CAEN_FERS_DLLAPI int FERS_WriteBoardInfo(int handle, FERS_BoardInfo_t binfo);
1130
1147 CAEN_FERS_DLLAPI int FERS_WritePedestals(int handle, uint16_t* PedLG, uint16_t* PedHG, uint16_t* dco);
1148
1161 CAEN_FERS_DLLAPI int FERS_ReadPedestalsFromFlash(int handle, char* date, uint16_t* PedLG, uint16_t* PedHG, uint16_t* dco);
1162
1171 CAEN_FERS_DLLAPI int FERS_PedestalBackupPage(int handle, int EnBckPage);
1172
1182 CAEN_FERS_DLLAPI int FERS_SetCommonPedestal(int handle, uint16_t Pedestal);
1183
1192 CAEN_FERS_DLLAPI int FERS_EnablePedestalCalibration(int handle, int enable);
1193
1194 int FERS_GetChannelPedestalBeforeCalib(int handle, int ch, uint16_t* PedLG, uint16_t* PedHG);
1195
1196 CAEN_FERS_DLLAPI int FERS_SetEnergyBitsRange(uint16_t EnergyRange);
1197 //CAEN_FERS_DLLAPI int FERS_Model(int handle); // ((FERS_INDEX(handle) >= 0) ? FERS_BoardInfo[FERS_INDEX(handle)]->Model : 0)
1198
1199
1212 CAEN_FERS_DLLAPI int FERS_GetBoardInfo(int handle, FERS_BoardInfo_t* BrdInfo);
1213
1221 CAEN_FERS_DLLAPI int FERS_GetCncInfo(int handle, FERS_CncInfo_t* BrdInfo);
1222
1230 CAEN_FERS_DLLAPI uint32_t FERS_pid(int handle); // ((FERS_INDEX(handle) >= 0) ? FERS_BoardInfo[FERS_INDEX(handle)]->pid : 0)
1231
1239 CAEN_FERS_DLLAPI uint16_t FERS_Code(int handle); // ((FERS_INDEX(handle) >= 0) ? FERS_BoardInfo[FERS_INDEX(handle)]->FERSCode : 0)
1240
1248 CAEN_FERS_DLLAPI char* FERS_ModelName(int handle); // ((FERS_INDEX(handle) >= 0) ? FERS_BoardInfo[FERS_INDEX(handle)]->ModelName : "")
1249
1257 CAEN_FERS_DLLAPI uint32_t FERS_FPGA_FWrev(int handle); // ((FERS_INDEX(handle) >= 0) ? FERS_BoardInfo[FERS_INDEX(handle)]->FPGA_FWrev : 0)
1258
1266 CAEN_FERS_DLLAPI uint32_t FERS_FPGA_FW_MajorRev(int handle);// ((FERS_INDEX(handle) >= 0) ? ((FERS_BoardInfo[FERS_INDEX(handle)]->FPGA_FWrev) >> 8) & 0xFF : 0)
1267
1275 CAEN_FERS_DLLAPI uint32_t FERS_FPGA_FW_MinorRev(int handle);// ((FERS_INDEX(handle) >= 0) ? (FERS_BoardInfo[FERS_INDEX(handle)]->FPGA_FWrev) & 0xFF : 0)
1276
1284 CAEN_FERS_DLLAPI uint32_t FERS_uC_FWrev(int handle); // ((FERS_INDEX(handle) >= 0) ? FERS_BoardInfo[FERS_INDEX(handle)]->uC_FWrev : 0)
1285
1293 CAEN_FERS_DLLAPI uint16_t FERS_NumChannels(int handle); // ((FERS_INDEX(handle) >= 0) ? FERS_BoardInfo[FERS_INDEX(handle)]->NumCh : 0)
1294
1302 CAEN_FERS_DLLAPI uint8_t FERS_PCB_Rev(int handle); // ((FERS_INDEX(handle) >= 0) ? FERS_BoardInfo[FERS_INDEX(handle)]->PCBrevision : 0)
1303
1311 CAEN_FERS_DLLAPI bool FERS_IsXROC(int handle);
1312
1313 // DNIN: This 2 should be intern function. The user should only set the DebugLogMask
1321 CAEN_FERS_DLLAPI int FERS_DumpBoardRegister(int handle);
1322
1330 CAEN_FERS_DLLAPI int FERS_DumpCfgSaved(int handle);
1331
1332
1346 CAEN_FERS_DLLAPI int FERS_Get_TDC0_Temp(int handle, float* temp);
1347
1356 CAEN_FERS_DLLAPI int FERS_Get_TDC1_Temp(int handle, float* temp);
1357
1366 CAEN_FERS_DLLAPI int FERS_Get_FPGA_Temp(int handle, float* temp);
1367
1368
1377 CAEN_FERS_DLLAPI int FERS_Get_Board_Temp(int handle, float* temp);
1378
1379
1380
1381
1382 // -----------------------------------------------------------------
1383 // High Voltage Control
1384 // -----------------------------------------------------------------
1385
1398 CAEN_FERS_DLLAPI int FERS_HV_Init(int handle);
1399
1410 CAEN_FERS_DLLAPI int FERS_HV_WriteReg(int handle, uint32_t reg_addr, uint32_t dtype, uint32_t reg_data);
1411
1422 CAEN_FERS_DLLAPI int FERS_HV_ReadReg(int handle, uint32_t reg_addr, uint32_t dtype, uint32_t* reg_data);
1423
1432 CAEN_FERS_DLLAPI int FERS_HV_Set_OnOff(int handle, int OnOff);
1433
1445 CAEN_FERS_DLLAPI int FERS_HV_Get_Status(int handle, int* OnOff, int* Ramping, int* OvC, int* OvV);
1446
1455 CAEN_FERS_DLLAPI int FERS_HV_Get_SerNum(int handle, int* sernum);
1456
1465 CAEN_FERS_DLLAPI int FERS_HV_Set_Vbias(int handle, float vbias);
1466
1475 CAEN_FERS_DLLAPI int FERS_HV_Get_Vbias(int handle, float* vbias);
1476
1485 CAEN_FERS_DLLAPI int FERS_HV_Get_Vmon(int handle, float* vmon);
1486
1495 CAEN_FERS_DLLAPI int FERS_HV_Set_Imax(int handle, float imax);
1496
1505 CAEN_FERS_DLLAPI int FERS_HV_Get_Imax(int handle, float* imax);
1506
1515 CAEN_FERS_DLLAPI int FERS_HV_Get_Imon(int handle, float* imon);
1516
1525 CAEN_FERS_DLLAPI int FERS_HV_Get_IntTemp(int handle, float* temp);
1526
1535 CAEN_FERS_DLLAPI int FERS_HV_Get_DetectorTemp(int handle, float* temp);
1536
1545 CAEN_FERS_DLLAPI int FERS_HV_Set_Tsens_Coeff(int handle, float Tsens_coeff[3]);
1546
1556 CAEN_FERS_DLLAPI int FERS_HV_Set_TempFeedback(int handle, int enable, float Tsens_coeff);
1557
1558
1559 // -----------------------------------------------------------------
1560 // TDC Config and readout (for test)
1561 // -----------------------------------------------------------------
1562 CAEN_FERS_DLLAPI int FERS_TDC_WriteReg(int handle, int tdc_id, uint32_t addr, uint32_t data);
1563 CAEN_FERS_DLLAPI int FERS_TDC_ReadReg(int handle, int tdc_id, uint32_t addr, uint32_t* data);
1564 CAEN_FERS_DLLAPI int FERS_TDC_Config(int handle, int tdc_id, int StartSrc, int StopSrc);
1565 CAEN_FERS_DLLAPI int FERS_TDC_DoStartStopMeasurement(int handle, int tdc_id, double* tof_ns);
1566
1567
1568 // -----------------------------------------------------------------
1569 // Set/Get param, parse file and configure FERS
1570 // -----------------------------------------------------------------
1571
1585 CAEN_FERS_DLLAPI int FERS_configure(int handle, int mode);
1586
1594 CAEN_FERS_DLLAPI int FERS_LoadConfigFile(char* filepath);
1595
1606 CAEN_FERS_DLLAPI int FERS_SetParam(int handle, char* param_name, char* value);
1607
1618 CAEN_FERS_DLLAPI int FERS_GetParam(int handle, char* param_name, char* value);
1619
1620
1621 // -----------------------------------------------------------------
1622 // Data Readout
1623 // -----------------------------------------------------------------
1624
1639 CAEN_FERS_DLLAPI int FERS_InitReadout(int handle, int ROmode, int* AllocatedSize);
1640
1648 CAEN_FERS_DLLAPI int FERS_CloseReadout(int handle);
1649
1657 CAEN_FERS_DLLAPI int FERS_FlushData(int handle);
1658
1667 CAEN_FERS_DLLAPI int FERS_GetCrcErrorCnt(int cnc_handle, uint32_t* errcnt);
1668
1680 CAEN_FERS_DLLAPI int FERS_StartAcquisition(int* handle, int NumBrd, int StartMode, int RunNum);
1681
1695 CAEN_FERS_DLLAPI int FERS_StopAcquisition(int* handle, int NumBrd, int StartMode, int RunNum);
1696
1709 CAEN_FERS_DLLAPI int FERS_GetEvent(int* handle, int* bindex, int* DataQualifier, double* tstamp_us, void** Event, int* nb);
1710
1722 CAEN_FERS_DLLAPI int FERS_GetEventFromBoard(int handle, int* DataQualifier, double* tstamp_us, void** Event, int* nb);
1723
1724
1725 // -----------------------------------------------------------------
1726 // Firmware Upgrade
1727 // -----------------------------------------------------------------
1728
1743 CAEN_FERS_DLLAPI int FERS_FirmwareUpgrade(int handle, char filen[200], void(*ptr)(char* msg, int progress));
1744
1752 CAEN_FERS_DLLAPI int FERS_FirmwareBootApplication_ethusb(int handle);
1753
1761 CAEN_FERS_DLLAPI int FERS_FirmwareBootApplication_tdl(int* handle);
1762
1773 int FERS_CheckBootloaderVersion(int handle, int* isInBootloader, uint32_t* version, uint32_t* release);
1774
1775 // -----------------------------------------------------------------
1776 // EEPROM 5256
1777 // -----------------------------------------------------------------
1778
1797 CAEN_FERS_DLLAPI int FERS_ReadA5256EEPROMInfo(int handle, FERS_A5256_Info_t* binfo);
1798
1807 CAEN_FERS_DLLAPI int FERS_WriteA5256EEPROMInfo(int handle, FERS_A5256_Info_t binfo);
1808
1819 int FERS_ReadEEPROMBlock(int handle, int start_address, int size, uint8_t* data);
1820
1831 int FERS_WriteEEPROMBlock(int handle, int start_address, int size, uint8_t* data);
1832
1841 CAEN_FERS_DLLAPI int FERS_checkA5256presence(int handle, FERS_A5256_Info_t* binfo);
1842
1859 CAEN_FERS_DLLAPI int FERS_ChIndex_ada2tdc(int Adapter_ch, int* TDC_ch, int brd);
1860
1870 CAEN_FERS_DLLAPI int FERS_ChIndex_tdc2ada(int TDC_ch, int* Adapter_ch, int brd);
1871
1872
1885 CAEN_FERS_DLLAPI int FERS_FindMemThrDest(int handle);
1886
1898 CAEN_FERS_DLLAPI int FERS_ReadThrCalib(int handle, int npts, int MemThrDest, char* date, float* ThrOffset);
1899
1907 CAEN_FERS_DLLAPI int FERS_AdapterNch(int brd);
1908
1916 int FERS_DisableThrCalib(int handle);
1917
1928 int FERS_Set_DiscrThreshold(int handle, int Adapter_ch, float thr_mv, int brd);
1929
1940 int FERS_ChMask_ada2tdc(uint32_t AdapterMask, uint32_t* ChMask0, uint32_t* ChMask1, int brd);
1941
1954 CAEN_FERS_DLLAPI int FERS_CalibThresholdOffset(int handle, float min_thr, float max_thr, int* done, float* ThrOffset, float* RMSnoise, void(*ptr)(char* msg, int progress));
1955
1967 CAEN_FERS_DLLAPI int FERS_WriteThrCalib(int handle, int npts, int MemThrDest, float* ThrOffset);
1968
1970 // * @ingroup calib
1971 // * @brief Read BIC from the EEPROM of the Adapter (if present)
1972 // * @param[in] handle Board handle
1973 // * @param[out] binfo Board info struct
1974 // * @return 0 in case of success, or a negative error code specified in #FERSLIB_ErrorCodes
1975 // */
1976 //CAEN_FERS_DLLAPI int FERS_ReadAdapterBIC(int handle, FERS_A5256_Info_t* binfo);
1977
1979 // * @ingroup calib
1980 // * @brief Write BIC into the EEPROM of the Adapter (if present)
1981 // * @param[in] handle Board handle
1982 // * @param[out] binfo Board info struct
1983 // * @return 0 in case of success, or a negative error code specified in #FERSLIB_ErrorCodes
1984 // */
1985 //CAEN_FERS_DLLAPI int FERS_WriteAdapterBIC(int handle, FERS_A5256_Info_t binfo);
1986
1987
1988#ifdef __cplusplus
1989 }
1990#endif
1991
1992#endif
1993
ConfigureProbe
int ConfigureProbe(int handle)
FERS_TDC_Config
int FERS_TDC_Config(int handle, int tdc_id, int StartSrc, int StopSrc)
FERS_TDC_ReadReg
int FERS_TDC_ReadReg(int handle, int tdc_id, uint32_t addr, uint32_t *data)
FERS_SetEnergyBitsRange
int FERS_SetEnergyBitsRange(uint16_t EnergyRange)
FERS_OpenRawDataFile
int FERS_OpenRawDataFile(int *handle, int RunNum)
Enable the rawdata file saving and set default file name.
MAX_LIST_SIZE
#define MAX_LIST_SIZE
Definition: FERSlib.h:310
MAX_TEST_NWORDS
#define MAX_TEST_NWORDS
Definition: FERSlib.h:311
FERS_TDC_DoStartStopMeasurement
int FERS_TDC_DoStartStopMeasurement(int handle, int tdc_id, double *tof_ns)
FERS_TDC_WriteReg
int FERS_TDC_WriteReg(int handle, int tdc_id, uint32_t addr, uint32_t data)
FERS_CloseRawDataFile
int FERS_CloseRawDataFile(int *handle)
Close raw data file after run stops.
FERS_GetChannelPedestalBeforeCalib
int FERS_GetChannelPedestalBeforeCalib(int handle, int ch, uint16_t *PedLG, uint16_t *PedHG)
_setLastLocalError
void _setLastLocalError(const char *description,...)
FERS_Registers_5215.h
FERS_Registers_520X.h
FERSLIB_HRClockModes
FERSLIB_HRClockModes
High resolution clock modes.
Definition: FERSlib.h:384
FERSLIB_ErrorCodes
FERSLIB_ErrorCodes
Error codes.
Definition: FERSlib.h:182
FERSLIB_EvtBuildingModes
FERSLIB_EvtBuildingModes
Event Building modes.
Definition: FERSlib.h:255
FERSLIB_ServEventsMode
FERSLIB_ServEventsMode
Service event Modes.
Definition: FERSlib.h:265
FERSLIB_RxThreadSatatus
FERSLIB_RxThreadSatatus
Status of the data RX thread.
Definition: FERSlib.h:159
FERSLIB_GlitchFilterModes
FERSLIB_GlitchFilterModes
Glitch filter modes.
Definition: FERSlib.h:372
FERSLIB_ReadoutStatus
FERSLIB_ReadoutStatus
Readout status.
Definition: FERSlib.h:170
FERSLIB_StartMode
FERSLIB_StartMode
Start/Stop modes.
Definition: FERSlib.h:336
HRCLK_FAN_OUT
@ HRCLK_FAN_OUT
Definition: FERSlib.h:387
HRCLK_DISABLED
@ HRCLK_DISABLED
Definition: FERSlib.h:385
HRCLK_DAISY_CHAIN
@ HRCLK_DAISY_CHAIN
Definition: FERSlib.h:386
FERSLIB_ERR_INVALID_FWFILE
@ FERSLIB_ERR_INVALID_FWFILE
Definition: FERSlib.h:196
FERSLIB_ERR_INVALID_PARAM_UNIT
@ FERSLIB_ERR_INVALID_PARAM_UNIT
Definition: FERSlib.h:211
FERSLIB_ERR_PEDCALIB_NOT_FOUND
@ FERSLIB_ERR_PEDCALIB_NOT_FOUND
Definition: FERSlib.h:195
FERSLIB_ERR_INVALID_PATH
@ FERSLIB_ERR_INVALID_PATH
Definition: FERSlib.h:188
FERSLIB_ERR_I2C_NACK
@ FERSLIB_ERR_I2C_NACK
Definition: FERSlib.h:207
FERSLIB_ERR_MAX_NBOARD_REACHED
@ FERSLIB_ERR_MAX_NBOARD_REACHED
Definition: FERSlib.h:186
FERSLIB_ERR_INVALID_PARAM_VALUE
@ FERSLIB_ERR_INVALID_PARAM_VALUE
Definition: FERSlib.h:210
FERSLIB_ERR_INVALID_CLK_SETTING
@ FERSLIB_ERR_INVALID_CLK_SETTING
Definition: FERSlib.h:204
FERSLIB_ERR_INVALID_FW
@ FERSLIB_ERR_INVALID_FW
Definition: FERSlib.h:209
FERSLIB_ERR_READOUT_NOT_INIT
@ FERSLIB_ERR_READOUT_NOT_INIT
Definition: FERSlib.h:193
FERSLIB_ERR_INVALID_PARAM
@ FERSLIB_ERR_INVALID_PARAM
Definition: FERSlib.h:198
FERSLIB_ERR_CALIB_FAIL
@ FERSLIB_ERR_CALIB_FAIL
Definition: FERSlib.h:208
FERSLIB_ERR_QUEUE_OVERRUN
@ FERSLIB_ERR_QUEUE_OVERRUN
Definition: FERSlib.h:201
FERSLIB_ERR_TDL_ERROR
@ FERSLIB_ERR_TDL_ERROR
Definition: FERSlib.h:200
FERSLIB_SUCCESS
@ FERSLIB_SUCCESS
Definition: FERSlib.h:183
FERSLIB_ERR_UPGRADE_ERROR
@ FERSLIB_ERR_UPGRADE_ERROR
Definition: FERSlib.h:197
FERSLIB_ERR_COMMUNICATION
@ FERSLIB_ERR_COMMUNICATION
Definition: FERSlib.h:185
FERSLIB_ERR_TDL_CHAIN_DOWN
@ FERSLIB_ERR_TDL_CHAIN_DOWN
Definition: FERSlib.h:206
FERSLIB_ERR_OPER_NOT_ALLOWED
@ FERSLIB_ERR_OPER_NOT_ALLOWED
Definition: FERSlib.h:203
FERSLIB_ERR_MALLOC_BUFFERS
@ FERSLIB_ERR_MALLOC_BUFFERS
Definition: FERSlib.h:191
FERSLIB_ERR_READOUT_ERROR
@ FERSLIB_ERR_READOUT_ERROR
Definition: FERSlib.h:190
FERSLIB_ERR_TDL_CHAIN_BROKEN
@ FERSLIB_ERR_TDL_CHAIN_BROKEN
Definition: FERSlib.h:205
FERSLIB_ERR_START_STOP_ERROR
@ FERSLIB_ERR_START_STOP_ERROR
Definition: FERSlib.h:202
FERSLIB_ERR_GENERIC
@ FERSLIB_ERR_GENERIC
Definition: FERSlib.h:184
FERSLIB_ERR_NOT_APPLICABLE
@ FERSLIB_ERR_NOT_APPLICABLE
Definition: FERSlib.h:199
FERSLIB_ERR_INVALID_BIC
@ FERSLIB_ERR_INVALID_BIC
Definition: FERSlib.h:192
FERSLIB_ERR_DEVICE_ALREADY_OPENED
@ FERSLIB_ERR_DEVICE_ALREADY_OPENED
Definition: FERSlib.h:187
FERSLIB_ERR_CALIB_NOT_FOUND
@ FERSLIB_ERR_CALIB_NOT_FOUND
Definition: FERSlib.h:194
FERSLIB_ERR_INVALID_HANDLE
@ FERSLIB_ERR_INVALID_HANDLE
Definition: FERSlib.h:189
ROMODE_DISABLE_SORTING
@ ROMODE_DISABLE_SORTING
Definition: FERSlib.h:256
ROMODE_TRGTIME_SORTING
@ ROMODE_TRGTIME_SORTING
Definition: FERSlib.h:257
ROMODE_TRGID_SORTING
@ ROMODE_TRGID_SORTING
Definition: FERSlib.h:258
SE_HV
@ SE_HV
Definition: FERSlib.h:266
SE_ALL
@ SE_ALL
Definition: FERSlib.h:268
SE_COUNT
@ SE_COUNT
Definition: FERSlib.h:267
RXSTATUS_IDLE
@ RXSTATUS_IDLE
Definition: FERSlib.h:161
RXSTATUS_EMPTYING
@ RXSTATUS_EMPTYING
Definition: FERSlib.h:163
RXSTATUS_OFF
@ RXSTATUS_OFF
Definition: FERSlib.h:160
RXSTATUS_RUNNING
@ RXSTATUS_RUNNING
Definition: FERSlib.h:162
GLITCHFILTERMODE_BOTH
@ GLITCHFILTERMODE_BOTH
Definition: FERSlib.h:376
GLITCHFILTERMODE_LEADING
@ GLITCHFILTERMODE_LEADING
Definition: FERSlib.h:375
GLITCHFILTERMODE_TRAILING
@ GLITCHFILTERMODE_TRAILING
Definition: FERSlib.h:374
GLITCHFILTERMODE_DISABLED
@ GLITCHFILTERMODE_DISABLED
Definition: FERSlib.h:373
ROSTATUS_RUNNING
@ ROSTATUS_RUNNING
Definition: FERSlib.h:172
RAWDATA_REPROCESS_FINISHED
@ RAWDATA_REPROCESS_FINISHED
Definition: FERSlib.h:175
ROSTATUS_FLUSHING
@ ROSTATUS_FLUSHING
Definition: FERSlib.h:174
ROSTATUS_EMPTYING
@ ROSTATUS_EMPTYING
Definition: FERSlib.h:173
ROSTATUS_IDLE
@ ROSTATUS_IDLE
Definition: FERSlib.h:171
STARTRUN_ASYNC
@ STARTRUN_ASYNC
Definition: FERSlib.h:337
STARTRUN_TDL
@ STARTRUN_TDL
Definition: FERSlib.h:340
STARTRUN_CHAIN_T1
@ STARTRUN_CHAIN_T1
Definition: FERSlib.h:339
STARTRUN_CHAIN_T0
@ STARTRUN_CHAIN_T0
Definition: FERSlib.h:338
FERSLIB_MAX_NTDL
#define FERSLIB_MAX_NTDL
Definition: FERSlib.h:132
FERSLIB_MAX_NNODES
#define FERSLIB_MAX_NNODES
Definition: FERSlib.h:133
FERSLIB_MAX_NBRD
#define FERSLIB_MAX_NBRD
Definition: FERSlib.h:126
FERSLIB_MAX_NCNC
#define FERSLIB_MAX_NCNC
Definition: FERSlib.h:125
FERSLIB_MAX_NCH_5202
#define FERSLIB_MAX_NCH_5202
Definition: FERSlib.h:128
FERS_DisableThrCalib
int FERS_DisableThrCalib(int handle)
Disable threshold calibration.
FERS_DumpBoardRegister
int FERS_DumpBoardRegister(int handle)
Dump the board register information to a file.
FERS_DumpCfgSaved
int FERS_DumpCfgSaved(int handle)
Dump the saved configuration.
FERS_GetLibReleaseDate
char * FERS_GetLibReleaseDate()
Get the release date of the library.
FERS_GetLibReleaseNum
char * FERS_GetLibReleaseNum()
Get the release number of the library.
FERS_GetLastError
int FERS_GetLastError(char description[1024])
Get the last message error of library.
FERS_LibMsg
int FERS_LibMsg(char *fmt,...)
Write on FERSlib log file.
FERS_GetClockPeriod
float FERS_GetClockPeriod(int handle)
Get the clock of the FERS board @parma[in] handle board handle return Clock period in ns.
FERS_OpenDevice
int FERS_OpenDevice(char *path, int *handle)
Open a device (either FERS board, concentrator or offline)
FERS_InitTDLchains
int FERS_InitTDLchains(int handle, float DelayAdjust[8][16])
Send a sync broadcast command via TDL.
FERS_TDLchainsInitialized
bool FERS_TDLchainsInitialized(int handle)
Check if TDL chains are initialized.
FERS_TotalAllocatedMemory
int FERS_TotalAllocatedMemory()
Return the total size of the allocated buffers for the readout of all boards.
FERS_CloseDevice
int FERS_CloseDevice(int handle)
Cloase a device (either FERS board or concentrator)
FERS_GetNumBrdConnected
uint16_t FERS_GetNumBrdConnected()
Get the number of boards connected.
FERS_Get_CncPath
int FERS_Get_CncPath(char *dev_path, char *cnc_path)
Find the path of the concentrator to which a device is connected.
FERS_IsOpen
int FERS_IsOpen(char *path)
Check if a device is already opened.
FERS_Reset_IPaddress
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 ...
FERS_SendCommand
int FERS_SendCommand(int handle, uint32_t cmd)
Send a command to the board
FERS_XROC_WriteRegisterSilce
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.
FERS_ReadRegister
int FERS_ReadRegister(int handle, uint32_t address, uint32_t *data)
Read a register of a FERS board.
FERS_I2C_ReadRegister
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, ...)
FERS_SendCommandBroadcast
int FERS_SendCommandBroadcast(int *handle, uint32_t cmd, uint32_t delay)
Send a broadcast command to multiple boards connected to a concentrator.
FERS_XROC_ReadRegister
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.
FERS_WriteRegister
int FERS_WriteRegister(int handle, uint32_t address, uint32_t data)
Write a register of a FERS board.
FERS_XROC_WriteRegister
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.
FERS_I2C_WriteRegisterSlice
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.
FERS_ReadFlashPage
int FERS_ReadFlashPage(int handle, int pagenum, int size, uint8_t *data)
Read a page from the flash memory.
FERS_I2C_WriteRegister
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, ...)
FERS_WriteRegisterSlice
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.
FERS_WriteBoardInfo
int FERS_WriteBoardInfo(int handle, FERS_BoardInfo_t binfo)
Write Board info into the relevant flash memory page.
FERS_ReadConcentratorInfo
int FERS_ReadConcentratorInfo(int handle, FERS_CncInfo_t *cinfo)
Read concentrator info from the device.
FERS_WriteFlashPage
int FERS_WriteFlashPage(int handle, int pagenum, int size, uint8_t *data)
Write a page of the flash memory.
FERS_ReadPedestalsFromFlash
int FERS_ReadPedestalsFromFlash(int handle, char *date, uint16_t *PedLG, uint16_t *PedHG, uint16_t *dco)
Read pedestal calibration and DC offset
FERS_WritePedestals
int FERS_WritePedestals(int handle, uint16_t *PedLG, uint16_t *PedHG, uint16_t *dco)
Write Pedestal calibration.
FERS_SetCommonPedestal
int FERS_SetCommonPedestal(int handle, uint16_t Pedestal)
Set a common pedestal (applied to all channels after pedestal calibration)
FERS_EnablePedestalCalibration
int FERS_EnablePedestalCalibration(int handle, int enable)
Enable / Disabled pedestal calibration.
FERS_PedestalBackupPage
int FERS_PedestalBackupPage(int handle, int EnBckPage)
Switch to pedestal backup page.
FERS_FPGA_FWrev
uint32_t FERS_FPGA_FWrev(int handle)
Get the FPGA firmware revision of the FERS board.
FERS_ModelName
char * FERS_ModelName(int handle)
Get the model name of the FERS board.
FERS_pid
uint32_t FERS_pid(int handle)
Get the board PID.
FERS_GetCncInfo
int FERS_GetCncInfo(int handle, FERS_CncInfo_t *BrdInfo)
Get concentrator info saved into the library structure.
FERS_GetBoardInfo
int FERS_GetBoardInfo(int handle, FERS_BoardInfo_t *BrdInfo)
Get board info saved into the library structure.
FERS_Code
uint16_t FERS_Code(int handle)
Get the code of the FERS board.
FERS_NumChannels
uint16_t FERS_NumChannels(int handle)
Get the number of channels of the FERS board.
FERS_FPGA_FW_MinorRev
uint32_t FERS_FPGA_FW_MinorRev(int handle)
Get the minor revision of the FPGA firmware.
FERS_IsXROC
bool FERS_IsXROC(int handle)
Check if the board mounts an XROC ASIC chip.
FERS_FPGA_FW_MajorRev
uint32_t FERS_FPGA_FW_MajorRev(int handle)
Get the major revision of the FPGA firmware.
FERS_PCB_Rev
uint8_t FERS_PCB_Rev(int handle)
Get the PCB revision of the FERS board.
FERS_uC_FWrev
uint32_t FERS_uC_FWrev(int handle)
Get them microcontroller firmware revision.
FERS_Get_TDC0_Temp
int FERS_Get_TDC0_Temp(int handle, float *temp)
Get the temperature from picoTDC0 (on the board)
FERS_Get_FPGA_Temp
int FERS_Get_FPGA_Temp(int handle, float *temp)
Get FPGA die temperature.
FERS_Get_Board_Temp
int FERS_Get_Board_Temp(int handle, float *temp)
Get Board temperature, between PIC and FPGA.
FERS_Get_TDC1_Temp
int FERS_Get_TDC1_Temp(int handle, float *temp)
Get the temperature from picoTDC1 (on the mezzanine)
FERS_HV_Get_Vmon
int FERS_HV_Get_Vmon(int handle, float *vmon)
Get HV output voltage (HV read back with internal ADC)
FERS_HV_Get_Status
int FERS_HV_Get_Status(int handle, int *OnOff, int *Ramping, int *OvC, int *OvV)
Get the status of the high voltage module.
FERS_HV_Set_Tsens_Coeff
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.
FERS_HV_ReadReg
int FERS_HV_ReadReg(int handle, uint32_t reg_addr, uint32_t dtype, uint32_t *reg_data)
Read a register of HV.
FERS_HV_Set_OnOff
int FERS_HV_Set_OnOff(int handle, int OnOff)
Turn the high voltage module ON or OFF.
FERS_HV_Init
int FERS_HV_Init(int handle)
Initialize the HV communication bus (I2C)
FERS_HV_Get_Imon
int FERS_HV_Get_Imon(int handle, float *imon)
Get the output monitored current flowing into the detector.
FERS_HV_Get_IntTemp
int FERS_HV_Get_IntTemp(int handle, float *temp)
Get the internal temperature of the HV module.
FERS_HV_Set_TempFeedback
int FERS_HV_Set_TempFeedback(int handle, int enable, float Tsens_coeff)
Set coefficient for Vbias temperature feedback.
FERS_HV_Get_Imax
int FERS_HV_Get_Imax(int handle, float *imax)
Get the maximum allowed current of the high voltage module.
FERS_HV_Get_Vbias
int FERS_HV_Get_Vbias(int handle, float *vbias)
Get the output bias voltage set.
FERS_HV_Get_SerNum
int FERS_HV_Get_SerNum(int handle, int *sernum)
Get the serial number of the high voltage module.
FERS_HV_WriteReg
int FERS_HV_WriteReg(int handle, uint32_t reg_addr, uint32_t dtype, uint32_t reg_data)
Write a value of the HV.
FERS_HV_Get_DetectorTemp
int FERS_HV_Get_DetectorTemp(int handle, float *temp)
Get external temperature (of the detector). Temp sensor must be connected to dedicated lines.
FERS_HV_Set_Vbias
int FERS_HV_Set_Vbias(int handle, float vbias)
Set HV output voltage (bias)
FERS_HV_Set_Imax
int FERS_HV_Set_Imax(int handle, float imax)
Set the maximum output current from the high voltage module.
FERS_configure
int FERS_configure(int handle, int mode)
Configures a FERS board.
FERS_LoadConfigFile
int FERS_LoadConfigFile(char *filepath)
Loads a configuration file.
FERS_SetParam
int FERS_SetParam(int handle, char *param_name, char *value)
Set a parameter by name. The function assigns the value to the relevant parameter in the FERScfg stru...
FERS_GetParam
int FERS_GetParam(int handle, char *param_name, char *value)
Get the value of a parameter. The function reads the value from the relevant parameter in the FERScfg...
FERS_GetEventFromBoard
int FERS_GetEventFromBoard(int handle, int *DataQualifier, double *tstamp_us, void **Event, int *nb)
Read and decode one event from a specific board.
FERS_CloseReadout
int FERS_CloseReadout(int handle)
De-init readoout (free buffers)
FERS_FlushData
int FERS_FlushData(int handle)
Flush the data buffer (Read and discard data until the RX buffer is empty)
FERS_GetCrcErrorCnt
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.
FERS_StopAcquisition
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)
FERS_StartAcquisition
int FERS_StartAcquisition(int *handle, int NumBrd, int StartMode, int RunNum)
Start data acquisition. Set ReadoutState = RUNNING, wait until all threads are running,...
FERS_InitReadout
int FERS_InitReadout(int handle, int ROmode, int *AllocatedSize)
Init readout for one board (allocate buffers and initialize variables)
FERS_GetEvent
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....
FERS_FirmwareBootApplication_ethusb
int FERS_FirmwareBootApplication_ethusb(int handle)
Reboot the firmware application via Ethernet/USB.
FERS_CheckBootloaderVersion
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.
FERS_FirmwareBootApplication_tdl
int FERS_FirmwareBootApplication_tdl(int *handle)
Reboot the firmware application via TDL.
FERS_FirmwareUpgrade
int FERS_FirmwareUpgrade(int handle, char filen[200], void(*ptr)(char *msg, int progress))
Upgrade the firmware of the board.
FERS_checkA5256presence
int FERS_checkA5256presence(int handle, FERS_A5256_Info_t *binfo)
Check A5256 presence.
FERS_WriteEEPROMBlock
int FERS_WriteEEPROMBlock(int handle, int start_address, int size, uint8_t *data)
Writes a block of data to the EEPROM.
FERS_WriteA5256EEPROMInfo
int FERS_WriteA5256EEPROMInfo(int handle, FERS_A5256_Info_t binfo)
Write Adapter A5256 info into the relevant EEPROM memory page.
FERS_ReadEEPROMBlock
int FERS_ReadEEPROMBlock(int handle, int start_address, int size, uint8_t *data)
Reads a block of data from the EEPROM.
FERS_ReadA5256EEPROMInfo
int FERS_ReadA5256EEPROMInfo(int handle, FERS_A5256_Info_t *binfo)
Read Adapter A5256 info into the relevant EEPROM memory page.
FERS_ChMask_ada2tdc
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.
FERS_ChIndex_ada2tdc
int FERS_ChIndex_ada2tdc(int Adapter_ch, int *TDC_ch, int brd)
Remap Adapter channel to TDC channel.
FERS_AdapterNch
int FERS_AdapterNch(int brd)
Get the number of channels for the adapter.
FERS_ChIndex_tdc2ada
int FERS_ChIndex_tdc2ada(int TDC_ch, int *Adapter_ch, int brd)
Remap TDC channel to Adapter channel.
FERS_Set_DiscrThreshold
int FERS_Set_DiscrThreshold(int handle, int Adapter_ch, float thr_mv, int brd)
Set the discriminator threshold.
FERS_CalibThresholdOffset
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.
FERS_ReadThrCalib
int FERS_ReadThrCalib(int handle, int npts, int MemThrDest, char *date, float *ThrOffset)
Read threshold calibration offsets from flash memory.
FERS_FindMemThrDest
int FERS_FindMemThrDest(int handle)
Find the source where calibration is stored (if present EEPROM is default)
FERS_WriteThrCalib
int FERS_WriteThrCalib(int handle, int npts, int MemThrDest, float *ThrOffset)
Write Threshold offset calibration of A5256 adapter to flash.
FERS_TDL_ChainInfo_t
TDL chain information structure.
Definition: FERSlib.h:494
FERS_TDL_ChainInfo_t::EventRate
float EventRate
Definition: FERSlib.h:500
FERS_TDL_ChainInfo_t::EventCount
uint64_t EventCount
Definition: FERSlib.h:498
FERS_TDL_ChainInfo_t::rrt
float rrt
Definition: FERSlib.h:497
FERS_TDL_ChainInfo_t::ByteCount
uint64_t ByteCount
Definition: FERSlib.h:499
FERS_TDL_ChainInfo_t::BoardCount
uint16_t BoardCount
Definition: FERSlib.h:496
FERS_TDL_ChainInfo_t::Status
uint16_t Status
Definition: FERSlib.h:495
FERS_TDL_ChainInfo_t::Mbps
float Mbps
Definition: FERSlib.h:501
FERS_CncInfo_t
Concentrator board information structure.
Definition: FERSlib.h:511
FERS_CncInfo_t::NumLink
uint16_t NumLink
Number of links.
Definition: FERSlib.h:519
FERS_CncInfo_t::pid
uint32_t pid
Board PID (5 decimal digits)
Definition: FERSlib.h:512
FERS_BoardInfo_t
FERS board information structure.
Definition: FERSlib.h:530
FERS_BoardInfo_t::NumCh
uint16_t NumCh
Number of channels.
Definition: FERSlib.h:537
FERS_BoardInfo_t::FERSCode
uint16_t FERSCode
FERS code, e.g. 5202.
Definition: FERSlib.h:532
FERS_BoardInfo_t::FPGA_FWrev
uint32_t FPGA_FWrev
FPGA FW revision.
Definition: FERSlib.h:538
FERS_BoardInfo_t::PCBrevision
uint8_t PCBrevision
PCB revision.
Definition: FERSlib.h:533
FERS_BoardInfo_t::uC_FWrev
uint32_t uC_FWrev
Microcontroller (uC) FW revision.
Definition: FERSlib.h:539
FERS_BoardInfo_t::pid
uint32_t pid
Board PID (5 decimal digits)
Definition: FERSlib.h:531
FERS_BoardInfo_t::FormFactor
uint8_t FormFactor
Form factor (0=naked version (A52XX), 1=boxed version (DT52XX)
Definition: FERSlib.h:536
FERS_A5256_Info_t
A5256 adapter information structure.
Definition: FERSlib.h:549
FERS_A5256_Info_t::NumCh
uint16_t NumCh
Number of channels.
Definition: FERSlib.h:555
FERS_A5256_Info_t::AdapterCode
uint16_t AdapterCode
Adapter code, e.g. 5256.
Definition: FERSlib.h:551
FERS_A5256_Info_t::PCBrevision
uint8_t PCBrevision
PCB revision.
Definition: FERSlib.h:552
FERS_A5256_Info_t::pid
uint32_t pid
Adapter PID (5 decimal digits)
Definition: FERSlib.h:550
SpectEvent_t
Spectroscopy Event data structure (with or without timing)
Definition: FERSlib.h:566
SpectEvent_t::rel_tstamp_us
double rel_tstamp_us
Relative timestamp in us, reset by Tref.
Definition: FERSlib.h:568
SpectEvent_t::tstamp_us
double tstamp_us
Timestamp in us.
Definition: FERSlib.h:567
SpectEvent_t::qdmask
uint64_t qdmask
QD Mask.
Definition: FERSlib.h:571
SpectEvent_t::chmask
uint64_t chmask
Channel Mask.
Definition: FERSlib.h:570
SpectEvent_t::trigger_id
uint64_t trigger_id
Trigger ID.
Definition: FERSlib.h:569
CountingEvent_t
Counting Event data structure.
Definition: FERSlib.h:583
CountingEvent_t::rel_tstamp_us
double rel_tstamp_us
Relative timestamp in us, reset by Tref.
Definition: FERSlib.h:585
CountingEvent_t::q_or_counts
uint32_t q_or_counts
Q-OR counts.
Definition: FERSlib.h:590
CountingEvent_t::tstamp_us
double tstamp_us
Timestamp in us.
Definition: FERSlib.h:584
CountingEvent_t::chmask
uint64_t chmask
Channel Mask from zero suppression.
Definition: FERSlib.h:587
CountingEvent_t::trigger_id
uint64_t trigger_id
Trigger ID.
Definition: FERSlib.h:586
CountingEvent_t::t_or_counts
uint32_t t_or_counts
T-OR counts.
Definition: FERSlib.h:589
WaveEvent_t
Waveform Event data structure.
Definition: FERSlib.h:598
WaveEvent_t::dig_probes
uint8_t * dig_probes
Digital probes samples.
Definition: FERSlib.h:604
WaveEvent_t::tstamp_us
double tstamp_us
Timestamp in us.
Definition: FERSlib.h:599
WaveEvent_t::ns
uint16_t ns
Definition: FERSlib.h:601
WaveEvent_t::wave_hg
uint16_t * wave_hg
High-gain waveform samples.
Definition: FERSlib.h:602
WaveEvent_t::wave_lg
uint16_t * wave_lg
Low-gain waveform samples.
Definition: FERSlib.h:603
WaveEvent_t::trigger_id
uint64_t trigger_id
Trigger ID.
Definition: FERSlib.h:600
ListEvent_t
List Event data structure for timing mode.
Definition: FERSlib.h:611
ListEvent_t::nhits
uint16_t nhits
Number of hits.
Definition: FERSlib.h:616
ListEvent_t::Tref_tstamp
uint64_t Tref_tstamp
Timestamp of reference time signal (5202 only)
Definition: FERSlib.h:613
ListEvent_t::tstamp_us
double tstamp_us
Timestamp in microseconds.
Definition: FERSlib.h:612
ListEvent_t::ow_trailer
uint32_t ow_trailer
PicoTDC one-word trailer.
Definition: FERSlib.h:619
ListEvent_t::trigger_id
uint64_t trigger_id
Trigger ID.
Definition: FERSlib.h:615
ListEvent_t::tstamp_clk
uint64_t tstamp_clk
Timestamp in LSB (5203 only)
Definition: FERSlib.h:614
ServEvent_t
Service Event data structure, common to all FERS module.
Definition: FERSlib.h:632
ServEvent_t::ReadoutFlags
uint32_t ReadoutFlags
Readout Flags from picoTDC and FPGA.
Definition: FERSlib.h:655
ServEvent_t::SupprTrg_cnt
uint32_t SupprTrg_cnt
Zero suppressed triggers counter.
Definition: FERSlib.h:658
ServEvent_t::hv_status_ovv
uint8_t hv_status_ovv
HV over-voltage status.
Definition: FERSlib.h:650
ServEvent_t::hv_status_on
uint8_t hv_status_on
HV status ON/OFF.
Definition: FERSlib.h:648
ServEvent_t::hv_Vmon
float hv_Vmon
HV voltage monitor.
Definition: FERSlib.h:646
ServEvent_t::tstamp_us
double tstamp_us
Time stamp of service event.
Definition: FERSlib.h:633
ServEvent_t::t_or_cnt
uint32_t t_or_cnt
T-OR counts value.
Definition: FERSlib.h:640
ServEvent_t::q_or_cnt
uint32_t q_or_cnt
Q-OR counts value.
Definition: FERSlib.h:639
ServEvent_t::tempHV
float tempHV
High-voltage module temperature.
Definition: FERSlib.h:644
ServEvent_t::tempDetector
float tempDetector
Detector temperature (referred to ?)
Definition: FERSlib.h:645
ServEvent_t::format
uint8_t format
Event Format.
Definition: FERSlib.h:637
ServEvent_t::TDCROStatus
uint16_t TDCROStatus
TDC Readout Status Register.
Definition: FERSlib.h:653
ServEvent_t::update_time
uint64_t update_time
Update time (epoch, ms)
Definition: FERSlib.h:634
ServEvent_t::version
uint8_t version
Service event version.
Definition: FERSlib.h:636
ServEvent_t::hv_Imon
float hv_Imon
HV current monitor.
Definition: FERSlib.h:647
ServEvent_t::tempFPGA
float tempFPGA
FPGA core temperature.
Definition: FERSlib.h:641
ServEvent_t::TotTrg_cnt
uint32_t TotTrg_cnt
Total triggers counter.
Definition: FERSlib.h:656
ServEvent_t::RejTrg_cnt
uint32_t RejTrg_cnt
Rejected triggers counter.
Definition: FERSlib.h:657
ServEvent_t::Status
uint16_t Status
Status Register.
Definition: FERSlib.h:652
ServEvent_t::hv_status_ovc
uint8_t hv_status_ovc
HV over-current status.
Definition: FERSlib.h:651
ServEvent_t::hv_status_ramp
uint8_t hv_status_ramp
HV ramp status.
Definition: FERSlib.h:649
ServEvent_t::pkt_size
uint16_t pkt_size
Event size.
Definition: FERSlib.h:635
ServEvent_t::tempBoard
float tempBoard
Board temperature (near uC PIC)
Definition: FERSlib.h:642
TestEvent_t
Test Mode Event data structure.
Definition: FERSlib.h:667
TestEvent_t::tstamp_us
double tstamp_us
Timestamp in us.
Definition: FERSlib.h:668
TestEvent_t::nwords
uint16_t nwords
Number of words.
Definition: FERSlib.h:670
TestEvent_t::trigger_id
uint64_t trigger_id
Trigger ID.
Definition: FERSlib.h:669