--- /dev/null
+static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwtof.c,v 1.1 1999-09-02 08:36:41 hades Exp $";
+
+#define _POSIX_C_SOURCE 199309L
+#include <unistd.h>
+
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/time.h>
+
+#include "param.h"
+#include "subevt.h"
+#include "hwv775.h"
+
+struct HardwareS {
+ size_t maxSubEvtSize;
+ void *specific;
+};
+
+#include "hardware.h"
+
+size_t Hardware_maxSubEvtSize(const Hardware *my)
+{
+ return my->maxSubEvtSize;
+}
+
+int Hardware_inSpill(const Hardware *my)
+{
+ return 0;
+}
+
+Hardware *newHardware(void)
+{
+ Hardware *my;
+ Param paramS, *param = ¶mS;
+ HwV775 *v775;
+ int i;
+
+ if (0 > conParam(param, "param.tcl")) {
+ msglog(LOG_DEBUG, "%s:%d:%s\n", __FILE__, __LINE__, strerror(errno));
+ return NULL;
+ }
+ my = allocMem(sizeof(Hardware));
+ my->specific = allocMem(sizeof(v775));
+
+ my->maxSubEvtSize = SubEvt_hdrSize() + (2564 * sizeof(UInt4));
+
+ v775 = allocMem(sizeof(HwV775));
+ if (0 > conHwV775(v775, "tdc0", param)) {
+ msglog(LOG_DEBUG, "%s:%d:%s\n", __FILE__, __LINE__, strerror(errno));
+ return NULL;
+ }
+ my->specific = (void *) v775;
+
+
+ desParam(param);
+ return my;
+}
+
+void deleteHardware(Hardware *my)
+{
+ HwV775 *v775 = (HwV775 *) my->specific;
+
+ desHwV775(v775);
+ freeMem(v775);
+
+ freeMem(my);
+}
+
+void Hardware_waitForTrigger(const Hardware *my, void *subEvt)
+{
+ HwV775 *v775 = (HwV775 *) my->specific;
+
+ if (HwV775_isEmpty(v775)) {
+ HwV775_requestBuffer(v775);
+ while (HwV775_isBusy(v775)) {
+#if 1
+ struct timespec tS, *t = &tS;
+ t->tv_sec = 0;
+ t->tv_nsec = 020000000;
+ nanosleep(t, NULL);
+#endif
+ }
+ }
+}
+
+void Hardware_readout(const Hardware *my, void *subEvt)
+{
+ HwV775 *v775 = (HwV775 *) my->specific;
+
+ HwV775_readSubEvt(v775, subEvt);
+}
--- /dev/null
+static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwv775.c,v 1.1 1999-09-02 08:36:41 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 "hwv775.h"
+
+int conHwV775(HwV775 * 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, 0x04, 4)) {
+ msglog(LOG_DEBUG, "%s:%d:%s\n", __FILE__, __LINE__, strerror(errno));
+ return -1;
+ }
+ LVme_setW(my->lvme, V775_BIT_SET_1, 0x0080);
+ LVme_setW(my->lvme, V775_BIT_CLR_1, 0x0080);
+ LVme_setW(my->lvme, V775_BIT_SET_2, 0x0004);
+ LVme_setW(my->lvme, V775_BIT_CLR_2, 0x0004);
+ LVme_setW(my->lvme, V775_CTRL_REG_2, 0x0002);
+ LVme_setW(my->lvme, V775_CRATE_REG, 0x0000);
+ LVme_setW(my->lvme, V775_RANGE_SET, Param_getVal(param, my->name, "range"));
+ LVme_setW(my->lvme, V775_VSET, Param_getVal(param, my->name, "vset"));
+ LVme_setW(my->lvme, V775_VOFF, Param_getVal(param, my->name, "voff"));
+ for (i = 0; i < V775_NCHANNELS; i++) {
+ char buf[16];
+
+ sprintf(buf, "threshold%02d", i);
+ LVme_setW(my->lvme,
+ V775_THRESH + 2 * i, Param_getVal(param, my->name, buf));
+ }
+ return 0;
+}
+
+void desHwV775(HwV775 * my)
+{
+ desLVme(my->lvme);
+ freeMem(my->lvme);
+}
+
+void HwV775_requestBuffer(HwV775 * my)
+{
+}
+
+int HwV775_isBusy(HwV775 * my)
+{
+ return 0;
+}
+
+int HwV775_isEmpty(HwV775 * my)
+{
+ return LVme_tstBitW(my->lvme, V775_STAT_REG_1, 0) == 0;
+}
+
+int HwV775_readSubEvt(HwV775 * my, void *subEvt)
+{
+ UInt4 *data = subEvt;
+ UInt4 hdr;
+ UInt4 eob;
+ int nWords;
+ UInt1 trigTag;
+
+ msglog(LOG_DEBUG, "V775 Readout\n");
+ *data++ = hdr = LVme_getL(my->lvme, V775_OUT_BUF);
+ if ((hdr & 0x07000000) != 0x02000000) {
+ msglog(LOG_EMERG, "V775 First word not header: 0x%08x\n", hdr);
+ } else {
+ msglog(LOG_DEBUG, "V775 First word is header: 0x%08x\n", hdr);
+ }
+
+ nWords = hdr >> 8 & 0xff;
+ while (--nWords >= 0) {
+ *data++ = LVme_getL(my->lvme, V775_OUT_BUF);
+ }
+ *data++ = eob = LVme_getL(my->lvme, V775_OUT_BUF);
+ if ((eob & 0x07000000) != 0x04000000) {
+ msglog(LOG_EMERG, "V775 Last word not eob: 0x%08x\n", eob);
+ } else {
+ msglog(LOG_DEBUG, "V775 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;
+}
--- /dev/null
+#ifndef HwV775_H
+#define HwV775_H
+
+#include <lvme.h>
+#include "rc.h"
+
+#include "param.h"
+
+#define V775_NCHANNELS 32
+
+typedef struct HwV775S {
+ char name[16];
+ LVme *lvme;
+ unsigned long trigNr;
+} HwV775;
+
+#define V775_OUT_BUF 0x00
+#define V775_BIT_SET_1 0x06
+#define V775_BIT_CLR_1 0x08
+#define V775_STAT_REG_1 0x0e
+#define V775_CTRL_REG_1 0x10
+#define V775_CTRL_REG_2 0x20
+#define V775_STAT_REG_2 0x22
+#define V775_RANGE_SET 0x2e
+#define V775_BIT_SET_2 0x32
+#define V775_BIT_CLR_2 0x34
+#define V775_CRATE_REG 0x3c
+#define V775_VSET 0x60
+#define V775_VOFF 0x62
+#define V775_THRESH 0x80
+
+
+int conHwV775(HwV775 *my, const char *name, const Param *param);
+void desHwV775(HwV775 *my);
+
+void HwV775_requestBuffer(HwV775 *my);
+int HwV775_isBusy(HwV775 *my);
+int HwV775_isEmpty(HwV775 *my);
+int HwV775_readSubEvt(HwV775 *my, void *subEvt);
+
+#endif