LCOV - code coverage report
Current view: top level - src/AH/Hardware/ExtendedInputOutput - ExtendedIOElement.cpp (source / functions) Hit Total Coverage
Test: 00f463b534fbea22f0b596e091a60715679e3064 Lines: 25 25 100.0 %
Date: 2024-11-03 16:33:35 Functions: 10 10 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : #include "ExtendedIOElement.hpp"
       2             : #include <AH/Error/Error.hpp>
       3             : #include <AH/STL/type_traits> // is_unsigned
       4             : 
       5             : BEGIN_AH_NAMESPACE
       6             : 
       7          48 : ExtendedIOElement::ExtendedIOElement(pin_t length)
       8          48 :     : length(length), start(offset), end(offset + length) {
       9          48 :     if (end < start)
      10           1 :         FATAL_ERROR(F("ExtIO ran out of pin numbers. "
      11             :                       "Dynamically creating new ExtendedIOElements is not "
      12             :                       "recommended."),
      13             :                     0x00FF);
      14          47 :     offset = end;
      15          48 : }
      16             : 
      17          10 : void ExtendedIOElement::beginAll() {
      18          10 :     ExtendedIOElement::applyToAll(&ExtendedIOElement::begin);
      19          10 : }
      20             : 
      21           1 : void ExtendedIOElement::updateAllBufferedOutputs() {
      22           1 :     ExtendedIOElement::applyToAll(&ExtendedIOElement::updateBufferedOutputs);
      23           1 : }
      24             : 
      25           1 : void ExtendedIOElement::updateAllBufferedInputs() {
      26           1 :     ExtendedIOElement::applyToAll(&ExtendedIOElement::updateBufferedInputs);
      27           1 : }
      28             : 
      29          72 : pin_t ExtendedIOElement::pin(pin_t p) const {
      30          72 :     if (p >= length) {
      31             :         static_assert(std::is_unsigned<pin_t>::value,
      32             :                       "Error: pin_t should be an unsigned integer type");
      33           2 :         ERROR(F("Error: the pin number (")
      34             :                   << p
      35             :                   << F(") is greater than the number of pins of this "
      36             :                        "ExtendedIOElement (")
      37             :                   << length << ')',
      38             :               0x4567);
      39             :         return end - 1; // LCOV_EXCL_LINE
      40             :     }
      41          70 :     return p + start;
      42             : }
      43             : 
      44           1 : pin_t ExtendedIOElement::operator[](pin_t p) const { return pin(p); }
      45             : 
      46           1 : pin_t ExtendedIOElement::getLength() const { return length; }
      47             : 
      48          90 : pin_t ExtendedIOElement::getEnd() const { return end; }
      49             : 
      50         259 : pin_t ExtendedIOElement::getStart() const { return start; }
      51             : 
      52          80 : DoublyLinkedList<ExtendedIOElement> &ExtendedIOElement::getAll() {
      53          80 :     return updatables;
      54             : }
      55             : 
      56             : pin_t ExtendedIOElement::offset = NUM_DIGITAL_PINS + NUM_ANALOG_INPUTS;
      57             : 
      58             : END_AH_NAMESPACE

Generated by: LCOV version 1.15