LCOV - code coverage report
Current view: top level - src/AH/Hardware - Arduino-Hardware-Types.hpp (source / functions) Hit Total Coverage
Test: 169c36a3797bc662d84b5726f34a3f37d3c58247 Lines: 3 3 100.0 %
Date: 2024-11-09 15:32:27 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include <AH/Hardware/Hardware-Types.hpp>
       4             : #include <AH/Types/FunctionTraits.hpp>
       5             : 
       6             : #include <AH/Arduino-Wrapper.h> // pin functions and constants
       7             : #include <AH/STL/type_traits>
       8             : 
       9             : #if defined(ARDUINO_API_VERSION)
      10             : 
      11             : using ArduinoPin_t = pin_size_t;
      12             : using PinStatus_t = PinStatus;
      13             : using PinMode_t = PinMode;
      14             : using BitOrder_t = BitOrder;
      15             : 
      16             : #else // ARDUINO_API_VERSION
      17             : 
      18             : using ArduinoPin_t =
      19             :     AH::function_traits<decltype(::digitalWrite)>::argument_t<0>;
      20             : using PinStatus_t =
      21             :     AH::function_traits<decltype(::digitalWrite)>::argument_t<1>;
      22             : using PinMode_t = AH::function_traits<decltype(::pinMode)>::argument_t<1>;
      23             : 
      24             : #if defined(ARDUINO_ARCH_SAM) || defined(ARDUINO_ARCH_SAMD)
      25             : using BitOrder_t = BitOrder;
      26             : #else
      27             : using BitOrder_t = uint8_t;
      28             : #endif
      29             : 
      30             : namespace AH_pin_detail {
      31             : constexpr static auto tmp_HIGH = HIGH;
      32             : constexpr static auto tmp_LOW = LOW;
      33             : constexpr static auto tmp_INPUT = INPUT;
      34             : constexpr static auto tmp_OUTPUT = OUTPUT;
      35             : constexpr static auto tmp_INPUT_PULLUP = INPUT_PULLUP;
      36             : } // namespace AH_pin_detail
      37             : #ifdef HIGH
      38             : #undef HIGH
      39             : #define HIGH HIGH
      40             : #endif
      41             : #ifdef LOW
      42             : #undef LOW
      43             : #define LOW LOW
      44             : #endif
      45             : #ifdef INPUT
      46             : #undef INPUT
      47             : #define INPUT INPUT
      48             : #endif
      49             : #ifdef OUTPUT
      50             : #undef OUTPUT
      51             : #define OUTPUT OUTPUT
      52             : #endif
      53             : #ifdef INPUT_PULLUP
      54             : #undef INPUT_PULLUP
      55             : #define INPUT_PULLUP INPUT_PULLUP
      56             : #endif
      57             : constexpr PinStatus_t HIGH = AH_pin_detail::tmp_HIGH;
      58             : constexpr PinStatus_t LOW = AH_pin_detail::tmp_LOW;
      59             : constexpr PinMode_t INPUT = AH_pin_detail::tmp_INPUT;
      60             : constexpr PinMode_t OUTPUT = AH_pin_detail::tmp_OUTPUT;
      61             : constexpr PinMode_t INPUT_PULLUP = AH_pin_detail::tmp_INPUT_PULLUP;
      62             : 
      63             : #endif // ARDUINO_API_VERSION
      64             : 
      65             : BEGIN_AH_NAMESPACE
      66             : 
      67             : template <class T>
      68          34 : constexpr ArduinoPin_t arduino_pin_cast(T t) {
      69          34 :     return static_cast<ArduinoPin_t>(t);
      70             : }
      71         756 : constexpr ArduinoPin_t arduino_pin_cast(pin_t t) { return t.pin; }
      72             : #if (defined(NOT_AN_INTERRUPT) || defined(ARDUINO_API_VERSION)) &&             \
      73             :     !defined(ARDUINO_ARCH_RENESAS)
      74             : using not_an_interrupt_t = decltype(NOT_AN_INTERRUPT);
      75             : /// Type of interrupt indices (result of digitalPinToInterrupt).
      76             : using interrupt_t =
      77             :     std::conditional<std::is_enum<not_an_interrupt_t>::value,
      78             :                      std::underlying_type<not_an_interrupt_t>,
      79             :                      type_identity<not_an_interrupt_t>>::type::type;
      80             : #endif
      81             : 
      82             : END_AH_NAMESPACE

Generated by: LCOV version 1.15