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)
79#include <hardware/structs/sio.h>
83 return {&sio_hw->gpio_in, uint32_t(1) << pin};
87#elif defined(ARDUINO_ARCH_MBED)
92#include <drivers/DigitalIn.h>
99 return {mbed::DigitalIn {digitalPinToPinName(pin), PullUp}};
103#elif defined(ARDUINO_UNOR4_MINIMA) || defined(ARDUINO_UNOR4_WIFI)
106 bsp_io_port_pin_t
pin;
109 R_IOPORT_PinRead(NULL,
pin, &ret);
110 return ret == BSP_IO_LEVEL_LOW;
114 return {g_pin_cfg[pin].
pin};
118#warning "Unknown board. Please define the direct_pin_read function."
constexpr PinStatus_t HIGH
AH::function_traits< decltype(::digitalWrite)>::argument_t< 0 > ArduinoPin_t
DirectPinRead direct_pin_read(ArduinoPin_t pin)
#define BEGIN_CS_NAMESPACE
std::remove_cv< RegisterType >::type bitmask