MPU6050 module library

All credit to kriswiner @https://github.com/kriswiner. Just changed some code for my own purposes

Committer:
kohlerba
Date:
Tue Nov 21 20:29:49 2017 +0000
Revision:
0:8a2cac9ba89e
MPU6050 accelerometer;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kohlerba 0:8a2cac9ba89e 1 #ifndef MPU6050_H
kohlerba 0:8a2cac9ba89e 2 #define MPU6050_H
kohlerba 0:8a2cac9ba89e 3
kohlerba 0:8a2cac9ba89e 4 #include "mpu6050_reg.h"
kohlerba 0:8a2cac9ba89e 5 #include "mbed.h"
kohlerba 0:8a2cac9ba89e 6
kohlerba 0:8a2cac9ba89e 7 enum Ascale {
kohlerba 0:8a2cac9ba89e 8 AFS_2G = 0,
kohlerba 0:8a2cac9ba89e 9 AFS_4G,
kohlerba 0:8a2cac9ba89e 10 AFS_8G,
kohlerba 0:8a2cac9ba89e 11 AFS_16G
kohlerba 0:8a2cac9ba89e 12 };
kohlerba 0:8a2cac9ba89e 13
kohlerba 0:8a2cac9ba89e 14 enum Gscale {
kohlerba 0:8a2cac9ba89e 15 GFS_250DPS = 0,
kohlerba 0:8a2cac9ba89e 16 GFS_500DPS,
kohlerba 0:8a2cac9ba89e 17 GFS_1000DPS,
kohlerba 0:8a2cac9ba89e 18 GFS_2000DPS
kohlerba 0:8a2cac9ba89e 19 };
kohlerba 0:8a2cac9ba89e 20
kohlerba 0:8a2cac9ba89e 21 class mpu6050 {
kohlerba 0:8a2cac9ba89e 22 protected:
kohlerba 0:8a2cac9ba89e 23
kohlerba 0:8a2cac9ba89e 24 public:
kohlerba 0:8a2cac9ba89e 25 //wire.h functions
kohlerba 0:8a2cac9ba89e 26 void writeByte(uint8_t address, uint8_t subAddress, uint8_t data);
kohlerba 0:8a2cac9ba89e 27 char readByte(uint8_t address, uint8_t subAddress);
kohlerba 0:8a2cac9ba89e 28 void readBytes(uint8_t address, uint8_t subAddress, uint8_t count, uint8_t * dest);
kohlerba 0:8a2cac9ba89e 29 //mpu6050 functions
kohlerba 0:8a2cac9ba89e 30 void getGres();
kohlerba 0:8a2cac9ba89e 31 void getAres();
kohlerba 0:8a2cac9ba89e 32 void readAccelData(int16_t * destination);
kohlerba 0:8a2cac9ba89e 33 void readGyroData(int16_t * destination);
kohlerba 0:8a2cac9ba89e 34 int16_t readTempData();
kohlerba 0:8a2cac9ba89e 35 void lowPowerAccelOnly();
kohlerba 0:8a2cac9ba89e 36 void reset();
kohlerba 0:8a2cac9ba89e 37 void init();
kohlerba 0:8a2cac9ba89e 38 void calibrate(float * dest1, float * dest2);
kohlerba 0:8a2cac9ba89e 39 void selfTest(float * destination); // Should return percent deviation from factory trim values, +/- 14 or less deviation is a pass
kohlerba 0:8a2cac9ba89e 40 void MadgwickQuaternionUpdate(float ax, float ay, float az, float gx, float gy, float gz);
kohlerba 0:8a2cac9ba89e 41 };
kohlerba 0:8a2cac9ba89e 42
kohlerba 0:8a2cac9ba89e 43 #endif