lrs1151.c

Go to the documentation of this file.
00001 /*********************************************************************
00002   @file
00003   Name:         lrs1151.c
00004   Created by:   Pierre-Andre Amaudruz
00005   Content:      LeCroy 16 channel scalers
00006   $Id: lrs1151.c 4108 2008-01-08 20:49:41Z amaudruz $
00007 *********************************************************************/
00008 #include <stdio.h>
00009 #include <string.h>
00010 #if defined(OS_LINUX)
00011 #include <unistd.h>
00012 #endif
00013 #include "lrs1151.h"
00014 
00015 /*---------------------------------------------------------------*/
00016 void lrs1151_Read(MVME_INTERFACE *mvme, DWORD base, DWORD * data)
00017 {
00018   int   r, cmode;
00019 
00020   mvme_get_dmode(mvme, &cmode);
00021   mvme_set_dmode(mvme, MVME_DMODE_D32);
00022 
00023   for (r = 0; r < 16; r++) {
00024     *data++ = mvme_read_value(mvme, base + LRS1151_DATA_RO + r);
00025   }
00026   mvme_set_dmode(mvme, cmode);
00027   return;
00028 }
00029 
00030 /*---------------------------------------------------------------*/
00031 void lrs1151_Clear (MVME_INTERFACE *mvme, DWORD base)
00032 {
00033   int   r, cmode, status;
00034 
00035   mvme_get_dmode(mvme, &cmode);
00036   mvme_set_dmode(mvme, MVME_DMODE_D32);
00037 
00038   for (r = 0; r < 16; r++) {
00039     status = mvme_write_value(mvme, base+LRS1151_CLEAR_WO + r, 0x0);
00040   }
00041   mvme_set_dmode(mvme, cmode);
00042   return;
00043 }
00044 
00045 /*****************************************************************/
00046 /*-PAA- For test purpose only */
00047 #ifdef MAIN_ENABLE
00048 int main (int argc, char* argv[]) {
00049   DWORD data[20];
00050   int status, count = 16, i;
00051   DWORD LRS1151_BASE = 0xF00000;
00052   
00053   MVME_INTERFACE *myvme;
00054   
00055   if (argc>1) {
00056     sscanf(argv[1],"%lx",&LRS1151_BASE);
00057   }
00058   
00059   // Test under vmic
00060   status = mvme_open(&myvme, 0);
00061   
00062   // Set am to A24 non-privileged Data
00063   mvme_set_am(myvme, MVME_AM_A24_ND);
00064   
00065   // Set dmode to D32
00066   mvme_set_dmode(myvme, MVME_DMODE_D32);
00067   lrs1151_Clear(myvme, LRS1151_BASE);
00068   printf("\nClear Scalers \n");  
00069   
00070 #if 1
00071   lrs1151_Read(myvme, LRS1151_BASE, data);
00072   for (i=0;i<count;i++) {
00073     printf("Data[%i]=0x%lx\n", i, data[i]);
00074   }
00075 #endif
00076   
00077   status = mvme_close(myvme);
00078   
00079   return 0;
00080 }
00081 #endif
00082 
00083 /* emacs
00084  * Local Variables:
00085  * mode:C
00086  * mode:font-lock
00087  * tab-width: 8
00088  * c-basic-offset: 2
00089  * End:
00090  */

Midas DOC Version 2.0.2 ---- 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