Line data Source code
1 : /**
2 : * @file VLCmdGeneratorNode.cpp
3 : *
4 : * This is part of the DUNE DAQ Software Suite, copyright 2020.
5 : * Licensing/copyright details are in the COPYING file that you should have
6 : * received with this code.
7 : */
8 :
9 : #include "timing/VLCmdGeneratorNode.hpp"
10 : #include "timing/toolbox.hpp"
11 :
12 : #include "logging/Logging.hpp"
13 :
14 : #include <string>
15 :
16 : namespace dunedaq {
17 : namespace timing {
18 :
19 0 : UHAL_REGISTER_DERIVED_NODE(VLCmdGeneratorNode)
20 :
21 : //-----------------------------------------------------------------------------
22 0 : VLCmdGeneratorNode::VLCmdGeneratorNode(const uhal::Node& node)
23 0 : : TimingNode(node)
24 0 : {}
25 : //-----------------------------------------------------------------------------
26 :
27 : //-----------------------------------------------------------------------------
28 0 : VLCmdGeneratorNode::~VLCmdGeneratorNode() {}
29 : //-----------------------------------------------------------------------------
30 :
31 : //-----------------------------------------------------------------------------
32 : std::string
33 0 : VLCmdGeneratorNode::get_status(bool print_out) const
34 : {
35 0 : std::stringstream status;
36 0 : auto subnodes = read_sub_nodes(getNode("csr.stat"));
37 0 : status << format_reg_table(subnodes, "VL Cmd gen state");
38 :
39 0 : if (print_out)
40 0 : TLOG() << status.str();
41 0 : return status.str();
42 0 : }
43 : //-----------------------------------------------------------------------------
44 :
45 : //-----------------------------------------------------------------------------
46 : void
47 0 : VLCmdGeneratorNode::switch_endpoint_sfp(uint32_t address, bool enable) const // NOLINT(build/unsigned)
48 : {
49 0 : TLOG_DEBUG(3) << "Switching SFP for endpoint address: " << address << ", to state: " << enable;
50 0 : reset_sub_nodes(getNode("csr.ctrl"));
51 0 : getNode("csr.ctrl.addr").write(address);
52 0 : getNode("csr.ctrl.tx_en").write(enable);
53 0 : getNode("csr.ctrl.go").write(0x1);
54 0 : getNode("csr.ctrl.go").write(0x0);
55 0 : getClient().dispatch();
56 0 : }
57 : //-----------------------------------------------------------------------------
58 :
59 : //-----------------------------------------------------------------------------
60 : void
61 0 : VLCmdGeneratorNode::apply_endpoint_delay(uint32_t address, // NOLINT(build/unsigned)
62 : uint32_t coarse_delay, // NOLINT(build/unsigned)
63 : uint32_t fine_delay, // NOLINT(build/unsigned)
64 : uint32_t phase_delay) const // NOLINT(build/unsigned)
65 : {
66 0 : reset_sub_nodes(getNode("csr.ctrl"), false);
67 0 : getNode("csr.ctrl.tx_en").write(0x0);
68 0 : getNode("csr.ctrl.addr").write(address);
69 0 : getNode("csr.ctrl.cdel").write(coarse_delay);
70 0 : getNode("csr.ctrl.fdel").write(fine_delay);
71 0 : getNode("csr.ctrl.pdel").write(phase_delay);
72 0 : getNode("csr.ctrl.update").write(0x1);
73 0 : getNode("csr.ctrl.go").write(0x1);
74 0 : getNode("csr.ctrl.go").write(0x0);
75 0 : getClient().dispatch();
76 :
77 0 : TLOG_DEBUG(2) << "Coarse delay " << format_reg_value(coarse_delay) << " applied";
78 0 : TLOG_DEBUG(2) << "Fine delay " << format_reg_value(fine_delay) << " applied";
79 0 : TLOG_DEBUG(2) << "Phase delay " << format_reg_value(phase_delay) << " applied";
80 0 : }
81 : //-----------------------------------------------------------------------------
82 :
83 : } // namespace timing
84 : } // namespace dunedaq
|