KM3NeT CLB  2.0
KM3NeT CLB v2 Embedded Software
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
tdc.h
Go to the documentation of this file.
1 /*
2  * KM3NeT CLB v2 Firmware
3  * ----------------------
4  *
5  * Copyright 2013 KM3NeT Collaboration
6  *
7  * All Rights Reserved.
8  *
9  *
10  * File : tdc.h
11  * Created : 25 nov 2013
12  * Author : David Calvo, Vincent van Beveren
13  */
14 
15 #ifndef TDC_H_
16 #define TDC_H_
17 /**
18  * @file
19  *
20  * @ingroup wbdrivers
21  *
22  * TDC Driver.
23  */
24 #include <stdint.h>
25 #include <stdbool.h>
26 
27 #define TDC_CH_ALL_MASK 0x7FFFFFFF //!< All channels
28 
29 /**
30  * Resets the TDC to defaults.
31  */
32 void tdcReset();
33 
34 /**
35  * Set the enable/disable channels.
36  *
37  * @param channels
38  */
39 void tdcSetChannels(uint32_t channels, uint32_t mask);
40 
41 /**
42  * Sets the HR veto rate per time-slice.
43  *
44  * @param thrs Threshold, beyond which the TDCs will stop producing data for this frame.
45  */
46 void tdcSetMinTot(uint32_t m_tot);
47 
48 /**
49  * Sets the Minimun ToT width allowed
50  *
51  * @param m_tot ToTs lower will be discarded
52  */
53 void tdcSetHRVeto(uint32_t thrs);
54 
55 /**
56  * Returns the HR-veto rate per time-slice.
57  *
58  * @return The HR-veto rate.
59  */
60 uint32_t tdcHRVeto();
61 
62 /**
63  * Returns which TDC channels are enabled/disabled.
64  *
65  * @return A bitmask containing, per bit position, whether or not the channel is enalbed.
66  */
67 uint32_t tdcChannels();
68 
69 
70 /**
71  * Enables or disables a single channel.
72  *
73  * @param enable true - enable this channel, false - disable this channel.
74  * @param ch Channel to enable.
75  */
76 static inline void tdcChEnable(int ch, bool enable)
77 {
78  tdcSetChannels(enable ? TDC_CH_ALL_MASK : 0, 1 << ch);
79 }
80 
81 /**
82  * Returns whether or not a specific TDC channel is enabled or not.
83  *
84  * @param ch The channel to check
85  *
86  * @retval true The channel is enabled
87  * @retval false The channel is not enabled.
88  */
89 static inline bool tdcChEnabled(int ch) {
90  return (tdcChannels() >> ch) & 1;
91 }
92 
93 /**
94  * Enables all channels.
95  */
96 static inline void tdcEnableAll()
97 {
99 }
100 
101 /**
102  * Disables all channels.
103  */
104 static inline void tdcDisableAll()
105 {
107 }
108 
109 
110 /**
111  * Returns on which channels the high-rate veto is applied.
112  *
113  * @return A bitmask containing, per bit position, whether or not the
114  * HRV is enabled
115  */
116 uint32_t tdcHrvEnabled();
117 
118 /**
119  * Sets on which channels the high-rate veto must be applied.
120  *
121  * @param channels A bitmask containing, per bit position, whether or not the
122  * HRV is enalbed.
123  */
124 void tdcSetHrvEnabled(uint32_t channels);
125 
126 /*
127  * Returns on which channels multi-hit is enabled.
128  *
129  * @return A bitmask containing, per bit position, whether or not the
130  * mutli-hit is enabled
131  */
132 uint32_t tdcMultiHitEnabled();
133 
134 /**
135 * Sets on which channels the mutli-hit veto must be enabled.
136 *
137 * @param channels A bitmask containing, per bit position, whether or not the
138 * multi-hit is enabled
139 */
140 void tdcSetMultiHitEnabled(uint32_t channels);
141 
142 /**
143  * Blast full FIFOs bitmask for debugging.
144  */
145 void tdcDbgSetBlastFull(uint32_t channels);
146 
147 
148 /**
149  * Return Blast full FIFOs bitmask for debugging.
150  */
151 uint32_t tdcDbgBlastFull();
152 
153 
154 
155 #endif /* TDC_H_ */
void tdcReset()
Resets the TDC to defaults.
Definition: tdc.c:20
void tdcSetMultiHitEnabled(uint32_t channels)
Sets on which channels the mutli-hit veto must be enabled.
Definition: tdc.c:70
uint32_t tdcDbgBlastFull()
Return Blast full FIFOs bitmask for debugging.
Definition: tdc.c:81
uint32_t tdcChannels()
Returns which TDC channels are enabled/disabled.
Definition: tdc.c:49
void tdcSetMinTot(uint32_t m_tot)
Sets the HR veto rate per time-slice.
Definition: tdc.c:29
static bool tdcChEnabled(int ch)
Returns whether or not a specific TDC channel is enabled or not.
Definition: tdc.h:89
static void tdcChEnable(int ch, bool enable)
Enables or disables a single channel.
Definition: tdc.h:76
void tdcDbgSetBlastFull(uint32_t channels)
Blast full FIFOs bitmask for debugging.
Definition: tdc.c:75
void tdcSetHRVeto(uint32_t thrs)
Sets the Minimun ToT width allowed.
Definition: tdc.c:33
static void tdcEnableAll()
Enables all channels.
Definition: tdc.h:96
uint32_t tdcHRVeto()
Returns the HR-veto rate per time-slice.
Definition: tdc.c:38
#define TDC_CH_ALL_MASK
All channels.
Definition: tdc.h:27
void tdcSetHrvEnabled(uint32_t channels)
Sets on which channels the high-rate veto must be applied.
Definition: tdc.c:60
static void tdcDisableAll()
Disables all channels.
Definition: tdc.h:104
uint32_t tdcHrvEnabled()
Returns on which channels the high-rate veto is applied.
Definition: tdc.c:55
void tdcSetChannels(uint32_t channels, uint32_t mask)
Set the enable/disable channels.
Definition: tdc.c:44