From bcd18db494de771ebe786817e74d3585a94312e9 Mon Sep 17 00:00:00 2001 From: BlackMark Date: Mon, 13 Apr 2020 13:06:11 +0200 Subject: [PATCH] Fix double speed flag not being cleared if not used --- hardware.hpp | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) 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