Skip to content

For I2C, end() method calls for _wire->end() instead of _wire->endTransmission() #17

Open
@cjinn

Description

@cjinn

I noticed, when trying out this library for a ESP32 and I2C project, this library does not compile due to the following errors:

libraries\Arduino_LSM6DS3\src\LSM6DS3.cpp: In member function 'void LSM6DS3Class::end()':`
`libraries\Arduino_LSM6DS3\src\LSM6DS3.cpp:110:12: error: 'class TwoWire' has no member named 'end'_wire->end()';

This issue is only present when compiling for any ESP32 boards. When I switched the board to a Arduino board, it compiles.

Further investigate reveals, on both Arduino ESP32's Wire.h and the Arduino Standard Library use endTransmission(), not end().

A hotfix inside LSM6DS3.cpp that got my library to compile would be of the following:

void LSM6DS3Class::end()
{
  if (_spi != NULL) {
    _spi->end();
    digitalWrite(_csPin, LOW);
    pinMode(_csPin, INPUT);
  } else {
    writeRegister(LSM6DS3_CTRL2_G, 0x00);
    writeRegister(LSM6DS3_CTRL1_XL, 0x00);

    _wire->end(); // This does not compile for esp32. Somehow works for Arduino. Legacy code?
    // _wire->endTransmission();
  }
}

I'm wondering if the above code is all that is required to fix this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions