From 9d012f64c8505a7ca23e4c7a391389522d5372ed Mon Sep 17 00:00:00 2001 From: s-hadinger <49731213+s-hadinger@users.noreply.github.com> Date: Wed, 11 Sep 2024 16:41:35 +0200 Subject: [PATCH] Add internal I2C argument to send stop while reading (#22127) --- tasmota/tasmota_support/support_a_i2c.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasmota/tasmota_support/support_a_i2c.ino b/tasmota/tasmota_support/support_a_i2c.ino index 364cd1fe5..8a1e84930 100644 --- a/tasmota/tasmota_support/support_a_i2c.ino +++ b/tasmota/tasmota_support/support_a_i2c.ino @@ -62,7 +62,7 @@ TwoWire& I2cGetWire(uint8_t bus = 0) { * Return code: 0 = Error, 1 = OK \*-------------------------------------------------------------------------------------------*/ -bool I2cValidRead(uint8_t addr, uint8_t reg, uint8_t size, uint8_t bus = 0) { +bool I2cValidRead(uint8_t addr, uint8_t reg, uint8_t size, uint8_t bus = 0, bool sendStop = false) { i2c_buffer = 0; TwoWire& myWire = I2cGetWire(bus); @@ -73,7 +73,7 @@ bool I2cValidRead(uint8_t addr, uint8_t reg, uint8_t size, uint8_t bus = 0) { while (!status && retry) { myWire.beginTransmission(addr); // start transmission to device myWire.write(reg); // sends register address to read from - if (0 == myWire.endTransmission(false)) { // Try to become I2C Master, send data and collect bytes, keep master status for next request... + if (0 == myWire.endTransmission(sendStop)) { // Try to become I2C Master, send data and collect bytes, keep master status for next request... myWire.requestFrom((int)addr, (int)size); // send data n-bytes read if (myWire.available() == size) { for (uint32_t i = 0; i < size; i++) {