]> jspc29.x-matter.uni-frankfurt.de Git - daqdata.git/commitdiff
Initial revision
authorhades <hades>
Thu, 2 Sep 1999 11:20:09 +0000 (11:20 +0000)
committerhades <hades>
Thu, 2 Sep 1999 11:20:09 +0000 (11:20 +0000)
hadaq/hwv488.c [new file with mode: 0644]
hadaq/hwv488.h [new file with mode: 0644]

diff --git a/hadaq/hwv488.c b/hadaq/hwv488.c
new file mode 100644 (file)
index 0000000..349d373
--- /dev/null
@@ -0,0 +1,84 @@
+indent: Standard input: 93: Error:Stuff missing from end of file.
+static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwv488.c,v 1.1 1999-09-02 11:20:09 hades Exp $";
+
+#define _POSIX_C_SOURCE 199309L
+#include <unistd.h>
+
+#include <assert.h>
+#include <errno.h>
+#include <string.h>
+#include <stdio.h>
+
+#include <hadesstd.h>
+#include <lvme.h>
+
+
+#include "subevt.h"
+#include "param.h"
+#include "hwv488.h"
+
+int conHwV488(HwV488 * my, const char *name, const Param *param)
+{
+       unsigned long cardBase;
+       int i;
+
+       assert(my != NULL);
+
+       strcpy(my->name, name);
+       my->trigNr = 0;
+
+       cardBase = Param_getVal(param, my->name, "cardbase");
+       my->lvme = allocMem(sizeof(LVme));
+
+       if (0 > conLVme(my->lvme, cardBase, 0x10000, 0x39, V488_SERIAL, 2)) {
+               msglog(LOG_DEBUG, "%s:%d:%s\n", __FILE__, __LINE__, strerror(errno));
+               return -1;
+       }
+       LVme_setW(my->lvme, V488_RESET, 0);
+       LVme_setW(my->lvme, V488_FF_REG, 0);
+       LVme_setW(my->lvme, V488_CTRL_REG, Param_getVal(param, my->name, "ctrl"));
+       LVme_setW(my->lvme, V488_THRL, Param_getVal(param, my->name, "thrl"));
+       LVme_setW(my->lvme, V488_THRH, Param_getVal(param, my->name, "thrh"));
+       LVme_setW(my->lvme, V488_RANGE, Param_getVal(param, my->name, "range"));
+
+       return 0;
+}
+
+void desHwV488(HwV488 * my)
+{
+       desLVme(my->lvme);
+       freeMem(my->lvme);
+}
+
+int HwV488_read(HwV488 * my, void *subEvt)
+{
+       UInt2 *data = SubEvt_end(subEvt);
+       UInt2 *first = data;
+       UInt2 hdr;
+       int nWords;
+       UInt1 trigTag;
+
+       msglog(LOG_DEBUG, "V488 Readout\n");
+       *data++ = LVme_getW(my->lvme, V488_SERIAL);
+       if (!HwV488_isEmpty(my)) {
+               *data++ = hdr = LVme_getW(my->lvme, V488_OUT_BUF);
+               if ((hdr & 0x8000) != 0x8000) {
+                       msglog(LOG_EMERG, "V488 First word not header: 0x%04x\n", hdr);
+               } else {
+                       msglog(LOG_DEBUG, "V488 First word is header: 0x%04x\n", hdr);
+               }
+
+               trigTag = hdr & 0xff;
+               if (trigTag != (SubEvt_trigNr(subEvt) & 0xff)) {
+                       msglog(LOG_EMERG, "%s trigNr mismatch: 0x%08x != 0x%02x \n",
+                                  v488->name, SubEvt_trigNr(subEvt), trigTag);
+               }
+
+               nWords = (hdr >> 12 & 0x07) + 1;
+               while (--nWords >= 0) {
+                       *data++ = LVme_getW(my->lvme, V488_OUT_BUF);
+               }
+               SubEvt_setSize(subEvt, SubEvt_size(subEvt) + (char *) data - (char *) first);
+               return 0;
+       }
+}
diff --git a/hadaq/hwv488.h b/hadaq/hwv488.h
new file mode 100644 (file)
index 0000000..221096a
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef HwV488_H
+#define HwV488_H
+
+#include <lvme.h>
+#include "rc.h"
+
+#include "param.h"
+
+typedef struct HwV488S {
+  char name[16];
+  LVme *lvme;
+  unsigned long trigNr;
+} HwV488;
+
+#define V488_NCHANNELS 32
+
+#define V488_OUT_BUF 0x18
+#define V488_STAT_REG 0x1a
+#define V488_RANGE_SET 0x14
+#define V488_THRH 0x12
+#define V488_THRL 0x10
+#define V488_RESET 0x1c
+#define V488_SERIAL 0xfe
+#define V488_HF_REG 0x1e
+#define V488_FF_REG 0x16
+
+int conHwV488(HwV488 *my, const char *name, const Param *param);
+void desHwV488(HwV488 *my);
+
+int HwV488_isEmpty(HwV488 *my);
+int HwV488_readSubEvt(HwV488 *my, void *subEvt);
+
+#endif