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 PHT_RH_CMD_RESET 0xFE
74#define PHT_RH_CMD_WRITE_USER_REG 0xE6
75#define PHT_RH_CMD_READ_USER_REG 0xE7
76#define PHT_RH_MEASURE_RH_HOLD 0xE5
77#define PHT_RH_MEASURE_RH_NO_HOLD 0xF5
83#define PHT_PT_CMD_RESET 0x1E
84#define PHT_PT_CMD_ADC_READ 0x00
85#define PHT_PT_CMD_PROM_READ_P_T_START 0xA0
86#define PHT_PT_CMD_PROM_READ_P_T_END 0xAE
88#define PHT_PT_CMD_RATIO_256 0x00
89#define PHT_PT_CMD_RATIO_512 0x01
90#define PHT_PT_CMD_RATIO_1024 0x02
91#define PHT_PT_CMD_RATIO_2048 0x03
92#define PHT_PT_CMD_RATIO_4096 0x04
93#define PHT_PT_CMD_RATIO_8192 0x05
99#define PHT_PT_MANUFACTURER_RESERVED 0x00
100#define PHT_PT_C1_SENS 0x01
101#define PHT_PT_C2_OFF 0x02
102#define PHT_PT_C3_TCS 0x03
103#define PHT_PT_C4_TCO 0x04
104#define PHT_PT_C5_TREF 0x05
105#define PHT_PT_C6_TEMPSENS 0x06
106#define PHT_PT_CRC 0x07
112#define PHT_SENSOR_TYPE_RH 0x00
113#define PHT_SENSOR_TYPE_PT 0x01
120#define PHT_I2C_SLAVE_ADDR_RH 0x40
121#define PHT_I2C_SLAVE_ADDR_P_AND_T 0x76
140#define PHT_MAP_MIKROBUS( cfg, mikrobus ) \
141 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
142 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
void pht_get_temperature_pressure(pht_t *ctx, float *temperature, float *pressure)
Get temperature and pressure function.
uint8_t pht_read_user_register(pht_t *ctx)
Raed User Register function.
void pht_soft_reset(pht_t *ctx, uint8_t sensor_type)
Soft Reset function.
uint8_t pht_get_prom(pht_t *ctx, uint8_t sel_data, uint32_t *tx_data)
Calibration Data Read function.
void pht_get_relative_humidity(pht_t *ctx, float *humidity)
Get humidity function.
err_t pht_generic_read(pht_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
PHT I2C reading function.
uint8_t pht_set_ratio(pht_t *ctx, uint8_t temp_ratio, uint8_t press_ratio)
Set Ratio function.
err_t pht_init(pht_t *ctx, pht_cfg_t *cfg)
PHT initialization function.
void pht_set_command(pht_t *ctx, uint8_t sensor_type, uint8_t cmd)
Set Command function.
err_t pht_generic_write(pht_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
PHT I2C writing function.
void pht_reset(pht_t *ctx)
Reset function.
uint8_t pht_measure_rh(pht_t *ctx, uint16_t *rh_data)
Measure RH function.
void pht_write_user_register(pht_t *ctx, uint8_t tx_data)
Write User Register function.
void pht_cfg_setup(pht_cfg_t *cfg)
PHT configuration object setup function.
float humidity
Definition main.c:33
float pressure
Definition main.c:32
float temperature
Definition main.c:34
pht_return_value_t
PHT Click return value data.
Definition pht.h:180
@ PHT_ERROR
Definition pht.h:182
@ PHT_OK
Definition pht.h:181
PHT Click configuration object.
Definition pht.h:166
uint32_t i2c_speed
Definition pht.h:170
pin_name_t scl
Definition pht.h:167
pin_name_t sda
Definition pht.h:168
uint8_t i2c_address
Definition pht.h:171
PHT Click context object.
Definition pht.h:152
i2c_master_t i2c
Definition pht.h:154
uint8_t slave_address
Definition pht.h:157