Skip to content

Commit

Permalink
Fixed memory on Wire instance
Browse files Browse the repository at this point in the history
The constructor doesn't cleanup memory for a wire instance.
Issues could happen, such as wrong initialization during boot

Signed-off-by: Giovanni Bruno <[email protected]>
  • Loading branch information
gbr1 authored and fpistm committed Nov 22, 2023
1 parent d61ad83 commit 61a41ec
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libraries/Wire/src/Wire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ static const uint8_t MASTER_ADDRESS = 0x01;

TwoWire::TwoWire()
{
memset((void *)&_i2c, 0, sizeof(_i2c));
_i2c.sda = digitalPinToPinName(SDA);
_i2c.scl = digitalPinToPinName(SCL);
}

TwoWire::TwoWire(uint32_t sda, uint32_t scl)
{
memset((void *)&_i2c, 0, sizeof(_i2c));
_i2c.sda = digitalPinToPinName(sda);
_i2c.scl = digitalPinToPinName(scl);
}
Expand Down

0 comments on commit 61a41ec

Please sign in to comment.