read acceleration and angler ratio from mpu6050 and estimate pitch and roll angle

Dependencies:   mbed

Committer:
ojan
Date:
Wed May 13 04:02:27 2015 +0000
Revision:
3:40559ebef0f1
estimate gravity vector & geomagnetic vector

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ojan 3:40559ebef0f1 1 #pragma once
ojan 3:40559ebef0f1 2
ojan 3:40559ebef0f1 3 const static int mpu_addr = 0xd0;
ojan 3:40559ebef0f1 4
ojan 3:40559ebef0f1 5 typedef union {
ojan 3:40559ebef0f1 6 uint8_t reg[14];
ojan 3:40559ebef0f1 7 struct {
ojan 3:40559ebef0f1 8 uint8_t acc_x_L;
ojan 3:40559ebef0f1 9 uint8_t acc_x_H;
ojan 3:40559ebef0f1 10 uint8_t acc_y_L;
ojan 3:40559ebef0f1 11 uint8_t acc_y_H;
ojan 3:40559ebef0f1 12 uint8_t acc_z_L;
ojan 3:40559ebef0f1 13 uint8_t acc_z_H;
ojan 3:40559ebef0f1 14
ojan 3:40559ebef0f1 15 uint8_t T_L;
ojan 3:40559ebef0f1 16 uint8_t T_H;
ojan 3:40559ebef0f1 17
ojan 3:40559ebef0f1 18 uint8_t gyro_x_L;
ojan 3:40559ebef0f1 19 uint8_t gyro_x_H;
ojan 3:40559ebef0f1 20 uint8_t gyro_y_L;
ojan 3:40559ebef0f1 21 uint8_t gyro_y_H;
ojan 3:40559ebef0f1 22 uint8_t gyro_z_L;
ojan 3:40559ebef0f1 23 uint8_t gyro_z_H;
ojan 3:40559ebef0f1 24 } byte;
ojan 3:40559ebef0f1 25
ojan 3:40559ebef0f1 26 struct {
ojan 3:40559ebef0f1 27 int16_t acc[3];
ojan 3:40559ebef0f1 28
ojan 3:40559ebef0f1 29 int16_t T;
ojan 3:40559ebef0f1 30
ojan 3:40559ebef0f1 31 int16_t gyro[3];
ojan 3:40559ebef0f1 32 } value;
ojan 3:40559ebef0f1 33 } MPU_DATA;
ojan 3:40559ebef0f1 34
ojan 3:40559ebef0f1 35 class MPU6050 {
ojan 3:40559ebef0f1 36 public:
ojan 3:40559ebef0f1 37 MPU6050(I2C* i2c);
ojan 3:40559ebef0f1 38 ~MPU6050();
ojan 3:40559ebef0f1 39
ojan 3:40559ebef0f1 40 int init();
ojan 3:40559ebef0f1 41 int read();
ojan 3:40559ebef0f1 42
ojan 3:40559ebef0f1 43 MPU_DATA data;
ojan 3:40559ebef0f1 44
ojan 3:40559ebef0f1 45 private:
ojan 3:40559ebef0f1 46 I2C* i2c;
ojan 3:40559ebef0f1 47 };