Skip to content

Instantly share code, notes, and snippets.

@esmarr58
Created November 11, 2017 01:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esmarr58/18217f2fa0908de7003c85c89a638574 to your computer and use it in GitHub Desktop.
Save esmarr58/18217f2fa0908de7003c85c89a638574 to your computer and use it in GitHub Desktop.
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