vavpress 2.0.0.0
vavpress.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 VAVPRESS_H
29#define VAVPRESS_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 VAVPRESS_SET_CMD_RESET_FIRMWARE 0x11
74#define VAVPRESS_SET_CMD_START_PRESSURE_CONVERSION 0x21
75#define VAVPRESS_SET_CMD_RETRIEVE_ELECTRONIC_SIGNATURE 0x23
76
82#define VAVPRESS_SET_DEV_ADDR_0 0x5C
83#define VAVPRESS_SET_DEV_ADDR_1 0x5D
84#define VAVPRESS_SET_DEV_ADDR_2 0x5E
85#define VAVPRESS_SET_DEV_ADDR_3 0x5F
86
87 // vavpress_set
88
103#define VAVPRESS_MAP_MIKROBUS( cfg, mikrobus ) \
104 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
105 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
106
107 // vavpress_map
108 // vavpress
109
114typedef struct
115{
116 // Modules
117
118 i2c_master_t i2c;
120 // I2C slave address
121
124} vavpress_t;
125
130typedef struct
131{
132 pin_name_t scl;
133 pin_name_t sda;
135 uint32_t i2c_speed;
136 uint8_t i2c_address;
139
144typedef enum
145{
147 VAVPRESS_ERROR = -1
148
150
155typedef struct
156{
158 char part_number[ 12 ];
159 char lot_number[ 7 ];
162 uint16_t scale_factor;
163 char calibration_id[ 2 ];
164 uint8_t week_number;
165 uint8_t year_number;
167
169
182
201
219
236
255err_t vavpress_set_command ( vavpress_t *ctx, uint8_t cmd );
256
273err_t vavpress_generic_write ( vavpress_t *ctx, uint8_t *tx_buf, uint8_t tx_len );
274
291err_t vavpress_generic_read ( vavpress_t *ctx, uint8_t *rx_buf, uint8_t rx_len );
292
310
328err_t vavpress_get_readout_data ( vavpress_t *ctx, int16_t *press_data, int16_t *temp_data );
329
348err_t vavpress_get_dif_press_and_temp ( vavpress_t *ctx, vavpress_sensor_param_data_t *param_data, float *diff_press, float *temperature );
349
367
368
369#ifdef __cplusplus
370}
371#endif
372#endif // VAVPRESS_H
373
374 // vavpress
375
376// ------------------------------------------------------------------------ END
void vavpress_cfg_setup(vavpress_cfg_t *cfg)
VAV Press configuration object setup function.
err_t vavpress_set_command(vavpress_t *ctx, uint8_t cmd)
VAV Press set command function.
err_t vavpress_get_dif_press_and_temp(vavpress_t *ctx, vavpress_sensor_param_data_t *param_data, float *diff_press, float *temperature)
VAV Press get differential pressure and temperature function.
err_t vavpress_init(vavpress_t *ctx, vavpress_cfg_t *cfg)
VAV Press initialization function.
err_t vavpress_set_default_sensor_param(vavpress_t *ctx, vavpress_sensor_param_data_t *param_data)
VAV Press set default sensor parameter function.
err_t vavpress_generic_write(vavpress_t *ctx, uint8_t *tx_buf, uint8_t tx_len)
VAV Press I2C writing function.
err_t vavpress_get_readout_data(vavpress_t *ctx, int16_t *press_data, int16_t *temp_data)
VAV Press get data readout function.
err_t vavpress_generic_read(vavpress_t *ctx, uint8_t *rx_buf, uint8_t rx_len)
VAV Press I2C reading function.
err_t vavpress_retrieve_electronic_signature(vavpress_t *ctx, vavpress_el_signature_data_t *el_signature_data)
VAV Press retrieve electronic signature function.
err_t vavpress_default_cfg(vavpress_t *ctx)
VAV Press default configuration function.
vavpress_el_signature_data_t el_signature_data
Definition main.c:36
vavpress_sensor_param_data_t param_data
Definition main.c:37
VAV Press Click configuration object.
Definition vavpress.h:131
uint32_t i2c_speed
Definition vavpress.h:135
pin_name_t scl
Definition vavpress.h:132
pin_name_t sda
Definition vavpress.h:133
uint8_t i2c_address
Definition vavpress.h:136
VAV Press Click electronic signature.
Definition vavpress.h:156
char output_type
Definition vavpress.h:161
uint16_t pressure_range
Definition vavpress.h:160
float firmware_version
Definition vavpress.h:157
uint16_t scale_factor
Definition vavpress.h:162
uint8_t week_number
Definition vavpress.h:164
uint16_t sequence_number
Definition vavpress.h:166
uint8_t year_number
Definition vavpress.h:165
VAV Press Click sensor parameter data.
Definition vavpress.h:175
uint16_t readout_at_known_temperature
Definition vavpress.h:178
float known_temperature_c
Definition vavpress.h:179
uint16_t scale_factor_press
Definition vavpress.h:177
uint16_t scale_factor_temp
Definition vavpress.h:176
VAV Press Click context object.
Definition vavpress.h:115
i2c_master_t i2c
Definition vavpress.h:118
uint8_t slave_address
Definition vavpress.h:122
vavpress_return_value_t
VAV Press Click return value data.
Definition vavpress.h:145
@ VAVPRESS_OK
Definition vavpress.h:146
@ VAVPRESS_ERROR
Definition vavpress.h:147