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
159typedef enum {
165
170typedef enum {
177
182typedef enum {
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
255typedef enum {
258 ROMODE_TRGID_SORTING = 0x0002
260
265typedef enum {
266 SE_HV = 1,
268 SE_ALL = 3
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
336typedef enum {
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
372typedef enum {
378
384typedef enum {
387 HRCLK_FAN_OUT = 2
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//******************************************************************
494typedef 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;
503
504//******************************************************************
505// Concentrator Info Struct
506//******************************************************************
511typedef 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];
522
523//******************************************************************
524// FERS Board Info Struct
525//******************************************************************
530typedef 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;
541
542//******************************************************************
543// A5256 Adapter Info Struct
544//******************************************************************
549typedef 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;
557
558//******************************************************************
559// Event Data Structures
560//******************************************************************
561// Spectroscopy Event (with or without timing)
566typedef struct {
567 double 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];
577
578// Counting Event
583typedef struct {
584 double 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;
592
593// Waveform Event
598typedef 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;
606
611typedef 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
632typedef 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;
646 float hv_Vmon;
647 float hv_Imon;
648 uint8_t hv_status_on;
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)
667typedef struct {
668 double tstamp_us;
669 uint64_t trigger_id;
670 uint16_t nwords;
671 uint32_t test_data[MAX_TEST_NWORDS];
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
701extern "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
int ConfigureProbe(int handle)
int FERS_TDC_Config(int handle, int tdc_id, int StartSrc, int StopSrc)
int FERS_TDC_ReadReg(int handle, int tdc_id, uint32_t addr, uint32_t *data)
int FERS_SetEnergyBitsRange(uint16_t EnergyRange)
int FERS_OpenRawDataFile(int *handle, int RunNum)
Enable the rawdata file saving and set default file name.
#define MAX_LIST_SIZE
Definition: FERSlib.h:310
#define MAX_TEST_NWORDS
Definition: FERSlib.h:311
int FERS_TDC_DoStartStopMeasurement(int handle, int tdc_id, double *tof_ns)
int FERS_TDC_WriteReg(int handle, int tdc_id, uint32_t addr, uint32_t data)
int FERS_CloseRawDataFile(int *handle)
Close raw data file after run stops.
int FERS_GetChannelPedestalBeforeCalib(int handle, int ch, uint16_t *PedLG, uint16_t *PedHG)
void _setLastLocalError(const char *description,...)
FERSLIB_HRClockModes
High resolution clock modes.
Definition: FERSlib.h:384
FERSLIB_ErrorCodes
Error codes.
Definition: FERSlib.h:182
FERSLIB_EvtBuildingModes
Event Building modes.
Definition: FERSlib.h:255
FERSLIB_ServEventsMode
Service event Modes.
Definition: FERSlib.h:265
FERSLIB_RxThreadSatatus
Status of the data RX thread.
Definition: FERSlib.h:159
FERSLIB_GlitchFilterModes
Glitch filter modes.
Definition: FERSlib.h:372
FERSLIB_ReadoutStatus
Readout status.
Definition: FERSlib.h:170
FERSLIB_StartMode
Start/Stop modes.
Definition: FERSlib.h:336
@ HRCLK_FAN_OUT
Definition: FERSlib.h:387
@ HRCLK_DISABLED
Definition: FERSlib.h:385
@ HRCLK_DAISY_CHAIN
Definition: FERSlib.h:386
@ FERSLIB_ERR_INVALID_FWFILE
Definition: FERSlib.h:196
@ FERSLIB_ERR_INVALID_PARAM_UNIT
Definition: FERSlib.h:211
@ FERSLIB_ERR_PEDCALIB_NOT_FOUND
Definition: FERSlib.h:195
@ FERSLIB_ERR_INVALID_PATH
Definition: FERSlib.h:188
@ FERSLIB_ERR_I2C_NACK
Definition: FERSlib.h:207
@ FERSLIB_ERR_MAX_NBOARD_REACHED
Definition: FERSlib.h:186
@ FERSLIB_ERR_INVALID_PARAM_VALUE
Definition: FERSlib.h:210
@ FERSLIB_ERR_INVALID_CLK_SETTING
Definition: FERSlib.h:204
@ FERSLIB_ERR_INVALID_FW
Definition: FERSlib.h:209
@ FERSLIB_ERR_READOUT_NOT_INIT
Definition: FERSlib.h:193
@ FERSLIB_ERR_INVALID_PARAM
Definition: FERSlib.h:198
@ FERSLIB_ERR_CALIB_FAIL
Definition: FERSlib.h:208
@ FERSLIB_ERR_QUEUE_OVERRUN
Definition: FERSlib.h:201
@ FERSLIB_ERR_TDL_ERROR
Definition: FERSlib.h:200
@ FERSLIB_SUCCESS
Definition: FERSlib.h:183
@ FERSLIB_ERR_UPGRADE_ERROR
Definition: FERSlib.h:197
@ FERSLIB_ERR_COMMUNICATION
Definition: FERSlib.h:185
@ FERSLIB_ERR_TDL_CHAIN_DOWN
Definition: FERSlib.h:206
@ FERSLIB_ERR_OPER_NOT_ALLOWED
Definition: FERSlib.h:203
@ FERSLIB_ERR_MALLOC_BUFFERS
Definition: FERSlib.h:191
@ FERSLIB_ERR_READOUT_ERROR
Definition: FERSlib.h:190
@ FERSLIB_ERR_TDL_CHAIN_BROKEN
Definition: FERSlib.h:205
@ FERSLIB_ERR_START_STOP_ERROR
Definition: FERSlib.h:202
@ FERSLIB_ERR_GENERIC
Definition: FERSlib.h:184
@ FERSLIB_ERR_NOT_APPLICABLE
Definition: FERSlib.h:199
@ FERSLIB_ERR_INVALID_BIC
Definition: FERSlib.h:192
@ FERSLIB_ERR_DEVICE_ALREADY_OPENED
Definition: FERSlib.h:187
@ FERSLIB_ERR_CALIB_NOT_FOUND
Definition: FERSlib.h:194
@ FERSLIB_ERR_INVALID_HANDLE
Definition: FERSlib.h:189
@ ROMODE_DISABLE_SORTING
Definition: FERSlib.h:256
@ ROMODE_TRGTIME_SORTING
Definition: FERSlib.h:257
@ ROMODE_TRGID_SORTING
Definition: FERSlib.h:258
@ SE_HV
Definition: FERSlib.h:266
@ SE_ALL
Definition: FERSlib.h:268
@ SE_COUNT
Definition: FERSlib.h:267
@ RXSTATUS_IDLE
Definition: FERSlib.h:161
@ RXSTATUS_EMPTYING
Definition: FERSlib.h:163
@ RXSTATUS_OFF
Definition: FERSlib.h:160
@ RXSTATUS_RUNNING
Definition: FERSlib.h:162
@ GLITCHFILTERMODE_BOTH
Definition: FERSlib.h:376
@ GLITCHFILTERMODE_LEADING
Definition: FERSlib.h:375
@ GLITCHFILTERMODE_TRAILING
Definition: FERSlib.h:374
@ GLITCHFILTERMODE_DISABLED
Definition: FERSlib.h:373
@ ROSTATUS_RUNNING
Definition: FERSlib.h:172
@ RAWDATA_REPROCESS_FINISHED
Definition: FERSlib.h:175
@ ROSTATUS_FLUSHING
Definition: FERSlib.h:174
@ ROSTATUS_EMPTYING
Definition: FERSlib.h:173
@ ROSTATUS_IDLE
Definition: FERSlib.h:171
@ STARTRUN_ASYNC
Definition: FERSlib.h:337
@ STARTRUN_TDL
Definition: FERSlib.h:340
@ STARTRUN_CHAIN_T1
Definition: FERSlib.h:339
@ STARTRUN_CHAIN_T0
Definition: FERSlib.h:338
#define FERSLIB_MAX_NTDL
Definition: FERSlib.h:132
#define FERSLIB_MAX_NNODES
Definition: FERSlib.h:133
#define FERSLIB_MAX_NBRD
Definition: FERSlib.h:126
#define FERSLIB_MAX_NCNC
Definition: FERSlib.h:125
#define FERSLIB_MAX_NCH_5202
Definition: FERSlib.h:128
int FERS_DisableThrCalib(int handle)
Disable threshold calibration.
int FERS_DumpBoardRegister(int handle)
Dump the board register information to a file.
int FERS_DumpCfgSaved(int handle)
Dump the saved configuration.
char * FERS_GetLibReleaseDate()
Get the release date of the library.
char * FERS_GetLibReleaseNum()
Get the release number of the library.
int FERS_GetLastError(char description[1024])
Get the last message error of library.
int FERS_LibMsg(char *fmt,...)
Write on FERSlib log file.
float FERS_GetClockPeriod(int handle)
Get the clock of the FERS board @parma[in] handle board handle return Clock period in ns.
int FERS_OpenDevice(char *path, int *handle)
Open a device (either FERS board, concentrator or offline)
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.
int FERS_TotalAllocatedMemory()
Return the total size of the allocated buffers for the readout of all boards.
int FERS_CloseDevice(int handle)
Cloase a device (either FERS board or concentrator)
uint16_t FERS_GetNumBrdConnected()
Get the number of boards connected.
int FERS_Get_CncPath(char *dev_path, char *cnc_path)
Find the path of the concentrator to which a device is connected.
int FERS_IsOpen(char *path)
Check if a device is already opened.
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 ...
int FERS_SendCommand(int handle, uint32_t cmd)
Send a command to the board
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_ReadRegister(int handle, uint32_t address, uint32_t *data)
Read a register of a FERS board.
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_SendCommandBroadcast(int *handle, uint32_t cmd, uint32_t delay)
Send a broadcast command to multiple boards connected to a concentrator.
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_WriteRegister(int handle, uint32_t address, uint32_t data)
Write a register of a FERS board.
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_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_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_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_WriteBoardInfo(int handle, FERS_BoardInfo_t binfo)
Write Board info into the relevant flash memory page.
int FERS_ReadConcentratorInfo(int handle, FERS_CncInfo_t *cinfo)
Read concentrator info from the device.
int FERS_WriteFlashPage(int handle, int pagenum, int size, uint8_t *data)
Write a page of the flash memory.
int FERS_ReadPedestalsFromFlash(int handle, char *date, uint16_t *PedLG, uint16_t *PedHG, uint16_t *dco)
Read pedestal calibration and DC offset
int FERS_WritePedestals(int handle, uint16_t *PedLG, uint16_t *PedHG, uint16_t *dco)
Write Pedestal calibration.
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_PedestalBackupPage(int handle, int EnBckPage)
Switch to pedestal backup page.
uint32_t FERS_FPGA_FWrev(int handle)
Get the FPGA firmware revision of the FERS board.
char * FERS_ModelName(int handle)
Get the model name of the FERS board.
uint32_t FERS_pid(int handle)
Get the board PID.
int FERS_GetCncInfo(int handle, FERS_CncInfo_t *BrdInfo)
Get concentrator info saved into the library structure.
int FERS_GetBoardInfo(int handle, FERS_BoardInfo_t *BrdInfo)
Get board info saved into the library structure.
uint16_t FERS_Code(int handle)
Get the code of the FERS board.
uint16_t FERS_NumChannels(int handle)
Get the number of channels of the FERS board.
uint32_t FERS_FPGA_FW_MinorRev(int handle)
Get the minor revision of the FPGA firmware.
bool FERS_IsXROC(int handle)
Check if the board mounts an XROC ASIC chip.
uint32_t FERS_FPGA_FW_MajorRev(int handle)
Get the major revision of the FPGA firmware.
uint8_t FERS_PCB_Rev(int handle)
Get the PCB revision of the FERS board.
uint32_t FERS_uC_FWrev(int handle)
Get them microcontroller firmware revision.
int FERS_Get_TDC0_Temp(int handle, float *temp)
Get the temperature from picoTDC0 (on the board)
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_Get_TDC1_Temp(int handle, float *temp)
Get the temperature from picoTDC1 (on the mezzanine)
int FERS_HV_Get_Vmon(int handle, float *vmon)
Get HV output voltage (HV read back with internal ADC)
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_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_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_Init(int handle)
Initialize the HV communication bus (I2C)
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_Set_TempFeedback(int handle, int enable, float Tsens_coeff)
Set coefficient for Vbias temperature feedback.
int FERS_HV_Get_Imax(int handle, float *imax)
Get the maximum allowed current of the high voltage module.
int FERS_HV_Get_Vbias(int handle, float *vbias)
Get the output bias voltage set.
int FERS_HV_Get_SerNum(int handle, int *sernum)
Get the serial number of the high voltage module.
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_Get_DetectorTemp(int handle, float *temp)
Get external temperature (of the detector). Temp sensor must be connected to dedicated lines.
int FERS_HV_Set_Vbias(int handle, float vbias)
Set HV output voltage (bias)
int FERS_HV_Set_Imax(int handle, float imax)
Set the maximum output current from the high voltage module.
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, char *param_name, char *value)
Set a parameter by name. The function assigns the value to the relevant parameter in the FERScfg stru...
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...
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_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_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_StartAcquisition(int *handle, int NumBrd, int StartMode, int RunNum)
Start data acquisition. Set ReadoutState = RUNNING, wait until all threads are running,...
int FERS_InitReadout(int handle, int ROmode, int *AllocatedSize)
Init readout for one board (allocate buffers and initialize variables)
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....
int FERS_FirmwareBootApplication_ethusb(int handle)
Reboot the firmware application via Ethernet/USB.
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_FirmwareBootApplication_tdl(int *handle)
Reboot the firmware application via TDL.
int FERS_FirmwareUpgrade(int handle, char filen[200], void(*ptr)(char *msg, int progress))
Upgrade the firmware of the board.
int FERS_checkA5256presence(int handle, FERS_A5256_Info_t *binfo)
Check A5256 presence.
int FERS_WriteEEPROMBlock(int handle, int start_address, int size, uint8_t *data)
Writes a block of data to the EEPROM.
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_ReadA5256EEPROMInfo(int handle, FERS_A5256_Info_t *binfo)
Read Adapter A5256 info into the relevant EEPROM memory page.
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_ChIndex_ada2tdc(int Adapter_ch, int *TDC_ch, int brd)
Remap Adapter channel to TDC channel.
int FERS_AdapterNch(int brd)
Get the number of channels for the adapter.
int FERS_ChIndex_tdc2ada(int TDC_ch, int *Adapter_ch, int brd)
Remap TDC channel to Adapter channel.
int FERS_Set_DiscrThreshold(int handle, int Adapter_ch, float thr_mv, int brd)
Set the discriminator threshold.
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_ReadThrCalib(int handle, int npts, int MemThrDest, char *date, float *ThrOffset)
Read threshold calibration offsets from flash memory.
int FERS_FindMemThrDest(int handle)
Find the source where calibration is stored (if present EEPROM is default)
int FERS_WriteThrCalib(int handle, int npts, int MemThrDest, float *ThrOffset)
Write Threshold offset calibration of A5256 adapter to flash.
TDL chain information structure.
Definition: FERSlib.h:494
uint64_t EventCount
Definition: FERSlib.h:498
uint64_t ByteCount
Definition: FERSlib.h:499
uint16_t BoardCount
Definition: FERSlib.h:496
Concentrator board information structure.
Definition: FERSlib.h:511
uint16_t NumLink
Number of links.
Definition: FERSlib.h:519
uint32_t pid
Board PID (5 decimal digits)
Definition: FERSlib.h:512
FERS board information structure.
Definition: FERSlib.h:530
uint16_t NumCh
Number of channels.
Definition: FERSlib.h:537
uint16_t FERSCode
FERS code, e.g. 5202.
Definition: FERSlib.h:532
uint32_t FPGA_FWrev
FPGA FW revision.
Definition: FERSlib.h:538
uint8_t PCBrevision
PCB revision.
Definition: FERSlib.h:533
uint32_t uC_FWrev
Microcontroller (uC) FW revision.
Definition: FERSlib.h:539
uint32_t pid
Board PID (5 decimal digits)
Definition: FERSlib.h:531
uint8_t FormFactor
Form factor (0=naked version (A52XX), 1=boxed version (DT52XX)
Definition: FERSlib.h:536
A5256 adapter information structure.
Definition: FERSlib.h:549
uint16_t NumCh
Number of channels.
Definition: FERSlib.h:555
uint16_t AdapterCode
Adapter code, e.g. 5256.
Definition: FERSlib.h:551
uint8_t PCBrevision
PCB revision.
Definition: FERSlib.h:552
uint32_t pid
Adapter PID (5 decimal digits)
Definition: FERSlib.h:550
Spectroscopy Event data structure (with or without timing)
Definition: FERSlib.h:566
double rel_tstamp_us
Relative timestamp in us, reset by Tref.
Definition: FERSlib.h:568
double tstamp_us
Timestamp in us.
Definition: FERSlib.h:567
uint64_t qdmask
QD Mask.
Definition: FERSlib.h:571
uint64_t chmask
Channel Mask.
Definition: FERSlib.h:570
uint64_t trigger_id
Trigger ID.
Definition: FERSlib.h:569
Counting Event data structure.
Definition: FERSlib.h:583
double rel_tstamp_us
Relative timestamp in us, reset by Tref.
Definition: FERSlib.h:585
uint32_t q_or_counts
Q-OR counts.
Definition: FERSlib.h:590
double tstamp_us
Timestamp in us.
Definition: FERSlib.h:584
uint64_t chmask
Channel Mask from zero suppression.
Definition: FERSlib.h:587
uint64_t trigger_id
Trigger ID.
Definition: FERSlib.h:586
uint32_t t_or_counts
T-OR counts.
Definition: FERSlib.h:589
Waveform Event data structure.
Definition: FERSlib.h:598
uint8_t * dig_probes
Digital probes samples.
Definition: FERSlib.h:604
double tstamp_us
Timestamp in us.
Definition: FERSlib.h:599
uint16_t ns
Definition: FERSlib.h:601
uint16_t * wave_hg
High-gain waveform samples.
Definition: FERSlib.h:602
uint16_t * wave_lg
Low-gain waveform samples.
Definition: FERSlib.h:603
uint64_t trigger_id
Trigger ID.
Definition: FERSlib.h:600
List Event data structure for timing mode.
Definition: FERSlib.h:611
uint16_t nhits
Number of hits.
Definition: FERSlib.h:616
uint64_t Tref_tstamp
Timestamp of reference time signal (5202 only)
Definition: FERSlib.h:613
double tstamp_us
Timestamp in microseconds.
Definition: FERSlib.h:612
uint32_t ow_trailer
PicoTDC one-word trailer.
Definition: FERSlib.h:619
uint64_t trigger_id
Trigger ID.
Definition: FERSlib.h:615
uint64_t tstamp_clk
Timestamp in LSB (5203 only)
Definition: FERSlib.h:614
Service Event data structure, common to all FERS module.
Definition: FERSlib.h:632
uint32_t ReadoutFlags
Readout Flags from picoTDC and FPGA.
Definition: FERSlib.h:655
uint32_t SupprTrg_cnt
Zero suppressed triggers counter.
Definition: FERSlib.h:658
uint8_t hv_status_ovv
HV over-voltage status.
Definition: FERSlib.h:650
uint8_t hv_status_on
HV status ON/OFF.
Definition: FERSlib.h:648
float hv_Vmon
HV voltage monitor.
Definition: FERSlib.h:646
double tstamp_us
Time stamp of service event.
Definition: FERSlib.h:633
uint32_t t_or_cnt
T-OR counts value.
Definition: FERSlib.h:640
uint32_t q_or_cnt
Q-OR counts value.
Definition: FERSlib.h:639
float tempHV
High-voltage module temperature.
Definition: FERSlib.h:644
float tempDetector
Detector temperature (referred to ?)
Definition: FERSlib.h:645
uint8_t format
Event Format.
Definition: FERSlib.h:637
uint16_t TDCROStatus
TDC Readout Status Register.
Definition: FERSlib.h:653
uint64_t update_time
Update time (epoch, ms)
Definition: FERSlib.h:634
uint8_t version
Service event version.
Definition: FERSlib.h:636
float hv_Imon
HV current monitor.
Definition: FERSlib.h:647
float tempFPGA
FPGA core temperature.
Definition: FERSlib.h:641
uint32_t TotTrg_cnt
Total triggers counter.
Definition: FERSlib.h:656
uint32_t RejTrg_cnt
Rejected triggers counter.
Definition: FERSlib.h:657
uint16_t Status
Status Register.
Definition: FERSlib.h:652
uint8_t hv_status_ovc
HV over-current status.
Definition: FERSlib.h:651
uint8_t hv_status_ramp
HV ramp status.
Definition: FERSlib.h:649
uint16_t pkt_size
Event size.
Definition: FERSlib.h:635
float tempBoard
Board temperature (near uC PIC)
Definition: FERSlib.h:642
Test Mode Event data structure.
Definition: FERSlib.h:667
double tstamp_us
Timestamp in us.
Definition: FERSlib.h:668
uint16_t nwords
Number of words.
Definition: FERSlib.h:670
uint64_t trigger_id
Trigger ID.
Definition: FERSlib.h:669