Speeduino
Loading...
Searching...
No Matches
port_pin.h
Go to the documentation of this file.
1#pragma once
2
3#include <Arduino.h>
4
6// Automatic type deduction
7namespace type_detection_detail {
8 // These are used for automatic type detection *at compile time* and are never executed.
9
10 // Get the return type of a function call
11 template <typename R, typename... Args> R return_type_of(R(*)(Args...));
12
13 // portOutputRegister() and digitalPinToBitMask() on AVR is a GCC return expression, which needs to
14 // be wrapped in a function to be used in this context.
15 static inline auto detectPortRegisterType(void) { return portOutputRegister(digitalPinToPort(0)); };
16 static inline auto detectDigitalPinToBitMask(void) { return digitalPinToBitMask(0); };
17}
19
23{
25 using port_register_t = decltype(type_detection_detail::return_type_of(&type_detection_detail::detectPortRegisterType));
26
28 using pin_mask_t = decltype(type_detection_detail::return_type_of(&type_detection_detail::detectDigitalPinToBitMask));
29
30 static constexpr port_register_t NULL_PORT = {nullptr};
31
34
36 bool isValid(void) const
37 {
39 }
40};
41
static TIntegral readSerialIntegralTimeout(void)
Reads an integral type, timing out if necessary.
Definition comms.cpp:175
A structure to support direct port manipulation.
Definition port_pin.h:23
pin_mask_t mask
Definition port_pin.h:33
decltype(type_detection_detail::return_type_of(&type_detection_detail::detectDigitalPinToBitMask)) pin_mask_t
The return type of a "call" to digitalPinToBitMask()
Definition port_pin.h:28
bool isValid(void) const
Is the port register initialised?
Definition port_pin.h:36
port_register_t port
Definition port_pin.h:32
decltype(type_detection_detail::return_type_of(&type_detection_detail::detectPortRegisterType)) port_register_t
The return type of a "call" to portOutputRegister()
Definition port_pin.h:25
static constexpr port_register_t NULL_PORT
Definition port_pin.h:30