Go to the documentation of this file.
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 WEATHER_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 );
81 #define WEATHER_MASTER_I2C 0
82 #define WEATHER_MASTER_SPI 1
90 #define WEATHER_ERROR -1
97 #define WEATHER_DEF_CHIP_ID 0x60
98 #define WEATHER_SOFT_RESET 0xB6
105 #define WEATHER_I2C_ADDRESS_0 0x76
106 #define WEATHER_I2C_ADDRESS_1 0x77
113 #define WEATHER_REG_CHIP_ID 0xD0
114 #define WEATHER_REG_RESET 0xE0
115 #define WEATHER_REG_STATUS 0xF3
116 #define WEATHER_REG_CTRL_MEASUREMENT 0xF4
117 #define WEATHER_REG_CTRL_HUMIDITY 0xF2
118 #define WEATHER_REG_CONFIG 0xF5
119 #define WEATHER_REG_RAW_DATA 0xF7
120 #define WEATHER_REG_PRESSURE_MSB 0xF7
121 #define WEATHER_REG_PRESSURE_LSB 0xF8
122 #define WEATHER_REG_PRESSURE_XLSB 0xF9
123 #define WEATHER_REG_TEMPERATURE_MSB 0xFA
124 #define WEATHER_REG_TEMPERATURE_LSB 0xFB
125 #define WEATHER_REG_TEMPERATURE_XLSB 0xFC
126 #define WEATHER_REG_HUMIDITY_MSB 0xFD
127 #define WEATHER_REG_HUMIDITY_LSB 0xFE
134 #define WEATHER_REG_CALIB_TEMPERATURE 0x88
135 #define WEATHER_REG_CALIB_TEMP_1_LSB 0x88
136 #define WEATHER_REG_CALIB_TEMP_1_MSB 0x89
137 #define WEATHER_REG_CALIB_TEMP_2_LSB 0x8A
138 #define WEATHER_REG_CALIB_TEMP_2_MSB 0x8B
139 #define WEATHER_REG_CALIB_TEMP_3_LSB 0x8C
140 #define WEATHER_REG_CALIB_TEMP_3_MSB 0x8D
142 #define WEATHER_REG_CALIB_PRESSURE 0x8E
143 #define WEATHER_REG_CALIB_PRESS_1_LSB 0x8E
144 #define WEATHER_REG_CALIB_PRESS_1_MSB 0x8F
145 #define WEATHER_REG_CALIB_PRESS_2_LSB 0x90
146 #define WEATHER_REG_CALIB_PRESS_2_MSB 0x91
147 #define WEATHER_REG_CALIB_PRESS_3_LSB 0x92
148 #define WEATHER_REG_CALIB_PRESS_3_MSB 0x93
149 #define WEATHER_REG_CALIB_PRESS_4_LSB 0x94
150 #define WEATHER_REG_CALIB_PRESS_4_MSB 0x95
151 #define WEATHER_REG_CALIB_PRESS_5_LSB 0x96
152 #define WEATHER_REG_CALIB_PRESS_5_MSB 0x97
153 #define WEATHER_REG_CALIB_PRESS_6_LSB 0x98
154 #define WEATHER_REG_CALIB_PRESS_6_MSB 0x99
155 #define WEATHER_REG_CALIB_PRESS_7_LSB 0x9A
156 #define WEATHER_REG_CALIB_PRESS_7_MSB 0x9B
157 #define WEATHER_REG_CALIB_PRESS_8_LSB 0x9C
158 #define WEATHER_REG_CALIB_PRESS_8_MSB 0x9D
159 #define WEATHER_REG_CALIB_PRESS_9_LSB 0x9E
160 #define WEATHER_REG_CALIB_PRESS_9_MSB 0x9F
162 #define WEATHER_REG_CALIB_HUMIDITY 0xA1
163 #define WEATHER_REG_CALIB_HUM_1 0xA1
164 #define WEATHER_REG_CALIB_HUM_2_LSB 0xE1
165 #define WEATHER_REG_CALIB_HUM_2_MSB 0xE2
166 #define WEATHER_REG_CALIB_HUM_3 0xE3
167 #define WEATHER_REG_CALIB_HUM_4_MSB 0xE4
168 #define WEATHER_REG_CALIB_HUM_4_LSB 0xE5
169 #define WEATHER_REG_CALIB_HUM_5_MSB 0xE6
170 #define WEATHER_REG_CALIB_HUM_6 0xE7
177 #define WEATHER_HUM_OS_SKIPPED 0x00
178 #define WEATHER_HUM_OS_1X 0x01
179 #define WEATHER_HUM_OS_2X 0x02
180 #define WEATHER_HUM_OS_4X 0x03
181 #define WEATHER_HUM_OS_8X 0x04
182 #define WEATHER_HUM_OS_16X 0x05
189 #define WEATHER_STATUS_MEASURING 0x08
190 #define WEATHER_STATUS_IM_UPDATE 0x01
197 #define WEATHER_MCTRL_PRESS_OS_SKIPPED 0x00;
198 #define WEATHER_MCTRL_PRESS_OS_1X ( 0x01<<2 )
199 #define WEATHER_MCTRL_PRESS_OS_2X ( 0x02<<2 )
200 #define WEATHER_MCTRL_PRESS_OS_4X ( 0x03<<2 )
201 #define WEATHER_MCTRL_PRESS_OS_8X ( 0x04<<2 )
202 #define WEATHER_MCTRL_PRESS_OS_16X ( 0x05<<2 )
203 #define WEATHER_MCTRL_TEMP_OS_SKIPPED 0x00
204 #define WEATHER_MCTRL_TEMP_OS_1X ( 0x01<<5 )
205 #define WEATHER_MCTRL_TEMP_OS_2X ( 0x02<<5 )
206 #define WEATHER_MCTRL_TEMP_OS_4X ( 0x03<<5 )
207 #define WEATHER_MCTRL_TEMP_OS_8X ( 0x04<<5 )
208 #define WEATHER_MCTRL_TEMP_OS_16X ( 0x05<<5 )
209 #define WEATHER_MCTRL_MODE_SLEEP 0x00
210 #define WEATHER_MCTRL_MODE_FORCED 0x01
211 #define WEATHER_MCTRL_MODE_NORMAL 0x03
218 #define WEATHER_CFG_STANDBY_TIME_0p5ms 0x00
219 #define WEATHER_CFG_STANDBY_TIME_62p5ms ( 0x01<<5 )
220 #define WEATHER_CFG_STANDBY_TIME_125ms ( 0x02<<5 )
221 #define WEATHER_CFG_STANDBY_TIME_250ms ( 0x03<<5 )
222 #define WEATHER_CFG_STANDBY_TIME_500ms ( 0x04<<5 )
223 #define WEATHER_CFG_STANDBY_TIME_1000ms ( 0x05<<5 )
224 #define WEATHER_CFG_STANDBY_TIME_10ms ( 0x06<<5 )
225 #define WEATHER_CFG_STANDBY_TIME_20ms ( 0x07<<5 )
226 #define WEATHER_CFG_FILTER_OFF 0x00
227 #define WEATHER_CFG_FILTER_2 ( 0x01<<2 )
228 #define WEATHER_CFG_FILTER_4 ( 0x02<<2 )
229 #define WEATHER_CFG_FILTER_8 ( 0x03<<2 )
230 #define WEATHER_CFG_FILTER_16 ( 0x04<<2 )
466 #endif // _WEATHER_H_
Definition: weather.h:246
int16_t press_9
Definition: weather.h:267
uint8_t os_press
Definition: weather.h:344
int16_t temp_3
Definition: weather.h:250
err_t weather_generic_read(weather_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
uint8_t hum_1
Definition: weather.h:252
uint8_t standby_time
Definition: weather.h:349
uint16_t temp_1
Definition: weather.h:248
weather_master_io_t write_f
Definition: weather.h:293
int32_t t_fine
Definition: weather.h:269
float pressure
Definition: weather.h:332
float temperature
Definition: weather.h:331
uint8_t os_temp
Definition: weather.h:343
err_t weather_get_ambient_data(weather_t *ctx, weather_data_t *weather_data)
Weather data.
err_t(* weather_master_io_t)(struct weather_s *, uint8_t, uint8_t *, uint8_t)
Master Input/Output type.
Definition: weather.h:243
uint16_t press_1
Definition: weather.h:259
uint32_t i2c_speed
Definition: weather.h:315
int16_t press_8
Definition: weather.h:266
int16_t press_3
Definition: weather.h:261
uint32_t temperature
Definition: weather.h:275
pin_name_t cs
Definition: weather.h:312
pin_name_t sda
Definition: weather.h:308
pin_name_t scl
Definition: weather.h:307
float humidity
Definition: weather.h:333
weather_master_io_t read_f
Definition: weather.h:294
Measurement configuration structure definition.
Definition: weather.h:341
struct weather_s weather_t
Click ctx object definition.
uint8_t i2c_address
Definition: weather.h:316
err_t weather_default_cfg(weather_t *ctx)
Click Default Configuration function.
void weather_cfg_setup(weather_cfg_t *cfg)
Config Object Initialization function.
err_t weather_software_reset(weather_t *ctx)
Software reset function.
uint8_t slave_address
Definition: weather.h:291
i2c_master_t i2c
Definition: weather.h:287
err_t weather_measurement_cfg(weather_t *ctx, weather_measurement_cfg_t *cfg)
Measurement config.
spi_master_mode_t spi_mode
Definition: weather.h:319
pin_name_t chip_select
Definition: weather.h:292
pin_name_t miso
Definition: weather.h:309
spi_master_t spi
Definition: weather.h:288
Click configuration structure definition.
Definition: weather.h:305
int16_t hum_5
Definition: weather.h:256
int16_t press_7
Definition: weather.h:265
uint32_t spi_speed
Definition: weather.h:318
err_t weather_generic_write(weather_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
err_t weather_get_device_id(weather_t *ctx, uint8_t *device_id)
Device ID.
int16_t press_6
Definition: weather.h:264
uint8_t filter
Definition: weather.h:350
spi_master_chip_select_polarity_t cs_polarity
Definition: weather.h:320
weather_digital_data_t calib_params
Definition: weather.h:297
int16_t press_2
Definition: weather.h:260
uint8_t mode
Definition: weather.h:346
uint8_t os_hum
Definition: weather.h:345
err_t weather_init(weather_t *ctx, weather_cfg_t *cfg)
Initialization function.
int16_t hum_2
Definition: weather.h:253
uint32_t humidity
Definition: weather.h:277
uint8_t master_sel
Definition: weather.h:295
uint8_t hum_3
Definition: weather.h:254
Definition: weather.h:274
int16_t hum_4
Definition: weather.h:255
Click ctx object definition.
Definition: weather.h:285
int8_t hum_6
Definition: weather.h:257
uint8_t sel
Definition: weather.h:322
uint32_t pressure
Definition: weather.h:276
Weather data structure definition.
Definition: weather.h:330
int16_t temp_2
Definition: weather.h:249
pin_name_t mosi
Definition: weather.h:310
int16_t press_5
Definition: weather.h:263
int16_t press_4
Definition: weather.h:262
pin_name_t sck
Definition: weather.h:311