barometer12 2.1.0.0
barometer12.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 BAROMETER12_H
29#define BAROMETER12_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
78#define BAROMETER12_CMD_OP_MODE_T_FIRST_LOW_POWER 0x609C
79#define BAROMETER12_CMD_OP_MODE_T_FIRST_NORMAL 0x6825
80#define BAROMETER12_CMD_OP_MODE_T_FIRST_LOW_NOISE 0x70DF
81#define BAROMETER12_CMD_OP_MODE_T_FIRST_ULTRA_LOW_NOISE 0x7866
82#define BAROMETER12_CMD_OP_MODE_P_FIRST_LOW_POWER 0x401A
83#define BAROMETER12_CMD_OP_MODE_P_FIRST_NORMAL 0x48A3
84#define BAROMETER12_CMD_OP_MODE_P_FIRST_LOW_NOISE 0x5059
85#define BAROMETER12_CMD_OP_MODE_P_FIRST_ULTRA_LOW_NOISE 0x58E0
86#define BAROMETER12_CMD_SOFT_RESET 0x805D
87#define BAROMETER12_CMD_DEVICE_ID 0xEFC8
88#define BAROMETER12_CMD_READ_OTP 0xC7F7
89#define BAROMETER12_CMD_OTP_READ_ADDRESS_REG 0xC595
90#define BAROMETER12_CMD_OTP_READ_ADDRESS_PARAM 0x0066
91
96#define BAROMETER12_P_PA_CALIB_0 45000.0f
97#define BAROMETER12_P_PA_CALIB_1 80000.0f
98#define BAROMETER12_P_PA_CALIB_2 96700.0f
99#define BAROMETER12_LUT_LOWER 3670016.0f
100#define BAROMETER12_LUT_UPPER 12058624.0f
101#define BAROMETER12_QUADR_FACTOR 5.960464477539063e-8f
102#define BAROMETER12_OFFSET_FACTOR 2048.0f
103#define BAROMETER12_TEMPERATURE_COEF_1 45.0f
104#define BAROMETER12_TEMPERATURE_COEF_2 175.0f
105#define BAROMETER12_TEMPERATURE_COEF_3 65536.0f
106
111#define BAROMETER12_OP_MODE_LOW_POWER 0
112#define BAROMETER12_OP_MODE_NORMAL 1
113#define BAROMETER12_OP_MODE_LOW_NOISE 2
114#define BAROMETER12_OP_MODE_ULTRA_LOW_NOISE 3
115
121#define BAROMETER12_DEVICE_ADDRESS 0x63
122
123 // barometer12_set
124
139#define BAROMETER12_MAP_MIKROBUS( cfg, mikrobus ) \
140 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
141 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
142
143 // barometer12_map
144 // barometer12
145
150typedef struct
151{
152 // Modules
153 i2c_master_t i2c;
155 // I2C slave address
159
164typedef struct
165{
166 pin_name_t scl;
167 pin_name_t sda;
169 uint32_t i2c_speed;
170 uint8_t i2c_address;
173
180typedef struct
181{
182 uint16_t op_mode;
183 float sensor_constants[ 4 ];
184 float p_pa_calib[ 3 ];
185 float lut_lower;
186 float lut_upper;
191
202
219
234
248
263err_t barometer12_generic_write ( barometer12_t *ctx, uint16_t cmd, uint16_t *data_in, uint8_t len );
264
279err_t barometer12_generic_read ( barometer12_t *ctx, uint16_t cmd, uint16_t *data_out, uint8_t len );
280
292err_t barometer12_set_command ( barometer12_t *ctx, uint16_t cmd ) ;
293
305
317err_t barometer12_get_device_id ( barometer12_t *ctx, uint16_t *device_id );
318
330
342err_t barometer12_get_otp ( barometer12_t *ctx, uint16_t *otp_data );
343
356
370err_t barometer12_get_raw_data ( barometer12_t *ctx, uint16_t measurement_comd, uint32_t *pressure, uint16_t *temperature );
371
385err_t barometer12_get_press_and_temp ( barometer12_t *ctx, float *pressure, float *temperature );
386
387#ifdef __cplusplus
388}
389#endif
390#endif // BAROMETER12_H
391
392 // barometer12
393
394// ------------------------------------------------------------------------ END
barometer12_return_value_t
Barometer 12 Click return value data.
Definition barometer12.h:197
@ BAROMETER12_OK
Definition barometer12.h:198
@ BAROMETER12_ERROR
Definition barometer12.h:199
err_t barometer12_set_up_otp_read(barometer12_t *ctx)
Barometer 12 set up OTP read function.
err_t barometer12_inv_invpres_calib(barometer12_t *ctx, barometer12_invpres_t *cfg_data)
Barometer 12 inverse process data function.
err_t barometer12_get_press_and_temp(barometer12_t *ctx, float *pressure, float *temperature)
Barometer 12 get pressure and temperature function.
err_t barometer12_default_cfg(barometer12_t *ctx)
Barometer 12 default configuration function.
err_t barometer12_get_device_id(barometer12_t *ctx, uint16_t *device_id)
Barometer 12 get device ID function.
err_t barometer12_generic_write(barometer12_t *ctx, uint16_t cmd, uint16_t *data_in, uint8_t len)
Barometer 12 I2C writing function.
err_t barometer12_set_command(barometer12_t *ctx, uint16_t cmd)
Barometer 12 set command function.
err_t barometer12_generic_read(barometer12_t *ctx, uint16_t cmd, uint16_t *data_out, uint8_t len)
Barometer 12 I2C reading function.
err_t barometer12_soft_reset(barometer12_t *ctx)
Barometer 12 software reset function.
err_t barometer12_init(barometer12_t *ctx, barometer12_cfg_t *cfg)
Barometer 12 initialization function.
void barometer12_cfg_setup(barometer12_cfg_t *cfg)
Barometer 12 configuration object setup function.
err_t barometer12_get_raw_data(barometer12_t *ctx, uint16_t measurement_comd, uint32_t *pressure, uint16_t *temperature)
Barometer 12 get RAW data function.
err_t barometer12_get_otp(barometer12_t *ctx, uint16_t *otp_data)
Barometer 12 get OTP function.
Barometer 12 Click configuration object.
Definition barometer12.h:165
uint32_t i2c_speed
Definition barometer12.h:169
pin_name_t scl
Definition barometer12.h:166
pin_name_t sda
Definition barometer12.h:167
uint8_t i2c_address
Definition barometer12.h:170
Barometer 12 Click structure to hold pressure sensor related parameters object.
Definition barometer12.h:181
float lut_lower
Definition barometer12.h:185
float offst_factor
Definition barometer12.h:188
float quadr_factor
Definition barometer12.h:187
float lut_upper
Definition barometer12.h:186
uint16_t op_mode
Definition barometer12.h:182
Barometer 12 Click context object.
Definition barometer12.h:151
i2c_master_t i2c
Definition barometer12.h:153
uint8_t slave_address
Definition barometer12.h:156