pressure19 2.0.0.0
pressure19.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 PRESSURE19_H
29#define PRESSURE19_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_analog_in.h"
52#include "drv_i2c_master.h"
53
74#define PRESSURE19_MIN_PRESSURE 0.2
75#define PRESSURE19_MAX_PRESSURE 3.0
76#define PRESSURE19_MIN_VOLTAGE 0.4
77#define PRESSURE19_MAX_VOLTAGE 4.65
78#define PRESSURE19_BAR_TO_MBAR 1000
79
84#define PRESSURE19_ADC_RESOLUTION 0x0FFF
85#define PRESSURE19_VREF_3V3 3.3
86#define PRESSURE19_VREF_5V 5.0
87
93#define PRESSURE19_SET_DEV_ADDR 0x4D
94
95 // pressure19_set
96
111#define PRESSURE19_MAP_MIKROBUS( cfg, mikrobus ) \
112 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
113 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
114 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA );
115
116 // pressure19_map
117 // pressure19
118
129
134typedef struct
135{
136 analog_in_t adc;
137 i2c_master_t i2c;
140 pin_name_t chip_select;
141 float vref;
145
150typedef struct
151{
152 pin_name_t an;
153 pin_name_t scl;
154 pin_name_t sda;
156 analog_in_resolution_t resolution;
157 float vref;
159 uint32_t i2c_speed;
160 uint8_t i2c_address;
165
176
193
209
224
236err_t pressure19_read_raw_adc ( pressure19_t *ctx, uint16_t *raw_adc );
237
249err_t pressure19_read_voltage ( pressure19_t *ctx, float *voltage );
250
262err_t pressure19_set_vref ( pressure19_t *ctx, float vref );
263
276err_t pressure19_get_pressure ( pressure19_t *ctx, uint16_t *pressure );
277
278#ifdef __cplusplus
279}
280#endif
281#endif // PRESSURE19_H
282
283 // pressure19
284
285// ------------------------------------------------------------------------ END
err_t pressure19_set_vref(pressure19_t *ctx, float vref)
Pressure 19 set vref function.
void pressure19_cfg_setup(pressure19_cfg_t *cfg)
Pressure 19 configuration object setup function.
err_t pressure19_read_voltage(pressure19_t *ctx, float *voltage)
Pressure 19 read voltage level function.
err_t pressure19_init(pressure19_t *ctx, pressure19_cfg_t *cfg)
Pressure 19 initialization function.
void pressure19_drv_interface_selection(pressure19_cfg_t *cfg, pressure19_drv_t drv_sel)
Pressure 19 driver interface setup function.
err_t pressure19_get_pressure(pressure19_t *ctx, uint16_t *pressure)
Pressure 19 get pressure function.
err_t pressure19_read_raw_adc(pressure19_t *ctx, uint16_t *raw_adc)
Pressure 19 read raw ADC value function.
pressure19_return_value_t
Pressure 19 Click return value data.
Definition pressure19.h:171
@ PRESSURE19_ERROR
Definition pressure19.h:173
@ PRESSURE19_OK
Definition pressure19.h:172
pressure19_drv_t
Pressure 19 Click driver selector.
Definition pressure19.h:124
@ PRESSURE19_DRV_SEL_ADC
Definition pressure19.h:125
@ PRESSURE19_DRV_SEL_I2C
Definition pressure19.h:126
Pressure 19 Click configuration object.
Definition pressure19.h:151
analog_in_resolution_t resolution
Definition pressure19.h:156
float vref
Definition pressure19.h:157
uint32_t i2c_speed
Definition pressure19.h:159
pressure19_drv_t drv_sel
Definition pressure19.h:162
pin_name_t scl
Definition pressure19.h:153
pin_name_t sda
Definition pressure19.h:154
pin_name_t an
Definition pressure19.h:152
uint8_t i2c_address
Definition pressure19.h:160
Pressure 19 Click context object.
Definition pressure19.h:135
float vref
Definition pressure19.h:141
i2c_master_t i2c
Definition pressure19.h:137
pressure19_drv_t drv_sel
Definition pressure19.h:142
uint8_t slave_address
Definition pressure19.h:139
pin_name_t chip_select
Definition pressure19.h:140
analog_in_t adc
Definition pressure19.h:136