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

The Wire.requestFrom does not need a Wire.beginTransmission, no Wire.endTransmission and no waiting. #4

Open
Koepel opened this issue May 5, 2017 · 2 comments · May be fixed by #8

Comments

@Koepel
Copy link

Koepel commented May 5, 2017

In the file MPU6050.cpp the use of Wire.requestFrom can be improved.

The Wire.beginTransmission and Wire.endTransmission are only needed when writing data. They should not be used with Wire.requestFrom and can be removed. In two places there is Wire.beginTransmission, and in three places both the Wire.beginTransmission and Wire.endTransmission with the Wire.requestFrom. They can all be removed.

The Wire.requestFrom is a complete I2C transaction on its own. It stores the received data in a buffer in the Wire library and returns when the I2C transaction completely has finished. It is therefor not needed to wait for something. In four places there is a while-loop after Wire.requestFrom. Those while-loops can be removed.

@J3r3Xy
Copy link

J3r3Xy commented Dec 14, 2017

I agree with Koepel, the loops also cause the Arduino to hang if the MPU6050 disconnects (either because of cable or power failure)

@Koepel
Copy link
Author

Koepel commented May 12, 2019

If he can fix it, why can't you ?
https://github.com/ErcBunny/VTOL_osprey/issues/1

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

Successfully merging a pull request may close this issue.

2 participants