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 
35 #include "drv_digital_in.h"
36 #include "drv_i2c_master.h"
37 
58 #define BAROMETER10_REG_INTERRUPT_CFG 0x0B
59 #define BAROMETER10_REG_THS_P_L 0x0C
60 #define BAROMETER10_REG_THS_P_H 0x0D
61 #define BAROMETER10_REG_IF_CTRL 0x0E
62 #define BAROMETER10_REG_WHO_AM_I 0x0F
63 #define BAROMETER10_REG_CTRL_REG1 0x10
64 #define BAROMETER10_REG_CTRL_REG2 0x11
65 #define BAROMETER10_REG_CTRL_REG3 0x12
66 #define BAROMETER10_REG_CTRL_REG4 0x13
67 #define BAROMETER10_REG_FIFO_CTRL 0x14
68 #define BAROMETER10_REG_FIFO_WTM 0x15
69 #define BAROMETER10_REG_REF_P_L 0x16
70 #define BAROMETER10_REG_REF_P_H 0x17
71 #define BAROMETER10_REG_I3C_IF_CTRL_ADD 0x19
72 #define BAROMETER10_REG_RPDS_L 0x1A
73 #define BAROMETER10_REG_RPDS_H 0x1B
74 #define BAROMETER10_REG_INT_SOURCE 0x24
75 #define BAROMETER10_REG_FIFO_STATUS1 0x25
76 #define BAROMETER10_REG_FIFO_STATUS2 0x26
77 #define BAROMETER10_REG_STATUS 0x27
78 #define BAROMETER10_REG_PRESS_OUT_XL 0x28
79 #define BAROMETER10_REG_PRESS_OUT_L 0x29
80 #define BAROMETER10_REG_PRESS_OUT_H 0x2A
81 #define BAROMETER10_REG_TEMP_OUT_L 0x2B
82 #define BAROMETER10_REG_TEMP_OUT_H 0x2C
83 #define BAROMETER10_REG_FIFO_DATA_OUT_PRESS_XL 0x78
84 #define BAROMETER10_REG_FIFO_DATA_OUT_PRESS_L 0x79
85 #define BAROMETER10_REG_FIFO_DATA_OUT_PRESS_H 0x7A
86  // barometer10_reg
88 
103 #define BAROMETER10_DEVICE_ID 0xB4
104 
109 #define BAROMETER10_ODR_ONE_SHOT 0x00
110 #define BAROMETER10_ODR_1_Hz 0x01
111 #define BAROMETER10_ODR_4_Hz 0x02
112 #define BAROMETER10_ODR_10_Hz 0x03
113 #define BAROMETER10_ODR_25_Hz 0x04
114 #define BAROMETER10_ODR_50_Hz 0x05
115 #define BAROMETER10_ODR_75_Hz 0x06
116 #define BAROMETER10_ODR_100_Hz 0x07
117 #define BAROMETER10_ODR_200_Hz 0x08
118 #define BAROMETER10_AVG_4 0x00
119 #define BAROMETER10_AVG_8 0x01
120 #define BAROMETER10_AVG_16 0x02
121 #define BAROMETER10_AVG_32 0x03
122 #define BAROMETER10_AVG_64 0x04
123 #define BAROMETER10_AVG_128 0x05
124 #define BAROMETER10_AVG_512 0x07
125 
130 #define BAROMETER10_FS_MODE_1260_hPa 0x00
131 #define BAROMETER10_FS_MODE_4060_hPa 0x01
132 #define BAROMETER10_LFPF_CFG_ODR4 0x00
133 #define BAROMETER10_LFPF_CFG_ODR9 0x01
134 #define BAROMETER10_EN_LPFP_DISABLE 0x00
135 #define BAROMETER10_EN_LPFP_ENABLE 0x01
136 #define BAROMETER10_BDU_CONTINUOUS_UPDATE 0x00
137 #define BAROMETER10_BDU_NO_UPDATE_UNTIL_READ 0x01
138 #define BAROMETER10_SWRESET_BIT_MASK 0x02
139 #define BAROMETER10_ONESHOT_IDLE_MODE 0x00
140 #define BAROMETER10_ONESHOT_NEW_SET_ACQUIRED 0x01
141 
146 #define BAROMETER10_INT_H_L_ACTIVE_HIGH 0x00
147 #define BAROMETER10_INT_H_L_ACTIVE_LOW 0x01
148 #define BAROMETER10_IF_ADD_INC_DISABLE 0x00
149 #define BAROMETER10_IF_ADD_INC_ENABLE 0x01
150 
155 #define BAROMETER10_DRDY_PLS_DISABLE 0x00
156 #define BAROMETER10_DRDY_PLS_ENABLE 0x01
157 #define BAROMETER10_DRDY_DISABLE 0x00
158 #define BAROMETER10_DRDY_ENABLE 0x01
159 #define BAROMETER10_INT_EN_DISABLE 0x00
160 #define BAROMETER10_INT_EN_ENABLE 0x01
161 
167 #define BAROMETER10_DEVICE_ADDRESS_GND 0x5C
168 #define BAROMETER10_DEVICE_ADDRESS_VCC 0x5D
169  // barometer10_set
171 
186 #define BAROMETER10_MAP_MIKROBUS( cfg, mikrobus ) \
187  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
188  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
189  cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
190  // barometer10_map // barometer10
193 
198 typedef struct
199 {
200  // Input pins
201  digital_in_t int_pin;
203  // Modules
204  i2c_master_t i2c;
206  // I2C slave address
207  uint8_t slave_address;
209 } barometer10_t;
210 
215 typedef struct
216 {
217  pin_name_t scl;
218  pin_name_t sda;
220  pin_name_t int_pin;
222  uint32_t i2c_speed;
223  uint8_t i2c_address;
226 
231 typedef struct
232 {
233  uint8_t odr;
234  uint8_t avg;
235  uint8_t fs_mode;
236  uint8_t lfpf_cfg;
237  uint8_t en_lpfp;
238  uint8_t bdu;
239  uint8_t oneshot;
240  uint8_t int_h_l;
241  uint8_t if_add_inc;
242  uint8_t drdy_pls;
243  uint8_t drdy;
244  uint8_t int_en;
247 
252 typedef enum
253 {
255  BAROMETER10_ERROR = -1
256 
258 
275 
290 
304 
319 err_t barometer10_generic_write ( barometer10_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len );
320 
335 err_t barometer10_generic_read ( barometer10_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len );
336 
351 
366 err_t barometer10_get_device_id ( barometer10_t *ctx, uint8_t *device_id );
367 
384 
401 
416 
431 err_t barometer10_get_pressure_output ( barometer10_t *ctx, int32_t *pressure_raw );
432 
447 err_t barometer10_get_temperature_output ( barometer10_t *ctx, int16_t *temperature_raw );
448 
463 err_t barometer10_get_pressure ( barometer10_t *ctx, float *pressure );
464 
479 err_t barometer10_get_temperature ( barometer10_t *ctx, float *temperature );
480 
495 
496 #ifdef __cplusplus
497 }
498 #endif
499 #endif // BAROMETER10_H
500  // barometer10
502 
503 // ------------------------------------------------------------------------ END
barometer10_cfg_t::sda
pin_name_t sda
Definition: barometer10.h:218
barometer10_t::i2c
i2c_master_t i2c
Definition: barometer10.h:204
barometer10_sensor_cfg_t::drdy_pls
uint8_t drdy_pls
Definition: barometer10.h:242
barometer10_sensor_cfg_t::lfpf_cfg
uint8_t lfpf_cfg
Definition: barometer10.h:236
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:239
barometer10_cfg_t::i2c_address
uint8_t i2c_address
Definition: barometer10.h:223
barometer10_sensor_cfg_t::odr
uint8_t odr
Definition: barometer10.h:233
barometer10_sensor_cfg_t::fs_mode
uint8_t fs_mode
Definition: barometer10.h:235
barometer10_t::slave_address
uint8_t slave_address
Definition: barometer10.h:207
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:234
barometer10_sensor_cfg_t::drdy
uint8_t drdy
Definition: barometer10.h:243
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:216
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:253
barometer10_cfg_t::scl
pin_name_t scl
Definition: barometer10.h:217
barometer10_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: barometer10.h:222
barometer10_sensor_cfg_t
Barometer 10 Click sensor configuration object.
Definition: barometer10.h:232
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:244
BAROMETER10_OK
@ BAROMETER10_OK
Definition: barometer10.h:254
BAROMETER10_ERROR
@ BAROMETER10_ERROR
Definition: barometer10.h:255
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:201
barometer10_sensor_cfg_t::bdu
uint8_t bdu
Definition: barometer10.h:238
barometer10_sensor_cfg_t::if_add_inc
uint8_t if_add_inc
Definition: barometer10.h:241
barometer10_cfg_t::int_pin
pin_name_t int_pin
Definition: barometer10.h:220
barometer10_sensor_cfg_t::en_lpfp
uint8_t en_lpfp
Definition: barometer10.h:237
barometer10_t
Barometer 10 Click context object.
Definition: barometer10.h:199
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:240
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.