altitude3 2.0.0.0
altitude3.h
Go to the documentation of this file.
1/*
2 * MikroSDK - MikroE Software Development Kit
3 * Copyright© 2020 MikroElektronika d.o.o.
4 *
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without restriction,
8 * including without limitation the rights to use, copy, modify, merge,
9 * publish, distribute, sublicense, and/or sell copies of the Software,
10 * and to permit persons to whom the Software is furnished to do so,
11 * subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22 * OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
33// ----------------------------------------------------------------------------
34
35#ifndef ALTITUDE3_H
36#define ALTITUDE3_H
37
42#ifdef PREINIT_SUPPORTED
43#include "preinit.h"
44#endif
45
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
48 #include "delays.h"
49 #endif
50#endif
51
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_i2c_master.h"
55
56#include "math.h"
57#include "string.h"
58
59// -------------------------------------------------------------- PUBLIC MACROS
69#define ALTITUDE3_MAP_MIKROBUS( cfg, mikrobus ) \
70 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
71 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
78#define ALTITUDE3_RETVAL uint8_t
79
80#define ALTITUDE3_OK 0x00
81#define ALTITUDE3_INIT_ERROR 0xFF
84#define ALTITUDE3_SLAVE_ADDR 0x63
85
86#define ALTITUDE3_LOW_POWER_T_FIRST 0x609C
87#define ALTITUDE3_LOW_POWER_P_FIRST 0x401A
88#define ALTITUDE3_NORMAL_T_FIRST 0x6825
89#define ALTITUDE3_NORMAL_P_FIRST 0x48A3
90#define ALTITUDE3_LOW_NOISE_T_FIRST 0x70DF
91#define ALTITUDE3_LOW_NOISE_P_FIRST 0x5059
92#define ALTITUDE3_ULTRA_LOW_NOISE_T_FIRST 0x7866
93#define ALTITUDE3_ULTRA_LOW_NOISE_P_FIRST 0x58E0
94
95#define ALTITUDE3_OK 0x00
96#define ALTITUDE3_T_FIRST_ORDER 0x01
97#define ALTITUDE3_P_FIRST_ORDER 0x02
98#define ALTITUDE3_INITIALIZED 0x03
99#define ALTITUDE3_ERROR 0xFF
100
101 // End group macro
102// --------------------------------------------------------------- PUBLIC TYPES
108typedef struct
109{
110
111 uint32_t min_delay_us;
112 uint16_t sensor_const[ 4 ];
113 uint32_t p_pa_calib[ 3 ];
117 uint16_t offst_factor;
118
120
121typedef struct
122{
123 //Sensor data
124
125 int8_t temperature;
126 uint32_t pressure;
127 int16_t altitude;
128
130
134typedef struct
135{
136 // Modules
137
138 i2c_master_t i2c;
139
140 // ctx variable
141
143
145
147
149
153typedef struct
154{
155 // Communication gpio pins
156
157 pin_name_t scl;
158 pin_name_t sda;
159
160 // static variable
161
162 uint32_t i2c_speed;
163 uint8_t i2c_address;
164
166
168
169 // End types group
170// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
171
177#ifdef __cplusplus
178extern "C"{
179#endif
180
190
200
209
220void altitude3_generic_write ( altitude3_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
221
233void altitude3_generic_read ( altitude3_t *ctx, uint8_t *reg_buf, uint8_t *data_buf, uint8_t len );
234
245uint8_t altitude3_measurement_mode ( altitude3_t *ctx, uint16_t mode_cmd );
246
256
269uint8_t altitude3_read_adc_results ( altitude3_t *ctx, uint8_t read_order, int16_t *temperature, uint32_t *pressure );
270
280
294uint8_t altitude3_get_data ( altitude3_t *ctx, uint8_t read_order );
295
296#ifdef __cplusplus
297}
298#endif
299#endif // _ALTITUDE3_H_
300
301 // End public_function group
303
304// ------------------------------------------------------------------------- END
#define ALTITUDE3_RETVAL
Definition altitude3.h:78
uint8_t altitude3_measurement_mode(altitude3_t *ctx, uint16_t mode_cmd)
Set Measurement Mode function.
uint8_t altitude3_read_adc_results(altitude3_t *ctx, uint8_t read_order, int16_t *temperature, uint32_t *pressure)
Read AD Conversion function.
void altitude3_soft_reset(altitude3_t *ctx)
Software Reset function.
ALTITUDE3_RETVAL altitude3_init(altitude3_t *ctx, altitude3_cfg_t *cfg)
Initialization function.
void altitude3_default_cfg(altitude3_t *ctx)
Click Default Configuration function.
void altitude3_generic_write(altitude3_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
void altitude3_init_cfg(altitude3_t *ctx, altitude3_param_t *s)
Init configuration function.
void altitude3_cfg_setup(altitude3_cfg_t *cfg)
Config Object Initialization function.
uint8_t altitude3_get_data(altitude3_t *ctx, uint8_t read_order)
Get Data function.
void altitude3_generic_read(altitude3_t *ctx, uint8_t *reg_buf, uint8_t *data_buf, uint8_t len)
Generic read function.
Click configuration structure definition.
Definition altitude3.h:154
uint8_t update_check_cfg
Definition altitude3.h:165
uint32_t i2c_speed
Definition altitude3.h:162
pin_name_t scl
Definition altitude3.h:157
pin_name_t sda
Definition altitude3.h:158
uint8_t i2c_address
Definition altitude3.h:163
Definition altitude3.h:109
float lut_lower
Definition altitude3.h:114
uint32_t min_delay_us
Definition altitude3.h:111
float lut_upper
Definition altitude3.h:115
uint16_t offst_factor
Definition altitude3.h:117
double quadr_factor
Definition altitude3.h:116
Click ctx object definition.
Definition altitude3.h:135
i2c_master_t i2c
Definition altitude3.h:138
uint8_t update_check
Definition altitude3.h:144
uint8_t slave_address
Definition altitude3.h:142
sensor_data_t sens_data
Definition altitude3.h:146
Definition altitude3.h:122
uint32_t pressure
Definition altitude3.h:126
int16_t altitude
Definition altitude3.h:127
int8_t temperature
Definition altitude3.h:125