/* VME_trig.h include file defining some usefull macro and definition to use the VME trigger card 4 fevrier 1992 documented in RD13 note 23 8 fevrier 1992 last modification the memory needs an offset not a channel number Bill recognise a bug : no more need of TM_setAddress() no more need of the virtual address argument of TM_init() christophe rondot ECP, RD13 rondot@marcls.in2p3.fr rondot@vxcrna.cern.ch Modified: G. Fumagalli 17-Sep-93 */ #define TRIG_CSR1 0X00 /* status registers */ #define TRIG_CSR2 0X02 #define TRIG_CSR3 0X04 #define TRIG_CSR4 0X06 #define TRIG_CPT1 0X10 /* counter */ #define TRIG_CPT2 0X14 #define TRIG_CPT3 0X18 #define TRIG_CPT4 0X1C #define TRIG_TOU1 0X20 /* time out */ #define TRIG_TOU2 0X22 #define TRIG_TOU3 0X24 #define TRIG_TOU4 0X26 #define TRIG_BIM1 0X30 /* BIM */ #define TRIG_BIM2 0X40 #define OFST_CR1 0X01 /* control */ #define OFST_CR2 0X03 #define OFST_CR3 0X05 #define OFST_CR4 0X07 #define OFST_VR1 0X09 /* vector */ #define OFST_VR2 0X0B #define OFST_VR3 0X0D #define OFST_VR4 0X0F #define TRIG_TEST1 0X50 /* test (to generate) */ #define TRIG_TEST2 0X52 #define TRIG_TEST3 0X54 #define TRIG_TEST4 0X56 #define TRIG_CLEAR1 0X58 /* clear */ #define TRIG_CLEAR2 0X5A #define TRIG_CLEAR3 0X5C #define TRIG_CLEAR4 0X5E #define TRIG_RAM 0X60 /* RAM */ #define TRIG_AM 0x39 #define TRIG_LEN 0x100 #define TRIG_PHY_ADD 0xF75A00 static char *TRIG_ADD; #define TM_init RD13_VmeMap(TRIG_PHY_ADD,TRIG_AM,TRIG_LEN,&TRIG_ADD) #define TM_release {\ RD13_VmeUnmap(&TRIG_ADD);\ } /* read and write in the 12 bits csr */ #define TM_csrW(channel,value) {\ *(short *) (TRIG_ADD + TRIG_CSR/**/channel) = value; \ } #define TM_csrR(channel,value) {\ value = (*(short *) (TRIG_ADD + TRIG_CSR/**/channel))&0x0fff; \ } /* read and write in the time out word */ #define TM_toW(channel,value) {\ *(unsigned short *) (TRIG_ADD + TRIG_TOU/**/channel) = value; \ } #define TM_toR(channel,value) {\ value = *(unsigned short *) (TRIG_ADD + TRIG_TOU/**/channel); \ } /* read and write in the BIM1 control register we assume only the first BIM corresponding to the four channel */ #define TM_crW(channel,value) {\ *(char *) (TRIG_ADD + TRIG_BIM1 + OFST_CR/**/channel) = value; \ } #define TM_crR(channel,value) {\ value = *(char *) (TRIG_ADD + TRIG_BIM1 + OFST_CR/**/channel); \ } /* read and write in the BIM2 control register we assume only the first BIM corresponding to the four channel */ #define TM_cr1W(channel,value) {\ *(char *) (TRIG_ADD + TRIG_BIM2 + OFST_CR/**/channel) = value; \ } #define TM_cr1R(channel,value) {\ value = *(char *) (TRIG_ADD + TRIG_BIM2 + OFST_CR/**/channel); \ } /* read and write in the BIM1 vector register we assume only the first BIM corresponding to the four channel */ #define TM_vrW(channel,value) {\ *(char *) (TRIG_ADD + TRIG_BIM1 + OFST_VR/**/channel) = value; \ } #define TM_vrR(channel,value) {\ value = *(char *) (TRIG_ADD + TRIG_BIM1 + OFST_VR/**/channel); \ } /* read and write in the BIM2 vector register we assume only the first BIM corresponding to the four channel */ #define TM_vr1W(channel,value) {\ *(char *) (TRIG_ADD + TRIG_BIM2 + OFST_VR/**/channel) = value; \ } #define TM_vr1R(channel,value) {\ value = *(char *) (TRIG_ADD + TRIG_BIM2 + OFST_VR/**/channel); \ } /* one can only write in the test */ #define TM_test(channel) {\ *(short *) (TRIG_ADD + TRIG_TEST/**/channel) = 0xFF; \ } /* one can only write in the clear */ #define TM_clear(channel) {\ *(short *) (TRIG_ADD + TRIG_CLEAR/**/channel) = 0xFF; \ } /* read and write in the RAM word */ #define TM_ramW(offset,value) {\ *(short *) (TRIG_ADD + TRIG_RAM + offset) = value; \ } #define TM_ramR(offset,value) {\ value = *(short *) (TRIG_ADD + TRIG_RAM + offset); \ } /* a bit tricky to read and write in the counter (MSW LSW) 2 words per counter need 2 accesses */ #define TM_cptW(channel,value) {\ *(short *) (TRIG_ADD + TRIG_CPT/**/channel) = (value >> 16); \ *(short *) (TRIG_ADD + TRIG_CPT/**/channel + 2) = (value&0x0000ffff); \ } /* here we don't know if the value is unsigned so | rather than + */ #define TM_cptR(channel,value) {\ value = (*(short *) (TRIG_ADD + TRIG_CPT/**/channel)) << 16; \ value |= *(short *) (TRIG_ADD + TRIG_CPT/**/channel + 2); \ }