diff --git a/hardware.hpp b/hardware.hpp index 0cf5b8a..4e5f174 100644 --- a/hardware.hpp +++ b/hardware.hpp @@ -46,24 +46,24 @@ class Hardware { public: static void init() FORCE_INLINE { - constexpr auto baudVal = calcBaud(); + constexpr auto BaudVal = calcBaud(); - *getRegPtr() = static_cast(baudVal >> 8); - *getRegPtr() = static_cast(baudVal); + *getRegPtr() = static_cast(BaudVal >> 8); + *getRegPtr() = static_cast(BaudVal); - constexpr auto dataBitsVal = calcDataBits(); - constexpr auto parityVal = calcParity(); - constexpr auto stopBitsVal = calcStopBits(); - constexpr auto modeVal = calcMode(); - constexpr auto enableRx = calcRxState(); - constexpr auto enableTx = calcTxState(); - constexpr auto interruptVal = calcInterrupt(); + constexpr auto DataBitsValues = calcDataBits(); + constexpr auto ParityVal = calcParity(); + constexpr auto StopBitsVal = calcStopBits(); + constexpr auto ModeVal = calcMode(); + constexpr auto EnableRx = calcRxState(); + constexpr auto EnableTx = calcTxState(); + constexpr auto InterruptVal = calcInterrupt(); - constexpr uint8_t controlRegB = dataBitsVal.regBVal | enableRx | enableTx | interruptVal; - constexpr uint8_t controlRegC = dataBitsVal.regCVal | parityVal | stopBitsVal | modeVal; + constexpr uint8_t ControlRegB = DataBitsValues.regBVal | EnableRx | EnableTx | InterruptVal; + constexpr uint8_t ControlRegC = DataBitsValues.regCVal | ParityVal | StopBitsVal | ModeVal; - *getRegPtr() = controlRegB; - *getRegPtr() = controlRegC; + *getRegPtr() = ControlRegB; + *getRegPtr() = ControlRegC; } static bool rxByteBlocking(typename cfg::data_t &byte) FORCE_INLINE @@ -137,8 +137,8 @@ class Hardware { static constexpr auto calcBaud() { // The actual formula is (F_CPU / (16 * baudRate)) - 1, but this one has the advantage of rounding correctly - constexpr auto baudVal = (F_CPU + 8 * cfg::BAUD_RATE) / (16 * cfg::BAUD_RATE) - 1; - return baudVal; + constexpr auto BaudVal = (F_CPU + 8 * cfg::BAUD_RATE) / (16 * cfg::BAUD_RATE) - 1; + return BaudVal; } static constexpr auto calcDataBits() @@ -202,23 +202,23 @@ class Hardware { return modeVal; } - template + template static constexpr auto calcRxState() { uint8_t enableVal = 0; - if (enable) + if (Enable) enableVal = (1 << CtrlFlagsB::RX_ENABLE); return enableVal; } - template + template static constexpr auto calcTxState() { uint8_t enableVal = 0; - if (enable) + if (Enable) enableVal = (1 << CtrlFlagsB::TX_ENABLE); return enableVal; diff --git a/uart.hpp b/uart.hpp index 6f51869..4839296 100644 --- a/uart.hpp +++ b/uart.hpp @@ -36,13 +36,13 @@ static constexpr size_t cntDigits() template static constexpr size_t maxNumDigits() { - constexpr T minVal = util::NumericLimits::min(); - constexpr T maxVal = util::NumericLimits::max(); + constexpr T MinVal = util::NumericLimits::min(); + constexpr T MaxVal = util::NumericLimits::max(); - constexpr T minDigits = cntDigits(); - constexpr T maxDigits = cntDigits(); + constexpr T MinDigits = cntDigits(); + constexpr T MaxDigits = cntDigits(); - return (minDigits < maxDigits) ? maxDigits : minDigits; + return (MinDigits < MaxDigits) ? MaxDigits : MinDigits; } } // namespace detail @@ -120,8 +120,8 @@ class Uart { static_assert(Base <= 16, "Numbers with base higher than 16 are not supported"); static_assert(Padding <= detail::maxNumDigits(), "Cannot pad more than maximum length of number"); - constexpr char alphaChar = (LowerCase) ? 'a' : 'A'; - constexpr size_t numDigits = detail::maxNumDigits(); + constexpr char AlphaChar = (LowerCase) ? 'a' : 'A'; + constexpr size_t NumDigits = detail::maxNumDigits(); T digits = val; @@ -130,17 +130,17 @@ class Uart { txByte('-'); } - data_t buffer[numDigits]; - data_t *bufEnd = buffer + numDigits - 1; + data_t buffer[NumDigits]; + data_t *bufEnd = buffer + NumDigits - 1; do { const data_t lastDigit = digits % Base; - *bufEnd-- = (lastDigit < 10) ? ('0' + lastDigit) : (alphaChar + lastDigit - 10); + *bufEnd-- = (lastDigit < 10) ? ('0' + lastDigit) : (AlphaChar + lastDigit - 10); digits /= Base; } while (digits > 0); if (Padding > 0) { - size_t strLen = buffer + numDigits - (bufEnd + 1); + size_t strLen = buffer + NumDigits - (bufEnd + 1); if (Padding > strLen) { for (size_t i = Padding; i > strLen && bufEnd >= buffer; --i) { @@ -149,7 +149,7 @@ class Uart { } } - for (data_t *buf = bufEnd + 1; buf < buffer + numDigits; ++buf) + for (data_t *buf = bufEnd + 1; buf < buffer + NumDigits; ++buf) txByte(*buf); }