From 8965473452268f3028f0e3037d599a53399143f2 Mon Sep 17 00:00:00 2001 From: Pieter Pas Date: Mon, 4 Nov 2024 20:24:29 +0100 Subject: [PATCH 1/2] Add interrupt_t --- src/AH/Hardware/Arduino-Hardware-Types.hpp | 11 +++++++++++ src/AH/STL/type_traits | 9 ++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/AH/Hardware/Arduino-Hardware-Types.hpp b/src/AH/Hardware/Arduino-Hardware-Types.hpp index 46e09187ce..9c1195051c 100644 --- a/src/AH/Hardware/Arduino-Hardware-Types.hpp +++ b/src/AH/Hardware/Arduino-Hardware-Types.hpp @@ -4,6 +4,7 @@ #include #include // pin functions and constants +#include #if defined(ARDUINO_API_VERSION) @@ -62,9 +63,19 @@ constexpr PinMode_t INPUT_PULLUP = AH_pin_detail::tmp_INPUT_PULLUP; #endif // ARDUINO_API_VERSION BEGIN_AH_NAMESPACE + template constexpr ArduinoPin_t arduino_pin_cast(T t) { return static_cast(t); } constexpr ArduinoPin_t arduino_pin_cast(pin_t t) { return t.pin; } +#ifdef NOT_AN_INTERRUPT +using not_an_interrupt_t = decltype(NOT_AN_INTERRUPT); +/// Type of interrupt indices (result of digitalPinToInterrupt). +using interrupt_t = + std::conditional::value, + std::underlying_type, + type_identity>::type::type; +#endif + END_AH_NAMESPACE diff --git a/src/AH/STL/type_traits b/src/AH/STL/type_traits index 4b8bfb5d2c..1e0e76dfa2 100644 --- a/src/AH/STL/type_traits +++ b/src/AH/STL/type_traits @@ -16,4 +16,11 @@ using enable_if_t = typename enable_if::type; #endif -} // namespace std \ No newline at end of file +} // namespace std + +BEGIN_AH_NAMESPACE +template +struct type_identity { + using type = T; +}; +END_AH_NAMESPACE \ No newline at end of file From 4ded80ebbcf1f6e243b21325b88c123c6b8589fd Mon Sep 17 00:00:00 2001 From: Pieter Pas Date: Sat, 9 Nov 2024 15:09:30 +0100 Subject: [PATCH 2/2] Define interrupt_t for SAMD --- src/AH/Hardware/Arduino-Hardware-Types.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/AH/Hardware/Arduino-Hardware-Types.hpp b/src/AH/Hardware/Arduino-Hardware-Types.hpp index 9c1195051c..e0c7dec6b4 100644 --- a/src/AH/Hardware/Arduino-Hardware-Types.hpp +++ b/src/AH/Hardware/Arduino-Hardware-Types.hpp @@ -69,7 +69,8 @@ constexpr ArduinoPin_t arduino_pin_cast(T t) { return static_cast(t); } constexpr ArduinoPin_t arduino_pin_cast(pin_t t) { return t.pin; } -#ifdef NOT_AN_INTERRUPT +#if (defined(NOT_AN_INTERRUPT) || defined(ARDUINO_API_VERSION)) && \ + !defined(ARDUINO_ARCH_RENESAS) using not_an_interrupt_t = decltype(NOT_AN_INTERRUPT); /// Type of interrupt indices (result of digitalPinToInterrupt). using interrupt_t =