LCOV - code coverage report
Current view: top level - src/AH/Hardware/ExtendedInputOutput - ExtendedIOElement.cpp (source / functions) Hit Total Coverage
Test: 169c36a3797bc662d84b5726f34a3f37d3c58247 Lines: 25 25 100.0 %
Date: 2024-11-09 15:32:27 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_int_t length)
       8          48 :     : length(length), start(offset), end(offset + length) {
       9          48 :     if (end > NO_PIN)
      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_int_t p) const {
      30          72 :     if (p >= length) {
      31             :         static_assert(!std::is_integral<pin_t>::value ||
      32             :                           std::is_unsigned<pin_t>::value,
      33             :                       "Error: pin_t should be an unsigned integer type");
      34           2 :         ERROR(F("Error: the pin number (")
      35             :                   << p
      36             :                   << F(") is greater than the number of pins of this "
      37             :                        "ExtendedIOElement (")
      38             :                   << length << ')',
      39             :               0x4567);
      40             :         return end - 1; // LCOV_EXCL_LINE
      41             :     }
      42          70 :     return p + start;
      43             : }
      44             : 
      45           1 : pin_t ExtendedIOElement::operator[](pin_int_t p) const { return pin(p); }
      46             : 
      47           1 : pin_int_t ExtendedIOElement::getLength() const { return length; }
      48             : 
      49          90 : pin_t ExtendedIOElement::getEnd() const { return end; }
      50             : 
      51         259 : pin_t ExtendedIOElement::getStart() const { return start; }
      52             : 
      53          80 : DoublyLinkedList<ExtendedIOElement> &ExtendedIOElement::getAll() {
      54          80 :     return updatables;
      55             : }
      56             : 
      57             : pin_t ExtendedIOElement::offset = NUM_DIGITAL_PINS + NUM_ANALOG_INPUTS;
      58             : 
      59             : END_AH_NAMESPACE

Generated by: LCOV version 1.15