LCOV - code coverage report
Current view: top level - src/AH/Hardware/ExtendedInputOutput - ExtendedInputOutput.hpp (source / functions) Hit Total Coverage
Test: 3a807a259ebe0769dd942f7f612dca5273937539 Lines: 2 2 100.0 %
Date: 2024-03-24 17:16:54 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* ✔ */
       2             : 
       3             : #pragma once
       4             : 
       5             : #include <AH/Hardware/Arduino-Hardware-Types.hpp>
       6             : #include <AH/STL/climits>
       7             : #include <AH/Settings/NamespaceSettings.hpp>
       8             : 
       9             : BEGIN_AH_NAMESPACE
      10             : 
      11             : class ExtendedIOElement;
      12             : 
      13             : /**
      14             :  * @brief   A namespace with alternatives to the standard Arduino IO functions
      15             :  *          that can be used with extended IO pin numbers.
      16             :  */
      17             : namespace ExtIO {
      18             : 
      19             : /// @addtogroup AH_ExtIO
      20             : /// @{
      21             : 
      22             : /// Check if the given pin number is a real Arduino pin number, and not an ExtIO 
      23             : /// pin number.
      24         714 : inline bool isNativePin(pin_t pin) {
      25         714 :     return pin < NUM_DIGITAL_PINS + NUM_ANALOG_INPUTS;
      26             : }
      27             : 
      28             : /**
      29             :  * @brief   Find the IO element of a given extended IO pin number. 
      30             :  * 
      31             :  * @param   pin
      32             :  *          The extended IO pin number to find the IO element of.
      33             :  * @return  A pointer to the extended IO element that the given pin belongs to.
      34             :  */
      35             : ExtendedIOElement *getIOElementOfPinOrNull(pin_t pin);
      36             : /// @copydoc getIOElementOfPinOrNull
      37             : /// Throws an error if the element was not found.
      38             : ExtendedIOElement *getIOElementOfPin(pin_t pin);
      39             : 
      40             : /// An ExtIO version of the Arduino function
      41             : /// @see    ExtendedIOElement::pinMode
      42             : void pinMode(pin_t pin, PinMode_t mode);
      43             : /// Overload to Arduino pinMode function.
      44             : void pinMode(int pin, PinMode_t mode);
      45             : /// An ExtIO version of the Arduino function
      46             : /// @see    ExtendedIOElement::digitalWrite
      47             : void digitalWrite(pin_t pin, PinStatus_t val);
      48             : /// Overload to Arduino digitalWrite function.
      49             : void digitalWrite(int pin, PinStatus_t val);
      50             : /// An ExtIO version of the Arduino function
      51             : /// @see    ExtendedIOElement::digitalRead
      52             : PinStatus_t digitalRead(pin_t pin);
      53             : /// Overload to Arduino digitalRead function.
      54             : PinStatus_t digitalRead(int pin);
      55             : 
      56             : /// An ExtIO version of the Arduino function
      57             : /// @see    ExtendedIOElement::analogRead
      58             : analog_t analogRead(pin_t pin);
      59             : /// Overload to Arduino analogRead function.
      60             : analog_t analogRead(int pin);
      61             : /// An ExtIO version of the Arduino function
      62             : /// @see    ExtendedIOElement::analogWrite
      63             : void analogWrite(pin_t pin, analog_t val);
      64             : /// An ExtIO version of the Arduino function
      65             : /// @see    ExtendedIOElement::analogWrite
      66             : void analogWrite(pin_t pin, int val);
      67             : #ifndef ESP32
      68             : /// Overload to Arduino analogWrite function.
      69             : void analogWrite(int pin, analog_t val);
      70             : /// Overload to Arduino analogWrite function.
      71             : void analogWrite(int pin, int val);
      72             : #endif
      73             : 
      74             : /// An ExtIO version of the Arduino function
      75             : void shiftOut(pin_t dataPin, pin_t clockPin, BitOrder_t bitOrder, uint8_t val);
      76             : /// Overload to Arduino shiftOut function
      77             : void shiftOut(int dataPin, int clockPin, BitOrder_t bitOrder, uint8_t val);
      78             : 
      79             : /// A buffered ExtIO version of the Arduino function
      80             : /// @see   ExtendedIOElement::pinModeBuffered
      81             : void pinModeBuffered(pin_t pin, PinMode_t mode);
      82             : /// A buffered ExtIO version of the Arduino function
      83             : /// @see   ExtendedIOElement::digitalWriteBuffered
      84             : void digitalWriteBuffered(pin_t pin, PinStatus_t val);
      85             : /// A buffered ExtIO version of the Arduino function
      86             : /// @see   ExtendedIOElement::digitalReadBuffered
      87             : PinStatus_t digitalReadBuffered(pin_t pin);
      88             : 
      89             : /// A buffered ExtIO version of the Arduino function
      90             : /// @see   ExtendedIOElement::analogReadBuffered
      91             : analog_t analogReadBuffered(pin_t pin);
      92             : /// A buffered ExtIO version of the Arduino function
      93             : /// @see   ExtendedIOElement::analogWriteBuffered
      94             : void analogWriteBuffered(pin_t pin, analog_t val);
      95             : /// A buffered ExtIO version of the Arduino function
      96             : /// @see   ExtendedIOElement::analogWriteBuffered
      97             : void analogWriteBuffered(pin_t pin, int val);
      98             : 
      99             : #if UINT16_MAX != UINT_MAX
     100             : /// Overload to Arduino pinMode function.
     101             : void pinMode(unsigned int pin, PinMode_t mode);
     102             : /// Overload to Arduino digitalWrite function.
     103             : void digitalWrite(unsigned int pin, PinStatus_t val);
     104             : /// Overload to Arduino digitalRead function.
     105             : PinStatus_t digitalRead(unsigned int pin);
     106             : 
     107             : /// Overload to Arduino analogRead function.
     108             : analog_t analogRead(unsigned int pin);
     109             : #ifndef ESP32
     110             : /// Overload to Arduino analogWrite function.
     111             : void analogWrite(unsigned int pin, analog_t val);
     112             : /// Overload to Arduino analogWrite function.
     113             : void analogWrite(unsigned int pin, int val);
     114             : #endif
     115             : 
     116             : /// Overload to Arduino shiftOut function
     117             : void shiftOut(unsigned int dataPin, unsigned int clockPin, BitOrder_t bitOrder,
     118             :               uint8_t val);
     119             : #endif
     120             : 
     121             : /// @}
     122             : 
     123             : } // namespace ExtIO
     124             : 
     125             : END_AH_NAMESPACE

Generated by: LCOV version 1.15