pressure16 2.0.0.0
pressure16.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2020 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
28#ifndef PRESSURE16_H
29#define PRESSURE16_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
52#include "drv_spi_master.h"
53
54
75#define PRESSURE16_REG_INT_CFG 0x0B
76#define PRESSURE16_REG_THR_P_L 0x0C
77#define PRESSURE16_REG_THR_P_H 0x0D
78#define PRESSURE16_REG_INTERFACE_CTRL 0x0E
79#define PRESSURE16_REG_DEVICE_ID 0x0F
80#define PRESSURE16_REG_CTRL_1 0x10
81#define PRESSURE16_REG_CTRL_2 0x11
82#define PRESSURE16_REG_CTRL_3 0x12
83#define PRESSURE16_REG_FIFO_CTRL 0x13
84#define PRESSURE16_REG_FIFO_WTM 0x14
85#define PRESSURE16_REG_REF_P_L 0x15
86#define PRESSURE16_REG_REF_P_H 0x16
87#define PRESSURE16_REG_OPC_P_L 0x18
88#define PRESSURE16_REG_OPC_P_H 0x19
89#define PRESSURE16_REG_INT_SOURCE 0x24
90#define PRESSURE16_REG_FIFO_STATUS_1 0x25
91#define PRESSURE16_REG_FIFO_STATUS_2 0x26
92#define PRESSURE16_REG_STATUS 0x27
93#define PRESSURE16_REG_DATA_P_XL 0x28
94#define PRESSURE16_REG_DATA_P_L 0x29
95#define PRESSURE16_REG_DATA_P_H 0x2A
96#define PRESSURE16_REG_DATA_T_L 0x2B
97#define PRESSURE16_REG_DATA_T_H 0x2C
98#define PRESSURE16_REG_FIFO_DATA_P_XL 0x78
99#define PRESSURE16_REG_FIFO_DATA_P_L 0x79
100#define PRESSURE16_REG_FIFO_DATA_P_H 0x7A
101#define PRESSURE16_REG_FIFO_DATA_T_L 0x7B
102#define PRESSURE16_REG_FIFO_DATA_T_H 0x7C
103
104 // pressure16_reg
105
120#define PRESSURE16_SET_CTRL_ODR_POWER_DOWN_MODE 0x00
121#define PRESSURE16_SET_CTRL_ODR_1 0x01
122#define PRESSURE16_SET_CTRL_ODR_10 0x02
123#define PRESSURE16_SET_CTRL_ODR_25 0x03
124#define PRESSURE16_SET_CTRL_ODR_50 0x04
125#define PRESSURE16_SET_CTRL_ODR_75 0x05
126#define PRESSURE16_SET_CTRL_ODR_100 0x06
127#define PRESSURE16_SET_CTRL_ODR_200 0x07
128
129#define PRESSURE16_SET_CTRL_LPFP_DISABLE 0x00
130#define PRESSURE16_SET_CTRL_LPFP_ENABLE 0x01
131
132#define PRESSURE16_SET_CTRL_LPFP_DISABLE 0x00
133#define PRESSURE16_SET_CTRL_LPFP_ENABLE 0x01
134
135#define PRESSURE16_SET_BDU_DATA_UPDATES_CONTINUOUS 0x00
136#define PRESSURE16_SET_BDU_DATA_NOT_UPDATES_UNTIL_READ 0x01
137
138#define PRESSURE16_SET_SIM_SPI_4_WIRE_INTERFACE 0x00
139#define PRESSURE16_SET_SIM_SPI_3_WIRE_INTERFACE 0x01
140
141#define PRESSURE16_SET_BOOT_NORMAL_OPERATION 0x00
142#define PRESSURE16_SET_BOOT_REBOOT_MEMORY_CONTENT 0x01
143
144#define PRESSURE16_SET_INT_H_L_INTERRUPT_ACTIVE_HIGH 0x00
145#define PRESSURE16_SET_INT_H_L_INTERRUPT_ACTIVE_LOW 0x01
146
147#define PRESSURE16_SET_PP_OD_PUSH_PULL 0x00
148#define PRESSURE16_SET_PP_OD_OPEN_DRAIN 0x01
149
150#define PRESSURE16_SET_IF_ADD_INC_DISABLED 0x00
151#define PRESSURE16_SET_IF_ADD_INC_ENABLED 0x01
152
153#define PRESSURE16_SET_LOW_NOISE_ENABLE_LOW_POWER_MODE 0x00
154#define PRESSURE16_SET_LOW_NOISE_ENABLE_LOW_NOISE_MODE 0x01
155
156#define PRESSURE16_SET_ONE_SHOT_NORMAL_OPERATION 0x00
157#define PRESSURE16_SET_ONE_SHOT_NEW_DATA_SET_IS_ACQUIRED 0x01
158
159#define PRESSURE16_SET_INT_F_FULL_DISABLED 0x00
160#define PRESSURE16_SET_INT_F_FULL_ENABLED 0x01
161
162#define PRESSURE16_SET_INT_F_WTM_DISABLED 0x00
163#define PRESSURE16_SET_INT_F_WTM_ENABLED 0x01
164
165#define PRESSURE16_SET_INT_F_OVR_DISABLED 0x00
166#define PRESSURE16_SET_INT_F_OVR_ENABLED 0x01
167
168#define PRESSURE16_SET_DRDY_DISABLED 0x00
169#define PRESSURE16_SET_DRDY_ENABLED 0x01
170
171#define PRESSURE16_SET_INT_S_DATA_SIGNAL 0x00
172#define PRESSURE16_SET_INT_S_PRESSURE_HIGH_EVENT 0x01
173#define PRESSURE16_SET_INT_S_PRESSURE_LOW_EVENT 0x02
174#define PRESSURE16_SET_INT_S_PRESSURE_LOW_HIGH_EVENT 0x03
175
176#define PRESSURE16_SET_INT_CFG_AUTOREFP_DISABLED 0x00
177#define PRESSURE16_SET_INT_CFG_AUTOREFP_ENABLED 0x01
178
179#define PRESSURE16_SET_INT_CFG_RESET_ARP_NORMAL_MODE 0x00
180#define PRESSURE16_SET_INT_CFG_RESET_ARP_RST_AUTOREFP 0x01
181
182#define PRESSURE16_SET_INT_CFG_AUTOZERO_DISABLED 0x00
183#define PRESSURE16_SET_INT_CFG_AUTOZERO_ENABLED 0x01
184
185#define PRESSURE16_SET_INT_CFG_AUTOZERO_NORMAL_MODE 0x00
186#define PRESSURE16_SET_INT_CFG_RST_AUTOZERO 0x01
187
188#define PRESSURE16_SET_INT_CFG_DIFF_EN_DISABLED 0x00
189#define PRESSURE16_SET_INT_CFG_DIFF_EN_ENABLED 0x01
190
191#define PRESSURE16_SET_INT_CFG_LIR_INT_IS_NOT_LATCHED 0x00
192#define PRESSURE16_SET_INT_CFG_LIR_INT_IS_LATCHED 0x01
193
194#define PRESSURE16_SET_INT_CFG_PLE_INT_IS_INACTIVE 0x00
195#define PRESSURE16_SET_INT_CFG_PLE_INT_IS_ACTIVE 0x01
196
197#define PRESSURE16_SET_INT_CFG_PHE_INT_IS_INACTIVE 0x00
198#define PRESSURE16_SET_INT_CFG_PHE_INT_IS_ACTIVE 0x01
199
200#define PRESSURE16_SET_SW_RESET_BIT_MASK 0x04
201
207#define PRESSURE16_SET_DEV_ADDR_GND 0x5C
208#define PRESSURE16_SET_DEV_ADDR_VCC 0x5D
209
215#define PRESSURE16_DEVICE_ID 0xB3
216
217 // pressure16_set
218
233#define PRESSURE16_MAP_MIKROBUS( cfg, mikrobus ) \
234 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
235 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
236 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
237 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
238 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
239 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
240 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
241
242 // pressure16_map
243 // pressure16
244
255
260typedef err_t ( *pressure16_master_io_t )( struct pressure16_s*, uint8_t, uint8_t*, uint8_t );
281
286typedef struct
287{
288 pin_name_t scl;
289 pin_name_t sda;
290 pin_name_t miso;
291 pin_name_t mosi;
292 pin_name_t sck;
293 pin_name_t cs;
294 pin_name_t int_pin;
296 uint32_t i2c_speed;
297 uint8_t i2c_address;
299 uint32_t spi_speed;
300 spi_master_mode_t spi_mode;
301 spi_master_chip_select_polarity_t cs_polarity;
306
311typedef struct
312{
313
314 uint8_t auto_refp;
315 uint8_t reset_arp;
316 uint8_t auto_zero;
317 uint8_t reset_az;
318 uint8_t diff_en;
319 uint8_t lir;
320 uint8_t ple;
321 uint8_t phe;
322
324
329typedef struct
330{
331
332 uint8_t odr;
333 uint8_t en_lpfp;
334 uint8_t lpfp_cfg;
335 uint8_t bdu;
336 uint8_t sim;
337 uint8_t boot;
338 uint8_t int_h_l;
339 uint8_t pp_od;
340 uint8_t if_add_inc;
342 uint8_t one_shot;
343 uint8_t int_f_full;
344 uint8_t int_f_wtm;
345 uint8_t int_f_ovr;
346 uint8_t drdy;
347 uint8_t int_s;
348
350
361
378
394
410
425
441err_t pressure16_generic_write ( pressure16_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len );
442
458err_t pressure16_generic_read ( pressure16_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len );
459
474err_t pressure16_get_device_id ( pressure16_t *ctx, uint8_t *dev_id );
475
490
506
522
538
554
569err_t pressure16_get_pressure ( pressure16_t *ctx, float *pressure );
570
585err_t pressure16_get_temperature ( pressure16_t *ctx, float *temperature );
586
602err_t pressure16_get_press_temp ( pressure16_t *ctx, float *pressure, float *temperature );
603
617
618#ifdef __cplusplus
619}
620#endif
621#endif // PRESSURE16_H
622
623 // pressure16
624
625// ------------------------------------------------------------------------ END
err_t pressure16_get_press_temp(pressure16_t *ctx, float *pressure, float *temperature)
Pressure 16 get pressure and temperature function.
void pressure16_drv_interface_selection(pressure16_cfg_t *cfg, pressure16_drv_t drv_sel)
Pressure 16 driver interface setup function.
err_t pressure16_generic_read(pressure16_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Pressure 16 data reading function.
err_t pressure16_default_cfg(pressure16_t *ctx)
Pressure 16 default configuration function.
err_t pressure16_get_ctrl_config(pressure16_t *ctx, pressure16_ctrl_cfg_t *ctrl_cfg_data)
Pressure 16 get control configuration function.
uint8_t pressure16_get_interrupt(pressure16_t *ctx)
Pressure 16 get interrupt function.
err_t pressure16_set_ctrl_config(pressure16_t *ctx, pressure16_ctrl_cfg_t ctrl_cfg_data)
Pressure 16 set control configuration function.
err_t pressure16_get_temperature(pressure16_t *ctx, float *temperature)
Pressure 16 get temperature function.
err_t pressure16_get_interrupt_config(pressure16_t *ctx, pressure16_int_cfg_t *int_cfg_data)
Pressure 16 get interrupt configuration function.
err_t pressure16_get_pressure(pressure16_t *ctx, float *pressure)
Pressure 16 get pressure function.
err_t pressure16_set_interrupt_config(pressure16_t *ctx, pressure16_int_cfg_t int_cfg_data)
Pressure 16 set interrupt configuration function.
err_t pressure16_generic_write(pressure16_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Pressure 16 data writing function.
err_t pressure16_init(pressure16_t *ctx, pressure16_cfg_t *cfg)
Pressure 16 initialization function.
err_t pressure16_get_device_id(pressure16_t *ctx, uint8_t *dev_id)
Pressure 16 get device ID function.
err_t pressure16_sw_reset(pressure16_t *ctx)
Pressure 16 software reset function.
void pressure16_cfg_setup(pressure16_cfg_t *cfg)
Pressure 16 configuration object setup function.
pressure16_return_value_t
Pressure 16 Click return value data.
Definition pressure16.h:356
@ PRESSURE16_OK
Definition pressure16.h:357
@ PRESSURE16_ERROR
Definition pressure16.h:358
err_t(* pressure16_master_io_t)(struct pressure16_s *, uint8_t, uint8_t *, uint8_t)
Pressure 16 Click driver interface.
Definition pressure16.h:260
struct pressure16_s pressure16_t
Pressure 16 Click context object.
pressure16_drv_t
Pressure 16 Click driver selector.
Definition pressure16.h:250
@ PRESSURE16_DRV_SEL_I2C
Definition pressure16.h:252
@ PRESSURE16_DRV_SEL_SPI
Definition pressure16.h:251
Pressure 16 Click configuration object.
Definition pressure16.h:287
uint32_t i2c_speed
Definition pressure16.h:296
spi_master_chip_select_polarity_t cs_polarity
Definition pressure16.h:301
pressure16_drv_t drv_sel
Definition pressure16.h:303
pin_name_t sck
Definition pressure16.h:292
spi_master_mode_t spi_mode
Definition pressure16.h:300
pin_name_t mosi
Definition pressure16.h:291
uint32_t spi_speed
Definition pressure16.h:299
pin_name_t scl
Definition pressure16.h:288
pin_name_t int_pin
Definition pressure16.h:294
pin_name_t miso
Definition pressure16.h:290
pin_name_t sda
Definition pressure16.h:289
pin_name_t cs
Definition pressure16.h:293
uint8_t i2c_address
Definition pressure16.h:297
Pressure 16 Click Control configuration object.
Definition pressure16.h:330
uint8_t one_shot
Definition pressure16.h:342
uint8_t bdu
Definition pressure16.h:335
uint8_t pp_od
Definition pressure16.h:339
uint8_t int_h_l
Definition pressure16.h:338
uint8_t sim
Definition pressure16.h:336
uint8_t int_s
Definition pressure16.h:347
uint8_t int_f_ovr
Definition pressure16.h:345
uint8_t if_add_inc
Definition pressure16.h:340
uint8_t drdy
Definition pressure16.h:346
uint8_t lpfp_cfg
Definition pressure16.h:334
uint8_t low_noise_en
Definition pressure16.h:341
uint8_t en_lpfp
Definition pressure16.h:333
uint8_t int_f_full
Definition pressure16.h:343
uint8_t boot
Definition pressure16.h:337
uint8_t odr
Definition pressure16.h:332
uint8_t int_f_wtm
Definition pressure16.h:344
Pressure 16 Click Interrupt configuration object.
Definition pressure16.h:312
uint8_t auto_zero
Definition pressure16.h:316
uint8_t phe
Definition pressure16.h:321
uint8_t lir
Definition pressure16.h:319
uint8_t diff_en
Definition pressure16.h:318
uint8_t auto_refp
Definition pressure16.h:314
uint8_t ple
Definition pressure16.h:320
uint8_t reset_az
Definition pressure16.h:317
uint8_t reset_arp
Definition pressure16.h:315
Pressure 16 Click context object.
Definition pressure16.h:267
pressure16_master_io_t read_f
Definition pressure16.h:278
spi_master_t spi
Definition pressure16.h:271
pressure16_master_io_t write_f
Definition pressure16.h:277
pressure16_drv_t drv_sel
Definition pressure16.h:275
digital_in_t int_pin
Definition pressure16.h:268
i2c_master_t i2c
Definition pressure16.h:270
uint8_t slave_address
Definition pressure16.h:273
pin_name_t chip_select
Definition pressure16.h:274