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
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 PRESSURE14_STATUS_PWR_IND 0x40
60 #define PRESSURE14_STATUS_BUSY_FLAG 0x20
61 #define PRESSURE14_STATUS_ERR_FLAG 0x04
62 #define PRESSURE14_STATUS_MATH_SAT 0x01
63  // pressure14_stat_reg
65 
75 #define PRESSURE14_CONV_UNIT_PSI 0x00
76 #define PRESSURE14_CONV_UNIT_PASCAL 0x01
77 #define PRESSURE14_CONV_UNIT_KILOPASCAL 0x02
78 #define PRESSURE14_CONV_UNIT_MMHG 0x03
79 #define PRESSURE14_CONV_UNIT_INHG 0x04
80 #define PRESSURE14_CONV_UNIT_ATMOSPHERIC 0x05
81 #define PRESSURE14_CONV_UNIT_MILIBAR 0x06
82 #define PRESSURE14_CONV_UNIT_BAR 0x07
83  // pressure14_pressure_conversion_units
85 
94 #define PRESSURE14_CONV_UNIT_CELSIUS 0x00
95 #define PRESSURE14_CONV_UNIT_KELVIN 0x01
96 #define PRESSURE14_CONV_UNIT_FAHRENHEIT 0x02
97  // pressure14_temperature_conversion_units
99 
109 #define PRESSURE14_CONST_PSI 1.00000
110 #define PRESSURE14_CONST_PASCAL 6894.76
111 #define PRESSURE14_CONST_KILOPASCAL 6.89476
112 #define PRESSURE14_CONST_MMHG 51.7149
113 #define PRESSURE14_CONST_INHG 2.03602
114 #define PRESSURE14_CONST_ATMOSPHERIC 0.06805
115 #define PRESSURE14_CONST_MILIBAR 68.9500
116 #define PRESSURE14_CONST_BAR 0.06895
117  // pressure14_pressure_conversion_constants
119 
128 #define PRESSURE14_CONST_ADDI_CELS 0.00000
129 #define PRESSURE14_CONST_MULT_CELS 1.00000
130 #define PRESSURE14_CONST_ADDI_KELV 273.150
131 #define PRESSURE14_CONST_MULT_KELV 1.00000
132 #define PRESSURE14_CONST_ADDI_FAHR 32.0000
133 #define PRESSURE14_CONST_MULT_FAHR 1.80000
134  // pressure14_temperature_conversion_constants
136 
145 #define PRESSURE14_CONST_PRESS_OUT_MIN 1677722.00
146 #define PRESSURE14_CONST_PRESS_OUT_MAX 13421772.0
147 #define PRESSURE14_CONST_PRESS_VAL_MIN 0.00000000
148 #define PRESSURE14_CONST_PRESS_VAL_MAX 60.0000000
149 #define PRESSURE14_CONST_TEMP_MIN -50.000000
150 #define PRESSURE14_CONST_TEMP_MAX 150.000000
151 #define PRESSURE14_CONST_TEMP_OUT_MAX 16777215.0
152 
153 #define PRESSURE14_CMD_OUT_MEAS 0xAA
154 #define PRESSURE14_CMD_DUMMY 0x00
155  // pressure14_general_sensor_constants
157 
172 //
173 
179 #define PRESSURE14_SET_DEV_ADDR 0x28
180  // pressure14_set
182 
197 #define PRESSURE14_MAP_MIKROBUS( cfg, mikrobus ) \
198  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
199  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
200  cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
201  // pressure14_map // pressure14
204 
209 typedef struct
210 {
211  // Input pins
212  digital_in_t int_pin;
214  // Modules
215  i2c_master_t i2c;
217  // I2C slave address
218  uint8_t slave_address;
220 } pressure14_t;
221 
226 typedef struct
227 {
228  pin_name_t scl;
229  pin_name_t sda;
231  pin_name_t int_pin;
233  uint32_t i2c_speed;
234  uint8_t i2c_address;
237 
242 typedef enum
243 {
245  PRESSURE14_ERROR = -1
246 
248 
265 
280 err_t pressure14_init ( pressure14_t *ctx, pressure14_cfg_t *cfg );
281 
297 err_t pressure14_generic_write ( pressure14_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len );
298 
314 err_t pressure14_generic_read ( pressure14_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len );
315 
328 
341 
356 void pressure14_read_press_and_temp ( pressure14_t *ctx, uint8_t *status_byte, uint32_t *pressure_data, uint32_t *temp_data );
357 
369 float pressure14_get_pressure ( uint32_t pressure_raw, uint8_t conv_unit );
370 
371 
384 float pressure14_get_temperature ( uint32_t temperature_raw, uint8_t conv_unit );
385 #ifdef __cplusplus
386 }
387 #endif
388 #endif // PRESSURE14_H
389  // pressure14
391 
392 // ------------------------------------------------------------------------ END
pressure14_check_busy_flag_int
uint8_t pressure14_check_busy_flag_int(pressure14_t *ctx)
Pressure 14 checks INT pin state function.
pressure14_get_pressure
float pressure14_get_pressure(uint32_t pressure_raw, uint8_t conv_unit)
Pressure 14 calculate pressure function.
pressure14_generic_read
err_t pressure14_generic_read(pressure14_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
Pressure 14 I2C reading function.
PRESSURE14_ERROR
Definition: pressure14.h:244
pressure14_cfg_t
Pressure 14 Click configuration object.
Definition: pressure14.h:225
pressure14_return_value_t
pressure14_return_value_t
Pressure 14 Click return value data.
Definition: pressure14.h:241
PRESSURE14_OK
Definition: pressure14.h:243
pressure14_init
err_t pressure14_init(pressure14_t *ctx, pressure14_cfg_t *cfg)
Pressure 14 initialization function.
pressure14_get_temperature
float pressure14_get_temperature(uint32_t temperature_raw, uint8_t conv_unit)
Pressure 14 calculate temperature function.
pressure14_measure_cmd
void pressure14_measure_cmd(pressure14_t *ctx)
Pressure 14 output Measurement Command function.
pressure14_cfg_setup
void pressure14_cfg_setup(pressure14_cfg_t *cfg)
Pressure 14 configuration object setup function.
pressure14_t
Pressure 14 Click context object.
Definition: pressure14.h:208
pressure14_generic_write
err_t pressure14_generic_write(pressure14_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
Pressure 14 I2C writing function.
pressure14_read_press_and_temp
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.