#ifndef _SA02_DEF_H
#define _SA02_DEF_H
#define FEB_SINGLE
#ifdef CAEN_V1495
// read data access
# define FEB_DATA_RDY 0x10c4
# define FEB_DATA_RST 0x101c
//# define FEB_TPENB 0x1020
// setup trigger SW or HW
# define FEB_SEUTRG 0x1028
# define FEB_SWTRG 0x1020
# ifdef FEB_SINGLE
# define FEB_DATA_START 0x1030
# define FEB_DATA_STOP 0x10c0
# else /* FEB_SINGLE */
# define FEB_DATA_START 0x1100
# define FEB_DATA_STOP 0x1340
# endif /* FEB_SINGLE */
# define FEB_DATA_INC 0x0004
# define FEB_BLTDATA_START 0x0030
# define FEB_BLTDATA_STOP 0x00c0
# define FEB_SREG 0x10c0
# ifdef FEB_SINGLE
# define FEB_SREG0 FEB_SREG
# define FEB_SREG1 FEB_SREG
# define FEB_SREG2 FEB_SREG
# define FEB_SREG3 FEB_SREG
# else /* FEB_SINGLE */ // parallel readout
# define FEB_SREG0 0x10d4
# define FEB_SREG1 0x10d8
# define FEB_SREG2 0x10dc
# define FEB_SREG3 0x10e0
# endif /* FEB_SINGLE */
// write accesss
# define FEB_REGH 0x1010
# define FEB_REGL 0x1014
# define FEB_EXEC 0x1018
#endif /* CAEN_V1495 */
#ifdef BELLEPTS
# define FEB_BLTDATA_START FEB_DATA_START
# define FEB_BLTDATA_STOP FEB_DATA_STOP
// data access
#define FEB_DATA 0x0100
#define FEB_DATA_INC 0x0100
#define FEB_CHADDR 0x0104
#define FEB_CNTR 0x0108
// write accesss
#define FEB_DATAOUT0 0x010C
#define FEB_DATAOUT1 0x0110
// read access
#define FEB_DATAIN0 0x0114
#define FEB_DATAIN1 0x0118
#define FEB_DATA_RST 0x0500
#define FEB_DATA_RDY 0x0504
#define FEB_DAQMODE 0x0508
#define FEB_SWTRG 0x050C // sw trigger
#define FEB_SELTRG 0x0510 // disable bits: 0-hw,1-sw
#define FEB_SETNEVE 0x0514
#define FEB_GETNEVE 0x0518
#define FEB_DEBUGMON 0x051C
#define FEB_SEUTRG 0x0520 // seu sw trigger
#define FEB_DEADBEEF 0x0FFC // register with a value 0xdeadbeef
#endif /* BELLEPTS */
// SA02 commands
#define FEB_INIT 0x00000000
#define FEB_CREG 0x01000000
#define FEB_SHFT_CLK 0x01000000
#define FEB_SEND_CLK 0x02000000
#define FEB_SEL_MON 0x03000000
#define FEB_MUX 0x03000000
#define FEB_SEL_DATA 0x04000000
#define FEB_TP 0x05000000
#define FEB_DLY0 0x06000000
#define FEB_SERIAL 0x08000000
#define FEB_DPM 0x09000000
#define FEB_VTH2 0x090000B0
#define FEB_VTH1 0x090000B1
#define FEB_TPLVL0 0x090100B0
#define FEB_TPLVL1 0x090100B1
#define DPM_WRITE 0x00B00000
#define DPM_CH1 0x00010000
#define FEB_SUBA_INC 0x00010000
#define FEB_RO 0x80000000
#define SA0x_ASIC0_CREG 0x0A000000
#define SA0x_ASIC0_GREG 0x0B000000
#define SA0x_ASIC0_CMON 0x0C000000
#define FEB_TMON0 0x0D000000
#define FEB_TMON1 0x0D010000
#define FEB_ADC_READ 0x0E000000
#define FEB_ADC_RESET 0x0E010000
#define ASIC_PHASECMPS 0x0000003
#define ASIC_GAIN 0x000000c
#define ASIC_SHAPINGTIME 0x0000030
#define ASIC_COMPARATOR 0x0000040
#define ASIC_VRDRIVE 0x0007F80
#define ASIC_MONITOR 0x0018000
#define ASIC_ID 0x3FE0000
#define ASIC_DECAYTIME 0x000007
#define ASIC_OFFSET 0x000078
#define ASIC_FINEADJ_UNIPOL 0x000780
#define ASIC_FINEADJ_DIFF 0x007800
#define ASIC_TPENDB 0x010000
#define ASIC_KILL 0x100000
#define ASIC_PHASECMPS_SHFT 0
#define ASIC_GAIN_SHFT 2
#define ASIC_SHAPINGTIME_SHFT 4
#define ASIC_COMPARATOR_SHFT 6
#define ASIC_VRDRIVE_SHFT 7
#define ASIC_MONITOR_SHFT 15
#define ASIC_ID_SHFT 17
#define ASIC_DECAYTIME_SHFT 0
#define ASIC_OFFSET_SHFT 3
#define ASIC_FINEADJ_UNIPOL_SHFT 7
#define ASIC_FINEADJ_DIFF_SHFT 11
#define ASIC_TPENDB_SHFT 16
#define ASIC_KILL_SHFT 17
#endif /* _SA02_DEF_H */