42#ifdef PREINIT_SUPPORTED
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
52#include "drv_digital_out.h"
53#include "drv_i2c_master.h"
66#define HTU21D_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
68 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
75#define HTU21D_RETVAL uint8_t
78#define HTU21D_INIT_ERROR 0xFF
86#define HTU21D_I2C_ADDRESS 0x40
93#define HTU21D_USER_REG_WRITE 0xE6
100#define HTU21D_USER_REG_READ 0xE7
107#define HTU21D_HEATER_REG_WRITE 0x51
114#define HTU21D_HEATER_REG_READ 0x11
121#define HTU21D_SOFT_RESET 0xFE
128#define HTU21D_SERIAL1_READ1 0xFA
135#define HTU21D_SERIAL1_READ2 0x0F
142#define HTU21D_SERIAL2_READ1 0xFC
149#define HTU21D_SERIAL2_READ2 0xC9
156#define HTU21D_SI7013_CHIPID 0x0D
163#define HTU21D_SI7020_CHIPID 0x14
170#define HTU21D_SI7021_CHIPID 0x15
177#define HTU21D_CHIPID 0x32
184#define HTU21D_FIRMWARE_READ1 0x84
191#define HTU21D_FIRMWARE_READ2 0xB8
198#define HTU21D_FIRMWARE_V1 0xFF
205#define HTU21D_FIRMWARE_V2 0x20
212#define HTU21D_FORCE_READ_TEMP 0xFE
219#define HTU21D_ERROR 0xFF
226#define HTU21D_RES_RH12_TEMP14 0x00
233#define HTU21D_RES_RH8_TEMP12 0x01
240#define HTU21D_RES_RH10_TEMP13 0x80
247#define HTU21D_RES_RH11_TEMP11 0x81
254#define HTU21D_TRIG_HUMD_MEASURE_HOLD 0xE5
261#define HTU21D_TRIG_HUMD_MEASURE_NOHOLD 0xF5
268#define HTU21D_TRIG_TEMP_MEASURE_HOLD 0xE3
275#define HTU21D_TRIG_TEMP_MEASURE_NOHOLD 0xF3
282#define HTU21D_ON 0x04
289#define HTU21D_OFF 0xFB
296#define HTU21D_CRC8_POLYNOMINAL 0x1310
303#define HTU21D_DATA_FILTER 0xFFFC
304#define HTU21D_DATA_RESOLUTION 65536.0
305#define HTU21D_TEMP_CALC_COEF 175.72
306#define HTU21D_TEMP_STB_COEF -46.85
307#define HTU21D_HUMI_CALC_COEF 125.0
308#define HTU21D_HUMI_STB_COEF 6.0
359 // End constants group
367 // End variable group
#define HTU21D_RETVAL
Definition htu21d.h:75
uint32_t htu21d_read_data(htu21d_t *ctx, uint8_t reg_adr)
Generic read 24-bit data function.
HTU21D_RETVAL htu21d_init(htu21d_t *ctx, htu21d_cfg_t *cfg)
Initialization function.
void htu21d_generic_read(htu21d_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
float htu21d_get_temperature(htu21d_t *ctx)
Get temperature value function.
float htu21d_get_humidity(htu21d_t *ctx)
Get humidity value function.
void htu21d_generic_write(htu21d_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
void htu21d_cfg_setup(htu21d_cfg_t *cfg)
Config Object Initialization function.
void htu21d_send_cmd(htu21d_t *ctx, uint8_t cmd_byte)
Send command function.
Click configuration structure definition.
Definition htu21d.h:337
uint32_t i2c_speed
Definition htu21d.h:345
pin_name_t scl
Definition htu21d.h:340
pin_name_t sda
Definition htu21d.h:341
uint8_t i2c_address
Definition htu21d.h:346
Click ctx object definition.
Definition htu21d.h:322
i2c_master_t i2c
Definition htu21d.h:325
uint8_t slave_address
Definition htu21d.h:329