DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
timing
python
timing
shells
boards.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
import
timing.cli.toolbox
as
toolbox
8
import
timing.common.definitions
as
defs
9
10
from
.factory
import
ShellFactory, ShellContext
11
from
click
import
echo, style, secho
12
from
timing.core
import
I2CSlave, SI534xSlave, I2CExpanderSlave, DACSlave
13
14
from
timing.common.definitions
import
kBoardSim, kBoardFMC, kBoardPC059, kBoardMicrozed, kBoardTLU
15
from
timing.common.definitions
import
kCarrierEnclustraA35, kCarrierKC705, kCarrierMicrozed
16
from
timing.common.definitions
import
kDesignMaster, kDesignOuroboros, kDesignOuroborosSim, kDesignEndpoint, kDesignFanout
17
18
from
os.path
import
join, expandvars, basename
19
20
# -----------------------------------------------------------------------------
21
class
BoardShell
(object):
22
"""docstring for BoardShell"""
23
24
25
# ------------------------------------------------------------------------------
26
def
soft_reset
(self):
27
lIO = self.device.getNode(
'io'
)
28
29
# Global soft reset
30
lIO.getNode(
'csr.ctrl.soft_rst'
).write(0x1)
31
lIO.getClient().dispatch()
32
# ------------------------------------------------------------------------------
33
34
35
# ------------------------------------------------------------------------------
36
def
enableI2CSwitch
(self):
37
try
:
38
# Wake up the switch
39
self.getAX3Slave().write_i2c(0x01, 0x7f)
40
except
RuntimeError:
41
pass
42
43
x = self.getAX3Slave().read_i2c(0x01)
44
return
x
45
# ------------------------------------------------------------------------------
46
47
48
# ------------------------------------------------------------------------------
49
def
readUID
(self):
50
lValues = self.getUIDSlave().read_i2cArray(0xfa, 6)
51
lUniqueID = 0x0
52
for
lVal
in
lValues:
53
lUniqueID = ( lUniqueID << 8 ) | lVal
54
return
lUniqueID
55
# ------------------------------------------------------------------------------
56
57
58
# ------------------------------------------------------------------------------
59
def
scanI2C
(self):
60
lIO = self.device.getNode(
'io'
)
61
lRes = {}
62
for
lI2CName
in
self.
i2cMasters
:
63
lRes[lI2CName] = lIO.getNode(lI2CName).scan()
64
return
lRes
65
# ------------------------------------------------------------------------------
66
67
68
# ------------------------------------------------------------------------------
69
def
pingI2CSlaves
(self):
70
lIO = self.device.getNode(
'io'
)
71
lRes = {}
72
for
lI2CName
in
self.
i2cMasters
:
73
lI2CNode = lIO.getNode(lI2CName)
74
for
lSlaveName
in
lI2CNode.get_slaves():
75
lRes[lI2CName+
'.'
+lSlaveName] = (lSlaveName, lI2CNode.get_slave_address(lSlaveName), lI2CNode.get_slave(lSlaveName).ping())
76
77
return
lRes
78
# ------------------------------------------------------------------------------
79
80
81
# ------------------------------------------------------------------------------
82
def
measureClockFrequency
(self):
83
lDevice = self.device
84
lBoardType = self.info.boardType
85
86
# secho("PLL Clock frequency measurement:", fg='cyan')
87
# Measure the generated clock frequency
88
freqs = {}
89
for
i
in
range(1
if
lBoardType == kBoardTLU
else
2):
90
lDevice.getNode(
"io.freq.ctrl.chan_sel"
).write(i)
91
lDevice.getNode(
"io.freq.ctrl.en_crap_mode"
).write(0)
92
lDevice.dispatch()
93
time.sleep(2)
94
fq = lDevice.getNode(
"io.freq.freq.count"
).read()
95
fv = lDevice.getNode(
"io.freq.freq.valid"
).read()
96
lDevice.dispatch()
97
freqs[i] = int(fq) * 119.20928 / 1000000
if
fv
else
'NaN'
98
99
lFreqs = {
100
'PLL'
: freqs[0]
101
}
102
if
lBoardType != kBoardTLU:
103
lFreqs[
'CDR'
] = freqs[1]
104
105
return
lFreqs
106
107
# ------------------------------------------------------------------------------
108
def
status
(self):
109
def
dec_rng( word, ibit, nbits=1):
110
return
(word >> ibit) & ((1<<nbits)-1)
111
112
lDevice = self.device
113
lIO = lDevice.getNode(
'io'
)
114
115
# echo()
116
# echo( "--- " + style("IO status", fg='cyan') + " ---")
117
return
toolbox.readSubNodes(lIO.getNode(
'csr.stat'
))
118
# ------------------------------------------------------------------------------
119
120
121
# ------------------------------------------------------------------------------
122
def
pllstatus
(self, verbose=False):
123
def
dec_rng( word, ibit, nbits=1):
124
return
(word >> ibit) & ((1<<nbits)-1)
125
126
lDevice = self.device
127
lBoardType = self.info.boardType
128
lIO = lDevice.getNode(
'io'
)
129
130
# Access the clock chip
131
if
lBoardType
in
[kBoardPC059, kBoardTLU]:
132
lI2CBusNode = lIO.getNode(
"i2c"
)
133
lSIChip = SI534xSlave(lI2CBusNode, lI2CBusNode.get_slave(
'SI5345'
).get_i2c_address())
134
else
:
135
lSIChip = lIO.getNode(
'pll_i2c'
)
136
137
# echo("PLL Configuration id: {}".format(style(lSIChip.read_config_id(), fg='cyan')))
138
# secho("PLL Information", fg='cyan')
139
lConfigID = lSIChip.read_config_id()
140
lVersion = collections.OrderedDict()
141
lVersion[
'Part number'
] = lSIChip.read_device_version()
142
lVersion[
'Device grade'
] = lSIChip.read_clock_register(0x4)
143
lVersion[
'Device revision'
] = lSIChip.read_clock_register(0x5)
144
# toolbox.printRegTable(lVersion)
145
146
w = lSIChip.read_clock_register(0xc)
147
148
lRegisters = collections.OrderedDict()
149
lRegisters[
'SYSINCAL'
] = dec_rng(w, 0)
150
lRegisters[
'LOSXAXB'
] = dec_rng(w, 1)
151
lRegisters[
'XAXB_ERR'
] = dec_rng(w, 3)
152
lRegisters[
'SMBUS_TIMEOUT'
] = dec_rng(w, 5)
153
154
w = lSIChip.read_clock_register(0xd)
155
156
lRegisters[
'LOS'
] = dec_rng(w, 0, 4)
157
lRegisters[
'OOF'
] = dec_rng(w, 4, 4)
158
159
w = lSIChip.read_clock_register(0xe)
160
161
lRegisters[
'LOL'
] = dec_rng(w, 1)
162
lRegisters[
'HOLD'
] = dec_rng(w, 5)
163
164
w = lSIChip.read_clock_register(0xf)
165
lRegisters[
'CAL_PLL'
] = dec_rng(w, 5)
166
167
w = lSIChip.read_clock_register(0x11)
168
lRegisters[
'SYSINCAL_FLG'
] = dec_rng(w, 0)
169
lRegisters[
'LOSXAXB_FLG'
] = dec_rng(w, 1)
170
lRegisters[
'XAXB_ERR_FLG'
] = dec_rng(w, 3)
171
lRegisters[
'SMBUS_TIMEOUT_FLG'
] = dec_rng(w, 5)
172
173
w = lSIChip.read_clock_register(0x12)
174
lRegisters[
'OOF (sticky)'
] = dec_rng(w, 4, 4)
175
176
# secho("PLL Status", fg='cyan')
177
return
(lConfigID, lVersion, lRegisters)
178
# toolbox.printRegTable(lRegisters)
179
# ------------------------------------------------------------------------------
180
181
timing.shells.boards.BoardShell
Definition
boards.py:21
timing.shells.boards.BoardShell.scanI2C
scanI2C(self)
Definition
boards.py:59
timing.shells.boards.BoardShell.measureClockFrequency
measureClockFrequency(self)
Definition
boards.py:82
timing.shells.boards.BoardShell.pingI2CSlaves
pingI2CSlaves(self)
Definition
boards.py:69
timing.shells.boards.BoardShell.readUID
readUID(self)
Definition
boards.py:49
timing.shells.boards.BoardShell.status
status(self)
Definition
boards.py:108
timing.shells.boards.BoardShell.pllstatus
pllstatus(self, verbose=False)
Definition
boards.py:122
timing.shells.boards.BoardShell.i2cMasters
i2cMasters
Definition
boards.py:62
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.cli.toolbox
Definition
toolbox.py:1
timing.common.definitions
Definition
__init__.py:1
timing.core
Definition
__init__.py:1
Generated on
for DUNE-DAQ by
1.17.0