/*---------- Subroutines for CAMAC ----------------*/ /* PPI AT-2, K0607 */ #define ccstat 0x240 #define cccmd 0x242 #define ccdata 0x244 #define ccpipe 0x246 #define ccncr0 0x2000 /* Crate #0 address. */ #define ccncr1 0x2200 /* Crate #1 address. */ #define ccread 0x1000 /* Read bit. */ /* Execute C. */ void exctc (int crate) {int ncrt=(crate&1)?ccncr1:ccncr0; outport (cccmd, ncrt); outport (ccpipe, 0x100);} /* Execute Z. */ void exctz (int crate) {int ncrt=(crate&1)?ccncr1:ccncr0; outport (cccmd, ncrt); outport (ccpipe, 0x200);} /* Execute NAF (16 bit). naf16 (...) = q (0 or 1) if (f&030) != 0 (write or control); naf16 (...) = data from CAMAC) if (f&030) == 0 (read). */ int naf16 (int crate, int n, int a, int f, int data/* not for read */) {int ncrt=(crate&1)?ccncr1:ccncr0, naf=((n&037)<<4)|(a&017)|ncrt; int port; /**/ outport (cccmd, ncrt); outport (ccpipe, f&037); if ((f&030)) {/* Write or control */ outport (cccmd, naf); outport (ccpipe, data); port = inport (ccstat); return /* q */ (012000 & port ) ? 0:1;}; /* Read */ outport (cccmd, naf|010000); inport (ccpipe); port = inport (ccdata); return port; } /* Execute k times control NAF. nafrp (...) = q (0 or 1). */ int nafrp (int crate, int n, int a, int f, int k) {int ncrt=(crate&1)?ccncr1:ccncr0, naf=((n&037)<<4)|(a&017)|ncrt; int port; if (k<=0 || f&8==0) return 0; /**/ outport (cccmd, ncrt); outport (ccpipe, f&037); outport (cccmd, naf); for (port=0; port