Skyward boardcore
Loading...
Searching...
No Matches
BMX160Defs.h
Go to the documentation of this file.
1/* Copyright (c) 2020 Skyward Experimental Rocketry
2 * Author: Davide Mor
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 * THE SOFTWARE.
21 */
22
23#pragma once
24
25#include <cstdint>
26
27namespace Boardcore
28{
29
33namespace BMX160Defs
34{
35
39const uint16_t FIFO_SIZE = 200;
40
44const float TEMP_SENSIBILITY = 64.0f / 32768.0f;
45
49const float MAG_SENSIBILITY = 0.003; // [Gauss]
50
54const uint8_t CHIPID = 0xD8;
55
59const uint8_t FIFO_CONFIG_1_DEFAULT = 0x10;
60
71
82
91
102
113
122
134
138const uint8_t PMU_STATUS_ALL_MASK = 0x03 | 0x0C | 0x30;
139
143const uint8_t PMU_STATUS_ALL_NORMAL = 0x01 | 0x04 | 0x10;
144
148const uint8_t FIFO_STOP_BYTE = 128;
149
153const uint8_t FIFO_HEADER_MODE_MASK = 0xC0;
154
158const uint8_t FIFO_HEADER_PARM_MASK = 0x3C;
159
163const uint8_t FIFO_HEADER_EXT_MASK = 0x03;
164
181
189
200
204struct MagRaw
205{
206 int16_t x, y, z;
207 uint16_t rhall;
208};
209
213struct GyrRaw
214{
215 int16_t x, y, z;
216};
217
221struct AccRaw
222{
223 int16_t x, y, z;
224};
225
230{
231 int8_t digX1;
232 int8_t digY1;
233 int8_t digX2;
234 int8_t digY2;
235 uint16_t digZ1;
236 int16_t digZ2;
237 int16_t digZ3;
238 int16_t digZ4;
239 uint8_t digXY1;
240 int8_t digXY2;
241 uint16_t digXYZ1;
242};
243
247enum class Cmd
248{
249 START_FOC = 0x03,
250 ACC_SET_PMU_MODE = 0x10,
251 GYR_SET_PMU_MODE = 0x14,
252 MAG_IF_SET_PMU_MODE = 0x18,
253 PROG_NVM = 0xA0,
254 FIFO_FLUSH = 0xB0,
255 INT_RESET = 0xB1,
256 SOFTRESET = 0xB6,
257 STEP_CNT_CLR = 0xB2,
258};
259
263enum class PowerMode
264{
265 SUSPEND = 0x00,
266 NORMAL = 0x01,
267 LOW_POWER = 0x02,
268 FAST_START_UP = 0x03
269};
270
275{
277 REG_ERR = 0x02,
279
280 REG_DATA = 0x04,
281
285
289
291
294
297
299
305
309
314
318
321
325
326 // INT_DATA_[0-1] not needed
327 // INT_LOWHIGH_[0-5] not needed
328 // INT_MOTION_[0-3] not needed
329 // INT_TAP_[0-1] not needed
330 // INT_ORIENT_[0-1] not needed
331 // INT_FLAT_[0-1] not needed
332
334 REG_CONF = 0x6A,
336
337 // PMU_TRIGGER not needed
338
340
341 // NV_CONF not needed
342 // OFFSET_[0-6] not needed
343 // STEP_CNT_[0-1] not needed
344 // STEP_CONF_[0-1] not needed
345
346 REG_CMD = 0x7E,
348};
349
354{
358
361
362 // Factory calibrated trim registers. This is all undocumented territory
363 // (the datasheet mentions this as "reserved").
364
381};
382
383} // namespace BMX160Defs
384
385} // namespace Boardcore
INT_MAP_1
Values for INT_MAP_1 register.
Definition BMX160Defs.h:107
MAG_IF_0
Values for MAG_IF_0 register.
Definition BMX160Defs.h:127
@ MAG_IF_0_BURST_8
8 byte of burst operation.
Definition BMX160Defs.h:132
@ MAG_IF_0_BURST_2
2 byte of burst operation.
Definition BMX160Defs.h:130
@ MAG_IF_0_BURST_1
1 byte of burst operation.
Definition BMX160Defs.h:129
@ MAG_IF_0_BURST_6
6 byte of burst operation.
Definition BMX160Defs.h:131
const uint8_t PMU_STATUS_ALL_MASK
Mask for PMU_STATUS register (Power Mode Unit).
Definition BMX160Defs.h:138
const uint8_t FIFO_CONFIG_1_DEFAULT
Default value for FIFO_CONFIG_1.
Definition BMX160Defs.h:59
const float TEMP_SENSIBILITY
Temperature sensor sensibility.
Definition BMX160Defs.h:44
const uint8_t CHIPID
BMX160 Chip Id.
Definition BMX160Defs.h:54
const uint8_t FIFO_HEADER_MODE_MASK
Mask for fifo header mode.
Definition BMX160Defs.h:153
const uint8_t PMU_STATUS_ALL_NORMAL
Mask for PMU_STATUS register, normal status for all sensors.
Definition BMX160Defs.h:143
Registers
Internal register definitions.
Definition BMX160Defs.h:275
FIFO_DOWNS
Values for FIFO_DOWNS register.
Definition BMX160Defs.h:87
const uint8_t FIFO_STOP_BYTE
This value indicates that the data in the FIFO stops prematurely.
Definition BMX160Defs.h:148
const uint8_t FIFO_HEADER_EXT_MASK
Mask for fifo header ext.
Definition BMX160Defs.h:163
MagnetometerRegisters
Internal magnetometer definitions.
Definition BMX160Defs.h:354
@ MAG_IF_SET_PMU_MODE
Sets the PMU mode for the magnetometer.
@ PROG_NVM
Writes the NVM backed registers into NVM.
@ STEP_CNT_CLR
Triggers a reset of the step counter.
@ INT_RESET
Resets interrupt engine, INT_STATUS reg and int pin.
@ FIFO_FLUSH
Clears all data in the fifo.
@ START_FOC
Starts Fast Offset Calibration for acc and gyro.
@ ACC_SET_PMU_MODE
Sets the PMU mode for the accelerometer.
@ GYR_SET_PMU_MODE
Sets the PMU mode for the gyroscope.
@ SOFTRESET
Triggers a reset including a reboot.
SELF_TEST
Values for SELF_TEST register.
Definition BMX160Defs.h:65
@ SELF_TEST_ACC_AMP
Select amplitude of the selftest deflection.
Definition BMX160Defs.h:67
@ SELF_TEST_GYR
Starts selftest of the gyroscope.
Definition BMX160Defs.h:66
@ SELF_TEST_ACC_ENABLE
Starts selftest of the accelerometer.
Definition BMX160Defs.h:69
@ SELF_TEST_ACC_SIGN
Select sign of selftest exitation.
Definition BMX160Defs.h:68
FIFO_HEADER
Values for fifo header byte.
Definition BMX160Defs.h:169
MAG_CONTROL
Values for mag CONTROL.
Definition BMX160Defs.h:194
FIFO_CONFIG_1
Values for FIFO_CONFIG_1 register.
Definition BMX160Defs.h:76
@ FIFO_CONFIG_1_ACC_EN
Store accelerometer data in fifo.
Definition BMX160Defs.h:77
@ FIFO_CONFIG_1_GYR_EN
Store gyroscope data in fifo.
Definition BMX160Defs.h:78
@ FIFO_CONFIG_1_HEADER_EN
Stores an header for each frame.
Definition BMX160Defs.h:80
@ FIFO_CONFIG_1_MAG_EN
Store magnetometer data in fifo.
Definition BMX160Defs.h:79
const uint8_t FIFO_HEADER_PARM_MASK
Mask for fifo header parm.
Definition BMX160Defs.h:158
INT_EN_1
Values for INT_EN_1 register.
Definition BMX160Defs.h:118
@ INT_EN_1_FIFO_FULL
Enables interrupt for FIFO full.
Definition BMX160Defs.h:120
@ INT_EN_1_FIFO_WATERMARK
Enables interrupt for FIFO watermark.
Definition BMX160Defs.h:119
const uint16_t FIFO_SIZE
Driver's fifo size expressed as number of samples.
Definition BMX160Defs.h:39
MAG_RESET
Values for mag RESET.
Definition BMX160Defs.h:186
const float MAG_SENSIBILITY
Magnetometer fixed sensibility.
Definition BMX160Defs.h:49
INT_OUT_CTRL
Values for INT_OUT_CTRL register.
Definition BMX160Defs.h:96
@ INT_OUT_CTRL_INT2_OD
Open drain enable for INT2 pin.
Definition BMX160Defs.h:98
@ INT_OUT_CTRL_INT1_OD
Open drain enable for INT1 pin.
Definition BMX160Defs.h:100
@ INT_OUT_CTRL_INT1_OUT_EN
Output enable for INT1 pin.
Definition BMX160Defs.h:99
@ INT_OUT_CTRL_INT2_OUT_EN
Output enable for INT2 pin.
Definition BMX160Defs.h:97
This file includes all the types the logdecoder script will decode.
Raw struct, read directly from device.
Definition BMX160Defs.h:222
Raw struct, read directly from device.
Definition BMX160Defs.h:214
Raw struct, read directly from device.
Definition BMX160Defs.h:205
Struct holding trim data used for magnetomer compensation.
Definition BMX160Defs.h:230