42#ifdef PREINIT_SUPPORTED
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_i2c_master.h"
55#include "drv_spi_master.h"
68#define BAROMETER_MAP_MIKROBUS( cfg, mikrobus ) \
69 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
70 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
71 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
72 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
73 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
74 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
75 cfg.rdy = MIKROBUS( mikrobus, MIKROBUS_INT )
82#define BAROMETER_MASTER_I2C 0
83#define BAROMETER_MASTER_SPI 1
90#define BAROMETER_RETVAL uint8_t
92#define BAROMETER_OK 0x00
93#define BAROMETER_INIT_ERROR 0xFF
100 #define BAROMETER_I2C_ADDRESS_0 0x5C
107 #define BAROMETER_I2C_ADDRESS_1 0x5D
114 #define BAROMETER_REF_P_XL 0x08
115 #define BAROMETER_REF_P_L 0x09
116 #define BAROMETER_REF_P_H 0x0A
123 #define BAROMETER_WHO_AM_I 0x0F
130 #define BAROMETER_RES_CONF 0x10
131 #define BAROMETER_CTRL_REG1 0x20
132 #define BAROMETER_CTRL_REG2 0x21
133 #define BAROMETER_CTRL_REG3 0x22
134 #define BAROMETER_CTRL_REG4 0x23
135 #define BAROMETER_INTERRUPT_CFG 0x24
136 #define BAROMETER_INT_SOURCE 0x25
137 #define BAROMETER_STATUS_REG 0x27
138 #define BAROMETER_PRESS_OUT_XL 0x28
139 #define BAROMETER_PRESS_OUT_L 0x29
140 #define BAROMETER_PRESS_OUT_H 0x2A
141 #define BAROMETER_TEMP_OUT_L 0x2B
142 #define BAROMETER_TEMP_OUT_H 0x2C
143 #define BAROMETER_FIFO_CTRL 0x2E
144 #define BAROMETER_FIFO_STATUS 0x2F
145 #define BAROMETER_THS_P_L 0x30
146 #define BAROMETER_THS_P_H 0x31
147 #define BAROMETER_RPDS_L 0x39
148 #define BAROMETER_RPDS_H 0x3A
149 #define BAROMETER_DEVICE_ID 0xBD
156 #define BAROMETER_DEFAULT_CONFIG 0xB0
157 #define BAROMETER_CONFIG_ACTIVE_MODE 0x80
#define BAROMETER_RETVAL
Definition barometer.h:90
void barometer_cfg_setup(barometer_cfg_t *cfg)
Config Object Initialization function.
uint8_t barometer_check_status(barometer_t *ctx)
Check sensor status function.
void barometer_generic_write(barometer_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
uint8_t barometer_check_id(barometer_t *ctx)
Check sensor id - Who Am I function.
void barometer_set_active(barometer_t *ctx)
Sets the module active function.
uint8_t barometer_check_interrupt(barometer_t *ctx)
State of interrupt pin function.
float barometer_get_pressure(barometer_t *ctx)
Read pressure in milibars function.
void barometer_generic_read(barometer_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
uint8_t barometer_read_data(barometer_t *ctx, uint8_t address)
Generic read 8-bit data function.
float barometer_get_temperature_f(barometer_t *ctx)
Read temperature in degrees of Fahrenheit function.
float barometer_get_temperature_c(barometer_t *ctx)
Read temperature in degrees Celsius function.
BAROMETER_RETVAL barometer_init(barometer_t *ctx, barometer_cfg_t *cfg)
Initialization function.
void barometer_default_cfg(barometer_t *ctx)
Click Default Configuration function.
struct barometer_s barometer_t
Click ctx object definition.
uint8_t barometer_select_t
Communication type.
Definition barometer.h:172
void(* barometer_master_io_t)(struct barometer_s *, uint8_t, uint8_t *, uint8_t)
Master Input/Output type.
Definition barometer.h:177
Click configuration structure definition.
Definition barometer.h:209
uint32_t i2c_speed
Definition barometer.h:225
spi_master_chip_select_polarity_t cs_polarity
Definition barometer.h:230
pin_name_t sck
Definition barometer.h:216
spi_master_mode_t spi_mode
Definition barometer.h:229
pin_name_t mosi
Definition barometer.h:215
uint32_t spi_speed
Definition barometer.h:228
pin_name_t scl
Definition barometer.h:212
pin_name_t rdy
Definition barometer.h:221
pin_name_t miso
Definition barometer.h:214
pin_name_t sda
Definition barometer.h:213
pin_name_t cs
Definition barometer.h:217
barometer_select_t sel
Definition barometer.h:232
uint8_t i2c_address
Definition barometer.h:226
Click ctx object definition.
Definition barometer.h:183
digital_out_t cs
Definition barometer.h:184
barometer_master_io_t write_f
Definition barometer.h:199
spi_master_t spi
Definition barometer.h:193
barometer_select_t master_sel
Definition barometer.h:201
barometer_master_io_t read_f
Definition barometer.h:200
i2c_master_t i2c
Definition barometer.h:192
uint8_t slave_address
Definition barometer.h:197
pin_name_t chip_select
Definition barometer.h:198
digital_in_t rdy
Definition barometer.h:188