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"
73#define TEMPHUM20_REG_PDM_CLIP_HIGH 0x16
74#define TEMPHUM20_REG_PDM_CLIP_LOW 0x17
75#define TEMPHUM20_REG_ALARM_HIGH_ON 0x18
76#define TEMPHUM20_REG_ALARM_HIGH_OFF 0x19
77#define TEMPHUM20_REG_ALARM_LOW_ON 0x1A
78#define TEMPHUM20_REG_ALARM_LOW_OFF 0x1B
79#define TEMPHUM20_REG_CUST_CONFIG 0x1C
80#define TEMPHUM20_REG_RESERVED 0x1D
81#define TEMPHUM20_REG_CUST_ID2 0x1E
82#define TEMPHUM20_REG_CUST_ID3 0x1F
83#define TEMPHUM20_CMD_START_NOM 0x80
84#define TEMPHUM20_CMD_START_CM 0xA0
102#define TEMPHUM20_DATA_RESOLUTION 0x4000
103#define TEMPHUM20_TEMP_MULTIPLIER 165.0
104#define TEMPHUM20_HUM_MULTIPLIER 100.0
105#define TEMPHUM20_TEMP_OFFSET 40.0
111#define TEMPHUM20_STATUS_BITS_MASK 0xC0
112#define TEMPHUM20_STATUS_VALID_DATA 0x00
113#define TEMPHUM20_STATUS_STALE_DATA 0x40
114#define TEMPHUM20_STATUS_COMMAND_MODE 0x80
120#define TEMPHUM20_OPMODE_COMMAND 0x00
121#define TEMPHUM20_OPMODE_NORMAL 0x01
127#define TEMPHUM20_DUMMY 0x0000
134#define TEMPHUM20_SET_DEV_ADDR 0x28
152#define TEMPHUM20_MAP_MIKROBUS( cfg, mikrobus ) \
153 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
154 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
155 cfg.alh = MIKROBUS( mikrobus, MIKROBUS_AN ); \
156 cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
157 cfg.all = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
158 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
err_t temphum20_write_command(temphum20_t *ctx, uint8_t cmd_byte, uint16_t cmd_data)
TempHum 20 write command function.
uint8_t temphum20_get_alarm_high_pin(temphum20_t *ctx)
TempHum 20 get alarm high pin function.
err_t temphum20_init(temphum20_t *ctx, temphum20_cfg_t *cfg)
TempHum 20 initialization function.
err_t temphum20_default_cfg(temphum20_t *ctx)
TempHum 20 default configuration function.
err_t temphum20_set_operating_mode(temphum20_t *ctx, uint8_t op_mode)
TempHum 20 set operating mode function.
void temphum20_reset_device(temphum20_t *ctx)
TempHum 20 reset device function.
err_t temphum20_write_data(temphum20_t *ctx, uint8_t *tx_buf, uint8_t tx_len)
TempHum 20 I2C writing function.
err_t temphum20_get_measurement(temphum20_t *ctx, float *temp, float *hum)
TempHum 20 get measurement function.
err_t temphum20_read_data(temphum20_t *ctx, uint8_t *rx_buf, uint8_t rx_len)
TempHum 20 I2C reading function.
uint8_t temphum20_get_alarm_low_pin(temphum20_t *ctx)
TempHum 20 get alarm low pin function.
uint8_t temphum20_get_int_pin(temphum20_t *ctx)
TempHum 20 get INT pin function.
void temphum20_cfg_setup(temphum20_cfg_t *cfg)
TempHum 20 configuration object setup function.
void temphum20_set_en_pin(temphum20_t *ctx, uint8_t state)
TempHum 20 set EN pin function.
TempHum 20 Click configuration object.
Definition temphum20.h:190
pin_name_t all
Definition temphum20.h:196
uint32_t i2c_speed
Definition temphum20.h:199
pin_name_t alh
Definition temphum20.h:195
pin_name_t scl
Definition temphum20.h:191
pin_name_t en
Definition temphum20.h:194
pin_name_t int_pin
Definition temphum20.h:197
pin_name_t sda
Definition temphum20.h:192
uint8_t i2c_address
Definition temphum20.h:200
TempHum 20 Click context object.
Definition temphum20.h:168
digital_in_t all
Definition temphum20.h:174
digital_in_t int_pin
Definition temphum20.h:175
i2c_master_t i2c
Definition temphum20.h:178
digital_in_t alh
Definition temphum20.h:173
digital_out_t en
Definition temphum20.h:170
uint8_t slave_address
Definition temphum20.h:181
temphum20_return_value_t
TempHum 20 Click return value data.
Definition temphum20.h:209
@ TEMPHUM20_OK
Definition temphum20.h:210
@ TEMPHUM20_ERROR
Definition temphum20.h:211