Fix double speed flag not being cleared if not used

This commit is contained in:
BlackMark 2020-04-13 13:06:11 +02:00
parent 04b6782ec4
commit bcd18db494

View File

@ -63,12 +63,15 @@ class Hardware {
constexpr auto EnableRx = calcRxState<true>(); constexpr auto EnableRx = calcRxState<true>();
constexpr auto EnableTx = calcTxState<true>(); constexpr auto EnableTx = calcTxState<true>();
constexpr auto InterruptVal = calcInterrupt(); constexpr auto InterruptVal = calcInterrupt();
constexpr auto DoubleSpeedVal = calcDoubleSpeedVal<UseDoubleSpeed>();
constexpr uint8_t ControlRegB = DataBitsValues.regBVal | EnableRx | EnableTx | InterruptVal; constexpr uint8_t ControlRegB = DataBitsValues.regBVal | EnableRx | EnableTx | InterruptVal;
constexpr uint8_t ControlRegC = DataBitsValues.regCVal | ParityVal | StopBitsVal | ModeVal; constexpr uint8_t ControlRegC = DataBitsValues.regCVal | ParityVal | StopBitsVal | ModeVal;
*getRegPtr<Registers::CTRL_STAT_REG_A_ADDR>() |= DoubleSpeedVal; if constexpr (UseDoubleSpeed)
*getRegPtr<Registers::CTRL_STAT_REG_A_ADDR>() |= (1 << CtrlFlagsA::SPEED_2X);
else
*getRegPtr<Registers::CTRL_STAT_REG_A_ADDR>() &= ~(1 << CtrlFlagsA::SPEED_2X);
*getRegPtr<Registers::CTRL_STAT_REG_B_ADDR>() = ControlRegB; *getRegPtr<Registers::CTRL_STAT_REG_B_ADDR>() = ControlRegB;
*getRegPtr<Registers::CTRL_STAT_REG_C_ADDR>() = ControlRegC; *getRegPtr<Registers::CTRL_STAT_REG_C_ADDR>() = ControlRegC;
} }
@ -266,17 +269,6 @@ class Hardware {
return interruptVal; return interruptVal;
} }
template <bool DoubleSpeed>
static constexpr auto calcDoubleSpeedVal()
{
uint8_t doubleSpeedVal = 0;
if constexpr (DoubleSpeed)
doubleSpeedVal = (1 << CtrlFlagsA::SPEED_2X);
return doubleSpeedVal;
}
}; };
template <class Registers, typename CtrlFlagsA, typename CtrlFlagsB, typename CtrlFlagsC, class cfg, Mode mode> template <class Registers, typename CtrlFlagsA, typename CtrlFlagsB, typename CtrlFlagsC, class cfg, Mode mode>