divers/lrs1151.c

Go to the documentation of this file.
00001 /*-----------------------------------------------------------------------------
00002  * Copyright (c) 1996      TRIUMF Data Acquistion Group
00003  * Please leave this header in any reproduction of that distribution
00004  *
00005  * TRIUMF Data Acquisition Group, 4004 Wesbrook Mall, Vancouver, B.C. V6T 2A3
00006  * Email: online@triumf.ca           Tel: (604) 222-1047  Fax: (604) 222-1074
00007  *         amaudruz@triumf.ca
00008  * ----------------------------------------------------------------------------
00009  *
00010  * Description  : VME function for the LRS1151 using Macros or INLINE
00011  *                No reference to Midas.
00012  *
00013  * Application : VME
00014  *
00015  * Author:  Pierre-Andre Amaudruz Data Acquisition Group
00016  *
00017   $Id: lrs1151.c 2753 2005-10-07 14:55:31Z ritt $
00018 
00019  * Revision 1.0  1996/ Pierre    Initial revision
00020  * Revision 1.1  1998/ Pierre    Split include for specific hardware.
00021  * ---------------------------------------------------------------------------- */
00022 #ifdef OS_VXWORKS
00023 #include "vxWorks.h"
00024 #include "vme.h"
00025 #endif
00026 
00027 #ifdef PPCxxx
00028 #define A32D24_1151            0xfa000000       /* A32D24_1151 access */
00029 #else
00030 #define A32D24_1151            0xf0000000       /* A32D24_1151 access */
00031 #endif
00032 
00033 #if defined( _MSC_VER )
00034 #define INLINE __inline
00035 #elif defined(__GNUC__)
00036 #define INLINE __inline__
00037 #else
00038 #define INLINE
00039 #endif
00040 
00041 #define EXTERNAL extern
00042 
00043 #ifndef MIDAS_TYPE_DEFINED
00044 #define MIDAS_TYPE_DEFINED
00045 
00046 typedef unsigned short int WORD;
00047 
00048 #ifdef __alpha
00049 typedef unsigned int DWORD;
00050 #else
00051 typedef unsigned long int DWORD;
00052 #endif
00053 
00054 #endif                          /* MIDAS_TYPE_DEFINED */
00055 
00056 /*-Macros--------------------------------------------------------*/
00057 #define LRS1151_READ(_vmebase,_d,_r){\
00058   {\
00059      volatile DWORD _ll, *_local, __r;\
00060         _ll = _vmebase;\
00061         _local = (DWORD *) (((_ll << 8) | 0x80) | A32D24_1151);\
00062         __r =_r;\
00063         if (__r > 16) __r = 16;\
00064         while (__r > 0) {\
00065                    *_d++ = *_local++;\
00066                    __r--;}\
00067         }\
00068   }
00069 
00070 #define LRS115_CLEAR(_vmebase){\
00071   {\
00072      volatile DWORD _ll, _dummy, *_local, __r=16;\
00073         _ll = _vmebase;\
00074         _local =(DWORD *)( ((_ll << 8) | 0x40) | A32D24_1151);\
00075         while (__r > 0) {\
00076                    _dummy = *_local;\
00077                    _local++;\
00078                    __r--;}\
00079         }\
00080   }
00081 
00082 /*-input---------------------------------------------------------*/
00083 INLINE void lrs1151_read(DWORD vmeBase, DWORD ** d, int r)
00084 {
00085    volatile DWORD *local;
00086 
00087    if (r > 16)
00088       r = 16;
00089    local = (DWORD *) (((vmeBase << 8) | 0x80) | A32D24_1151);
00090    while (r > 0) {
00091       *((*d)++) = *((DWORD *) local);
00092       local++;
00093       r--;
00094    }
00095 }
00096 
00097 /*-command-------------------------------------------------------*/
00098 INLINE void lrs1151_clear(DWORD vmeBase)
00099 {
00100    volatile DWORD *local, dummy, r;
00101 
00102    local = (DWORD *) (((vmeBase << 8) | 0x40) | A32D24_1151);
00103    for (r = 0; r < 16; r++) {
00104       dummy = *local++;
00105    }
00106 }
00107 
00108 void lrs1151(void)
00109 {
00110    printf("\n---> LeCroy 1151 16ch. NIM/ECL scalers <---\n");
00111    printf("Macro  : LRS1151_READ (DWORD base, DWORD *data, int repeat);\n");
00112    printf("Macro  : LRS1151_CLEAR (DWORD base);\n");
00113    printf("Inline : lrs1151_read  (DWORD base, DWORD *data, int repeat);\n");
00114    printf("Inline : lrs1151_clear (DWORD base);\n");
00115    printf("Test   : rd1151   (0x7a00)    <--- read    VME scaler\n");
00116    printf("Test   : clr1151  (0x7a00)    <--- clear   VME scaler\n");
00117 }
00118 
00119 void rd1151(DWORD vmeBase)
00120 {
00121    DWORD i, dd[16], *pdd;
00122    for (i = 0; i < 16; i++)
00123       dd[i] = 0;
00124    pdd = &dd[0];
00125    lrs1151_read(vmeBase, &pdd, 16);
00126    for (i = 0; i < 16; i++)
00127       printf("%i-> %8.8x\n", i, dd[i]);
00128 }
00129 
00130 void clr1151(DWORD vmeBase)
00131 {
00132    lrs1151_clear(vmeBase);
00133 }

Midas DOC Version 3.0.0 ---- PSI Stefan Ritt ----
Contributions: Pierre-Andre Amaudruz - Sergio Ballestrero - Suzannah Daviel - Doxygen - Peter Green - Qing Gu - Greg Hackman - Gertjan Hofman - Paul Knowles - Exaos Lee - Rudi Meier - Glenn Moloney - Dave Morris - John M O'Donnell - Konstantin Olchanski - Renee Poutissou - Tamsen Schurman - Andreas Suter - Jan M.Wouters - Piotr Adam Zolnierczuk