NuMaker-PFM-NUC472: I2C0 read on-board MPU6500 and calculate tilt angle

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers mpu6500.h Source File

mpu6500.h

00001 #define MPU6500_SELF_TEST_X_GYRO    0x00 
00002 #define MPU6500_SELF_TEST_Y_GYRO    0x01
00003 #define MPU6500_SELF_TEST_Z_GYRO    0x02
00004 #define MPU6500_SELF_TEST_X_ACCEL   0x0D
00005 #define MPU6500_SELF_TEST_Y_ACCEL   0x0E
00006 #define MPU6500_SELF_TEST_Z_ACCEL   0x0F
00007 #define MPU6500_XG_OFFSET_H         0x13
00008 #define MPU6500_XG_OFFSET_L         0x14
00009 #define MPU6500_YG_OFFSET_H         0x15
00010 #define MPU6500_YG_OFFSET_L         0x16
00011 #define MPU6500_ZG_OFFSET_H         0x17
00012 #define MPU6500_ZG_OFFSET_L         0x18
00013 #define MPU6500_SMPLRT_DIV          0x19
00014 #define MPU6500_CONFIG              0x1A
00015 #define MPU6500_GYRO_CONFIG         0x1B
00016 #define MPU6500_ACCEL_CONFIG        0x1C
00017 #define MPU6500_ACCEL_CONFIG2       0x1D
00018 #define MPU6500_LP_ACCEL_ODR        0x1E
00019 #define MPU6500_WOM_THR             0x1F
00020 #define MPU6500_FIFO_EN             0x23
00021 #define MPU6500_I2C_MST_CTRL        0x24
00022 #define MPU6500_I2C_SLV0_ADDR       0x25
00023 #define MPU6500_I2C_SLV0_REG        0x26
00024 #define MPU6500_I2C_SLV0_CTRL       0x27
00025 #define MPU6500_I2C_SLV1_ADDR       0x28
00026 #define MPU6500_I2C_SLV1_REG        0x29
00027 #define MPU6500_I2C_SLV1_CTRL       0x2A
00028 #define MPU6500_I2C_SLV2_ADDR       0x2B
00029 #define MPU6500_I2C_SLV2_REG        0x2C
00030 #define MPU6500_I2C_SLV2_CTRL       0x2D
00031 #define MPU6500_I2C_SLV3_ADDR       0x2E
00032 #define MPU6500_I2C_SLV3_REG        0x2F
00033 #define MPU6500_I2C_SLV3_CTRL       0x30
00034 #define MPU6500_I2C_SLV4_ADDR       0x31
00035 #define MPU6500_I2C_SLV4_REG        0x32
00036 #define MPU6500_I2C_SLV4_DO         0x33
00037 #define MPU6500_I2C_SLV4_CTRL       0x34
00038 #define MPU6500_I2C_SLV4_DI         0x35
00039 #define MPU6500_I2C_MST_STATUS      0x36
00040 #define MPU6500_INT_PIN_CFG         0x37
00041 #define MPU6500_INT_ENABLE          0x38
00042 #define MPU6500_INT_STATUS          0x3A
00043 #define MPU6500_ACCEL_XOUT_H        0x3B
00044 #define MPU6500_ACCEL_XOUT_L        0x3C
00045 #define MPU6500_ACCEL_YOUT_H        0x3D
00046 #define MPU6500_ACCEL_YOUT_L        0x3E
00047 #define MPU6500_ACCEL_ZOUT_H        0x3F
00048 #define MPU6500_ACCEL_ZOUT_L        0x40
00049 #define MPU6500_TEMP_OUT_H          0x41
00050 #define MPU6500_TEMP_OUT_L          0x42
00051 #define MPU6500_GYRO_XOUT_H         0x43
00052 #define MPU6500_GYRO_XOUT_L         0x44
00053 #define MPU6500_GYRO_YOUT_H         0x45
00054 #define MPU6500_GYRO_YOUT_L         0x46
00055 #define MPU6500_GYRO_ZOUT_H         0x47
00056 #define MPU6500_GYRO_ZOUT_L         0x48
00057 #define MPU6500_EXT_SENS_DATA_00    0x49
00058 #define MPU6500_EXT_SENS_DATA_01    0x4A
00059 #define MPU6500_EXT_SENS_DATA_02    0x4B
00060 #define MPU6500_EXT_SENS_DATA_03    0x4C
00061 #define MPU6500_EXT_SENS_DATA_04    0x4D
00062 #define MPU6500_EXT_SENS_DATA_05    0x4E
00063 #define MPU6500_EXT_SENS_DATA_06    0x4F
00064 #define MPU6500_EXT_SENS_DATA_07    0x50
00065 #define MPU6500_EXT_SENS_DATA_08    0x51
00066 #define MPU6500_EXT_SENS_DATA_09    0x52
00067 #define MPU6500_EXT_SENS_DATA_10    0x53
00068 #define MPU6500_EXT_SENS_DATA_11    0x54
00069 #define MPU6500_EXT_SENS_DATA_12    0x55
00070 #define MPU6500_EXT_SENS_DATA_13    0x56
00071 #define MPU6500_EXT_SENS_DATA_14    0x57
00072 #define MPU6500_EXT_SENS_DATA_15    0x58
00073 #define MPU6500_EXT_SENS_DATA_16    0x59
00074 #define MPU6500_EXT_SENS_DATA_17    0x5A
00075 #define MPU6500_EXT_SENS_DATA_18    0x5B
00076 #define MPU6500_EXT_SENS_DATA_19    0x5C
00077 #define MPU6500_EXT_SENS_DATA_20    0x5D
00078 #define MPU6500_EXT_SENS_DATA_21    0x5E
00079 #define MPU6500_EXT_SENS_DATA_22    0x5F
00080 #define MPU6500_EXT_SENS_DATA_23    0x60
00081 #define MPU6500_I2C_SLV0_DO         0x63
00082 #define MPU6500_I2C_SLV1_DO         0x64
00083 #define MPU6500_I2C_SLV2_DO         0x65
00084 #define MPU6500_I2C_SLV3_DO         0x66
00085 #define MPU6500_I2C_MST_DELAY_CTRL  0x67
00086 #define MPU6500_SIGNAL_PATH_RESET   0x68
00087 #define MPU6500_ACCEL_INTEL_CTRL    0x69
00088 #define MPU6500_USER_CTRL           0x6A
00089 #define MPU6500_PWR_MGMT_1          0x6B
00090 #define MPU6500_PWR_MGMT_2          0x6C
00091 #define MPU6500_FIFO_COUNT_H        0x72
00092 #define MPU6500_FIFO_COUNT_L        0x73
00093 #define MPU6500_FIFO_R_W            0x74
00094 #define MPU6500_WHO_AM_I            0x75
00095 #define MPU6500_XA_OFFSET_H         0x77
00096 #define MPU6500_XA_OFFSET_L         0x78
00097 #define MPU6500_YA_OFFSET_H         0x79
00098 #define MPU6500_YA_OFFSET_L         0x7A
00099 #define MPU6500_ZA_OFFSET_H         0x7D
00100 #define MPU6500_ZA_OFFSET_L         0x7E
00101 
00102 #define MPU6500_slave_addr          0xD0
00103 
00104 class MPU6500 {
00105     public:
00106         void    initialize();
00107         int16_t getAccelXvalue();
00108         int16_t getAccelYvalue();
00109         int16_t getAccelZvalue();
00110         int16_t getGyroXvalue();
00111         int16_t getGyroYvalue();
00112         int16_t getGyroZvalue();
00113 };