Skip to content

Commit

Permalink
Add internal I2C argument to send stop while reading (#22127)
Browse files Browse the repository at this point in the history
  • Loading branch information
s-hadinger authored Sep 11, 2024
1 parent 1edc4b5 commit 9d012f6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tasmota/tasmota_support/support_a_i2c.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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++) {
Expand Down

0 comments on commit 9d012f6

Please sign in to comment.