blob: 5c0cee1b1184e02dcfdcf340e815ae3f4a75cac5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
/*
* Copyright © 2012 Keith Packard <keithp@keithp.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
#ifndef _AO_MPU6000_H_
#define _AO_MPU6000_H_
#define MPU6000_ADDR_WRITE 0xd0
#define MPU6000_ADDR_READ 0xd1
#define MPU6000_SMPRT_DIV 0x19
#define MPU6000_CONFIG 0x1a
#define MPU6000_CONFIG_EXT_SYNC_SET 3
#define MPU6000_CONFIG_EXT_SYNC_SET_DISABLED 0
#define MPU6000_CONFIG_EXT_SYNC_SET_TEMP_OUT_L 1
#define MPU6000_CONFIG_EXT_SYNC_SET_GYRO_XOUT_L 2
#define MPU6000_CONFIG_EXT_SYNC_SET_GYRO_YOUT_L 3
#define MPU6000_CONFIG_EXT_SYNC_SET_GYRO_ZOUT_L 4
#define MPU6000_CONFIG_EXT_SYNC_SET_ACCEL_XOUT_L 5
#define MPU6000_CONFIG_EXT_SYNC_SET_ACCEL_YOUT_L 6
#define MPU6000_CONFIG_EXT_SYNC_SET_ACCEL_ZOUT_L 7
#define MPU6000_CONFIG_EXT_SYNC_SET_MASK 7
#define MPU6000_CONFIG_DLPF_CFG 0
#define MPU6000_CONFIG_DLPF_CFG_260_256 0
#define MPU6000_CONFIG_DLPF_CFG_184_188 1
#define MPU6000_CONFIG_DLPF_CFG_94_98 2
#define MPU6000_CONFIG_DLPF_CFG_44_42 3
#define MPU6000_CONFIG_DLPF_CFG_21_20 4
#define MPU6000_CONFIG_DLPF_CFG_10_10 5
#define MPU6000_CONFIG_DLPF_CFG_5_5 6
#define MPU6000_CONFIG_DLPF_CFG_MASK 7
#define MPU6000_GYRO_CONFIG 0x1b
# define MPU600_GYRO_CONFIG_XG_ST 7
# define MPU600_GYRO_CONFIG_YG_ST 6
# define MPU600_GYRO_CONFIG_ZG_ST 5
# define MPU600_GYRO_CONFIG_FS_SEL 3
# define MPU600_GYRO_CONFIG_FS_SEL_250 0
# define MPU600_GYRO_CONFIG_FS_SEL_500 1
# define MPU600_GYRO_CONFIG_FS_SEL_1000 2
# define MPU600_GYRO_CONFIG_FS_SEL_2000 3
# define MPU600_GYRO_CONFIG_FS_SEL_MASK 3
#define MPU6000_ACCEL_CONFIG 0x1c
# define MPU600_ACCEL_CONFIG_XA_ST 7
# define MPU600_ACCEL_CONFIG_YA_ST 6
# define MPU600_ACCEL_CONFIG_ZA_ST 5
# define MPU600_ACCEL_CONFIG_AFS_SEL 3
# define MPU600_ACCEL_CONFIG_AFS_SEL_2G 0
# define MPU600_ACCEL_CONFIG_AFS_SEL_4G 1
# define MPU600_ACCEL_CONFIG_AFS_SEL_8G 2
# define MPU600_ACCEL_CONFIG_AFS_SEL_16G 3
# define MPU600_ACCEL_CONFIG_AFS_SEL_MASK 3
# define MPU600_ACCEL_CONFIG_ACCEL_HPF 0
# define MPU600_ACCEL_CONFIG_ACCEL_HPF_RESET 0
# define MPU600_ACCEL_CONFIG_ACCEL_HPF_5Hz 1
# define MPU600_ACCEL_CONFIG_ACCEL_HPF_2_5Hz 2
# define MPU600_ACCEL_CONFIG_ACCEL_HPF_1_25Hz 3
# define MPU600_ACCEL_CONFIG_ACCEL_HPF_0_63Hz 4
# define MPU600_ACCEL_CONFIG_ACCEL_HPF_HOLD 7
# define MPU600_ACCEL_CONFIG_ACCEL_HPF_MASK 7
#define MPU6000_INT_ENABLE 0x38
#define MPU6000_INT_ENABLE_FF_EN 7
#define MPU6000_INT_ENABLE_MOT_EN 6
#define MPU6000_INT_ENABLE_ZMOT_EN 5
#define MPU6000_INT_ENABLE_FIFO_OFLOW_EN 4
#define MPU6000_INT_ENABLE_I2C_MST_INT_EN 3
#define MPU6000_INT_ENABLE_DATA_RDY_EN 0
#define MPU6000_INT_STATUS 0x3a
#define MPU6000_INT_STATUS_FF_EN 7
#define MPU6000_INT_STATUS_MOT_EN 6
#define MPU6000_INT_STATUS_ZMOT_EN 5
#define MPU6000_INT_STATUS_FIFO_OFLOW_EN 4
#define MPU6000_INT_STATUS_I2C_MST_INT_EN 3
#define MPU6000_INT_STATUS_DATA_RDY_EN 0
#define MPU6000_ACCEL_XOUT_H 0x3b
#define MPU6000_ACCEL_XOUT_L 0x3c
#define MPU6000_ACCEL_YOUT_H 0x3d
#define MPU6000_ACCEL_YOUT_L 0x3e
#define MPU6000_ACCEL_ZOUT_H 0x3f
#define MPU6000_ACCEL_ZOUT_L 0x40
#define MPU6000_TEMP_H 0x41
#define MPU6000_TEMP_L 0x42
#define MPU6000_GYRO_XOUT_H 0x43
#define MPU6000_GYRO_XOUT_L 0x44
#define MPU6000_GYRO_YOUT_H 0x45
#define MPU6000_GYRO_YOUT_L 0x46
#define MPU6000_GYRO_ZOUT_H 0x47
#define MPU6000_GYRO_ZOUT_L 0x48
#define MPU6000_SIGNAL_PATH_RESET 0x68
#define MPU6000_SIGNAL_PATH_RESET_GYRO_RESET 2
#define MPU6000_SIGNAL_PATH_RESET_ACCEL_RESET 1
#define MPU6000_SIGNAL_PATH_RESET_TEMP_RESET 0
#define MPU6000_USER_CONTROL 0x6a
#define MPU6000_USER_CONTROL_FIFO_EN 6
#define MPU6000_USER_CONTROL_I2C_MST_EN 5
#define MPU6000_USER_CONTROL_I2C_IF_DIS 4
#define MPU6000_USER_CONTROL_FIFO_RESET 2
#define MPU6000_USER_CONTROL_I2C_MST_RESET 1
#define MPU6000_USER_CONTROL_SIG_COND_RESET 0
#define MPU6000_PWR_MGMT_1 0x6b
#define MPU6000_PWR_MGMT_1_DEVICE_RESET 7
#define MPU6000_PWR_MGMT_1_SLEEP 6
#define MPU6000_PWR_MGMT_1_CYCLE 5
#define MPU6000_PWR_MGMT_1_TEMP_DIS 3
#define MPU6000_PWR_MGMT_1_CLKSEL 0
#define MPU6000_PWR_MGMT_1_CLKSEL_INTERNAL 0
#define MPU6000_PWR_MGMT_1_CLKSEL_PLL_X_AXIS 1
#define MPU6000_PWR_MGMT_1_CLKSEL_PLL_Y_AXIS 2
#define MPU6000_PWR_MGMT_1_CLKSEL_PLL_Z_AXIS 3
#define MPU6000_PWR_MGMT_1_CLKSEL_PLL_EXTERNAL_32K 4
#define MPU6000_PWR_MGMT_1_CLKSEL_PLL_EXTERNAL_19M 5
#define MPU6000_PWR_MGMT_1_CLKSEL_STOP 7
#define MPU6000_PWR_MGMT_1_CLKSEL_MASK 7
#define MPU6000_PWR_MGMT_2 0x6c
#define MPU6000_WHO_AM_I 0x75
/* Self test acceleration is approximately 0.5g */
#define MPU6000_ST_ACCEL(full_scale) (32767 / ((full_scale) * 2))
/* Self test gyro is approximately 50°/s */
#define MPU6000_ST_GYRO(full_scale) ((int16_t) (((int32_t) 32767 * (int32_t) 50) / (full_scale)))
#define MPU6000_GYRO_FULLSCALE 2000
#define MPU6000_ACCEL_FULLSCALE 16
struct ao_mpu6000_sample {
int16_t accel_x;
int16_t accel_y;
int16_t accel_z;
int16_t temp;
int16_t gyro_x;
int16_t gyro_y;
int16_t gyro_z;
};
void
ao_mpu6000_init(void);
#endif /* _AO_MPU6000_H_ */
|