c13dof 2.0.0.0
c13dof.h
Go to the documentation of this file.
1/*
2 * MikroSDK - MikroE Software Development Kit
3 * Copyright (c) 2019, MikroElektronika - www.mikroe.com
4// * All rights reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24
33// ----------------------------------------------------------------------------
34
35#ifndef C13DOF_H
36#define C13DOF_H
37
42#ifdef PREINIT_SUPPORTED
43#include "preinit.h"
44#endif
45
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
48 #include "delays.h"
49 #endif
50#endif
51
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_i2c_master.h"
55
56
57// -------------------------------------------------------------- PUBLIC MACROS
67#define C13DOF_MAP_MIKROBUS( cfg, mikrobus ) \
68 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
69 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
76#define C13DOF_RETVAL uint8_t
77
78#define C13DOF_OK 0x00
79#define C13DOF_INIT_ERROR 0xFF
82#define C13DOF_POLL_PERIOD_MS 10
83
88#define C13DOF_BME680_DEVICE_SLAVE_ADDR_0 0x76
89#define C13DOF_BME680_DEVICE_SLAVE_ADDR_1 0x77
90#define C13DOF_BME680_CHIP_ID 0x61
91#define C13DOF_BME680_COEFF_SIZE 41
92#define C13DOF_BME680_COEFF_ADDR1_LEN 25
93#define C13DOF_BME680_COEFF_ADDR2_LEN 16
94#define C13DOF_BME680_FIELD_LENGTH 15
95#define C13DOF_BME680_FIELD_ADDR_OFFSET 17
96#define C13DOF_BME680_SOFT_RESET_CMD 0xB6
97#define C13DOF_BME680_DEVICE_OK 0
98#define C13DOF_BME680_DEVICE_ERROR 1
99#define C13DOF_BME680_E_NULL_PTR -1
100#define C13DOF_BME680_E_COM_FAIL -2
101#define C13DOF_BME680_E_DEV_NOT_FOUND -3
102#define C13DOF_BME680_E_INVALID_LENGTH -4
103#define C13DOF_BME680_W_DEFINE_PWR_MODE 1
104#define C13DOF_BME680_W_NO_NEW_DATA 2
105#define C13DOF_BME680_I_MIN_CORRECTION 1
106#define C13DOF_BME680_I_MAX_CORRECTION 2
107#define C13DOF_BME680_ADDR_RES_HEAT_VAL_ADDR 0x00
108#define C13DOF_BME680_ADDR_RES_HEAT_RANGE_ADDR 0x02
109#define C13DOF_BME680_ADDR_RANGE_SW_ERR_ADDR 0x04
110#define C13DOF_BME680_ADDR_SENS_CONF_START 0x5A
111#define C13DOF_BME680_ADDR_GAS_CONF_START 0x64
112#define C13DOF_BME680_FIELD0_ADDR 0x1D
113#define C13DOF_BME680_RES_HEAT0_ADDR 0x5A
114#define C13DOF_BME680_GAS_WAIT0_ADDR 0x64
115#define C13DOF_BME680_CONF_HEAT_CTRL_ADDR 0x70
116#define C13DOF_BME680_CONF_ODR_RUN_GAS_NBC_ADDR 0x71
117#define C13DOF_BME680_CONF_OS_H_ADDR 0x72
118#define C13DOF_BME680_MEM_PAGE_ADDR 0xf3
119#define C13DOF_BME680_CONF_T_P_MODE_ADDR 0x74
120#define C13DOF_BME680_CONF_ODR_FILT_ADDR 0x75
121#define C13DOF_BME680_COEFF_ADDR1 0x89
122#define C13DOF_BME680_COEFF_ADDR2 0xe1
123#define C13DOF_BME680_CHIP_ID_ADDR 0xD0
124#define C13DOF_BME680_SOFT_RESET_ADDR 0xE0
125#define C13DOF_BME680_ENABLE_HEATER 0x00
126#define C13DOF_BME680_DISABLE_HEATER 0x08
127#define C13DOF_BME680_DISABLE_GAS_MEAS 0x00
128#define C13DOF_BME680_ENABLE_GAS_MEAS 0x01
129#define C13DOF_BME680_OS_NONE 0
130#define C13DOF_BME680_OS_1X 1
131#define C13DOF_BME680_OS_2X 2
132#define C13DOF_BME680_OS_4X 3
133#define C13DOF_BME680_OS_8X 4
134#define C13DOF_BME680_OS_16X 5
135#define C13DOF_BME680_FILTER_SIZE_0 0
136#define C13DOF_BME680_FILTER_SIZE_1 1
137#define C13DOF_BME680_FILTER_SIZE_3 2
138#define C13DOF_BME680_FILTER_SIZE_7 3
139#define C13DOF_BME680_FILTER_SIZE_15 4
140#define C13DOF_BME680_FILTER_SIZE_31 5
141#define C13DOF_BME680_FILTER_SIZE_63 6
142#define C13DOF_BME680_FILTER_SIZE_127 7
143#define C13DOF_BME680_SLEEP_MODE 0
144#define C13DOF_BME680_FORCED_MODE 1
145#define C13DOF_BME680_RESET_PERIOD 10
146#define C13DOF_BME680_MEM_PAGE0 0x10
147#define C13DOF_BME680_MEM_PAGE1 0x00
148#define C13DOF_BME680_HUM_REG_SHIFT_VAL 4
149#define C13DOF_BME680_RUN_GAS_DISABLE 0
150#define C13DOF_BME680_RUN_GAS_ENABLE 1
151#define C13DOF_BME680_TMP_BUFFER_LENGTH 40
152#define C13DOF_BME680_REG_BUFFER_LENGTH 6
153#define C13DOF_BME680_FIELD_DATA_LENGTH 3
154#define C13DOF_BME680_GAS_REG_BUF_LENGTH 20
155#define C13DOF_BME680_OST_SEL 1
156#define C13DOF_BME680_OSP_SEL 2
157#define C13DOF_BME680_OSH_SEL 4
158#define C13DOF_BME680_GAS_MEAS_SEL 8
159#define C13DOF_BME680_FILTER_SEL 16
160#define C13DOF_BME680_HCNTRL_SEL 32
161#define C13DOF_BME680_RUN_GAS_SEL 64
162#define C13DOF_BME680_NBCONV_SEL 128
163#define C13DOF_BME680_GAS_SENSOR_SEL ( C13DOF_BME680_GAS_MEAS_SEL | \
164 C13DOF_BME680_RUN_GAS_SEL | \
165 C13DOF_BME680_NBCONV_SEL )
166#define C13DOF_BME680_NBCONV_MIN 0
167#define C13DOF_BME680_NBCONV_MAX 10
168#define C13DOF_BME680_GAS_MEAS_MSK 0x30
169#define C13DOF_BME680_NBCONV_MSK 0X0F
170#define C13DOF_BME680_FILTER_MSK 0X1C
171#define C13DOF_BME680_OST_MSK 0XE0
172#define C13DOF_BME680_OSP_MSK 0X1C
173#define C13DOF_BME680_OSH_MSK 0X07
174#define C13DOF_BME680_HCTRL_MSK 0x08
175#define C13DOF_BME680_RUN_GAS_MSK 0x10
176#define C13DOF_BME680_MODE_MSK 0x03
177#define C13DOF_BME680_RHRANGE_MSK 0x30
178#define C13DOF_BME680_RSERROR_MSK 0xf0
179#define C13DOF_BME680_NEW_DATA_MSK 0x80
180#define C13DOF_BME680_GAS_INDEX_MSK 0x0f
181#define C13DOF_BME680_GAS_RANGE_MSK 0x0f
182#define C13DOF_BME680_GASM_VALID_MSK 0x20
183#define C13DOF_BME680_HEAT_STAB_MSK 0x10
184#define C13DOF_BME680_MEM_PAGE_MSK 0x10
185#define C13DOF_BME680_SPI_RD_MSK 0x80
186#define C13DOF_BME680_SPI_WR_MSK 0x7f
187#define C13DOF_BME680_BIT_H1_DATA_MSK 0x0F
188#define C13DOF_BME680_GAS_MEAS_POS 4
189#define C13DOF_BME680_FILTER_POS 2
190#define C13DOF_BME680_OST_POS 5
191#define C13DOF_BME680_OSP_POS 2
192#define C13DOF_BME680_RUN_GAS_POS 4
193#define C13DOF_BME680_T2_LSB_REG 1
194#define C13DOF_BME680_T2_MSB_REG 2
195#define C13DOF_BME680_T3_REG 3
196#define C13DOF_BME680_P1_LSB_REG 5
197#define C13DOF_BME680_P1_MSB_REG 6
198#define C13DOF_BME680_P2_LSB_REG 7
199#define C13DOF_BME680_P2_MSB_REG 8
200#define C13DOF_BME680_P3_REG 9
201#define C13DOF_BME680_P4_LSB_REG 11
202#define C13DOF_BME680_P4_MSB_REG 12
203#define C13DOF_BME680_P5_LSB_REG 13
204#define C13DOF_BME680_P5_MSB_REG 14
205#define C13DOF_BME680_P7_REG 15
206#define C13DOF_BME680_P6_REG 16
207#define C13DOF_BME680_P8_LSB_REG 19
208#define C13DOF_BME680_P8_MSB_REG 20
209#define C13DOF_BME680_P9_LSB_REG 21
210#define C13DOF_BME680_P9_MSB_REG 22
211#define C13DOF_BME680_P10_REG 23
212#define C13DOF_BME680_H2_MSB_REG 25
213#define C13DOF_BME680_H2_LSB_REG 26
214#define C13DOF_BME680_H1_LSB_REG 26
215#define C13DOF_BME680_H1_MSB_REG 27
216#define C13DOF_BME680_H3_REG 28
217#define C13DOF_BME680_H4_REG 29
218#define C13DOF_BME680_H5_REG 30
219#define C13DOF_BME680_H6_REG 31
220#define C13DOF_BME680_H7_REG 32
221#define C13DOF_BME680_T1_LSB_REG 33
222#define C13DOF_BME680_T1_MSB_REG 34
223#define C13DOF_BME680_GH2_LSB_REG 35
224#define C13DOF_BME680_GH2_MSB_REG 36
225#define C13DOF_BME680_GH1_REG 37
226#define C13DOF_BME680_GH3_REG 38
227#define C13DOF_BME680_REG_FILTER_INDEX 5
228#define C13DOF_BME680_REG_TEMP_INDEX 4
229#define C13DOF_BME680_REG_PRES_INDEX 4
230#define C13DOF_BME680_REG_HUM_INDEX 2
231#define C13DOF_BME680_REG_NBCONV_INDEX 1
232#define C13DOF_BME680_REG_RUN_GAS_INDEX 1
233#define C13DOF_BME680_REG_HCTRL_INDEX 0
234#define C13DOF_BME680_MAX_OVERFLOW_VAL 0x40000000
235#define C13DOF_BME680_DATA_TEMPERATURE 0x01
236#define C13DOF_BME680_DATA_PRESSURE 0x02
237#define C13DOF_BME680_DATA_HUMIDITY 0x03
238#define C13DOF_BME680_OK 0x01
239#define C13DOF_BME680_ERROR 0x00
246#define C13DOF_BMM150_DEVICE_SLAVE_ADDR 0x10
247#define C13DOF_BMM150_DUMMY 0x00
248#define C13DOF_BMM150_ID_REG 0x40
249#define C13DOF_BMM150_RESERVED1_REG 0x41
250#define C13DOF_BMM150_DATAX_LSB_REG 0x42
251#define C13DOF_BMM150_DATAX_MSB_REG 0x43
252#define C13DOF_BMM150_DATAY_LSB_REG 0x44
253#define C13DOF_BMM150_DATAY_MSB_REG 0x45
254#define C13DOF_BMM150_DATAZ_LSB_REG 0x46
255#define C13DOF_BMM150_DATAZ_MSB_REG 0x47
256#define C13DOF_BMM150_RHALL_LSB_REG 0x48
257#define C13DOF_BMM150_RHALL_MSB_REG 0x49
258#define C13DOF_BMM150_INTERRUPT_STATUS_REG 0x4A
259#define C13DOF_BMM150_POWER_AND_RESET_CON_REG 0x4B
260#define C13DOF_BMM150_DATARATE_AND_OPMODE_CON_REG 0x4C
261#define C13DOF_BMM150_INTERR_AND_AXIS_EN_REG 0x4D
262#define C13DOF_BMM150_INTERR_AND_CHANNEL_EN_REG 0x4E
263#define C13DOF_BMM150_LOW_THRESHOLD_REG 0x4F
264#define C13DOF_BMM150_HIGH_THRESHOLD_REG 0x50
265#define C13DOF_BMM150_REPETITION_XY_CON_REG 0x51
266#define C13DOF_BMM150_REPETITION_Z_CON_REG 0x52
267#define C13DOF_BMM150_RESERVED2_REG 0x53
268#define C13DOF_BMM150_RESERVED3_REG 0x54
269#define C13DOF_BMM150_RESERVED4_REG 0x55
270#define C13DOF_BMM150_RESERVED5_REG 0x56
271#define C13DOF_BMM150_RESERVED6_REG 0x57
272#define C13DOF_BMM150_RESERVED7_REG 0x58
273#define C13DOF_BMM150_RESERVED8_REG 0x59
274#define C13DOF_BMM150_RESERVED9_REG 0x5A
275#define C13DOF_BMM150_RESERVED10_REG 0x5B
276#define C13DOF_BMM150_RESERVED11_REG 0x5C
277#define C13DOF_BMM150_RESERVED12_REG 0x5D
278#define C13DOF_BMM150_RESERVED13_REG 0x5E
279#define C13DOF_BMM150_RESERVED14_REG 0x5F
280#define C13DOF_BMM150_RESERVED15_REG 0x60
281#define C13DOF_BMM150_RESERVED16_REG 0x61
282#define C13DOF_BMM150_RESERVED17_REG 0x62
283#define C13DOF_BMM150_RESERVED18_REG 0x63
284#define C13DOF_BMM150_RESERVED19_REG 0x64
285#define C13DOF_BMM150_RESERVED20_REG 0x65
286#define C13DOF_BMM150_RESERVED21_REG 0x66
287#define C13DOF_BMM150_RESERVED22_REG 0x67
288#define C13DOF_BMM150_RESERVED23_REG 0x68
289#define C13DOF_BMM150_RESERVED24_REG 0x69
290#define C13DOF_BMM150_RESERVED25_REG 0x6A
291#define C13DOF_BMM150_RESERVED26_REG 0x6B
292#define C13DOF_BMM150_RESERVED27_REG 0x6C
293#define C13DOF_BMM150_RESERVED28_REG 0x6D
294#define C13DOF_BMM150_RESERVED29_REG 0x6E
295#define C13DOF_BMM150_RESERVED30_REG 0x6F
296#define C13DOF_BMM150_RESERVED31_REG 0x70
297#define C13DOF_BMM150_RESERVED32_REG 0x71
298#define C13DOF_BMM150_OK 0x00
299#define C13DOF_BMM150_ADDR_ERR 0x01
300#define C13DOF_BMM150_INTERRUPT_OCCURED 0x02
301#define C13DOF_BMM150_NBYTES_ERR 0x03
302#define C13DOF_BMM150_DATA_READY 0x01
303#define C13DOF_BMM150_DATA_NOT_READY 0x00
304#define C13DOF_BMM150_SUSPEND_MODE_SPI4_EN 0x00
305#define C13DOF_BMM150_SLEEP_MODE 0x01
306#define C13DOF_BMM150_SOFT_RESET_EN 0x82
307#define C13DOF_BMM150_SPI3_EN 0x04
308#define C13DOF_BMM150_NORMAL_OPMODE_DR_10HZ 0x00
309#define C13DOF_BMM150_FORCED_OPMODE 0x02
310#define C13DOF_BMM150_SLEEP_OPMODE 0x06
311#define C13DOF_BMM150_DR_2HZ 0x08
312#define C13DOF_BMM150_DR_6HZ 0x10
313#define C13DOF_BMM150_DR_8HZ 0x18
314#define C13DOF_BMM150_DR_15HZ 0x20
315#define C13DOF_BMM150_DR_20HZ 0x28
316#define C13DOF_BMM150_DR_25HZ 0x30
317#define C13DOF_BMM150_DR_30HZ 0x38
318#define C13DOF_BMM150_INTERR_DISABLED_THRESHOLDS_ENABLED 0x00
319#define C13DOF_BMM150_LOWTHRESHOLD_X_DISABLED 0x01
320#define C13DOF_BMM150_LOWTHRESHOLD_Y_DISABLED 0x02
321#define C13DOF_BMM150_LOWTHRESHOLD_Z_DISABLED 0x04
322#define C13DOF_BMM150_HIGHTHRESHOLD_X_DISABLED 0x08
323#define C13DOF_BMM150_HIGHTHRESHOLD_Y_DISABLED 0x10
324#define C13DOF_BMM150_HIGHTHRESHOLD_Z_DISABLED 0x20
325#define C13DOF_BMM150_OVERFLOW_PIN_IND_EN 0x40
326#define C13DOF_BMM150_DATAOVERRUN_IND_EN 0x80
327#define C13DOF_BMM150_CHANNELS_ENABLED_INTERR_DATAREADY_ACTIVE_LOW 0x00
328#define C13DOF_BMM150_INTERR_PIN_ACTIVE_HIGH 0x01
329#define C13DOF_BMM150_INTERR_LATCHED 0x02
330#define C13DOF_BMM150_DATAREADY_ACTIVE_HIGH 0x04
331#define C13DOF_BMM150_CHANNEL_X_DISABLED 0x08
332#define C13DOF_BMM150_CHANNEL_Y_DISABLED 0x10
333#define C13DOF_BMM150_CHANNEL_Z_DISABLED 0x20
334#define C13DOF_BMM150_INTERR_PIN_EN 0x40
335#define C13DOF_BMM150_DATAREADY_PIN_EN 0x80
342#define C13DOF_BMI088_ACCEL_SLAVE_ADDR 0x18
343#define C13DOF_BMI088_GYRO_SLAVE_ADDR 0x68
344#define C13DOF_BMI088_ACCEL_CHIP_ID_REG 0x00
345#define C13DOF_BMI088_ACCEL_ERR_REG 0x02
346#define C13DOF_BMI088_ACCEL_STATUS_REG 0x03
347#define C13DOF_BMI088_ACCEL_X_LSB_REG 0x12
348#define C13DOF_BMI088_ACCEL_X_MSB_REG 0x13
349#define C13DOF_BMI088_ACCEL_Y_LSB_REG 0x14
350#define C13DOF_BMI088_ACCEL_Y_MSB_REG 0x15
351#define C13DOF_BMI088_ACCEL_Z_LSB_REG 0x16
352#define C13DOF_BMI088_ACCEL_Z_MSB_REG 0x17
353#define C13DOF_BMI088_ACCEL_SENSORTIME_0_REG 0x18
354#define C13DOF_BMI088_ACCEL_SENSORTIME_1_REG 0x19
355#define C13DOF_BMI088_ACCEL_SENSORTIME_2_REG 0x1A
356#define C13DOF_BMI088_ACCEL_INT_STAT_0_REG 0x1C
357#define C13DOF_BMI088_ACCEL_INT_STAT_1_REG 0x1D
358#define C13DOF_BMI088_ACCEL_GP_0_REG 0x1E
359#define C13DOF_BMI088_TEMP_MSB_REG 0x22
360#define C13DOF_BMI088_TEMP_LSB_REG 0x23
361#define C13DOF_BMI088_ACCEL_GP_4_REG 0x27
362#define C13DOF_BMI088_ACCEL_INTERNAL_STAT_REG 0x2A
363#define C13DOF_BMI088_ACCEL_CONF_REG 0x40
364#define C13DOF_BMI088_ACCEL_RANGE_REG 0x41
365#define C13DOF_BMI088_ACCEL_INT1_IO_CONF_REG 0x53
366#define C13DOF_BMI088_ACCEL_INT2_IO_CONF_REG 0x54
367#define C13DOF_BMI088_ACCEL_INT_LATCH_CONF_REG 0x55
368#define C13DOF_BMI088_ACCEL_INT1_MAP_REG 0x56
369#define C13DOF_BMI088_ACCEL_INT2_MAP_REG 0x57
370#define C13DOF_BMI088_ACCEL_INT1_INT2_MAP_DATA_REG 0x58
371#define C13DOF_BMI088_ACCEL_INIT_CTRL_REG 0x59
372#define C13DOF_BMI088_ACCEL_SELF_TEST_REG 0x6D
373#define C13DOF_BMI088_ACCEL_PWR_CONF_REG 0x7C
374#define C13DOF_BMI088_ACCEL_PWR_CTRL_REG 0x7D
375#define C13DOF_BMI088_ACCEL_SOFTRESET_REG 0x7E
376#define C13DOF_BMI088_ACCEL_CHIP_ID 0x1E
377#define C13DOF_BMI088_ACCEL_I2C_ADDR_PRIMARY 0x18
378#define C13DOF_BMI088_ACCEL_I2C_ADDR_SECONDARY 0x19
379#define C13DOF_BMI088_ACCEL_RESERVED_5B_REG 0x5B
380#define C13DOF_BMI088_ACCEL_RESERVED_5C_REG 0x5C
381#define C13DOF_BMI088_ACCEL_FEATURE_CFG_REG 0x5E
382#define C13DOF_BMI088_ACCEL_DATA_READY_INT 0x80
383#define C13DOF_BMI088_ACCEL_BW_OSR4 0x00
384#define C13DOF_BMI088_ACCEL_BW_OSR2 0x01
385#define C13DOF_BMI088_ACCEL_BW_NORMAL 0x02
386#define C13DOF_BMI088_ACCEL_ODR_12_5_HZ 0x05
387#define C13DOF_BMI088_ACCEL_ODR_25_HZ 0x06
388#define C13DOF_BMI088_ACCEL_ODR_50_HZ 0x07
389#define C13DOF_BMI088_ACCEL_ODR_100_HZ 0x08
390#define C13DOF_BMI088_ACCEL_ODR_200_HZ 0x09
391#define C13DOF_BMI088_ACCEL_ODR_400_HZ 0x0A
392#define C13DOF_BMI088_ACCEL_ODR_800_HZ 0x0B
393#define C13DOF_BMI088_ACCEL_ODR_1600_HZ 0x0C
394#define C13DOF_BMI088_ACCEL_SWITCH_OFF_SELF_TEST 0x00
395#define C13DOF_BMI088_ACCEL_POSITIVE_SELF_TEST 0x0D
396#define C13DOF_BMI088_ACCEL_NEGATIVE_SELF_TEST 0x09
397#define C13DOF_BMI088_ACCEL_PM_ACTIVE 0x00
398#define C13DOF_BMI088_ACCEL_PM_SUSPEND 0x03
399#define C13DOF_BMI088_ACCEL_POWER_DISABLE 0x00
400#define C13DOF_BMI088_ACCEL_POWER_ENABLE 0x04
401#define C13DOF_BMI088_ACCEL_INTA_DISABLE 0x00
402#define C13DOF_BMI088_ACCEL_INTA_ENABLE 0x01
403#define C13DOF_BMI088_ACCEL_INTB_DISABLE 0x00
404#define C13DOF_BMI088_ACCEL_INTB_ENABLE 0x02
405#define C13DOF_BMI088_ACCEL_SOFTRESET_DELAY_MS 1
406#define C13DOF_BMI088_FATAL_ERR_MASK 0x01
407#define C13DOF_BMI088_ERR_CODE_MASK 0x1C
408#define C13DOF_BMI088_CMD_ERR_POS 1
409#define C13DOF_BMI088_ERR_CODE_POS 2
410#define C13DOF_BMI088_ACCEL_STATUS_MASK 0x80
411#define C13DOF_BMI088_ACCEL_STATUS_POS 7
412#define C13DOF_BMI088_ACCEL_ODR_MASK 0x0F
413#define C13DOF_BMI088_ACCEL_BW_MASK 0x70
414#define C13DOF_BMI088_ACCEL_RANGE_MASK 0x03
415#define C13DOF_BMI088_ACCEL_BW_POS 4
416#define C13DOF_BMI088_ACCEL_INT_EDGE_MASK 0x01
417#define C13DOF_BMI088_ACCEL_INT_LVL_MASK 0x02
418#define C13DOF_BMI088_ACCEL_INT_OD_MASK 0x04
419#define C13DOF_BMI088_ACCEL_INT_IO_MASK 0x08
420#define C13DOF_BMI088_ACCEL_INT_IN_MASK 0x10
421#define C13DOF_BMI088_ACCEL_INT_EDGE_POS 0
422#define C13DOF_BMI088_ACCEL_INT_LVL_POS 1
423#define C13DOF_BMI088_ACCEL_INT_OD_POS 2
424#define C13DOF_BMI088_ACCEL_INT_IO_POS 3
425#define C13DOF_BMI088_ACCEL_INT_IN_POS 4
426#define C13DOF_BMI088_ACCEL_MAP_INTA_MASK 0x01
427#define C13DOF_BMI088_ACCEL_MAP_INTA_POS 0x00
428#define C13DOF_BMI088_ACCEL_INT1_DRDY_MASK 0x04
429#define C13DOF_BMI088_ACCEL_INT2_DRDY_MASK 0x40
430#define C13DOF_BMI088_ACCEL_INT1_DRDY_POS 2
431#define C13DOF_BMI088_ACCEL_INT2_DRDY_POS 6
432#define C13DOF_BMI088_ASIC_INITIALIZED 0x01
433#define C13DOF_BMI088_GYRO_CHIP_ID_REG 0x00
434#define C13DOF_BMI088_GYRO_X_LSB_REG 0x02
435#define C13DOF_BMI088_GYRO_X_MSB_REG 0x03
436#define C13DOF_BMI088_GYRO_Y_LSB_REG 0x04
437#define C13DOF_BMI088_GYRO_Y_MSB_REG 0x05
438#define C13DOF_BMI088_GYRO_Z_LSB_REG 0x06
439#define C13DOF_BMI088_GYRO_Z_MSB_REG 0x07
440#define C13DOF_BMI088_GYRO_INT_STAT_1_REG 0x0A
441#define C13DOF_BMI088_GYRO_RANGE_REG 0x0F
442#define C13DOF_BMI088_GYRO_BANDWIDTH_REG 0x10
443#define C13DOF_BMI088_GYRO_LPM1_REG 0x11
444#define C13DOF_BMI088_GYRO_SOFTRESET_REG 0x14
445#define C13DOF_BMI088_GYRO_INT_CTRL_REG 0x15
446#define C13DOF_BMI088_GYRO_INT3_INT4_IO_CONF_REG 0x16
447#define C13DOF_BMI088_GYRO_INT3_INT4_IO_MAP_REG 0x18
448#define C13DOF_BMI088_GYRO_SELF_TEST_REG 0x3C
449#define C13DOF_BMI088_GYRO_CHIP_ID 0x0F
450#define C13DOF_BMI088_GYRO_I2C_ADDR_PRIMARY 0x68
451#define C13DOF_BMI088_GYRO_I2C_ADDR_SECONDARY 0x69
452#define C13DOF_BMI088_GYRO_RANGE_2000_DPS 0x00
453#define C13DOF_BMI088_GYRO_RANGE_1000_DPS 0x01
454#define C13DOF_BMI088_GYRO_RANGE_500_DPS 0x02
455#define C13DOF_BMI088_GYRO_RANGE_250_DPS 0x03
456#define C13DOF_BMI088_GYRO_RANGE_125_DPS 0x04
457#define C13DOF_BMI088_GYRO_BW_532_ODR_2000_HZ 0x00
458#define C13DOF_BMI088_GYRO_BW_230_ODR_2000_HZ 0x01
459#define C13DOF_BMI088_GYRO_BW_116_ODR_1000_HZ 0x02
460#define C13DOF_BMI088_GYRO_BW_47_ODR_400_HZ 0x03
461#define C13DOF_BMI088_GYRO_BW_23_ODR_200_HZ 0x04
462#define C13DOF_BMI088_GYRO_BW_12_ODR_100_HZ 0x05
463#define C13DOF_BMI088_GYRO_BW_64_ODR_200_HZ 0x06
464#define C13DOF_BMI088_GYRO_BW_32_ODR_100_HZ 0x07
465#define C13DOF_BMI088_GYRO_ODR_RESET_VAL 0x80
466#define C13DOF_BMI088_GYRO_PM_NORMAL 0x00
467#define C13DOF_BMI088_GYRO_PM_DEEP_SUSPEND 0x20
468#define C13DOF_BMI088_GYRO_PM_SUSPEND 0x80
469#define C13DOF_BMI088_GYRO_DRDY_INT_DISABLE_VAL 0x00
470#define C13DOF_BMI088_GYRO_DRDY_INT_ENABLE_VAL 0x80
471#define C13DOF_BMI088_GYRO_MAP_DRDY_TO_INT3 0x01
472#define C13DOF_BMI088_GYRO_MAP_DRDY_TO_INT4 0x80
473#define C13DOF_BMI088_GYRO_MAP_DRDY_TO_BOTH_INT3_INT4 0x81
474#define C13DOF_BMI088_GYRO_SOFTRESET_DELAY 30
475#define C13DOF_BMI088_GYRO_POWER_MODE_CONFIG_DELAY 30
476#define C13DOF_BMI088_GYRO_RANGE_MASK 0x07
477#define C13DOF_BMI088_GYRO_BW_MASK 0x0F
478#define C13DOF_BMI088_GYRO_POWER_MASK 0xA0
479#define C13DOF_BMI088_GYRO_POWER_POS 5
480#define C13DOF_BMI088_GYRO_DATA_EN_MASK 0x80
481#define C13DOF_BMI088_GYRO_DATA_EN_POS 7
482#define C13DOF_BMI088_GYRO_INT3_LVL_MASK 0x01
483#define C13DOF_BMI088_GYRO_INT3_OD_MASK 0x02
484#define C13DOF_BMI088_GYRO_INT4_LVL_MASK 0x04
485#define C13DOF_BMI088_GYRO_INT4_OD_MASK 0x08
486#define C13DOF_BMI088_GYRO_INT3_OD_POS 1
487#define C13DOF_BMI088_GYRO_INT4_LVL_POS 2
488#define C13DOF_BMI088_GYRO_INT4_OD_POS 3
489#define C13DOF_BMI088_GYRO_INT_EN_MASK 0x80
490#define C13DOF_BMI088_GYRO_INT_EN_POS 7
491#define C13DOF_BMI088_GYRO_INT3_MAP_MASK 0x01
492#define C13DOF_BMI088_GYRO_INT4_MAP_MASK 0x80
493#define C13DOF_BMI088_GYRO_INT3_MAP_POS 0
494#define C13DOF_BMI088_GYRO_INT4_MAP_POS 7
495#define C13DOF_BMI088_OK 0x00
496#define C13DOF_BMI088_ERROR 0x01
497#define T_C13DOF_P const uint8_t*
498#define C13DOF_BME680_RETVAL_T uint8_t
499#define C13DOF_BMM150_RETVAL_T uint8_t
500#define C13DOF_BMI088_RETVAL_T uint8_t
503 // End group macro
504// --------------------------------------------------------------- PUBLIC TYPES
514typedef struct
515{
516 uint8_t status;
517 uint8_t gas_index;
518 uint8_t meas_index;
519 int16_t temperature;
520 float pressure;
521 uint32_t humidity;
523
525
526typedef struct
527{
528
529 uint16_t par_h1;
530 uint16_t par_h2;
531 int8_t par_h3;
532 int8_t par_h4;
533 int8_t par_h5;
534 uint8_t par_h6;
535 int8_t par_h7;
536
537 int8_t par_gh1;
538 int16_t par_gh2;
539 int8_t par_gh3;
540
541 uint16_t par_t1;
542 int16_t par_t2;
543 int8_t par_t3;
544
545 uint16_t par_p1;
546 int16_t par_p2;
547 int8_t par_p3;
548 int16_t par_p4;
549 int16_t par_p5;
550 int8_t par_p6;
551 int8_t par_p7;
552 int16_t par_p8;
553 int16_t par_p9;
554 uint8_t par_p10;
555
556 int32_t t_fine;
557
561
563
564typedef struct
565{
566 uint8_t os_hum;
567
568 uint8_t os_temp;
569
570 uint8_t os_pres;
571
572 uint8_t filter;
573
575
576
577typedef struct
578{
579 uint8_t nb_conv;
580
581 uint8_t heatr_ctrl;
582
583 uint8_t run_gas;
584
585 uint16_t heatr_temp;
586
587 uint16_t heatr_dur;
588
590
613
617typedef struct
618{
619 // Communication gpio pins
620
621 pin_name_t scl;
622 pin_name_t sda;
623
624 // static variable
625
626 uint32_t i2c_speed;
631
633
634 // End types group
635
636// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
637
643#ifdef __cplusplus
644extern "C"{
645#endif
646
656
666
675
689void c13dof_bme680_write_byte ( c13dof_t *ctx, uint8_t reg_address, uint8_t write_data );
690
705uint8_t c13dof_bme680_read_byte ( c13dof_t *ctx, uint8_t reg_address );
706
721
738
749
764
765
784float c13dof_bme680_get_ambient_data ( c13dof_t *ctx, uint8_t data_in );
785
799
813
827
841
855C13DOF_BMM150_RETVAL_T c13dof_bmm150_write_byte ( c13dof_t *ctx, uint8_t reg_address, uint8_t write_data );
856
871uint8_t c13dof_bmm150_read_byte ( c13dof_t *ctx, uint8_t reg_address );
872
892C13DOF_BMM150_RETVAL_T c13dof_bmm150_read_bytes ( c13dof_t *ctx, uint8_t *data_out, uint8_t reg_address, uint8_t n_bytes );
893
908
926void c13dof_bmm150_read_geo_mag_data ( c13dof_t *ctx, int16_t *mag_x, int16_t *mag_y, int16_t *mag_z, uint16_t *res_hall );
927
938
950
964void c13dof_bmi088_gyro_write_byte ( c13dof_t *ctx, uint8_t reg_address, uint8_t write_data );
965
981void c13dof_bmi088_gyro_write_bytes ( c13dof_t *ctx, uint8_t reg_address, uint8_t *write_data, uint8_t n_bytes );
982
997uint8_t c13dof_bmi088_gyro_read_byte ( c13dof_t *ctx, uint8_t reg_address );
998
1018C13DOF_BMI088_RETVAL_T c13dof_bmi088_gyro_read_bytes ( c13dof_t *ctx, uint8_t *data_out, uint8_t reg_address, uint8_t n_bytes );
1019
1034
1052
1071
1082
1099int16_t c13dof_bmi088_get_gyro_axis ( c13dof_t *ctx, uint8_t adr_reg_LSB, uint8_t adr_reg_MSB );
1100
1117void c13dof_bmi088_read_gyro ( c13dof_t *ctx, int16_t *gyro_x, int16_t *gyro_y, int16_t *gyro_z );
1118
1132void c13dof_bmi088_accel_write_byte ( c13dof_t *ctx, uint8_t reg_address, uint8_t write_data );
1133
1149void c13dof_bmi088_accel_write_bytes ( c13dof_t *ctx, uint8_t reg_address, uint8_t *write_data, uint8_t n_bytes );
1150
1165uint8_t c13dof_bmi088_accel_read_byte ( c13dof_t *ctx, uint8_t reg_address );
1166
1186C13DOF_BMI088_RETVAL_T c13dof_bmi088_accel_read_bytes ( c13dof_t *ctx, uint8_t *data_out, uint8_t reg_address, uint8_t n_bytes );
1187
1202
1215// uint8_t c13dof_bmi088_get_accel_error ( c13dof_t *ctx );
1216
1232
1245void c13dof_bmi088_set_accel_config ( c13dof_t *ctx, uint8_t accel_config );
1246
1260
1275
1298void c13dof_bmi088_set_accel_mode ( c13dof_t *ctx, uint8_t active_mode );
1299
1318
1337
1353int16_t c13dof_bmi088_get_accel_axis ( c13dof_t *ctx, uint8_t adr_reg_LSB, uint8_t adr_reg_MSB );
1354
1371void c13dof_bmi088_read_accel ( c13dof_t *ctx, int16_t *accel_x, int16_t *accel_y, int16_t *accel_z );
1372
1383
1384#ifdef __cplusplus
1385}
1386#endif
1387#endif // _C13DOF_H_
1388
1389 // End public_function group
1391
1392// ------------------------------------------------------------------------- END
#define C13DOF_BME680_RETVAL_T
Definition c13dof.h:498
#define C13DOF_BMM150_RETVAL_T
Definition c13dof.h:499
#define C13DOF_BMI088_RETVAL_T
Definition c13dof.h:500
#define C13DOF_RETVAL
Definition c13dof.h:76
C13DOF_BMI088_RETVAL_T c13dof_bmi088_set_gyro_range(c13dof_t *ctx, uint8_t gyro_range)
Set BMI088 Gyro range function.
void c13dof_bmi088_read_accel(c13dof_t *ctx, int16_t *accel_x, int16_t *accel_y, int16_t *accel_z)
Get BMI088 Accel X-axis, Y-axis and Z-axis function.
void c13dof_bme680_soft_reset(c13dof_t *ctx)
Software BME680 reset function.
void c13dof_bmm150_soft_reset(c13dof_t *ctx)
Software BMM150 reset function.
int16_t c13dof_bmi088_get_gyro_axis(c13dof_t *ctx, uint8_t adr_reg_LSB, uint8_t adr_reg_MSB)
Get BMI088 Gyro axis data function.
float c13dof_bme680_get_ambient_data(c13dof_t *ctx, uint8_t data_in)
Get BME680 ambient data function.
uint8_t c13dof_bmm150_read_byte(c13dof_t *ctx, uint8_t reg_address)
Generic BMM150 read byte of data function.
void c13dof_bmi088_read_gyro(c13dof_t *ctx, int16_t *gyro_x, int16_t *gyro_y, int16_t *gyro_z)
Get BMI088 Gyro X-axis, Y-axis and Z-axis function.
int16_t c13dof_bmi088_get_accel_axis(c13dof_t *ctx, uint8_t adr_reg_LSB, uint8_t adr_reg_MSB)
Get BMI088 Accel axis data function.
C13DOF_RETVAL c13dof_init(c13dof_t *ctx, c13dof_cfg_t *cfg)
Initialization function.
void c13dof_default_cfg(c13dof_t *ctx)
Click Default Configuration function.
void c13dof_bmi088_accel_write_byte(c13dof_t *ctx, uint8_t reg_address, uint8_t write_data)
Generic BMI088 Accel write data function.
C13DOF_BMI088_RETVAL_T c13dof_bmi088_set_gyro_bandwidth(c13dof_t *ctx, uint8_t gyro_bandwidth)
Set BMI088 Gyro bandwidth function.
void c13dof_bmi088_default_config(c13dof_t *ctx)
Set BMI088 Accel & Gyro default configuration fuction.
void c13dof_bmi088_soft_reset_accel(c13dof_t *ctx)
Set BMI088 Accel soft reset function.
uint8_t c13dof_bmi088_get_gyro_id(c13dof_t *ctx)
Get BMI088 Gyro ID function.
void c13dof_bmi088_gyro_write_byte(c13dof_t *ctx, uint8_t reg_address, uint8_t write_data)
Generic BMI088 Gyro write data function.
void c13dof_cfg_setup(c13dof_cfg_t *cfg)
Config Object Initialization function.
uint8_t c13dof_bmi088_accel_read_byte(c13dof_t *ctx, uint8_t reg_address)
Generic BMI088 Accel read data function.
uint8_t c13dof_bmi088_gyro_read_byte(c13dof_t *ctx, uint8_t reg_address)
Generic BMI088 Gyro read data function.
uint8_t c13dof_bme680_get_device_id(c13dof_t *ctx)
Get BME680 device ID function.
void c13dof_bmi088_soft_reset_giro(c13dof_t *ctx)
Software BMI088 Gyro reset function.
void c13dof_bmi088_set_accel_config(c13dof_t *ctx, uint8_t accel_config)
Set BMI088 Accel configuration function.
float c13dof_bme680_get_pressure(c13dof_t *ctx)
Gets BME680 pressure in degrees Celsius function.
C13DOF_BMM150_RETVAL_T c13dof_bmm150_write_byte(c13dof_t *ctx, uint8_t reg_address, uint8_t write_data)
Generic BMM150 write the byte of data function.
C13DOF_BMI088_RETVAL_T c13dof_bmi088_gyro_read_bytes(c13dof_t *ctx, uint8_t *data_out, uint8_t reg_address, uint8_t n_bytes)
Generic BMI088 Gyro sequential data read function.
C13DOF_BMM150_RETVAL_T c13dof_bmm150_read_bytes(c13dof_t *ctx, uint8_t *data_out, uint8_t reg_address, uint8_t n_bytes)
Generic BMM150 sequential data read function.
void c13dof_bme680_write_byte(c13dof_t *ctx, uint8_t reg_address, uint8_t write_data)
Generic BME680 write the byte of data function.
C13DOF_BMI088_RETVAL_T c13dof_bmi088_enable_accel(c13dof_t *ctx)
Enable BMI088 Accel function.
void c13dof_bmi088_accel_write_bytes(c13dof_t *ctx, uint8_t reg_address, uint8_t *write_data, uint8_t n_bytes)
Generic sequential BMI088 Accel write data function.
float c13dof_bme680_get_humidity(c13dof_t *ctx)
Gets BME680 humidity in percentage [ % ] function.
void c13dof_bmm150_power_on_reset(c13dof_t *ctx)
BMM150 power ON reset function.
uint8_t c13dof_bmi088_check_accel_data_ready(c13dof_t *ctx)
Get BMI088 Accel error function.
C13DOF_BMI088_RETVAL_T c13dof_bmi088_set_accel_range(c13dof_t *ctx, uint8_t accel_range)
Set BMI088 Accel range function.
C13DOF_BMI088_RETVAL_T c13dof_bmi088_disable_accel(c13dof_t *ctx)
Disable BMI088 Accel function.
uint32_t c13dof_bme680_get_gas_resistance(c13dof_t *ctx)
Gets BME680 gas resistance data function.
C13DOF_BME680_RETVAL_T c13dof_bme680_check_id(c13dof_t *ctx)
Check BME680 device ID function.
uint8_t c13dof_bme680_read_byte(c13dof_t *ctx, uint8_t reg_address)
Generic BME680 read byte of data function.
uint8_t c13dof_bmi088_get_accel_id(c13dof_t *ctx)
Get BMI088 Accel ID function.
void c13dof_bme680_get_calibration_data(c13dof_t *ctx)
Get BME680 factory calibration parameters function.
void c13dof_bmm150_read_geo_mag_data(c13dof_t *ctx, int16_t *mag_x, int16_t *mag_y, int16_t *mag_z, uint16_t *res_hall)
Get BMM150 Geomagnetic sensors data function.
float c13dof_bme680_get_temperature(c13dof_t *ctx)
Gets BME680 temperature in degrees Celsius function.
C13DOF_BMI088_RETVAL_T c13dof_bmi088_accel_read_bytes(c13dof_t *ctx, uint8_t *data_out, uint8_t reg_address, uint8_t n_bytes)
Generic BMI088 Accel sequential data read function.
void c13dof_bmi088_gyro_write_bytes(c13dof_t *ctx, uint8_t reg_address, uint8_t *write_data, uint8_t n_bytes)
Generic sequential BMI088 Gyro write data function.
C13DOF_BMM150_RETVAL_T c13dof_bmm150_check_ready(c13dof_t *ctx)
Check BMM150 data ready status function.
void c13dof_bmi088_set_accel_mode(c13dof_t *ctx, uint8_t active_mode)
Set BMI088 Accel mode function.
int16_t mag_y
Definition main.c:52
int16_t accel_x
Definition main.c:45
int16_t mag_z
Definition main.c:53
int16_t gyro_y
Definition main.c:49
int16_t accel_y
Definition main.c:46
int16_t gyro_x
Definition main.c:48
int16_t gyro_z
Definition main.c:50
int16_t mag_x
Definition main.c:51
int16_t accel_z
Definition main.c:47
Definition c13dof.h:527
int16_t par_p4
Definition c13dof.h:548
int8_t par_h5
Definition c13dof.h:533
int8_t par_p6
Definition c13dof.h:550
uint16_t par_p1
Definition c13dof.h:545
int8_t par_h3
Definition c13dof.h:531
uint16_t par_h1
Definition c13dof.h:529
int8_t par_gh1
Definition c13dof.h:537
int8_t par_h4
Definition c13dof.h:532
int16_t par_p2
Definition c13dof.h:546
int8_t par_p3
Definition c13dof.h:547
uint8_t par_p10
Definition c13dof.h:554
int16_t par_gh2
Definition c13dof.h:538
uint8_t res_heat_range
Definition c13dof.h:558
int8_t par_h7
Definition c13dof.h:535
uint16_t par_h2
Definition c13dof.h:530
int8_t res_heat_val
Definition c13dof.h:559
int8_t par_gh3
Definition c13dof.h:539
int16_t par_p8
Definition c13dof.h:552
uint16_t par_t1
Definition c13dof.h:541
int8_t range_sw_err
Definition c13dof.h:560
int16_t par_p9
Definition c13dof.h:553
int32_t t_fine
Definition c13dof.h:556
int16_t par_t2
Definition c13dof.h:542
int8_t par_p7
Definition c13dof.h:551
int16_t par_p5
Definition c13dof.h:549
int8_t par_t3
Definition c13dof.h:543
uint8_t par_h6
Definition c13dof.h:534
Click ctx object definition.
Definition c13dof.h:515
int16_t temperature
Definition c13dof.h:519
uint32_t humidity
Definition c13dof.h:521
uint32_t gas_resistance
Definition c13dof.h:522
float pressure
Definition c13dof.h:520
uint8_t gas_index
Definition c13dof.h:517
uint8_t meas_index
Definition c13dof.h:518
uint8_t status
Definition c13dof.h:516
Definition c13dof.h:578
uint8_t nb_conv
Definition c13dof.h:579
uint8_t run_gas
Definition c13dof.h:583
uint16_t heatr_temp
Definition c13dof.h:585
uint8_t heatr_ctrl
Definition c13dof.h:581
uint16_t heatr_dur
Definition c13dof.h:587
Definition c13dof.h:565
uint8_t os_temp
Definition c13dof.h:568
uint8_t os_hum
Definition c13dof.h:566
uint8_t filter
Definition c13dof.h:572
uint8_t os_pres
Definition c13dof.h:570
Click configuration structure definition.
Definition c13dof.h:618
uint8_t bmi088Gyro_slave_address
Definition c13dof.h:629
uint8_t bme680_slave_address
Definition c13dof.h:627
uint32_t i2c_speed
Definition c13dof.h:626
uint8_t bmi088Accel_slave_address
Definition c13dof.h:630
pin_name_t scl
Definition c13dof.h:621
pin_name_t sda
Definition c13dof.h:622
uint8_t bmm150_slave_address
Definition c13dof.h:628
Definition c13dof.h:592
T_C13DOF_BME680_FIELD_DATA d_data
Definition c13dof.h:604
T_C13DOF_BME680_GAS_SETTINGS gas_sett
Definition c13dof.h:607
uint8_t bmi088Gyro_slave_address
Definition c13dof.h:601
uint8_t bme680_slave_address
Definition c13dof.h:599
T_C13DOF_BME680_CALIB_DATA calib
Definition c13dof.h:605
i2c_master_t i2c
Definition c13dof.h:595
uint8_t bmi088Accel_slave_address
Definition c13dof.h:602
uint8_t device_power_mode
Definition c13dof.h:610
T_C13DOF_BME680_TPH_SETTINGS tph_sett
Definition c13dof.h:606
uint8_t device_mem_page
Definition c13dof.h:609
uint8_t bmm150_slave_address
Definition c13dof.h:600