Implement empty/unused pin and port
This commit is contained in:
parent
37b8f77fd3
commit
d89322bdaa
28
io.hpp
28
io.hpp
@ -102,6 +102,8 @@ enum class P {
|
||||
D6 = 0x36,
|
||||
D7 = 0x37,
|
||||
#endif
|
||||
|
||||
NONE,
|
||||
};
|
||||
|
||||
enum class Bus {
|
||||
@ -117,6 +119,8 @@ enum class Bus {
|
||||
#ifdef PORT_D_AVAILABLE
|
||||
D = 0x03,
|
||||
#endif
|
||||
|
||||
NONE,
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@ -299,6 +303,7 @@ class Pin {
|
||||
|
||||
[[gnu::always_inline]] static inline void dir(const Dir dir)
|
||||
{
|
||||
if constexpr (pin != P::NONE) {
|
||||
constexpr auto bus = detail::getBus(pin);
|
||||
constexpr auto pinBit = detail::getPinBit(pin);
|
||||
|
||||
@ -309,9 +314,11 @@ class Pin {
|
||||
else if (dir == Dir::OUT)
|
||||
*dirRegPtr |= (1 << pinBit);
|
||||
}
|
||||
}
|
||||
|
||||
[[gnu::always_inline]] static inline void pullup(const bool enable)
|
||||
{
|
||||
if constexpr (pin != P::NONE) {
|
||||
constexpr auto bus = detail::getBus(pin);
|
||||
constexpr auto pinBit = detail::getPinBit(pin);
|
||||
|
||||
@ -322,9 +329,11 @@ class Pin {
|
||||
else
|
||||
*portRegPtr &= ~(1 << pinBit);
|
||||
}
|
||||
}
|
||||
|
||||
[[gnu::always_inline]] static inline void write(const bool value)
|
||||
{
|
||||
if constexpr (pin != P::NONE) {
|
||||
constexpr auto bus = detail::getBus(pin);
|
||||
constexpr auto pinBit = detail::getPinBit(pin);
|
||||
|
||||
@ -335,9 +344,11 @@ class Pin {
|
||||
else
|
||||
*portRegPtr &= ~(1 << pinBit);
|
||||
}
|
||||
}
|
||||
|
||||
[[gnu::always_inline]] static inline void toggle()
|
||||
{
|
||||
if constexpr (pin != P::NONE) {
|
||||
constexpr auto bus = detail::getBus(pin);
|
||||
constexpr auto pinBit = detail::getPinBit(pin);
|
||||
|
||||
@ -349,9 +360,11 @@ class Pin {
|
||||
*portRegPtr ^= (1 << pinBit);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
[[gnu::always_inline]] static inline bool read()
|
||||
{
|
||||
if constexpr (pin != P::NONE) {
|
||||
constexpr auto bus = detail::getBus(pin);
|
||||
constexpr auto pinBit = detail::getPinBit(pin);
|
||||
|
||||
@ -359,7 +372,7 @@ class Pin {
|
||||
|
||||
if (*pinRegPtr >> pinBit & 1)
|
||||
return true;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -392,6 +405,7 @@ class Port {
|
||||
|
||||
[[gnu::always_inline]] static inline void dir(const Dir dir)
|
||||
{
|
||||
if constexpr (port != Bus::NONE) {
|
||||
detail::reg_ptr_t dirRegPtr = detail::getRegPtr<detail::getDDR(port)>();
|
||||
|
||||
if (dir == Dir::IN)
|
||||
@ -399,9 +413,11 @@ class Port {
|
||||
else if (dir == Dir::OUT)
|
||||
*dirRegPtr = 0xFF;
|
||||
}
|
||||
}
|
||||
|
||||
[[gnu::always_inline]] static inline void pullup(const bool enable)
|
||||
{
|
||||
if constexpr (port != Bus::NONE) {
|
||||
detail::reg_ptr_t portRegPtr = detail::getRegPtr<detail::getPORT(port)>();
|
||||
|
||||
if (enable)
|
||||
@ -409,15 +425,19 @@ class Port {
|
||||
else
|
||||
*portRegPtr = 0x00;
|
||||
}
|
||||
}
|
||||
|
||||
[[gnu::always_inline]] static inline void write(const uint8_t value)
|
||||
[[gnu::always_inline]] static inline void write([[maybe_unused]] const uint8_t value)
|
||||
{
|
||||
if constexpr (port != Bus::NONE) {
|
||||
detail::reg_ptr_t portRegPtr = detail::getRegPtr<detail::getPORT(port)>();
|
||||
*portRegPtr = value;
|
||||
}
|
||||
}
|
||||
|
||||
[[gnu::always_inline]] static inline void invert()
|
||||
{
|
||||
if constexpr (port != Bus::NONE) {
|
||||
#ifdef HARDWARE_TOGGLE
|
||||
detail::reg_ptr_t pinRegPtr = detail::getRegPtr<detail::getPIN(port)>();
|
||||
*pinRegPtr = 0xFF;
|
||||
@ -426,13 +446,17 @@ class Port {
|
||||
*portRegPtr = ~(*portRegPtr);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
[[gnu::always_inline]] static inline uint8_t read()
|
||||
{
|
||||
if constexpr (port != Bus::NONE) {
|
||||
detail::reg_ptr_t pinRegPtr = detail::getRegPtr<detail::getPIN(port)>();
|
||||
|
||||
return *pinRegPtr;
|
||||
}
|
||||
return 0x00;
|
||||
}
|
||||
|
||||
[[gnu::always_inline]] inline Port &operator=(const uint8_t value)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user