pressure14 2.0.0.0
pressure14.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 PRESSURE14_H
29#define PRESSURE14_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 PRESSURE14_STATUS_PWR_IND 0x40
74#define PRESSURE14_STATUS_BUSY_FLAG 0x20
75#define PRESSURE14_STATUS_ERR_FLAG 0x04
76#define PRESSURE14_STATUS_MATH_SAT 0x01
77
78 // pressure14_stat_reg
79
89#define PRESSURE14_CONV_UNIT_PSI 0x00
90#define PRESSURE14_CONV_UNIT_PASCAL 0x01
91#define PRESSURE14_CONV_UNIT_KILOPASCAL 0x02
92#define PRESSURE14_CONV_UNIT_MMHG 0x03
93#define PRESSURE14_CONV_UNIT_INHG 0x04
94#define PRESSURE14_CONV_UNIT_ATMOSPHERIC 0x05
95#define PRESSURE14_CONV_UNIT_MILIBAR 0x06
96#define PRESSURE14_CONV_UNIT_BAR 0x07
97
98 // pressure14_pressure_conversion_units
99
108#define PRESSURE14_CONV_UNIT_CELSIUS 0x00
109#define PRESSURE14_CONV_UNIT_KELVIN 0x01
110#define PRESSURE14_CONV_UNIT_FAHRENHEIT 0x02
111
112 // pressure14_temperature_conversion_units
113
123#define PRESSURE14_CONST_PSI 1.00000
124#define PRESSURE14_CONST_PASCAL 6894.76
125#define PRESSURE14_CONST_KILOPASCAL 6.89476
126#define PRESSURE14_CONST_MMHG 51.7149
127#define PRESSURE14_CONST_INHG 2.03602
128#define PRESSURE14_CONST_ATMOSPHERIC 0.06805
129#define PRESSURE14_CONST_MILIBAR 68.9500
130#define PRESSURE14_CONST_BAR 0.06895
131
132 // pressure14_pressure_conversion_constants
133
142#define PRESSURE14_CONST_ADDI_CELS 0.00000
143#define PRESSURE14_CONST_MULT_CELS 1.00000
144#define PRESSURE14_CONST_ADDI_KELV 273.150
145#define PRESSURE14_CONST_MULT_KELV 1.00000
146#define PRESSURE14_CONST_ADDI_FAHR 32.0000
147#define PRESSURE14_CONST_MULT_FAHR 1.80000
148
149 // pressure14_temperature_conversion_constants
150
159#define PRESSURE14_CONST_PRESS_OUT_MIN 1677722.00
160#define PRESSURE14_CONST_PRESS_OUT_MAX 13421772.0
161#define PRESSURE14_CONST_PRESS_VAL_MIN 0.00000000
162#define PRESSURE14_CONST_PRESS_VAL_MAX 60.0000000
163#define PRESSURE14_CONST_TEMP_MIN -50.000000
164#define PRESSURE14_CONST_TEMP_MAX 150.000000
165#define PRESSURE14_CONST_TEMP_OUT_MAX 16777215.0
166
167#define PRESSURE14_CMD_OUT_MEAS 0xAA
168#define PRESSURE14_CMD_DUMMY 0x00
169
170 // pressure14_general_sensor_constants
171
186//
187
193#define PRESSURE14_SET_DEV_ADDR 0x28
194
195 // pressure14_set
196
211#define PRESSURE14_MAP_MIKROBUS( cfg, mikrobus ) \
212 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
213 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
214 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
215
216 // pressure14_map
217 // pressure14
218
223typedef struct
224{
225 // Input pins
226 digital_in_t int_pin;
228 // Modules
229 i2c_master_t i2c;
231 // I2C slave address
235
240typedef struct
241{
242 pin_name_t scl;
243 pin_name_t sda;
245 pin_name_t int_pin;
247 uint32_t i2c_speed;
248 uint8_t i2c_address;
251
262
279
295
311err_t pressure14_generic_write ( pressure14_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len );
312
328err_t pressure14_generic_read ( pressure14_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len );
329
342
355
370void pressure14_read_press_and_temp ( pressure14_t *ctx, uint8_t *status_byte, uint32_t *pressure_data, uint32_t *temp_data );
371
383float pressure14_get_pressure ( uint32_t pressure_raw, uint8_t conv_unit );
384
385
398float pressure14_get_temperature ( uint32_t temperature_raw, uint8_t conv_unit );
399#ifdef __cplusplus
400}
401#endif
402#endif // PRESSURE14_H
403
404 // pressure14
405
406// ------------------------------------------------------------------------ END
uint8_t pressure14_check_busy_flag_int(pressure14_t *ctx)
Pressure 14 checks INT pin state function.
err_t pressure14_generic_write(pressure14_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
Pressure 14 I2C writing function.
err_t pressure14_generic_read(pressure14_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
Pressure 14 I2C reading function.
float pressure14_get_temperature(uint32_t temperature_raw, uint8_t conv_unit)
Pressure 14 calculate temperature function.
void pressure14_read_press_and_temp(pressure14_t *ctx, uint8_t *status_byte, uint32_t *pressure_data, uint32_t *temp_data)
Pressure 14 read pressure and temperature function.
float pressure14_get_pressure(uint32_t pressure_raw, uint8_t conv_unit)
Pressure 14 calculate pressure function.
err_t pressure14_init(pressure14_t *ctx, pressure14_cfg_t *cfg)
Pressure 14 initialization function.
void pressure14_cfg_setup(pressure14_cfg_t *cfg)
Pressure 14 configuration object setup function.
void pressure14_measure_cmd(pressure14_t *ctx)
Pressure 14 output Measurement Command function.
pressure14_return_value_t
Pressure 14 Click return value data.
Definition pressure14.h:257
@ PRESSURE14_ERROR
Definition pressure14.h:259
@ PRESSURE14_OK
Definition pressure14.h:258
Pressure 14 Click configuration object.
Definition pressure14.h:241
uint32_t i2c_speed
Definition pressure14.h:247
pin_name_t scl
Definition pressure14.h:242
pin_name_t int_pin
Definition pressure14.h:245
pin_name_t sda
Definition pressure14.h:243
uint8_t i2c_address
Definition pressure14.h:248
Pressure 14 Click context object.
Definition pressure14.h:224
digital_in_t int_pin
Definition pressure14.h:226
i2c_master_t i2c
Definition pressure14.h:229
uint8_t slave_address
Definition pressure14.h:232