Go to the documentation of this file.
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"
67 #define THERMOSTAT_MAP_MIKROBUS( cfg, mikrobus ) \
68 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
69 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
70 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
71 cfg.te = MIKROBUS( mikrobus, MIKROBUS_CS )
78 #define THERMOSTAT_RETVAL uint8_t
80 #define THERMOSTAT_OK 0x00
81 #define THERMOSTAT_INIT_ERROR 0xFF
88 #define THERMOSTAT_I2C_ADDRESS_0 0x48
89 #define THERMOSTAT_I2C_ADDRESS_1 0x49
90 #define THERMOSTAT_I2C_ADDRESS_2 0x4A
91 #define THERMOSTAT_I2C_ADDRESS_3 0x4B
98 #define THERMOSTAT_REG_TEMP_OUT 0x00
99 #define THERMOSTAT_REG_CONFIG 0x01
100 #define THERMOSTAT_REG_TEMP_HYST 0x02
101 #define THERMOSTAT_REG_TEMP_REF 0x03
103 #define THERMOSTAT_CHECK_SIGN 0x80
104 #define THERMOSTAT_DEFAULT_CONFIG 0x0000
105 #define THERMOSTAT_MSB_BITS 0xFF00
106 #define THERMOSTAT_LSB_BITS 0x00FF
107 #define THERMOSTAT_START_RESULT 0x0000
109 #define THERMOSTAT_UPPER_LIMITS_TEMP 126.00
110 #define THERMOSTAT_LOWER_LIMITS_TEMP -55.00
111 #define THERMOSTAT_CALCULATE_COEF_MULT 1.8000
112 #define THERMOSTAT_CALCULATE_COEF_PLUS 32.000
340 #endif // _THERMOSTAT_H_
pin_name_t scl
Definition: thermostat.h:149
float thermostat_convert_fahrenheit(thermostat_t *ctx, float temp_celsius)
Convert temperature in degrees Celsius to Fahrenheit.
pin_name_t te
Definition: thermostat.h:155
void thermostat_set_configuration(thermostat_t *ctx, uint16_t config_value)
Set configuration function.
uint32_t i2c_speed
Definition: thermostat.h:159
#define THERMOSTAT_RETVAL
Definition: thermostat.h:78
uint8_t i2c_address
Definition: thermostat.h:160
void thermostat_enable(thermostat_t *ctx)
Thermostat enabled function.
void thermostat_cfg_setup(thermostat_cfg_t *cfg)
Config Object Initialization function.
THERMOSTAT_RETVAL thermostat_init(thermostat_t *ctx, thermostat_cfg_t *cfg)
Initialization function.
float thermostat_get_temperature(thermostat_t *ctx)
Get temperature in degrees Celsius.
Click ctx object definition.
Definition: thermostat.h:126
uint8_t slave_address
Definition: thermostat.h:138
void thermostat_switch_off(thermostat_t *ctx)
Set off thermal switch function.
void thermostat_soft_reset(thermostat_t *ctx)
Soft reset function.
void thermostat_write_data(thermostat_t *ctx, uint8_t reg_address, uint16_t write_data)
Generic write 16-bit data function.
digital_out_t te
Definition: thermostat.h:130
digital_out_t rst
Definition: thermostat.h:129
void thermostat_set_temp_ref(thermostat_t *ctx, int8_t temp_ref)
Set referent temperature function.
void thermostat_generic_write(thermostat_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
pin_name_t sda
Definition: thermostat.h:150
uint16_t thermostat_read_data(thermostat_t *ctx, uint8_t reg_address)
Generic read 16-bit data function.
void thermostat_switch_on(thermostat_t *ctx)
Set on thermal switch function.
void thermostat_set_temp_hyst(thermostat_t *ctx, int8_t temp_hyst)
Set temperature hysterezis function.
void thermostat_disable(thermostat_t *ctx)
Thermostat disabled function.
pin_name_t rst
Definition: thermostat.h:154
i2c_master_t i2c
Definition: thermostat.h:134
void thermostat_generic_read(thermostat_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
Click configuration structure definition.
Definition: thermostat.h:146