Minh Nguyen / MPU6050
Committer:
khaiminhvn
Date:
Wed Mar 10 20:53:54 2021 +0000
Revision:
15:11993501be6c
Parent:
13:23c9db5753c8
Changes to I2C input

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Sissors 0:6757f7363a9f 1 /**
Sissors 0:6757f7363a9f 2 * Includes
Sissors 0:6757f7363a9f 3 */
Sissors 0:6757f7363a9f 4 #include "MPU6050.h"
Sissors 0:6757f7363a9f 5
khaiminhvn 15:11993501be6c 6 MPU6050::MPU6050(I2C *i2cIn){
khaiminhvn 15:11993501be6c 7 connection = i2cIn;
Sissors 0:6757f7363a9f 8 this->setSleepMode(false);
Sissors 0:6757f7363a9f 9
Sissors 0:6757f7363a9f 10 //Initializations:
Sissors 0:6757f7363a9f 11 currentGyroRange = 0;
Sissors 0:6757f7363a9f 12 currentAcceleroRange=0;
moklumbys 10:bd9665d14241 13 alpha = ALPHA;
Sissors 0:6757f7363a9f 14 }
Sissors 0:6757f7363a9f 15
Sissors 0:6757f7363a9f 16 //--------------------------------------------------
Sissors 0:6757f7363a9f 17 //-------------------General------------------------
Sissors 0:6757f7363a9f 18 //--------------------------------------------------
Sissors 0:6757f7363a9f 19
Sissors 0:6757f7363a9f 20 void MPU6050::write(char address, char data) {
Sissors 0:6757f7363a9f 21 char temp[2];
Sissors 0:6757f7363a9f 22 temp[0]=address;
Sissors 0:6757f7363a9f 23 temp[1]=data;
Sissors 0:6757f7363a9f 24
khaiminhvn 15:11993501be6c 25 connection->write(MPU6050_ADDRESS * 2,temp,2);
Sissors 0:6757f7363a9f 26 }
Sissors 0:6757f7363a9f 27
Sissors 0:6757f7363a9f 28 char MPU6050::read(char address) {
Sissors 0:6757f7363a9f 29 char retval;
khaiminhvn 15:11993501be6c 30 connection->write(MPU6050_ADDRESS * 2, &address, 1, true);
khaiminhvn 15:11993501be6c 31 connection->read(MPU6050_ADDRESS * 2, &retval, 1);
Sissors 0:6757f7363a9f 32 return retval;
Sissors 0:6757f7363a9f 33 }
Sissors 0:6757f7363a9f 34
Sissors 0:6757f7363a9f 35 void MPU6050::read(char address, char *data, int length) {
khaiminhvn 15:11993501be6c 36 connection->write(MPU6050_ADDRESS * 2, &address, 1, true);
khaiminhvn 15:11993501be6c 37 connection->read(MPU6050_ADDRESS * 2, data, length);
Sissors 0:6757f7363a9f 38 }
Sissors 0:6757f7363a9f 39
Sissors 0:6757f7363a9f 40 void MPU6050::setSleepMode(bool state) {
Sissors 0:6757f7363a9f 41 char temp;
Sissors 0:6757f7363a9f 42 temp = this->read(MPU6050_PWR_MGMT_1_REG);
Sissors 0:6757f7363a9f 43 if (state == true)
Sissors 0:6757f7363a9f 44 temp |= 1<<MPU6050_SLP_BIT;
Sissors 0:6757f7363a9f 45 if (state == false)
Sissors 0:6757f7363a9f 46 temp &= ~(1<<MPU6050_SLP_BIT);
Sissors 0:6757f7363a9f 47 this->write(MPU6050_PWR_MGMT_1_REG, temp);
Sissors 0:6757f7363a9f 48 }
Sissors 0:6757f7363a9f 49
Sissors 0:6757f7363a9f 50 bool MPU6050::testConnection( void ) {
Sissors 0:6757f7363a9f 51 char temp;
Sissors 0:6757f7363a9f 52 temp = this->read(MPU6050_WHO_AM_I_REG);
Sissors 0:6757f7363a9f 53 return (temp == (MPU6050_ADDRESS & 0xFE));
Sissors 0:6757f7363a9f 54 }
Sissors 0:6757f7363a9f 55
Sissors 0:6757f7363a9f 56 void MPU6050::setBW(char BW) {
Sissors 0:6757f7363a9f 57 char temp;
Sissors 0:6757f7363a9f 58 BW=BW & 0x07;
Sissors 0:6757f7363a9f 59 temp = this->read(MPU6050_CONFIG_REG);
Sissors 0:6757f7363a9f 60 temp &= 0xF8;
Sissors 0:6757f7363a9f 61 temp = temp + BW;
Sissors 0:6757f7363a9f 62 this->write(MPU6050_CONFIG_REG, temp);
Sissors 0:6757f7363a9f 63 }
Sissors 0:6757f7363a9f 64
Sissors 0:6757f7363a9f 65 void MPU6050::setI2CBypass(bool state) {
Sissors 0:6757f7363a9f 66 char temp;
Sissors 0:6757f7363a9f 67 temp = this->read(MPU6050_INT_PIN_CFG);
Sissors 0:6757f7363a9f 68 if (state == true)
Sissors 0:6757f7363a9f 69 temp |= 1<<MPU6050_BYPASS_BIT;
Sissors 0:6757f7363a9f 70 if (state == false)
Sissors 0:6757f7363a9f 71 temp &= ~(1<<MPU6050_BYPASS_BIT);
Sissors 0:6757f7363a9f 72 this->write(MPU6050_INT_PIN_CFG, temp);
Sissors 0:6757f7363a9f 73 }
Sissors 0:6757f7363a9f 74
Sissors 0:6757f7363a9f 75 //--------------------------------------------------
Sissors 0:6757f7363a9f 76 //----------------Accelerometer---------------------
Sissors 0:6757f7363a9f 77 //--------------------------------------------------
Sissors 0:6757f7363a9f 78
Sissors 0:6757f7363a9f 79 void MPU6050::setAcceleroRange( char range ) {
Sissors 0:6757f7363a9f 80 char temp;
Sissors 0:6757f7363a9f 81 range = range & 0x03;
Sissors 0:6757f7363a9f 82 currentAcceleroRange = range;
Sissors 0:6757f7363a9f 83
Sissors 0:6757f7363a9f 84 temp = this->read(MPU6050_ACCELERO_CONFIG_REG);
Sissors 0:6757f7363a9f 85 temp &= ~(3<<3);
Sissors 0:6757f7363a9f 86 temp = temp + (range<<3);
Sissors 0:6757f7363a9f 87 this->write(MPU6050_ACCELERO_CONFIG_REG, temp);
Sissors 0:6757f7363a9f 88 }
Sissors 0:6757f7363a9f 89
Sissors 0:6757f7363a9f 90 int MPU6050::getAcceleroRawX( void ) {
Sissors 0:6757f7363a9f 91 short retval;
Sissors 0:6757f7363a9f 92 char data[2];
Sissors 0:6757f7363a9f 93 this->read(MPU6050_ACCEL_XOUT_H_REG, data, 2);
Sissors 0:6757f7363a9f 94 retval = (data[0]<<8) + data[1];
Sissors 0:6757f7363a9f 95 return (int)retval;
Sissors 0:6757f7363a9f 96 }
Sissors 0:6757f7363a9f 97
Sissors 0:6757f7363a9f 98 int MPU6050::getAcceleroRawY( void ) {
Sissors 0:6757f7363a9f 99 short retval;
Sissors 0:6757f7363a9f 100 char data[2];
Sissors 0:6757f7363a9f 101 this->read(MPU6050_ACCEL_YOUT_H_REG, data, 2);
Sissors 0:6757f7363a9f 102 retval = (data[0]<<8) + data[1];
Sissors 0:6757f7363a9f 103 return (int)retval;
Sissors 0:6757f7363a9f 104 }
Sissors 0:6757f7363a9f 105
Sissors 0:6757f7363a9f 106 int MPU6050::getAcceleroRawZ( void ) {
Sissors 0:6757f7363a9f 107 short retval;
Sissors 0:6757f7363a9f 108 char data[2];
Sissors 0:6757f7363a9f 109 this->read(MPU6050_ACCEL_ZOUT_H_REG, data, 2);
Sissors 0:6757f7363a9f 110 retval = (data[0]<<8) + data[1];
Sissors 0:6757f7363a9f 111 return (int)retval;
Sissors 0:6757f7363a9f 112 }
Sissors 0:6757f7363a9f 113
Sissors 0:6757f7363a9f 114 void MPU6050::getAcceleroRaw( int *data ) {
Sissors 0:6757f7363a9f 115 char temp[6];
Sissors 0:6757f7363a9f 116 this->read(MPU6050_ACCEL_XOUT_H_REG, temp, 6);
Sissors 0:6757f7363a9f 117 data[0] = (int)(short)((temp[0]<<8) + temp[1]);
Sissors 0:6757f7363a9f 118 data[1] = (int)(short)((temp[2]<<8) + temp[3]);
Sissors 0:6757f7363a9f 119 data[2] = (int)(short)((temp[4]<<8) + temp[5]);
Sissors 0:6757f7363a9f 120 }
Sissors 0:6757f7363a9f 121
Sissors 0:6757f7363a9f 122 void MPU6050::getAccelero( float *data ) {
Sissors 0:6757f7363a9f 123 int temp[3];
Sissors 0:6757f7363a9f 124 this->getAcceleroRaw(temp);
Sissors 0:6757f7363a9f 125 if (currentAcceleroRange == MPU6050_ACCELERO_RANGE_2G) {
Sissors 0:6757f7363a9f 126 data[0]=(float)temp[0] / 16384.0 * 9.81;
Sissors 0:6757f7363a9f 127 data[1]=(float)temp[1] / 16384.0 * 9.81;
Sissors 0:6757f7363a9f 128 data[2]=(float)temp[2] / 16384.0 * 9.81;
Sissors 0:6757f7363a9f 129 }
Sissors 0:6757f7363a9f 130 if (currentAcceleroRange == MPU6050_ACCELERO_RANGE_4G){
Sissors 0:6757f7363a9f 131 data[0]=(float)temp[0] / 8192.0 * 9.81;
Sissors 0:6757f7363a9f 132 data[1]=(float)temp[1] / 8192.0 * 9.81;
Sissors 0:6757f7363a9f 133 data[2]=(float)temp[2] / 8192.0 * 9.81;
Sissors 0:6757f7363a9f 134 }
Sissors 0:6757f7363a9f 135 if (currentAcceleroRange == MPU6050_ACCELERO_RANGE_8G){
Sissors 0:6757f7363a9f 136 data[0]=(float)temp[0] / 4096.0 * 9.81;
Sissors 0:6757f7363a9f 137 data[1]=(float)temp[1] / 4096.0 * 9.81;
Sissors 0:6757f7363a9f 138 data[2]=(float)temp[2] / 4096.0 * 9.81;
Sissors 0:6757f7363a9f 139 }
Sissors 0:6757f7363a9f 140 if (currentAcceleroRange == MPU6050_ACCELERO_RANGE_16G){
Sissors 0:6757f7363a9f 141 data[0]=(float)temp[0] / 2048.0 * 9.81;
Sissors 0:6757f7363a9f 142 data[1]=(float)temp[1] / 2048.0 * 9.81;
Sissors 0:6757f7363a9f 143 data[2]=(float)temp[2] / 2048.0 * 9.81;
Sissors 0:6757f7363a9f 144 }
Sissors 0:6757f7363a9f 145
Sissors 0:6757f7363a9f 146 #ifdef DOUBLE_ACCELERO
Sissors 0:6757f7363a9f 147 data[0]*=2;
Sissors 0:6757f7363a9f 148 data[1]*=2;
Sissors 0:6757f7363a9f 149 data[2]*=2;
Sissors 0:6757f7363a9f 150 #endif
Sissors 0:6757f7363a9f 151 }
Sissors 0:6757f7363a9f 152 //--------------------------------------------------
Sissors 0:6757f7363a9f 153 //------------------Gyroscope-----------------------
Sissors 0:6757f7363a9f 154 //--------------------------------------------------
Sissors 0:6757f7363a9f 155 void MPU6050::setGyroRange( char range ) {
Sissors 0:6757f7363a9f 156 char temp;
Sissors 0:6757f7363a9f 157 currentGyroRange = range;
Sissors 0:6757f7363a9f 158 range = range & 0x03;
Sissors 0:6757f7363a9f 159 temp = this->read(MPU6050_GYRO_CONFIG_REG);
Sissors 0:6757f7363a9f 160 temp &= ~(3<<3);
khaiminhvn 13:23c9db5753c8 161 temp = temp + (range<<3);
Sissors 0:6757f7363a9f 162 this->write(MPU6050_GYRO_CONFIG_REG, temp);
Sissors 0:6757f7363a9f 163 }
Sissors 0:6757f7363a9f 164
Sissors 0:6757f7363a9f 165 int MPU6050::getGyroRawX( void ) {
Sissors 0:6757f7363a9f 166 short retval;
Sissors 0:6757f7363a9f 167 char data[2];
Sissors 0:6757f7363a9f 168 this->read(MPU6050_GYRO_XOUT_H_REG, data, 2);
Sissors 0:6757f7363a9f 169 retval = (data[0]<<8) + data[1];
Sissors 0:6757f7363a9f 170 return (int)retval;
Sissors 0:6757f7363a9f 171 }
Sissors 0:6757f7363a9f 172
Sissors 0:6757f7363a9f 173 int MPU6050::getGyroRawY( void ) {
Sissors 0:6757f7363a9f 174 short retval;
Sissors 0:6757f7363a9f 175 char data[2];
Sissors 0:6757f7363a9f 176 this->read(MPU6050_GYRO_YOUT_H_REG, data, 2);
Sissors 0:6757f7363a9f 177 retval = (data[0]<<8) + data[1];
Sissors 0:6757f7363a9f 178 return (int)retval;
Sissors 0:6757f7363a9f 179 }
Sissors 0:6757f7363a9f 180
Sissors 0:6757f7363a9f 181 int MPU6050::getGyroRawZ( void ) {
Sissors 0:6757f7363a9f 182 short retval;
Sissors 0:6757f7363a9f 183 char data[2];
Sissors 0:6757f7363a9f 184 this->read(MPU6050_GYRO_ZOUT_H_REG, data, 2);
Sissors 0:6757f7363a9f 185 retval = (data[0]<<8) + data[1];
Sissors 0:6757f7363a9f 186 return (int)retval;
Sissors 0:6757f7363a9f 187 }
Sissors 0:6757f7363a9f 188
Sissors 0:6757f7363a9f 189 void MPU6050::getGyroRaw( int *data ) {
Sissors 0:6757f7363a9f 190 char temp[6];
Sissors 0:6757f7363a9f 191 this->read(MPU6050_GYRO_XOUT_H_REG, temp, 6);
Sissors 0:6757f7363a9f 192 data[0] = (int)(short)((temp[0]<<8) + temp[1]);
Sissors 0:6757f7363a9f 193 data[1] = (int)(short)((temp[2]<<8) + temp[3]);
Sissors 0:6757f7363a9f 194 data[2] = (int)(short)((temp[4]<<8) + temp[5]);
Sissors 0:6757f7363a9f 195 }
Sissors 0:6757f7363a9f 196
Sissors 0:6757f7363a9f 197 void MPU6050::getGyro( float *data ) {
Sissors 0:6757f7363a9f 198 int temp[3];
Sissors 0:6757f7363a9f 199 this->getGyroRaw(temp);
Sissors 1:a3366f09e95c 200 if (currentGyroRange == MPU6050_GYRO_RANGE_250) {
moklumbys 3:187152513f8d 201 data[0]=(float)temp[0] / 301.0;
moklumbys 3:187152513f8d 202 data[1]=(float)temp[1] / 301.0;
moklumbys 3:187152513f8d 203 data[2]=(float)temp[2] / 301.0;
moklumbys 3:187152513f8d 204 } //7505.5
Sissors 1:a3366f09e95c 205 if (currentGyroRange == MPU6050_GYRO_RANGE_500){
Sissors 0:6757f7363a9f 206 data[0]=(float)temp[0] / 3752.9;
Sissors 0:6757f7363a9f 207 data[1]=(float)temp[1] / 3752.9;
Sissors 0:6757f7363a9f 208 data[2]=(float)temp[2] / 3752.9;
Sissors 0:6757f7363a9f 209 }
Sissors 1:a3366f09e95c 210 if (currentGyroRange == MPU6050_GYRO_RANGE_1000){
Sissors 0:6757f7363a9f 211 data[0]=(float)temp[0] / 1879.3;;
Sissors 0:6757f7363a9f 212 data[1]=(float)temp[1] / 1879.3;
Sissors 0:6757f7363a9f 213 data[2]=(float)temp[2] / 1879.3;
Sissors 0:6757f7363a9f 214 }
Sissors 1:a3366f09e95c 215 if (currentGyroRange == MPU6050_GYRO_RANGE_2000){
Sissors 0:6757f7363a9f 216 data[0]=(float)temp[0] / 939.7;
Sissors 0:6757f7363a9f 217 data[1]=(float)temp[1] / 939.7;
Sissors 0:6757f7363a9f 218 data[2]=(float)temp[2] / 939.7;
Sissors 0:6757f7363a9f 219 }
Sissors 0:6757f7363a9f 220 }
Sissors 0:6757f7363a9f 221 //--------------------------------------------------
Sissors 0:6757f7363a9f 222 //-------------------Temperature--------------------
Sissors 0:6757f7363a9f 223 //--------------------------------------------------
Sissors 0:6757f7363a9f 224 int MPU6050::getTempRaw( void ) {
Sissors 0:6757f7363a9f 225 short retval;
Sissors 0:6757f7363a9f 226 char data[2];
Sissors 0:6757f7363a9f 227 this->read(MPU6050_TEMP_H_REG, data, 2);
Sissors 0:6757f7363a9f 228 retval = (data[0]<<8) + data[1];
Sissors 0:6757f7363a9f 229 return (int)retval;
Sissors 0:6757f7363a9f 230 }
Sissors 0:6757f7363a9f 231
Sissors 0:6757f7363a9f 232 float MPU6050::getTemp( void ) {
Sissors 0:6757f7363a9f 233 float retval;
Sissors 0:6757f7363a9f 234 retval=(float)this->getTempRaw();
Sissors 0:6757f7363a9f 235 retval=(retval+521.0)/340.0+35.0;
Sissors 0:6757f7363a9f 236 return retval;
Sissors 0:6757f7363a9f 237 }
Sissors 0:6757f7363a9f 238
moklumbys 11:9b414412b09e 239 /**Additional function added by Montvydas Klumbys, which will allow easy offset, angle calculation and much more.
moklumbys 11:9b414412b09e 240 function for getting angles in degrees from accelerometer
moklumbys 11:9b414412b09e 241 */
moklumbys 10:bd9665d14241 242 void MPU6050::getAcceleroAngle( float *data ) {
moklumbys 10:bd9665d14241 243 float temp[3];
moklumbys 10:bd9665d14241 244 this->getAccelero(temp);
moklumbys 10:bd9665d14241 245
moklumbys 10:bd9665d14241 246 data[X_AXIS] = atan (temp[Y_AXIS]/sqrt(pow(temp[X_AXIS], 2) + pow(temp[Z_AXIS], 2))) * RADIANS_TO_DEGREES; //calculate angle x(pitch/roll?) from accellerometer reading
moklumbys 10:bd9665d14241 247 data[Y_AXIS] = atan (-1*temp[X_AXIS]/sqrt(pow(temp[Y_AXIS], 2) + pow(temp[Z_AXIS], 2))) * RADIANS_TO_DEGREES; //calculate angle x(pitch/roll?) from accellerometer reading
moklumbys 10:bd9665d14241 248 data[Z_AXIS] = atan (sqrt(pow(temp[X_AXIS], 2) + pow(temp[Y_AXIS], 2))/temp[Z_AXIS]) * RADIANS_TO_DEGREES; //This one is not used anywhere later on
moklumbys 10:bd9665d14241 249
moklumbys 10:bd9665d14241 250 // data[Y_AXIS] = atan2 (temp[Y_AXIS],temp[Z_AXIS]) * RADIANS_TO_DEGREES; //This spits out values between -180 to 180 (360 degrees)
moklumbys 10:bd9665d14241 251 // data[X_AXIS] = atan2 (-1*temp[X_AXIS], temp[Z_AXIS]) * RADIANS_TO_DEGREES; //but it takes longer and system gets unstable when angles ~90 degrees
moklumbys 10:bd9665d14241 252 }
moklumbys 10:bd9665d14241 253
moklumbys 11:9b414412b09e 254 ///function for getting offset values for the gyro & accelerometer
moklumbys 10:bd9665d14241 255 void MPU6050::getOffset(float *accOffset, float *gyroOffset, int sampleSize){
moklumbys 10:bd9665d14241 256 float gyro[3];
moklumbys 10:bd9665d14241 257 float accAngle[3];
moklumbys 10:bd9665d14241 258
moklumbys 10:bd9665d14241 259 for (int i = 0; i < 3; i++) {
moklumbys 10:bd9665d14241 260 accOffset[i] = 0.0; //initialise offsets to 0.0
moklumbys 10:bd9665d14241 261 gyroOffset[i] = 0.0;
moklumbys 10:bd9665d14241 262 }
moklumbys 10:bd9665d14241 263
moklumbys 10:bd9665d14241 264 for (int i = 0; i < sampleSize; i++){
moklumbys 10:bd9665d14241 265 this->getGyro(gyro); //take real life measurements
moklumbys 10:bd9665d14241 266 this->getAcceleroAngle (accAngle);
moklumbys 10:bd9665d14241 267
moklumbys 10:bd9665d14241 268 for (int j = 0; j < 3; j++){
moklumbys 10:bd9665d14241 269 *(accOffset+j) += accAngle[j]/sampleSize; //average measurements
moklumbys 10:bd9665d14241 270 *(gyroOffset+j) += gyro[j]/sampleSize;
moklumbys 10:bd9665d14241 271 }
khaiminhvn 12:bc6638e00812 272 wait_us (10000); //wait between each reading for accuracy
moklumbys 10:bd9665d14241 273 }
moklumbys 10:bd9665d14241 274 }
moklumbys 10:bd9665d14241 275
moklumbys 11:9b414412b09e 276 ///function for computing angles for roll, pitch anf yaw
moklumbys 11:9b414412b09e 277 void MPU6050::computeAngle (float *angle, float *accOffset, float *gyroOffset, float interval){
moklumbys 10:bd9665d14241 278 float gyro[3];
moklumbys 10:bd9665d14241 279 float accAngle[3];
moklumbys 10:bd9665d14241 280
moklumbys 10:bd9665d14241 281 this->getGyro(gyro); //get gyro value in rad/s
moklumbys 10:bd9665d14241 282 this->getAcceleroAngle(accAngle); //get angle from accelerometer
moklumbys 10:bd9665d14241 283
moklumbys 10:bd9665d14241 284 for (int i = 0; i < 3; i++){
moklumbys 10:bd9665d14241 285 gyro[i] -= gyroOffset[i]; //substract offset values
moklumbys 10:bd9665d14241 286 accAngle[i] -= accOffset[i];
moklumbys 10:bd9665d14241 287 }
moklumbys 10:bd9665d14241 288
moklumbys 10:bd9665d14241 289 //apply filters on pitch and roll to get accurate angle values
moklumbys 11:9b414412b09e 290 angle[X_AXIS] = alpha * (angle[X_AXIS] + GYRO_SCALE*gyro[X_AXIS]*interval) + (1-alpha)*accAngle[X_AXIS];
moklumbys 11:9b414412b09e 291 angle[Y_AXIS] = alpha * (angle[Y_AXIS] + GYRO_SCALE*gyro[Y_AXIS]*interval) + (1-alpha)*accAngle[Y_AXIS];
moklumbys 10:bd9665d14241 292
moklumbys 10:bd9665d14241 293 //calculate Yaw using just the gyroscope values - inaccurate
moklumbys 11:9b414412b09e 294 angle[Z_AXIS] = angle[Z_AXIS] + GYRO_SCALE*gyro[Z_AXIS]*interval;
moklumbys 10:bd9665d14241 295 }
moklumbys 10:bd9665d14241 296
moklumbys 11:9b414412b09e 297 ///function for setting a different Alpha value, which is used in complemetary filter calculations
moklumbys 10:bd9665d14241 298 void MPU6050::setAlpha(float val){
moklumbys 10:bd9665d14241 299 alpha = val;
moklumbys 10:bd9665d14241 300 }
moklumbys 10:bd9665d14241 301
moklumbys 11:9b414412b09e 302 ///function for enabling interrupts on MPU6050 INT pin, when the data is ready to take
moklumbys 10:bd9665d14241 303 void MPU6050::enableInt( void ){
moklumbys 10:bd9665d14241 304 char temp;
moklumbys 10:bd9665d14241 305 temp = this->read(MPU6050_RA_INT_ENABLE);
moklumbys 10:bd9665d14241 306 temp |= 0x01;
moklumbys 10:bd9665d14241 307 this->write(MPU6050_RA_INT_ENABLE, temp);
moklumbys 10:bd9665d14241 308 }
moklumbys 10:bd9665d14241 309
moklumbys 11:9b414412b09e 310 ///function for disbling interrupts on MPU6050 INT pin, when the data is ready to take
moklumbys 10:bd9665d14241 311 void MPU6050::disableInt ( void ){
moklumbys 10:bd9665d14241 312 char temp;
moklumbys 10:bd9665d14241 313 temp = this->read(MPU6050_RA_INT_ENABLE);
moklumbys 10:bd9665d14241 314 temp &= 0xFE;
moklumbys 10:bd9665d14241 315 this->write(MPU6050_RA_INT_ENABLE, temp);
moklumbys 10:bd9665d14241 316 }