diff --git a/hardware.hpp b/hardware.hpp index ff3f960..1efcef2 100644 --- a/hardware.hpp +++ b/hardware.hpp @@ -67,10 +67,12 @@ class Hardware { constexpr uint8_t ControlRegB = DataBitsValues.regBVal | EnableRx | EnableTx | InterruptVal; constexpr uint8_t ControlRegC = DataBitsValues.regCVal | ParityVal | StopBitsVal | ModeVal; + auto ctrlStatRegA = getRegPtr(); + if constexpr (UseDoubleSpeed) - *getRegPtr() |= (1 << CtrlFlagsA::SPEED_2X); + *ctrlStatRegA = *ctrlStatRegA | (1 << CtrlFlagsA::SPEED_2X); else - *getRegPtr() &= ~(1 << CtrlFlagsA::SPEED_2X); + *ctrlStatRegA = *ctrlStatRegA & ~(1 << CtrlFlagsA::SPEED_2X); *getRegPtr() = ControlRegB; *getRegPtr() = ControlRegC; @@ -130,12 +132,14 @@ class Hardware { static void enableDataRegEmptyInt() FORCE_INLINE { - *getRegPtr() |= (1 << CtrlFlagsB::DATA_REG_EMPTY_INT_ENABLE); + auto ctrlStatRegB = getRegPtr(); + *ctrlStatRegB = *ctrlStatRegB | (1 << CtrlFlagsB::DATA_REG_EMPTY_INT_ENABLE); } static void disableDataRegEmptyInt() FORCE_INLINE { - *getRegPtr() &= ~(1 << CtrlFlagsB::DATA_REG_EMPTY_INT_ENABLE); + auto ctrlStatRegB = getRegPtr(); + *ctrlStatRegB = *ctrlStatRegB & ~(1 << CtrlFlagsB::DATA_REG_EMPTY_INT_ENABLE); } private: