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"
66#define TEMPHUM4_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
68 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
69 cfg.ad0 = MIKROBUS( mikrobus, MIKROBUS_RST ); \
70 cfg.ad1 = MIKROBUS( mikrobus, MIKROBUS_CS ); \
71 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
78#define TEMPHUM4_RETVAL uint8_t
80#define TEMPHUM4_OK 0x00
81#define TEMPHUM4_INIT_ERROR 0xFF
88#define TEMPHUM4_MODE_ACTIVE 0x01
89#define TEMPHUM4_MODE_SLEEP 0x00
96#define TEMPHUM4_REG_TEMPERATURE 0x00
97#define TEMPHUM4_REG_HUMINIDY 0x01
98#define TEMPHUM4_REG_CONFIGURATION 0x02
99#define TEMPHUM4_REG_MANUFACTURER_ID 0xFE
100#define TEMPHUM4_REG_DEVICE_ID 0xFF
101#define TEMPHUM4_REG_SERIAL_ID 0xFB
108#define TEMPHUM4_CONF_NORMAL_OPERATION ( 0x00 << 14 )
109#define TEMPHUM4_CONF_SOFT_RESET ( 0x01 << 14 )
110#define TEMPHUM4_CONF_HEATER_DISABLED ( 0x00 << 12 )
111#define TEMPHUM4_CONF_HEATER_ENABLED ( 0x01 << 12 )
112#define TEMPHUM4_CONF_MODE_TEMP_OR_HUM ( 0x00 << 11 )
113#define TEMPHUM4_CONF_MODE_TEMP_AND_HUM ( 0x01 << 11 )
114#define TEMPHUM4_CONF_BATTERY_VOLTAGE_2_8_V ( 0x00 << 10 )
115#define TEMPHUM4_CONF_TEMPERATURE_14bit ( 0x00 << 9 )
116#define TEMPHUM4_CONF_TEMPERATURE_11bit ( 0x01 << 9 )
117#define TEMPHUM4_CONF_HUMINIDY_14bit ( 0x00 << 7 )
118#define TEMPHUM4_CONF_HUMINIDY_11bit ( 0x01 << 7 )
119#define TEMPHUM4_CONF_HUMINIDY_9bit ( 0x02 << 7 )
126#define TEMPHUM4_MANUFACTURER_ID 0x5449
#define TEMPHUM4_RETVAL
Definition temphum4.h:78
void temphum4_set_mode(temphum4_t *ctx, uint8_t value)
Set device mode function.
uint16_t temphum4_get_device_id(temphum4_t *ctx)
Get device id.
float temphum4_get_temperature(temphum4_t *ctx)
Get temperature function.
TEMPHUM4_RETVAL temphum4_init(temphum4_t *ctx, temphum4_cfg_t *cfg)
Initialization function.
void temphum4_configuration(temphum4_t *ctx, uint16_t conf_data)
Set device configuration function.
void temphum4_cfg_setup(temphum4_cfg_t *cfg)
Config Object Initialization function.
void temphum4_generic_write(temphum4_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
float temphum4_get_humidity(temphum4_t *ctx)
Get humidity function.
void temphum4_default_cfg(temphum4_t *ctx)
Click Default Configuration function.
uint16_t temphum4_get_manifacturer_id(temphum4_t *ctx)
Get manufacturer's id.
void temphum4_generic_read(temphum4_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
Click configuration structure definition.
Definition temphum4.h:164
uint32_t i2c_speed
Definition temphum4.h:178
pin_name_t ad1
Definition temphum4.h:173
pin_name_t scl
Definition temphum4.h:167
pin_name_t ad0
Definition temphum4.h:172
pin_name_t int_pin
Definition temphum4.h:174
pin_name_t sda
Definition temphum4.h:168
uint8_t i2c_address
Definition temphum4.h:179
Click ctx object definition.
Definition temphum4.h:140
digital_out_t ad1
Definition temphum4.h:144
digital_out_t ad0
Definition temphum4.h:143
digital_in_t int_pin
Definition temphum4.h:148
i2c_master_t i2c
Definition temphum4.h:152
uint8_t slave_address
Definition temphum4.h:156