00001 00002 #ifndef __WIENERCAMAC_H 00003 #define __WIENERCAMAC_H 00004 #include <daqdatatypes.h> 00005 /* 00006 The Wiener VC32 each control only one crate, so an array of pointers is 00007 required for multiple crate operation 00008 */ 00009 00010 extern void* (pBranchBases[]); 00011 #define CAMBAS(b) (pBranchBases[(b)]) 00012 00013 00014 /* New camac inlines when wiener vc32cc32 modules are used --ddc */ 00015 00016 /* 00017 HUH... better check what's going on here because getlong and putlong are 00018 also defined as macros in vme.h! Ah... ok. For __unix__ vme.h is 00019 not included. So camac.h is the only place this defined... --ddc 00020 */ 00021 00022 /* not loved... don't know why 00023 static inline UINT32 getlong(volatile void* a) { 00024 return (*((volatile UINT32*)a)); 00025 }; 00026 */ 00027 00028 00029 00030 00031 /* 00032 *CAM16 and CAM32 were previously used in computing CAMAC pointers... 00033 * but that will be done with type casting now (all addresses are for 00034 * 32bit words with Wiener, so 32bit words will be accessed with a type cast 00035 * after the address is computed) --ddc. 00036 */ 00037 00038 #define CAMF 2 /* Shift count to F field. */ 00039 #define CAMA 6 /* Shift count to A field */ 00040 #define CAMN 10 /* Shift count to N field */ 00041 #define CAM24 0 /* unused for wiener interface */ 00042 #define CAM16 0 /* Unused for wiener interface */ 00043 #define CAMB 0 /* Unused if wiener interface */ 00044 00045 /* 00046 * The macros are used to do accesses to the CAMAC at higher 00047 * speed than function calls might allow. 00048 */ 00049 00050 /* 00051 * CBDPTR 00052 * CBDPTR - Generate a CAMAC pointer for the VC32 cards. 00053 * - Arguments: c - crate, n - slot, 00054 * - a - subaddress, f - function 00055 * By compile time generation, we mean that this macro 00056 * can be used on the right hand side of #define directives 00057 * or variable initializers for example: 00058 * #define READDE1 CBDPTR(1, 1, 0, 0) 00059 * INT16 *readde1 = CBDPTR(1, 1, 0, 0); 00060 * produce a macro READDE1 which produces the same pointer that the 00061 * variable readde1 is initialized to point to. 00062 */ 00063 /* 00064 * NOTE! The version of CBDPTR varies significantly from the version 00065 * in camac.h used at MSU. There is NO branch(b) or size(s) parameters! 00066 * also note that only four bits are used for "f" (the 5th bit is implicit 00067 * in the operation). Also note that to match common usage, crates are 00068 * numbered starting with "1" (so the index is decremented). 00069 * --ddc. 00070 */ 00071 00072 /* Unhappiness with recasting a pointer in 24bit reads... replace this --ddc 00073 #define CBDPTR(c, n, a, f) \ 00074 ((volatile INT16 *)(((unsigned long)CAMBAS(c-1)) + \ 00075 ( (n) << CAMN ) | ( (a) << CAMA) | ( (f&0x0f) << CAMF ))) 00076 */ 00077 00078 #define CBDPTR(b, c, n, a, f, width) \ 00079 ((unsigned long)(((unsigned long)CAMBAS(c-1)) + \ 00080 ( (n) << CAMN ) | ( (a) << CAMA) | ( (f&0x0f) << CAMF ))) 00081 00082 /* 00083 * CAMCTL 00084 * Do a CAMAC control operation (non data transfer) The argument is 00085 * use in a statement by itself, e.g. CAMCTL(ADC1RST); 00086 */ 00087 00088 /* camctl for cc32 assumes writes (but no data transfer --ddc */ 00089 00090 #define CAMCTL(ptr) { if(*((volatile INT16 *)(ptr))=0){} } 00091 00092 /* 00093 * CAMRD16 00094 * Do a 16 bit read from CAMAC via a pointer cons4ructed with 00095 * CBDPTR. The macro returns a value (may be treated like a 00096 * function) which is the result of the read. 00097 * Sample usage: 00098 * result = (CAMRD16(DE1) * scale) / offset; 00099 */ 00100 00101 /* camrd16 is unchanged --ddc */ 00102 00103 #define CAMRD16(ptr) (*(volatile INT16 *)(ptr)) 00104 00105 /* 00106 * CAMRD24 00107 * Same as CAMRD16, but a 24 bit read is done... (pointer still for 16bit) 00108 * This operation will be quite a bit slower than CAMRD16 00109 */ 00110 00111 /*This is unchanged, BUT getlong is quite different. It recasts the 00112 pointer, which is ALWAYS for a 16 bit word. It is unclear to me if 00113 how much slower this is with vc32! Manual claims ~10% --ddc */ 00114 00115 /*#define CAMRD24(ptr) (getlong(ptr) & 0xffffff) */ 00116 /*replacing CAMRD24 with macro to eliminate inline getlong... --ddc */ 00117 00118 #define CAMRD24(ptr) ((*(INT32 *)(ptr))&0xffffff) 00119 #define CAMRD32(ptr) (*(INT32 *)(ptr)) 00120 00121 /* 00122 * CAMWR16 00123 * Does a 16 bit write CAMAC cycle. Use as a single statment e.g. 00124 * CAMWR16(ptr, value); 00125 * Arguments: 00126 * ptr - Pointer produced by CBDPTR. 00127 * value - Least significant 16 bits of this are written 00128 */ 00129 00130 /* this is unchanged --ddc */ 00131 #define CAMWR16(ptr, val) (*((volatile INT16 *)(ptr)) = (val)) 00132 00133 /* 00134 * CAMWR24 00135 * Just like CAMWR16, but the operation writes the lower 24 bits of 00136 * the data. The pointer argument must have been constructed with 00137 * size CAM24 00138 */ 00139 00140 #define CAMWR24(ptr, val) (putlong( ((val) & 0xFFFFFF), ((volatile INT32 *)ptr))) 00141 00142 /* 00143 * This is unchanged... although I don't understand why the ptr was recast 00144 * to the pointer for a long (INT32) pointer in the original camac.h 00145 * (since it is recast there to int16 * in putlong!) --ddc 00146 */ 00147 00148 /* The definitions below allows the library code to figure out which version 00149 of the headers the user has selected. 00150 */ 00151 00152 00153 00154 #include <wienermacros.h> /* Don't allow mis-match screwups */ 00155 00156 #endif