DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
timing
python
timing
shells
tlu.py
Go to the documentation of this file.
1
from
__future__
import
print_function
2
3
import
click
4
import
time
5
import
collections
6
7
from
.boards
import
BoardShell
8
from
.factory
import
ShellFactory
9
10
from
os.path
import
join, expandvars, basename
11
from
click
import
echo, style, secho
12
from
timing.common.definitions
import
kBoardTLU, kBoardSim
13
# from timing.common.definitions import kCarrierEnclustraA35, kCarrierKC705, kCarrierMicrozed
14
from
timing.common.definitions
import
kDesignFanout
15
from
timing.core
import
I2CSlave, SI534xSlave, I2CExpanderSlave, DACSlave
16
17
18
19
# ------------------------------------------------------------------------------
20
class
TLUShell
(
BoardShell
):
21
"""docstring for PC059Shell"""
22
kTLURev1 = 6
23
24
kUIDRevisionMap = {
25
0x5410ecbb9426: kTLURev1,
26
}
27
28
kClockConfigMap = {
29
kTLURev1:
"wr/TLU_EXTCLK_10MHZ_NOZDM.txt"
30
}
31
32
i2cMasters=[
33
'i2c'
,
34
]
35
# ------------------------------------------------------------------------------
36
def
getAX3Slave
(self):
37
lIO = self.device.getNode(
'io'
)
38
return
lIO.getNode(
'i2c'
).get_slave(
'AX3_Switch'
)
39
# ------------------------------------------------------------------------------
40
#
41
42
# ------------------------------------------------------------------------------
43
def
getUIDSlave
(self):
44
lIO = self.device.getNode(
'io'
)
45
return
lIO.getNode(
'i2c'
).get_slave(
'UID_PROM'
)
46
# ------------------------------------------------------------------------------
47
48
# ------------------------------------------------------------------------------
49
def
resetI2CnPll
(self):
50
lIO = self.device.getNode(
'io'
)
51
52
# PLL and I@C reset
53
lIO.getNode(
'csr.ctrl.pll_rst'
).write(0x1)
54
lIO.getNode(
'csr.ctrl.rst_i2c'
).write(0x1)
55
lIO.getClient().dispatch()
56
57
lIO.getNode(
'csr.ctrl.pll_rst'
).write(0x0)
58
lIO.getNode(
'csr.ctrl.rst_i2c'
).write(0x0)
59
lIO.getClient().dispatch()
60
# ------------------------------------------------------------------------------
61
62
63
# ------------------------------------------------------------------------------
64
def
resetLockMon
(self):
65
lIO = self.device.getNode(
'io'
)
66
67
lIO.getNode(
'csr.ctrl.rst_lock_mon'
).write(0x1)
68
lIO.getNode(
'csr.ctrl.rst_lock_mon'
).write(0x0)
69
lIO.getClient().dispatch()
70
# ------------------------------------------------------------------------------
71
72
73
# ------------------------------------------------------------------------------
74
def
configureExpanders
(self):
75
76
lI2CBusNode = self.device.getNode(
"io.i2c"
)
77
78
lIC6 =
I2CExpanderSlave
(lI2CBusNode, lI2CBusNode.get_slave(
'Expander1'
).get_i2c_address())
79
lIC7 =
I2CExpanderSlave
(lI2CBusNode, lI2CBusNode.get_slave(
'Expander2'
).get_i2c_address())
80
81
# Bank 0
82
lIC6.set_inversion(0, 0x00)
83
lIC6.set_io(0, 0x00)
84
lIC6.set_outputs(0, 0x00)
85
86
# Bank 1
87
lIC6.set_inversion(1, 0x00)
88
lIC6.set_io(1, 0x00)
89
lIC6.set_outputs(1, 0x88)
90
91
92
# Bank 0
93
lIC7.set_inversion(0, 0x00)
94
lIC7.set_io(0, 0x00)
95
lIC7.set_outputs(0, 0xf0)
96
97
# Bank 1
98
lIC7.set_inversion(1, 0x00)
99
lIC7.set_io(1, 0x00)
100
lIC7.set_outputs(1, 0xf0)
101
# ------------------------------------------------------------------------------
102
103
104
# ------------------------------------------------------------------------------
105
def
configure_pllSwing
(self):
106
lI2CBusNode = self.device.getNode(
"io.i2c"
)
107
lSIChip = SI534xSlave(lI2CBusNode, lI2CBusNode.get_slave(
'SI5345'
).get_i2c_address())
108
109
lSIChip.write_i2cArray(0x113, [0x9, 0x33])
110
# ------------------------------------------------------------------------------
111
112
# ------------------------------------------------------------------------------
113
def
configure_dacs
(self):
114
lI2CBusNode = self.device.getNode(
"io.i2c"
)
115
116
lDAC1 = DACSlave(lI2CBusNode, lI2CBusNode.get_slave(
'DAC1'
).get_i2c_address())
117
lDAC2 = DACSlave(lI2CBusNode, lI2CBusNode.get_slave(
'DAC2'
).get_i2c_address())
118
119
# BI signals are NIM
120
lBISignalThreshold = 0x589D
121
122
lDAC1.set_interal_ref(
False
);
123
lDAC2.set_interal_ref(
False
);
124
lDAC1.set_dac(7, lBISignalThreshold);
125
lDAC2.set_dac(7, lBISignalThreshold);
126
127
secho(
"DAC1 and DAC2 set to "
+ hex(lBISignalThreshold), fg=
'cyan'
)
128
# ------------------------------------------------------------------------------
129
130
# ------------------------------------------------------------------------------
131
def
reset
(self, soft, forcepllcfg):
132
'''
133
Perform a hard reset on the timing master, including
134
135
\b
136
- ipbus registers
137
- i2c buses
138
- pll and pll configuration
139
140
\b
141
Fanout mode:
142
0 = local master
143
1 = sfp
144
'''
145
146
lDevice = self.device
147
lBoardType = self.info.boardType
148
lCarrierType = self.info.carrierType
149
lDesignType = self.info.designType
150
151
echo(
'Resetting '
+ click.style(lDevice.id(), fg=
'blue'
))
152
153
lIO = lDevice.getNode(
'io'
)
154
155
# Global soft reset
156
self.
soft_reset
()
157
158
if
not
(soft
or
lBoardType == kBoardSim):
159
160
time.sleep(0.1)
161
162
# PLL and I@C reset
163
self.
resetI2CnPll
()
164
165
# Enable I2C routing on carrier
166
self.
enableI2CSwitch
()
167
168
lUniqueID = self.
readUID
()
169
170
try
:
171
lRevision = self.
kUIDRevisionMap
[lUniqueID]
172
except
KeyError:
173
raise
click.ClickException(
"No revision associated to UID "
+hex(lUniqueID))
174
175
# Access the clock chip
176
lI2CBusNode = lDevice.getNode(
"io.i2c"
)
177
lSIChip = SI534xSlave(lI2CBusNode, lI2CBusNode.get_slave(
'SI5345'
).get_i2c_address())
178
lSIVersion = lSIChip.read_device_version()
179
echo(
"PLL version : "
+style(hex(lSIVersion), fg=
'blue'
))
180
181
# Ensure that the board revision has a registered clock config
182
if
forcepllcfg
is
not
None
:
183
lFullClockConfigPath = forcepllcfg
184
echo(
"Using PLL Clock configuration file: "
+style(basename(lFullClockConfigPath), fg=
'green'
) )
185
else
:
186
try
:
187
lClockConfigPath = self.
kClockConfigMap
[lRevision]
188
except
KeyError:
189
raise
ClickException(
"Board revision "
<< lRevision <<
" has no associated clock configuration"
)
190
191
echo(
"PLL Clock configuration file: "
+style(lClockConfigPath, fg=
'green'
) )
192
193
# Configure the clock chip
194
lFullClockConfigPath = expandvars(join(
'${TIMING_SHARE}/config/etc/clock'
, lClockConfigPath))
195
196
lSIChip.configure(lFullClockConfigPath)
197
echo(
"SI3545 configuration id: {}"
.format(style(lSIChip.read_config_id(), fg=
'green'
)))
198
199
self.
configureExpanders
()
200
201
# Tweak the PLL swing
202
lI2CBusNode = lDevice.getNode(
"io.i2c"
)
203
self.
configure_pllSwing
()
204
205
self.
configure_dacs
()
206
207
self.
resetLockMon
()
208
# ------------------------------------------------------------------------------
209
210
ShellFactory.registerBoard(kBoardTLU, TLUShell)
211
212
# ------------------------------------------------------------------------------
I2CExpanderSlave
Definition
I2CExpanderNode.hpp:25
timing.shells.boards.BoardShell
Definition
boards.py:21
timing.shells.boards.BoardShell.readUID
readUID(self)
Definition
boards.py:49
timing.shells.boards.BoardShell.enableI2CSwitch
enableI2CSwitch(self)
Definition
boards.py:36
timing.shells.boards.BoardShell.soft_reset
soft_reset(self)
Definition
boards.py:26
timing.shells.tlu.TLUShell
Definition
tlu.py:20
timing.shells.tlu.TLUShell.kUIDRevisionMap
dict kUIDRevisionMap
Definition
tlu.py:24
timing.shells.tlu.TLUShell.getAX3Slave
getAX3Slave(self)
Definition
tlu.py:36
timing.shells.tlu.TLUShell.configure_pllSwing
configure_pllSwing(self)
Definition
tlu.py:105
timing.shells.tlu.TLUShell.resetLockMon
resetLockMon(self)
Definition
tlu.py:64
timing.shells.tlu.TLUShell.kClockConfigMap
dict kClockConfigMap
Definition
tlu.py:28
timing.shells.tlu.TLUShell.configureExpanders
configureExpanders(self)
Definition
tlu.py:74
timing.shells.tlu.TLUShell.configure_dacs
configure_dacs(self)
Definition
tlu.py:113
timing.shells.tlu.TLUShell.getUIDSlave
getUIDSlave(self)
Definition
tlu.py:43
timing.shells.tlu.TLUShell.reset
reset(self, soft, forcepllcfg)
Definition
tlu.py:131
timing.shells.tlu.TLUShell.resetI2CnPll
resetI2CnPll(self)
Definition
tlu.py:49
timing.common.definitions
Definition
__init__.py:1
timing.core
Definition
__init__.py:1
Generated on
for DUNE-DAQ by
1.17.0