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.
Fork of MPU6050 by
MPU6050.h
00001 /* 00002 * Copyright (c) 2015, Baser Kandehir, baser.kandehir@ieee.metu.edu.tr 00003 * 00004 * Permission is hereby granted, free of charge, to any person obtaining a copy 00005 * of this software and associated documentation files (the "Software"), to deal 00006 * in the Software without restriction, including without limitation the rights 00007 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00008 * copies of the Software, and to permit persons to whom the Software is 00009 * furnished to do so, subject to the following conditions: 00010 * 00011 * The above copyright notice and this permission notice shall be included in 00012 * all copies or substantial portions of the Software. 00013 * 00014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00015 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00016 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00017 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00018 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00019 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00020 * THE SOFTWARE. 00021 * 00022 */ 00023 00024 // Most of the code is adapted from Kris Winer's MPU6050 library 00025 00026 #ifndef MPU6050_H 00027 #define MPU6050_H 00028 00029 #include "mbed.h" 00030 #include "math.h" 00031 #include "MPU6050RegDef.h" 00032 00033 #define PI 3.14159265359 // This value will be used when calculating angles 00034 #define dt 0.005 // 200 Hz sampling period 00035 00036 extern float aRes, gRes; 00037 00038 /* whoAmI func uses this func, variables etc */ 00039 extern Ticker toggler1; 00040 extern Serial pc; 00041 extern DigitalOut led2; 00042 extern void toggle_led1(); 00043 00044 /* Sensor datas to be used in program */ 00045 extern float ax,ay,az; 00046 extern float gx,gy,gz; 00047 extern int16_t accelData[3],gyroData[3],tempData; 00048 extern float accelBias[3], gyroBias[3]; 00049 00050 /* Function Prototypes */ 00051 class MPU6050 00052 { 00053 protected: 00054 public: 00055 void getAres(); 00056 void getGres(); 00057 void writeByte(uint8_t address, uint8_t subAddress, uint8_t data); 00058 char readByte(uint8_t address, uint8_t subAddress); 00059 void readBytes(uint8_t address, uint8_t subAddress, uint8_t byteNum, uint8_t* dest); 00060 void whoAmI(); 00061 void init(); 00062 void reset(); 00063 void readAccelData(int16_t* dest); 00064 void readGyroData(int16_t* dest); 00065 int16_t readTempData(); 00066 void calibrate(float* dest1, float* dest2); 00067 void complementaryFilter(float* pitch, float* roll); 00068 }; 00069 00070 #endif
Generated on Sat Jul 16 2022 11:48:24 by
 1.7.2
 1.7.2 
    