28#ifndef INCLINOMETER2_H
29#define INCLINOMETER2_H
39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
52#include "drv_spi_master.h"
75#define INCLINOMETER2_REG_FUNC_CFG_ACCESS 0x01
76#define INCLINOMETER2_REG_PIN_CTRL 0x02
77#define INCLINOMETER2_REG_FIFO_CTRL1 0x07
78#define INCLINOMETER2_REG_FIFO_CTRL2 0x08
79#define INCLINOMETER2_REG_FIFO_CTRL3 0x09
80#define INCLINOMETER2_REG_FIFO_CTRL4 0x0A
81#define INCLINOMETER2_REG_COUNTER_BDR_REG1 0x0B
82#define INCLINOMETER2_REG_COUNTER_BDR_REG2 0x0C
83#define INCLINOMETER2_REG_INT1_CTRL 0x0D
84#define INCLINOMETER2_REG_INT2_CTRL 0x0E
85#define INCLINOMETER2_REG_WHO_AM_I 0x0F
86#define INCLINOMETER2_REG_CTRL1_XL 0x10
87#define INCLINOMETER2_REG_CTRL3_C 0x12
88#define INCLINOMETER2_REG_CTRL4_C 0x13
89#define INCLINOMETER2_REG_CTRL5_C 0x14
90#define INCLINOMETER2_REG_CTRL6_C 0x15
91#define INCLINOMETER2_REG_CTRL7_XL 0x16
92#define INCLINOMETER2_REG_CTRL8_XL 0x17
93#define INCLINOMETER2_REG_CTRL9_XL 0x18
94#define INCLINOMETER2_REG_CTRL10_C 0x19
95#define INCLINOMETER2_REG_ALL_INT_SRC 0x1A
96#define INCLINOMETER2_REG_WAKE_UP_SRC 0x1B
97#define INCLINOMETER2_REG_TAP_SRC 0x1C
98#define INCLINOMETER2_REG_DEN_SRC 0x1D
99#define INCLINOMETER2_REG_STATUS 0x1E
100#define INCLINOMETER2_REG_OUT_TEMP_L 0x20
101#define INCLINOMETER2_REG_OUT_TEMP_H 0x21
102#define INCLINOMETER2_REG_OUTX_L_A 0x28
103#define INCLINOMETER2_REG_OUTX_H_A 0x29
104#define INCLINOMETER2_REG_OUTY_L_A 0x2A
105#define INCLINOMETER2_REG_OUTY_H_A 0x2B
106#define INCLINOMETER2_REG_EMB_FUNC_STATUS_MAINPAGE 0x35
107#define INCLINOMETER2_REG_FSM_STATUS_A_MAINPAGE 0x36
108#define INCLINOMETER2_REG_FSM_STATUS_B_MAINPAGE 0x37
109#define INCLINOMETER2_REG_MLC_STATUS_MAINPAGE 0x38
110#define INCLINOMETER2_REG_STATUS_MASTER_MAINPAGE 0x39
111#define INCLINOMETER2_REG_FIFO_STATUS1 0x3A
112#define INCLINOMETER2_REG_FIFO_STATUS2 0x3B
113#define INCLINOMETER2_REG_TIMESTAMP0 0x40
114#define INCLINOMETER2_REG_TIMESTAMP1 0x41
115#define INCLINOMETER2_REG_TIMESTAMP2 0x42
116#define INCLINOMETER2_REG_TIMESTAMP3 0x43
117#define INCLINOMETER2_REG_TAP_CFG0 0x56
118#define INCLINOMETER2_REG_TAP_CFG1 0x57
119#define INCLINOMETER2_REG_TAP_CFG2 0x58
120#define INCLINOMETER2_REG_INT_DUR2 0x5A
121#define INCLINOMETER2_REG_WAKE_UP_THS 0x5B
122#define INCLINOMETER2_REG_WAKE_UP_DUR 0x5C
123#define INCLINOMETER2_REG_MD1_CFG 0x5E
124#define INCLINOMETER2_REG_MD2_CFG 0x5F
125#define INCLINOMETER2_REG_INTERNAL_FREQ_FINE 0x63
126#define INCLINOMETER2_REG_X_OFS_USR 0x73
127#define INCLINOMETER2_REG_Y_OFS_USR 0x74
128#define INCLINOMETER2_REG_FIFO_DATA_OUT_TAG 0x78
129#define INCLINOMETER2_REG_FIFO_DATA_OUT_X_L 0x79
130#define INCLINOMETER2_REG_FIFO_DATA_OUT_X_H 0x7A
131#define INCLINOMETER2_REG_FIFO_DATA_OUT_Y_L 0x7B
132#define INCLINOMETER2_REG_FIFO_DATA_OUT_Y_H 0x7C
133#define INCLINOMETER2_REG_FIFO_DATA_OUT_Z_L 0x7D
134#define INCLINOMETER2_REG_FIFO_DATA_OUT_Z_H 0x7E
140#define INCLINOMETER2_FUNC_REG_PAGE_SEL 0x02
141#define INCLINOMETER2_FUNC_REG_EMB_FUNC_EN_B 0x05
142#define INCLINOMETER2_FUNC_REG_PAGE_ADDRESS 0x08
143#define INCLINOMETER2_FUNC_REG_PAGE_VALUE 0x09
144#define INCLINOMETER2_FUNC_REG_EMB_FUNC_INT1 0x0A
145#define INCLINOMETER2_FUNC_REG_FSM_INT1_A 0x0B
146#define INCLINOMETER2_FUNC_REG_FSM_INT1_B 0x0C
147#define INCLINOMETER2_FUNC_REG_MLC_INT1 0x0D
148#define INCLINOMETER2_FUNC_REG_EMB_FUNC_INT2 0x0E
149#define INCLINOMETER2_FUNC_REG_FSM_INT2_A 0x0F
150#define INCLINOMETER2_FUNC_REG_FSM_INT2_B 0x10
151#define INCLINOMETER2_FUNC_REG_MLC_INT2 0x11
152#define INCLINOMETER2_FUNC_REG_EMB_FUNC_STATUS 0x12
153#define INCLINOMETER2_FUNC_REG_FSM_STATUS_A 0x13
154#define INCLINOMETER2_FUNC_REG_FSM_STATUS_B 0x14
155#define INCLINOMETER2_FUNC_REG_MLC_STATUS 0x15
156#define INCLINOMETER2_FUNC_REG_PAGE_RW 0x17
157#define INCLINOMETER2_FUNC_REG_FSM_ENABLE_A 0x46
158#define INCLINOMETER2_FUNC_REG_FSM_ENABLE_B 0x47
159#define INCLINOMETER2_FUNC_REG_FSM_LONG_COUNTER_L 0x48
160#define INCLINOMETER2_FUNC_REG_FSM_LONG_COUNTER_H 0x49
161#define INCLINOMETER2_FUNC_REG_FSM_LONG_COUNTER_CLR 0x4A
162#define INCLINOMETER2_FUNC_REG_FSM_OUTS1 0x4C
163#define INCLINOMETER2_FUNC_REG_FSM_OUTS2 0x4D
164#define INCLINOMETER2_FUNC_REG_FSM_OUTS3 0x4E
165#define INCLINOMETER2_FUNC_REG_FSM_OUTS4 0x4F
166#define INCLINOMETER2_FUNC_REG_FSM_OUTS5 0x50
167#define INCLINOMETER2_FUNC_REG_FSM_OUTS6 0x51
168#define INCLINOMETER2_FUNC_REG_FSM_OUTS7 0x52
169#define INCLINOMETER2_FUNC_REG_FSM_OUTS8 0x53
170#define INCLINOMETER2_FUNC_REG_FSM_OUTS9 0x54
171#define INCLINOMETER2_FUNC_REG_FSM_OUTS10 0x55
172#define INCLINOMETER2_FUNC_REG_FSM_OUTS11 0x56
173#define INCLINOMETER2_FUNC_REG_FSM_OUTS12 0x57
174#define INCLINOMETER2_FUNC_REG_FSM_OUTS13 0x58
175#define INCLINOMETER2_FUNC_REG_FSM_OUTS14 0x59
176#define INCLINOMETER2_FUNC_REG_FSM_OUTS15 0x5A
177#define INCLINOMETER2_FUNC_REG_FSM_OUTS16 0x5B
178#define INCLINOMETER2_FUNC_REG_EMB_FUNC_ODR_CFG_B 0x5F
179#define INCLINOMETER2_FUNC_REG_EMB_FUNC_ODR_CFG_C 0x60
180#define INCLINOMETER2_FUNC_REG_EMB_FUNC_INIT_B 0x67
181#define INCLINOMETER2_FUNC_REG_MCL0_SRC 0x70
182#define INCLINOMETER2_FUNC_REG_MCL1_SRC 0x71
183#define INCLINOMETER2_FUNC_REG_MCL2_SRC 0x72
184#define INCLINOMETER2_FUNC_REG_MCL3_SRC 0x73
185#define INCLINOMETER2_FUNC_REG_MCL4_SRC 0x74
186#define INCLINOMETER2_FUNC_REG_MCL5_SRC 0x75
187#define INCLINOMETER2_FUNC_REG_MCL6_SRC 0x76
188#define INCLINOMETER2_FUNC_REG_MCL7_SRC 0x77
194#define INCLINOMETER2_SHUB_REG_SENSOR_HUB_1 0x02
195#define INCLINOMETER2_SHUB_REG_SENSOR_HUB_2 0x03
196#define INCLINOMETER2_SHUB_REG_SENSOR_HUB_3 0x04
197#define INCLINOMETER2_SHUB_REG_SENSOR_HUB_4 0x05
198#define INCLINOMETER2_SHUB_REG_SENSOR_HUB_5 0x06
199#define INCLINOMETER2_SHUB_REG_SENSOR_HUB_6 0x07
200#define INCLINOMETER2_SHUB_REG_SENSOR_HUB_7 0x08
201#define INCLINOMETER2_SHUB_REG_SENSOR_HUB_8 0x09
202#define INCLINOMETER2_SHUB_REG_SENSOR_HUB_9 0x0A
203#define INCLINOMETER2_SHUB_REG_SENSOR_HUB_10 0x0B
204#define INCLINOMETER2_SHUB_REG_SENSOR_HUB_11 0x0C
205#define INCLINOMETER2_SHUB_REG_SENSOR_HUB_12 0x0D
206#define INCLINOMETER2_SHUB_REG_SENSOR_HUB_13 0x0E
207#define INCLINOMETER2_SHUB_REG_SENSOR_HUB_14 0x0F
208#define INCLINOMETER2_SHUB_REG_SENSOR_HUB_15 0x10
209#define INCLINOMETER2_SHUB_REG_SENSOR_HUB_16 0x11
210#define INCLINOMETER2_SHUB_REG_SENSOR_HUB_17 0x12
211#define INCLINOMETER2_SHUB_REG_SENSOR_HUB_18 0x13
212#define INCLINOMETER2_SHUB_REG_MASTER_CONFIG 0x14
213#define INCLINOMETER2_SHUB_REG_SLV0_ADD 0x15
214#define INCLINOMETER2_SHUB_REG_SLV0_SUBADD 0x16
215#define INCLINOMETER2_SHUB_REG_SLV0_CONFIG 0x17
216#define INCLINOMETER2_SHUB_REG_SLV1_ADD 0x18
217#define INCLINOMETER2_SHUB_REG_SLV1_SUBADD 0x19
218#define INCLINOMETER2_SHUB_REG_SLV1_CONFIG 0x1A
219#define INCLINOMETER2_SHUB_REG_SLV2_ADD 0x1B
220#define INCLINOMETER2_SHUB_REG_SLV2_SUBADD 0x1C
221#define INCLINOMETER2_SHUB_REG_SLV2_CONFIG 0x1D
222#define INCLINOMETER2_SHUB_REG_SLV3_ADD 0x1E
223#define INCLINOMETER2_SHUB_REG_SLV3_SUBADD 0x1F
224#define INCLINOMETER2_SHUB_REG_SLV3_CONFIG 0x20
225#define INCLINOMETER2_SHUB_REG_DATAWRITE_SLV0 0x21
226#define INCLINOMETER2_SHUB_REG_STATUS_MASTER 0x22
244#define INCLINOMETER2_INT1_CTRL_DEN_DRDY 0x80
245#define INCLINOMETER2_INT1_CTRL_CNT_BDR 0x40
246#define INCLINOMETER2_INT1_CTRL_FIFO_FULL 0x20
247#define INCLINOMETER2_INT1_CTRL_FIFO_OVR 0x10
248#define INCLINOMETER2_INT1_CTRL_FIFO_TH 0x08
249#define INCLINOMETER2_INT1_CTRL_BOOT 0x04
250#define INCLINOMETER2_INT1_CTRL_DRDY_XL 0x01
256#define INCLINOMETER2_STATUS_TEMP_DRDY 0x04
257#define INCLINOMETER2_STATUS_ACCEL_DRDY 0x01
263#define INCLINOMETER2_ACCEL_FSR_0p5G_RES 0.015f
264#define INCLINOMETER2_ACCEL_FSR_1G_RES 0.031f
265#define INCLINOMETER2_ACCEL_FSR_2G_RES 0.061f
266#define INCLINOMETER2_ACCEL_FSR_3G_RES 0.122f
267#define INCLINOMETER2_ROOM_TEMP 25.0f
268#define INCLINOMETER2_TEMP_SENS 256.0f
274#define INCLINOMETER2_WHO_AM_I 0x6B
281#define INCLINOMETER2_DEVICE_ADDRESS_0 0x6A
282#define INCLINOMETER2_DEVICE_ADDRESS_1 0x6B
292#define INCLINOMETER2_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
293#define INCLINOMETER2_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
311#define INCLINOMETER2_MAP_MIKROBUS( cfg, mikrobus ) \
312 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
313 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
314 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
315 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
316 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
317 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
318 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
err_t inclinometer2_get_temperature(inclinometer2_t *ctx, float *temperature)
Inclinometer 2 get temperature function.
err_t inclinometer2_get_accel(inclinometer2_t *ctx, float *x_axis, float *y_axis)
Inclinometer 2 get accel function.
err_t inclinometer2_generic_read(inclinometer2_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Inclinometer 2 data reading function.
err_t inclinometer2_set_fsr_and_odr(inclinometer2_t *ctx, inclinometer2_fsr_t fsr, inclinometer2_odr_t odr)
Inclinometer 2 set fsr and odr function.
uint8_t inclinometer2_get_int_pin(inclinometer2_t *ctx)
Inclinometer 2 get int pin function.
void inclinometer2_drv_interface_selection(inclinometer2_cfg_t *cfg, inclinometer2_drv_t drv_sel)
Inclinometer 2 driver interface setup function.
err_t inclinometer2_read_register(inclinometer2_t *ctx, uint8_t reg, uint8_t *data_out)
Inclinometer 2 read register function.
err_t inclinometer2_write_register(inclinometer2_t *ctx, uint8_t reg, uint8_t data_in)
Inclinometer 2 write register function.
err_t inclinometer2_init(inclinometer2_t *ctx, inclinometer2_cfg_t *cfg)
Inclinometer 2 initialization function.
err_t inclinometer2_default_cfg(inclinometer2_t *ctx)
Inclinometer 2 default configuration function.
void inclinometer2_cfg_setup(inclinometer2_cfg_t *cfg)
Inclinometer 2 configuration object setup function.
err_t inclinometer2_generic_write(inclinometer2_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Inclinometer 2 data writing function.
err_t inclinometer2_check_communication(inclinometer2_t *ctx)
Inclinometer 2 check communication function.
struct inclinometer2_s inclinometer2_t
Inclinometer 2 Click context object.
inclinometer2_fsr_t
Inclinometer 2 Click accel full-scale range selection.
Definition inclinometer2.h:392
@ INCLINOMETER2_FSR_BIT_MASK
Definition inclinometer2.h:397
@ INCLINOMETER2_FSR_3G
Definition inclinometer2.h:394
@ INCLINOMETER2_FSR_0p5G
Definition inclinometer2.h:393
@ INCLINOMETER2_FSR_2G
Definition inclinometer2.h:396
@ INCLINOMETER2_FSR_1G
Definition inclinometer2.h:395
inclinometer2_return_value_t
Inclinometer 2 Click return value data.
Definition inclinometer2.h:424
@ INCLINOMETER2_ERROR
Definition inclinometer2.h:426
@ INCLINOMETER2_OK
Definition inclinometer2.h:425
inclinometer2_odr_t
Inclinometer 2 Click output data rate.
Definition inclinometer2.h:406
@ INCLINOMETER2_ODR_104HZ
Definition inclinometer2.h:411
@ INCLINOMETER2_ODR_12p5HZ
Definition inclinometer2.h:408
@ INCLINOMETER2_ODR_52HZ
Definition inclinometer2.h:410
@ INCLINOMETER2_ODR_833HZ
Definition inclinometer2.h:414
@ INCLINOMETER2_ODR_416HZ
Definition inclinometer2.h:413
@ INCLINOMETER2_ODR_POWER_DOWN
Definition inclinometer2.h:407
@ INCLINOMETER2_ODR_26HZ
Definition inclinometer2.h:409
@ INCLINOMETER2_ODR_BIT_MASK
Definition inclinometer2.h:415
@ INCLINOMETER2_ODR_208HZ
Definition inclinometer2.h:412
inclinometer2_drv_t
Inclinometer 2 Click driver selector.
Definition inclinometer2.h:328
@ INCLINOMETER2_DRV_SEL_I2C
Definition inclinometer2.h:330
@ INCLINOMETER2_DRV_SEL_SPI
Definition inclinometer2.h:329
err_t(* inclinometer2_master_io_t)(struct inclinometer2_s *, uint8_t, uint8_t *, uint8_t)
Definition inclinometer2.h:339
This file contains SPI specific macros, functions, etc.
Inclinometer 2 Click configuration object.
Definition inclinometer2.h:367
inclinometer2_drv_t drv_sel
Definition inclinometer2.h:383
uint32_t i2c_speed
Definition inclinometer2.h:376
spi_master_chip_select_polarity_t cs_polarity
Definition inclinometer2.h:381
pin_name_t sck
Definition inclinometer2.h:372
spi_master_mode_t spi_mode
Definition inclinometer2.h:380
pin_name_t mosi
Definition inclinometer2.h:371
uint32_t spi_speed
Definition inclinometer2.h:379
pin_name_t scl
Definition inclinometer2.h:368
pin_name_t int_pin
Definition inclinometer2.h:374
pin_name_t miso
Definition inclinometer2.h:370
pin_name_t sda
Definition inclinometer2.h:369
pin_name_t cs
Definition inclinometer2.h:373
uint8_t i2c_address
Definition inclinometer2.h:377
Inclinometer 2 Click context object.
Definition inclinometer2.h:346
spi_master_t spi
Definition inclinometer2.h:350
inclinometer2_drv_t drv_sel
Definition inclinometer2.h:354
float resolution
Definition inclinometer2.h:358
inclinometer2_master_io_t write_f
Definition inclinometer2.h:356
inclinometer2_master_io_t read_f
Definition inclinometer2.h:357
digital_in_t int_pin
Definition inclinometer2.h:347
i2c_master_t i2c
Definition inclinometer2.h:349
uint8_t slave_address
Definition inclinometer2.h:352
pin_name_t chip_select
Definition inclinometer2.h:353