altitude5  2.0.0.0
altitude5.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 ALTITUDE5_H
29 #define ALTITUDE5_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
35 #include "mikrosdk_version.h"
36 
37 #ifdef __GNUC__
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
40 #else
41 #include "delays.h"
42 #endif
43 #endif
44 
45 #include "drv_i2c_master.h"
46 #include "drv_analog_in.h"
47 
74 #define ALTITUDE5_SET_DEV_ADDR 0x4D
75  // altitude5_set
77 
92 #define ALTITUDE5_MAP_MIKROBUS( cfg, mikrobus ) \
93  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
94  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
95  cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN )
96  // altitude5_map // altitude5
99 
100 typedef enum
101 {
106 
107 typedef err_t ( *altitude5_master_io_t )( struct altitude5_s*, uint16_t* );
108 
113 typedef struct altitude5_s
114 {
115  analog_in_t adc;
117  // Modules
118  i2c_master_t i2c;
120  // I2C slave address
121  uint8_t slave_address;
127  int16_t offset;
129  float temperature;
132 
137 typedef struct
138 {
139  pin_name_t an;
141  analog_in_resolution_t resolution;
142  float vref;
144  pin_name_t scl;
145  pin_name_t sda;
147  uint32_t i2c_speed;
148  uint8_t i2c_address;
151 
152  int16_t adc_offset;
157 
158 
163 typedef enum
164 {
166  ALTITUDE5_ERROR = -1
167 
169 
186 
202 
217 
232 err_t altitude5_get_adc ( altitude5_t *ctx, uint16_t *data_out );
233 
247 err_t altitude5_read_an_pin_voltage ( altitude5_t *ctx, float *data_out );
248 
263 err_t altitude5_get_adc_voltage ( altitude5_t *ctx, float *adc_vtg );
264 
279 err_t altitude5_get_pressure ( altitude5_t *ctx, float *pressure );
280 
295 err_t altitude5_get_altitude ( altitude5_t *ctx, float *altitude );
296 
297 #ifdef __cplusplus
298 }
299 #endif
300 #endif // ALTITUDE5_H
301  // altitude5
303 
304 // ------------------------------------------------------------------------ END
altitude5_s::sea_lvl_pressure
float sea_lvl_pressure
Definition: altitude5.h:128
altitude5_cfg_t::scl
pin_name_t scl
Definition: altitude5.h:144
altitude5_cfg_t::sea_level_pressure
float sea_level_pressure
Definition: altitude5.h:153
altitude5_default_cfg
err_t altitude5_default_cfg(altitude5_t *ctx)
Altitude 5 default configuration function.
altitude5_drv_t
altitude5_drv_t
Definition: altitude5.h:101
altitude5_s::offset
int16_t offset
Definition: altitude5.h:127
altitude5_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: altitude5.h:147
altitude5_cfg_t::drv_sel
altitude5_drv_t drv_sel
Definition: altitude5.h:150
altitude5_return_value_t
altitude5_return_value_t
Altitude 5 Click return value data.
Definition: altitude5.h:164
altitude5_get_altitude
err_t altitude5_get_altitude(altitude5_t *ctx, float *altitude)
Altitude 5 get altitude function.
altitude5_t
struct altitude5_s altitude5_t
Altitude 5 Click context object.
altitude5_master_io_t
err_t(* altitude5_master_io_t)(struct altitude5_s *, uint16_t *)
Definition: altitude5.h:107
ALTITUDE5_OK
@ ALTITUDE5_OK
Definition: altitude5.h:165
altitude5_s::drv_sel
altitude5_drv_t drv_sel
Definition: altitude5.h:123
altitude5_cfg_t::sda
pin_name_t sda
Definition: altitude5.h:145
altitude5_get_pressure
err_t altitude5_get_pressure(altitude5_t *ctx, float *pressure)
Altitude 5 get pressure function.
altitude5_cfg_t
Altitude 5 Click configuration object.
Definition: altitude5.h:138
altitude5_read_an_pin_voltage
err_t altitude5_read_an_pin_voltage(altitude5_t *ctx, float *data_out)
Altitude 5 read AN pin voltage level function.
altitude5_cfg_t::an
pin_name_t an
Definition: altitude5.h:139
ALTITUDE5_ERROR
@ ALTITUDE5_ERROR
Definition: altitude5.h:166
altitude5_cfg_t::adc_offset
int16_t adc_offset
Definition: altitude5.h:152
altitude5_get_adc
err_t altitude5_get_adc(altitude5_t *ctx, uint16_t *data_out)
Altitude 5 get ADC function.
altitude5_s::slave_address
uint8_t slave_address
Definition: altitude5.h:121
altitude5_cfg_t::vref
float vref
Definition: altitude5.h:142
altitude5_init
err_t altitude5_init(altitude5_t *ctx, altitude5_cfg_t *cfg)
Altitude 5 initialization function.
altitude5_cfg_t::resolution
analog_in_resolution_t resolution
Definition: altitude5.h:141
altitude5_s
Altitude 5 Click context object.
Definition: altitude5.h:114
altitude5_cfg_t::i2c_address
uint8_t i2c_address
Definition: altitude5.h:148
altitude5_s::adc
analog_in_t adc
Definition: altitude5.h:115
altitude5_cfg_t::temperature_degree_celsius
float temperature_degree_celsius
Definition: altitude5.h:154
ALTITUDE5_DRV_SEL_I2C
@ ALTITUDE5_DRV_SEL_I2C
Definition: altitude5.h:103
altitude5_cfg_setup
void altitude5_cfg_setup(altitude5_cfg_t *cfg)
Altitude 5 configuration object setup function.
altitude5_s::read_adc_f
altitude5_master_io_t read_adc_f
Definition: altitude5.h:125
altitude5_get_adc_voltage
err_t altitude5_get_adc_voltage(altitude5_t *ctx, float *adc_vtg)
Altitude 5 get ADC voltage function.
altitude5_s::i2c
i2c_master_t i2c
Definition: altitude5.h:118
ALTITUDE5_DRV_SEL_AN
@ ALTITUDE5_DRV_SEL_AN
Definition: altitude5.h:102
altitude5_s::temperature
float temperature
Definition: altitude5.h:129