/************************************************ * a200.h * * * * Definitions used with the CAEN A200 Interface * * * *************************************************/ #define A200_BASE 0x00e00000 /* base address of CAEN 127 Controller */ /* VME CYCLES ADDRESSES */ #define RESET 0x28 #define SEL_TARG 0x18 #define SEL_TARG_VAL 0x1a #define WRITE_DATA 0x1c #define WRITE_DATA_VAL 0x1e #define START_RD 0x18 #define START_RD_VAL 0x1a #define READ_VAL 0x3c /* SELECT_TARGET Parameters */ /* 0-39 : individual channels */ #define GAG_ALL 50 /* GAG = Global Absolute Group */ #define ALL GAG_ALL #define GAG_A 51 #define GAG_B 52 #define GAG_C 53 #define GAG_D 54 #define GAG_E 55 #define GAG_F 56 #define GAG_G 57 #define GRG_ALL 60 /* GRG = Global Relative Group */ #define GRG_A 61 #define GRG_B 62 #define GRG_C 63 #define GRG_D 64 #define GRG_E 65 #define GRG_F 66 #define GRG_G 67 #define PROT_WORD 70 /* Protection Bit */ /* Read/Write Parameters */ #define V0 0 #define V1 1 #define I0 2 #define I1 3 #define RAMP_UP 4 #define RAMP_DOWN 5 #define TRIP 6 #define STATUS_BIT 7 #define STATUS STATUS_BIT #define SWITCH STATUS_BIT #define CH_TO_GR_ASS 8 #define GROUP_ASS CH_TO_GR_ASS #define GROUP CH_TO_GR_ASS #define VMON 9 #define IMON 10 #define PHASE 11 #define TIME 12 #define CHAN_TYPE 13 #define TYPE CHAN_TYPE /* number 14 is invalid ! */ #define ALL_PAR 15 #define DUMMY 0 #define READOUT 0xff00 /* bits 8-15 for START_READOUT cycle */ #define ON 1 #define OFF 0 #define ONOFF 2 #define EN 1 #define DIS 0 #define MAXDATA 43 #define IS_OFF & 0x01 /* allows tests of kinds "if(test_word IS_OFF )" */ #define IS_TRIP & 0x02 /* ... etc */ #define IS_ON & 0x04 #define IS_OVERV & 0x08 #define IS_UNDERV & 0x10 #define IS_OVERC & 0x20 #define IS_RAMPU & 0x40 #define IS_RAMPD & 0x80 #define POWER_ON & 0x01 #define PASSW_EN & 0x02 #define KEYBOARD_EN & 0x04 #define V1_ACTIVE & 0x10 #define I1_ACTIVE & 0x20 #define ALARM & 0x48 #define HV_ENABLE & 0x80 /* Channel_to_Group bits : */ #define GROUP_ALL 0x01 #define GROUP_A 0x02 #define GROUP_B 0x04 #define GROUP_C 0x08 #define GROUP_D 0x10 #define GROUP_E 0x20 #define GROUP_F 0x40 #define GROUP_G 0x80 #define T300 0x8000004d /* 300 milliseconds , for tsleep */ #define BIT32 0x80000000 /* bit 32 ON " " */ #define CONDITIONING 0x40000000 /* bit 31 ON " " */ #define SITTERING BIT32 /* bit 32 ON " " */ #define IS_CONDITIONING & CONDITIONING #define IS_SITTERING & SITTERING #define COND_CODE 23011925 #define TIMOUT 100000 /* maximum number of attempts to give a command */ #define READ_MAX_TRY 100 /* maximum trys to read a value ( with a sleep between each one ... */ #define WAIT_SOME_MS BIT32 + 10 /* ... controlled by this parameter */ /*********************************************************** * * Distributore SY227 * ***********************************************************/ /* write parameters */ #define D_SLOT_SEL 0 #define D_Z_I_SET 2 /* zero current set */ #define D_IMAX 3 #define D_ONOFF 5 #define D_PULSE_TEST 6 #define D_ZERO 0x0001 /* data used for the zero current set */ /* Select target parameters */ #define D_COM_SLOT ALL #define D_ALL ALL #define D_SYS_PROT PROT_WORD /* readout parameters */ #define D_VMON 1 #define D_IMON 2 /* D_IMAX is already defined in the Write param. */ #define D_HV_IN_STATUS 4 /* D_ONOFF is already defined in the Write param. */ /* D_PULSE_TEST is already defined in the Write param. */ #define D_STATUS 7 #define D_NCHAN 8 #define D_IRESOL 9 #define D_ISCALE 10 #define D_VRESOL 11 #define D_VMAX 12 #define D_HVPOL 13 #define D_ALL_PAR ALL_PAR #define D_RELAY_IS_ON & 0x01 #define D_SWITCH_IS_ON & 0x02 #define D_IS_OVC & 0x02 /* overcurrent */ #define D_IS_OFS & 0x04 /* over full scale */ #define D_IS_OMV & 0x08 /* over Max Voltage */ #define D_IS_OK == 0x101 /* only bit 0 and 8 ON */ #define D_NO_HV == 0x00 #define D_POS_HV == 0x01 #define D_NEG_HV == 0x02 struct par127{ short v0; short v1; short i0; short i1; short ramp_up; short ramp_down; short trip; short status; short ch_to_gr_ass; short vmon; short imon; short phase; short time; short type; }; typedef struct par127 PAR127; struct sy127{ short prot_word; short v0[40]; short v1[40]; short i0[40]; short i1[40]; short ramp_up[40]; short ramp_down[40]; short trip[40]; short status[40]; short ch_to_gr_ass[40]; short vmon[40]; short imon[40]; short phase[40]; short time[40]; short type[40]; }; typedef struct sy127 SY127; struct sy127_mbox{ struct modhcom _mh; /* Standard module header */ SY127 hv_par[2]; /* hv parameters defined in a200.h */ int creat_tim[6]; /* date of module creation */ int pset_tim[6]; /* date of last parameter update */ /* yy, mm, dd, hh, min, sec */ int pchk_tim[6]; /* date of last parameter check */ int vim_tim[6]; /* date of last Vmon, Imon update */ int sta_tim[6]; /* date of last Status check */ int sit_tim[6]; /* date of last tubi_sitter check */ int nchk; int nchk_err; int nvim; int nvim_err; int nsta; int nsta_err; }; typedef struct sy127_mbox SY127_MBOX; struct sy227sl{ short imax_set[32]; /* setted value */ short imax[32]; /* readout value */ short vmon[32]; short imon[32]; short status[32]; short hvin; short onoff_set; short onoff; short pulse_test_set; short pulse_test; short i_resol_value; char i_resol_unit[2]; short i_full_scale; short v_resol_value; char v_resol_unit[2]; short vmax; short hv_in_pol; }; typedef struct sy227sl SY227SL; struct sy227_mbox{ struct modhcom _mh; /* Standard module header */ SY227SL sl_par[10][4]; /* 1.st index: crate; 2.nd index: slot */ int creat_tim[6]; /* date of module creation */ int pset_tim[6]; /* date of last parameter update */ /* yy, mm, dd, hh, min, sec */ int pchk_tim[6]; /* date of last parameter check */ int vim_tim[6]; /* date of last Vmon, Imon update */ int sta_tim[6]; /* date of last Status check */ int nchk; int nchk_err; int nvim; int nvim_err; int nsta; int nsta_err; }; typedef struct sy227_mbox SY227_MBOX; struct procs_info{ struct modhcom _mh; /* Standard module header */ int creat_date[6]; /* date of module creation */ /* yy, mm, dd, hh, min, sec */ unsigned sy127_par_mon_id; /* ID of process sy127_par_mon */ int sy127_par_mon_date[6]; /* date of process fork */ int sy127_par_mon_tcycle; /* process waiting time */ int sy127_par_mon_active; /* process active/sleep (1/0) */ int sy127_par_mon_com; /* used as mail_box prom steering processes */ unsigned sy127_vi_mon_id; int sy127_vi_mon_date[6]; int sy127_vi_mon_tcycle; int sy127_vi_mon_active; int sy127_vi_mon_com; unsigned sy127_st_mon_id; int sy127_st_mon_date[6]; int sy127_st_mon_tcycle; int sy127_st_mon_active; int sy127_st_mon_com; unsigned sy127_vi_send_id; int sy127_vi_send_date[6]; int sy127_vi_send_tcycle; int sy127_vi_send_active; int sy127_vi_send_com; unsigned sy227_par_mon_id; int sy227_par_mon_date[6]; int sy227_par_mon_tcycle; int sy227_par_mon_active; int sy227_par_mon_com; unsigned sy227_vi_mon_id; int sy227_vi_mon_date[6]; int sy227_vi_mon_tcycle; int sy227_vi_mon_active; int sy227_vi_mon_com; unsigned sy227_st_mon_id; int sy227_st_mon_date[6]; int sy227_st_mon_tcycle; int sy227_st_mon_active; int sy227_st_mon_com; unsigned sy227_vi_send_id; int sy227_vi_send_date[6]; int sy227_vi_send_tcycle; int sy227_vi_send_active; int sy227_vi_send_com; unsigned a200_resetter_id; int a200_resetter_date[6]; int a200_resetter_tcycle; int a200_resetter_active; int a200_resetter_com; unsigned xxcond_id; int xxcond_date[6]; int xxcond_active; int xxcond_com; }; typedef struct procs_info PROCS_INFO; static char *A200_event = "A200_CAEN"; static int ev_id; #define MAX_CRATES 4 /* maximum value of the HV crates address ( !! ) */ static short group_ch[MAX_CRATES][8][3] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } ;