From 0d8416a3746531ccf475873503348e6f257bb8ee Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Wed, 28 Feb 2024 14:35:14 +0100 Subject: [PATCH] refactor(i2c): simplify constructor Signed-off-by: Frederic Pillon --- libraries/Wire/src/Wire.cpp | 12 ------------ libraries/Wire/src/Wire.h | 3 +-- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/libraries/Wire/src/Wire.cpp b/libraries/Wire/src/Wire.cpp index 1840060aa1..c167aca5ac 100644 --- a/libraries/Wire/src/Wire.cpp +++ b/libraries/Wire/src/Wire.cpp @@ -33,18 +33,6 @@ static const uint8_t MASTER_ADDRESS = 0x01; // Constructors //////////////////////////////////////////////////////////////// -TwoWire::TwoWire() -{ - memset((void *)&_i2c, 0, sizeof(_i2c)); - _i2c.sda = digitalPinToPinName(SDA); - _i2c.scl = digitalPinToPinName(SCL); - - txBuffer = nullptr; - txBufferAllocated = 0; - rxBuffer = nullptr; - rxBufferAllocated = 0; -} - TwoWire::TwoWire(uint32_t sda, uint32_t scl) { memset((void *)&_i2c, 0, sizeof(_i2c)); diff --git a/libraries/Wire/src/Wire.h b/libraries/Wire/src/Wire.h index fafea29dd9..58398cd76c 100644 --- a/libraries/Wire/src/Wire.h +++ b/libraries/Wire/src/Wire.h @@ -76,8 +76,7 @@ class TwoWire : public Stream { void recoverBus(void); public: - TwoWire(); - TwoWire(uint32_t sda, uint32_t scl); + TwoWire(uint32_t sda = SDA, uint32_t scl = SCL); ~TwoWire(); // setSCL/SDA have to be called before begin() void setSCL(uint32_t scl)