barometer10  2.1.0.0
barometer10.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 BAROMETER10_H
29 #define BAROMETER10_H
30 
31 #ifdef __cplusplus
32 extern "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_in.h"
50 #include "drv_i2c_master.h"
51 
72 #define BAROMETER10_REG_INTERRUPT_CFG 0x0B
73 #define BAROMETER10_REG_THS_P_L 0x0C
74 #define BAROMETER10_REG_THS_P_H 0x0D
75 #define BAROMETER10_REG_IF_CTRL 0x0E
76 #define BAROMETER10_REG_WHO_AM_I 0x0F
77 #define BAROMETER10_REG_CTRL_REG1 0x10
78 #define BAROMETER10_REG_CTRL_REG2 0x11
79 #define BAROMETER10_REG_CTRL_REG3 0x12
80 #define BAROMETER10_REG_CTRL_REG4 0x13
81 #define BAROMETER10_REG_FIFO_CTRL 0x14
82 #define BAROMETER10_REG_FIFO_WTM 0x15
83 #define BAROMETER10_REG_REF_P_L 0x16
84 #define BAROMETER10_REG_REF_P_H 0x17
85 #define BAROMETER10_REG_I3C_IF_CTRL_ADD 0x19
86 #define BAROMETER10_REG_RPDS_L 0x1A
87 #define BAROMETER10_REG_RPDS_H 0x1B
88 #define BAROMETER10_REG_INT_SOURCE 0x24
89 #define BAROMETER10_REG_FIFO_STATUS1 0x25
90 #define BAROMETER10_REG_FIFO_STATUS2 0x26
91 #define BAROMETER10_REG_STATUS 0x27
92 #define BAROMETER10_REG_PRESS_OUT_XL 0x28
93 #define BAROMETER10_REG_PRESS_OUT_L 0x29
94 #define BAROMETER10_REG_PRESS_OUT_H 0x2A
95 #define BAROMETER10_REG_TEMP_OUT_L 0x2B
96 #define BAROMETER10_REG_TEMP_OUT_H 0x2C
97 #define BAROMETER10_REG_FIFO_DATA_OUT_PRESS_XL 0x78
98 #define BAROMETER10_REG_FIFO_DATA_OUT_PRESS_L 0x79
99 #define BAROMETER10_REG_FIFO_DATA_OUT_PRESS_H 0x7A
100  // barometer10_reg
102 
117 #define BAROMETER10_DEVICE_ID 0xB4
118 
123 #define BAROMETER10_ODR_ONE_SHOT 0x00
124 #define BAROMETER10_ODR_1_Hz 0x01
125 #define BAROMETER10_ODR_4_Hz 0x02
126 #define BAROMETER10_ODR_10_Hz 0x03
127 #define BAROMETER10_ODR_25_Hz 0x04
128 #define BAROMETER10_ODR_50_Hz 0x05
129 #define BAROMETER10_ODR_75_Hz 0x06
130 #define BAROMETER10_ODR_100_Hz 0x07
131 #define BAROMETER10_ODR_200_Hz 0x08
132 #define BAROMETER10_AVG_4 0x00
133 #define BAROMETER10_AVG_8 0x01
134 #define BAROMETER10_AVG_16 0x02
135 #define BAROMETER10_AVG_32 0x03
136 #define BAROMETER10_AVG_64 0x04
137 #define BAROMETER10_AVG_128 0x05
138 #define BAROMETER10_AVG_512 0x07
139 
144 #define BAROMETER10_FS_MODE_1260_hPa 0x00
145 #define BAROMETER10_FS_MODE_4060_hPa 0x01
146 #define BAROMETER10_LFPF_CFG_ODR4 0x00
147 #define BAROMETER10_LFPF_CFG_ODR9 0x01
148 #define BAROMETER10_EN_LPFP_DISABLE 0x00
149 #define BAROMETER10_EN_LPFP_ENABLE 0x01
150 #define BAROMETER10_BDU_CONTINUOUS_UPDATE 0x00
151 #define BAROMETER10_BDU_NO_UPDATE_UNTIL_READ 0x01
152 #define BAROMETER10_SWRESET_BIT_MASK 0x02
153 #define BAROMETER10_ONESHOT_IDLE_MODE 0x00
154 #define BAROMETER10_ONESHOT_NEW_SET_ACQUIRED 0x01
155 
160 #define BAROMETER10_INT_H_L_ACTIVE_HIGH 0x00
161 #define BAROMETER10_INT_H_L_ACTIVE_LOW 0x01
162 #define BAROMETER10_IF_ADD_INC_DISABLE 0x00
163 #define BAROMETER10_IF_ADD_INC_ENABLE 0x01
164 
169 #define BAROMETER10_DRDY_PLS_DISABLE 0x00
170 #define BAROMETER10_DRDY_PLS_ENABLE 0x01
171 #define BAROMETER10_DRDY_DISABLE 0x00
172 #define BAROMETER10_DRDY_ENABLE 0x01
173 #define BAROMETER10_INT_EN_DISABLE 0x00
174 #define BAROMETER10_INT_EN_ENABLE 0x01
175 
181 #define BAROMETER10_DEVICE_ADDRESS_GND 0x5C
182 #define BAROMETER10_DEVICE_ADDRESS_VCC 0x5D
183  // barometer10_set
185 
200 #define BAROMETER10_MAP_MIKROBUS( cfg, mikrobus ) \
201  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
202  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
203  cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
204  // barometer10_map // barometer10
207 
212 typedef struct
213 {
214  // Input pins
215  digital_in_t int_pin;
217  // Modules
218  i2c_master_t i2c;
220  // I2C slave address
221  uint8_t slave_address;
223 } barometer10_t;
224 
229 typedef struct
230 {
231  pin_name_t scl;
232  pin_name_t sda;
234  pin_name_t int_pin;
236  uint32_t i2c_speed;
237  uint8_t i2c_address;
240 
245 typedef struct
246 {
247  uint8_t odr;
248  uint8_t avg;
249  uint8_t fs_mode;
250  uint8_t lfpf_cfg;
251  uint8_t en_lpfp;
252  uint8_t bdu;
253  uint8_t oneshot;
254  uint8_t int_h_l;
255  uint8_t if_add_inc;
256  uint8_t drdy_pls;
257  uint8_t drdy;
258  uint8_t int_en;
261 
266 typedef enum
267 {
269  BAROMETER10_ERROR = -1
270 
272 
289 
304 
318 
333 err_t barometer10_generic_write ( barometer10_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len );
334 
349 err_t barometer10_generic_read ( barometer10_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len );
350 
365 
380 err_t barometer10_get_device_id ( barometer10_t *ctx, uint8_t *device_id );
381 
398 
415 
430 
445 err_t barometer10_get_pressure_output ( barometer10_t *ctx, int32_t *pressure_raw );
446 
461 err_t barometer10_get_temperature_output ( barometer10_t *ctx, int16_t *temperature_raw );
462 
477 err_t barometer10_get_pressure ( barometer10_t *ctx, float *pressure );
478 
493 err_t barometer10_get_temperature ( barometer10_t *ctx, float *temperature );
494 
509 
510 #ifdef __cplusplus
511 }
512 #endif
513 #endif // BAROMETER10_H
514  // barometer10
516 
517 // ------------------------------------------------------------------------ END
barometer10_cfg_t::sda
pin_name_t sda
Definition: barometer10.h:232
barometer10_t::i2c
i2c_master_t i2c
Definition: barometer10.h:218
barometer10_sensor_cfg_t::drdy_pls
uint8_t drdy_pls
Definition: barometer10.h:256
barometer10_sensor_cfg_t::lfpf_cfg
uint8_t lfpf_cfg
Definition: barometer10.h:250
barometer10_get_temperature_output
err_t barometer10_get_temperature_output(barometer10_t *ctx, int16_t *temperature_raw)
Barometer 10 gets temperature output function.
barometer10_sensor_cfg_t::oneshot
uint8_t oneshot
Definition: barometer10.h:253
barometer10_cfg_t::i2c_address
uint8_t i2c_address
Definition: barometer10.h:237
barometer10_sensor_cfg_t::odr
uint8_t odr
Definition: barometer10.h:247
barometer10_sensor_cfg_t::fs_mode
uint8_t fs_mode
Definition: barometer10.h:249
barometer10_t::slave_address
uint8_t slave_address
Definition: barometer10.h:221
barometer10_set_config
err_t barometer10_set_config(barometer10_t *ctx, barometer10_sensor_cfg_t config)
Barometer 10 set configuration function.
barometer10_get_device_id
err_t barometer10_get_device_id(barometer10_t *ctx, uint8_t *device_id)
Barometer 10 gets device ID function.
barometer10_sensor_cfg_t::avg
uint8_t avg
Definition: barometer10.h:248
barometer10_sensor_cfg_t::drdy
uint8_t drdy
Definition: barometer10.h:257
barometer10_get_temperature
err_t barometer10_get_temperature(barometer10_t *ctx, float *temperature)
Barometer 10 gets temperature function.
barometer10_default_cfg
err_t barometer10_default_cfg(barometer10_t *ctx)
Barometer 10 default configuration function.
barometer10_cfg_t
Barometer 10 Click configuration object.
Definition: barometer10.h:230
barometer10_cfg_setup
void barometer10_cfg_setup(barometer10_cfg_t *cfg)
Barometer 10 configuration object setup function.
barometer10_get_pressure
err_t barometer10_get_pressure(barometer10_t *ctx, float *pressure)
Barometer 10 gets pressure function.
barometer10_return_value_t
barometer10_return_value_t
Barometer 10 Click return value data.
Definition: barometer10.h:267
barometer10_cfg_t::scl
pin_name_t scl
Definition: barometer10.h:231
barometer10_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: barometer10.h:236
barometer10_sensor_cfg_t
Barometer 10 Click sensor configuration object.
Definition: barometer10.h:246
barometer10_get_pressure_output
err_t barometer10_get_pressure_output(barometer10_t *ctx, int32_t *pressure_raw)
Barometer 10 gets pressure output function.
barometer10_init
err_t barometer10_init(barometer10_t *ctx, barometer10_cfg_t *cfg)
Barometer 10 initialization function.
barometer10_sw_reset
err_t barometer10_sw_reset(barometer10_t *ctx)
Barometer 10 software reset function.
barometer10_sensor_cfg_t::int_en
uint8_t int_en
Definition: barometer10.h:258
BAROMETER10_OK
@ BAROMETER10_OK
Definition: barometer10.h:268
BAROMETER10_ERROR
@ BAROMETER10_ERROR
Definition: barometer10.h:269
barometer10_get_config
err_t barometer10_get_config(barometer10_t *ctx, barometer10_sensor_cfg_t *config)
Barometer 10 gets configuration function.
barometer10_t::int_pin
digital_in_t int_pin
Definition: barometer10.h:215
barometer10_sensor_cfg_t::bdu
uint8_t bdu
Definition: barometer10.h:252
barometer10_sensor_cfg_t::if_add_inc
uint8_t if_add_inc
Definition: barometer10.h:255
barometer10_cfg_t::int_pin
pin_name_t int_pin
Definition: barometer10.h:234
barometer10_sensor_cfg_t::en_lpfp
uint8_t en_lpfp
Definition: barometer10.h:251
barometer10_t
Barometer 10 Click context object.
Definition: barometer10.h:213
barometer10_get_int_pin
uint8_t barometer10_get_int_pin(barometer10_t *ctx)
Barometer 10 gets interrupt function.
barometer10_trigger_one_shot
err_t barometer10_trigger_one_shot(barometer10_t *ctx)
Barometer 10 trigger one-shot function.
barometer10_generic_write
err_t barometer10_generic_write(barometer10_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Barometer 10 I2C writing function.
barometer10_sensor_cfg_t::int_h_l
uint8_t int_h_l
Definition: barometer10.h:254
barometer10_generic_read
err_t barometer10_generic_read(barometer10_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Barometer 10 I2C reading function.