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 TEMPHUM21_REG_ALARM_HIGH_ON 0x18
74#define TEMPHUM21_REG_ALARM_HIGH_OFF 0x19
75#define TEMPHUM21_REG_ALARM_LOW_ON 0x1A
76#define TEMPHUM21_REG_ALARM_LOW_OFF 0x1B
77#define TEMPHUM21_REG_CUST_CONFIG 0x1C
78#define TEMPHUM21_REG_CUST_ID2 0x1E
79#define TEMPHUM21_REG_CUST_ID3 0x1F
80#define TEMPHUM21_CMD_WRITE_EEPROM 0x40
81#define TEMPHUM21_CMD_START_NOM 0x80
82#define TEMPHUM21_CMD_START_CM 0xA0
100#define TEMPHUM21_STATUS_NORMAL_OP 0x00
101#define TEMPHUM21_STATUS_STALE_DATA 0x40
102#define TEMPHUM21_STATUS_COMMAND_MODE 0x80
103#define TEMPHUM21_STATUS_BIT_MASK 0xC0
104#define TEMPHUM21_DIAGNOSTIC_CORR_EP_ERR 0x04
105#define TEMPHUM21_DIAGNOSTIC_UNCORR_EP_ERR 0x08
106#define TEMPHUM21_DIAGNOSTIC_RAM_PAR_ERR 0x10
107#define TEMPHUM21_DIAGNOSTIC_CONFIG_ERR 0x20
108#define TEMPHUM21_DIAGNOSTIC_BIT_MASK 0x3C
109#define TEMPHUM21_RESPONSE_BUSY 0x00
110#define TEMPHUM21_RESPONSE_ACK 0x01
111#define TEMPHUM21_RESPONSE_NACK 0x02
112#define TEMPHUM21_RESPONSE_BIT_MASK 0x03
118#define TEMPHUM21_DATA_RES 0x3FFF
119#define TEMPHUM21_TEMP_RES 165.0
120#define TEMPHUM21_TEMP_OFFSET 40.0
121#define TEMPHUM21_HUM_RES 100.0
127#define TEMPHUM21_ALARM_HIGH_ON_80PCT 0x3333
128#define TEMPHUM21_ALARM_HIGH_OFF_75PCT 0x3000
129#define TEMPHUM21_ALARM_LOW_ON_20PCT 0x0CCD
130#define TEMPHUM21_ALARM_LOW_OFF_25PCT 0x1000
137#define TEMPHUM21_SET_DEV_ADDR 0x27
155#define TEMPHUM21_MAP_MIKROBUS( cfg, mikrobus ) \
156 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
157 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
158 cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
159 cfg.all = MIKROBUS( mikrobus, MIKROBUS_AN ); \
160 cfg.alh = MIKROBUS( mikrobus, MIKROBUS_INT )
uint8_t temphum21_get_alh_pin(temphum21_t *ctx)
TempHum 21 get alh pin function.
void temphum21_cfg_setup(temphum21_cfg_t *cfg)
TempHum 21 configuration object setup function.
err_t temphum21_default_cfg(temphum21_t *ctx)
TempHum 21 default configuration function.
err_t temphum21_init(temphum21_t *ctx, temphum21_cfg_t *cfg)
TempHum 21 initialization function.
void temphum21_disable_device(temphum21_t *ctx)
TempHum 21 disable device function.
err_t temphum21_eeprom_write(temphum21_t *ctx, uint8_t address, uint16_t data_in)
TempHum 21 eeprom write function.
err_t temphum21_request_measurement(temphum21_t *ctx)
TempHum 21 request measurement function.
err_t temphum21_eeprom_read(temphum21_t *ctx, uint8_t address, uint8_t *status, uint16_t *data_out)
TempHum 21 eeprom read function.
err_t temphum21_read_measurement(temphum21_t *ctx, float *temperature, float *humidity)
TempHum 21 read measurement function.
uint8_t temphum21_get_all_pin(temphum21_t *ctx)
TempHum 21 get all pin function.
void temphum21_enable_device(temphum21_t *ctx)
TempHum 21 enable device function.
err_t temphum21_exit_command_mode(temphum21_t *ctx)
TempHum 21 exit command mode function.
err_t temphum21_enter_command_mode(temphum21_t *ctx)
TempHum 21 enter command mode function.
TempHum 21 Click configuration object.
Definition temphum21.h:191
pin_name_t all
Definition temphum21.h:196
uint32_t i2c_speed
Definition temphum21.h:199
pin_name_t alh
Definition temphum21.h:197
pin_name_t scl
Definition temphum21.h:192
pin_name_t en
Definition temphum21.h:195
pin_name_t sda
Definition temphum21.h:193
uint8_t i2c_address
Definition temphum21.h:200
TempHum 21 Click context object.
Definition temphum21.h:170
digital_in_t all
Definition temphum21.h:175
i2c_master_t i2c
Definition temphum21.h:179
digital_in_t alh
Definition temphum21.h:176
digital_out_t en
Definition temphum21.h:172
uint8_t slave_address
Definition temphum21.h:182
temphum21_return_value_t
TempHum 21 Click return value data.
Definition temphum21.h:209
@ TEMPHUM21_ERROR
Definition temphum21.h:211
@ TEMPHUM21_OK
Definition temphum21.h:210