library of measure the sensor MPU6050 by I2C

Dependents:   1-K64F_with_5_acel

Fork of MPU6050 by Erik -

Revision:
4:52b05c0e09a6
Parent:
3:6d0ea7c8c5c4
--- a/MPU6050.cpp	Thu Dec 01 08:16:02 2016 +0000
+++ b/MPU6050.cpp	Thu Jan 18 07:52:45 2018 +0000
@@ -3,8 +3,12 @@
  */
 #include "MPU6050.h"
 
-MPU6050::MPU6050(PinName sda, PinName scl) : connection(sda, scl) {
+MPU6050::MPU6050(I2C * puntero) : connection(puntero) {
     this->setSleepMode(false);
+    write(0x19, 19);    //configure Fs Accel = 400Hz
+    write(0x1A, 0x00);  //Gyroscope Output Rate = 8kHz  Bandwidth (Hz) Acele= 260Hz
+    write(0x37, 0xE0);  //Interrupcion activa a nivel bajo , open drail, mantener interrupcion
+    write(0x38, 0x01);  //activa interrupcion  por data Redy
     
     //Initializations:
     currentGyroRange = 0;
@@ -20,19 +24,19 @@
     temp[0]=address;
     temp[1]=data;
     
-    connection.write(MPU6050_ADDRESS * 2,temp,2);
+    connection->write(MPU6050_ADDRESS * 2,temp,2);
 }
 
 char MPU6050::read(char address) {
     char retval;
-    connection.write(MPU6050_ADDRESS * 2, &address, 1, true);
-    connection.read(MPU6050_ADDRESS * 2, &retval, 1);
+    connection->write(MPU6050_ADDRESS * 2, &address, 1, true);
+    connection->read(MPU6050_ADDRESS * 2, &retval, 1);
     return retval;
 }
 
 void MPU6050::read(char address, char *data, int length) {
-    connection.write(MPU6050_ADDRESS * 2, &address, 1, true);
-    connection.read(MPU6050_ADDRESS * 2, data, length);
+    connection->write(MPU6050_ADDRESS * 2, &address, 1, true);
+    connection->read(MPU6050_ADDRESS * 2, data, length);
 }
 
 void MPU6050::setSleepMode(bool state) {