From 7c9f467c3d3d1fd44f0907c4b33f4d324527af2b Mon Sep 17 00:00:00 2001 From: "Dirk O. Kaar" Date: Fri, 21 Apr 2023 22:33:56 +0200 Subject: [PATCH] Refactor default member initialization for those that are required - m_invert was lacking before. --- src/SoftwareSerial.cpp | 8 -------- src/SoftwareSerial.h | 8 ++++---- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/SoftwareSerial.cpp b/src/SoftwareSerial.cpp index f8956b2..f058954 100644 --- a/src/SoftwareSerial.cpp +++ b/src/SoftwareSerial.cpp @@ -52,18 +52,10 @@ __attribute__((always_inline)) inline void IRAM_ATTR UARTBase::restoreInterrupts constexpr uint8_t BYTE_ALL_BITS_SET = ~static_cast(0); UARTBase::UARTBase() { - m_isrOverflow = false; - m_rxGPIOHasPullUp = false; - m_rxGPIOPullUpEnabled = true; - m_txGPIOOpenDrain = false; } UARTBase::UARTBase(int8_t rxPin, int8_t txPin, bool invert) { - m_isrOverflow = false; - m_rxGPIOHasPullUp = false; - m_rxGPIOPullUpEnabled = true; - m_txGPIOOpenDrain = false; m_rxPin = rxPin; m_txPin = txPin; m_invert = invert; diff --git a/src/SoftwareSerial.h b/src/SoftwareSerial.h index c0a6648..d6f1a57 100644 --- a/src/SoftwareSerial.h +++ b/src/SoftwareSerial.h @@ -342,9 +342,9 @@ class UARTBase : public Stream { /// PDU bits include data, parity and stop bits; the start bit is not counted. uint8_t m_pduBits; bool m_intTxEnabled; - bool m_rxGPIOHasPullUp; - bool m_rxGPIOPullUpEnabled; - bool m_txGPIOOpenDrain; + bool m_rxGPIOHasPullUp = false; + bool m_rxGPIOPullUpEnabled = true; + bool m_txGPIOOpenDrain = false; Parity m_parityMode; uint8_t m_stopBits; bool m_lastReadParity; @@ -367,7 +367,7 @@ class UARTBase : public Stream { // 1 = positive including 0, 0 = negative. std::unique_ptr > m_isrBuffer; const Delegate m_isrBufferForEachDel = { [](UARTBase* self, uint32_t&& isrTick) { self->rxBits(isrTick); }, this }; - std::atomic m_isrOverflow; + std::atomic m_isrOverflow = false; uint32_t m_isrLastTick; bool m_rxCurParity = false; Delegate m_rxHandler;