39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
52#include "drv_spi_master.h"
75#define BAROMETER9_REG_PART_ID0 0x00
76#define BAROMETER9_REG_PART_ID1 0x01
77#define BAROMETER9_REG_UIND0 0x02
78#define BAROMETER9_REG_UIND1 0x03
79#define BAROMETER9_REG_UIND2 0x04
80#define BAROMETER9_REG_UIND3 0x05
81#define BAROMETER9_MODE_CFG 0x06
82#define BAROMETER9_MEAS_CFG 0x07
83#define BAROMETER9_STBY_CFG 0x08
84#define BAROMETER9_OVS_CFG 0x09
85#define BAROMETER9_MAVG_CFG 0x0A
86#define BAROMETER9_INTF_CFG 0x0B
87#define BAROMETER9_INT_CFG 0x0C
88#define BAROMETER9_PRESS_LO_XL_CFG 0x0D
89#define BAROMETER9_PRESS_LO_L_CFG 0x0E
90#define BAROMETER9_PRESS_LO_H_CFG 0x0F
91#define BAROMETER9_PRESS_HI_XL_CFG 0x10
92#define BAROMETER9_PRESS_HI_L_CFG 0x11
93#define BAROMETER9_PRESS_HI_H_CFG 0x12
94#define BAROMETER9_FIFO_CFG 0x13
95#define BAROMETER9_DATA_STAT 0x14
96#define BAROMETER9_FIFO_STAT 0x15
97#define BAROMETER9_INT_STAT 0x16
98#define BAROMETER9_PRESS_OUT_XL 0x17
99#define BAROMETER9_PRESS_OUT_L 0x18
100#define BAROMETER9_PRESS_OUT_H 0x19
101#define BAROMETER9_TEMP_OUT_L 0x1A
102#define BAROMETER9_TEMP_OUT_H 0x1B
103#define BAROMETER9_PRESS_OUT_F_XL 0x27
104#define BAROMETER9_PRESS_OUT_F_L 0x28
105#define BAROMETER9_PRESS_OUT_F_H 0x29
123#define BAROMETER9_HIGH_POWER_MODE 0x80
124#define BAROMETER9_LOW_POWER_MODE 0x00
125#define BAROMETER9_DIRECT_PATH 0x00
126#define BAROMETER9_FIFO_MODE 0x20
127#define BAROMETER9_AVERAGE_MODE 0x40
128#define BAROMETER9_IDLE_MODE 0x00
129#define BAROMETER9_MEASURMENT_MODE 0x10
130#define BAROMETER9_SW_RESET 0x08
131#define BAROMETER9_READ_PRESS_ONLY 0x01
132#define BAROMETER9_READ_TEMP_ONLY 0x02
133#define BAROMETER9_READ_PRES_AND_TEMP 0x03
139#define BAROMETER9_P_CONV_0 0x00
140#define BAROMETER9_P_CONV_1 0x08
141#define BAROMETER9_P_CONV_2 0x10
142#define BAROMETER9_PT_RATE_1 0x00
143#define BAROMETER9_PT_RATE_4 0x01
144#define BAROMETER9_PT_RATE_8 0x02
145#define BAROMETER9_PT_RATE_16 0x03
146#define BAROMETER9_PT_RATE_32 0x04
147#define BAROMETER9_PT_RATE_64 0x05
148#define BAROMETER9_PT_RATE_128 0x06
149#define BAROMETER9_PT_RATE_256 0x07
155#define BAROMETER9_TEMPERATURE_CON_CONST 128
156#define BAROMETER9_K_TO_C_CON_CONST 273.15f
157#define BAROMETER9_PRESSURE_CON_CONST 64
163#define BAROMETER9_DEVICE_ID 0x0321
170#define BAROMETER9_DEVICE_ADDRESS 0x20
180#define BAROMETER9_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
181#define BAROMETER9_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
199#define BAROMETER9_MAP_MIKROBUS( cfg, mikrobus ) \
200 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
201 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
202 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
203 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
204 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
205 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
206 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
barometer9_return_value_t
Barometer 9 Click return value data.
Definition barometer9.h:279
@ BAROMETER9_ERROR
Definition barometer9.h:281
@ BAROMETER9_OK
Definition barometer9.h:280
struct barometer9_s barometer9_t
Barometer 9 Click context object.
barometer9_drv_t
Barometer 9 Click driver selector.
Definition barometer9.h:216
@ BAROMETER9_DRV_SEL_SPI
Definition barometer9.h:217
@ BAROMETER9_DRV_SEL_I2C
Definition barometer9.h:218
err_t(* barometer9_master_io_t)(struct barometer9_s *, uint8_t, uint8_t *, uint8_t)
Definition barometer9.h:227
err_t barometer9_generic_read(barometer9_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Barometer 9 data reading function.
void barometer9_cfg_setup(barometer9_cfg_t *cfg)
Barometer 9 configuration object setup function.
err_t barometer9_init(barometer9_t *ctx, barometer9_cfg_t *cfg)
Barometer 9 initialization function.
err_t barometer9_read_part_id(barometer9_t *ctx, uint16_t *part_id)
Barometer 9 Device ID reading function.
err_t barometer9_get_temperature(barometer9_t *ctx, float *temperature)
Barometer 9 temperature reading function.
err_t barometer9_get_pressure(barometer9_t *ctx, float *pressure)
Barometer 9 pressure reading function.
err_t barometer9_generic_write(barometer9_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Barometer 9 data writing function.
err_t barometer9_default_cfg(barometer9_t *ctx)
Barometer 9 default configuration function.
err_t barometer9_sw_reset(barometer9_t *ctx)
Barometer 9 software reset function.
void barometer9_drv_interface_sel(barometer9_cfg_t *cfg, barometer9_drv_t drv_sel)
Barometer 9 driver interface setup function.
This file contains SPI specific macros, functions, etc.
Barometer 9 Click configuration object.
Definition barometer9.h:254
uint32_t i2c_speed
Definition barometer9.h:263
spi_master_chip_select_polarity_t cs_polarity
Definition barometer9.h:268
barometer9_drv_t drv_sel
Definition barometer9.h:270
pin_name_t sck
Definition barometer9.h:259
spi_master_mode_t spi_mode
Definition barometer9.h:267
pin_name_t mosi
Definition barometer9.h:258
uint32_t spi_speed
Definition barometer9.h:266
pin_name_t scl
Definition barometer9.h:255
pin_name_t int_pin
Definition barometer9.h:261
pin_name_t miso
Definition barometer9.h:257
pin_name_t sda
Definition barometer9.h:256
pin_name_t cs
Definition barometer9.h:260
uint8_t i2c_address
Definition barometer9.h:264
Barometer 9 Click context object.
Definition barometer9.h:234
spi_master_t spi
Definition barometer9.h:238
barometer9_master_io_t write_f
Definition barometer9.h:244
barometer9_drv_t drv_sel
Definition barometer9.h:242
digital_in_t int_pin
Definition barometer9.h:235
i2c_master_t i2c
Definition barometer9.h:237
uint8_t slave_address
Definition barometer9.h:240
pin_name_t chip_select
Definition barometer9.h:241
barometer9_master_io_t read_f
Definition barometer9.h:245