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 "mikrosdk_version.h"
36 
37 #ifdef __GNUC__
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
40 #else
41 #include "delays.h"
42 #endif
43 #endif
44 
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_i2c_master.h"
48 
69 #define PRESSURE17_REG_MANUFACTURER_ID 0x0F
70 #define PRESSURE17_REG_PART_ID 0x10
71 #define PRESSURE17_REG_POWER_DOWN 0x12
72 #define PRESSURE17_REG_RESET 0x13
73 #define PRESSURE17_REG_MODE_CONTROL 0x14
74 #define PRESSURE17_REG_IIR_FIFO_CONTROL 0x15
75 #define PRESSURE17_REG_FIFO_DATA 0x18
76 #define PRESSURE17_REG_STATUS 0x19
77 #define PRESSURE17_REG_PRESS_OUT_MSB 0x1A
78 #define PRESSURE17_REG_PRESS_OUT_LSB 0x1B
79 #define PRESSURE17_REG_PRESS_OUT_XL 0x1C
80 #define PRESSURE17_REG_TEMP_OUT_MSB 0x1D
81 #define PRESSURE17_REG_TEMP_OUT_LSB 0x1E
82  // pressure17_reg
84 
99 #define PRESSURE17_MANUFACTURER_ID 0xE0
100 #define PRESSURE17_PART_ID 0x34
101 
106 #define PRESSURE17_POWER_DOWN 0x00
107 #define PRESSURE17_POWER_ACTIVE 0x01
108 
113 #define PRESSURE17_RSTB_RESET 0x00
114 #define PRESSURE17_RSTB_ACTIVE 0x01
115 
120 #define PRESSURE17_MODE_AVE_NUM_8_TIMES 0x60
121 #define PRESSURE17_MODE_AVE_NUM_16_TIMES 0x80
122 #define PRESSURE17_MODE_AVE_NUM_32_TIMES 0xA0
123 #define PRESSURE17_MODE_AVE_NUM_64_TIMES 0xC0
124 #define PRESSURE17_MODE_DR_EN 0x10
125 #define PRESSURE17_MODE_FULL_EN 0x08
126 #define PRESSURE17_MODE_WTM_EN 0x04
127 #define PRESSURE17_MODE_STANDBY_MODE 0x00
128 #define PRESSURE17_MODE_ONE_SHOT_MODE 0x01
129 #define PRESSURE17_MODE_CONTINUOUS_MODE 0x02
130 
135 #define PRESSURE17_FIFO_EN 0x80
136 #define PRESSURE17_WTM_LEVEL_2 0x00
137 #define PRESSURE17_WTM_LEVEL_3 0x40
138 #define PRESSURE17_IIR_OFF 0x00
139 #define PRESSURE17_IIR_ON_WEAK 0x01
140 #define PRESSURE17_IIR_ON_MIDDLE 0x02
141 #define PRESSURE17_IIR_ON_STRONG 0x03
142 
147 #define PRESSURE17_FIFO_LVL_FIFO_EMPTY 0x00
148 #define PRESSURE17_FIFO_LVL_FIFO_NUM_1 0x01
149 #define PRESSURE17_FIFO_LVL_FIFO_NUM_2 0x02
150 #define PRESSURE17_FIFO_LVL_FIFO_NUM_3 0x03
151 #define PRESSURE17_FIFO_LVL_FIFO_FULL 0x04
152 
157 #define PRESSURE17_STATUS_RD_FULL 0x04
158 #define PRESSURE17_STATUS_RD_WTM 0x02
159 #define PRESSURE17_STATUS_RD_DRDY 0x01
160 
165 #define PRESSURE17_PRESS_COUNTS_PER_MBAR 2048
166 #define PRESSURE17_TEMP_COUNTS_PER_C 32
167 
173 #define PRESSURE17_SET_DEV_ADDR 0x5D
174  // pressure17_set
176 
191 #define PRESSURE17_MAP_MIKROBUS( cfg, mikrobus ) \
192  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
193  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
194  cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
195  // pressure17_map // pressure17
198 
203 typedef struct
204 {
205  // Input pins
206  digital_in_t int_pin;
208  // Modules
209  i2c_master_t i2c;
211  // I2C slave address
212  uint8_t slave_address;
214 } pressure17_t;
215 
220 typedef struct
221 {
222  pin_name_t scl;
223  pin_name_t sda;
225  pin_name_t int_pin;
227  uint32_t i2c_speed;
228  uint8_t i2c_address;
231 
236 typedef enum
237 {
239  PRESSURE17_ERROR = -1
240 
242 
259 
275 
290 
306 err_t pressure17_generic_write ( pressure17_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len );
307 
323 err_t pressure17_generic_read ( pressure17_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len );
324 
338 err_t pressure17_write_register ( pressure17_t *ctx, uint8_t reg, uint8_t data_in );
339 
353 err_t pressure17_read_register ( pressure17_t *ctx, uint8_t reg, uint8_t *data_out );
354 
367 
382 err_t pressure17_read_data ( pressure17_t *ctx, float *pressure, float *temperature );
383 
393 
394 #ifdef __cplusplus
395 }
396 #endif
397 #endif // PRESSURE17_H
398  // pressure17
400 
401 // ------------------------------------------------------------------------ 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:212
PRESSURE17_OK
@ PRESSURE17_OK
Definition: pressure17.h:238
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:222
pressure17_cfg_t
Pressure 17 Click configuration object.
Definition: pressure17.h:221
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:225
pressure17_t::i2c
i2c_master_t i2c
Definition: pressure17.h:209
pressure17_cfg_t::sda
pin_name_t sda
Definition: pressure17.h:223
pressure17_return_value_t
pressure17_return_value_t
Pressure 17 Click return value data.
Definition: pressure17.h:237
pressure17_t
Pressure 17 Click context object.
Definition: pressure17.h:204
pressure17_cfg_t::i2c_address
uint8_t i2c_address
Definition: pressure17.h:228
PRESSURE17_ERROR
@ PRESSURE17_ERROR
Definition: pressure17.h:239
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:227
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:206