pressure15 2.0.0.0
pressure15.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 PRESSURE15_H
29#define PRESSURE15_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
74#define PRESSURE15_REG_INTERRUPT_CFG 0x0B
75#define PRESSURE15_REG_THS_P_L 0x0C
76#define PRESSURE15_REG_THS_P_H 0x0D
77#define PRESSURE15_REG_IF_CTRL 0x0E
78#define PRESSURE15_REG_WHO_AM_I 0x0F
79#define PRESSURE15_REG_CTRL_REG1 0x10
80#define PRESSURE15_REG_CTRL_REG2 0x11
81#define PRESSURE15_REG_CTRL_REG3 0x12
82#define PRESSURE15_REG_FIFO_CTRL 0x13
83#define PRESSURE15_REG_FIFO_WTM 0x14
84#define PRESSURE15_REG_REF_PL_L 0x15
85#define PRESSURE15_REG_REF_PL_H 0x16
86#define PRESSURE15_REG_RPDS_L 0x18
87#define PRESSURE15_REG_RPDS_H 0x19
88#define PRESSURE15_REG_INT_SOURCE 0x24
89#define PRESSURE15_REG_FIFO_STATUS1 0x25
90#define PRESSURE15_REG_FIFO_STATUS2 0x26
91#define PRESSURE15_REG_STATUS 0x27
92#define PRESSURE15_REG_PRESSURE_OUT_XL 0x28
93#define PRESSURE15_REG_PRESSURE_OUT_L 0x29
94#define PRESSURE15_REG_PRESSURE_OUT_H 0x2A
95#define PRESSURE15_REG_TEMP_OUT_L 0x2B
96#define PRESSURE15_REG_TEMP_OUT_H 0x2C
97#define PRESSURE15_REG_LPFP_RES 0x3C
98#define PRESSURE15_REG_FIFO_DATA_OUT_PRESS_XL 0x78
99#define PRESSURE15_REG_FIFO_DATA_OUT_PRESS_L 0x79
100#define PRESSURE15_REG_FIFO_DATA_OUT_PRESS_H 0x7A
101#define PRESSURE15_REG_FIFO_DATA_OUT_TEMP_L 0x7B
102#define PRESSURE15_REG_FIFO_DATA_OUT_TEMP_H 0x7C
103
104 // pressure15_reg
105
120#define PRESSURE15_ID 0xB3
121
127#define PRESSURE15_SET_DEV_ADDR 0x5C
128
129 // pressure15_set
130
145#define PRESSURE15_MAP_MIKROBUS( cfg, mikrobus ) \
146 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
147 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
148 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
149 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
150 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
151 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
152 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
153
154 // pressure15_map
155 // pressure15
156
167
172typedef err_t ( *pressure15_master_io_t )( struct pressure15_s*, uint8_t, uint8_t*, uint8_t );
194
199typedef struct
200{
201 pin_name_t scl;
202 pin_name_t sda;
203 pin_name_t miso;
204 pin_name_t mosi;
205 pin_name_t sck;
206 pin_name_t cs;
207 pin_name_t int_pin;
209 uint32_t i2c_speed;
210 uint8_t i2c_address;
212 uint32_t spi_speed;
213 spi_master_mode_t spi_mode;
214 spi_master_chip_select_polarity_t cs_polarity;
219
230
247
263
279
294
309err_t pressure15_generic_write ( pressure15_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len );
310
325err_t pressure15_generic_read ( pressure15_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len );
326
335
347err_t pressure15_get_temperature ( pressure15_t *ctx, float *temperature );
348
360err_t pressure15_get_pressure ( pressure15_t *ctx, float *pressure );
361
362#ifdef __cplusplus
363}
364#endif
365#endif // PRESSURE15_H
366
367 // pressure15
368
369// ------------------------------------------------------------------------ END
err_t pressure15_default_cfg(pressure15_t *ctx)
Pressure 15 default configuration function.
uint8_t pressure15_get_int(pressure15_t *ctx)
Get interrupt pin state.
err_t pressure15_get_temperature(pressure15_t *ctx, float *temperature)
Get temperature data.
err_t pressure15_generic_read(pressure15_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Pressure 15 data reading function.
void pressure15_cfg_setup(pressure15_cfg_t *cfg)
Pressure 15 configuration object setup function.
err_t pressure15_init(pressure15_t *ctx, pressure15_cfg_t *cfg)
Pressure 15 initialization function.
err_t pressure15_get_pressure(pressure15_t *ctx, float *pressure)
Get pressure data.
err_t pressure15_generic_write(pressure15_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Pressure 15 data writing function.
void pressure15_drv_interface_selection(pressure15_cfg_t *cfg, pressure15_drv_t drv_sel)
Pressure 15 driver interface setup function.
pressure15_drv_t
Pressure 15 Click driver selector.
Definition pressure15.h:162
@ PRESSURE15_DRV_SEL_I2C
Definition pressure15.h:164
@ PRESSURE15_DRV_SEL_SPI
Definition pressure15.h:163
pressure15_return_value_t
Pressure 15 Click return value data.
Definition pressure15.h:225
@ PRESSURE15_ERROR
Definition pressure15.h:227
@ PRESSURE15_OK
Definition pressure15.h:226
err_t(* pressure15_master_io_t)(struct pressure15_s *, uint8_t, uint8_t *, uint8_t)
Pressure 15 Click driver interface.
Definition pressure15.h:172
struct pressure15_s pressure15_t
Pressure 15 Click context object.
Pressure 15 Click configuration object.
Definition pressure15.h:200
pressure15_drv_t drv_sel
Definition pressure15.h:216
uint32_t i2c_speed
Definition pressure15.h:209
spi_master_chip_select_polarity_t cs_polarity
Definition pressure15.h:214
pin_name_t sck
Definition pressure15.h:205
spi_master_mode_t spi_mode
Definition pressure15.h:213
pin_name_t mosi
Definition pressure15.h:204
uint32_t spi_speed
Definition pressure15.h:212
pin_name_t scl
Definition pressure15.h:201
pin_name_t int_pin
Definition pressure15.h:207
pin_name_t miso
Definition pressure15.h:203
pin_name_t sda
Definition pressure15.h:202
pin_name_t cs
Definition pressure15.h:206
uint8_t i2c_address
Definition pressure15.h:210
Pressure 15 Click context object.
Definition pressure15.h:180
pressure15_drv_t drv_sel
Definition pressure15.h:188
spi_master_t spi
Definition pressure15.h:184
digital_in_t int_pin
Definition pressure15.h:181
i2c_master_t i2c
Definition pressure15.h:183
pressure15_master_io_t write_f
Definition pressure15.h:190
uint8_t slave_address
Definition pressure15.h:186
pin_name_t chip_select
Definition pressure15.h:187
pressure15_master_io_t read_f
Definition pressure15.h:191