altitude6 2.0.0.0
altitude6.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 ALTITUDE6_H
29#define ALTITUDE6_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#include "drv_spi_master.h"
53#include "spi_specifics.h"
54
75#define ALTITUDE6_CMD_RESET 0x1E
76#define ALTITUDE6_CMD_CONV_D1_OSR_256 0x40
77#define ALTITUDE6_CMD_CONV_D1_OSR_512 0x42
78#define ALTITUDE6_CMD_CONV_D1_OSR_1024 0x44
79#define ALTITUDE6_CMD_CONV_D1_OSR_2048 0x46
80#define ALTITUDE6_CMD_CONV_D1_OSR_4096 0x48
81#define ALTITUDE6_CMD_CONV_D2_OSR_256 0x50
82#define ALTITUDE6_CMD_CONV_D2_OSR_512 0x52
83#define ALTITUDE6_CMD_CONV_D2_OSR_1024 0x54
84#define ALTITUDE6_CMD_CONV_D2_OSR_2048 0x56
85#define ALTITUDE6_CMD_CONV_D2_OSR_4096 0x58
86#define ALTITUDE6_CMD_ADC_READ 0x00
87#define ALTITUDE6_CMD_PROM_READ_START 0xA0
88
89 // altitude6_reg
90
105#define ALTITUDE6_RATIO_256 0x00
106#define ALTITUDE6_RATIO_512 0x01
107#define ALTITUDE6_RATIO_1024 0x02
108#define ALTITUDE6_RATIO_2048 0x03
109#define ALTITUDE6_RATIO_4096 0x04
110
116#define ALTITUDE6_SET_DEV_ADDR_1 0x76
117#define ALTITUDE6_SET_DEV_ADDR_0 0x77
118
127#define ALTITUDE6_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
128#define ALTITUDE6_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
129
130 // altitude6_set
131
146#define ALTITUDE6_MAP_MIKROBUS( cfg, mikrobus ) \
147 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
148 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
149 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
150 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
151 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
152 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS )
153
154 // altitude6_map
155 // altitude6
156
167
172typedef err_t ( *altitude6_master_io_t )( struct altitude6_s*, uint8_t, uint8_t*, uint8_t );
203
208typedef struct
209{
210 pin_name_t scl;
211 pin_name_t sda;
212 pin_name_t miso;
213 pin_name_t mosi;
214 pin_name_t sck;
215 pin_name_t cs;
217 uint32_t i2c_speed;
218 uint8_t i2c_address;
220 uint32_t spi_speed;
221 spi_master_mode_t spi_mode;
222 spi_master_chip_select_polarity_t cs_polarity;
229
240
257
273
289
304
319err_t altitude6_set_command ( altitude6_t *ctx, uint8_t cmd );
320
337err_t altitude6_generic_read ( altitude6_t *ctx, uint8_t cmd, uint8_t *data_out, uint8_t len );
338
354err_t altitude6_set_ratio ( altitude6_t *ctx, uint8_t temp_ratio, uint8_t press_ratio );
355
370
385
401err_t altitude6_get_raw_data ( altitude6_t *ctx, uint32_t *temp_data, uint32_t *press_data );
402
417err_t altitude6_get_temperature ( altitude6_t *ctx, float *temperature );
418
433err_t altitude6_get_pressure ( altitude6_t *ctx, float *pressure );
434
453err_t altitude6_get_data ( altitude6_t *ctx, float *temperature, float *pressure, float *altitude );
454
455
456
457#ifdef __cplusplus
458}
459#endif
460#endif // ALTITUDE6_H
461
462 // altitude6
463
464// ------------------------------------------------------------------------ END
altitude6_return_value_t
Altitude 6 Click return value data.
Definition altitude6.h:235
@ ALTITUDE6_OK
Definition altitude6.h:236
@ ALTITUDE6_ERROR
Definition altitude6.h:237
err_t(* altitude6_master_io_t)(struct altitude6_s *, uint8_t, uint8_t *, uint8_t)
Altitude 6 Click driver interface.
Definition altitude6.h:172
altitude6_drv_t
Altitude 6 Click driver selector.
Definition altitude6.h:162
@ ALTITUDE6_DRV_SEL_I2C
Definition altitude6.h:164
@ ALTITUDE6_DRV_SEL_SPI
Definition altitude6.h:163
struct altitude6_s altitude6_t
Altitude 6 Click context object.
err_t altitude6_get_raw_data(altitude6_t *ctx, uint32_t *temp_data, uint32_t *press_data)
Altitude 6 get raw data function.
err_t altitude6_get_pressure(altitude6_t *ctx, float *pressure)
Altitude 6 get pressure data function.
err_t altitude6_get_data(altitude6_t *ctx, float *temperature, float *pressure, float *altitude)
Altitude 6 get data function.
void altitude6_cfg_setup(altitude6_cfg_t *cfg)
Altitude 6 configuration object setup function.
err_t altitude6_init(altitude6_t *ctx, altitude6_cfg_t *cfg)
Altitude 6 initialization function.
err_t altitude6_set_ratio(altitude6_t *ctx, uint8_t temp_ratio, uint8_t press_ratio)
Altitude 6 set data ratio function.
err_t altitude6_sw_reset(altitude6_t *ctx)
Altitude 6 software reset function.
void altitude6_drv_interface_selection(altitude6_cfg_t *cfg, altitude6_drv_t drv_sel)
Altitude 6 driver interface setup function.
err_t altitude6_generic_read(altitude6_t *ctx, uint8_t cmd, uint8_t *data_out, uint8_t len)
Altitude 6 data reading function.
err_t altitude6_default_cfg(altitude6_t *ctx)
Altitude 6 default configuration function.
err_t altitude6_get_calibration_data(altitude6_t *ctx)
Altitude 6 get calibration data function.
err_t altitude6_set_command(altitude6_t *ctx, uint8_t cmd)
Altitude 6 set command function.
err_t altitude6_get_temperature(altitude6_t *ctx, float *temperature)
Altitude 6 get temperature data function.
This file contains SPI specific macros, functions, etc.
Altitude 6 Click configuration object.
Definition altitude6.h:209
altitude6_drv_t drv_sel
Definition altitude6.h:224
uint32_t i2c_speed
Definition altitude6.h:217
spi_master_chip_select_polarity_t cs_polarity
Definition altitude6.h:222
pin_name_t sck
Definition altitude6.h:214
spi_master_mode_t spi_mode
Definition altitude6.h:221
float sea_level_pressure
Definition altitude6.h:226
pin_name_t mosi
Definition altitude6.h:213
uint32_t spi_speed
Definition altitude6.h:220
pin_name_t scl
Definition altitude6.h:210
pin_name_t miso
Definition altitude6.h:212
pin_name_t sda
Definition altitude6.h:211
pin_name_t cs
Definition altitude6.h:215
uint8_t i2c_address
Definition altitude6.h:218
Altitude 6 Click context object.
Definition altitude6.h:179
uint16_t press_tcs_c3
Definition altitude6.h:194
spi_master_t spi
Definition altitude6.h:181
altitude6_master_io_t write_f
Definition altitude6.h:187
altitude6_drv_t drv_sel
Definition altitude6.h:185
uint16_t press_sens_c1
Definition altitude6.h:192
float sea_lvl_pressure
Definition altitude6.h:190
altitude6_master_io_t read_f
Definition altitude6.h:188
uint16_t press_tempsens_c6
Definition altitude6.h:197
uint16_t press_tco_c4
Definition altitude6.h:195
i2c_master_t i2c
Definition altitude6.h:180
uint8_t ratio_temp
Definition altitude6.h:199
uint16_t press_tref_c5
Definition altitude6.h:196
uint8_t slave_address
Definition altitude6.h:183
pin_name_t chip_select
Definition altitude6.h:184
uint16_t press_off_c2
Definition altitude6.h:193
uint8_t ratio_press
Definition altitude6.h:200