Kuon  1.1.3
RoadNarrows Robotics Large Outdoor Mobile Robot Project
MPU6050.h
1 #ifndef _MPU6050_H
2 #define _MPU6050_H
3 
4 #include <stdlib.h>
5 #include <stdint.h>
6 #include <string.h>
7 #include <dirent.h>
8 #include <sys/types.h>
9 #include <sys/stat.h>
10 #include <sys/time.h>
11 #include <sys/ioctl.h>
12 #include <termios.h>
13 #include <unistd.h>
14 #include <stdarg.h>
15 #include <time.h>
16 #include <math.h>
17 #include <stdio.h>
18 #include "rnr/i2c.h"
19 #include <limits.h>
20 
21 
22 #define MPU_ADDR 0x69
23 #define SMPRT_DIV 0x19
24 #define CONFIG 0x1A
25 #define GYRO_CONFIG 0x1B
26 #define ACCEL_CONFIG 0x1C
27 #define FIFO_EN 0x23
28 #define USER_CTRL 0x6A
29 #define PWR_MGMT_1 0x6B
30 #define PWR_MGMT_2 0x6C
31 #define I2C_MST_CTRL 0x24
32 #define HIGH_AX 0x3B
33 #define LOW_AX 0x3C
34 #define HIGH_AY 0x3D
35 #define LOW_AY 0x3E
36 #define HIGH_AZ 0x3F
37 #define LOW_AZ 0x40
38 #define HIGH_GX 0x43
39 #define LOW_GX 0x44
40 #define HIGH_GY 0x45
41 #define LOW_GY 0x46
42 #define HIGH_GZ 0x47
43 #define LOW_GZ 0x48
44 #define CALIB_COUNT 100
45 
46 
47 float GyOX = 0.0;
48 float GyOY = 0.0;
49 float GyOZ = 0.0;
50 
51 void initMPU6050(i2c_t *sensor);
52 
53 void timer_mark(struct timeval *pTvMark);
54 
55 uint_t timer_elapsed(struct timeval *pTvMark);
56 
57 void Seti2cReg(i2c_t *sensor, uint8_t registr, uint8_t buffr);
58 
59 float ReadSingleValue(i2c_t *sensor, uint8_t highRegistr, uint8_t lowRegistr);
60 
61 void BulkUpdate(i2c_t *sensor,
62  float *acx, float *acy, float *acz,
63  float *gyx, float *gyy, float *gyz );
64 #endif