From 2dc6fe2bf58f41b9a997b603f969574af6e40e8a Mon Sep 17 00:00:00 2001 From: hades Date: Fri, 3 Sep 1999 07:35:06 +0000 Subject: [PATCH] Initial revision --- hadaq/hwdtu.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++ hadaq/hwdtu.h | 29 ++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 hadaq/hwdtu.c create mode 100644 hadaq/hwdtu.h diff --git a/hadaq/hwdtu.c b/hadaq/hwdtu.c new file mode 100644 index 0000000..fd7b079 --- /dev/null +++ b/hadaq/hwdtu.c @@ -0,0 +1,57 @@ +static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwdtu.c,v 1.1 1999-09-03 07:35:06 hades Exp $"; + +#define _POSIX_C_SOURCE 199309L +#include + +#include +#include +#include +#include + +#include +#include + + +#include "subevt.h" +#include "param.h" +#include "hwdtu.h" + +int conHwDtu(HwDtu *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, DTU_MAGIC, 1)) { + msglog(LOG_DEBUG, "%s:%d:%s\n", __FILE__, __LINE__, strerror(errno)); + return -1; + } + return 0; +} + +void desHwDtu(HwDtu *my) +{ + desLVme(my->lvme); + freeMem(my->lvme); +} + +int HwDTU_isEmpty(HwDtu *my) +{ + return LVme_tstBitB(my->lvme, DTU_FIFO_2, 0); +} + +int HwDTU_read(HwDtu *my, void *subEvt) +{ + my->trigTag = LVme_getB(my->lvme, DTU_TRIG_TAG); + my->trigCode = LVme_getB(my->lvme, DTU_TRIG_CODE) & 0x0f; + LVme_setB(my->lvme, DTU_FIFO_1, 0); + LVme_setB(my->lvme, DTU_FIFO_2, 0); + return 0; +} diff --git a/hadaq/hwdtu.h b/hadaq/hwdtu.h new file mode 100644 index 0000000..9f84be5 --- /dev/null +++ b/hadaq/hwdtu.h @@ -0,0 +1,29 @@ +#ifndef HwDTU_H +#define HwDTU_H + +#include +#include "rc.h" + +#include "param.h" + +typedef struct HwDtuS { + char name[16]; + LVme *lvme; + unsigned long trigNr; + UInt1 trigTag; + UInt1 trigCode; +} HwDtu; + +#define DTU_TRIG_CODE 0x18 +#define DTU_TRIG_TAG 0x1c +#define DTU_FIFO_1 0x20 +#define DTU_FIFO_2 0x24 +#define DTU_MAGIC 0x3c + +int conHwDtu(HwDtu *my, const char *name, const Param *param); +void desHwDtu(HwDtu *my); + +int HwDtu_isEmpty(HwDtu *my); +int HwDtu_read(HwDtu *my, void *subEvt); + +#endif -- 2.43.0