sis3820.c

Go to the documentation of this file.
00001 /*********************************************************************
00002 
00003   Name:         sis3820.c
00004   Created by:   K.Olchanski
00005 
00006   Contents:     SIS3820 32-channel 32-bit multiscaler
00007                 
00008   $Log$
00009   Revision 1.1  2006/05/25 05:53:42  alpha
00010   First commit
00011 
00012 *********************************************************************/
00013 #include <stdio.h>
00014 #include <stdint.h>
00015 #include <string.h>
00016 #include "sis3820drv.h"
00017 #include "sis3820.h"
00018 #include "mvmestd.h"
00019 
00020 /*****************************************************************/
00021 /*
00022 Read sis3820 register value
00023 */
00024 static uint32_t regRead(MVME_INTERFACE *mvme, DWORD base, int offset)
00025 {
00026   mvme_set_am(mvme, MVME_AM_A32);
00027   mvme_set_dmode(mvme, MVME_DMODE_D32);
00028   return mvme_read_value(mvme, base + offset);
00029 }
00030 
00031 /*****************************************************************/
00032 /*
00033 Write sis3820 register value
00034 */
00035 static void regWrite(MVME_INTERFACE *mvme, DWORD base, int offset, uint32_t value)
00036 {
00037   mvme_set_am(mvme, MVME_AM_A32);
00038   mvme_set_dmode(mvme, MVME_DMODE_D32);
00039   mvme_write_value(mvme, base + offset, value);
00040 }
00041 
00042 uint32_t sis3820_RegisterRead(MVME_INTERFACE *mvme, DWORD base, int offset)
00043 {
00044   return regRead(mvme,base,offset);
00045 }
00046 
00047 void     sis3820_RegisterWrite(MVME_INTERFACE *mvme, DWORD base, int offset, uint32_t value)
00048 {
00049   regWrite(mvme,base,offset,value);
00050 }
00051 
00052 /*
00053 Read nentry of data from the data buffer. Will use the DMA engine
00054 if size is larger then 127 bytes. 
00055 */
00056 int sis3820_FifoRead(MVME_INTERFACE *mvme, DWORD base, void *pdest, int wcount)
00057 {
00058   int rd;
00059   int save_am;
00060 
00061   mvme_get_am(mvme,&save_am);
00062   mvme_set_blt(  mvme, MVME_BLT_MBLT64);
00063   mvme_set_am(   mvme, MVME_AM_A32_D64);
00064 
00065   rd = mvme_read(mvme, pdest, base + 0x800000, wcount*4);
00066   //printf("fifo read wcount: %d, rd: %d\n",wcount,rd);
00067 
00068   mvme_set_am(mvme, save_am);
00069 
00070   return wcount;
00071 }
00072 
00073 /*****************************************************************/
00074 void sis3820_Reset(MVME_INTERFACE *mvme, DWORD base)
00075 {
00076   regWrite(mvme,base,SIS3820_KEY_RESET,0);
00077 }
00078 
00079 /*****************************************************************/
00080 int  sis3820_DataReady(MVME_INTERFACE *mvme, DWORD base)
00081 {
00082   return regRead(mvme,base,SIS3820_FIFO_WORDCOUNTER);
00083 }
00084 
00085 /*****************************************************************/
00086 void  sis3820_Status(MVME_INTERFACE *mvme, DWORD base)
00087 {
00088   printf("SIS3820 at A32 0x%x\n", (int)base);
00089   printf("CSR: 0x%x\n", regRead(mvme,base,SIS3820_CONTROL_STATUS));
00090   printf("ModuleID and Firmware: 0x%x\n", regRead(mvme,base,SIS3820_MODID));
00091   printf("Operation mode: 0x%x\n", regRead(mvme,base,SIS3820_OPERATION_MODE));
00092 }
00093 
00094 //end

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