barometer6 2.0.0.0
barometer6.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 BAROMETER6_H
29#define BAROMETER6_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 BAROMETER6_TEMP_TXD0 0xFC
76#define BAROMETER6_TEMP_TXD1 0xFB
77#define BAROMETER6_TEMP_TXD2 0xFA
78#define BAROMETER6_PRESS_TXD0 0xF9
79#define BAROMETER6_PRESS_TXD1 0xF8
80#define BAROMETER6_PRESS_TXD2 0xF7
81#define BAROMETER6_IO_SETUP 0xF5
82#define BAROMETER6_CTRL_MESS 0xF4
83#define BAROMETER6_DEVICE_STAT 0xF3
84#define BAROMETER6_I2C_SET 0xF2
85#define BAROMETER6_IIR_CNT 0XF1
86#define BAROMETER6_RESET 0XE0
87#define BAROMETER6_CHIP_ID 0XD1
88#define BAROMETER6_COE_B00_A0_EX 0XB8
89#define BAROMETER6_COE_A2_0 0XB7
90#define BAROMETER6_COE_A2_1 0XB6
91#define BAROMETER6_COE_A1_0 0XB5
92#define BAROMETER6_COE_A1_1 0XB4
93#define BAROMETER6_COE_A0_0 0XB3
94#define BAROMETER6_COE_A0_1 0XB2
95#define BAROMETER6_COE_BP3_0 0XB1
96#define BAROMETER6_COE_BP3_1 0XB0
97#define BAROMETER6_COE_B21_0 0XAF
98#define BAROMETER6_COE_B21_1 0XAE
99#define BAROMETER6_COE_B12_0 0XAD
100#define BAROMETER6_COE_B12_1 0XAC
101#define BAROMETER6_COE_BP2_0 0XAB
102#define BAROMETER6_COE_BP2_1 0XAA
103#define BAROMETER6_COE_B11_0 0XA9
104#define BAROMETER6_COE_B11_1 0XA8
105#define BAROMETER6_COE_BP1_0 0XA7
106#define BAROMETER6_COE_BP1_1 0XA6
107#define BAROMETER6_COE_BT2_0 0XA5
108#define BAROMETER6_COE_BT2_1 0XA4
109#define BAROMETER6_COE_BT1_0 0XA3
110#define BAROMETER6_COE_BT1_1 0XA2
111#define BAROMETER6_COE_B00_0 0XA1
112#define BAROMETER6_COE_B00_1 0XA0
113
114 // barometer6_reg
115
135#define BAROMETER6_CMD_RESET 0xE6
136
141#define BAROMETER6_AVG_SKIP 0x00
142#define BAROMETER6_AVG_1 0x01
143#define BAROMETER6_AVG_2 0x02
144#define BAROMETER6_AVG_4 0x03
145#define BAROMETER6_AVG_8 0x04
146#define BAROMETER6_AVG_16 0x05
147#define BAROMETER6_AVG_32 0x06
148#define BAROMETER6_AVG_64 0x07
149
154#define BAROMETER6_SLEEP_MODE 0x00
155#define BAROMETER6_FORCED_MODE_1 0x01
156#define BAROMETER6_FORCED_MODE_2 0x02
157#define BAROMETER6_NORMAL_MODE 0x03
158
163#define BAROMETER6_DATA_NOT_READY 0x00
164#define BAROMETER6_DATA_READY 0x01
165
170#define BAROMETER6_STANDBY_1ms 0x00
171#define BAROMETER6_STANDBY_5ms 0x01
172#define BAROMETER6_STANDBY_50ms 0x02
173#define BAROMETER6_STANDBY_250ms 0x03
174#define BAROMETER6_STANDBY_500ms 0x04
175#define BAROMETER6_STANDBY_1s 0x05
176#define BAROMETER6_STANDBY_2s 0x06
177#define BAROMETER6_STANDBY_4s 0x07
178
183#define BAROMETER6_ID_VALUE 0x5C
184
190#define BAROMETER6_SET_DEV_ADDR_LOW 0x70
191#define BAROMETER6_SET_DEV_ADDR_HIGH 0x56
192
201#define BAROMETER6_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
202#define BAROMETER6_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
203
204 // barometer6_set
205
220#define BAROMETER6_MAP_MIKROBUS( cfg, mikrobus ) \
221 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
222 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
223 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
224 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
225 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
226 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
227 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST )
228 // barometer6_map
229 // barometer6
230
241
246typedef err_t ( *barometer6_master_io_t )( struct barometer6_s*, uint8_t, uint8_t*, uint8_t );
281
286typedef struct
287{
288 pin_name_t scl;
289 pin_name_t sda;
290 pin_name_t miso;
291 pin_name_t mosi;
292 pin_name_t sck;
293 pin_name_t cs;
294 pin_name_t rst;
296 uint32_t i2c_speed;
297 uint8_t i2c_address;
299 uint32_t spi_speed;
300 spi_master_mode_t spi_mode;
301 spi_master_chip_select_polarity_t cs_polarity;
306
317
334
350
365
378
393err_t barometer6_generic_write ( barometer6_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len );
394
409err_t barometer6_generic_read ( barometer6_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len );
410
420void barometer6_write_register ( barometer6_t *ctx, uint8_t reg, uint8_t data_in );
421
432void barometer6_read_register ( barometer6_t *ctx, uint8_t reg, uint16_t *data_out );
433
442void barometer6_read_id ( barometer6_t *ctx, uint8_t *data_out );
443
452
461
474void barometer6_set_avrege ( barometer6_t *ctx, uint8_t temp_avg, uint8_t pressure_avg );
475
484void barometer6_set_mode ( barometer6_t *ctx, uint8_t mode );
485
494void barometer6_set_standby_time ( barometer6_t *ctx, uint8_t t_standby );
495
505
514void barometer6_read_raw_temp ( barometer6_t *ctx, int32_t *data_out );
515
524void barometer6_read_raw_pressure ( barometer6_t *ctx, float *data_out );
525
536void barometer6_read_conp_coef ( barometer6_t *ctx, uint8_t reg, int16_t *data_out );
537
550void barometer6_get_conp_coef ( barometer6_t *ctx, uint8_t reg, float a_coef, float s_coef,
551 float *data_out );
552
563void barometer6_get_a0_b00_coef ( barometer6_t *ctx, float *coef_a0, float *coef_b00 );
564
574
583void barometer6_get_temperature_data ( barometer6_t *ctx, float *temp_out );
584
594void barometer6_read_temperature_value ( barometer6_t *ctx, float *temp_out );
595
605void barometer6_read_preassure_data ( barometer6_t *ctx, float *press_out );
606
616void barometer6_read_preassure_value ( barometer6_t *ctx, float *press_out );
617
618#ifdef __cplusplus
619}
620#endif
621#endif // BAROMETER6_H
622
623 // barometer6
624
625// ------------------------------------------------------------------------ END
barometer6_drv_t
Barometer 6 Click driver selector.
Definition barometer6.h:236
@ BAROMETER6_DRV_SEL_I2C
Definition barometer6.h:238
@ BAROMETER6_DRV_SEL_SPI
Definition barometer6.h:237
struct barometer6_s barometer6_t
Barometer 6 Click context object.
barometer6_return_value_t
Barometer 6 Click return value data.
Definition barometer6.h:312
@ BAROMETER6_OK
Definition barometer6.h:313
@ BAROMETER6_ERROR
Definition barometer6.h:314
err_t(* barometer6_master_io_t)(struct barometer6_s *, uint8_t, uint8_t *, uint8_t)
Barometer 6 Click driver interface.
Definition barometer6.h:246
void barometer6_read_raw_temp(barometer6_t *ctx, int32_t *data_out)
Barometer 6 read raw temperature function.
void barometer6_read_temperature_value(barometer6_t *ctx, float *temp_out)
Barometer 6 get temperature value function.
void barometer6_read_raw_pressure(barometer6_t *ctx, float *data_out)
Barometer 6 read raw pressure function.
void barometer6_read_preassure_value(barometer6_t *ctx, float *press_out)
Barometer 6 get preassure mBar function.
void barometer6_read_preassure_data(barometer6_t *ctx, float *press_out)
Barometer 6 get preassure data function.
void barometer6_get_conp_coef(barometer6_t *ctx, uint8_t reg, float a_coef, float s_coef, float *data_out)
Barometer 6 calculate conpensation coefficients data function.
void barometer6_default_cfg(barometer6_t *ctx)
Barometer 6 default configuration function.
void barometer6_read_conp_coef(barometer6_t *ctx, uint8_t reg, int16_t *data_out)
Barometer 6 read conpensation coefficients data function.
void barometer6_read_id(barometer6_t *ctx, uint8_t *data_out)
Barometer 6 Id reading function.
void barometer6_set_mode(barometer6_t *ctx, uint8_t mode)
Barometer 6 set operation mode function.
uint8_t barometer6_check_ready(barometer6_t *ctx)
Barometer 6 check if data is ready function.
void barometer6_get_conpesation_coe(barometer6_t *ctx)
Barometer 6 get all conpensation coefficients data function.
void barometer6_software_reset(barometer6_t *ctx)
Barometer 6 software reset function.
void barometer6_hardware_reset(barometer6_t *ctx)
Barometer 6 hardware reset function.
void barometer6_get_a0_b00_coef(barometer6_t *ctx, float *coef_a0, float *coef_b00)
Barometer 6 calculate a0 and b00 conpensation coefficients data function.
void barometer6_read_register(barometer6_t *ctx, uint8_t reg, uint16_t *data_out)
Barometer 6 data reading function.
void barometer6_get_temperature_data(barometer6_t *ctx, float *temp_out)
Barometer 6 get temperature data function.
void barometer6_write_register(barometer6_t *ctx, uint8_t reg, uint8_t data_in)
Barometer 6 data writing function.
err_t barometer6_generic_write(barometer6_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Barometer 6 data writing function.
void barometer6_set_standby_time(barometer6_t *ctx, uint8_t t_standby)
Barometer 6 set standby time function.
void barometer6_cfg_setup(barometer6_cfg_t *cfg)
Barometer 6 configuration object setup function.
void barometer6_set_avrege(barometer6_t *ctx, uint8_t temp_avg, uint8_t pressure_avg)
Barometer 6 set average data function.
err_t barometer6_generic_read(barometer6_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Barometer 6 data reading function.
void barometer6_drv_interface_selection(barometer6_cfg_t *cfg, barometer6_drv_t drv_sel)
Barometer 6 driver interface setup function.
err_t barometer6_init(barometer6_t *ctx, barometer6_cfg_t *cfg)
Barometer 6 initialization function.
This file contains SPI specific macros, functions, etc.
Barometer 6 Click configuration object.
Definition barometer6.h:287
uint32_t i2c_speed
Definition barometer6.h:296
spi_master_chip_select_polarity_t cs_polarity
Definition barometer6.h:301
pin_name_t sck
Definition barometer6.h:292
spi_master_mode_t spi_mode
Definition barometer6.h:300
pin_name_t mosi
Definition barometer6.h:291
uint32_t spi_speed
Definition barometer6.h:299
pin_name_t scl
Definition barometer6.h:288
pin_name_t miso
Definition barometer6.h:290
pin_name_t sda
Definition barometer6.h:289
barometer6_drv_t drv_sel
Definition barometer6.h:303
pin_name_t rst
Definition barometer6.h:294
pin_name_t cs
Definition barometer6.h:293
uint8_t i2c_address
Definition barometer6.h:297
Barometer 6 Click context object.
Definition barometer6.h:253
spi_master_t spi
Definition barometer6.h:257
float coef_b00
Definition barometer6.h:270
float coef_a0
Definition barometer6.h:266
float coef_a1
Definition barometer6.h:267
float coef_b21
Definition barometer6.h:277
barometer6_master_io_t write_f
Definition barometer6.h:263
float coef_bt1
Definition barometer6.h:271
float coef_bp3
Definition barometer6.h:278
float coef_bp1
Definition barometer6.h:272
float coef_a2
Definition barometer6.h:268
i2c_master_t i2c
Definition barometer6.h:256
barometer6_master_io_t read_f
Definition barometer6.h:264
float coef_bp2
Definition barometer6.h:275
digital_out_t rst
Definition barometer6.h:254
float coef_bt2
Definition barometer6.h:274
uint8_t slave_address
Definition barometer6.h:259
float coef_b11
Definition barometer6.h:273
float coef_b12
Definition barometer6.h:276
pin_name_t chip_select
Definition barometer6.h:260
barometer6_drv_t drv_sel
Definition barometer6.h:261