diffpress3 2.1.0.0
diffpress3.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 DIFFPRESS3_H
29#define DIFFPRESS3_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 DIFFPRESS3_PMIN -100.0f // Measurement range minimum
75#define DIFFPRESS3_PMAX 1000.0f // Measurement range maximum
76#define DIFFPRESS3_ACCP_ABS_MIN -0.3f // Absolute accuracy minimum
77#define DIFFPRESS3_ACCP_ABS_TYP 0.1f // Absolute accuracy typical
78#define DIFFPRESS3_ACCP_ABS_MAX 0.3f // Absolute accuracy minimum
79#define DIFFPRESS3_ACCP_TOT_MIN -0.5f // Total accuracy minimum
80#define DIFFPRESS3_ACCP_TOT_TYP 0.25f // Total accuracy typical
81#define DIFFPRESS3_ACCP_TOT_MAX 0.5f // Total accuracy minimum
82#define DIFFPRESS3_SENP 0.04196f // Sensitivity (digital)
83#define DIFFPRESS3_AN_SENP 275.0f // Sensitivity (analog)
84#define DIFFPRESS3_ACCP_REP 0.01f // Repeatability
85#define DIFFPRESS3_ACCP_DRIFT 0.05f // Long term drift
86#define DIFFPRESS3_DIG_OUTOFF 5660.0f // Digital Zero pressure offset
87#define DIFFPRESS3_DIG_FSS 26214.0f // DigitalFull scale span
88#define DIFFPRESS3_DIG_OUTP_MIN 3207.0f // Digital Output at minimum pressure
89#define DIFFPRESS3_DIG_OUTP_MAX 29491.0f // Digital Output at maximum pressure
90#define DIFFPRESS3_AN_OUTOFF 0.87f // Analog Zero pressure offset
91#define DIFFPRESS3_AN_FSS 4.0f // Analog Full scale span
92#define DIFFPRESS3_AN_OUTP_MIN 0.5f // Analog Output at minimum pressure
93#define DIFFPRESS3_AN_OUTP_MAX 4.5f // Analog Output at maximum pressure
94#define DIFFPRESS3_PRES 0x7FFF // Resolution
95
100#define DIFFPRESS3_TRANGE_MIN 0.0f // Measurement range minimum
101#define DIFFPRESS3_TRANGE_MAX 70.0f // Measurement range maximum
102#define DIFFPRESS3_TRES 0x7FFF // Resolution
103#define DIFFPRESS3_SENT 0.004272 // Sensitivity
104#define DIFFPRESS3_OUTT_MIN 8192.0 // Output at minimum temperature
105#define DIFFPRESS3_OUTT_MAX 24576.0 // Output at maximum temperature
106
111#define DIFFPRESS3_ADC_RESOLUTION 0x7FFF
112#define DIFFPRESS3_VREF_3V3 3.3
113#define DIFFPRESS3_VREF_5V 5.0
114
120#define DIFFPRESS3_SET_DEV_ADDR 0x78
121
122 // diffpress3_set
123
138#define DIFFPRESS3_MAP_MIKROBUS( cfg, mikrobus ) \
139 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
140 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
141 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
142
143 // diffpress3_map
144 // diffpress3
145
156
167
178
196
201typedef struct
202{
203 pin_name_t an;
204 pin_name_t scl;
205 pin_name_t sda;
207 analog_in_resolution_t resolution;
208 float vref;
210 uint32_t i2c_speed;
211 uint8_t i2c_address;
218
229
246
262
277
291err_t diffpress3_read_raw_adc ( diffpress3_t *ctx, uint16_t *raw_adc, diffpress3_d_sel_t data_sel );
292
304err_t diffpress3_read_voltage ( diffpress3_t *ctx, float *voltage );
305
317err_t diffpress3_set_vref ( diffpress3_t *ctx, float vref );
318
332err_t diffpress3_get_pressure ( diffpress3_t *ctx, float *pressure );
333
347err_t diffpress3_get_temperature ( diffpress3_t *ctx, float *temperature );
348
363err_t diffpress3_get_digit_out_data ( diffpress3_t *ctx, uint16_t *press_data, uint16_t *temp_data );
364
365#ifdef __cplusplus
366}
367#endif
368#endif // DIFFPRESS3_H
369
370 // diffpress3
371
372// ------------------------------------------------------------------------ END
diffpress3_return_value_t
Diff Press 3 Click return value data.
Definition diffpress3.h:224
@ DIFFPRESS3_ERROR
Definition diffpress3.h:226
@ DIFFPRESS3_OK
Definition diffpress3.h:225
diffpress3_d_sel_t
Diff Press 3 Click digital output data selector.
Definition diffpress3.h:173
@ DIFFPRESS3_RAW_DATA_PRESSURE
Definition diffpress3.h:174
@ DIFFPRESS3_RAW_DATA_TEMPERATURE
Definition diffpress3.h:175
diffpress3_drv_t
Diff Press 3 Click driver selector.
Definition diffpress3.h:151
@ DIFFPRESS3_DRV_SEL_ADC
Definition diffpress3.h:152
@ DIFFPRESS3_DRV_SEL_I2C
Definition diffpress3.h:153
diffpress3_an_sel_t
Diff Press 3 Click AN SEL selector value.
Definition diffpress3.h:162
@ DIFFPRESS3_AN_SEL_5V
Definition diffpress3.h:163
@ DIFFPRESS3_AN_SEL_2V5
Definition diffpress3.h:164
void diffpress3_cfg_setup(diffpress3_cfg_t *cfg)
Diff Press 3 configuration object setup function.
void diffpress3_drv_interface_selection(diffpress3_cfg_t *cfg, diffpress3_drv_t drv_sel)
Diff Press 3 driver interface setup function.
err_t diffpress3_set_vref(diffpress3_t *ctx, float vref)
Diff Press 3 set vref function.
err_t diffpress3_read_raw_adc(diffpress3_t *ctx, uint16_t *raw_adc, diffpress3_d_sel_t data_sel)
Diff Press 3 read raw ADC value function.
err_t diffpress3_read_voltage(diffpress3_t *ctx, float *voltage)
Diff Press 3 read voltage level function.
err_t diffpress3_get_pressure(diffpress3_t *ctx, float *pressure)
Diff Press 3 get pressure function.
err_t diffpress3_init(diffpress3_t *ctx, diffpress3_cfg_t *cfg)
Diff Press 3 initialization function.
err_t diffpress3_get_digit_out_data(diffpress3_t *ctx, uint16_t *press_data, uint16_t *temp_data)
Diff Press 3 get digital output data function.
err_t diffpress3_get_temperature(diffpress3_t *ctx, float *temperature)
Diff Press 3 get temperature function.
Diff Press 3 Click configuration object.
Definition diffpress3.h:202
diffpress3_an_sel_t an_sel
Definition diffpress3.h:214
analog_in_resolution_t resolution
Definition diffpress3.h:207
float vref
Definition diffpress3.h:208
diffpress3_drv_t drv_sel
Definition diffpress3.h:213
uint32_t i2c_speed
Definition diffpress3.h:210
pin_name_t scl
Definition diffpress3.h:204
pin_name_t sda
Definition diffpress3.h:205
pin_name_t an
Definition diffpress3.h:203
diffpress3_d_sel_t data_sel
Definition diffpress3.h:215
uint8_t i2c_address
Definition diffpress3.h:211
Diff Press 3 Click context object.
Definition diffpress3.h:184
diffpress3_an_sel_t an_sel
Definition diffpress3.h:192
float vref
Definition diffpress3.h:189
diffpress3_drv_t drv_sel
Definition diffpress3.h:190
i2c_master_t i2c
Definition diffpress3.h:186
uint8_t slave_address
Definition diffpress3.h:188
analog_in_t adc
Definition diffpress3.h:185
diffpress3_d_sel_t data_sel
Definition diffpress3.h:193