CAEN FERS Library v1.3.0
SDK for FERS systems
Loading...
Searching...
No Matches
FERSlib.h
Go to the documentation of this file.
1
23
38
39
40#ifndef _FERSLIB_H
41#define _FERSLIB_H // Protect against multiple inclusion
42
43#include <stdint.h>
44#include <stdlib.h> // for min/max definition
45#include <stdio.h>
46#include <math.h>
47#include "ExportTypes.h"
48
49#include "FERS_Registers_520X.h"
50#include "FERS_Registers_5215.h"
51
52//#include "FERS_MultiPlatform.h"
53
54#ifndef WIN32
55#include <stdbool.h>
56#endif
57
58
59#define FERSLIB_STR_HELPER_(S) #S
60#define FERSLIB_STR(S) FERSLIB_STR_HELPER_(S)
61
62
63#define f_sprintf sprintf_s
64#define f_fopen fopen_s
65
66
71
77
83
89
94
99
104
109
116#define FERSLIB_VERSION_MAJOR 1
117#define FERSLIB_VERSION_MINOR 3
118#define FERSLIB_VERSION_PATCH 0
119#define FERSLIB_RELEASE_NUM (FERSLIB_VERSION_MAJOR * 10000) + (FERSLIB_VERSION_MINOR * 100) + (FERSLIB_VERSION_PATCH)
120#define FERSLIB_RELEASE_STRING FERSLIB_STR(FERSLIB_VERSION_MAJOR) "." FERSLIB_STR(FERSLIB_VERSION_MINOR) "." FERSLIB_STR(FERSLIB_VERSION_PATCH)
121#define FERSLIB_RELEASE_DATE "14/01/2026"
123
124#define THROUGHPUT_METER 0
125
126#define INVALID_TEMP 999
127
134#define FERSLIB_MAX_NCNC 4
135#define FERSLIB_MAX_NBRD 128
136#define FERSLIB_MAX_NCH 128
137#define FERSLIB_MAX_NCH_5202 64
138#define FERSLIB_MAX_NCH_5203 128
139#define FERSLIB_MAX_NCH_5204 64
140#define PICOTDC_NCH 64
141#define FERSLIB_MAX_NTDL 8
142#define FERSLIB_MAX_NNODES 16
144
145
152#define DBLOG_FERSLIB_MSG 0x0001
153#define DBLOG_RAW_DATA_OUTFILE 0x0002
154#define DBLOG_LL_DATADUMP 0x0004
155#define DBLOG_LL_MSGDUMP 0x0008
156#define DBLOG_QUEUES 0x0010
157#define DBLOG_RAW_DECODE 0x0020
158#define DBLOG_LL_READDUMP 0x0040
159#define DBLOG_PARAMS 0x0080
160#define DBLOG_CONFIG 0x0100
161#define ENABLE_FERSLIB_LOGMSG 1
163
174
186
222
229#define ACQMODE_SPECT 0x01
230#define ACQMODE_TSPECT 0x03
231#define ACQMODE_TIMING_CSTART 0x02
232#define ACQMODE_TIMING_GATED 0x02
233#define ACQMODE_TIMING_CSTOP 0x12
234#define ACQMODE_TIMING_STREAMING 0x22
235#define ACQMODE_COMMON_START 0x02
236#define ACQMODE_COMMON_STOP 0x12
237#define ACQMODE_STREAMING 0x22
238#define ACQMODE_TRG_MATCHING 0x32
239#define ACQMODE_TEST_MODE 0x01
240#define ACQMODE_COUNT 0x04
241#define ACQMODE_WAVE 0x08
243
250#define DTQ_SPECT 0x01
251#define DTQ_TIMING 0x02
252#define DTQ_COUNT 0x04
253#define DTQ_WAVE 0x08
254#define DTQ_TSPECT 0x03
255#define DTQ_SERVICE 0x2F
256#define DTQ_TEST 0xFF
257#define DTQ_START 0x0F
259
269
274typedef enum {
275 SE_HV = 1,
279
280
285#define NODATA_TIMEOUT 100
286#define STOP_TIMEOUT 500
287#define FERS_CONNECT_TIMEOUT 3
288
295#define TDL_COMMAND_DELAY 1000000
296#define CLK_PERIOD_5202 8
297#define CLK_PERIOD_5203 12.8
298#define CLK_PERIOD_5204 12.8
300
307#define TDC_CLK_PERIOD (CLK_PERIOD_5203*2)
308#define TDC_PULSER_CLK_PERIOD (TDC_CLK_PERIOD / 32)
309#define TDC_LSB_ps (TDC_CLK_PERIOD / 8 / 1.024)
310#define CLK2LSB 4096
312// ---------------------
313
318#define MAX_WAVEFORM_LENGTH 2048
319#define MAX_LIST_SIZE 2048
320#define MAX_TEST_NWORDS 4
321#define MAX_SERV_NWORDS 6
322
323
330#define MEASMODE_LEAD_ONLY 0x01
331#define MEASMODE_LEAD_TRAIL 0x03
332#define MEASMODE_LEAD_TOT8 0x05
333#define MEASMODE_LEAD_TOT11 0x09
334#define MEASMODE_OWLT(m) (((m) == MEASMODE_LEAD_TOT8) || ((m) == MEASMODE_LEAD_TOT11))
336
337#define EDGE_LEAD 1
338#define EDGE_TRAIL 0
339
351
352#define STOPRUN_MANUAL 0
353#define STOPRUN_PRESET_TIME 1
354#define STOPRUN_PRESET_COUNTS 2
355
356#define EVBLD_DISABLED 0 // Event Building disabled */
357#define EVBLD_TRGTIME_SORTING 1 // Sorting events by timestamp of the trigger */
358#define EVBLD_TRGID_SORTING 2 // Sorting events by the trigger ID */
359
360// Citiroc Configuration
361#define CITIROC_CFG_FROM_REGS 0
362#define CITIROC_CFG_FROM_FILE 1
363
364
369#define ENERGY_NBIT 14
370#define TOA_NBIT 16
371#define TOA_LSB_ns 0.5
372#define TOT_NBIT 9
373
374
375// Parameter Options
387
398
405#define EEPROM_BIC_SIZE 44
406#define EEPROM_BIC_PAGE 0
407#define EEPROM_CAL_PAGE 256
408#define EEPROM_CAL_SIZE 256
410
417#define FLASH_PAGE_SIZE 528
418#define FLASH_BIC_PAGE 0
419
420#define FLASH_PEDCALIB_PAGE 4
421#define FLASH_PEDCALIB_BCK_PAGE 5
422
423#define FLASH_THR_OFFS_PAGE 4
424#define FLASH_THR_OFFS_BCK_PAGE 5
426
427
432#define A5203_FLASH 0
433#define A5256_EEPROM 1
435
436// Handles and indexing
443#define FERS_INDEX(handle) ((handle) & 0xFF)
444#define FERS_CONNECTIONTYPE(handle) ((handle) & 0xF0000)
445#define FERS_CONNECTIONTYPE_ETH 0x00000
446#define FERS_CONNECTIONTYPE_USB 0x10000
447#define FERS_CONNECTIONTYPE_TDL 0x20000
448#define FERS_CONNECTIONTYPE_CNC 0x80000
449#define FERS_NODE(handle) ((handle >> 20) & 0xF)
450#define FERS_CHAIN(handle) ((handle >> 24) & 0xF)
451#define FERS_CNCINDEX(handle) ((handle >> 30) & 0xF)
452#define FERS_CNC_HANDLE(handle) (0x80000 | ((handle >> 30) & 0xF))
454
455// Fimrware upgrade via TDL
461#define FUP_BA 0xFF000000
462#define FUP_CONTROL_REG 1023
463#define FUP_PARAM_REG 1022
464#define FUP_RESULT_REG 1021
465#define FUP_CMD_READ_VERSION 0xFF
466#define POLY 0x82f63b78
467
468
469// Definition of limits and sizes
470#define FERSLIB_MAX_GW 20
471
472#define OUTFILE_RAW_LL 0x0001 // Can be a Janus parameter
473
480#define CFG_HARD 0
481#define CFG_SOFT 1
483
484
485// Other macros
492#ifndef max
493#define max(a,b) ((a) > (b) ? (a) : (b))
494#endif
495#ifndef min
496#define min(a,b) ((a) < (b) ? (a) : (b))
497#endif
499
500//******************************************************************
501// TDL-chain Info Struct
502//******************************************************************
507typedef struct {
508 uint16_t Status;
509 uint16_t BoardCount;
510 float rrt;
511 uint64_t EventCount;
512 uint64_t ByteCount;
513 float EventRate;
514 float Mbps;
516
517//******************************************************************
518// Concentrator Info Struct
519//******************************************************************
524typedef struct {
525 uint32_t pid;
526 char PCBrevision[16];
527 char ModelCode[16];
528 char ModelName[16];
529 char FPGA_FWrev[20];
530 char SW_rev[20];
531 char MACaddr_10GbE[20];
532 uint16_t NumLink;
535
536//******************************************************************
537// FERS Board Info Struct
538//******************************************************************
543typedef struct {
544 uint32_t pid;
545 uint16_t FERSCode;
546 uint8_t PCBrevision;
547 char ModelCode[16];
548 char ModelName[16];
549 uint8_t FormFactor;
550 uint16_t NumCh;
551 uint32_t FPGA_FWrev;
552 uint32_t uC_FWrev;
554
555//******************************************************************
556// A5256 Adapter Info Struct
557//******************************************************************
562typedef struct {
563 uint32_t pid;
564 uint16_t AdapterCode;
565 uint8_t PCBrevision;
566 char ModelCode[16];
567 char ModelName[16];
568 uint16_t NumCh;
570
571//******************************************************************
572// Event Data Structures
573//******************************************************************
574// Spectroscopy Event (with or without timing)
579typedef struct {
580 double tstamp_us;
582 uint64_t tstamp_clk;
583 uint64_t Tref_tstamp;
584 uint64_t trigger_id;
585 uint64_t chmask;
586 uint64_t qdmask;
587 uint16_t energyHG[64];
588 uint16_t energyLG[64];
589 uint32_t tstamp[64];
590 uint16_t ToT[64];
592
593// Counting Event
598typedef struct {
599 double tstamp_us;
601 uint64_t trigger_id;
602 uint64_t chmask;
603 uint32_t counts[64];
604 uint32_t t_or_counts;
605 uint32_t q_or_counts;
607
608// Waveform Event
613typedef struct {
614 double tstamp_us;
615 uint64_t trigger_id;
616 uint16_t ns;
617 uint16_t *wave_hg;
618 uint16_t *wave_lg;
619 uint8_t *dig_probes;
621
626typedef struct {
627 double tstamp_us;
628 uint64_t Tref_tstamp;
629 uint64_t tstamp_clk;
630 uint64_t trigger_id;
631 uint16_t nhits;
632 uint32_t header1[8];
633 uint32_t header2[8];
634 uint32_t ow_trailer;
635 uint32_t trailer[8];
639 uint32_t ToA[MAX_LIST_SIZE];
640 uint16_t ToT[MAX_LIST_SIZE];
641} ListEvent_t; // 5202 + 5203
642
647typedef struct {
648 double tstamp_us;
649 uint64_t update_time;
650 uint16_t pkt_size;
651 uint8_t version;
652 uint8_t format;
653 uint32_t ch_trg_cnt[FERSLIB_MAX_NCH_5202]; // Channel trigger counts
654 uint32_t q_or_cnt;
655 uint32_t t_or_cnt;
656 float tempFPGA;
657 float tempBoard;
658 float tempTDC[2];
659 float tempHV;
661 float hv_Vmon;
662 float hv_Imon;
663 uint8_t hv_status_on;
667 uint16_t Status;
668 uint16_t TDCROStatus;
669 uint64_t ChAlmFullFlags[2];
670 uint32_t ReadoutFlags;
671 uint32_t TotTrg_cnt;
672 uint32_t RejTrg_cnt;
673 uint32_t SupprTrg_cnt;
674} ServEvent_t; // 5202 + 5203
675
676
677// Test Mode Event (fixed data patterns)
682typedef struct {
683 double tstamp_us;
684 uint64_t trigger_id;
685 uint16_t nwords;
688
689
696#define A5256_CH0_POSITIVE 0
697#define A5256_CH0_NEGATIVE 1
698#define A5256_CH0_DUAL 2
699
700
701#define ADAPTER_NONE 0x0000
702#define ADAPTER_A5255 0x0000
703#define ADAPTER_A5256 0x0002
704#define ADAPTER_A5256_REV0_POS 0x0100
705#define ADAPTER_A5256_REV0_NEG 0x0101
706
707
708#define NC -1 // DNIN=?
709
710#define A5256_DAC_LSB ((float)2500/4095)
711#define A5256_mV_to_DAC(mV) (uint32_t)round((1250 - (mV)) / A5256_DAC_LSB)
712#define A5256_DAC_to_mV(lsb) (1250 - (float)((lsb) * A5256_DAC_LSB))
714
715#ifdef __cplusplus
716extern "C" {
717#endif
718 // *****************************************************************
719 // External Variables (defined in FERlib.c)
720 // *****************************************************************
724 extern uint16_t PedestalLG[FERSLIB_MAX_NBRD][FERSLIB_MAX_NCH_5202];
725 extern uint16_t PedestalHG[FERSLIB_MAX_NBRD][FERSLIB_MAX_NCH_5202];
726 extern uint16_t CommonPedestal;
727 extern int EnablePedCal;
728 extern uint32_t TDL_NumNodes[FERSLIB_MAX_NCNC][FERSLIB_MAX_NTDL];
729
730 //extern uint8_t EnableRawData; //!< Flag to enable Low Level data saving
731 extern uint8_t ProcessRawData;
732 //extern uint8_t EnableMaxSizeFile; //!< Flag to enable the maximum size eforcement for Raw Data file saving
733 extern uint8_t EnableSubRun;
734 //extern float MaxSizeRawDataFile; //!< Maximum size for saving low-level data
735 extern char RawDataFilename[FERSLIB_MAX_NBRD][500];
736 extern char RawDataFilenameTdl[FERSLIB_MAX_NBRD][500];
737 extern int FERS_Offline;
738
739 extern int FERS_RunningCnt;
740 extern int FERS_ReadoutStatus;
741 extern int FERS_TotalAllocatedMem;
742 extern uint32_t DebugLogs;
743
744 //extern mutex_t FERS_mutex; //!< Mutex for access to shared resources (FERScfg, InitBuffers ...)
748
749 // *****************************************************************
750 // Funtion Prototypes
751 // *****************************************************************
756
757 CAEN_FERS_DLLAPI int ConfigureProbe(int handle);
758
759 // -----------------------------------------------------------------
760 // Get FERSlib info
761 // -----------------------------------------------------------------
771 CAEN_FERS_DLLAPI char* FERS_GetLibReleaseNum();
772
778 CAEN_FERS_DLLAPI char* FERS_GetLibReleaseDate();
779
780 // -----------------------------------------------------------------
781 // Messaging and errors
782 // -----------------------------------------------------------------
783
788
796 CAEN_FERS_DLLAPI int FERS_LibMsg(char* fmt, ...);
797
804 CAEN_FERS_DLLAPI int FERS_GetLastError(char description[1024]);
805
806 // Not exported
807 void _setLastLocalError(const char* description, ...);
808
809 // -----------------------------------------------------------------
810 // Raw Data Save and Load
811 // -----------------------------------------------------------------
812 // DNIN: Is it better to have an API to enable both RawData and LimitFileSize
813 // and then do the open directly inside the StartAcquisition?
814
815 //CAEN_FERS_DLLAPI int FERS_EnableRawdataWriteFile(uint8_t RawDataEnable, char* DataOutputPath, int RunNumber);
816
817 //CAEN_FERS_DLLAPI int FERS_EnableLimitRawdataFileSize(uint8_t LimitSizeEnable, float MaxSizeRawOutputFile);
818
819 //CAEN_FERS_DLLAPI int FERS_SetRawdataReadFile(char DataRawFilePath[500], int brd);
820
825
834 CAEN_FERS_DLLAPI int FERS_OpenRawDataFile(int* handle, int RunNum, int NumBrd);
835
843 CAEN_FERS_DLLAPI int FERS_CloseRawDataFile(int* handle, int NumBrd);
844
851 CAEN_FERS_DLLAPI float FERS_GetClockPeriod(int handle);
852 //CAEN_FERS_DLLAPI int FERS_SetPedestalOffline(uint16_t PedLG[FERSLIB_MAX_NCH_5202], uint16_t PedHG[FERSLIB_MAX_NCH_5202], int handle);
853
854 // -----------------------------------------------------------------
855 // Open/Close
856 // -----------------------------------------------------------------
861
869 CAEN_FERS_DLLAPI int FERS_OpenDevice(char* path, int* handle);
870
877 CAEN_FERS_DLLAPI int FERS_IsOpen(char* path);
878
886 CAEN_FERS_DLLAPI int FERS_IsOpenByHandle(int handle, char* path);
887
894 CAEN_FERS_DLLAPI int FERS_CloseDevice(int handle);
895
901 CAEN_FERS_DLLAPI int FERS_TotalAllocatedMemory();
902
909 CAEN_FERS_DLLAPI int FERS_Reset_IPaddress(int handle);
910
918 CAEN_FERS_DLLAPI int FERS_Get_CncPath(char* dev_path, char* cnc_path);
919
927 CAEN_FERS_DLLAPI int FERS_InitTDLchains(int handle, float DelayAdjust[FERSLIB_MAX_NTDL][FERSLIB_MAX_NNODES]);
928
935 CAEN_FERS_DLLAPI bool FERS_TDLchainsInitialized(int handle);
936
937 //CAEN_FERS_DLLAPI int FERS_SetOffline(int offline);
938 //CAEN_FERS_DLLAPI int FERS_SetBoardInfo(FERS_BoardInfo_t* BrdInfo, int b);
939 //CAEN_FERS_DLLAPI int FERS_SetConcentratorInfo(int handle, FERS_CncInfo_t* cinfo);
940
947 CAEN_FERS_DLLAPI uint16_t FERS_GetNumBrdConnected();
948
949
950 // -----------------------------------------------------------------
951 // Register Read/Write
952 // -----------------------------------------------------------------
957
967 CAEN_FERS_DLLAPI int FERS_ReadRegister(int handle, uint32_t address, uint32_t* data);
968
978 CAEN_FERS_DLLAPI int FERS_WriteRegister(int handle, uint32_t address, uint32_t data);
979
991 CAEN_FERS_DLLAPI int FERS_WriteRegisterSlice(int handle, uint32_t address, uint32_t start_bit, uint32_t stop_bit, uint32_t data);
992
1001 CAEN_FERS_DLLAPI int FERS_SendCommand(int handle, uint32_t cmd);
1002
1012 CAEN_FERS_DLLAPI int FERS_SendCommandBroadcast(int* handle, uint32_t cmd, uint32_t delay);
1013
1024 CAEN_FERS_DLLAPI int FERS_I2C_ReadRegister(int handle, uint32_t i2c_dev_addr, uint32_t reg_addr, uint32_t* reg_data);
1025
1036 CAEN_FERS_DLLAPI int FERS_I2C_WriteRegister(int handle, uint32_t i2c_dev_addr, uint32_t reg_addr, uint32_t reg_data);
1037
1050 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);
1051 //CAEN_FERS_DLLAPI int FERS_ReadBoardInfo(int handle, FERS_BoardInfo_t* binfo);
1052
1053 // -----------------------------------------------------------------
1054 // Flash Read/Write
1055 // -----------------------------------------------------------------
1066 CAEN_FERS_DLLAPI int FERS_ReadFlashPage(int handle, int pagenum, int size, uint8_t* data);
1067
1079 CAEN_FERS_DLLAPI int FERS_WriteFlashPage(int handle, int pagenum, int size, uint8_t* data);
1080
1081
1082 // -----------------------------------------------------------------
1083 // XROC Register Read/Write
1084 // -----------------------------------------------------------------
1095 CAEN_FERS_DLLAPI int FERS_XROC_WriteRegister(int handle, int page_addr, int sub_addr, uint8_t data);
1096
1107 CAEN_FERS_DLLAPI int FERS_XROC_ReadRegister(int handle, int page_addr, int sub_addr, uint8_t* data);
1108
1121 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);
1122
1123
1132 CAEN_FERS_DLLAPI int FERS_ReadConcentratorInfo(int handle, FERS_CncInfo_t* cinfo);
1133
1143 CAEN_FERS_DLLAPI int FERS_WriteBoardInfo(int handle, FERS_BoardInfo_t binfo);
1144
1149
1161 CAEN_FERS_DLLAPI int FERS_WritePedestals(int handle, uint16_t* PedLG, uint16_t* PedHG, uint16_t* dco);
1162
1175 CAEN_FERS_DLLAPI int FERS_ReadPedestalsFromFlash(int handle, char* date, uint16_t* PedLG, uint16_t* PedHG, uint16_t* dco);
1176
1185 CAEN_FERS_DLLAPI int FERS_PedestalBackupPage(int handle, int EnBckPage);
1186
1196 CAEN_FERS_DLLAPI int FERS_SetCommonPedestal(int handle, uint16_t Pedestal);
1197
1206 CAEN_FERS_DLLAPI int FERS_EnablePedestalCalibration(int handle, int enable);
1207
1208 int FERS_GetChannelPedestalBeforeCalib(int handle, int ch, uint16_t* PedLG, uint16_t* PedHG);
1209
1210 CAEN_FERS_DLLAPI int FERS_SetEnergyBitsRange(uint16_t EnergyRange);
1211 //CAEN_FERS_DLLAPI int FERS_Model(int handle); // ((FERS_INDEX(handle) >= 0) ? FERS_BoardInfo[FERS_INDEX(handle)]->Model : 0)
1212
1213
1218
1226 CAEN_FERS_DLLAPI int FERS_GetBoardInfo(int handle, FERS_BoardInfo_t* BrdInfo);
1227
1235 CAEN_FERS_DLLAPI int FERS_GetCncInfo(int handle, FERS_CncInfo_t* BrdInfo);
1236
1244 CAEN_FERS_DLLAPI uint32_t FERS_pid(int handle); // ((FERS_INDEX(handle) >= 0) ? FERS_BoardInfo[FERS_INDEX(handle)]->pid : 0)
1245
1253 CAEN_FERS_DLLAPI uint16_t FERS_Code(int handle); // ((FERS_INDEX(handle) >= 0) ? FERS_BoardInfo[FERS_INDEX(handle)]->FERSCode : 0)
1254
1262 CAEN_FERS_DLLAPI char* FERS_ModelName(int handle); // ((FERS_INDEX(handle) >= 0) ? FERS_BoardInfo[FERS_INDEX(handle)]->ModelName : "")
1263
1271 CAEN_FERS_DLLAPI uint32_t FERS_FPGA_FWrev(int handle); // ((FERS_INDEX(handle) >= 0) ? FERS_BoardInfo[FERS_INDEX(handle)]->FPGA_FWrev : 0)
1272
1280 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)
1281
1289 CAEN_FERS_DLLAPI uint32_t FERS_FPGA_FW_MinorRev(int handle);// ((FERS_INDEX(handle) >= 0) ? (FERS_BoardInfo[FERS_INDEX(handle)]->FPGA_FWrev) & 0xFF : 0)
1290
1298 CAEN_FERS_DLLAPI uint32_t FERS_uC_FWrev(int handle); // ((FERS_INDEX(handle) >= 0) ? FERS_BoardInfo[FERS_INDEX(handle)]->uC_FWrev : 0)
1299
1307 CAEN_FERS_DLLAPI uint16_t FERS_NumChannels(int handle); // ((FERS_INDEX(handle) >= 0) ? FERS_BoardInfo[FERS_INDEX(handle)]->NumCh : 0)
1308
1316 CAEN_FERS_DLLAPI uint8_t FERS_PCB_Rev(int handle); // ((FERS_INDEX(handle) >= 0) ? FERS_BoardInfo[FERS_INDEX(handle)]->PCBrevision : 0)
1317
1325 CAEN_FERS_DLLAPI bool FERS_IsXROC(int handle);
1326
1327 // DNIN: Ideally, these 2 should be intern function. The user should only set the DebugLogMask
1335 CAEN_FERS_DLLAPI int FERS_DumpBoardRegister(int handle);
1336
1344 CAEN_FERS_DLLAPI int FERS_DumpCfgSaved(int handle);
1345
1346
1351
1360 CAEN_FERS_DLLAPI int FERS_Get_TDC0_Temp(int handle, float* temp);
1361
1370 CAEN_FERS_DLLAPI int FERS_Get_TDC1_Temp(int handle, float* temp);
1371
1380 CAEN_FERS_DLLAPI int FERS_Get_FPGA_Temp(int handle, float* temp);
1381
1382
1391 CAEN_FERS_DLLAPI int FERS_Get_Board_Temp(int handle, float* temp);
1392
1393
1394
1395
1396 // -----------------------------------------------------------------
1397 // High Voltage Control
1398 // -----------------------------------------------------------------
1399
1404
1412 CAEN_FERS_DLLAPI int FERS_HV_Init(int handle);
1413
1424 CAEN_FERS_DLLAPI int FERS_HV_WriteReg(int handle, uint32_t reg_addr, uint32_t dtype, uint32_t reg_data);
1425
1436 CAEN_FERS_DLLAPI int FERS_HV_ReadReg(int handle, uint32_t reg_addr, uint32_t dtype, uint32_t* reg_data);
1437
1446 CAEN_FERS_DLLAPI int FERS_HV_Set_OnOff(int handle, int OnOff);
1447
1459 CAEN_FERS_DLLAPI int FERS_HV_Get_Status(int handle, int* OnOff, int* Ramping, int* OvC, int* OvV);
1460
1469 CAEN_FERS_DLLAPI int FERS_HV_Get_FWVer(int handle, uint32_t* FWver);
1470
1479 CAEN_FERS_DLLAPI int FERS_HV_Get_SerNum(int handle, int* sernum);
1480
1489 CAEN_FERS_DLLAPI int FERS_HV_Set_Vbias(int handle, float vbias);
1490
1499 CAEN_FERS_DLLAPI int FERS_HV_Get_Vbias(int handle, float* vbias);
1500
1509 CAEN_FERS_DLLAPI int FERS_HV_Get_Vmon(int handle, float* vmon);
1510
1519 CAEN_FERS_DLLAPI int FERS_HV_Set_Imax(int handle, float imax);
1520
1529 CAEN_FERS_DLLAPI int FERS_HV_Get_Imax(int handle, float* imax);
1530
1539 CAEN_FERS_DLLAPI int FERS_HV_Get_Imon(int handle, float* imon);
1540
1549 CAEN_FERS_DLLAPI int FERS_HV_Get_IntTemp(int handle, float* temp);
1550
1559 CAEN_FERS_DLLAPI int FERS_HV_Get_DetectorTemp(int handle, float* temp);
1560
1569 CAEN_FERS_DLLAPI int FERS_HV_Set_Tsens_Coeff(int handle, float Tsens_coeff[3]);
1570
1580 CAEN_FERS_DLLAPI int FERS_HV_Set_TempFeedback(int handle, int enable, float Tsens_coeff);
1581
1582
1583 // -----------------------------------------------------------------
1584 // TDC Config and readout (for test)
1585 // -----------------------------------------------------------------
1586 CAEN_FERS_DLLAPI int FERS_TDC_WriteReg(int handle, int tdc_id, uint32_t addr, uint32_t data);
1587 CAEN_FERS_DLLAPI int FERS_TDC_ReadReg(int handle, int tdc_id, uint32_t addr, uint32_t* data);
1588 CAEN_FERS_DLLAPI int FERS_TDC_Config(int handle, int tdc_id, int StartSrc, int StopSrc);
1589 CAEN_FERS_DLLAPI int FERS_TDC_DoStartStopMeasurement(int handle, int tdc_id, double* tof_ns);
1590
1591
1592 // -----------------------------------------------------------------
1593 // Set/Get param, parse file and configure FERS
1594 // -----------------------------------------------------------------
1595
1600
1609 CAEN_FERS_DLLAPI int FERS_configure(int handle, int mode);
1610
1618 CAEN_FERS_DLLAPI int FERS_LoadConfigFile(char* filepath);
1619
1630 CAEN_FERS_DLLAPI int FERS_SetParam(int handle, const char* param_name, const char* value_original);
1631
1642 CAEN_FERS_DLLAPI int FERS_GetParam(int handle, const char* param_name, char* value);
1643
1644
1645 // -----------------------------------------------------------------
1646 // Data Readout
1647 // -----------------------------------------------------------------
1648
1653
1663 CAEN_FERS_DLLAPI int FERS_InitReadout(int handle, int ROmode, int* AllocatedSize);
1664
1672 CAEN_FERS_DLLAPI int FERS_CloseReadout(int handle);
1673
1681 CAEN_FERS_DLLAPI int FERS_FlushData(int handle);
1682
1691 CAEN_FERS_DLLAPI int FERS_GetCrcErrorCnt(int cnc_handle, uint32_t* errcnt);
1692
1704 CAEN_FERS_DLLAPI int FERS_StartAcquisition(int* handle, int NumBrd, int StartMode, int RunNum);
1705
1719 CAEN_FERS_DLLAPI int FERS_StopAcquisition(int* handle, int NumBrd, int StartMode, int RunNum);
1720
1733 CAEN_FERS_DLLAPI int FERS_GetEvent(int* handle, int* bindex, int* DataQualifier, double* tstamp_us, void** Event, int* nb);
1734
1746 CAEN_FERS_DLLAPI int FERS_GetEventFromBoard(int handle, int* DataQualifier, double* tstamp_us, void** Event, int* nb);
1747
1748
1749 // -----------------------------------------------------------------
1750 // Firmware Upgrade
1751 // -----------------------------------------------------------------
1752
1757
1767 CAEN_FERS_DLLAPI int FERS_FirmwareUpgrade(int handle, char filen[200], void(*ptr)(char* msg, int progress));
1768
1776 CAEN_FERS_DLLAPI int FERS_FirmwareBootApplication_ethusb(int handle);
1777
1785 CAEN_FERS_DLLAPI int FERS_FirmwareBootApplication_tdl(int* handle);
1786
1797 int FERS_CheckBootloaderVersion(int handle, int* isInBootloader, uint32_t* version, uint32_t* release);
1798
1799 // -----------------------------------------------------------------
1800 // EEPROM 5256
1801 // -----------------------------------------------------------------
1802
1807
1812
1821 CAEN_FERS_DLLAPI int FERS_ReadA5256EEPROMInfo(int handle, FERS_A5256_Info_t* binfo);
1822
1831 CAEN_FERS_DLLAPI int FERS_WriteA5256EEPROMInfo(int handle, FERS_A5256_Info_t binfo);
1832
1843 int FERS_ReadEEPROMBlock(int handle, int start_address, int size, uint8_t* data);
1844
1855 int FERS_WriteEEPROMBlock(int handle, int start_address, int size, uint8_t* data);
1856
1865 CAEN_FERS_DLLAPI int FERS_checkA5256presence(int handle, FERS_A5256_Info_t* tinfo);
1866
1871
1872
1873
1883 CAEN_FERS_DLLAPI int FERS_ChIndex_ada2tdc(int Adapter_ch, int* TDC_ch, int brd);
1884
1894 CAEN_FERS_DLLAPI int FERS_ChIndex_tdc2ada(int TDC_ch, int* Adapter_ch, int brd);
1895
1896
1901
1909 CAEN_FERS_DLLAPI int FERS_FindMemThrDest(int handle);
1910
1922 CAEN_FERS_DLLAPI int FERS_ReadThrCalib(int handle, int npts, int MemThrDest, char* date, float* ThrOffset);
1923
1931 CAEN_FERS_DLLAPI int FERS_AdapterNch(int brd);
1932
1940 int FERS_DisableThrCalib(int handle);
1941
1952 int FERS_Set_DiscrThreshold(int handle, int Adapter_ch, float thr_mv, int brd);
1953
1964 int FERS_ChMask_ada2tdc(uint32_t AdapterMask, uint32_t* ChMask0, uint32_t* ChMask1, int brd);
1965
1978 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));
1979
1991 CAEN_FERS_DLLAPI int FERS_WriteThrCalib(int handle, int npts, int MemThrDest, float* ThrOffset);
1992
1994 // * @ingroup calib
1995 // * @brief Read BIC from the EEPROM of the Adapter (if present)
1996 // * @param[in] handle Board handle
1997 // * @param[out] binfo Board info struct
1998 // * @return 0 in case of success, or a negative error code specified in #FERSLIB_ErrorCodes
1999 // */
2000 //CAEN_FERS_DLLAPI int FERS_ReadAdapterBIC(int handle, FERS_A5256_Info_t* binfo);
2001
2003 // * @ingroup calib
2004 // * @brief Write BIC into the EEPROM of the Adapter (if present)
2005 // * @param[in] handle Board handle
2006 // * @param[out] binfo Board info struct
2007 // * @return 0 in case of success, or a negative error code specified in #FERSLIB_ErrorCodes
2008 // */
2009 //CAEN_FERS_DLLAPI int FERS_WriteAdapterBIC(int handle, FERS_A5256_Info_t binfo);
2010
2011
2012#ifdef __cplusplus
2013 }
2014#endif
2015
2016#endif
2017
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)
#define MAX_LIST_SIZE
Definition FERSlib.h:319
#define MAX_TEST_NWORDS
Definition FERSlib.h:320
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_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:393
FERSLIB_ErrorCodes
Error codes.
Definition FERSlib.h:191
FERSLIB_EvtBuildingModes
Event Building modes.
Definition FERSlib.h:264
FERSLIB_ServEventsMode
Service event Modes.
Definition FERSlib.h:274
FERSLIB_RxThreadSatatus
Status of the data RX thread.
Definition FERSlib.h:168
FERSLIB_GlitchFilterModes
Glitch filter modes.
Definition FERSlib.h:381
FERSLIB_ReadoutStatus
Readout status.
Definition FERSlib.h:179
FERSLIB_StartMode
Start/Stop modes.
Definition FERSlib.h:345
@ HRCLK_FAN_OUT
Definition FERSlib.h:396
@ HRCLK_DISABLED
Definition FERSlib.h:394
@ HRCLK_DAISY_CHAIN
Definition FERSlib.h:395
@ FERSLIB_ERR_INVALID_FWFILE
Definition FERSlib.h:205
@ FERSLIB_ERR_INVALID_PARAM_UNIT
Definition FERSlib.h:220
@ FERSLIB_ERR_PEDCALIB_NOT_FOUND
Definition FERSlib.h:204
@ FERSLIB_ERR_INVALID_PATH
Definition FERSlib.h:197
@ FERSLIB_ERR_I2C_NACK
Definition FERSlib.h:216
@ FERSLIB_ERR_MAX_NBOARD_REACHED
Definition FERSlib.h:195
@ FERSLIB_ERR_INVALID_PARAM_VALUE
Definition FERSlib.h:219
@ FERSLIB_ERR_INVALID_CLK_SETTING
Definition FERSlib.h:213
@ FERSLIB_ERR_INVALID_FW
Definition FERSlib.h:218
@ FERSLIB_ERR_READOUT_NOT_INIT
Definition FERSlib.h:202
@ FERSLIB_ERR_INVALID_PARAM
Definition FERSlib.h:207
@ FERSLIB_ERR_CALIB_FAIL
Definition FERSlib.h:217
@ FERSLIB_ERR_QUEUE_OVERRUN
Definition FERSlib.h:210
@ FERSLIB_ERR_TDL_ERROR
Definition FERSlib.h:209
@ FERSLIB_SUCCESS
Definition FERSlib.h:192
@ FERSLIB_ERR_UPGRADE_ERROR
Definition FERSlib.h:206
@ FERSLIB_ERR_COMMUNICATION
Definition FERSlib.h:194
@ FERSLIB_ERR_TDL_CHAIN_DOWN
Definition FERSlib.h:215
@ FERSLIB_ERR_OPER_NOT_ALLOWED
Definition FERSlib.h:212
@ FERSLIB_ERR_MALLOC_BUFFERS
Definition FERSlib.h:200
@ FERSLIB_ERR_READOUT_ERROR
Definition FERSlib.h:199
@ FERSLIB_ERR_TDL_CHAIN_BROKEN
Definition FERSlib.h:214
@ FERSLIB_ERR_START_STOP_ERROR
Definition FERSlib.h:211
@ FERSLIB_ERR_GENERIC
Definition FERSlib.h:193
@ FERSLIB_ERR_NOT_APPLICABLE
Definition FERSlib.h:208
@ FERSLIB_ERR_INVALID_BIC
Definition FERSlib.h:201
@ FERSLIB_ERR_DEVICE_ALREADY_OPENED
Definition FERSlib.h:196
@ FERSLIB_ERR_CALIB_NOT_FOUND
Definition FERSlib.h:203
@ FERSLIB_ERR_INVALID_HANDLE
Definition FERSlib.h:198
@ ROMODE_DISABLE_SORTING
Definition FERSlib.h:265
@ ROMODE_TRGTIME_SORTING
Definition FERSlib.h:266
@ ROMODE_TRGID_SORTING
Definition FERSlib.h:267
@ SE_HV
Definition FERSlib.h:275
@ SE_ALL
Definition FERSlib.h:277
@ SE_COUNT
Definition FERSlib.h:276
@ RXSTATUS_IDLE
Definition FERSlib.h:170
@ RXSTATUS_EMPTYING
Definition FERSlib.h:172
@ RXSTATUS_OFF
Definition FERSlib.h:169
@ RXSTATUS_RUNNING
Definition FERSlib.h:171
@ GLITCHFILTERMODE_BOTH
Definition FERSlib.h:385
@ GLITCHFILTERMODE_LEADING
Definition FERSlib.h:384
@ GLITCHFILTERMODE_TRAILING
Definition FERSlib.h:383
@ GLITCHFILTERMODE_DISABLED
Definition FERSlib.h:382
@ ROSTATUS_RUNNING
Definition FERSlib.h:181
@ RAWDATA_REPROCESS_FINISHED
Definition FERSlib.h:184
@ ROSTATUS_FLUSHING
Definition FERSlib.h:183
@ ROSTATUS_EMPTYING
Definition FERSlib.h:182
@ ROSTATUS_IDLE
Definition FERSlib.h:180
@ STARTRUN_ASYNC
Definition FERSlib.h:346
@ STARTRUN_TDL
Definition FERSlib.h:349
@ STARTRUN_CHAIN_T1
Definition FERSlib.h:348
@ STARTRUN_CHAIN_T0
Definition FERSlib.h:347
#define FERSLIB_MAX_NTDL
Definition FERSlib.h:141
#define FERSLIB_MAX_NNODES
Definition FERSlib.h:142
#define FERSLIB_MAX_NBRD
Definition FERSlib.h:135
#define FERSLIB_MAX_NCNC
Definition FERSlib.h:134
#define FERSLIB_MAX_NCH_5202
Definition FERSlib.h:137
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.
int FERS_OpenRawDataFile(int *handle, int RunNum, int NumBrd)
Open raw data file, to be done before starting the run.
int FERS_CloseRawDataFile(int *handle, int NumBrd)
Close raw data file after run stops.
float FERS_GetClockPeriod(int handle)
Get the clock of the FERS board.
int FERS_OpenDevice(char *path, int *handle)
Open a device (either FERS board, concentrator or offline)
int FERS_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_IsOpenByHandle(int handle, char *path)
Check if a device is already opened, with handle.
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_Get_FWVer(int handle, uint32_t *FWver)
Get the Firmware Version of the high voltage module.
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_GetParam(int handle, const char *param_name, char *value)
Get the value of a parameter. The function reads the value from the relevant parameter in the FERScfg...
int FERS_LoadConfigFile(char *filepath)
Loads a configuration file.
int FERS_SetParam(int handle, const char *param_name, const char *value_original)
Set a parameter by name. The function assigns the value to the relevant parameter in the FERScfg stru...
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 *tinfo)
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:507
uint64_t EventCount
Definition FERSlib.h:511
uint16_t BoardCount
Definition FERSlib.h:509
Concentrator board information structure.
Definition FERSlib.h:524
char MACaddr_10GbE[20]
MAC address of 10 GbE.
Definition FERSlib.h:531
char ModelName[16]
Model name, e.g. DT5215.
Definition FERSlib.h:528
char FPGA_FWrev[20]
FPGA FW revision.
Definition FERSlib.h:529
FERS_TDL_ChainInfo_t ChainInfo[8]
TDL Chain info.
Definition FERSlib.h:533
char ModelCode[16]
Model code, e.g. WDT5215XAAAA.
Definition FERSlib.h:527
char SW_rev[20]
Software Revision (embedded ARM)
Definition FERSlib.h:530
char PCBrevision[16]
PCB revision.
Definition FERSlib.h:526
uint16_t NumLink
Number of links.
Definition FERSlib.h:532
uint32_t pid
Board PID (5 decimal digits)
Definition FERSlib.h:525
FERS board information structure.
Definition FERSlib.h:543
uint16_t NumCh
Number of channels.
Definition FERSlib.h:550
char ModelName[16]
Model name, e.g. A5202.
Definition FERSlib.h:548
uint16_t FERSCode
FERS code, e.g. 5202.
Definition FERSlib.h:545
uint32_t FPGA_FWrev
FPGA FW revision.
Definition FERSlib.h:551
uint8_t PCBrevision
PCB revision.
Definition FERSlib.h:546
char ModelCode[16]
Model code, e.g. WA5202XAAAAA.
Definition FERSlib.h:547
uint32_t uC_FWrev
Microcontroller (uC) FW revision.
Definition FERSlib.h:552
uint32_t pid
Board PID (5 decimal digits)
Definition FERSlib.h:544
uint8_t FormFactor
Form factor (0=naked version (A52XX), 1=boxed version (DT52XX)
Definition FERSlib.h:549
A5256 adapter information structure.
Definition FERSlib.h:562
uint16_t NumCh
Number of channels.
Definition FERSlib.h:568
char ModelName[16]
Model name, e.g. A5256.
Definition FERSlib.h:567
uint16_t AdapterCode
Adapter code, e.g. 5256.
Definition FERSlib.h:564
uint8_t PCBrevision
PCB revision.
Definition FERSlib.h:565
char ModelCode[16]
Model code, e.g. WA5256XAAAAA.
Definition FERSlib.h:566
uint32_t pid
Adapter PID (5 decimal digits)
Definition FERSlib.h:563
Spectroscopy Event data structure (with or without timing)
Definition FERSlib.h:579
double rel_tstamp_us
Relative timestamp in us, reset by Tref.
Definition FERSlib.h:581
uint64_t Tref_tstamp
Timestamp of reference time signal (5202 only)
Definition FERSlib.h:583
double tstamp_us
Timestamp in us.
Definition FERSlib.h:580
uint16_t energyLG[64]
Low-gain energy values per channel.
Definition FERSlib.h:588
uint64_t qdmask
QD Mask.
Definition FERSlib.h:586
uint16_t energyHG[64]
High-gain energy values per channel.
Definition FERSlib.h:587
uint16_t ToT[64]
ToT values (used in TSPEC mode only) per channel.
Definition FERSlib.h:590
uint64_t chmask
Channel Mask.
Definition FERSlib.h:585
uint64_t trigger_id
Trigger ID.
Definition FERSlib.h:584
uint32_t tstamp[64]
ToAs (used in TSPEC mode only) per channel.
Definition FERSlib.h:589
uint64_t tstamp_clk
Timestamp in LSB.
Definition FERSlib.h:582
Counting Event data structure.
Definition FERSlib.h:598
double rel_tstamp_us
Relative timestamp in us, reset by Tref.
Definition FERSlib.h:600
uint32_t q_or_counts
Q-OR counts.
Definition FERSlib.h:605
double tstamp_us
Timestamp in us.
Definition FERSlib.h:599
uint64_t chmask
Channel Mask from zero suppression.
Definition FERSlib.h:602
uint64_t trigger_id
Trigger ID.
Definition FERSlib.h:601
uint32_t t_or_counts
T-OR counts.
Definition FERSlib.h:604
uint32_t counts[64]
Counts per channel.
Definition FERSlib.h:603
Waveform Event data structure.
Definition FERSlib.h:613
uint8_t * dig_probes
Digital probes samples.
Definition FERSlib.h:619
double tstamp_us
Timestamp in us.
Definition FERSlib.h:614
uint16_t ns
Definition FERSlib.h:616
uint16_t * wave_hg
High-gain waveform samples.
Definition FERSlib.h:617
uint16_t * wave_lg
Low-gain waveform samples.
Definition FERSlib.h:618
uint64_t trigger_id
Trigger ID.
Definition FERSlib.h:615
List Event data structure for timing mode.
Definition FERSlib.h:626
uint32_t header1[8]
PicoTDC header 1.
Definition FERSlib.h:632
uint16_t nhits
Number of hits.
Definition FERSlib.h:631
uint64_t Tref_tstamp
Timestamp of reference time signal (5202 only)
Definition FERSlib.h:628
double tstamp_us
Timestamp in microseconds.
Definition FERSlib.h:627
uint32_t header2[8]
PicoTDC header 2.
Definition FERSlib.h:633
uint32_t trailer[8]
PicoTDC trailer.
Definition FERSlib.h:635
uint32_t ToA[2048]
List of ToA in LSB (other board)
Definition FERSlib.h:639
uint32_t ow_trailer
PicoTDC one-word trailer.
Definition FERSlib.h:634
uint16_t ToT[2048]
List of ToT in LSB.
Definition FERSlib.h:640
uint8_t channel[2048]
List of channels.
Definition FERSlib.h:636
uint8_t edge[2048]
List of associated edges.
Definition FERSlib.h:637
uint64_t trigger_id
Trigger ID.
Definition FERSlib.h:630
uint64_t tstamp_clk
Timestamp in LSB (5203 only)
Definition FERSlib.h:629
uint32_t tstamp[2048]
List of ToA in LSB (5202 only)
Definition FERSlib.h:638
Service Event data structure, common to all FERS module.
Definition FERSlib.h:647
uint32_t ReadoutFlags
Readout Flags from picoTDC and FPGA.
Definition FERSlib.h:670
float tempTDC[2]
Temperature of TDC0 and TDC1.
Definition FERSlib.h:658
uint32_t ch_trg_cnt[64]
Definition FERSlib.h:653
uint32_t SupprTrg_cnt
Zero suppressed triggers counter.
Definition FERSlib.h:673
uint8_t hv_status_ovv
HV over-voltage status.
Definition FERSlib.h:665
uint8_t hv_status_on
HV status ON/OFF.
Definition FERSlib.h:663
float hv_Vmon
HV voltage monitor.
Definition FERSlib.h:661
double tstamp_us
Time stamp of service event.
Definition FERSlib.h:648
uint32_t t_or_cnt
T-OR counts value.
Definition FERSlib.h:655
uint32_t q_or_cnt
Q-OR counts value.
Definition FERSlib.h:654
float tempHV
High-voltage module temperature.
Definition FERSlib.h:659
float tempDetector
Detector temperature (referred to ?)
Definition FERSlib.h:660
uint8_t format
Event Format.
Definition FERSlib.h:652
uint16_t TDCROStatus
TDC Readout Status Register.
Definition FERSlib.h:668
uint64_t update_time
Update time (epoch, ms)
Definition FERSlib.h:649
uint8_t version
Service event version.
Definition FERSlib.h:651
float hv_Imon
HV current monitor.
Definition FERSlib.h:662
float tempFPGA
FPGA core temperature.
Definition FERSlib.h:656
uint32_t TotTrg_cnt
Total triggers counter.
Definition FERSlib.h:671
uint32_t RejTrg_cnt
Rejected triggers counter.
Definition FERSlib.h:672
uint16_t Status
Status Register.
Definition FERSlib.h:667
uint8_t hv_status_ovc
HV over-current status.
Definition FERSlib.h:666
uint8_t hv_status_ramp
HV ramp status.
Definition FERSlib.h:664
uint64_t ChAlmFullFlags[2]
Channel Almost Full flag (from picoTDC)
Definition FERSlib.h:669
uint16_t pkt_size
Event size.
Definition FERSlib.h:650
float tempBoard
Board temperature (near uC PIC)
Definition FERSlib.h:657
Test Mode Event data structure.
Definition FERSlib.h:682
uint32_t test_data[4]
Test data words.
Definition FERSlib.h:686
double tstamp_us
Timestamp in us.
Definition FERSlib.h:683
uint16_t nwords
Number of words.
Definition FERSlib.h:685
uint64_t trigger_id
Trigger ID.
Definition FERSlib.h:684