Control Surface
main
MIDI Control Surface library for Arduino
Toggle main menu visibility
Loading...
Searching...
No Matches
src
AH
Hardware
Arduino-Hardware-Types.hpp
Go to the documentation of this file.
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(BOARD_HAS_PIN_REMAP) && !defined(BOARD_USES_HW_GPIO_NUMBERS)
10
#error \
11
"This library is not compatible with pin remapping. Please disable it by choosing "Tools > Pin Numbering > By GPIO number (legacy)" in the Arduino IDE. See https://github.com/espressif/arduino-esp32/issues/9150 for details"
12
#endif
13
14
#if defined(ARDUINO_API_VERSION)
15
16
using
ArduinoPin_t
= pin_size_t;
17
using
PinStatus_t
= PinStatus;
18
using
PinMode_t
= PinMode;
19
using
BitOrder_t
= BitOrder;
20
21
#else
// ARDUINO_API_VERSION
22
23
using
ArduinoPin_t
=
24
AH::function_traits
<
decltype
(::digitalWrite)>::argument_t<0>;
25
using
PinStatus_t
=
26
AH::function_traits
<
decltype
(::digitalWrite)>::argument_t<1>;
27
using
PinMode_t
=
AH::function_traits
<
decltype
(::pinMode)>::argument_t<1>;
28
29
#if defined(ARDUINO_ARCH_SAM) || defined(ARDUINO_ARCH_SAMD)
30
using
BitOrder_t
= BitOrder;
31
#else
32
using
BitOrder_t
= uint8_t;
33
#endif
34
35
namespace
AH_pin_detail
{
36
constexpr
static
auto
tmp_HIGH
=
HIGH
;
37
constexpr
static
auto
tmp_LOW
=
LOW
;
38
constexpr
static
auto
tmp_INPUT
=
INPUT
;
39
constexpr
static
auto
tmp_OUTPUT
=
OUTPUT
;
40
constexpr
static
auto
tmp_INPUT_PULLUP
=
INPUT_PULLUP
;
41
}
// namespace AH_pin_detail
42
#ifdef HIGH
43
#undef HIGH
44
#define HIGH HIGH
45
#endif
46
#ifdef LOW
47
#undef LOW
48
#define LOW LOW
49
#endif
50
#ifdef INPUT
51
#undef INPUT
52
#define INPUT INPUT
53
#endif
54
#ifdef OUTPUT
55
#undef OUTPUT
56
#define OUTPUT OUTPUT
57
#endif
58
#ifdef INPUT_PULLUP
59
#undef INPUT_PULLUP
60
#define INPUT_PULLUP INPUT_PULLUP
61
#endif
62
constexpr
PinStatus_t
HIGH
=
AH_pin_detail::tmp_HIGH
;
63
constexpr
PinStatus_t
LOW
=
AH_pin_detail::tmp_LOW
;
64
constexpr
PinMode_t
INPUT
=
AH_pin_detail::tmp_INPUT
;
65
constexpr
PinMode_t
OUTPUT
=
AH_pin_detail::tmp_OUTPUT
;
66
constexpr
PinMode_t
INPUT_PULLUP
=
AH_pin_detail::tmp_INPUT_PULLUP
;
67
68
#endif
// ARDUINO_API_VERSION
69
70
BEGIN_AH_NAMESPACE
71
72
template
<
class
T>
73
constexpr
ArduinoPin_t
arduino_pin_cast
(T t) {
74
return
static_cast<
ArduinoPin_t
>
(t);
75
}
76
constexpr
ArduinoPin_t
arduino_pin_cast
(
pin_t
t) {
return
t.
pin
; }
77
#if (defined(NOT_AN_INTERRUPT) || defined(ARDUINO_API_VERSION)) && \
78
!defined(ARDUINO_ARCH_RENESAS)
79
using
not_an_interrupt_t =
decltype
(NOT_AN_INTERRUPT);
81
using
interrupt_t =
82
std::conditional<std::is_enum<not_an_interrupt_t>::value,
83
std::underlying_type<not_an_interrupt_t>,
84
type_identity<not_an_interrupt_t>>::type::type;
85
#endif
86
87
END_AH_NAMESPACE
END_AH_NAMESPACE
#define END_AH_NAMESPACE
Definition
AH/Settings/NamespaceSettings.hpp:14
BEGIN_AH_NAMESPACE
#define BEGIN_AH_NAMESPACE
Definition
AH/Settings/NamespaceSettings.hpp:11
LOW
constexpr PinStatus_t LOW
Definition
Arduino-Hardware-Types.hpp:63
INPUT
constexpr PinMode_t INPUT
Definition
Arduino-Hardware-Types.hpp:64
BitOrder_t
uint8_t BitOrder_t
Definition
Arduino-Hardware-Types.hpp:32
HIGH
constexpr PinStatus_t HIGH
Definition
Arduino-Hardware-Types.hpp:62
ArduinoPin_t
AH::function_traits< decltype(::digitalWrite)>::argument_t< 0 > ArduinoPin_t
Definition
Arduino-Hardware-Types.hpp:23
PinMode_t
AH::function_traits< decltype(::pinMode)>::argument_t< 1 > PinMode_t
Definition
Arduino-Hardware-Types.hpp:27
PinStatus_t
AH::function_traits< decltype(::digitalWrite)>::argument_t< 1 > PinStatus_t
Definition
Arduino-Hardware-Types.hpp:25
INPUT_PULLUP
constexpr PinMode_t INPUT_PULLUP
Definition
Arduino-Hardware-Types.hpp:66
OUTPUT
constexpr PinMode_t OUTPUT
Definition
Arduino-Hardware-Types.hpp:65
Arduino-Wrapper.h
FunctionTraits.hpp
Hardware-Types.hpp
AH_pin_detail
Definition
Arduino-Hardware-Types.hpp:35
AH_pin_detail::tmp_INPUT
static constexpr auto tmp_INPUT
Definition
Arduino-Hardware-Types.hpp:38
AH_pin_detail::tmp_HIGH
static constexpr auto tmp_HIGH
Definition
Arduino-Hardware-Types.hpp:36
AH_pin_detail::tmp_OUTPUT
static constexpr auto tmp_OUTPUT
Definition
Arduino-Hardware-Types.hpp:39
AH_pin_detail::tmp_LOW
static constexpr auto tmp_LOW
Definition
Arduino-Hardware-Types.hpp:37
AH_pin_detail::tmp_INPUT_PULLUP
static constexpr auto tmp_INPUT_PULLUP
Definition
Arduino-Hardware-Types.hpp:40
AH::arduino_pin_cast
constexpr ArduinoPin_t arduino_pin_cast(T t)
Definition
Arduino-Hardware-Types.hpp:73
AH::function_traits
Definition
FunctionTraits.hpp:11
pin_t
Type for storing pin numbers of Extended Input/Output elements.
Definition
Hardware-Types.hpp:25
pin_t::pin
pin_int_t pin
The actual underlying pin number.
Definition
Hardware-Types.hpp:32
Generated by
1.17.0