Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: MPU6050.cpp
- Revision:
- 15:11993501be6c
- Parent:
- 13:23c9db5753c8
--- a/MPU6050.cpp Mon Feb 15 21:48:30 2021 +0000 +++ b/MPU6050.cpp Wed Mar 10 20:53:54 2021 +0000 @@ -3,7 +3,8 @@ */ #include "MPU6050.h" -MPU6050::MPU6050(PinName sda, PinName scl) : connection(sda, scl) { +MPU6050::MPU6050(I2C *i2cIn){ + connection = i2cIn; this->setSleepMode(false); //Initializations: @@ -21,19 +22,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) {