LCOV - code coverage report
Current view: top level - timing/src - GIBV2IONode.cpp (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 40 0
Test Date: 2025-12-21 13:07:08 Functions: 0.0 % 10 0

            Line data    Source code
       1              : /**
       2              :  * @file GIBV2IONode.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/GIBV2IONode.hpp"
      10              : 
      11              : #include <string>
      12              : #include <math.h>
      13              : 
      14              : namespace dunedaq {
      15              : namespace timing {
      16              : 
      17            0 : UHAL_REGISTER_DERIVED_NODE(GIBV2IONode)
      18              : 
      19              : //-----------------------------------------------------------------------------
      20            0 : GIBV2IONode::GIBV2IONode(const uhal::Node& node)
      21            0 :   : 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            0 : }
      24              : //-----------------------------------------------------------------------------
      25              : 
      26              : //-----------------------------------------------------------------------------
      27            0 : GIBV2IONode::~GIBV2IONode() {}
      28              : //-----------------------------------------------------------------------------
      29              : 
      30              : //-----------------------------------------------------------------------------
      31              : uint8_t
      32            0 : GIBV2IONode::read_sfps_los() const { // NOLINT(build/unsigned)
      33            0 :   uint32_t expander_bits = read_io_expanders();
      34              : 
      35              :   // A-CLK LOS is 1st bit
      36            0 :   uint8_t los_bits = static_cast<uint8_t>(expander_bits & 0b01);
      37              : 
      38            0 :   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            0 :     los_bits = (los_bits << 1) + ((expander_bits >> (2 + 20 - 4*sfp)) & 1);
      42              :   }
      43              : 
      44            0 :   return los_bits;
      45              : }
      46              : //-----------------------------------------------------------------------------
      47              : 
      48              : //-----------------------------------------------------------------------------
      49              : uint8_t
      50            0 : GIBV2IONode::read_sfps_fault() const { // NOLINT(build/unsigned)
      51            0 :   uint32_t expander_bits = read_io_expanders();
      52              : 
      53              :   // A-CLK fault is 2nd bit
      54            0 :   uint8_t fault_bits = static_cast<uint8_t>(expander_bits & 0b10);
      55              : 
      56            0 :   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            0 :     fault_bits = (fault_bits << 1) + ((expander_bits >> (3 + 20 - 4*sfp)) & 1);
      60              :   }
      61              : 
      62            0 :   return fault_bits;
      63              : }
      64              : //-----------------------------------------------------------------------------
      65              : 
      66              : //-----------------------------------------------------------------------------
      67              : bool
      68            0 : GIBV2IONode::clocks_ok() const
      69              : {
      70            0 :   std::stringstream status;
      71              : 
      72            0 :   auto states = read_sub_nodes(getNode("csr.stat"));
      73            0 :   bool pll_lol = states.find("clk_gen_lol")->second.value();
      74              :   //bool pll_interrupt = states.find("clk_gen_intr")->second.value();
      75            0 :   bool mmcm_ok = states.find("mmcm_ok")->second.value();
      76              : 
      77            0 :   TLOG_DEBUG(5) << "pll lol: " << pll_lol << ", mmcm ok: " << mmcm_ok;
      78              : 
      79            0 :   return !pll_lol && mmcm_ok;
      80            0 : }
      81              : //-----------------------------------------------------------------------------
      82              : 
      83              : //-----------------------------------------------------------------------------
      84              : void
      85            0 : GIBV2IONode::switch_sfp_tx(uint32_t sfp_id, bool turn_on) const { // NOLINT(build/unsigned)
      86            0 :         validate_sfp_id(sfp_id);
      87              : 
      88              :   // A-CLK is the 7th SFP, but is in slot 7 not 6
      89              :   // TODO make this a map dlindebaum 25/10/02
      90            0 :   sfp_id = sfp_id + (sfp_id/6);
      91              : 
      92            0 :   auto sfp_expander_1 = get_i2c_device<I2CExpanderSlave>(m_uid_i2c_bus, "SFPExpander1");
      93            0 :         uint8_t current_sfp_tx_control_flags = sfp_expander_1->read_outputs_config(1); // NOLINT(build/unsigned)
      94              : 
      95            0 :         uint8_t new_sfp_tx_control_flags; // NOLINT(build/unsigned)
      96            0 :         if (turn_on)
      97              :         {
      98            0 :                 new_sfp_tx_control_flags = current_sfp_tx_control_flags & ~(1UL << sfp_id);
      99              :         }
     100              :   else
     101              :   {
     102            0 :     new_sfp_tx_control_flags = current_sfp_tx_control_flags | (1UL << sfp_id);
     103              :   }
     104              : 
     105            0 :   sfp_expander_1->set_outputs(1, new_sfp_tx_control_flags);
     106            0 : }
     107              : //-----------------------------------------------------------------------------
     108              : 
     109              : //-----------------------------------------------------------------------------
     110              : uint8_t
     111            0 : GIBV2IONode::get_sfp_tx_disable_bitmap() const { // NOLINT(build/unsigned)
     112              :   // First 6 bits and the 8th bit are tx disable for GIBv2/3
     113            0 :   return 0x40;
     114              : }
     115              : //-----------------------------------------------------------------------------
     116              : 
     117              : //-----------------------------------------------------------------------------
     118              : uint8_t
     119            0 : GIBV2IONode::get_num_sfps() const { // NOLINT(build/unsigned)
     120              :   // 7 SFPs on GIBv2/3
     121            0 :   return 7;
     122              : }
     123              : //-----------------------------------------------------------------------------
     124              : 
     125              : } // namespace timing
     126              : } // namespace dunedaq
        

Generated by: LCOV version 2.0-1