DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
timing
src
GIBV2IONode.cpp
Go to the documentation of this file.
1
8
9
#include "
timing/GIBV2IONode.hpp
"
10
11
#include <string>
12
#include <math.h>
13
14
namespace
dunedaq
{
15
namespace
timing
{
16
17
UHAL_REGISTER_DERIVED_NODE(
GIBV2IONode
)
18
19
//-----------------------------------------------------------------------------
20
GIBV2IONode
::
GIBV2IONode
(const
uhal
::Node& node)
21
:
GIBIONode
(node,
"i2c"
,
"i2c"
, {
"PLL"
}, {
"PLL"
,
"SFP CDR 0"
,
"SFP CDR 1"
,
"SFP CDR 2"
,
"SFP CDR 3"
,
"SFP CDR 4"
,
"SFP CDR 5"
,
"10 MHz"
}, {
"i2c"
,
"i2c"
,
"i2c"
,
"i2c"
,
"i2c"
,
"i2c"
,
"i2c"
})
22
{
23
}
24
//-----------------------------------------------------------------------------
25
26
//-----------------------------------------------------------------------------
27
GIBV2IONode::~GIBV2IONode
() {}
28
//-----------------------------------------------------------------------------
29
30
//-----------------------------------------------------------------------------
31
uint8_t
32
GIBV2IONode::read_sfps_los
()
const
{
// NOLINT(build/unsigned)
33
uint32_t expander_bits =
read_io_expanders
();
34
35
// A-CLK LOS is 1st bit
36
uint8_t los_bits =
static_cast<
uint8_t
>
(expander_bits & 0b01);
37
38
for
(uint8_t sfp = 0; sfp<6; sfp++) {
39
// Each SFP has 4 bits, the 3rd bit is the LOS
40
// Adds the SFPs in inverse order
41
los_bits = (los_bits << 1) + ((expander_bits >> (2 + 20 - 4*sfp)) & 1);
42
}
43
44
return
los_bits;
45
}
46
//-----------------------------------------------------------------------------
47
48
//-----------------------------------------------------------------------------
49
uint8_t
50
GIBV2IONode::read_sfps_fault
()
const
{
// NOLINT(build/unsigned)
51
uint32_t expander_bits =
read_io_expanders
();
52
53
// A-CLK fault is 2nd bit
54
uint8_t fault_bits =
static_cast<
uint8_t
>
(expander_bits & 0b10);
55
56
for
(uint8_t sfp = 0; sfp<6; sfp++) {
57
// Each SFP has 4 bits, the 4th bit is the fault
58
// Adds the SFPs in inverse order
59
fault_bits = (fault_bits << 1) + ((expander_bits >> (3 + 20 - 4*sfp)) & 1);
60
}
61
62
return
fault_bits;
63
}
64
//-----------------------------------------------------------------------------
65
66
//-----------------------------------------------------------------------------
67
bool
68
GIBV2IONode::clocks_ok
()
const
69
{
70
std::stringstream status;
71
72
auto
states =
read_sub_nodes
(getNode(
"csr.stat"
));
73
bool
pll_lol = states.find(
"clk_gen_lol"
)->second.value();
74
//bool pll_interrupt = states.find("clk_gen_intr")->second.value();
75
bool
mmcm_ok = states.find(
"mmcm_ok"
)->second.value();
76
77
TLOG_DEBUG
(5) <<
"pll lol: "
<< pll_lol <<
", mmcm ok: "
<< mmcm_ok;
78
79
return
!pll_lol && mmcm_ok;
80
}
81
//-----------------------------------------------------------------------------
82
83
//-----------------------------------------------------------------------------
84
void
85
GIBV2IONode::switch_sfp_tx
(uint32_t sfp_id,
bool
turn_on)
const
{
// NOLINT(build/unsigned)
86
87
validate_sfp_id
(sfp_id);
88
89
set_i2c_mux_channels
(0x1);
90
91
// A-CLK is the 7th SFP, but is in slot 7 not 6
92
// TODO make this a map dlindebaum 25/10/02
93
sfp_id = sfp_id + (sfp_id/6);
94
95
auto
sfp_expander_1 =
get_i2c_device<I2CExpanderSlave>
(
m_uid_i2c_bus
,
"SFPExpander1"
);
96
uint8_t current_sfp_tx_control_flags = sfp_expander_1->read_outputs_config(1);
// NOLINT(build/unsigned)
97
98
uint8_t new_sfp_tx_control_flags;
// NOLINT(build/unsigned)
99
if
(turn_on)
100
{
101
new_sfp_tx_control_flags = current_sfp_tx_control_flags & ~(1UL << sfp_id);
102
}
103
else
104
{
105
new_sfp_tx_control_flags = current_sfp_tx_control_flags | (1UL << sfp_id);
106
}
107
108
sfp_expander_1->set_outputs(1, new_sfp_tx_control_flags);
109
}
110
//-----------------------------------------------------------------------------
111
112
//-----------------------------------------------------------------------------
113
uint8_t
114
GIBV2IONode::get_sfp_tx_disable_bitmap
()
const
{
// NOLINT(build/unsigned)
115
// First 6 bits and the 8th bit are tx disable for GIBv2/3
116
return
0x40;
117
}
118
//-----------------------------------------------------------------------------
119
120
//-----------------------------------------------------------------------------
121
uint8_t
122
GIBV2IONode::get_num_sfps
()
const
{
// NOLINT(build/unsigned)
123
// 7 SFPs on GIBv2/3
124
return
7;
125
}
126
//-----------------------------------------------------------------------------
127
128
}
// namespace timing
129
}
// namespace dunedaq
GIBV2IONode.hpp
dunedaq::timing::GIBIONode::set_i2c_mux_channels
void set_i2c_mux_channels(uint8_t mux_channel_bitmask) const
Fill hardware monitoring structure.
Definition
GIBIONode.cpp:374
dunedaq::timing::GIBIONode::read_io_expanders
virtual uint32_t read_io_expanders() const
Read the contents of the IO expanders.
Definition
GIBIONode.cpp:233
dunedaq::timing::GIBIONode::validate_sfp_id
void validate_sfp_id(uint32_t sfp_id) const
Definition
GIBIONode.cpp:364
dunedaq::timing::GIBIONode::GIBIONode
GIBIONode(const uhal::Node &node)
Definition
GIBIONode.cpp:21
dunedaq::timing::GIBV2IONode
Class for the timing FMC board.
Definition
GIBV2IONode.hpp:33
dunedaq::timing::GIBV2IONode::get_num_sfps
uint8_t get_num_sfps() const override
Definition
GIBV2IONode.cpp:122
dunedaq::timing::GIBV2IONode::read_sfps_fault
uint8_t read_sfps_fault() const override
Retrive SFP fault status for all SFPs.
Definition
GIBV2IONode.cpp:50
dunedaq::timing::GIBV2IONode::~GIBV2IONode
virtual ~GIBV2IONode()
Definition
GIBV2IONode.cpp:27
dunedaq::timing::GIBV2IONode::read_sfps_los
uint8_t read_sfps_los() const override
Retrive SFP LOS status for all SFPs.
Definition
GIBV2IONode.cpp:32
dunedaq::timing::GIBV2IONode::clocks_ok
bool clocks_ok() const override
Clocks ready?
Definition
GIBV2IONode.cpp:68
dunedaq::timing::GIBV2IONode::GIBV2IONode
GIBV2IONode(const uhal::Node &node)
Definition
GIBV2IONode.cpp:20
dunedaq::timing::GIBV2IONode::get_sfp_tx_disable_bitmap
uint8_t get_sfp_tx_disable_bitmap() const override
Definition
GIBV2IONode.cpp:114
dunedaq::timing::GIBV2IONode::switch_sfp_tx
void switch_sfp_tx(uint32_t sfp_id, bool turn_on) const override
control tx laser of on-board SFP softly (I2C command)
Definition
GIBV2IONode.cpp:85
dunedaq::timing::IONode::m_uid_i2c_bus
const std::string m_uid_i2c_bus
Definition
IONode.hpp:215
dunedaq::timing::IONode::get_i2c_device
std::unique_ptr< const T > get_i2c_device(const std::string &i2c_bus_name, const std::string &i2c_device_name) const
Get the an I2C chip.
Definition
IONode.hxx:6
dunedaq::timing::TimingNode::read_sub_nodes
std::map< std::string, uhal::ValWord< uint32_t > > read_sub_nodes(const uhal::Node &node, bool dispatch=true) const
Read subnodes.
Definition
TimingNode.cpp:29
TLOG_DEBUG
#define TLOG_DEBUG(lvl,...)
Definition
Logging.hpp:112
dunedaq::timing
< Message parameters
Definition
BoreasDesign.hpp:29
dunedaq
Including Qt Headers.
Definition
module.cpp:16
uhal
Definition
ProtocolAxi4Lite.hpp:63
Generated on
for DUNE-DAQ by
1.17.0