2 * Copyright © 2019 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
22 struct ao_bmx160_sample {
35 extern struct ao_bmx160_sample ao_bmx160_current;
37 struct ao_bmx160_offset {
50 #define BMX160_CHIPID 0x00
51 #define BMX160_CHIPID_BMX160 0xd8
52 #define BMX160_ERR_REG 0x02
53 #define BMX160_PMU_STATUS 0x03
54 #define BMX160_PMU_STATUS_MAG_IF_PMU_STATUS 0
55 #define BMX160_PMU_STATUS_MAG_IF_PMU_STATUS_SUSPEND 0
56 #define BMX160_PMU_STATUS_MAG_IF_PMU_STATUS_NORMAL 1
57 #define BMX160_PMU_STATUS_MAG_IF_PMU_STATUS_LOW_POWER 2
58 #define BMX160_PMU_STATUS_GYR_PMU_STATUS 2
59 #define BMX160_PMU_STATUS_GYR_PMU_STATUS_SUSPEND 0
60 #define BMX160_PMU_STATUS_GYR_PMU_STATUS_NORMAL 1
61 #define BMX160_PMU_STATUS_GYR_PMU_STATUS_FAST_START_UP 3
62 #define BMX160_PMU_STATUS_ACC_PMU_STATUS 4
63 #define BMX160_PMU_STATUS_ACC_PMU_STATUS_SUSPEND 0
64 #define BMX160_PMU_STATUS_ACC_PMU_STATUS_NORMAL 1
65 #define BMX160_PMU_STATUS_ACC_PMU_STATUS_LOW_POWER 2
66 #define BMX160_DATA_0 0x04
67 #define BMX160_MAG_X_0_7 0x04
68 #define BMX160_MAG_X_8_15 0x05
69 #define BMX160_MAG_Y_0_7 0x06
70 #define BMX160_MAG_Y_8_15 0x07
71 #define BMX160_MAG_Z_0_7 0x08
72 #define BMX160_MAG_Z_8_15 0x09
73 #define BMX160_RHALL_0_7 0x0A
74 #define BMX160_RHALL_8_15 0x0B
75 #define BMX160_GYRO_X_0_7 0x0C
76 #define BMX160_GYRO_X_8_15 0x0D
77 #define BMX160_GYRO_Y_0_7 0x0E
78 #define BMX160_GYRO_Y_8_15 0x0F
79 #define BMX160_GYRO_Z_0_7 0x10
80 #define BMX160_GYRO_Z_8_15 0x11
81 #define BMX160_ACCEL_X_0_7 0x12
82 #define BMX160_ACCEL_X_8_15 0x13
83 #define BMX160_ACCEL_Y_0_7 0x14
84 #define BMX160_ACCEL_Y_8_15 0x15
85 #define BMX160_ACCEL_Z_0_7 0x16
86 #define BMX160_ACCEL_Z_8_15 0x17
87 #define BMX160_SENSORTIME_0_7 0x18
88 #define BMX160_SENSORTIME_8_15 0x19
89 #define BMX160_SENSORTIME_16_23 0x1A
90 #define BMX160_STATUS 0x1B
91 #define BMX160_STATUS_GYR_SELF_TEST_OK 1
92 #define BMX160_STATUS_MAG_MAN_OP 2
93 #define BMX160_STATUS_FOC_RDY 3
94 #define BMX160_STATUS_NVM_RDY 4
95 #define BMX160_STATUS_DRDY_MAG 5
96 #define BMX160_STATUS_DRDY_GYR 6
97 #define BMX160_STATUS_DRDY_ACC 7
98 #define BMX160_INT_STATUS_0 0x1C-0x1F
99 #define BMX160_INT_STATUS_1 0x1D
100 #define BMX160_INT_STATUS_2 0x1E
101 #define BMX160_INT_STATUS_3 0x1F
102 #define BMX160_TEMPERATURE_0_7 0x20
103 #define BMX160_TEMPERATURE_8_15 0x21
104 #define BMX160_FIFO_LENGTH_0_7 0x22
105 #define BMX160_FIFO_LENGTH_8_15 0x23
106 #define BMX160_FIFO_DATA 0x24
107 #define BMX160_ACC_CONF 0x40
108 #define BMX160_ACC_CONF_ACC_ODR 0
109 #define BMX160_ACC_CONF_ACC_ODR_25_32 0x1
110 #define BMX160_ACC_CONF_ACC_ODR_25_16 0x2
111 #define BMX160_ACC_CONF_ACC_ODR_25_8 0x3
112 #define BMX160_ACC_CONF_ACC_ODR_25_4 0x4
113 #define BMX160_ACC_CONF_ACC_ODR_25_2 0x5
114 #define BMX160_ACC_CONF_ACC_ODR_25 0x6
115 #define BMX160_ACC_CONF_ACC_ODR_50 0x7
116 #define BMX160_ACC_CONF_ACC_ODR_100 0x8
117 #define BMX160_ACC_CONF_ACC_ODR_200 0x9
118 #define BMX160_ACC_CONF_ACC_ODR_400 0xa
119 #define BMX160_ACC_CONF_ACC_ODR_800 0xb
120 #define BMX160_ACC_CONF_ACC_ODR_1600 0xc
121 #define BMX160_ACC_CONF_ACC_BWP 4
122 #define BMX160_ACC_CONF_ACC_BWP_NORMAL 0x2
123 #define BMX160_ACC_CONF_ACC_BWP_OSR2 0x1
124 #define BMX160_ACC_CONF_ACC_BWP_OSR4 0x0
125 #define BMX160_ACC_CONF_ACC_US 7
126 #define BMX160_ACC_RANGE 0x41
127 #define BMX160_ACC_RANGE_2G 0x3
128 #define BMX160_ACC_RANGE_4G 0x5
129 #define BMX160_ACC_RANGE_8G 0x8
130 #define BMX160_ACC_RANGE_16G 0xc
131 #define BMX160_ACC_RANGE_
132 #define BMX160_ACC_RANGE_
133 #define BMX160_GYR_CONF 0x42
134 #define BMX160_GYR_CONF_GYR_ODR 0
135 #define BMX160_GYR_CONF_GYR_ODR_25 0x6
136 #define BMX160_GYR_CONF_GYR_ODR_50 0x7
137 #define BMX160_GYR_CONF_GYR_ODR_100 0x8
138 #define BMX160_GYR_CONF_GYR_ODR_200 0x9
139 #define BMX160_GYR_CONF_GYR_ODR_400 0xa
140 #define BMX160_GYR_CONF_GYR_ODR_800 0xb
141 #define BMX160_GYR_CONF_GYR_ODR_1600 0xc
142 #define BMX160_GYR_CONF_GYR_ODR_3200 0xd
143 #define BMX160_GYR_CONF_GYR_BWP 4
144 #define BMX160_GYR_CONF_GYR_BWP_NORMAL 0x2
145 #define BMX160_GYR_CONF_GYR_BWP_OSR2 0x1
146 #define BMX160_GYR_CONF_GYR_BWP_OSR4 0x0
147 #define BMX160_GYR_RANGE 0x43
148 #define BMX160_GYR_RANGE_2000 0x0
149 #define BMX160_GYR_RANGE_1000 0x1
150 #define BMX160_GYR_RANGE_500 0x2
151 #define BMX160_GYR_RANGE_250 0x3
152 #define BMX160_GYR_RANGE_125 0x4
153 #define BMX160_MAG_CONF 0x44
154 #define BMX160_MAG_CONF_MAG_ODR 0
155 #define BMX160_MAG_CONF_MAG_ODR_25_32 0x1
156 #define BMX160_MAG_CONF_MAG_ODR_25_16 0x2
157 #define BMX160_MAG_CONF_MAG_ODR_25_8 0x3
158 #define BMX160_MAG_CONF_MAG_ODR_25_4 0x4
159 #define BMX160_MAG_CONF_MAG_ODR_25_2 0x5
160 #define BMX160_MAG_CONF_MAG_ODR_25 0x6
161 #define BMX160_MAG_CONF_MAG_ODR_50 0x7
162 #define BMX160_MAG_CONF_MAG_ODR_100 0x8
163 #define BMX160_MAG_CONF_MAG_ODR_200 0x9
164 #define BMX160_MAG_CONF_MAG_ODR_400 0xa
165 #define BMX160_MAG_CONF_MAG_ODR_800 0xb
166 #define BMX160_FIFO_DOWNS 0x45
167 #define BMX160_FIFO_CONFIG_0 0x46
168 #define BMX160_FIFO_CONFIG_1 0x47
169 #define BMX160_MAG_IF_0 0x4C
170 #define BMX160_MAG_IF_0_MAG_RD_BURST 0
171 #define BMX160_MAG_IF_0_MAG_OFFSET 2
172 #define BMX160_MAG_IF_0_MAG_MANUAL_EN 7
173 #define BMX160_MAG_IF_1 0x4D
174 #define BMX160_MAG_IF_2 0x4E
175 #define BMX160_MAG_IF_3 0x4F
176 #define BMX160_INT_EN 0x50-0x52
177 #define BMX160_INT_OUT_CTRL 0x53
178 #define BMX160_INT_LATCH 0x54
179 #define BMX160_INT_MAP 0x55-0x57
180 #define BMX160_INT_DATA 0x58-0x59
181 #define BMX160_INT_LOWHIGH 0x5A-0x5E
182 #define BMX160_INT_MOTION 0x5F-0x62
183 #define BMX160_INT_TAP 0x63-0x64
184 #define BMX160_INT_ORIENT 0x65-0x66
185 #define BMX160_INT_FLAT 0x67-0x68
186 #define BMX160_FOC_CONF 0x69
187 #define BMX160_CONF 0x6A
188 #define BMX160_IF_CONF 0x6B
189 #define BMX160_PMU_TRIGGER 0x6C
190 #define BMX160_SELF_TEST 0x6D
191 #define BMX160_NV_CONF 0x70
192 #define BMX160_NV_CONF_SPI_EN 0
193 #define BMX160_NV_CONF_I2C_WDT_SEL 1
194 #define BMX160_NV_CONF_I2C_WDT_EN 2
195 #define BMX160_OFFSET 0x71-0x77
196 #define BMX160_STEP_CNT 0x78-0x79
197 #define BMX160_STEP_CONF 0x7A-0x7B
198 #define BMX160_CMD 0x7E
199 #define BMX160_CMD_START_FOC 0x03
200 #define BMX160_CMD_ACC_SET_PMU_MODE(n) (0x10 | (n))
201 #define BMX160_CMD_GYR_SET_PMU_MODE(n) (0x14 | (n))
202 #define BMX160_CMD_MAG_IF_SET_PMU_MODE(n) (0x18 | (n))
203 #define BMX160_CMD_PROG_NVM 0xa0
204 #define BMX160_CMD_FIFO_FLUSH 0xb0
205 #define BMX160_CMD_INT_RESET 0xb1
206 #define BMX160_CMD_SOFTRESET 0xb6
207 #define BMX160_CMD_STEP_CNT_CLR 0xb2
209 #define BMM150_CHIP_ID 0x40
210 #define BMM150_DATA_X_0_4 0x42
211 #define BMM150_DATA_X_5_12 0x43
212 #define BMM150_DATA_Y_0_4 0x44
213 #define BMM150_DATA_Y_5_12 0x45
214 #define BMM150_DATA_Z_0_6 0x46
215 #define BMM150_DATA_Z_7_14 0x47
216 #define BMM150_RHALL_0_5 0x48
217 #define BMM150_RHALL_6_13 0x49
218 #define BMM150_INT_STATUS 0x4a
219 #define BMM150_POWER_MODE 0x4b
220 #define BMM150_POWER_MODE_SOFT_RESET_HI 7
221 #define BMM150_POWER_MODE_SPI3EN 2
222 #define BMM150_POWER_MODE_SOFT_RESET_LO 1
223 #define BMM150_POWER_MODE_POWER_CONTROL 0
224 #define BMM150_CONTROL 0x4c
225 #define BMM150_CONTROL_ADV_ST_1 7
226 #define BMM150_CONTROL_ADV_ST_0 6
227 #define BMM150_CONTROL_DATA_RATE 3
228 #define BMM150_CONTROL_DATA_RATE_10 0
229 #define BMM150_CONTROL_DATA_RATE_2 1
230 #define BMM150_CONTROL_DATA_RATE_6 2
231 #define BMM150_CONTROL_DATA_RATE_8 3
232 #define BMM150_CONTROL_DATA_RATE_15 4
233 #define BMM150_CONTROL_DATA_RATE_20 5
234 #define BMM150_CONTROL_DATA_RATE_25 6
235 #define BMM150_CONTROL_DATA_RATE_30 7
236 #define BMM150_CONTROL_OP_MODE 1
237 #define BMM150_CONTROL_OP_MODE_NORMAL 0
238 #define BMM150_CONTROL_OP_MODE_FORCED 1
239 #define BMM150_CONTROL_OP_MODE_SLEEP 3
240 #define BMM150_CONTROL_SELF_TEST 0
241 #define BMM150_INT_EN 0x4d
242 #define BMM150_INT_CONF 0x4e
243 #define BMM150_INT_CONF_X_DISABLE 3
244 #define BMM150_INT_CONF_Y_DISABLE 4
245 #define BMM150_INT_CONF_Z_DISABLE 5
246 #define BMM150_LOW_THRESHOLD 0x4f
247 #define BMM150_HIGH_THRESHOLD 0x50
248 #define BMM150_REPXY 0x51
249 #define BMM150_REPXY_VALUE(n) (((n)-1) >> 1)
250 #define BMM150_REPZ 0x52
251 #define BMM150_REPZ_VALUE(n) ((n) -1)
253 #endif /* _BMX160_H_ */