barometer4 2.0.0.0
barometer4.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 BAROMETER4_H
29#define BAROMETER4_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 BAROMETER4_CMD_OP_MODE_T_FIRST_LOW_POWER 0x609C
74#define BAROMETER4_CMD_OP_MODE_T_FIRST_NORMAL 0x6825
75#define BAROMETER4_CMD_OP_MODE_T_FIRST_LOW_NOISE 0x70DF
76#define BAROMETER4_CMD_OP_MODE_T_FIRST_ULTRA_LOW_NOISE 0x7866
77#define BAROMETER4_CMD_OP_MODE_P_FIRST_LOW_POWER 0x401A
78#define BAROMETER4_CMD_OP_MODE_P_FIRST_NORMAL 0x48A3
79#define BAROMETER4_CMD_OP_MODE_P_FIRST_LOW_NOISE 0x5059
80#define BAROMETER4_CMD_OP_MODE_P_FIRST_ULTRA_LOW_NOISE 0x58E0
81#define BAROMETER4_CMD_SOFT_RESET 0x805D
82#define BAROMETER4_CMD_DEVICE_ID 0xEFC8
83#define BAROMETER4_CMD_READ_OTP 0xC7F7
84
85 // barometer4_cmd
86
101#define BAROMETER4_OP_MODE_LOW_POWER 0
102#define BAROMETER4_OP_MODE_NORMAL 1
103#define BAROMETER4_OP_MODE_LOW_NOISE 2
104#define BAROMETER4_OP_MODE_ULTRA_LOW_NOISE 3
105
111#define BAROMETER4_SET_DEV_ADDR 0x63
112
113 // barometer4_set
114
129#define BAROMETER4_MAP_MIKROBUS( cfg, mikrobus ) \
130 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
131 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
132
133 // barometer4_map
134 // barometer4
135
140typedef struct
141{
142 // Modules
143 i2c_master_t i2c;
145 // I2C slave address
149
154typedef struct
155{
156 pin_name_t scl;
157 pin_name_t sda;
159 uint32_t i2c_speed;
160 uint8_t i2c_address;
163
170typedef struct
171{
172 uint16_t op_mode;
173 float sensor_constants[ 4 ];
174 float p_pa_calib[ 3 ];
179
181
192
209
225
240
256err_t barometer4_generic_write ( barometer4_t *ctx, uint16_t cmd, uint8_t *tx_buf, uint8_t tx_len );
257
273err_t barometer4_generic_read ( barometer4_t *ctx, uint16_t cmd, uint16_t *rx_buf, uint8_t rx_len );
274
289err_t barometer4_set_command ( barometer4_t *ctx, uint16_t cmd ) ;
290
305
320err_t barometer4_get_device_id ( barometer4_t *ctx, uint16_t *device_id );
321
336
351err_t barometer4_get_otp ( barometer4_t *ctx, uint16_t *otp_data );
352
368
385err_t barometer4_get_raw_data ( barometer4_t *ctx, uint16_t measurement_comd, uint32_t *pressure, uint16_t *temperature );
386
402err_t barometer4_get_pressure_and_temperature ( barometer4_t *ctx, float *pressure, float *temperature );
403
404#ifdef __cplusplus
405}
406#endif
407#endif // BAROMETER4_H
408
409 // barometer4
410
411// ------------------------------------------------------------------------ END
barometer4_return_value_t
Barometer 4 Click return value data.
Definition barometer4.h:187
@ BAROMETER4_OK
Definition barometer4.h:188
@ BAROMETER4_ERROR
Definition barometer4.h:189
void barometer4_cfg_setup(barometer4_cfg_t *cfg)
Barometer 4 configuration object setup function.
err_t barometer4_generic_read(barometer4_t *ctx, uint16_t cmd, uint16_t *rx_buf, uint8_t rx_len)
Barometer 4 I2C reading function.
err_t barometer4_inv_invpres_calibration(barometer4_t *ctx, barometer4_invpres_t *cfg_data)
Barometer 4 inverse process data function.
err_t barometer4_generic_write(barometer4_t *ctx, uint16_t cmd, uint8_t *tx_buf, uint8_t tx_len)
Barometer 4 I2C writing function.
err_t barometer4_set_command(barometer4_t *ctx, uint16_t cmd)
Barometer 4 set command function.
err_t barometer4_default_cfg(barometer4_t *ctx)
Barometer 4 default configuration function.
err_t barometer4_get_raw_data(barometer4_t *ctx, uint16_t measurement_comd, uint32_t *pressure, uint16_t *temperature)
Barometer 4 get RAW data function.
err_t barometer4_set_up_otp_read(barometer4_t *ctx)
Barometer 4 set up OTP read function.
err_t barometer4_get_device_id(barometer4_t *ctx, uint16_t *device_id)
Barometer 4 get device ID function.
err_t barometer4_soft_reset(barometer4_t *ctx)
Barometer 4 software reset function.
err_t barometer4_get_pressure_and_temperature(barometer4_t *ctx, float *pressure, float *temperature)
Barometer 4 get pressure and temperature function.
err_t barometer4_init(barometer4_t *ctx, barometer4_cfg_t *cfg)
Barometer 4 initialization function.
err_t barometer4_get_otp(barometer4_t *ctx, uint16_t *otp_data)
Barometer 4 get OTP function.
Barometer 4 Click configuration object.
Definition barometer4.h:155
uint32_t i2c_speed
Definition barometer4.h:159
pin_name_t scl
Definition barometer4.h:156
pin_name_t sda
Definition barometer4.h:157
uint8_t i2c_address
Definition barometer4.h:160
Barometer 4 Click structure to hold pressure sensor related parameters object.
Definition barometer4.h:171
float lut_lower
Definition barometer4.h:175
float offst_factor
Definition barometer4.h:178
float quadr_factor
Definition barometer4.h:177
float lut_upper
Definition barometer4.h:176
uint16_t op_mode
Definition barometer4.h:172
Barometer 4 Click context object.
Definition barometer4.h:141
i2c_master_t i2c
Definition barometer4.h:143
uint8_t slave_address
Definition barometer4.h:146