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.
Revision 15:11993501be6c, committed 2021-03-10
- Comitter:
- khaiminhvn
- Date:
- Wed Mar 10 20:53:54 2021 +0000
- Parent:
- 13:23c9db5753c8
- Commit message:
- Changes to I2C input
Changed in this revision
MPU6050.cpp | Show annotated file Show diff for this revision Revisions of this file |
MPU6050.h | Show annotated file Show diff for this revision Revisions of this file |
--- 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) {
--- a/MPU6050.h Mon Feb 15 21:48:30 2021 +0000 +++ b/MPU6050.h Wed Mar 10 20:53:54 2021 +0000 @@ -103,7 +103,7 @@ * @param sda - mbed pin to use for the SDA I2C line. * @param scl - mbed pin to use for the SCL I2C line. */ - MPU6050(PinName sda, PinName scl); + MPU6050(I2C *i2cIn); /** @@ -321,7 +321,7 @@ private: - I2C connection; + I2C *connection; char currentAcceleroRange; char currentGyroRange; float alpha;