Fix volatile compound assignments being deprecated in C++20
This commit is contained in:
parent
d89322bdaa
commit
bf94ebaac1
45
io.hpp
45
io.hpp
@ -188,14 +188,14 @@ static constexpr uintptr_t PORT_D_INPUT_REG_ADDR = 0;
|
|||||||
static constexpr auto getBus(const P pin)
|
static constexpr auto getBus(const P pin)
|
||||||
{
|
{
|
||||||
// Upper 4 bits of pin encode which port this pin is on
|
// Upper 4 bits of pin encode which port this pin is on
|
||||||
uint8_t port = static_cast<uint8_t>(pin) >> 4 & 0x0F;
|
const auto port = static_cast<uint8_t>(pin) >> 4 & 0x0F;
|
||||||
return static_cast<Bus>(port);
|
return static_cast<Bus>(port);
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr auto getPinBit(const P pin)
|
static constexpr auto getPinBit(const P pin)
|
||||||
{
|
{
|
||||||
// Lower 4 bits of pin encode which pin bit it is
|
// Lower 4 bits of pin encode which pin bit it is
|
||||||
uint8_t pinBit = static_cast<uint8_t>(pin) & 0x0F;
|
const auto pinBit = static_cast<uint8_t>(pin) & 0x0F;
|
||||||
return pinBit;
|
return pinBit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,12 +307,12 @@ class Pin {
|
|||||||
constexpr auto bus = detail::getBus(pin);
|
constexpr auto bus = detail::getBus(pin);
|
||||||
constexpr auto pinBit = detail::getPinBit(pin);
|
constexpr auto pinBit = detail::getPinBit(pin);
|
||||||
|
|
||||||
detail::reg_ptr_t dirRegPtr = detail::getRegPtr<detail::getDDR(bus)>();
|
auto dirRegPtr = detail::getRegPtr<detail::getDDR(bus)>();
|
||||||
|
|
||||||
if (dir == Dir::IN)
|
if (dir == Dir::IN)
|
||||||
*dirRegPtr &= ~(1 << pinBit);
|
*dirRegPtr = *dirRegPtr & ~(1 << pinBit);
|
||||||
else if (dir == Dir::OUT)
|
else if (dir == Dir::OUT)
|
||||||
*dirRegPtr |= (1 << pinBit);
|
*dirRegPtr = *dirRegPtr | (1 << pinBit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -322,12 +322,12 @@ class Pin {
|
|||||||
constexpr auto bus = detail::getBus(pin);
|
constexpr auto bus = detail::getBus(pin);
|
||||||
constexpr auto pinBit = detail::getPinBit(pin);
|
constexpr auto pinBit = detail::getPinBit(pin);
|
||||||
|
|
||||||
detail::reg_ptr_t portRegPtr = detail::getRegPtr<detail::getPORT(bus)>();
|
auto portRegPtr = detail::getRegPtr<detail::getPORT(bus)>();
|
||||||
|
|
||||||
if (enable)
|
if (enable)
|
||||||
*portRegPtr |= (1 << pinBit);
|
*portRegPtr = *portRegPtr | (1 << pinBit);
|
||||||
else
|
else
|
||||||
*portRegPtr &= ~(1 << pinBit);
|
*portRegPtr = *portRegPtr & ~(1 << pinBit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,12 +337,12 @@ class Pin {
|
|||||||
constexpr auto bus = detail::getBus(pin);
|
constexpr auto bus = detail::getBus(pin);
|
||||||
constexpr auto pinBit = detail::getPinBit(pin);
|
constexpr auto pinBit = detail::getPinBit(pin);
|
||||||
|
|
||||||
detail::reg_ptr_t portRegPtr = detail::getRegPtr<detail::getPORT(bus)>();
|
auto portRegPtr = detail::getRegPtr<detail::getPORT(bus)>();
|
||||||
|
|
||||||
if (value)
|
if (value)
|
||||||
*portRegPtr |= (1 << pinBit);
|
*portRegPtr = *portRegPtr | (1 << pinBit);
|
||||||
else
|
else
|
||||||
*portRegPtr &= ~(1 << pinBit);
|
*portRegPtr = *portRegPtr & ~(1 << pinBit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -353,11 +353,11 @@ class Pin {
|
|||||||
constexpr auto pinBit = detail::getPinBit(pin);
|
constexpr auto pinBit = detail::getPinBit(pin);
|
||||||
|
|
||||||
#ifdef HARDWARE_TOGGLE
|
#ifdef HARDWARE_TOGGLE
|
||||||
detail::reg_ptr_t pinRegPtr = detail::getRegPtr<detail::getPIN(bus)>();
|
auto pinRegPtr = detail::getRegPtr<detail::getPIN(bus)>();
|
||||||
*pinRegPtr |= (1 << pinBit);
|
*pinRegPtr = *pinRegPtr | (1 << pinBit);
|
||||||
#else
|
#else
|
||||||
detail::reg_ptr_t portRegPtr = detail::getRegPtr<detail::getPORT(bus)>();
|
auto portRegPtr = detail::getRegPtr<detail::getPORT(bus)>();
|
||||||
*portRegPtr ^= (1 << pinBit);
|
*portRegPtr = *portRegPtr ^ (1 << pinBit);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -368,7 +368,7 @@ class Pin {
|
|||||||
constexpr auto bus = detail::getBus(pin);
|
constexpr auto bus = detail::getBus(pin);
|
||||||
constexpr auto pinBit = detail::getPinBit(pin);
|
constexpr auto pinBit = detail::getPinBit(pin);
|
||||||
|
|
||||||
detail::reg_ptr_t pinRegPtr = detail::getRegPtr<detail::getPIN(bus)>();
|
auto pinRegPtr = detail::getRegPtr<detail::getPIN(bus)>();
|
||||||
|
|
||||||
if (*pinRegPtr >> pinBit & 1)
|
if (*pinRegPtr >> pinBit & 1)
|
||||||
return true;
|
return true;
|
||||||
@ -406,7 +406,7 @@ class Port {
|
|||||||
[[gnu::always_inline]] static inline void dir(const Dir dir)
|
[[gnu::always_inline]] static inline void dir(const Dir dir)
|
||||||
{
|
{
|
||||||
if constexpr (port != Bus::NONE) {
|
if constexpr (port != Bus::NONE) {
|
||||||
detail::reg_ptr_t dirRegPtr = detail::getRegPtr<detail::getDDR(port)>();
|
auto dirRegPtr = detail::getRegPtr<detail::getDDR(port)>();
|
||||||
|
|
||||||
if (dir == Dir::IN)
|
if (dir == Dir::IN)
|
||||||
*dirRegPtr = 0x00;
|
*dirRegPtr = 0x00;
|
||||||
@ -418,7 +418,7 @@ class Port {
|
|||||||
[[gnu::always_inline]] static inline void pullup(const bool enable)
|
[[gnu::always_inline]] static inline void pullup(const bool enable)
|
||||||
{
|
{
|
||||||
if constexpr (port != Bus::NONE) {
|
if constexpr (port != Bus::NONE) {
|
||||||
detail::reg_ptr_t portRegPtr = detail::getRegPtr<detail::getPORT(port)>();
|
auto portRegPtr = detail::getRegPtr<detail::getPORT(port)>();
|
||||||
|
|
||||||
if (enable)
|
if (enable)
|
||||||
*portRegPtr = 0xFF;
|
*portRegPtr = 0xFF;
|
||||||
@ -430,7 +430,7 @@ class Port {
|
|||||||
[[gnu::always_inline]] static inline void write([[maybe_unused]] const uint8_t value)
|
[[gnu::always_inline]] static inline void write([[maybe_unused]] const uint8_t value)
|
||||||
{
|
{
|
||||||
if constexpr (port != Bus::NONE) {
|
if constexpr (port != Bus::NONE) {
|
||||||
detail::reg_ptr_t portRegPtr = detail::getRegPtr<detail::getPORT(port)>();
|
auto portRegPtr = detail::getRegPtr<detail::getPORT(port)>();
|
||||||
*portRegPtr = value;
|
*portRegPtr = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -439,10 +439,10 @@ class Port {
|
|||||||
{
|
{
|
||||||
if constexpr (port != Bus::NONE) {
|
if constexpr (port != Bus::NONE) {
|
||||||
#ifdef HARDWARE_TOGGLE
|
#ifdef HARDWARE_TOGGLE
|
||||||
detail::reg_ptr_t pinRegPtr = detail::getRegPtr<detail::getPIN(port)>();
|
auto pinRegPtr = detail::getRegPtr<detail::getPIN(port)>();
|
||||||
*pinRegPtr = 0xFF;
|
*pinRegPtr = 0xFF;
|
||||||
#else
|
#else
|
||||||
detail::reg_ptr_t portRegPtr = detail::getRegPtr<detail::getPORT(port)>();
|
auto portRegPtr = detail::getRegPtr<detail::getPORT(port)>();
|
||||||
*portRegPtr = ~(*portRegPtr);
|
*portRegPtr = ~(*portRegPtr);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -451,8 +451,7 @@ class Port {
|
|||||||
[[gnu::always_inline]] static inline uint8_t read()
|
[[gnu::always_inline]] static inline uint8_t read()
|
||||||
{
|
{
|
||||||
if constexpr (port != Bus::NONE) {
|
if constexpr (port != Bus::NONE) {
|
||||||
detail::reg_ptr_t pinRegPtr = detail::getRegPtr<detail::getPIN(port)>();
|
auto pinRegPtr = detail::getRegPtr<detail::getPIN(port)>();
|
||||||
|
|
||||||
return *pinRegPtr;
|
return *pinRegPtr;
|
||||||
}
|
}
|
||||||
return 0x00;
|
return 0x00;
|
||||||
|
Loading…
Reference in New Issue
Block a user