diff --git a/hardware.hpp b/hardware.hpp index f6d15e3..4cef107 100644 --- a/hardware.hpp +++ b/hardware.hpp @@ -63,12 +63,15 @@ class Hardware { constexpr auto EnableRx = calcRxState(); constexpr auto EnableTx = calcTxState(); constexpr auto InterruptVal = calcInterrupt(); - constexpr auto DoubleSpeedVal = calcDoubleSpeedVal(); constexpr uint8_t ControlRegB = DataBitsValues.regBVal | EnableRx | EnableTx | InterruptVal; constexpr uint8_t ControlRegC = DataBitsValues.regCVal | ParityVal | StopBitsVal | ModeVal; - *getRegPtr() |= DoubleSpeedVal; + if constexpr (UseDoubleSpeed) + *getRegPtr() |= (1 << CtrlFlagsA::SPEED_2X); + else + *getRegPtr() &= ~(1 << CtrlFlagsA::SPEED_2X); + *getRegPtr() = ControlRegB; *getRegPtr() = ControlRegC; } @@ -266,17 +269,6 @@ class Hardware { return interruptVal; } - - template - static constexpr auto calcDoubleSpeedVal() - { - uint8_t doubleSpeedVal = 0; - - if constexpr (DoubleSpeed) - doubleSpeedVal = (1 << CtrlFlagsA::SPEED_2X); - - return doubleSpeedVal; - } }; template