4#include <Settings/NamespaceSettings.hpp>
6#include <AH/STL/type_traits>
9#ifdef ARDUINO_ARCH_NRF52840
10#include <pins_arduino.h>
15template <
class RegisterType = const volatile u
int32_t>
18 typename std::remove_cv<RegisterType>::type
bitmask;
23#if defined(__AVR__) || \
24 (defined(TEENSYDUINO) && (defined(KINETISK) || defined(KINETISL)))
28 return {portInputRegister(digitalPinToPort(pin)),
29 static_cast<uint8_t
>(digitalPinToBitMask(pin))};
33#elif defined(__SAM3X8E__) || defined(ESP32) || defined(ESP8266) || \
38 return {portInputRegister(digitalPinToPort(pin)), digitalPinToBitMask(pin)};
42#elif defined(__SAMD21G18A__) || defined(__SAMD21E18A__)
46 return {portModeRegister(digitalPinToPort(pin)) + 8,
47 static_cast<uint32_t
>(digitalPinToBitMask(pin))};
51#elif defined(__IMXRT1052__) || defined(__IMXRT1062__)
55 return {portOutputRegister(pin), digitalPinToBitMask(pin)};
59#elif defined(RBL_NRF51822) || defined(ARDUINO_ARCH_NRF52840)
63 bool read()
const {
return nrf_gpio_pin_read(
pin); }
66#if defined(RBL_NRF51822)
67 return {
static_cast<uint32_t
>(pin)};
68#elif defined(ARDUINO_ARCH_NRF52840)
69 return {
static_cast<uint32_t
>(digitalPinToPinName(pin))};
71#error "Unknown Nordic board"
76#elif defined(ARDUINO_ARCH_RP2040)
78#include <hardware/structs/sio.h>
81 return {&sio_hw->gpio_in, uint32_t(1) << pin};
85#elif defined(ARDUINO_ARCH_MBED)
87#include <drivers/DigitalIn.h>
90 bool read()
const {
return pin.read(); }
93 return {mbed::DigitalIn {digitalPinToPinName(pin), PullUp}};
97#warning "Unknown board. Please define the direct_pin_read function."
constexpr PinStatus_t HIGH
DirectPinRead direct_pin_read(uint8_t pin)
#define BEGIN_CS_NAMESPACE
PinStatus_t digitalRead(pin_t pin)
An ExtIO version of the Arduino function.
uint16_t pin_t
The type for Arduino pins (and ExtendedIOElement pins).
std::remove_cv< RegisterType >::type bitmask