28#ifndef ACCELPRESSURE_H
29#define ACCELPRESSURE_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"
74#define ACCELPRESSURE_ACC_REG_INT_STATUS 0x00
75#define ACCELPRESSURE_ACC_REG_TEMP_OUT 0x01
76#define ACCELPRESSURE_ACC_REG_VECM_LSB 0x02
77#define ACCELPRESSURE_ACC_REG_VECM_MSB 0x03
78#define ACCELPRESSURE_ACC_REG_OUT_X_LSB 0x04
79#define ACCELPRESSURE_ACC_REG_OUT_X_MSB 0x05
80#define ACCELPRESSURE_ACC_REG_OUT_Y_LSB 0x06
81#define ACCELPRESSURE_ACC_REG_OUT_Y_MSB 0x07
82#define ACCELPRESSURE_ACC_REG_OUT_Z_LSB 0x08
83#define ACCELPRESSURE_ACC_REG_OUT_Z_MSB 0x09
84#define ACCELPRESSURE_ACC_REG_BUF_STATUS 0x0B
85#define ACCELPRESSURE_ACC_REG_BUF_X_LSB 0x0C
86#define ACCELPRESSURE_ACC_REG_BUF_X_MSB 0x0D
87#define ACCELPRESSURE_ACC_REG_BUF_Y_LSB 0x0E
88#define ACCELPRESSURE_ACC_REG_BUF_Y_MSB 0x0F
89#define ACCELPRESSURE_ACC_REG_BUF_Z_LSB 0x10
90#define ACCELPRESSURE_ACC_REG_BUF_Z_MSB 0x11
91#define ACCELPRESSURE_ACC_REG_PROD_REV 0x12
92#define ACCELPRESSURE_ACC_REG_WHO_AM_I 0x13
93#define ACCELPRESSURE_ACC_REG_SYS_MODE 0x14
94#define ACCELPRESSURE_ACC_REG_SENS_CONFIG1 0x15
95#define ACCELPRESSURE_ACC_REG_SENS_CONFIG2 0x16
96#define ACCELPRESSURE_ACC_REG_SENS_CONFIG3 0x17
97#define ACCELPRESSURE_ACC_REG_SENS_CONFIG4 0x18
98#define ACCELPRESSURE_ACC_REG_SENS_CONFIG5 0x19
99#define ACCELPRESSURE_ACC_REG_WAKE_IDLE_LSB 0x1A
100#define ACCELPRESSURE_ACC_REG_WAKE_IDLE_MSB 0x1B
101#define ACCELPRESSURE_ACC_REG_SLEEP_IDLE_LSB 0x1C
102#define ACCELPRESSURE_ACC_REG_SLEEP_IDLE_MSB 0x1D
103#define ACCELPRESSURE_ACC_REG_ASLP_COUNT_LSB 0x1E
104#define ACCELPRESSURE_ACC_REG_ASLP_COUNT_MSB 0x1F
105#define ACCELPRESSURE_ACC_REG_INT_EN 0x20
106#define ACCELPRESSURE_ACC_REG_INT_PIN_SEL 0x21
107#define ACCELPRESSURE_ACC_REG_OFF_X 0x22
108#define ACCELPRESSURE_ACC_REG_OFF_Y 0x23
109#define ACCELPRESSURE_ACC_REG_OFF_Z 0x24
110#define ACCELPRESSURE_ACC_REG_BUF_CONFIG1 0x26
111#define ACCELPRESSURE_ACC_REG_BUF_CONFIG2 0x27
112#define ACCELPRESSURE_ACC_REG_ORIENT_STATUS 0x28
113#define ACCELPRESSURE_ACC_REG_ORIENT_CONFIG 0x29
114#define ACCELPRESSURE_ACC_REG_ORIENT_DBCOUNT 0x2A
115#define ACCELPRESSURE_ACC_REG_ORIENT_BF_ZCOMP 0x2B
116#define ACCELPRESSURE_ACC_REG_ORIENT_THS_REG 0x2C
117#define ACCELPRESSURE_ACC_REG_SDCD_INT_SRC1 0x2D
118#define ACCELPRESSURE_ACC_REG_SDCD_INT_SRC2 0x2E
119#define ACCELPRESSURE_ACC_REG_SDCD_CONFIG1 0x2F
120#define ACCELPRESSURE_ACC_REG_SDCD_CONFIG2 0x30
121#define ACCELPRESSURE_ACC_REG_SDCD_OT_DBCNT 0x31
122#define ACCELPRESSURE_ACC_REG_SDCD_WT_DBCNT 0x32
123#define ACCELPRESSURE_ACC_REG_SDCD_LTHS_LSB 0x33
124#define ACCELPRESSURE_ACC_REG_SDCD_LTHS_MSB 0x34
125#define ACCELPRESSURE_ACC_REG_SDCD_UTHS_LSB 0x35
126#define ACCELPRESSURE_ACC_REG_SDCD_UTHS_MSB 0x36
127#define ACCELPRESSURE_ACC_REG_SELF_TEST_CONFIG1 0x37
128#define ACCELPRESSURE_ACC_REG_SELF_TEST_CONFIG2 0x38
135#define ACCELPRESSURE_PRESS_REG_STATUS 0x00
136#define ACCELPRESSURE_PRESS_REG_OUT_P_MSB 0x01
137#define ACCELPRESSURE_PRESS_REG_OUT_P_CSB 0x02
138#define ACCELPRESSURE_PRESS_REG_OUT_P_LSB 0x03
139#define ACCELPRESSURE_PRESS_REG_OUT_T_MSB 0x04
140#define ACCELPRESSURE_PRESS_REG_OUT_T_LSB 0x05
141#define ACCELPRESSURE_PRESS_REG_DR_STATUS 0x06
142#define ACCELPRESSURE_PRESS_REG_OUT_P_DELTA_MSB 0x07
143#define ACCELPRESSURE_PRESS_REG_OUT_P_DELTA_CSB 0x08
144#define ACCELPRESSURE_PRESS_REG_OUT_P_DELTA_LSB 0x09
145#define ACCELPRESSURE_PRESS_REG_OUT_T_DELTA_MSB 0x0A
146#define ACCELPRESSURE_PRESS_REG_OUT_T_DELTA_LSB 0x0B
147#define ACCELPRESSURE_PRESS_REG_WHO_AM_I 0x0C
148#define ACCELPRESSURE_PRESS_REG_FIFO_STATUS 0x0D
149#define ACCELPRESSURE_PRESS_REG_FIFO_DATA 0x0E
150#define ACCELPRESSURE_PRESS_REG_FIFO_SETUP 0x0F
151#define ACCELPRESSURE_PRESS_REG_TIME_DLY 0x10
152#define ACCELPRESSURE_PRESS_REG_SYSMOD 0x11
153#define ACCELPRESSURE_PRESS_REG_INT_SOURCE 0x12
154#define ACCELPRESSURE_PRESS_REG_PT_DATA_CFG 0x13
155#define ACCELPRESSURE_PRESS_REG_BAR_IN_MSB 0x14
156#define ACCELPRESSURE_PRESS_REG_BAR_IN_LSB 0x15
157#define ACCELPRESSURE_PRESS_REG_P_TGT_MSB 0x16
158#define ACCELPRESSURE_PRESS_REG_P_TGT_LSB 0x17
159#define ACCELPRESSURE_PRESS_REG_T_TGT 0x18
160#define ACCELPRESSURE_PRESS_REG_P_WND_MSB 0x19
161#define ACCELPRESSURE_PRESS_REG_P_WND_LSB 0x1A
162#define ACCELPRESSURE_PRESS_REG_T_WND 0x1B
163#define ACCELPRESSURE_PRESS_REG_P_MIN_MSB 0x1C
164#define ACCELPRESSURE_PRESS_REG_P_MIN_CSB 0x1D
165#define ACCELPRESSURE_PRESS_REG_P_MIN_LSB 0x1E
166#define ACCELPRESSURE_PRESS_REG_T_MIN_MSB 0x1F
167#define ACCELPRESSURE_PRESS_REG_T_MIN_LSB 0x20
168#define ACCELPRESSURE_PRESS_REG_P_MAX_MSB 0x21
169#define ACCELPRESSURE_PRESS_REG_P_MAX_CSB 0x22
170#define ACCELPRESSURE_PRESS_REG_P_MAX_LSB 0x23
171#define ACCELPRESSURE_PRESS_REG_T_MAX_MSB 0x24
172#define ACCELPRESSURE_PRESS_REG_T_MAX_LSB 0x25
173#define ACCELPRESSURE_PRESS_REG_CTRL1 0x26
174#define ACCELPRESSURE_PRESS_REG_CTRL2 0x27
175#define ACCELPRESSURE_PRESS_REG_CTRL3 0x28
176#define ACCELPRESSURE_PRESS_REG_CTRL4 0x29
177#define ACCELPRESSURE_PRESS_REG_CTRL5 0x2A
178#define ACCELPRESSURE_PRESS_REG_OFF_P 0x2B
179#define ACCELPRESSURE_PRESS_REG_OFF_T 0x2C
180#define ACCELPRESSURE_PRESS_REG_OFF_H 0x2D
198#define ACCELPRESSURE_ACC_SRC_BOOT_COMPLETED 0x01
204#define ACCELPRESSURE_ACC_DEVICE_ID_VAL 0x86
210#define ACCELPRESSURE_ACC_SW_RESET_BIT_MASK 0x80
216#define ACCELPRESSURE_ACC_OP_MODE_STANDBY 0x00
217#define ACCELPRESSURE_ACC_OP_MODE_ACTIVE 0x01
218#define ACCELPRESSURE_ACC_OP_MODE_BIT_MASK 0xFE
224#define ACCELPRESSURE_ACC_FSR_SEL_2G 0x00
225#define ACCELPRESSURE_ACC_FSR_SEL_4G 0x01
226#define ACCELPRESSURE_ACC_FSR_SEL_8G 0x02
227#define ACCELPRESSURE_ACC_FSR_SEL_16G 0x03
228#define ACCELPRESSURE_ACC_FSR_SEL_BIT_MASK 0xF9
234#define ACCELPRESSURE_ACC_INT_EN_DRDY_DIS 0x00
235#define ACCELPRESSURE_ACC_INT_EN_DRDY_EN 0x80
241#define ACCELPRESSURE_ACC_FSR_SENS_VAL_2G 0.98f
242#define ACCELPRESSURE_ACC_FSR_SENS_VAL_4G 1.95f
243#define ACCELPRESSURE_ACC_FSR_SENS_VAL_8G 3.91f
244#define ACCELPRESSURE_ACC_FSR_SENS_VAL_16G 7.81f
250#define ACCELPRESSURE_PRESS_STATUS_FLAG_TDR 0x02
251#define ACCELPRESSURE_PRESS_STATUS_FLAG_PDR 0x04
252#define ACCELPRESSURE_PRESS_STATUS_FLAG_PTDR 0x08
253#define ACCELPRESSURE_PRESS_STATUS_FLAG_TOW 0x20
254#define ACCELPRESSURE_PRESS_STATUS_FLAG_POW 0x40
255#define ACCELPRESSURE_PRESS_STATUS_FLAG_PTOW 0x80
261#define ACCELPRESSURE_PRESS_INT_SOURCE_FLAG_DRDY 0x80
262#define ACCELPRESSURE_PRESS_INT_SOURCE_FLAG_FIFO 0x40
263#define ACCELPRESSURE_PRESS_INT_SOURCE_FLAG_PW 0x20
264#define ACCELPRESSURE_PRESS_INT_SOURCE_FLAG_TW 0x10
265#define ACCELPRESSURE_PRESS_INT_SOURCE_FLAG_PTH 0x08
266#define ACCELPRESSURE_PRESS_INT_SOURCE_FLAG_TTH 0x04
267#define ACCELPRESSURE_PRESS_INT_SOURCE_FLAG_PCHG 0x02
268#define ACCELPRESSURE_PRESS_INT_SOURCE_FLAG_TCHG 0x01
274#define ACCELPRESSURE_PRESS_CTRL1_ALT_BARO 0x00
275#define ACCELPRESSURE_PRESS_CTRL1_ALT_ALTI 0x80
276#define ACCELPRESSURE_PRESS_CTRL1_ALT_BITMASK 0x7F
277#define ACCELPRESSURE_PRESS_CTRL1_SBYB 0x01
278#define ACCELPRESSURE_PRESS_CTRL1_OST 0x02
279#define ACCELPRESSURE_PRESS_CTRL1_CLR 0x03
280#define ACCELPRESSURE_PRESS_CTRL1_RST 0x04
281#define ACCELPRESSURE_PRESS_CTRL1_RAW 0x40
282#define ACCELPRESSURE_PRESS_CTRL1_ALT 0x80
283#define ACCELPRESSURE_PRESS_CTRL1_BAR 0x00
284#define ACCELPRESSURE_PRESS_CTRL1_OS1_6MS 0x00
285#define ACCELPRESSURE_PRESS_CTRL1_OS2_10MS 0x08
286#define ACCELPRESSURE_PRESS_CTRL1_OS4_18MS 0x10
287#define ACCELPRESSURE_PRESS_CTRL1_OS8_34MS 0x18
288#define ACCELPRESSURE_PRESS_CTRL1_OS16_66MS 0x20
289#define ACCELPRESSURE_PRESS_CTRL1_OS32_130MS 0x28
290#define ACCELPRESSURE_PRESS_CTRL1_OS64_258MS 0x30
291#define ACCELPRESSURE_PRESS_CTRL1_OS128_512MS 0x38
297#define ACCELPRESSURE_PRESS_MODE_BAROMETER 0x00
298#define ACCELPRESSURE_PRESS_MODE_ALTIMETER 0x01
304#define ACCELPRESSURE_PRESS_CTRL3_INT1_POL_HIGH 0x20
305#define ACCELPRESSURE_PRESS_CTRL3_INT1_POL_LOW 0x00
306#define ACCELPRESSURE_PRESS_CTRL3_INT1_OD 0x10
307#define ACCELPRESSURE_PRESS_CTRL3_INT2_POL_HIGH 0x02
308#define ACCELPRESSURE_PRESS_CTRL3_INT2_POL_LOW 0x00
309#define ACCELPRESSURE_PRESS_CTRL3_INT2_OD 0x01
315#define ACCELPRESSURE_PRESS_CTRL4_INT_EN_DRDY 0x80
316#define ACCELPRESSURE_PRESS_CTRL4_INT_EN_FIFO 0x40
317#define ACCELPRESSURE_PRESS_CTRL4_INT_EN_PW 0x20
318#define ACCELPRESSURE_PRESS_CTRL4_INT_EN_TW 0x10
319#define ACCELPRESSURE_PRESS_CTRL4_INT_EN_PTH 0x08
320#define ACCELPRESSURE_PRESS_CTRL4_INT_EN_TTH 0x04
321#define ACCELPRESSURE_PRESS_CTRL4_INT_EN_PCHG 0x02
322#define ACCELPRESSURE_PRESS_CTRL4_INT_EN_TCHG 0x01
323#define ACCELPRESSURE_PRESS_CTRL4_INT_DIS_ALL 0x00
329#define ACCELPRESSURE_PRESS_CTRL5_INT1_DRDY 0x80
330#define ACCELPRESSURE_PRESS_CTRL5_INT2_DRDY 0x00
331#define ACCELPRESSURE_PRESS_CTRL5_INT1_FIFO 0x40
332#define ACCELPRESSURE_PRESS_CTRL5_INT2_FIFO 0x00
333#define ACCELPRESSURE_PRESS_CTRL5_INT1_PW 0x20
334#define ACCELPRESSURE_PRESS_CTRL5_INT2_PW 0x00
335#define ACCELPRESSURE_PRESS_CTRL5_INT1_TW 0x10
336#define ACCELPRESSURE_PRESS_CTRL5_INT2_TW 0x00
337#define ACCELPRESSURE_PRESS_CTRL5_INT1_PTH 0x08
338#define ACCELPRESSURE_PRESS_CTRL5_INT2_PTH 0x00
339#define ACCELPRESSURE_PRESS_CTRL5_INT1_TTH 0x04
340#define ACCELPRESSURE_PRESS_CTRL5_INT2_TTH 0x00
341#define ACCELPRESSURE_PRESS_CTRL5_INT1_PCHG 0x02
342#define ACCELPRESSURE_PRESS_CTRL5_INT2_PCHG 0x00
343#define ACCELPRESSURE_PRESS_CTRL5_INT1_TCHG 0x01
344#define ACCELPRESSURE_PRESS_CTRL5_INT2_TCHG 0x00
350#define ACCELPRESSURE_PRESS_F_SETUP_FIFO_DISABLE 0x00
351#define ACCELPRESSURE_PRESS_F_SETUP_FIFO_CIR_BUFF 0x40
352#define ACCELPRESSURE_PRESS_F_SETUP_FIFO_STOP_MODE 0x80
358#define ACCELPRESSURE_PRESS_PT_DATA_DR_EVENT_EN 0x04
359#define ACCELPRESSURE_PRESS_PT_DATA_PD_EVENT_EN 0x02
360#define ACCELPRESSURE_PRESS_PT_DATA_TD_EVENT_EN 0x01
361#define ACCELPRESSURE_PRESS_PT_DATA_ALL_EVENTS_DIS 0x00
367#define ACCELPRESSURE_PRESS_PRESSURE_SENS 0.25f
368#define ACCELPRESSURE_PRESS_CONVERT_PA_TO_MBAR 100.0f
369#define ACCELPRESSURE_PRESS_TEMP_SENS 0.0625f
376#define ACCELPRESSURE_DEVICE_ADDRESS_ACCEL 0x18
377#define ACCELPRESSURE_DEVICE_ADDRESS_PRESS 0x60
395#define ACCELPRESSURE_MAP_MIKROBUS( cfg, mikrobus ) \
396 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
397 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
398 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
399 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
400 cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
401 cfg.mot = MIKROBUS( mikrobus, MIKROBUS_INT )
accelpressure_return_value_t
AccelPressure Click return value data.
Definition accelpressure.h:467
@ ACCELPRESSURE_OK
Definition accelpressure.h:468
@ ACCELPRESSURE_ERROR
Definition accelpressure.h:469
uint8_t accelpressure_get_mot_det(accelpressure_t *ctx)
AccelPressure get motion detect state function.
err_t accelpressure_press_reg_write(accelpressure_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
AccelPressure pressure I2C writing function.
err_t accelpressure_set_fsr(accelpressure_t *ctx, uint8_t fsr)
AccelPressure set FSR function.
err_t accelpressure_get_device_id(accelpressure_t *ctx, uint8_t *device_id)
AccelPressure get device ID function.
err_t accelpressure_press_reg_read(accelpressure_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
AccelPressure pressure I2C reading function.
err_t accelpressure_acc_reg_read(accelpressure_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
AccelPressure accel I2C reading function.
err_t accelpressure_get_pressure(accelpressure_t *ctx, float *pressure)
AccelPressure get pressure data function.
err_t accelpressure_default_cfg(accelpressure_t *ctx)
AccelPressure default configuration function.
err_t accelpressure_get_status(accelpressure_t *ctx, uint8_t *status)
AccelPressure get status function.
err_t accelpressure_set_press_mode(accelpressure_t *ctx, uint8_t op_mode)
AccelPressure set pressure operating mode function.
err_t accelpressure_get_temperature(accelpressure_t *ctx, float *temperature)
AccelPressure get temperature data function.
err_t accelpressure_get_axes_data(accelpressure_t *ctx, accelpressure_axes_t *axes)
AccelPressure get the accel sensor axes function.
err_t accelpressure_get_drdy_status(accelpressure_t *ctx, uint8_t *drdy)
AccelPressure get data ready status function.
err_t accelpressure_acc_reg_write(accelpressure_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
AccelPressure accel I2C writing function.
err_t accelpressure_init(accelpressure_t *ctx, accelpressure_cfg_t *cfg)
AccelPressure initialization function.
err_t accelpressure_sw_reset(accelpressure_t *ctx)
AccelPressure soft reset function.
void accelpressure_cfg_setup(accelpressure_cfg_t *cfg)
AccelPressure configuration object setup function.
err_t accelpressure_set_acc_mode(accelpressure_t *ctx, uint8_t op_mode)
AccelPressure set accel operating mode function.
AccelPressure Click axes data.
Definition accelpressure.h:455
float y
Definition accelpressure.h:457
float x
Definition accelpressure.h:456
float z
Definition accelpressure.h:458
AccelPressure Click configuration object.
Definition accelpressure.h:436
uint32_t i2c_speed
Definition accelpressure.h:445
pin_name_t scl
Definition accelpressure.h:437
pin_name_t pwm
Definition accelpressure.h:442
pin_name_t sda
Definition accelpressure.h:438
pin_name_t mot
Definition accelpressure.h:443
pin_name_t an
Definition accelpressure.h:441
pin_name_t cs
Definition accelpressure.h:440
uint8_t i2c_address
Definition accelpressure.h:446
AccelPressure Click context object.
Definition accelpressure.h:411
digital_out_t cs
Definition accelpressure.h:413
digital_out_t pwm
Definition accelpressure.h:414
i2c_master_t i2c
Definition accelpressure.h:421
digital_in_t mot
Definition accelpressure.h:418
digital_in_t an
Definition accelpressure.h:417
float sensitivity
Definition accelpressure.h:427
uint8_t slave_address
Definition accelpressure.h:424