I2C通信を使用した角速度測定、LCD表示サンプル

Dependencies:   mbed mbed_mpu6050_i2c_raw_register AQM0802

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers mpu6050.h Source File

mpu6050.h

00001 #include "mbed.h"
00002 
00003 #ifndef MPU6050_H
00004 #define MPU6050_H
00005 
00006 enum {
00007     MAX_ACC_2G,
00008     MAX_ACC_4G,
00009     MAX_ACC_8G,
00010     MAX_ACC_16G,
00011 };
00012 
00013 enum {
00014     MAX_GYRO_250degpersec,
00015     MAX_GYRO_500degpersec,
00016     MAX_GYRO_1000degpersec,
00017     MAX_GYRO_2000degpersec,
00018 };
00019 
00020 class MPU6050
00021 {
00022 public:
00023     MPU6050(PinName i2c_sda, PinName i2c_scl);
00024     ~MPU6050();
00025     void readAccelemeter(double &acc_x, double &acc_y, double &acc_z);
00026     void readGyroscope(double &gyro_x, double &gyro_y, double &gyro_z);
00027     void setMaxScale(int max_acc, int max_gyro);
00028     void getMaxScale(int &acc, int &gyro);
00029     void setSleep(bool sleep);
00030 private:
00031     I2C i2c;
00032     int address;
00033     double rate_accelemeter;
00034     double rate_gyroscope;
00035     char readByte(char reg);
00036     void writeByte(char reg, char data);
00037 };
00038 
00039 #endif // MPU6050_H