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
32 extern "C"{
33 #endif
34 
35 #include "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_i2c_master.h"
38 
59 #define PRESSURE17_REG_MANUFACTURER_ID 0x0F
60 #define PRESSURE17_REG_PART_ID 0x10
61 #define PRESSURE17_REG_POWER_DOWN 0x12
62 #define PRESSURE17_REG_RESET 0x13
63 #define PRESSURE17_REG_MODE_CONTROL 0x14
64 #define PRESSURE17_REG_IIR_FIFO_CONTROL 0x15
65 #define PRESSURE17_REG_FIFO_DATA 0x18
66 #define PRESSURE17_REG_STATUS 0x19
67 #define PRESSURE17_REG_PRESS_OUT_MSB 0x1A
68 #define PRESSURE17_REG_PRESS_OUT_LSB 0x1B
69 #define PRESSURE17_REG_PRESS_OUT_XL 0x1C
70 #define PRESSURE17_REG_TEMP_OUT_MSB 0x1D
71 #define PRESSURE17_REG_TEMP_OUT_LSB 0x1E
72  // pressure17_reg
74 
89 #define PRESSURE17_MANUFACTURER_ID 0xE0
90 #define PRESSURE17_PART_ID 0x34
91 
96 #define PRESSURE17_POWER_DOWN 0x00
97 #define PRESSURE17_POWER_ACTIVE 0x01
98 
103 #define PRESSURE17_RSTB_RESET 0x00
104 #define PRESSURE17_RSTB_ACTIVE 0x01
105 
110 #define PRESSURE17_MODE_AVE_NUM_8_TIMES 0x60
111 #define PRESSURE17_MODE_AVE_NUM_16_TIMES 0x80
112 #define PRESSURE17_MODE_AVE_NUM_32_TIMES 0xA0
113 #define PRESSURE17_MODE_AVE_NUM_64_TIMES 0xC0
114 #define PRESSURE17_MODE_DR_EN 0x10
115 #define PRESSURE17_MODE_FULL_EN 0x08
116 #define PRESSURE17_MODE_WTM_EN 0x04
117 #define PRESSURE17_MODE_STANDBY_MODE 0x00
118 #define PRESSURE17_MODE_ONE_SHOT_MODE 0x01
119 #define PRESSURE17_MODE_CONTINUOUS_MODE 0x02
120 
125 #define PRESSURE17_FIFO_EN 0x80
126 #define PRESSURE17_WTM_LEVEL_2 0x00
127 #define PRESSURE17_WTM_LEVEL_3 0x40
128 #define PRESSURE17_IIR_OFF 0x00
129 #define PRESSURE17_IIR_ON_WEAK 0x01
130 #define PRESSURE17_IIR_ON_MIDDLE 0x02
131 #define PRESSURE17_IIR_ON_STRONG 0x03
132 
137 #define PRESSURE17_FIFO_LVL_FIFO_EMPTY 0x00
138 #define PRESSURE17_FIFO_LVL_FIFO_NUM_1 0x01
139 #define PRESSURE17_FIFO_LVL_FIFO_NUM_2 0x02
140 #define PRESSURE17_FIFO_LVL_FIFO_NUM_3 0x03
141 #define PRESSURE17_FIFO_LVL_FIFO_FULL 0x04
142 
147 #define PRESSURE17_STATUS_RD_FULL 0x04
148 #define PRESSURE17_STATUS_RD_WTM 0x02
149 #define PRESSURE17_STATUS_RD_DRDY 0x01
150 
155 #define PRESSURE17_PRESS_COUNTS_PER_MBAR 2048
156 #define PRESSURE17_TEMP_COUNTS_PER_C 32
157 
163 #define PRESSURE17_SET_DEV_ADDR 0x5D
164  // pressure17_set
166 
181 #define PRESSURE17_MAP_MIKROBUS( cfg, mikrobus ) \
182  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
183  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
184  cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
185  // pressure17_map // pressure17
188 
193 typedef struct
194 {
195  // Input pins
196  digital_in_t int_pin;
198  // Modules
199  i2c_master_t i2c;
201  // I2C slave address
202  uint8_t slave_address;
204 } pressure17_t;
205 
210 typedef struct
211 {
212  pin_name_t scl;
213  pin_name_t sda;
215  pin_name_t int_pin;
217  uint32_t i2c_speed;
218  uint8_t i2c_address;
221 
226 typedef enum
227 {
229  PRESSURE17_ERROR = -1
230 
232 
249 
265 
280 
296 err_t pressure17_generic_write ( pressure17_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len );
297 
313 err_t pressure17_generic_read ( pressure17_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len );
314 
328 err_t pressure17_write_register ( pressure17_t *ctx, uint8_t reg, uint8_t data_in );
329 
343 err_t pressure17_read_register ( pressure17_t *ctx, uint8_t reg, uint8_t *data_out );
344 
357 
372 err_t pressure17_read_data ( pressure17_t *ctx, float *pressure, float *temperature );
373 
383 
384 #ifdef __cplusplus
385 }
386 #endif
387 #endif // PRESSURE17_H
388  // pressure17
390 
391 // ------------------------------------------------------------------------ END
pressure17_read_data
err_t pressure17_read_data(pressure17_t *ctx, float *pressure, float *temperature)
Pressure 17 read data function.
pressure17_t::slave_address
uint8_t slave_address
Definition: pressure17.h:202
PRESSURE17_OK
@ PRESSURE17_OK
Definition: pressure17.h:228
pressure17_get_int_pin
uint8_t pressure17_get_int_pin(pressure17_t *ctx)
Pressure 17 get int pin function.
pressure17_cfg_t::scl
pin_name_t scl
Definition: pressure17.h:212
pressure17_cfg_t
Pressure 17 Click configuration object.
Definition: pressure17.h:211
pressure17_default_cfg
err_t pressure17_default_cfg(pressure17_t *ctx)
Pressure 17 default configuration function.
pressure17_cfg_t::int_pin
pin_name_t int_pin
Definition: pressure17.h:215
pressure17_t::i2c
i2c_master_t i2c
Definition: pressure17.h:199
pressure17_cfg_t::sda
pin_name_t sda
Definition: pressure17.h:213
pressure17_return_value_t
pressure17_return_value_t
Pressure 17 Click return value data.
Definition: pressure17.h:227
pressure17_t
Pressure 17 Click context object.
Definition: pressure17.h:194
pressure17_cfg_t::i2c_address
uint8_t i2c_address
Definition: pressure17.h:218
PRESSURE17_ERROR
@ PRESSURE17_ERROR
Definition: pressure17.h:229
pressure17_init
err_t pressure17_init(pressure17_t *ctx, pressure17_cfg_t *cfg)
Pressure 17 initialization function.
pressure17_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: pressure17.h:217
pressure17_write_register
err_t pressure17_write_register(pressure17_t *ctx, uint8_t reg, uint8_t data_in)
Pressure 17 write register function.
pressure17_generic_write
err_t pressure17_generic_write(pressure17_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
Pressure 17 I2C writing function.
pressure17_generic_read
err_t pressure17_generic_read(pressure17_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
Pressure 17 I2C reading function.
pressure17_read_register
err_t pressure17_read_register(pressure17_t *ctx, uint8_t reg, uint8_t *data_out)
Pressure 17 read register function.
pressure17_check_communication
err_t pressure17_check_communication(pressure17_t *ctx)
Pressure 17 check communication function.
pressure17_cfg_setup
void pressure17_cfg_setup(pressure17_cfg_t *cfg)
Pressure 17 configuration object setup function.
pressure17_t::int_pin
digital_in_t int_pin
Definition: pressure17.h:196