/* This header file gives you a simple set of the macros for convenient work with PPI-2. It was optimized for simplicity, not for speed, but will work good for most applications. Written by Anton V. Magleli, 1996 */ /* PPI registers */ const int STAT = 0x250; const int ADDR = 0x252; const int DATA = 0x254; const int PIPE = 0x256; #define set_F(f) ( outport(ADDR, 0x2000), outport(PIPE, f) ) /* this is equivalent to unsigned NAF_rd( unsigned c, n, a, f ) */ #define NAF_rd(c, n, a, f) \ ( set_F(f), \ outport(ADDR, 0x3000 | (c & 1)<<9 | (n & 0x1F)<<4 | (a & 0x0F) ), \ outport(PIPE, 0), inport(DATA) ) /* this is equivalent to void NAF_rd( unsigned c, n, a, f, data ) */ #define NAF_wr(c, n, a, f, data) \ ( set_F(f), \ outport(ADDR, 0x2000 | (c & 1)<<9 | (n & 0x1F)<<4 | (a & 0x0F) ), \ outport(PIPE, data) ) /* this macro gives TRUE when Q==1 in the last CAMAC cycle. You use it like this: if( CamacQ ) { ... } */ #define CamacQ ((inport(STAT) & 0x400) == 0) /* this macro generates a Z cycle. Usage: CamacZ; */ #define CamacZ (outport(ADDR, 0x31FF), outport(PIPE, 0), delay(1))