ICP  1
period_card.h
Go to the documentation of this file.
1 #ifndef PERIOD_CARD_H
2 #define PERIOD_CARD_H
3 
4 #define MAT_1 0x4
5 
6 #define MAX_NUM_PERIODS (16*1024) // should be same of OUTLUT and PERLUT sizes
7 
8 // all 32 bit aligned addresses
9 
10 #define MPCNT 0x60 // main period (DAQ + Dwell) counter (14 bit, RO) also has dwell flag
11 #define MPLIM 0x64 // main period (DAQ + Dwell) limit register (14 bit, RW)
12 #define PSCNT 0x68 // period sequence counter (16 bit, RO)
13 #define PSLR 0x6c // period sequence limit register (16 bit, RW)
14 #define EXTTRIGVC0 0x70 // extraft trigger veto count low (16 bit, RO)
15 #define EXTTRIGVC1 0x74 // extract trigger veto count high (16 bit, RO)
16 #define I50HZVC0 0x78 // isis not at 50Hz veto count low (16 bit, RO)
17 #define I50HZVC1 0x7C // isis not at 50Hz veto count high (16 bit, RO)
18 #define EXTPTRANVC0 0x80 // external period transition veto counter low (16 bit, RO)
19 #define EXTPTRANVC1 0x84 // external period transition veto counter high (16 bit, RO)
20 #define LOOKTAR 0x40000 // lookup table access register (4bit, RW) - see below
21 #define PCREG 0x40088 // period control register (16 bit, RW) - see below
22 #define EXTPERREG 0x4008c // external periods register (16bit, RW) - see below
23 #define FWVERREG 0x7fffc // firmware version regiuster (32 bit, RW)
24 #define PERLUTSTART 0x80000 // period lookup table (16k x 32 bit RW)
25 #define PERLUTSIZE (16*1024) //
26 #define PERLUTEND (PERLUTSTART + 4*PERLUTSIZE)
27 
28 #define OUTLUTSTART 0xc0000 // period switching output lookup table (16k x 16 bit RW)
29 #define OUTLUTSIZE (16*1024) //
30 #define OUTLUTEND (OUTLUTSTART + 4*OUTLUTSIZE)
31 #define RFCNT0START 0x100000 // raw frame counters(16k x 32 bit, RW) in counts0
32 #define RFCNT0SIZE (16*1024)
33 #define GFCNT0START 0x110000 // good frame counters(16k x 32 bit, RW) in counts0
34 #define GFCNT0SIZE (16*1024)
35 #define RPCNT0START 0x120000 // raw frame counters(16k x 32 bit, RW) in counts0
36 #define RFCNT0SIZE (16*1024)
37 #define GPCNT0START 0x130000 // good frame counters(16k x 32 bit, RW) in counts0
38 #define GFCNT0SIZE (16*1024)
39 
40 // bits for lookup table access register (LOOKTAR, 0x40000)
41 // All are active high
42 #define TARPERLUT (1 << 0) // access PERLUT enable bit, RW
43 #define TAROUTLUT (1 << 1) // access OUTLUT enable bit, RW
44 #define TARCNT0 (1 << 2) // access Counts0 enable bit, RW
45 #define TARBCT1 (1 << 3) // access Counts1 enable bit, RW
46 
47 // bits for period control register (PCREG, 0x40088)
48 // All are active high
49 #define PCENDAFTER (1 << 1) // end run after period sequence completes control bit (RW)
50 #define PCSEQCOMP (1 << 2) // period sequence complete monitor bit (RO)
51 #define PCENDSEQCOMP (1 << 3) // run ended and period sequence complete monitor bit (RO)
52 #define PCENAB (1 << 4) // normal/period mode enable (RW)
53 #define PCEXTENAB (1 << 5) // internal/external periods control mode enable (RW)
54 #define PCMULENAB (1 << 6) // single/multi period sequence control mode enable (RW)
55 #define PCMULCOMP (1 << 7) // multiple period sequence completed monitor bit (RO)
56 #define PCEXTPERCLK (1 << 8) // internal/external period clock mode enable (RW)
57 #define PC50HZENAB (1 << 9) // isis not at 50 Hz veto enable (RW)
58 #define PCEXTTRIG (1 << 10) // extract trigger veto enable (RW)
59 #define PCCLRVETO (1 << 12) // clear veto counters (RW)
60 #define PCCLRPC (1 << 13) // clear period counters (RW)
61 #define PCRESET (1 << 15) // period card reset control bit(RW)
62 
63 // bits for perlut
64 #define PERLUTTYPE (1 << 31) // bit of perlut used to decide if dwell or daq period
65 
66 #include "dae2_card.h"
67 
68 class PeriodCard : public DAE2Card
69 {
70 
71 public:
72  PeriodCard(int position, ISISVME* vme, DAEstatus& status);
73  void printStatus(std::ostream& os, DAEstatus& status);
74 
75  // main period register
76  int getCurrentPeriodNumber(DAEstatus& status); // 0 is first period
77  bool inDwellPeriod(DAEstatus& status); // is current period a dwell
78  int setNumberOfPeriods(isisU16_t n, DAEstatus& status); // numbered internally 0 to n-1
79  int getNumberOfPeriods(DAEstatus& status);
81 
82 
83 
84  // vetos
85  int clearVetoCounters(DAEstatus& status);
86 
87  // extract trigger veto count
90  int getExtractTriggerVetoCount(isisU32_t* value, DAEstatus& status);
93 
94  int resetCard(DAEstatus& status);
95  int clearPeriodCounters(DAEstatus& status);
96  int enable50HzVeto(DAEstatus& status);
97  int disable50HzVeto(DAEstatus& status);
104  int enablePeriodMode(DAEstatus& status);
105  int disablePeriodMode(DAEstatus& status);
108 
109  int programPERLUT(isisU16_t* dwell_flags, isisU16_t* frames, int nperiod, DAEstatus& status);
110  int programOUTLUT(isisU32_t* outputs, int nperiod, DAEstatus& status);
111  int readPERLUT(isisU16_t* dwell_flags, isisU16_t* frames, int nperiod, DAEstatus& status);
112  int readOUTLUT(isisU32_t* outputs, int nperiod, DAEstatus& status);
113  int getPeriodRawFrames(int period, isisU32_t* frames, DAEstatus& status);
114  int getPeriodGoodFrames(int period, isisU32_t* frames, DAEstatus& status);
115  int zeroPeriodFrameCounters(DAEstatus& status);
116  int setPeriodControlBits(isisU32_t mask, bool preserve, DAEstatus& status);
117 
118  int startDataCollection(DAEstatus& status);
119  int stopDataCollection(DAEstatus& status);
120  void abortSequenceCompleteWait(DAEstatus& status);
121 
122 protected:
123 
124  int clearPeriodControlBits(isisU32_t mask, DAEstatus& status);
125  int setAndClearPeriodControlBits(isisU32_t mask, bool preserve, DAEstatus& status);
126  int getRawFrames(int period_start, int nperiod, isisU32_t frames[], DAEstatus& status);
127  int getGoodFrames(int period_start, int nperiod, isisU32_t frames[], DAEstatus& status);
128  int getPeriodRequestedFrames(int period, isisU32_t* frames, DAEstatus& status);
129  int getRequestedFrames(int period_start, int nperiod, isisU32_t frames[], DAEstatus& status);
130 
131 // lookup table access register
132  int lookupAccessOUTLUT(DAEstatus& status);
133  int lookupAccessPERLUT(DAEstatus& status);
134  int lookupFinished(DAEstatus& status);
135 };
136 
137 #endif /* PERIOD_CARD_H */
int setMultiplePeriodSequenceMode(DAEstatus &status)
int lookupAccessOUTLUT(DAEstatus &status)
int startDataCollection(DAEstatus &status)
int setPeriodControlBits(isisU32_t mask, bool preserve, DAEstatus &status)
Definition: period_card.cpp:83
int setInternalPeriodControlMode(DAEstatus &status)
int getExtractTriggerVetoCount(isisU32_t *value, DAEstatus &status)
int getCurrentPeriodSequence(DAEstatus &status)
int programPERLUT(isisU16_t *dwell_flags, isisU16_t *frames, int nperiod, DAEstatus &status)
int enableExtractTriggerVeto(DAEstatus &status)
int readPERLUT(isisU16_t *dwell_flags, isisU16_t *frames, int nperiod, DAEstatus &status)
int endRunAfterSequenceCompletes(DAEstatus &status)
int lookupAccessPERLUT(DAEstatus &status)
int setSinglePeriodSequenceMode(DAEstatus &status)
unsigned long isisU32_t
Definition: isisvme_types.h:8
int getNumberOfPeriods(DAEstatus &status)
int stopDataCollection(DAEstatus &status)
int disable50HzVeto(DAEstatus &status)
int disableExtractTriggerVeto(DAEstatus &status)
int zeroPeriodFrameCounters(DAEstatus &status)
int getPeriodGoodFrames(int period, isisU32_t *frames, DAEstatus &status)
void abortSequenceCompleteWait(DAEstatus &status)
int enablePeriodMode(DAEstatus &status)
int readOUTLUT(isisU32_t *outputs, int nperiod, DAEstatus &status)
int setAndClearPeriodControlBits(isisU32_t mask, bool preserve, DAEstatus &status)
Definition: period_card.cpp:93
int clearVetoCounters(DAEstatus &status)
Definition: period_card.cpp:98
PeriodCard(int position, ISISVME *vme, DAEstatus &status)
Definition: period_card.cpp:5
int enable50HzVeto(DAEstatus &status)
int getPeriodRawFrames(int period, isisU32_t *frames, DAEstatus &status)
int clearPeriodControlBits(isisU32_t mask, DAEstatus &status)
Definition: period_card.cpp:88
int disablePeriodMode(DAEstatus &status)
unsigned short isisU16_t
Definition: isisvme_types.h:7
void printStatus(std::ostream &os, DAEstatus &status)
Definition: period_card.cpp:32
int getExtractTriggerVetoCountHigh(isisU16_t *value, DAEstatus &status)
int lookupFinished(DAEstatus &status)
int getRawFrames(int period_start, int nperiod, isisU32_t frames[], DAEstatus &status)
int getGoodFrames(int period_start, int nperiod, isisU32_t frames[], DAEstatus &status)
int setNumberOfPeriods(isisU16_t n, DAEstatus &status)
bool isRunEndedAndSequenceComplete(DAEstatus &status)
int clearPeriodCounters(DAEstatus &status)
int setExternalPeriodClockMode(DAEstatus &status)
bool inDwellPeriod(DAEstatus &status)
int position() const
Definition: dae2_card.h:72
int programOUTLUT(isisU32_t *outputs, int nperiod, DAEstatus &status)
int resetCard(DAEstatus &status)
int getPeriodRequestedFrames(int period, isisU32_t *frames, DAEstatus &status)
int getExtractTriggerVetoCountLow(isisU16_t *value, DAEstatus &status)
int getCurrentPeriodNumber(DAEstatus &status)
int setExternalPeriodControlMode(DAEstatus &status)
int getRequestedFrames(int period_start, int nperiod, isisU32_t frames[], DAEstatus &status)
int setInternalPeriodClockMode(DAEstatus &status)