Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cjinn opened this issue Nov 26, 2020 · 2 comments

Comments

@cjinn
Copy link

cjinn commented Nov 26, 2020

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.

@cjinn
Copy link
Author

cjinn commented Nov 26, 2020

Forgot to mention my library/environment versions:

  • Arduino IDE v1.8.13
  • Arduino ESP32 v1.0.4
  • Arduino_LSM6DS3 v1.0.0

@abrahmx
Copy link

abrahmx commented Aug 5, 2022

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.

Thank you for this, I'm using ESP8266 and I was getting this error as well. After changing this I could compile and upload. My settings are: Platformio(v2.5.1) on VS Code, Platform espressif8266, board = nodemcuv2, framework = Arduino.

Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants