blob: 936d1369d3bde17f5178e9d5880aeebb4c56e541 [file] [log] [blame]
Flemmard0604a8e2013-05-23 16:15:48 -07001/*
2 $License:
3 Copyright (C) 2010 InvenSense Corporation, All Rights Reserved.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 $
18 */
19
20#ifndef __MPU3050_H_
21#define __MPU3050_H_
22
23#ifdef __KERNEL__
24#include <linux/types.h>
25#endif
26
27#ifdef M_HW
28#error MPU6000 build including MPU3050 header
29#endif
30
31#define MPU_NAME "mpu3050"
32#define DEFAULT_MPU_SLAVEADDR 0x68
33
34enum mpu_register {
35 MPUREG_WHO_AM_I = 0,
36 MPUREG_PRODUCT_ID,
37 MPUREG_02_RSVD,
38 MPUREG_03_RSVD,
39 MPUREG_04_RSVD,
40 MPUREG_XG_OFFS_TC,
41 MPUREG_06_RSVD,
42 MPUREG_07_RSVD,
43 MPUREG_YG_OFFS_TC,
44 MPUREG_09_RSVD,
45 MPUREG_0A_RSVD,
46 MPUREG_ZG_OFFS_TC,
47 MPUREG_X_OFFS_USRH,
48 MPUREG_X_OFFS_USRL,
49 MPUREG_Y_OFFS_USRH,
50 MPUREG_Y_OFFS_USRL,
51 MPUREG_Z_OFFS_USRH,
52 MPUREG_Z_OFFS_USRL,
53 MPUREG_FIFO_EN1,
54 MPUREG_FIFO_EN2,
55 MPUREG_AUX_SLV_ADDR,
56 MPUREG_SMPLRT_DIV,
57 MPUREG_DLPF_FS_SYNC,
58 MPUREG_INT_CFG,
59 MPUREG_ACCEL_BURST_ADDR,
60 MPUREG_19_RSVD,
61 MPUREG_INT_STATUS,
62 MPUREG_TEMP_OUT_H,
63 MPUREG_TEMP_OUT_L,
64 MPUREG_GYRO_XOUT_H,
65 MPUREG_GYRO_XOUT_L,
66 MPUREG_GYRO_YOUT_H,
67 MPUREG_GYRO_YOUT_L,
68 MPUREG_GYRO_ZOUT_H,
69 MPUREG_GYRO_ZOUT_L,
70 MPUREG_23_RSVD,
71 MPUREG_24_RSVD,
72 MPUREG_25_RSVD,
73 MPUREG_26_RSVD,
74 MPUREG_27_RSVD,
75 MPUREG_28_RSVD,
76 MPUREG_29_RSVD,
77 MPUREG_2A_RSVD,
78 MPUREG_2B_RSVD,
79 MPUREG_2C_RSVD,
80 MPUREG_2D_RSVD,
81 MPUREG_2E_RSVD,
82 MPUREG_2F_RSVD,
83 MPUREG_30_RSVD,
84 MPUREG_31_RSVD,
85 MPUREG_32_RSVD,
86 MPUREG_33_RSVD,
87 MPUREG_34_RSVD,
88 MPUREG_DMP_CFG_1,
89 MPUREG_DMP_CFG_2,
90 MPUREG_BANK_SEL,
91 MPUREG_MEM_START_ADDR,
92 MPUREG_MEM_R_W,
93 MPUREG_FIFO_COUNTH,
94 MPUREG_FIFO_COUNTL,
95 MPUREG_FIFO_R_W,
96 MPUREG_USER_CTRL,
97 MPUREG_PWR_MGM,
98 MPUREG_3F_RSVD,
99 NUM_OF_MPU_REGISTERS
100};
101
102
103#define BIT_TEMP_OUT 0x80
104#define BIT_GYRO_XOUT 0x40
105#define BIT_GYRO_YOUT 0x20
106#define BIT_GYRO_ZOUT 0x10
107#define BIT_ACCEL_XOUT 0x08
108#define BIT_ACCEL_YOUT 0x04
109#define BIT_ACCEL_ZOUT 0x02
110#define BIT_AUX_1OUT 0x01
111#define BIT_AUX_2OUT 0x02
112#define BIT_AUX_3OUT 0x01
113#define BITS_EXT_SYNC_NONE 0x00
114#define BITS_EXT_SYNC_TEMP 0x20
115#define BITS_EXT_SYNC_GYROX 0x40
116#define BITS_EXT_SYNC_GYROY 0x60
117#define BITS_EXT_SYNC_GYROZ 0x80
118#define BITS_EXT_SYNC_ACCELX 0xA0
119#define BITS_EXT_SYNC_ACCELY 0xC0
120#define BITS_EXT_SYNC_ACCELZ 0xE0
121#define BITS_EXT_SYNC_MASK 0xE0
122#define BITS_FS_250DPS 0x00
123#define BITS_FS_500DPS 0x08
124#define BITS_FS_1000DPS 0x10
125#define BITS_FS_2000DPS 0x18
126#define BITS_FS_MASK 0x18
127#define BITS_DLPF_CFG_256HZ_NOLPF2 0x00
128#define BITS_DLPF_CFG_188HZ 0x01
129#define BITS_DLPF_CFG_98HZ 0x02
130#define BITS_DLPF_CFG_42HZ 0x03
131#define BITS_DLPF_CFG_20HZ 0x04
132#define BITS_DLPF_CFG_10HZ 0x05
133#define BITS_DLPF_CFG_5HZ 0x06
134#define BITS_DLPF_CFG_2100HZ_NOLPF 0x07
135#define BITS_DLPF_CFG_MASK 0x07
136#define BIT_ACTL 0x80
137#define BIT_ACTL_LOW 0x80
138#define BIT_ACTL_HIGH 0x00
139#define BIT_OPEN 0x40
140#define BIT_OPEN_DRAIN 0x40
141#define BIT_PUSH_PULL 0x00
142#define BIT_LATCH_INT_EN 0x20
143#define BIT_LATCH_INT_EN 0x20
144#define BIT_INT_PULSE_WIDTH_50US 0x00
145#define BIT_INT_ANYRD_2CLEAR 0x10
146#define BIT_INT_STAT_READ_2CLEAR 0x00
147#define BIT_MPU_RDY_EN 0x04
148#define BIT_DMP_INT_EN 0x02
149#define BIT_RAW_RDY_EN 0x01
150#define BIT_INT_STATUS_FIFO_OVERLOW 0x80
151#define BIT_MPU_RDY 0x04
152#define BIT_DMP_INT 0x02
153#define BIT_RAW_RDY 0x01
154#define BIT_PRFTCH_EN 0x20
155#define BIT_CFG_USER_BANK 0x10
156#define BITS_MEM_SEL 0x0f
157#define BIT_DMP_EN 0x80
158#define BIT_FIFO_EN 0x40
159#define BIT_AUX_IF_EN 0x20
160#define BIT_AUX_RD_LENG 0x10
161#define BIT_AUX_IF_RST 0x08
162#define BIT_DMP_RST 0x04
163#define BIT_FIFO_RST 0x02
164#define BIT_GYRO_RST 0x01
165#define BIT_H_RESET 0x80
166#define BIT_SLEEP 0x40
167#define BIT_STBY_XG 0x20
168#define BIT_STBY_YG 0x10
169#define BIT_STBY_ZG 0x08
170#define BITS_CLKSEL 0x07
171
172#define MPU_SILICON_REV_A4 1
173#define MPU_SILICON_REV_B1 2
174#define MPU_SILICON_REV_B4 3
175#define MPU_SILICON_REV_B6 4
176
177#define MPU_MEM_BANK_SIZE (256)
178#define FIFO_HW_SIZE (512)
179
180enum MPU_MEMORY_BANKS {
181 MPU_MEM_RAM_BANK_0 = 0,
182 MPU_MEM_RAM_BANK_1,
183 MPU_MEM_RAM_BANK_2,
184 MPU_MEM_RAM_BANK_3,
185 MPU_MEM_NUM_RAM_BANKS,
186 MPU_MEM_OTP_BANK_0 = MPU_MEM_NUM_RAM_BANKS,
187
188 MPU_MEM_NUM_BANKS
189};
190
191#define MPU_NUM_AXES (3)
192
193enum mpu_filter {
194 MPU_FILTER_256HZ_NOLPF2 = 0,
195 MPU_FILTER_188HZ,
196 MPU_FILTER_98HZ,
197 MPU_FILTER_42HZ,
198 MPU_FILTER_20HZ,
199 MPU_FILTER_10HZ,
200 MPU_FILTER_5HZ,
201 MPU_FILTER_2100HZ_NOLPF,
202 NUM_MPU_FILTER
203};
204
205enum mpu_fullscale {
206 MPU_FS_250DPS = 0,
207 MPU_FS_500DPS,
208 MPU_FS_1000DPS,
209 MPU_FS_2000DPS,
210 NUM_MPU_FS
211};
212
213enum mpu_clock_sel {
214 MPU_CLK_SEL_INTERNAL = 0,
215 MPU_CLK_SEL_PLLGYROX,
216 MPU_CLK_SEL_PLLGYROY,
217 MPU_CLK_SEL_PLLGYROZ,
218 MPU_CLK_SEL_PLLEXT32K,
219 MPU_CLK_SEL_PLLEXT19M,
220 MPU_CLK_SEL_RESERVED,
221 MPU_CLK_SEL_STOP,
222 NUM_CLK_SEL
223};
224
225enum mpu_ext_sync {
226 MPU_EXT_SYNC_NONE = 0,
227 MPU_EXT_SYNC_TEMP,
228 MPU_EXT_SYNC_GYROX,
229 MPU_EXT_SYNC_GYROY,
230 MPU_EXT_SYNC_GYROZ,
231 MPU_EXT_SYNC_ACCELX,
232 MPU_EXT_SYNC_ACCELY,
233 MPU_EXT_SYNC_ACCELZ,
234 NUM_MPU_EXT_SYNC
235};
236
237#define DLPF_FS_SYNC_VALUE(ext_sync, full_scale, lpf) \
238 ((ext_sync << 5) | (full_scale << 3) | lpf)
239
240#endif