MPU6050のサンプルプログラム2
Dependencies: ConfigFile SDFileSystem mbed
Fork of LAURUS_program by
MPU6050/MPU6050.h@1:6cd6d2760856, 2015-05-24 (annotated)
- Committer:
- ojan
- Date:
- Sun May 24 17:32:47 2015 +0000
- Revision:
- 1:6cd6d2760856
- Parent:
- 0:bc6f14fc60c7
Send all sensor's data to PC
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ojan | 0:bc6f14fc60c7 | 1 | #pragma once |
ojan | 0:bc6f14fc60c7 | 2 | |
ojan | 0:bc6f14fc60c7 | 3 | const static int mpu_addr = 0xd0; |
ojan | 0:bc6f14fc60c7 | 4 | |
ojan | 0:bc6f14fc60c7 | 5 | typedef union { |
ojan | 0:bc6f14fc60c7 | 6 | uint8_t reg[14]; |
ojan | 0:bc6f14fc60c7 | 7 | struct { |
ojan | 0:bc6f14fc60c7 | 8 | uint8_t acc_x_L; |
ojan | 0:bc6f14fc60c7 | 9 | uint8_t acc_x_H; |
ojan | 0:bc6f14fc60c7 | 10 | uint8_t acc_y_L; |
ojan | 0:bc6f14fc60c7 | 11 | uint8_t acc_y_H; |
ojan | 0:bc6f14fc60c7 | 12 | uint8_t acc_z_L; |
ojan | 0:bc6f14fc60c7 | 13 | uint8_t acc_z_H; |
ojan | 0:bc6f14fc60c7 | 14 | |
ojan | 0:bc6f14fc60c7 | 15 | uint8_t T_L; |
ojan | 0:bc6f14fc60c7 | 16 | uint8_t T_H; |
ojan | 0:bc6f14fc60c7 | 17 | |
ojan | 0:bc6f14fc60c7 | 18 | uint8_t gyro_x_L; |
ojan | 0:bc6f14fc60c7 | 19 | uint8_t gyro_x_H; |
ojan | 0:bc6f14fc60c7 | 20 | uint8_t gyro_y_L; |
ojan | 0:bc6f14fc60c7 | 21 | uint8_t gyro_y_H; |
ojan | 0:bc6f14fc60c7 | 22 | uint8_t gyro_z_L; |
ojan | 0:bc6f14fc60c7 | 23 | uint8_t gyro_z_H; |
ojan | 0:bc6f14fc60c7 | 24 | } byte; |
ojan | 0:bc6f14fc60c7 | 25 | |
ojan | 0:bc6f14fc60c7 | 26 | struct { |
ojan | 0:bc6f14fc60c7 | 27 | int16_t acc[3]; |
ojan | 0:bc6f14fc60c7 | 28 | |
ojan | 0:bc6f14fc60c7 | 29 | int16_t T; |
ojan | 0:bc6f14fc60c7 | 30 | |
ojan | 0:bc6f14fc60c7 | 31 | int16_t gyro[3]; |
ojan | 0:bc6f14fc60c7 | 32 | } value; |
ojan | 0:bc6f14fc60c7 | 33 | } MPU_DATA; |
ojan | 0:bc6f14fc60c7 | 34 | |
ojan | 0:bc6f14fc60c7 | 35 | class MPU6050 { |
ojan | 0:bc6f14fc60c7 | 36 | public: |
ojan | 1:6cd6d2760856 | 37 | MPU6050(I2C* p_i2c); |
ojan | 0:bc6f14fc60c7 | 38 | ~MPU6050(); |
ojan | 0:bc6f14fc60c7 | 39 | |
ojan | 0:bc6f14fc60c7 | 40 | int init(); |
ojan | 0:bc6f14fc60c7 | 41 | int read(); |
ojan | 0:bc6f14fc60c7 | 42 | |
ojan | 0:bc6f14fc60c7 | 43 | MPU_DATA data; |
ojan | 0:bc6f14fc60c7 | 44 | |
ojan | 0:bc6f14fc60c7 | 45 | private: |
ojan | 0:bc6f14fc60c7 | 46 | I2C* i2c; |
ojan | 0:bc6f14fc60c7 | 47 | }; |