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

diff --git a/hadaq/hwv878.c b/hadaq/hwv878.c
new file mode 100644 (file)
index 0000000..14e2885
--- /dev/null
@@ -0,0 +1,110 @@
+static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwv878.c,v 1.1 1999-09-02 09:24:30 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 "hwv878.h"
+
+int conHwV878(HwV878 * 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, 0x09, V878_GEO_ADDR, 4)) {
+               msglog(LOG_DEBUG, "%s:%d:%s\n", __FILE__, __LINE__, strerror(errno));
+               return -1;
+       }
+       LVme_setW(my->lvme, V878_BIT_SET_1, 0x0080);
+       LVme_setW(my->lvme, V878_BIT_CLR_1, 0x0080);
+       LVme_setW(my->lvme, V878_BIT_SET_2, 0x0004);
+       LVme_setW(my->lvme, V878_BIT_CLR_2, 0x0004);
+       LVme_setW(my->lvme, V878_BIT_SET_2, 0x8800);
+       LVme_setW(my->lvme, V878_CRATE_REG, 0x0000);
+       LVme_setW(my->lvme, V878_VSET, Param_getVal(param, my->name, "vset"));
+       LVme_setW(my->lvme, V878_VOFF, Param_getVal(param, my->name, "voff"));
+       for (i = 0; i < V878_NCHANNELS; i++) {
+               char buf[16];
+
+               sprintf(buf, "threshold%02d", i);
+               LVme_setW(my->lvme,
+                                 V878_THRESH + 2 * i, Param_getVal(param, my->name, buf));
+       }
+       return 0;
+}
+
+void desHwV878(HwV878 * my)
+{
+       desLVme(my->lvme);
+       freeMem(my->lvme);
+}
+
+void HwV878_requestBuffer(HwV878 * my)
+{
+}
+
+int HwV878_isBusy(HwV878 * my)
+{
+       return HwV878_isEmpty(my);
+}
+
+int HwV878_isEmpty(HwV878 * my)
+{
+       return LVme_tstBitW(my->lvme, V878_STAT_REG_1, 0) == 0;
+}
+
+int HwV878_readSubEvt(HwV878 * my, void *subEvt)
+{
+       UInt4 *data = subEvt;
+       UInt4 hdr;
+       UInt4 eob;
+       int nWords;
+       UInt1 trigTag;
+
+       msglog(LOG_DEBUG, "V878 Readout\n");
+       *data++ = hdr = LVme_getL(my->lvme, V878_OUT_BUF);
+       if ((hdr & 0x07000000) != 0x02000000) {
+               msglog(LOG_EMERG, "V878 First word not header: 0x%08x\n", hdr);
+       } else {
+               msglog(LOG_DEBUG, "V878 First word is header: 0x%08x\n", hdr);
+       }
+
+       nWords = hdr >> 8 & 0xff;
+       while (--nWords >= 0) {
+               *data++ = LVme_getL(my->lvme, V878_OUT_BUF);
+       }
+       *data++ = eob = LVme_getL(my->lvme, V878_OUT_BUF);
+       if ((eob & 0x07000000) != 0x04000000) {
+               msglog(LOG_EMERG, "V878 Last word not eob: 0x%08x\n", eob);
+       } else {
+               msglog(LOG_DEBUG, "V878 Last word is eob: 0x%08x\n", eob);
+       }
+
+       trigTag = eob & 0xff;
+
+       SubEvt_setSize(subEvt, (char *) data - (char *) subEvt);
+       SubEvt_setDecoding(subEvt, SubEvtDecoding_32bitData);
+       SubEvt_setId(subEvt, SubEvtId_tofTest);
+       SubEvt_setTrigNr(subEvt, my->trigNr << 24 | trigTag);
+       my->trigNr++;
+
+       return 0;
+}
diff --git a/hadaq/hwv878.h b/hadaq/hwv878.h
new file mode 100644 (file)
index 0000000..47d0ede
--- /dev/null
@@ -0,0 +1,39 @@
+#ifndef HwV878_H
+#define HwV878_H
+
+#include <lvme.h>
+#include "rc.h"
+
+#include "param.h"
+
+#define V878_NCHANNELS 32
+
+typedef struct HwV878S {
+  char name[16];
+  LVme *lvme;
+  unsigned long trigNr;
+} HwV878;
+
+#define V878_OUT_BUF 0x0000
+#define V878_GEO_ADDR 0x1002
+#define V878_BIT_SET_1 0x1006
+#define V878_BIT_CLR_1 0x1008
+#define V878_STAT_REG_1 0x100e
+#define V878_CTRL_REG_1 0x1010
+#define V878_BIT_SET_2 0x1032
+#define V878_BIT_CLR_2 0x1034
+#define V878_CRATE_REG 0x103c
+#define V878_VSET 0x1060
+#define V878_VOFF 0x1062
+#define V878_THRESH 0x1080
+
+
+int conHwV878(HwV878 *my, const char *name, const Param *param);
+void desHwV878(HwV878 *my);
+
+void HwV878_requestBuffer(HwV878 *my);
+int HwV878_isBusy(HwV878 *my);
+int HwV878_isEmpty(HwV878 *my);
+int HwV878_readSubEvt(HwV878 *my, void *subEvt);
+
+#endif