-static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwtrig.c,v 6.23 2002-01-31 20:01:49 hadaq Exp $";
+static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwtrig.c,v 6.24 2002-04-07 17:06:46 hadaq Exp $";
+/* modified MU readout producing a dense pack of 16 Bit words. 15-March-2002, W. Koenig */
#define _POSIX_C_SOURCE 199309L
#include <unistd.h>
#endif
/* Number of TOF crates */
-#define NCRATES 3
+#define NCRATES 2
#define MU_EVT_COUNT 0x0e8014UL
#define MU_FIFO 0x0000UL
void Hardware_waitForTrigger(Hardware *my, void *partEvt)
{
+/*
+* check if MU is ready
+*/
+#ifndef NDEBUG
+ syslog(LOG_DEBUG, "check if MU is ready");
+#endif
+
+ /*
+ only read the Matching Unit Count register, when all pending
+ events are processed. This is recommended, because it is very
+ "expensive" to read from an Sharc Register in the Matching Unit.
+ */
+
+ if(my->evtCount == my->old_evtCount) {
+ while ((my->old_evtCount = LVme_getL(my->lvme0, MU_EVT_COUNT)) == my->evtCount) {
+ /* wait for some time for not disturbing the DSP */
+ struct timespec tS, *t = &tS;
+ t->tv_sec = 0;
+ t->tv_nsec = 20000000UL;
+ nanosleep(t, NULL);
+
+ }
+#ifndef NDEBUG
+ syslog(LOG_DEBUG, "evtCount: %d, oldEvtCount: %d", my->evtCount, my->old_evtCount);
+#endif
+ }
+ my->evtCount++;
+
#ifdef TOF_READOUT
/*
* check if CONC is ready
*/
+#ifndef NDEBUG
+ syslog(LOG_DEBUG, "check if CONC is ready");
+#endif
if (HwTip_isEmpty(my->tip)) {
HwTip_requestBuffer(my->tip);
/* wait for some time for not disturbing the DSP */
struct timespec tS, *t = &tS;
t->tv_sec = 0;
- t->tv_nsec = 50000000;
+ t->tv_nsec = 20000000;
nanosleep(t, NULL);
}
}
#endif
-/*
-* check if MU is ready
-*/
-
- /*
- only read the Matching Unit Count register, when all pending
- events are processed. This is recommended, because it is very
- "expensive" to read from an Sharc Register in the Matching Unit.
- */
-
- if(my->evtCount != my->old_evtCount) {
- my->evtCount++;
- return;
- }
-
- my->old_evtCount=LVme_getL(my->lvme0, MU_EVT_COUNT);
- while (my->evtCount == my->old_evtCount) {
- /* wait for some time for not disturbing the DSP */
- struct timespec tS, *t = &tS;
- t->tv_sec = 0;
- t->tv_nsec = 50000000UL;
- nanosleep(t, NULL);
- my->old_evtCount=LVme_getL(my->lvme0, MU_EVT_COUNT);
- }
-
- my->evtCount++;
}
void readoutTrig(Hardware *my, void *subEvt)
{
- uint32_t *data;
- size_t size;
+ uint32_t *header;
+ uint16_t *data;
+ uint16_t *dataEnd;
- data = SubEvt_begin(subEvt);
+ header = SubEvt_begin(subEvt);
if (! ((LVme_getW(my->lvme6, MU_FIFO_STATUS) >> 3) &0x1) ) {
LVme_getW(my->lvme4, MU_FIFO);
}
-
- *data++ = LVme_getW(my->lvme4, MU_FIFO) & 0xffff;
- *data++ = LVme_getW(my->lvme4, MU_FIFO) & 0xffff;
- *data++ = LVme_getW(my->lvme4, MU_FIFO) & 0xffff;
- *data++ = LVme_getW(my->lvme4, MU_FIFO) & 0xffff;
- SubEvt_setDecoding(subEvt, SubEvtDecoding_32bitData);
-
- while ((void *)data < SubEvt_end(subEvt)) {
- *data++ = LVme_getW(my->lvme4, MU_FIFO) & 0xffff;
+ /*
+ old MU assumes its 16 bit words get expanded to 32 Bit.
+ This is not the case, see SubEvt_setDecoding(..)
+ */
+ *header++ =((LVme_getW(my->lvme4, MU_FIFO) & 0xffff)>>1) + 8;
+ *header++ = LVme_getW(my->lvme4, MU_FIFO) & 0xffff;
+ *header++ = LVme_getW(my->lvme4, MU_FIFO) & 0xffff;
+ *header++ = LVme_getW(my->lvme4, MU_FIFO) & 0xffff;
+ SubEvt_setDecoding(subEvt, SubEvtDecoding_16bitData);
+
+ data=header;
+ dataEnd=(uint16_t *)SubEvt_end(subEvt);
+
+ while (data < dataEnd) {
+ *data++ = (uint16_t) LVme_getW(my->lvme4, MU_FIFO);
}
#ifndef NDEBUG
if (trigTag != (SubEvt_trigNr(subEvt) & 0xff)) {
SubEvt_setId(subEvt, SubEvt_id(subEvt) | 0x80000000UL);
SubEvt_setId(partEvt, SubEvt_id(partEvt) | 0x80000000UL);
- syslog(LOG_ERR, "(%s)Trigger tag mismatch (crate: %d) : 0x%08x != 0x%08x",
+ syslog(LOG_ERR, "(%s)Trigger tag mismatch: (crate: %d) 0x%08x (MU) != 0x%08x",
my->tip->name, i, trigTag, SubEvt_trigNr(subEvt));
}
subEvt = SubEvt_next(partEvt, subEvt);