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
32 extern "C"{
33 #endif
34 
35 #include "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_analog_in.h"
38 #include "drv_i2c_master.h"
39 
60 // TODO -- dodati makroe koji definisu adrese registara
61  // pressure19_reg
63 
78 #define PRESSURE19_MIN_PRESSURE 0.2
79 #define PRESSURE19_MAX_PRESSURE 3.0
80 #define PRESSURE19_MIN_VOLTAGE 0.4
81 #define PRESSURE19_MAX_VOLTAGE 4.65
82 #define PRESSURE19_BAR_TO_MBAR 1000
83 
88 #define PRESSURE19_ADC_RESOLUTION 0x0FFF
89 #define PRESSURE19_VREF_3V3 3.3
90 #define PRESSURE19_VREF_5V 5.0
91 
97 #define PRESSURE19_SET_DEV_ADDR 0x4D
98  // pressure19_set
100 
115 #define PRESSURE19_MAP_MIKROBUS( cfg, mikrobus ) \
116  cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
117  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
118  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA );
119  // pressure19_map // pressure19
122 
127 typedef enum
128 {
133 
138 typedef struct
139 {
140  analog_in_t adc;
141  i2c_master_t i2c;
143  uint8_t slave_address;
144  pin_name_t chip_select;
145  float vref;
148 } pressure19_t;
149 
154 typedef struct
155 {
156  pin_name_t an;
157  pin_name_t scl;
158  pin_name_t sda;
160  analog_in_resolution_t resolution;
161  float vref;
163  uint32_t i2c_speed;
164  uint8_t i2c_address;
169 
174 typedef enum
175 {
177  PRESSURE19_ERROR = -1
178 
180 
197 
213 
228 
240 err_t pressure19_read_raw_adc ( pressure19_t *ctx, uint16_t *raw_adc );
241 
253 err_t pressure19_read_voltage ( pressure19_t *ctx, float *voltage );
254 
266 err_t pressure19_set_vref ( pressure19_t *ctx, float vref );
267 
280 err_t pressure19_get_pressure ( pressure19_t *ctx, uint16_t *pressure );
281 
282 #ifdef __cplusplus
283 }
284 #endif
285 #endif // PRESSURE19_H
286  // pressure19
288 
289 // ------------------------------------------------------------------------ END
pressure19_t::vref
float vref
Definition: pressure19.h:145
pressure19_drv_t
pressure19_drv_t
Pressure 19 Click driver selector.
Definition: pressure19.h:128
PRESSURE19_DRV_SEL_ADC
@ PRESSURE19_DRV_SEL_ADC
Definition: pressure19.h:129
pressure19_cfg_t
Pressure 19 Click configuration object.
Definition: pressure19.h:155
pressure19_get_pressure
err_t pressure19_get_pressure(pressure19_t *ctx, uint16_t *pressure)
Pressure 19 get pressure function.
pressure19_cfg_t::an
pin_name_t an
Definition: pressure19.h:156
pressure19_cfg_t::i2c_address
uint8_t i2c_address
Definition: pressure19.h:164
pressure19_t::drv_sel
pressure19_drv_t drv_sel
Definition: pressure19.h:146
pressure19_cfg_t::resolution
analog_in_resolution_t resolution
Definition: pressure19.h:160
pressure19_init
err_t pressure19_init(pressure19_t *ctx, pressure19_cfg_t *cfg)
Pressure 19 initialization function.
PRESSURE19_ERROR
@ PRESSURE19_ERROR
Definition: pressure19.h:177
pressure19_t
Pressure 19 Click context object.
Definition: pressure19.h:139
pressure19_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: pressure19.h:163
pressure19_t::adc
analog_in_t adc
Definition: pressure19.h:140
pressure19_cfg_t::vref
float vref
Definition: pressure19.h:161
pressure19_drv_interface_selection
void pressure19_drv_interface_selection(pressure19_cfg_t *cfg, pressure19_drv_t drv_sel)
Pressure 19 driver interface setup function.
pressure19_cfg_t::drv_sel
pressure19_drv_t drv_sel
Definition: pressure19.h:166
PRESSURE19_OK
@ PRESSURE19_OK
Definition: pressure19.h:176
pressure19_t::i2c
i2c_master_t i2c
Definition: pressure19.h:141
pressure19_cfg_setup
void pressure19_cfg_setup(pressure19_cfg_t *cfg)
Pressure 19 configuration object setup function.
pressure19_read_voltage
err_t pressure19_read_voltage(pressure19_t *ctx, float *voltage)
Pressure 19 read voltage level function.
pressure19_read_raw_adc
err_t pressure19_read_raw_adc(pressure19_t *ctx, uint16_t *raw_adc)
Pressure 19 read raw ADC value function.
PRESSURE19_DRV_SEL_I2C
@ PRESSURE19_DRV_SEL_I2C
Definition: pressure19.h:130
pressure19_t::slave_address
uint8_t slave_address
Definition: pressure19.h:143
pressure19_cfg_t::scl
pin_name_t scl
Definition: pressure19.h:157
pressure19_set_vref
err_t pressure19_set_vref(pressure19_t *ctx, float vref)
Pressure 19 set vref function.
pressure19_t::chip_select
pin_name_t chip_select
Definition: pressure19.h:144
pressure19_cfg_t::sda
pin_name_t sda
Definition: pressure19.h:158
pressure19_return_value_t
pressure19_return_value_t
Pressure 19 Click return value data.
Definition: pressure19.h:175