Skip to content

2.5.0 compatibility issue with Arduino Wire API #5901

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

Closed
SergioGarciaCuevasGonzalez opened this issue Mar 21, 2019 · 2 comments · Fixed by #5969
Closed

2.5.0 compatibility issue with Arduino Wire API #5901

SergioGarciaCuevasGonzalez opened this issue Mar 21, 2019 · 2 comments · Fixed by #5969

Comments

@SergioGarciaCuevasGonzalez

The Wire library included in version 2.5.0 breaks compatibility with the common Arduino Wire library. On version 2.5.0, TwoWire::onReceive() has the following (incompatible) signature:

void TwoWire::onReceive(void (*)(size_t));

The expected signature is as follows:

void TwoWire::onReceive(void (*)(int));

Portable I2C slave reception code won't compile anymore because of this.

@d-a-v
Copy link
Collaborator

d-a-v commented Mar 21, 2019

Thanks for the report. A fix will be proposed.

@SergioGarciaCuevasGonzalez
Copy link
Author

I deleted the template by accident. I see I left out a lot of required information! Please have a code example that compiles for other Arduino ports:

#include <Wire.h>

const uint8_t slaveAddress = 0x10;

void receiveEvent(int howMany) {
  (void) Serial.print("receiveEvent(");
  (void) Serial.print(howMany, DEC);
  (void) Serial.print("): ");
  while (Wire.available() > 1)
  {
    (void) Serial.print(Wire.read(), DEC);
    (void) Serial.print(", ");
  }
  (void) Serial.println(Wire.read(), DEC);
}

void setup() {
  Serial.begin(115200);
  Wire.begin(slaveAddress);
  Wire.onReceive(receiveEvent);
}

void loop() {
}

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

Successfully merging a pull request may close this issue.

2 participants