Created
November 11, 2017 01:37
-
-
Save esmarr58/18217f2fa0908de7003c85c89a638574 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int MPU6050_read(int start, uint8_t *buffer, int size) | |
{ | |
int i, n, error; | |
Wire.beginTransmission(MPU6050_I2C_ADDRESS); | |
n = Wire.write(start); | |
if (n != 1) | |
return (-10); | |
n = Wire.endTransmission(false); | |
if (n != 0) | |
return (n); | |
Wire.requestFrom(MPU6050_I2C_ADDRESS, size, true); | |
i = 0; | |
while(Wire.available() && i<size) { | |
buffer[i++]=Wire.read(); | |
} | |
if ( i != size) | |
return (-11); | |
return (0); // retorna: no error | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment