pressure17 2.0.0.0
pressure17.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 PRESSURE17_H
29#define PRESSURE17_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
73#define PRESSURE17_REG_MANUFACTURER_ID 0x0F
74#define PRESSURE17_REG_PART_ID 0x10
75#define PRESSURE17_REG_POWER_DOWN 0x12
76#define PRESSURE17_REG_RESET 0x13
77#define PRESSURE17_REG_MODE_CONTROL 0x14
78#define PRESSURE17_REG_IIR_FIFO_CONTROL 0x15
79#define PRESSURE17_REG_FIFO_DATA 0x18
80#define PRESSURE17_REG_STATUS 0x19
81#define PRESSURE17_REG_PRESS_OUT_MSB 0x1A
82#define PRESSURE17_REG_PRESS_OUT_LSB 0x1B
83#define PRESSURE17_REG_PRESS_OUT_XL 0x1C
84#define PRESSURE17_REG_TEMP_OUT_MSB 0x1D
85#define PRESSURE17_REG_TEMP_OUT_LSB 0x1E
86
87 // pressure17_reg
88
103#define PRESSURE17_MANUFACTURER_ID 0xE0
104#define PRESSURE17_PART_ID 0x34
105
110#define PRESSURE17_POWER_DOWN 0x00
111#define PRESSURE17_POWER_ACTIVE 0x01
112
117#define PRESSURE17_RSTB_RESET 0x00
118#define PRESSURE17_RSTB_ACTIVE 0x01
119
124#define PRESSURE17_MODE_AVE_NUM_8_TIMES 0x60
125#define PRESSURE17_MODE_AVE_NUM_16_TIMES 0x80
126#define PRESSURE17_MODE_AVE_NUM_32_TIMES 0xA0
127#define PRESSURE17_MODE_AVE_NUM_64_TIMES 0xC0
128#define PRESSURE17_MODE_DR_EN 0x10
129#define PRESSURE17_MODE_FULL_EN 0x08
130#define PRESSURE17_MODE_WTM_EN 0x04
131#define PRESSURE17_MODE_STANDBY_MODE 0x00
132#define PRESSURE17_MODE_ONE_SHOT_MODE 0x01
133#define PRESSURE17_MODE_CONTINUOUS_MODE 0x02
134
139#define PRESSURE17_FIFO_EN 0x80
140#define PRESSURE17_WTM_LEVEL_2 0x00
141#define PRESSURE17_WTM_LEVEL_3 0x40
142#define PRESSURE17_IIR_OFF 0x00
143#define PRESSURE17_IIR_ON_WEAK 0x01
144#define PRESSURE17_IIR_ON_MIDDLE 0x02
145#define PRESSURE17_IIR_ON_STRONG 0x03
146
151#define PRESSURE17_FIFO_LVL_FIFO_EMPTY 0x00
152#define PRESSURE17_FIFO_LVL_FIFO_NUM_1 0x01
153#define PRESSURE17_FIFO_LVL_FIFO_NUM_2 0x02
154#define PRESSURE17_FIFO_LVL_FIFO_NUM_3 0x03
155#define PRESSURE17_FIFO_LVL_FIFO_FULL 0x04
156
161#define PRESSURE17_STATUS_RD_FULL 0x04
162#define PRESSURE17_STATUS_RD_WTM 0x02
163#define PRESSURE17_STATUS_RD_DRDY 0x01
164
169#define PRESSURE17_PRESS_COUNTS_PER_MBAR 2048
170#define PRESSURE17_TEMP_COUNTS_PER_C 32
171
177#define PRESSURE17_SET_DEV_ADDR 0x5D
178
179 // pressure17_set
180
195#define PRESSURE17_MAP_MIKROBUS( cfg, mikrobus ) \
196 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
197 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
198 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
199
200 // pressure17_map
201 // pressure17
202
207typedef struct
208{
209 // Input pins
210 digital_in_t int_pin;
212 // Modules
213 i2c_master_t i2c;
215 // I2C slave address
219
224typedef struct
225{
226 pin_name_t scl;
227 pin_name_t sda;
229 pin_name_t int_pin;
231 uint32_t i2c_speed;
232 uint8_t i2c_address;
235
246
263
279
294
310err_t pressure17_generic_write ( pressure17_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len );
311
327err_t pressure17_generic_read ( pressure17_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len );
328
342err_t pressure17_write_register ( pressure17_t *ctx, uint8_t reg, uint8_t data_in );
343
357err_t pressure17_read_register ( pressure17_t *ctx, uint8_t reg, uint8_t *data_out );
358
371
386err_t pressure17_read_data ( pressure17_t *ctx, float *pressure, float *temperature );
387
397
398#ifdef __cplusplus
399}
400#endif
401#endif // PRESSURE17_H
402
403 // pressure17
404
405// ------------------------------------------------------------------------ END
err_t pressure17_generic_write(pressure17_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
Pressure 17 I2C writing function.
err_t pressure17_write_register(pressure17_t *ctx, uint8_t reg, uint8_t data_in)
Pressure 17 write register function.
err_t pressure17_generic_read(pressure17_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
Pressure 17 I2C reading function.
uint8_t pressure17_get_int_pin(pressure17_t *ctx)
Pressure 17 get int pin function.
err_t pressure17_read_data(pressure17_t *ctx, float *pressure, float *temperature)
Pressure 17 read data function.
void pressure17_cfg_setup(pressure17_cfg_t *cfg)
Pressure 17 configuration object setup function.
err_t pressure17_check_communication(pressure17_t *ctx)
Pressure 17 check communication function.
err_t pressure17_init(pressure17_t *ctx, pressure17_cfg_t *cfg)
Pressure 17 initialization function.
err_t pressure17_default_cfg(pressure17_t *ctx)
Pressure 17 default configuration function.
err_t pressure17_read_register(pressure17_t *ctx, uint8_t reg, uint8_t *data_out)
Pressure 17 read register function.
pressure17_return_value_t
Pressure 17 Click return value data.
Definition pressure17.h:241
@ PRESSURE17_ERROR
Definition pressure17.h:243
@ PRESSURE17_OK
Definition pressure17.h:242
Pressure 17 Click configuration object.
Definition pressure17.h:225
uint32_t i2c_speed
Definition pressure17.h:231
pin_name_t scl
Definition pressure17.h:226
pin_name_t int_pin
Definition pressure17.h:229
pin_name_t sda
Definition pressure17.h:227
uint8_t i2c_address
Definition pressure17.h:232
Pressure 17 Click context object.
Definition pressure17.h:208
digital_in_t int_pin
Definition pressure17.h:210
i2c_master_t i2c
Definition pressure17.h:213
uint8_t slave_address
Definition pressure17.h:216